0

Platform is Mac, Using NDK r11b, my application consists of around 8 c/c++ so files. In the past I've used ndk-gdb (sh) script via NDK r10e. the shell script is now deprecated and ndk-gdb.py is now the only option. Problem is I can't get it to work. I'm running it from my project folder as I've always done. I've tried multiple command line options with no luck. It feels like it isn't finding my source files. It launches the application with the "Waiting for Debugger". I get to the (gdb) prompt. I've tried adding breakpoints with no luck breaking at reliable interrupt points. I need some pointers as to how to configure and use the python version for ndk-gdb. Google has removed the documentation files and I can't find anything anywhere that suffices as a guide.

Some command lines I've tried.

ndk-gdb --launch --verbose This launches the application but blocks on Waiting for debugger

ndk-gdb will attach to a running process. ctr-c will pause the execution but a back trace bt lists a corrupt stack.

ndk-gdb --launch -t -v -p $ProjectDir I get a new interface I'm not familiar with and it states [ No Source Available ]

Any help or insight would be appreciated

rabidcat
  • 45
  • 6

2 Answers2

0

Same story for me - I was able to get past "Waiting for Debugger" message for a new debugging session by issuing ndk-gdb --launch --force --nowait but still ndk-gdb doesn't work well even with Google's NDK samples. Only info thread command produces the actual result except of stack traces - bt, info stack and others complaints on the corrupt stack. My target device is Nexus 5 running API 23 with latest updates. The same binaries compiled by NDK r11b could be successfully debugged by GDB 7.7 from a previous NDK r10e. On Windows, ndk-gdb.py fails with the following error message:

Traceback (most recent call last): File "F:\work\android-ndk-r11b\prebuilt\windows\bin\ndk-gdb.py", line 704, in <module> main() File "F:\work\android-ndk-r11b\prebuilt\windows\bin\ndk-gdb.py", line 583, in main args.props = device.get_props() File "F:\work\android-ndk-r11b\python-packages\adb\device.py", line 459, in get_props raise RuntimeError('invalid getprop line: "{}"'.format(line)) RuntimeError: invalid getprop line: ""

Actually, it looks like ndk-gdb.py from NDK r11b only works on Linux:

vagrant@vagrant:/vagrant/native_activity$ $ANDROID_NDK_ROOT/ndk-gdb --launch --force WARNING: Failed to find jdb on your path, defaulting to --nowait Redirecting gdbclient output to /tmp/gdbclient-9150 GNU gdb (GDB) 7.10 ... This GDB was configured as "x86_64-linux-gnu". ... warning: Could not load shared library symbols for 110 libraries, e.g. /system/lib/libcutils.so. Use the "info sharedlibrary" command to see the complete listing. Do you need "set solib-search-path" or "set sysroot"? 0xb6c93894 in __epoll_pwait () from /vagrant/native_activity/obj/local/armeabi-v7a/system/lib/libc.so (gdb) info sources Source files for which symbols have been read in: Source files for which symbols will be read in on demand: /Volumes/Android/buildbot/tmp/build/toolchain/gcc-4.9/gcc/include/unwind-arm-common.h, /Volumes/Android/buildbot/src/android/gcc/toolchain/build/../gcc/gcc-4.9/libgcc/config/arm/pr-support.c, /Volumes/Android/buildbot/src/android/gcc/toolchain/build/../gcc/gcc-4.9/libgcc/config/arm/libunwind.S, /Volumes/Android/buildbot/tmp/build/toolchain/gcc-4.9/arm-linux-androideabi/armv7-a/libgcc/./unwind.h, /Volumes/Android/buildbot/src/android/gcc/toolchain/build/../gcc/gcc-4.9/libgcc/unwind-arm-common.inc, /Volumes/Android/buildbot/src/android/gcc/toolchain/build/../gcc/gcc-4.9/libgcc/config/arm/unwind-arm.c, /Users/mike/android-ndk-r11b/sources/android/native_app_glue/android_native_app_glue.c, /vagrant/native_activity/jni/main.c

Basic commands is working correctly:

(gdb) bt #0 0xb6c93894 in __epoll_pwait () from /vagrant/native_activity/obj/local/armeabi-v7a/system/lib/libc.so #1 0xb6c6ce72 in epoll_pwait () from /vagrant/native_activity/obj/local/armeabi-v7a/system/lib/libc.so #2 0xb6c6ce80 in epoll_wait () from /vagrant/native_activity/obj/local/armeabi-v7a/system/lib/libc.so #3 0xb6ebfc5a in ?? () Backtrace stopped: previous frame identical to this frame (corrupt stack?) (gdb) info thread Id Target Id Frame 11 Thread 28735 0xb6c6a5e4 in syscall () from /vagrant/native_activity/obj/local/armeabi-v7a/system/lib/libc.so 10 Thread 28733 0xb6c93894 in __epoll_pwait () from /vagrant/native_activity/obj/local/armeabi-v7a/system/lib/libc.so 9 Thread 28721 0xb6c939bc in __ioctl () from /vagrant/native_activity/obj/local/armeabi-v7a/system/lib/libc.so 8 Thread 28720 0xb6c939bc in __ioctl () from /vagrant/native_activity/obj/local/armeabi-v7a/system/lib/libc.so 7 Thread 28719 0xb6c6a5e4 in syscall () from /vagrant/native_activity/obj/local/armeabi-v7a/system/lib/libc.so 6 Thread 28718 0xb6c6a5e4 in syscall () from /vagrant/native_activity/obj/local/armeabi-v7a/system/lib/libc.so 5 Thread 28717 0xb6c6a5e4 in syscall () from /vagrant/native_activity/obj/local/armeabi-v7a/system/lib/libc.so 4 Thread 28716 0xb6c6a5e4 in syscall () from /vagrant/native_activity/obj/local/armeabi-v7a/system/lib/libc.so 3 Thread 28715 0xb6c94948 in recvmsg () from /vagrant/native_activity/obj/local/armeabi-v7a/system/lib/libc.so 2 Thread 28714 0xb6c93b68 in __rt_sigtimedwait () from /vagrant/native_activity/obj/local/armeabi-v7a/system/lib/libc.so * 1 Thread 28709 0xb6c93894 in __epoll_pwait () from /vagrant/native_activity/obj/local/armeabi-v7a/system/lib/libc.so

  • changing over to linux is not an option for me unfortunately but thank you for the validation that I'm not the only one on planet earth suffering from this. appreciate the solidarity :) – rabidcat Mar 23 '16 at 21:15
  • Let's make an issue at NDK GitHub repo then. – Mikhail Filimonov Mar 24 '16 at 05:07
  • I'm not finding the NDK GitHub repo. The closest I can see is for the Samples but I don't think that is the right forum for the actual NDK issues. – rabidcat Mar 24 '16 at 23:48
  • Thanks Mikhail, I submitted the issue to GitHub this morning – rabidcat Mar 28 '16 at 15:42
0

This issue was posted to the https://github.com/android-ndk/ndk/issues site that Mikhail provided. The issue was assigned and claimed fixed: Resolution will be propagated in NDK r11c;

https://github.com/android-ndk/ndk/issues/51

additionally I updated to R11c. everything is now working

rabidcat
  • 45
  • 6