我有一个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调试工作?
发布于 2014-03-17 18:40:36
除了NDK_DEBUG=1之外,您还可以尝试使用APP_OPTIM=debug编译吗?此外,升级到NDK (r9d)的最新版本可能会有所帮助,因为自r8以来,有大量关于gdb的错误修复。
https://stackoverflow.com/questions/22327240
复制相似问题