gpt4 book ai didi

c++ - set sysroot 命令与 set solib-search-path 命令

转载 作者:太空宇宙 更新时间:2023-11-04 04:20:32 25 4
gpt4 key购买 nike

我对 set solib-search-path 和 set sysroot 命令感到困惑,不确定何时使用其中一个或另一个。在我的例子中,仅当我同时使用这两个命令时才会加载符号。是否总是需要这两个命令以及每个命令的作用。

在这里http://visualgdb.com/gdbreference/commands/ ,看起来 sysroot 也在子目录中查找,那么如果既要搜索库又要从这些库加载符号,为什么还需要 solib-search-path

最佳答案

gdb 首先搜索 sysroot 中的库(使用绝对路径),然后只有在找不到它们时才会搜索 solib-search-path(使用相对路径)。

因此,当使用 gdb 服务器/远程调试时,您可能只想使用 gdb 的 sysroot 选项。在 Linux 系统上使用 solib-search-path 将不起作用,除非您更改 sysroot 的值,因为 sysroot 的默认值是 target ,这意味着 gdb 正在加载在您正在调试的文件系统上找到的 so 文件。这也是 gdb 的 documentation 中指示的内容。 :

set solib-search-path path

colon-separated list of directories to search for shared libraries.‘solib-search-path’ is used after ‘sysroot’ fails to locate thelibrary, or if the path to the library is relative instead ofabsolute. If you want to use ‘solib-search-path’ instead of ‘sysroot’,be sure to set ‘sysroot’ to a nonexistent directory to prevent GDBfrom finding your host’s libraries. ‘sysroot’ is preferred; setting itto a nonexistent directory may interfere with automatic loading ofshared library symbols.

如本 thread 所示,solib-search-path 的用例是:

solib-search-path is there mostly to help targets like Windows thatdon't report to the debugger the full path to the shared library.GNU/Linux always works with full patchs, such as"/usr/lib/libjpeg.so.8"

关于c++ - set sysroot 命令与 set solib-search-path 命令,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47425543/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com