gdb输入/输出错误,远程调试到Android

Mat*_*inn 5 c++ android gdb android-ndk

我正在尝试调试一个调用本机代码来进行GL渲染的android应用。本机代码是我要移植的现有代码(我不太了解)。我已经正确地编译,链接和安装了现有代码,并且有一些本机函数可以从我的Java代码正确调用该代码。我遇到了要跟踪的段错误,让gdb在程序中设置断点时遇到了一些问题。这是在使用Cygwin的Windows XP上进行的-我可能应该提到我仍在学习gdb。

我从http://honeypod.blogspot.com/2008/01/debug-native-application-for-android.html的说明开始;这是我目前正在做的事情。

在模拟器中启动应用程序。

在cmd提示中:

> adb forward tcp:1234 tcp:1234
> adb shell
# gdbserver localhost:1234 --attach 2120
gdbserver localhost:1234 --attach 2120
Attached; pid = 2120
Listening on port 1234
Run Code Online (Sandbox Code Playgroud)

在cygwin外壳中:

arm-eabi-4.2.1/bin/arm-eabi-gdb.exe out/apps/app-android/libDM.so
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=i686-pc-cygwin --target=arm-elf-linux"...
(gdb) target remote localhost:1234
Remote debugging using localhost:1234
warning: shared library handler failed to enable breakpoint
0xafe0da04 in AppRefCounted::unref () at ../../stlport/stl/_iosfwd.h:39
39      class basic_ostream;
Current language:  auto; currently c++
(gdb) b Java_com_app_AppRenderer_onCreate
Breakpoint 1 at 0xafff1b1a: file apps/app-android/../../../app-Android/jni/DMJNI/DMInterface.cpp, line 75.
(gdb) c
Continuing.
Warning:
Cannot insert breakpoint 1.
Error accessing memory address 0xafff1b1a: Input/Output error.
Run Code Online (Sandbox Code Playgroud)

因此,看起来断点设置正确,符号也可以,但是在尝试插入断点时地址可能错误。我已经从上面引用的网页中尝试了几种不同命令的变体,但是到目前为止,还没有运气。

有什么想法吗?

谢谢

Mat*_*inn 1

本质上,在 NDK 1.6 中,我发现 NDK 并不严格支持这种调试。但是,如果您使用PDK(平台开发套件),则可以使用本机代码进行此类调试。我们还没有尝试过 PDK,因为生成地图文件对我们来说效果足够好(请参阅这个 SO 问题),但如果您确实走这条路,请检查NDK 谷歌组以获取更多详细信息。