【问题标题】:GDB source pathGDB 源路径
【发布时间】:2014-07-15 02:48:13
【问题描述】:

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

例如我编译时的源文件在目录中:

/home/foo/bar.c

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

/tmp/debug/home/foo/bar.c

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

dir /tmp/debug/

但它不起作用。我收到来自 gdb 的消息 foo.c: "No such file or directory"

【问题讨论】:

  • 尝试使用像dir /tmp/debug/home/foo这样的整个路径,我想它只想在那里找到文件本身。
  • 我知道这行得通,但事实并非如此。我只是想自动化一些过程。如果我会有很多这样的文件,那么为每个文件添加整个路径就像将所有文件放在一个调试目录中一样。换句话说,如果你有同名但不同目录的文件(在编译期间)添加整个路径将导致名称冲突(gdb 不会区分这些文件)。

标签: debugging path gdb


【解决方案1】:

【讨论】:

  • 我也知道这个。但是请想象一下,您的主目录中的某处还有一些其他文件。如果您设置此替代路径,它将为“home”下的所有文件更改。
  • 那就写几个set substitute-path。首先set substitute-path 用于您主目录中的文件和文件夹,然后set substitute-path 用于那些已移动的文件和文件夹。文档说:In the case when more than one substitution rule have been defined, the rules are evaluated one by one in the order where they have been defined. The first one matching, if any, is selected to perform the substitution.
猜你喜欢
  • 1970-01-01
  • 2021-08-22
  • 1970-01-01
  • 2020-04-10
  • 2012-10-10
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多