在 Linux 上的 gdb 中加载核心文件时,如何在目录前面添加库路径 [英] How do I prepend a directory the library path when loading a core file in gdb on Linux

查看:16
本文介绍了在 Linux 上的 gdb 中加载核心文件时,如何在目录前面添加库路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在无法直接访问的远程系统上生成了一个核心文件.我还有来自远程系统的库文件的本地副本,以及崩溃程序的可执行文件.

I have a core file generated on a remote system that I don't have direct access to. I also have local copies of the library files from the remote system, and the executable file for the crashing program.

我想在 gdb 中分析这个核心转储.

I'd like to analyse this core dump in gdb.

例如:

gdb path/to/executable path/to/corefile

我的库在当前目录中.

在过去,我看到调试器通过提供选项-p"来实现这一点.或-p/=.";所以我的问题是:

In the past I've seen debuggers implement this by supplying the option "-p ." or "-p /=."; so my question is:

在 gdb 中分析核心文件时,如何指定首先从相对于我当前目录的路径加载库?

How can I specify that libraries be loaded first from paths relative to my current directory when analysing a corefile in gdb?

推荐答案

不指定可执行文件或核心文件启动gdb,然后键入以下命令:

Start gdb without specifying the executable or core file, then type the following commands:

set solib-absolute-prefix ./usr
file path/to/executable
core-file path/to/corefile

您需要确保完全从目标系统镜像您的库路径.以上内容用于调试与您的主机不匹配的目标,这就是为什么复制包含您的库的根文件系统结构很重要的原因.

You will need to make sure to mirror your library path exactly from the target system. The above is meant for debugging targets that don't match your host, that is why it's important to replicate your root filesystem structure containing your libraries.

如果您正在远程调试与您的主机架构和 Linux/glibc 版本相同的服务器,那么您可以像 fd 建议:

If you are remote debugging a server that is the same architecture and Linux/glibc version as your host, then you can do as fd suggested:

set solib-search-path <path>

如果您尝试覆盖某些库,但不是全部,那么您可以将目标库目录结构复制到一个临时位置并使用上述 solib-absolute-prefix 解决方案.

If you are trying to override some of the libraries, but not all then you can copy the target library directory structure into a temporary place and use the solib-absolute-prefix solution described above.

这篇关于在 Linux 上的 gdb 中加载核心文件时,如何在目录前面添加库路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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