我目前正在调试我的android项目的一些代码。如何在使用Android NDK的线程上插入断点而不会崩溃?
我有一个问题让gdb打到我的辅助线程上的断点。当它们在主线程上设置时,一切正常,但是当第二个中断点出现断点时,我的应用程序就会崩溃。
我搜索了网页,有人说ndk使用旧版本的GDB,但现在看起来并不相关(因为随ndk r8发布的版本给出了7.3.1)。另一个网站曾经说过,包含的gdb版本是在没有多线程支持的情况下编译的,但我似乎无法验证这一点。
其他细节:
- 设备:Nexus S的
- 操作系统:Android的4.1.1
我不知道这是相关或不相关,但我得到下面的输出当我将调试器附加到正在运行的应用程序时(似乎只有符号存在问题):
warning: .dynamic section for "/home/sandy/workspace/tumbleweed/obj/local/armeabi-v7a/linker" is not at the expected address (wrong library or version mismatch?)
warning: Could not load shared library symbols for 78 libraries, e.g. libstdc++.so.
Use the "info sharedlibrary" command to see the complete listing.
Do you need "set solib-search-path" or "set sysroot"?
warning: Unable to find dynamic linker breakpoint function.
GDB will be unable to debug shared library initializers and track explicitly loaded dynamic code.
另外,这里是我的详细输出运行NDK-GDB --verbose时:
Android NDK installation path: /home/sandy/workspace/android-ndk-r8b
Using default adb command: /home/sandy/workspace/android-sdk/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.sandroid.tumbleweed
ABIs targetted by application: jni/../libs
/home/sandy/workspace/tumbleweed/libs/gtest-1.6.0
/home/sandy/workspace/tumbleweed/libs/gtest-1.6.0/lib/.libs/libgtest.a
armeabi-v7a
Device API Level: 16
Device CPU ABIs: armeabi-v7a armeabi
Compatible device ABI: armeabi-v7a
Using gdb setup init: ./libs/armeabi-v7a/gdb.setup
Using toolchain prefix: /home/sandy/workspace/android-ndk-r8b/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86/bin/arm-linux-androideabi-
Using app out directory: ./obj/local/armeabi-v7a
Found debuggable flag: true
Found device gdbserver: /data/data/com.sandroid.tumbleweed/lib/gdbserver
Found data directory: '/data/data/com.sandroid.tumbleweed'
Found running PID: 3539
Launched gdbserver succesfully.
Setup network redirection
## COMMAND: adb_cmd shell run-as com.sandroid.tumbleweed lib/gdbserver +debug-socket --attach 3539
## COMMAND: adb_cmd forward tcp:5039 localfilesystem:/data/data/com.sandroid.tumbleweed/debug-socket
## COMMAND: adb_cmd pull /system/bin/app_process ./obj/local/armeabi-v7a/app_process
Attached; pid = 3539
Listening on sockaddr socket debug-socket
118 KB/s (9572 bytes in 0.078s)
Pulled app_process from device/emulator.
## COMMAND: adb_cmd pull /system/bin/linker ./obj/local/armeabi-v7a/linker
844 KB/s (79976 bytes in 0.092s)
Pulled linker from device/emulator.
## COMMAND: adb_cmd pull /system/lib/libc.so ./obj/local/armeabi-v7a/libc.so
1662 KB/s (286500 bytes in 0.168s)
Pulled libc.so from device/emulator.
当应用程序崩溃,我得到这个:
Child terminated with signal = 5
Child terminated with signal = 0x5 (SIGTRAP)
GDBserver exiting
同样的问题,你找到了什么? – Intrepidd 2012-09-06 20:32:48
您应该遵循警告提示并发出“信息共享库”。有可能你的第二个线程位于gdb未能加载符号的78个库之一中。你可以尝试的一种解决方法是在托管第一个线程的同一个库中(为其正确分配gdb)构建托管第二个线程的库。 – 2012-09-19 23:04:00