Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

attaching to android native app with gdb closes app on device

I am attempting to debug my native app compiled with ndk-r6. When I attempt to run ndk-gdb to attach the debugger to the process, the app quits on the device. I am stumped. Can anyone shed some light on this for me please?

Here is a log of a run of the gdb process: http://pastebin.com/qTCR7mF2

This is all I get out of logcat:

I/ActivityManager(10006): Process com.gmail.whittock.tom.clockwork (pid 11460) has died.
I/WindowManager(10006): WIN DEATH: Window{4083aa18 com.gmail.whittock.tom.clockwork/com.gmail.whittock.tom.Util.NativeActivity paused=false}
I/WindowManager(10006): WIN DEATH: Window{4085d8d0 SurfaceView paused=false}
I/WindowManager(10006): Setting rotation to 0, animFlags=1
I/ActivityManager(10006): Config changed: { scale=1.0 imsi=234/10 loc=en_GB touch=3 keys=1/1/2 nav=1/1 orien=1 layout=34 uiMode=17 seq=31 themeResource=null}

EDIT:

and this is my gdb.setup file:

$ cat libs/armeabi-v7a/gdb.setup
set solib-search-path C:/Users/Tom/dev/android/Clockwork/obj/local/armeabi-v7a
directory C:/Users/Tom/dev/android/ANDROI~2/platforms/android-5/arch-arm/usr/include C:/Users/Tom/dev/android/ANDROI~2/sources/cxx-stl/stlport/stlport C:/Users/Tom/dev/android/ANDROI~2/sources/cxx-stl/system/include C:/Users/Tom/dev/android/modules/box2d C:/Users/Tom/dev/android/Clockwork/jni

all paths in there look correct to me, but perhaps it's the use of the dos-compatibility versions of filenames that's causing the issue?!

EDIT2: This is the other gdb.setup file:

$ cat obj/local/armeabi-v7a/gdb.setup 
file C:/Users/Tom/dev/android/Clockwork/obj/local/armeabi-v7a/app_process
target remote :5039
file C:/Users/Tom/dev/android/Clockwork/obj/local/armeabi-v7a/app_process
target remote :5039
file C:/Users/Tom/dev/android/Clockwork/obj/local/armeabi-v7a/app_process
target remote :5039
like image 499
Tom Whittock Avatar asked Nov 13 '22 14:11

Tom Whittock


1 Answers

I finally found the issue.

ndk-gdb HAS HAS HAS to have NDK_DEBUG=1 environment variable set, otherwise the NDK_APP_GDBSETUP variable gets set to blank due to make believing that the app isn't debuggable (being too damn smart for its own good)

This then causes the gdb.setup file to get corrupted, because a copy command fails and we start appending to the end of anything that is already there. This is why the same command pair is repeated 3 times in obj/local.../gdb.setup.

You have no idea how much pain this has caused me. Hopefully someone else will have an easier time if they read this.

like image 102
Tom Whittock Avatar answered Jan 23 '23 10:01

Tom Whittock