GDB中的solib-absolute-prefix和solib-search-path [英] solib-absolute-prefix vs. solib-search-path in GDB

查看:1859
本文介绍了GDB中的solib-absolute-prefix和solib-search-path的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我读了两者的描述,但我还不明白其中的差别。任何人都可以帮我理解这些差异吗?

  set solib-absolute-prefix  -  
指定包含副本的本地目录在
对应子目录中的目标库。使用gdbserver进行调试时,此选项很有用。

  set solib-search-path命令 -  
指定GDB将使用符号搜索共享库的目录。使用gdbserver进行调试时,此选项
非常有用。

谢谢。

解决方案

假设您的目标已加载 /usr/lib/libfoo.so code>,并且在主机上(在GDB运行的地方),你有一个在 / tmp / host 中的整个目标树的副本。也就是说,在 /tmp/host/usr/lib/libfoo.so 主机上找到目标 /usr/lib/libfoo.so 的副本c $ c>。

然后,下面的命令几乎是相同的:

  set solib-absolute-prefix / tmp / host 
set solib-search-path / tmp / host / usr / lib

现在考虑如果您的目标上还有 /usr/local/lib/libbar.so ,会发生什么情况以及它的副本 /tmp/host/usr/local/lib/libbar.so



上面设置的solib-absolute-prefix 仍然很好地定位 libbar.so ,但 solib-search-path 将不得不被修改如此:

  set solib-search-path / tmp / host / usr / lib:/ tmp / host / usr / local / lib 

总之,如果 整个 em>目标树 $ ROOT ,然后将 solib-absolute-prefix 设置为 $ ROOT ,你应该是好的。



但是,如果必须汇编目标路径多个不相交的树,那么带有多个路径的 solib-search-path 将允许GDB找到正确的库。


I read the description of both but I don't yet understand the difference. Can anyone help me understand the differences?

set solib-absolute-prefix -
Specifies the local directory that contains copies of target libraries in the 
corresponding subdirectories. This option is useful when debugging with gdbserver.

.

set solib-search-path command - 
Specifies directories where GDB will search for shared libraries with symbols. This option        
is useful when debugging with gdbserver.

Thanks.

解决方案

The wording is quite unclear :-(

Assume that your target loaded /usr/lib/libfoo.so, and that on the host (where GDB is running), you have a copy of the entire target tree in /tmp/host. That is, a copy of target's /usr/lib/libfoo.so is found on host in /tmp/host/usr/lib/libfoo.so.

Then, the following commands are almost equivalent:

set solib-absolute-prefix /tmp/host
set solib-search-path /tmp/host/usr/lib

Now consider what happens if you also have /usr/local/lib/libbar.so on target, and a copy of it in /tmp/host/usr/local/lib/libbar.so.

The solib-absolute-prefix as set above is still good to locate libbar.so, but solib-search-path would have to be modified like so:

set solib-search-path /tmp/host/usr/lib:/tmp/host/usr/local/lib

To summarize, if you have entire target tree under a single host $ROOT, then just set solib-absolute-prefix to $ROOT and you should be good.

But if you have to "assemble" target paths from multiple disjoint trees, then solib-search-path with multiple paths will allow GDB to still find correct libraries.

这篇关于GDB中的solib-absolute-prefix和solib-search-path的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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