How to debug local C ++ code using JNI in eclipse

Source: Internet
Author: User

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




Then there is the conventional GDB debugging command.
List-display code
X-view memory
P-view Variables
B-set breakpoints
Cont-program continues to run
S-one-step execution, but can be tracked into the function
N-one-step execution, but does not enter the Function

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.