对我来说同样的故事 - 我能够通过发出“等待调试器”消息来进行新的调试会话,ndk-gdb --launch --force --nowait
但即使使用 Google 的 NDK 示例,ndk-gdb 仍然无法正常工作。除了堆栈跟踪 -和其他有关损坏堆栈的投诉外,只有info thread
命令会产生实际结果。我的目标设备是运行最新更新的 API 23 的 Nexus 5。由 NDK r11b 编译的相同二进制文件可以通过 GDB 7.7 从以前的 NDK r10e 成功调试。在 Windows 上,失败并显示以下错误消息:bt
info stack
ndk-gdb.py
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: ""
实际上,ndk-gdb.py
从 NDK r11b 看来,它只适用于 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
基本命令正常工作:
(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