如何获得NDK-gdb的工作在Android? [英] How to get ndk-gdb working on Android?

查看:117
本文介绍了如何获得NDK-gdb的工作在Android?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图让NDK调试工作,但没有成功为止。

I'm trying to get the NDK debugger working but with no success so far.

要确保我的调试符号是present和有效的,我用的编译器选项-O0和-g和NDK的建造参数NDK_DEBUG = 1。

To make sure my debug symbols are present and valid, I use the compiler options -O0 and -g, and the ndk-build parameter NDK_DEBUG=1.

在NDK-gdb的脚本了问题运行并启动GDB。如果做一个sharedlibrary命令,我得到这样的:

The ndk-gdb script runs with out issues and launches GDB. When do a "sharedlibrary" command, I get this:

Symbols already loaded for /bla/bla/libMySharedLib.so

然而,当我尝试打破执行或如增加一个段错误测试,我从来没有得到任何符号从调用堆栈库。我已经得到了唯一的符号从libc的,如果我中断执行,而它在等待一个互斥体的实例。也试过没有运气添加断点。 GDB让我加的断点,和code运行良好,但断点永远不会触发。

However when I try breaking execution or e.g. adding a segfault to test, I never get any of the symbols from that library in the call stack. The only symbols I've gotten are from libc, if I break execution while it's waiting for a mutex for instance. Also tried adding breakpoints with no luck. GDB lets me add the breakpoints, and the code runs fine, but the breakpoints are never triggered.

我使用的API级别8,因为我需要支持Android 2.2(升级Froyo)。

I'm using API level 8 as I need to support Android 2.2 (Froyo).

我是什么做错了吗?

感谢您的时间。

推荐答案

您不需要使用-O0或-g开关。 你需要做以下操作之一:

You don't need to use -O0 or -g switches. You need to do one of following:

  1. 机器人:可调试=真正的<应用> 的标记 AndroidManifest.xml中文件
  2. 使用 NDK_DEBUG = 1 后NDK建造
  3. APP_OPTIM:=调试在Application.mk文件
  1. put android:debuggable="true" to the <application> tag in AndroidManifest.xml file
  2. use NDK_DEBUG=1 after ndk-build
  3. put APP_OPTIM := debug in Application.mk file

做这三件事的人会自动用-O0和-g开关。

Doing anyone of these three things will automatically use -O0 and -g switches.

您可以尝试手动运行GDB,没有GDB脚本? 它包括以下步骤:

Can you try running gdb manually, without gdb script? It involves following steps:

  1. gdbserver的文件到 /数据/本地在设备上的文件夹
  2. 在运行应用程序和放大器;调用在亚行外壳下面的命令的gdbserver:5055 --attach PID ,其中PID是应用程序的进程id
  3. 运行 ADB将TCP:5055 TCP:5055 主机
  4. 运行 ARM-Linux的androideabi-gdb.exe 从您的应用程序文件夹
  5. 在GDB中输入下面的命令
  6. 设置solib搜索路径OBJ /本地/ armeabi
  7. 文件OBJ /本地/ armeabi / libMySharedLib.so
  8. 远程目标:5055
  1. pushing gdbserver file to /data/local folder on device
  2. running your application & invoking in adb shell following command gdbserver :5055 --attach PID, where PID is your application process id.
  3. running adb forward tcp:5055 tcp:5055 on host
  4. running arm-linux-androideabi-gdb.exe from your app folder
  5. entering following commands in gdb
  6. set solib-search-path obj/local/armeabi
  7. file obj/local/armeabi/libMySharedLib.so
  8. target remote :5055

和看你能不能再调试。

如果你想看到符号库中使用如 libc.so 其他共享库,然后从设备拉他们(从 /系统/ LIB 文件夹)到你的 OBJ /本地/ armeabi 文件夹。

If you want see symbols for other shared libraries your library is using like libc.so, then pull them from device (from /system/lib folder) to your obj/local/armeabi folder.

这篇关于如何获得NDK-gdb的工作在Android?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆