Remote debugging Android native program with GDB

Source: Internet
Author: User

Last time wrote a few native program, think how to debug, after a while search and test, finally finished. There are several key points:

1 gdb and Gdbserver because these two need to be matched, it is recommended to use GDB and Gdbserver under the same NDK
Gdbserver is in Android-ndk-r9\prebuilt\android-arm\gdbserver this directory gdb is in android-ndk-r9\toolchains\ In the Arm-linux-androideabi-4.8\prebuilt\windows-x86_64\bin directory, the name is Arm-linux-androideabi-gdb.exe2 and the Gdbserver is installed to the device System/bin under ADB push gdbserver/system/bin/adb shell chmod u+x/system/bin/gdbserver3 Debug to compile the program specifically, is Ndk-build ndk_ Debug=1 can debug the program in the.  \obj\local\armeabi directory, starting program adb push hello/data/local/tmp/adb shell chmod u+x/data/local/tmp/hellogdbserver relative to JNI directory 4 : 8123/data/local/tmp/hello5 start GdB to start debugging adb forward tcp:1234 tcp:8123 set adb forwarding arm-linux-androideabi-gdb (gdb) file. /obj/local/armeabi/sum Load Debugger (GDB) target remote:1234 Description Remote Debug Object (GDB) list Display code (GDB) Break main set Breakpoint (GDB) Cont continue to run 6 Summary because GDB originally supported remote debugging, when starting Gdbserver, specify the local debugging port, but because the device is connected through ADB, so the designated ADB to do the transfer, after the device starts debugging, wait for gdb to connect debugging, so GDB started, specify the local port, Load the code, and then you can debug the

Remote debugging Android native program with GDB

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.