How to get ndk-gdb working on Android?

前端 未结 1 1472
梦毁少年i
梦毁少年i 2020-11-28 18:57

I\'m trying to get the NDK debugger working but with no success so far.

To make sure my debug symbols are present and valid, I use the compiler options -O0 and -g, a

相关标签:
1条回答
  • 2020-11-28 19:47

    You don't need to use -O0 or -g switches. You need to do one of following:

    1. put android:debuggable="true" to the <application> tag in AndroidManifest.xml file
    2. use NDK_DEBUG=1 after ndk-build
    3. put APP_OPTIM := debug in Application.mk file

    Doing anyone of these three things will automatically use -O0 and -g switches.

    Can you try running gdb manually, without gdb script? It involves following steps:

    1. pushing gdbserver file to /data/local folder on device
    2. running your application & invoking in adb shell following command gdbserver :5055 --attach PID, where PID is your application process id.
    3. running adb forward tcp:5055 tcp:5055 on host
    4. running arm-linux-androideabi-gdb.exe from your app folder
    5. entering following commands in gdb
    6. set solib-search-path obj/local/armeabi
    7. file obj/local/armeabi/libMySharedLib.so
    8. target remote :5055

    And see if you can debug then.

    If you want see symbols for other shared libraries your library is using like libc.so, then pull them from device (from /system/lib folder) to your obj/local/armeabi folder.

    0 讨论(0)
提交回复
热议问题