Use Eclipse/ndk-GDB for Java/native code joint debugging

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.