2014-07-22 47 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仍然找到正確的庫。