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

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

问题描述

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



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



例如:

  gdb path / to / executable path / to / corefile 

我的库位于当前目录中。



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



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

解决方案

在没有指定可执行文件或核心文件的情况下启动gdb,然后输入以下命令:

<$ p $设置solib-absolute-prefix ./usr
文件路径/可执行文件
core-file path / to / corefile

您需要确保完全从目标系统镜像库路径。以上是为了调试与主机不匹配的目标而设计的,这就是为什么复制包含您的库的根文件系统结构非常重要的原因。



如果您是远程调试与您的主机具有相同体系结构和Linux / glibc版本的服务器,则可以 fd 提示: p>

  set solib-search-path< path> 

如果您尝试覆盖某些库,但不是全部,则可以复制目标库目录结构放入临时位置,并使用上述的 solib-absolute-prefix 解决方案。


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.

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

For example:

gdb path/to/executable path/to/corefile

My libraries are in the current directory.

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

How can I specify that libraries be loaded first from paths relative to my current directory when analysing a corefile in 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.

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>

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天全站免登陆