请帮我使用 ndk-gdb!
我在 StackOverflow 和其他互联网上搜索过 =),但仍然做错了些什么。
配置: MacOSX 64 + 最新 SDK + 最新 NDK + 最新 IDEA + Nexus 7 + 大型 C++ 项目。
我已经完成了所有常规安排:
-g -ggdb -O0
添加到LOCAL_CFLAGS
(也尝试了只添加-g
)APP_OPTIM := debug
- 在清单文件中添加
debuggable=«true»
ndk-build NDK_DEBUG=1
我得到了预期的 gdb.setup 和 gdbserver 文件,但是 nm
命令对我的 *.so 文件输出为零。
我在项目的根目录中运行 ndk-gdb
并获得工作 GDB - 例如,我可以暂停应用程序并恢复它,可以在地址上获取 ASM 代码等。即使我使用 break Class::method
设置断点,gdb 也会告诉我正确的文件名和行号。
但断点在 99% 的情况下无法命中。回溯总是明显错误(方法名称错误)。似乎所有符号名称和地址都被映射错误。
我错过了什么?
更新。gdb 在两个命令 info sharedlibrary
和 C
开始时的输出。
:ndk-gdb
/android-ndk-macosx/build/core/add-application.mk:128: Android NDK: WARNING: APP_PLATFORM android-14 is larger than >android:minSdkVersion 8 in ./AndroidManifest.xml
/android-ndk-macosx/build/core/add-application.mk:128: Android NDK: WARNING: APP_PLATFORM android-14 is larger than >android:minSdkVersion 8 in ./AndroidManifest.xml
/android-ndk-macosx/build/core/add-application.mk:128: Android NDK: WARNING: APP_PLATFORM android-14 is larger than >android:minSdkVersion 8 in ./AndroidManifest.xml
/android-ndk-macosx/build/core/add-application.mk:128: Android NDK: WARNING: APP_PLATFORM android-14 is larger than >android:minSdkVersion 8 in ./AndroidManifest.xml
GNU gdb (GDB) 7.3.1-gg2
Copyright (C) 2011 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "--host=x86_64-apple-darwin --target=arm-linux-android".
For bug reporting instructions, please see:
<http://source.android.com/source/report-bugs.html>.
warning: .dynamic section for "/Users/<...>/android/obj/local/armeabi/lib1.so" is not at the expected address (wrong library or version >mismatch?)
warning: Could not load shared library symbols for 73 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: Breakpoint address adjusted from 0x400aca53 to 0x400aca52.
0x401a7ee4 in epoll_wait () from /Users/<...>/android/obj/local/armeabi/libc.so
(gdb) info sharedlibrary
From To Syms Read Shared Object Library
0x400aa220 0x400b2978 Yes (*) /Users/<...>/android/obj/local/armeabi/linker
0x4019c860 0x401cc184 Yes (*) /Users/<...>/android/obj/local/armeabi/libc.so
No libstdc++.so
No libm.so
<...dozens of system libs with "no"...>
No libjnigraphics.so
0x6749c160 0x67527844 Yes (*) /Users/<...>/android/obj/local/armeabi/lib1.so
0x65c487f8 0x65c6634c Yes (*) /Users/<...>/android/obj/local/armeabi/lib2.so
0x693e62e8 0x699dcd90 Yes /Users/<...>/android/obj/local/armeabi/lib3.so
(*): Shared library is missing debugging information.
(gdb) C
Continuing.>
您可以看到
- lib3.so(主要库)被最正确地加载了(或者没有?)
- 断点地址已经调整(这是什么意思?)
for f in find . -name "*.so"; do echo $f; nm $f; done
,但仍然没有得到任何结果。SO文件位于./libs和./obj。我该如何检查是否使用了错误的库? - mjollneer