2010-02-16 45 views
4

我试图调试一个调用本地代码来执行一些GL渲染的android应用程序。本机代码是我试图移植的现有代码(并且我不太清楚)。我已经有了正确编译,链接和正确安装的代码,并且我有一些原生函数调用了从我的Java代码正确调用的代码。我收到了一个段错误,我试图追踪,并且遇到了一些问题,让gdb在程序中设置断点。这是与Cygwin的Windows XP - 我应该提到我还在学习gdb。gdb输入/输出错误远程调试到Android

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

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

在命令提示符:

> 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 

在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. 

所以它看起来像断点被设定好了,并且这些符号都OK,但也许地址是当它试图插入断点时错误。我已经尝试过上面引用的网页中的几个不同命令的变体,但到目前为止,没有运气。

任何想法发生了什么?

感谢

回答

1

本质上说,在这一点上与NDK 1.6,我发现,那里只是没有为这种与NDK严格调试的支持。但是,如果您使用PDK(平台开发工具包),则可以使用本机代码进行此类调试。我们还没有尝试过PDK,因为生成的地图文件对我们来说工作得很好(请参阅this SO question),但是如果您确实走这条路线,请查看the NDK google group了解更多详细信息。