Address: http://blog.csdn.net/ariesjzj/article/details/7402832
In AndroidProgramMost of them are written in Java and run in Dalvik, but they are mixed with native C Code (for example, from JNI calls or from the Android operating system itself ). This causes the control flow to jump between the Java and C contexts during program execution. We usually use GDB to call the C program and jdb to call the Java program, therefore, we can use the dual-debugger method to debug applications in Android.
Step 1: Use the wait for debugger feature (http://blog.csdn.net/ariesjzj/article/details/7393573) in Dev tools to stop the program as soon as it is started so that we can set breakpoints. You can also manuallyCodeWaitfordebugger ().
Step 2 set GDB (http://blog.csdn.net/ariesjzj/article/details/7375048), GDB should be stopped in a wait function after startup, then you can set a breakpoint or something, after the input
(GDB) cont
Run the program. Otherwise, the jdb cannot attach.
Step 3 set jdb (http://blog.csdn.net/ariesjzj/article/details/7399249), after jdb is started and attach is successful, the application starts to run (if wait for debugger is set in front ). Then, both debuggers can control the configuration. Of course, just like using both the software debugger and hardware debugger, the program won't run unless both of them run.