指导GDB 6.5使用嵌入到目标文件源 [英] Instruct GDB 6.5 to use source embedded in object file

查看:187
本文介绍了指导GDB 6.5使用嵌入到目标文件源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直试图让 GNU GDB 6.5-14 使用嵌入在目标文件时,调试源$ C ​​$ C,而不是扫描某些目录中吧。

I've been trying to make GNU gdb 6.5-14 to use the source code embedded on the object file when debugging, instead of scanning some directories for it.

主要的原因是,我开发一个嵌入式平台,我交叉编译,这意味着所有的源代码是在我的电脑。

The main reason is that I develop for an embedded platform and I cross compile, which means that all the source is in my computer.

我读了 -ggdb3 标志,它包括了很多额外的信息,包括源$ C ​​$ C。于是我开始与该标志进行编译。

I read about the -ggdb3 flag, that includes a lot of extra info, including the source code. So I started compiling with that flag.

做一个 objdump的-S​​的src / lib目录/ libfoo.so 确实打印出所有的源$ C ​​$ C与源$混合组装code C $ C,所以我猜它确实包含这些信息。

Doing a objdump -S src/lib/libfoo.so indeed prints out all the source code with the assembly code intermixed with the source code, so I'm guessing that it does indeed contain that info.

的唯一一件事就是GDB不打印出来,除非我从NFS运行安装我的工作区包含源的版本。

The only thing is that GDB does not print it, unless I run from a nfs mounted version of my workspace that contains the source.

有谁知道我可以指导GDB为code中的目标文件中查找依赖外部文件,而不是?

Does anyone know how can I instruct gdb to look in the object file for code instead of relying on external files?

推荐答案

您猜什么 -ggdb3 做的是完全不正确的;目标文件做的的包含源。您可以证明,通过运行字符串-a libfoo.so

Your guess about what -ggdb3 does is totally incorrect; the object files do not contain the source. You can prove that by running 'strings -a libfoo.so'.

您最好的选择是学习如何使用远程调试 - 那么你可以使用 GDB 从上(其所有源的访问);与额外的好处,你需要的目标要少得多的内存。参见 gdbserver的信息GDB

Your best bet is to learn how to use remote debugging -- you can then use GDB from host (which has access to all the sources); with an added advantage that you need much less memory on target. See gdbserver in "info gdb".

这篇关于指导GDB 6.5使用嵌入到目标文件源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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