GDB源路径

Pio*_*ski 10 debugging gdb path

如何让gdb使用不同的目录来查找源文件.

例如,我在编译期间的源文件位于目录中:

/home/foo/bar.c
Run Code Online (Sandbox Code Playgroud)

接下来,我将其移动到目录中:

/tmp/debug/home/foo/bar.c
Run Code Online (Sandbox Code Playgroud)

如何强制gdb在这个目录中搜索?根据这个网站我应该使用命令:

dir /tmp/debug/
Run Code Online (Sandbox Code Playgroud)

但它没有用.我foo.c: "No such file or directory"从gdb 收到一条消息.

Ser*_*kov 15

set substitute-path /home/foo /tmp/debug/home/foo
Run Code Online (Sandbox Code Playgroud)

http://sourceware.org/gdb/current/onlinedocs/gdb/Source-Path.html#index-set-substitute_002dpath

  • 然后写一些`set substitute-path`.首先为你的主目录中的那些文件和文件夹设置"替换路径",然后为那些被移动的文件和文件夹设置"替换路径".该文档说:"在定义了多个替换规则的情况下,按照定义的顺序逐个评估规则.选择第一个匹配(如果有的话)来执行替换 (2认同)