如何使用gdb和gdbserver加载共享库符号以进行远程源代码级调试? [英] How to load shared libraries symbols for remote source level debugging with gdb and gdbserver?

查看:311
本文介绍了如何使用gdb和gdbserver加载共享库符号以进行远程源代码级调试?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在一块angstrom linux ARM板上安装了gdb和gdbserver(具有外部访问),并试图从我的本地机器上获取共享库的源代码级调试。目前,如果我登录设备,我可以运行gdb,并且能够使所有工作都能正常工作,包括设置断点,点击它并执行回溯。



我的问题来了,当我尝试使用gdbserver并在我的主机上运行gdb来完成同样的事情时(最终我想在eclipse中使用它,但在gdb中足够好的时候)。



我注意到当我在服务器上使用gdb并运行info shared时,它正确地加载了符号文件(读取的syms为yes)然后能够调试。使用符号文件或目录或共享,我没有如此遥远的运气。它显然看到了这些文件,但我无法加载任何符号,即使我直接指定远程文件。关于我可以尝试下一步的任何建议? 解决方案

有几种不同的方法会导致失败, gdb可以从服务器上获取本地文件而不是文件。

还有几种不同的方法可以解决这个问题,但最简单的方法是先完成调用 target remote

 (gdb)set sysroot remote:

这告诉gdb从远程系统获取文件。如果你在那里有调试信息(我从你的帖子中收集到你的信息),那么它一切正常。



这种方法的典型问题是它需要从远程复制数据。如果你有一个不好的链接,这可能是一个痛苦。在这种情况下,您可以在本地保留一份数据副本,并将sysroot指向副本。但是,这需要注意保持同步。


I've installed gdb and gdbserver on an angstrom linux ARM board (with external access), and am trying to get source level debugging of a shared library working from my local machine. Currently, if I ssh into the device, I can run gdb and I am able to get everything working, including setting a breakpoint, hitting it and doing a backtrace.

My problem comes when I try and do the same using gdbserver and running gdb on my host machine in order to accomplish the same thing (eventually I'd like to get this working in eclipse, but in gdb is good enough for the moment).

I notice that when I just use gdb on the server and run "info shared", it correctly loads symbol files (syms read : yes for all), which I'm then able to debug. I've had no such luck doing so remotely, using "symbol-file" or "directory" or "shared". Its obviously seeing the files, but I can't get it load any symbols, even when I specify remote files directly. Any advice on what I can try next?

解决方案

There are a few different ways for this to fail, but the typical one is for gdb to pick up local files rather than files from the server.

There are also a few different ways to fix this, but the simplest by far is to do this before invoking target remote:

(gdb) set sysroot remote:

This tells gdb to fetch files from the remote system. If you have debug info there (which I gather from your post that you do), then it will all work fine.

The typical problem with this approach is that it requires copying data from the remote. This can be a pain if you have a bad link. In this case you can keep a copy of the data locally and point sysroot at the copy. However, this requires some attention to keeping things in sync.

这篇关于如何使用gdb和gdbserver加载共享库符号以进行远程源代码级调试?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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