Reputation: 1467
I am trying to debug a multi-threaded Android app on a 2.3.6 device using NDK r6b. I've also tried using NDK r8 with the same result. Whenever I hit my breakpoint, the app crashes. I seem to be getting into a case that is described in the NDK r5b docs in the "Thread support" section:
What this means in practical terms are: - If you are on Android 2.3, or a prior platform release which has had the platform bugfix back-ported to it, you will be able to debug native threads automatically. - If you are not, you will only be able to debug the main thread (as in previous NDK releases). You will also see the following message when launching ndk-gdb (just before the gdb prompt): Thread debugging is unsupported on this Android platform! If you place a breakpoint on a function executed on a non-main thread, the program will exit with the following message in GDB: Program terminated with signal SIGTRAP, Trace/breakpoint trap. The program no longer exists.
I get the exact error mentioned. I believe I am getting into this case because I see Thread debugging is unsupported on this Android platform!
when I run ndk-gdb. As I mentioned, I am on a Gingerbread device and I have <uses-sdk android:minSdkVersion="9" android:targetSdkVersion="9"/>
in the manifest so I should NOT be getting into this case.
Here is more detail about the steps I follow to get to the crash:
See below for an edited console dump.
I'd appreciate any feedback on why this could be happening!
$ ndk-gdb --force --verbose --start Android NDK installation path: /Users/tony/Documents/android-ndk-r8 Using default adb command: /Users/tony/Documents/android-sdk-mac_86/platform-tools/adb ADB version found: Android Debug Bridge version 1.0.29 Using ADB flags: Using auto-detected project path: . Found package name: com.mycompany.myapp ABIs targetted by application: armeabi Device API Level: 10 Device CPU ABIs: armeabi-v7a armeabi Compatible device ABI: armeabi Using gdb setup init: ./libs/armeabi/gdb.setup Using toolchain prefix: /Users/tony/Documents/android-ndk-r8/toolchains/arm-linux-androideabi-4.4.3/prebuilt/darwin-x86/bin/arm-linux-androideabi- Using app out directory: ./obj/local/armeabi Found debuggable flag: true Found device gdbserver: /data/data/com.appMobi.applab/lib/gdbserver Found data directory: '/data/data/com.mycompany.myapp' Found first launchable activity: .MainActivity Launching activity: com.mycompany.myapp/.MainActivity ## COMMAND: /Users/tony/Documents/android-sdk-mac_86/platform-tools/adb shell am start -n com.mycompany.myapp/.MainActivity Starting: Intent { cmp=com.mycompany.myapp/.MainActivity } Warning: Activity not started, intent has been delivered to currently running top-most instance. ## COMMAND: /Users/tony/Documents/android-sdk-mac_86/platform-tools/adb shell sleep 2 Found running PID: 7341 Launched gdbserver succesfully. Setup network redirection ## COMMAND: /Users/tony/Documents/android-sdk-mac_86/platform-tools/adb forward tcp:5039 localfilesystem:/data/data/com.mycompany.myapp/debug-socket ## COMMAND: /Users/tony/Documents/android-sdk-mac_86/platform-tools/adb shell run-as com.appMobi.applab lib/gdbserver +debug-socket --attach 7341 ## COMMAND: /Users/tony/Documents/android-sdk-mac_86/platform-tools/adb pull /system/bin/app_process ./obj/local/armeabi/app_process Attached; pid = 7341 Listening on sockaddr socket debug-socket 184 KB/s (5720 bytes in 0.030s) Pulled app_process from device/emulator. ## COMMAND: /Users/tony/Documents/android-sdk-mac_86/platform-tools/adb pull /system/lib/libc.so ./obj/local/armeabi/libc.so 4347 KB/s (273940 bytes in 0.061s) Pulled libc.so from device/emulator. GNU gdb 6.6 Copyright (C) 2006 Free Software Foundation, Inc. GDB is free software, covered by the GNU General Public License, and you are welcome to change it and/or distribute copies of it under certain conditions. Type "show copying" to see the conditions. There is absolutely no warranty for GDB. Type "show warranty" for details. This GDB was configured as "--host=x86_64-apple-darwin --target=arm-elf-linux". (no debugging symbols found) Error while mapping shared library sections: ...shared library mapping errors ommitted... Thread debugging is unsupported on this Android platform! Thread debugging is unsupported on this Android platform! warning: Unable to find dynamic linker breakpoint function. GDB will be unable to debug shared library initializers and track explicitly loaded dynamic code. warning: shared library handler failed to enable breakpoint 0xafd0c5ac in epoll_wait () from /Developer/AppMobiAndroid/AppLab/obj/local/armeabi/libc.so Thread debugging is unsupported on this Android platform! (gdb) break dcanvas.cpp:544 Breakpoint 1 at 0x81833c8a: file /Developer/AppMobiAndroid/AppLab/jni/dcanvas.cpp, line 544. (gdb) c Continuing. Child terminated with signal = 5 Program terminated with signal SIGTRAP, Trace/breakpoint trap. The program no longer exists. (gdb) Child terminated with signal = 0x5 (SIGTRAP) GDBserver exiting
Upvotes: 2
Views: 2230
Reputation: 34592
I am suspecting the reason that its crashing when hitting the breakpoint is down to the version of the bionic
lib that comes with Android 2.3.6 version. More than likely, the library is not able to support threading or is broken.
bionic
lib is the core runtime library that provides native standard C code API's for the Android platform. If you can think of glibc
, you're not far off the mark there.
The best you can do instead is, to modify your native code and spam the logcat to see the paths taken during execution and do away with it.
Upvotes: 0