如何在xcode中设置lldb的发现路径

如何在xcode中设置lldb的发现路径,xcode,symbols,lldb,Xcode,Symbols,Lldb,我有一个在一个环境中构建的程序,我想在自己的环境中调试它。我已经复制了可执行文件、.dSYM和源代码,但我找不到让lldb知道在哪里可以找到源代码的方法 例如,在建筑环境中有以下源文件: /build_src/rel_path/source1.c /build_src/rel_path/source1.dSYM /build_src/rel_path/app1 在我的环境中,文件和.dSYM被复制到: /source/rel_path/source1.c /source/rel_path/so

我有一个在一个环境中构建的程序,我想在自己的环境中调试它。我已经复制了可执行文件、.dSYM和源代码,但我找不到让lldb知道在哪里可以找到源代码的方法

例如,在建筑环境中有以下源文件:

/build_src/rel_path/source1.c
/build_src/rel_path/source1.dSYM
/build_src/rel_path/app1
在我的环境中,文件和.dSYM被复制到:

/source/rel_path/source1.c
/source/rel_path/source1.dSYM
/source/rel_path/app1
是否有任何方法可以设置发现路径或任何其他方法来重新映射源代码路径?

这就是“target.source map”设置的目的:

(lldb) settings list target.source-map
  source-map -- Source path remappings used to track the change of location between a source file when built, and where it exists on the current system. 
                It consists of an array of duples, the first element of each duple is some part (starting at the root) of the path to the file when it
                was built, and the second is where the remainder of the original build hierarchy is rooted on the local system.  Each element of the
                array is checked in order and the first one that results in a match wins.
例如,在您的案例中,您会:

settings set target.source-map /build_src /source

lldb有一个
apropos
命令,您可以使用它来查找这些隐藏的物品,例如
apropos source
会向您显示上面的帮助,还有一个非常简短的列表。

类似的问题:如果生成文件不再存在,但源代码的副本可用,则此操作不起作用。我不太确定我是否理解您的意思。但您必须以某种形式拥有调试信息,否则lldb无法将源代码映射到指令。在macOS上,调试信息保留在.o文件(或.a文件,如果您创建了这些文件)中,而不会链接到最终映像中。如果要在删除中间.o文件后进行调试,则需要创建一个
dSYM
文件。Xcode可以为您执行此操作(选择
DWARF with dSYM
debug选项),或者您可以在二进制文件上运行
dsymutil
工具。ELF通常会将调试信息链接到二进制文件中,因此在Linux上不需要这样做。我应该补充一下,我在Linux上使用的是
lldb
。可能会有不同。我对Linux不是很熟悉。在linux上,有一种方法可以将调试信息存储在一个单独的文件中,尽管我不了解详细信息。也许你是无意中这么做的?