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, and the ndk-build parameter NDK_DEBUG=1.
The ndk-gdb script runs with out issues and launches GDB. When do a "sharedlibrary" command, I get this:
Symbols already loaded for /bla/bla/libMySharedLib.so
However when I try breaking execution or e.g. adding a segfault to test, I never get any of the symbols from that library in the call stack. The only symbols I've gotten are from libc, if I break execution while it's waiting for a mutex for instance. Also tried adding breakpoints with no luck. GDB lets me add the breakpoints, and the code runs fine, but the breakpoints are never triggered.
I'm using API level 8 as I need to support Android 2.2 (Froyo).
Use the run command to start your program under GDB. You must first specify the program name (except on VxWorks) with an argument to GDB (see section Getting In and Out of GDB), or by using the file or exec-file command (see section Commands to specify files).
The NDK itself invokes a customized cross-compiler built on the arm-eabi-gcc compiler.
You don't need to use -O0 or -g switches. You need to do one of following:
android:debuggable="true"
to the <application>
tag in AndroidManifest.xml
fileNDK_DEBUG=1
after ndk-buildAPP_OPTIM := debug
in Application.mk fileDoing 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:
gdbserver
file to /data/local
folder on deviceadb shell
following command gdbserver :5055 --attach PID
, where PID is your application process id.adb forward tcp:5055 tcp:5055
on hostarm-linux-androideabi-gdb.exe
from your app folder set solib-search-path obj/local/armeabi
file obj/local/armeabi/libMySharedLib.so
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With