10

我在目标和 CodeSourcery IDE 上使用 gdbserver。我的硬件是带有 omap3530 的 gumstix。

我可以在我的主应用程序中单步执行代码,但是如果我尝试单步执行共享库中的函数,我会得到内存地址并且调试器会终止。

这是我的库,已编译并复制到目标系统上的 /lib 文件夹。(它确实有调试符号)我试图使用 .gbdinit 文件来设置 solib-absolute-prefix /lib

以下是来自 gdb 跟踪的警告:

903,056 13-gdb-set sysroot-on-target /lib
903,065 13^done
903,065 (gdb) 
903,065 14-target-select remote 192.168.1.101:2345
903,114 =thread-group-started,id="i1",pid="42000"
903,114 =thread-created,id="1",group-id="i1"
903,115 15-list-thread-groups --available
903,120 16-list-thread-groups
903,128 &"warning: Unable to find dynamic linker breakpoint function.\nGDB will be unable to debug shared library initializers\nand track explicitly loaded dynamic code."
903,128 &"\n"

这导致

903,395 &"Error while mapping shared library sections:\n"
903,397 &"/lib/libCoreLib.so: Invalid argument.\n"
903,399 =library-loaded,id="/lib/libCoreLib.so",target-name="/lib/libCoreLib.so",hostname="/lib/libCoreLib.so",low-address="0x0",high-address="0x0",symbols-loaded="0",thread-group="i1"
4

4 回答 4

6

您可以使用安装在主机上的库进行调试,前提是调试机器也是开发机器。在这种情况下,您使用 set sysroot 而不是 set sysroot-on-target。例如 :

set sysroot /home/username/.../rootfs/

其中/home/username/.../rootfs/包含目标文件系统的副本

我认为您还应该指定/而不是/lib

于 2011-12-23T08:38:55.420 回答
4

带有调试符号的目标

这是开始工作的最简单方法,并且在您开发一个特定的共享库时特别有用。

首先将测试可执行文件和共享库复制到带有调试信息的目标:

然后在目标上:

gdbserver --multi :1234 ./executable_name

主持人:

arm-linux-gnueabihf-gdb -q -nh \
  -ex "target extended-remote target-hostname-or-ip:1234" \
  -ex "file ./executable_name" \
  -ex 'tb main' \
  -ex 'c' \
  -ex 'set solib-search-path .'

sharedlibrary libmylib.so也有效。

我遇到的问题是gdbserver在动态加载器处停止, before main,动态库此时尚未加载,因此 GDB 还不知道符号将在内存中的位置。

GDB 似乎有一些机制可以自动加载共享库符号,如果我为主机编译并在gdbserver本地运行,main则不需要运行到。但在 ARM 目标上,这是最可靠的做法。

目标gdbserver7.12-6,arm-linux-gnueabihf-gdb来自 Linaro 的主机 7.6.1。

没有调试符号的目标库

在部署到嵌入式目标之前,通常会剥离目标库,因为调试信息会使它们变得更大

例如,Buildroot 默认执行此操作,但您可以使用BR2_STRIP_none=y.

您可以通过运行来识别这种情况:

info shared

显示如下:

From                To                  Syms Read   Shared Object Library
0x00007ffff7df7f90  0x00007ffff7dfcdd7  Yes (*)     target:/lib/ld64-uClibc.so.0
0x00007ffff7b3a9b0  0x00007ffff7bbe05d  Yes (*)     target:/lib/libc.so.0
(*): Shared library is missing debugging information.

所以这*两个库都有星号 (),表示缺少调试信息。

如果是这种情况,那么您必须告诉 GDB在它们被剥离之前使用主机上的共享库。

例如,Buildroot 对我们来说很容易,因为它维护staging包含共享库之前的目录,并且在与目标相同的相对路径中:

set sysroot buildroot/output/staging/

设置此选项后,gdb立即在主机而不是目标中搜索库,并/lib/libc.so.0在路径buildroot/output/staging/+处查找/lib/libc.so.0

Reading symbols from buildroot/output/staging/lib/ld64-uClibc.so.0...done.
Reading symbols from buildroot/output/staging/lib/libc.so.0...done.

TODO:我认为您不能设置多个sysroot,因此您的所有共享库都必须放置在目标图像中的正确相对路径中。

如果您检查错误的默认 sysroot,您将看到:

show sysroot

给:

target:

这意味着默认情况下gdb在目标根目录上搜索共享库。/

于 2017-07-22T07:53:01.980 回答
0

调试时遇到了类似的问题。调试挂了。配置如下

主机:Ubuntu 12.04LTS

IDE:Eclipse 开普勒

目标:Beaglebone Black / ARM A8

操作系统:埃

解决方案

更新库和包含

在 Eclipse 中选择项目的属性

  • C/C++ General > Paths and Symbols > (include TAB) GNU C > Add > Files systems > / > usr 从 /usr/lib/gcc/i686-linux-gnu/4/6/include 更改为 /usr/arm- linux-gnueabi/包括

  • C/C++ General > Paths and Symbols > (Include TAB) GNU C++> Add >
    Files systems > / > usr /usr/arm-linux-gnueabi/include/c++/4.6.3/arm-linux-gnueabi

  • C/C++ General > Paths and Symbols > (Library Paths TAB) > Add > Files systems > / > usr /usr/arm-linux-gnueabi/lib

于 2014-07-08T22:24:36.930 回答
0

再会,

如果 GDB 中的 'debug-file-directory' 变量设置不正确,则报告的错误消息包含:warning: Unable to find dynamic linker breakpoint function。

目标的根文件系统位于我的主机 PC 上的 /opt/arm-linux-gnueabihf-rootfs

以下两个命令帮助我使用 GDB (v7.11.1) 通过 gdbserver 进行远程调试:

set debug-file-directory /opt/arm-linux-gnueabihf-rootfs/usr/lib/debug
set sysroot /opt/arm-linux-gnueabihf-rootfs

我注意到如果 'sysroot' 在路径中有一个斜杠,则 GDB 无法使用它。在连接到远程目标后,您将看到这个(不正确的输出):

Reading /lib/ld-linux-armhf.so.3 from remote target...

或者

Reading symbols from /opt/arm-linux-gnueabihf-rootfs/lib/ld-linux-
armhf.so.3...(no debugging symbols found)...done

而不是正确的输出:

Reading symbols from /opt/arm-linux-gnueabihf-rootfs/lib/ld-linux-
armhf.so.3...
Reading symbols from /opt/arm-linux-gnueabihf-rootfs/usr/lib/debug/
lib/arm-linux-gnueabihf/ld-2.23.so...done.

问候, Frikkie Thirion

于 2016-11-05T18:40:30.670 回答