10

我阅读了两者的描述,但我还不明白其中的区别。谁能帮我理解这些差异?

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.

谢谢。

4

1 回答 1

25

措辞很不清楚:-(

假设您的目标已加载/usr/lib/libfoo.so,并且在主机(运行 GDB 的地方)上,您在/tmp/host. 也就是说,/usr/lib/libfoo.so在主机上找到目标的副本/tmp/host/usr/lib/libfoo.so

然后,以下命令几乎是等效的:

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

总而言之,如果您在单个主机下拥有整个$ROOT目标树,那么只需设置solib-absolute-prefix为就$ROOT可以了。

但是,如果您必须从多个不相交的树中“组装”目标路径,那么solib-search-path使用多个路径将允许 GDB 仍然找到正确的库。

于 2014-07-23T14:43:13.133 回答