3

我目前正在使用我的 android 项目调试一些代码。

我在让 gdb 在辅助线程上达到我的断点时遇到问题。当它们设置在主线程上时一切正常,但是一旦在辅助线程上遇到断点,我的应用程序就会崩溃。

我在网上搜索过,有人说 ndk 使用的是旧版本的 GDB,但现在这似乎无关紧要(因为 ndk r8 附带的版本提供了 7.3.1)。另一个站点说包含的 gdb 版本是在没有多线程支持的情况下编译的,但我似乎也无法验证这一点。

额外细节:

  • 设备:Nexus S
  • 操作系统:安卓 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
4

1 回答 1

0

自从我发布此内容以来已经有一段时间了,但我想我记得弄清楚了。原来我最近更新了 NDK 版本,并没有完全将所有引用迁移到旧的 NDK 目录。在将旧的 NDK 目录完全移动到备份目录后,我修复了 Eclipse 项目中挥之不去的引用。重建后,这似乎解决了我的问题。

TL;DR:确保您的 NDK 引用是正确的。

于 2012-10-16T20:14:09.657 回答