5

I'm trying to debug an android app that call native code to do some GL rendering. The native code is existing code that I'm trying to port (and that I don't really know that well). I've got the existing code compiling, linking, and installing correctly, and I've got some native functions that call in to that code that are being correctly called from my Java code. I'm getting a segfault that I'm trying to track down, and having some problems getting gdb to set a breakpoint in the program. This is on windows XP with Cygwin - and I should probably mention I'm still learning gdb.

I started with the directions at http://honeypod.blogspot.com/2008/01/debug-native-application-for-android.html; here's what I'm currently doing.

Start the app in the emulator.

In a cmd prompt:

> 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

In a cygwin shell:

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.

So it looks like the breakpoint gets set ok, and that the symbols are ok, but maybe the address is wrong when it tries to insert the breakpoint. I've tried several variations of different commands from the webpage referenced above, but so far, no luck.

Any ideas what's going on?

Thanks

4

1 回答 1

1

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

于 2010-02-25T18:47:32.023 回答