【问题标题】:Debugging a native application with GDB on Android在 Android 上使用 GDB 调试本机应用程序
【发布时间】:2016-10-31 09:05:12
【问题描述】:

我有一个本机 C++ 应用程序,它应该在 Android 设备上运行。应用程序在启动时崩溃,很可能是从链接库调用函数时。我正在尝试使用 gdb 对其进行调试,但我无法成功。

我正在 Android 设备上的某个任意选择的端口 (2000) 上启动 gdbserver:

shell@msm8996: gdbserver :2000 my_app
Process my_app created; pid = 3420
Listening on port 2000

现在我正在尝试使用 Android-NDK 中提供的 gdb 在我的主机系统 (Windows 7) 上附加此进程。

C:\> gdb
(gdb) attach 3420
Can't attach to process.
(gdb) target remote :2000
:2000: The system tried to join a drive to a directory on a joined drive.

有什么问题?

编辑: 在运行 gdb 之前,我使用 adb 转发了端口 2000:

adb forward tcp:2000 tcp:2000

这至少帮助我建立了一些沟通,但是:

(gdb) target remote :2000
Remote debugging using :2000
warning: Architecture rejected target-supplied description
Remote 'g' packet reply is too long: 00000000000000000000000000000... 

在设备端:

Listening on port 2000
Remote debugging from host 127.0.0.1
readchar: Got EOF
Remote side has terminated connection.  GDBserver will reopen the connection.
Listening on port 2000

【问题讨论】:

    标签: android debugging gdb


    【解决方案1】:

    您很可能正在使用不同的架构/版本的 gdb。当您启动 gdb 时,它会显示如下一行(我正在显示我的 GDB 显示的内容):

    这个 GDB 被配置为“--host=x86_64-linux-gnu --target=arm-Linux-android"

    检查这是否与您手机的架构匹配。
    下载正确的 GDB 版本可能会解决您的问题。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-09-11
      • 1970-01-01
      • 2012-08-11
      • 2011-01-10
      • 1970-01-01
      • 2014-11-04
      • 1970-01-01
      相关资源
      最近更新 更多