2014-07-22 50 views
4

我阅读了两者的描述,但我还不明白其中的差别。任何人都可以帮助我理解差异吗?GDB中的solib-absolute-prefix与solib-search-path

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. 

谢谢。

回答

13

的措辞相当不明确:-(

假设你的目标加载/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

如上面还是不错的定位libbar.so,但solib-search-path将有solib-absolute-prefix进行修改,像这样:

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

总之,如果你有一台主机下整个目标树$ROOT,然后只需将solib-absolute-prefix设置为$ROOT,您应该很好。

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