You don’t need to use -O0 or -g switches.
You need to do one of following:
- put
android:debuggable="true"to the<application>tag inAndroidManifest.xmlfile - use
NDK_DEBUG=1after ndk-build - put
APP_OPTIM := debugin 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:
- pushing
gdbserverfile to/data/localfolder on device - running your application & invoking in
adb shellfollowing commandgdbserver :5055 --attach PID, where PID is your application process id. - running
adb forward tcp:5055 tcp:5055on host - running
arm-linux-androideabi-gdb.exefrom your app folder - entering following commands in gdb
set solib-search-path obj/local/armeabifile obj/local/armeabi/libMySharedLib.sotarget 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.