Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
489 views
in Technique[技术] by (71.8m points)

kgdb - solib-absolute-prefix vs. solib-search-path in 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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...