调试信息记录了 QT 源文件构建时的位置。您可以通过执行以下操作找到此信息:
(lldb) image lookup -va main
Address: hello[0x0000000100000f40] (hello.__TEXT.__text + 0)
Summary: hello`main at hello.c:5
Module: file = "/private/tmp/hello", arch = "x86_64"
CompileUnit: id = {0x00000000}, file = "/tmp/hello.c", language = "ISO C:1999"
Function: id = {0x00000026}, name = "main", range = [0x0000000100000f40-0x0000000100000f6d)
FuncType: id = {0x00000026}, decl = hello.c:4, clang_type = "int (void)"
Blocks: id = {0x00000026}, range = [0x100000f40-0x100000f6d)
LineEntry: [0x0000000100000f40-0x0000000100000f56): /tmp/hello.c:5
Symbol: id = {0x00000004}, range = [0x0000000100000f40-0x0000000100000f6d), name="main"
但用一些QT函数代替“main”。然后查看 CompileUnit 行并查看“文件”条目的内容。假设它说
"/BuildDirectory/sources/SomeSubdirectory/SomeFile.cpp"
现在想必您已经下载了 QT 源代码,并且它们位于您本地计算机上的某个位置,例如
"/Users/ME/QT/sources"
所以你想要做的是告诉 lldb:“当你看到根目录为 /BuildDirectory/sources 的源文件时,请改为查看 /Users/ME/QT/sources 。”您可以使用 lldb“target.source-map”设置来完成此操作。在这个例子中,你会说:
(lldb) settings set target.source-map /BuildDirectory/sources /Users/ME/QT/sources
您可以在命令行中输入该内容或将其放入 .lldbinit 文件中以供更一般的用途。 lldb 将自动更新其源映射,但如果您在 Xcode 中运行,则必须在发出命令后执行一次才能更新它。