LLDB - 设置源代码路径

LLDB - setting source code path

根据 lldb 的官方指南,在调试会话期间查看源代码的能力(使用命令 source list)是通过为源文件设置新的路径名来完成的。

即如果我在一台计算机上的 /tmp 中编译我的项目并将其部署到另一台源代码驻留在 /Users/Src/ 中的计算机上,我应该在部署机器中从 运行 lldb 中键入 settings set target.source-map /tmp /Users/Src

但是,如果我从其他人那里获得了可执行文件,但不知道构建目录,会发生什么情况。也许源代码的组织方式与构建位置不同(但文件内容相同)。

我的问题是:

  1. lldb 是否知道如何在提供的路径中递归搜索匹配的源文件?

  2. 如何从 mach-o 可执行文件中获取原始路径名?

这里是命令的正式描述:

Remap source file pathnames for the debug session. If your source files are no longer located in the same location as when the program was built --- maybe the program was built on a different computer --- you need to tell the debugger how to find the sources at their local file path instead of the build system's file path.

如果您知道相关代码中的函数名称,请执行:

(lldb) image lookup -vn <FunctionName> <BinaryImageNameContainingFunction>

并查找 CompileUnit 条目。那里给出的路径是lldb从调试信息中得到的路径。