1

我有一个 Android 本机代码,它由一个静态库(XXX.a)和最终的 ndk-build 命令(NDK_DEBUG 设置为 1)采用上述预构建的静态库并创建一个共享对象。

我使用 nm 命令查看特定函数定义的共享对象,它似乎可用(001ff2f5 T XXXXX)。

但是当我在运行 4.4.2 的 Android 设备上运行 ndk-gdb 时,gdb 无法加载共享对象符号:

Android NDK installation path: /opt/android-ndk-r8
Using specific adb command: ~/Desktop/adt-bundle-linux-x86-20131030/sdk/platform-tools/adb
ADB version found: Android Debug Bridge version 1.0.31
Using ADB flags: 
Using auto-detected project path: .
Found package name: com.example.ue2fileviewer
ABIs targetted by application: armeabi
Device API Level: 19
Device CPU ABIs: armeabi-v7a armeabi
Compatible device ABI: armeabi
Using gdb setup init: ./libs/armeabi/gdb.setup
Using toolchain prefix: /opt/android-ndk-r8/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/arm-linux-androideabi-
Using app out directory: ./obj/local/armeabi
Found debuggable flag: true
Found device gdbserver: /data/data/com.example.ue2fileviewer/lib/gdbserver
Found data directory: '/data/data/com.example.ue2fileviewer'
Found first launchable activity: .UE2FvSample
Launching activity: com.example.ue2fileviewer/.UE2FvSample
COMMAND: ~/Desktop/adt-bundle-linux-x86-20131030/sdk/platform-tools/adb shell am start -n com.example.ue2fileviewer/.UE2FvSample
Starting: Intent { cmp=com.example.ue2fileviewer/.UE2FvSample }
COMMAND:~/Desktop/adt-bundle-linux-x86-20131030/sdk/platform-tools/adb shell sleep 10
Found running PID: 1650
Killing existing debugging session
COMMAND: ~/Desktop/adt-bundle-linux-x86-20131030/sdk/platform-tools/adb shell kill -9 29470
/system/bin/sh: kill: 29470: Operation not permitted
Launched gdbserver succesfully.
Setup network redirection
COMMAND:~/Desktop/adt-bundle-linux-x86-20131030/sdk/platform-tools/adb forward tcp:5039 localfilesystem:/data/data/com.example.ue2fileviewer/debug-socket
COMMAND: ~/Desktop/adt-bundle-linux-x86-20131030/sdk/platform-tools/adb shell run-as com.example.ue2fileviewer lib/gdbserver +debug-socket --attach 1650
COMMAND: ~/Desktop/adt-bundle-linux-x86-20131030/sdk/platform-tools/adb pull /system/bin/app_process ./obj/local/armeabi/app_process
Attached; pid = 1650
Listening on sockaddr socket debug-socket
106 KB/s (9560 bytes in 0.087s)
Pulled app_process from device/emulator.
COMMAND: ~/Desktop/adt-bundle-linux-x86-20131030/sdk/platform-tools/adb pull /system/lib/libc.so ./obj/local/armeabi/libc.so
780 KB/s (310652 bytes in 0.388s)
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=i386-linux-gnu --target=arm-elf-linux".
(no debugging symbols found)
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
0x4004f73c in ?? ()
gdb: Unable to get location for thread creation breakpoint: requested event is not supported
(gdb) 

我在 Ubuntu、ndk-r8 NDK 版本和 Android SDK 平台 android-19 上运行它。

我已经尝试了堆栈溢出中当前可用的几乎所有帖子,但似乎没有一个对我有用。我一直在尝试在静态库中存在的函数中设置断点,但没有成功。

有人可以提供有关我可能出错的地方以及如何从这里开始以使 ndk-gdb 调试工作的见解吗?

4

1 回答 1

0

除了 NDK_DEBUG=1 之外,您可以尝试使用 APP_OPTIM=debug 进行编译吗?此外,升级到最新版本的 NDK (r9d) 可能会有所帮助,因为自 r8 以来有大量关于 gdb 的错误修复。

于 2014-03-17T10:40:36.283 回答