Many netizens may have such doubts: the upper layer of my program is Java code and the lower layer is written in C/C ++. How can I debug it?
The first thing we think of is ndk-GDB. ndk is provided by Google for native code development. ndk-GDB is used to debug native code. We also know that eclipse is used to debug Java code, and it cannot directly debug native code. If you can combine the two to debug Java code using eclipse and ndk-GDB, it would be better.
Next we will introduce how to perform joint debugging.
1. Prepare ndk_r4, SDK 2.2, eclipse, and ant
2. I made some modifications to the hello-JNI code. Refer to the attachment code.
3. shell enters ndk/samples/
Run Android update project -- path hello-JNI
Enter ndk/samples/Hello-JNI
Run ndk-build
Run ant debug
Start the android simulator (which can be started from eclipse)
Run ADB install bin/HelloJni-debug.apk
4. Use eclipse to create an android project named hellojni. Copy all the files under ndk/samples/Hello-JNI to the directory where the Eclipse project is located, and compile
5. Start ndk-GDB in Shell
6. set breakpoints in the hello-jni.c and execute B 30 in the shell
7. Execute continue in Shell
8. Open Eclipse/ddms, find hello-JNI, and click attach.
9. Set a breakpoint in the Java program of eclipse
10. button in the dot Simulator
11. The Code breakpoint in eclipse Java is hit
12. Eclipse point continnue, ndk-GDB command line can see that the hello-jni.c breakpoint is hit
From: http://www.devdiv.com/thread-32770-1-1.html