GDB 中的 solib-absolute-prefix 与 solib-search-path [英] 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.
谢谢.
推荐答案
措辞不清楚:-(
假设您的目标加载了 /usr/lib/libfoo.so
,并且在主机(运行 GDB 的地方)上,您在 /中有整个目标树的副本tmp/主机
.也就是说,在 /tmp/host/usr/lib/libfoo.so
中的主机上可以找到目标的 /usr/lib/libfoo.so
的副本.
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
现在考虑如果目标上还有 /usr/local/lib/libbar.so
会发生什么,并且在 /tmp/host/usr/local/lib 中有一个副本/libbar.so
.
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
.
上面设置的 solib-absolute-prefix
仍然可以很好地定位 libbar.so
,但是 solib-search-path
会有修改如下:
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
总而言之,如果你在一个主机$ROOT
下有整个目标树,那么只需设置solib-absolute-前缀
到$ROOT
,你应该很好.
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.
但是如果您必须从多个不相交的树中组装"目标路径,那么具有多个路径的 solib-search-path
将允许 GDB 仍然找到正确的库.
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屋!