Xcode等同于Visual Studio的“查找源" [英] Xcode equivalent of Visual Studio's "Find Source"

查看:83
本文介绍了Xcode等同于Visual Studio的“查找源"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个Qt项目,并且已经从他们的安装程序中将Qt安装到了我的计算机上.在Visual Studio中,调试到Qt源代码很简单:当我在未知文件中输入函数时,它将打开文件浏览器以让我找到原始Qt源代码.

I am developing on a Qt project, and have installed Qt from their installer onto my computer. In Visual Studio it is simple to debug-step into Qt sources: when I enter a function in an unknown file, it will open a file browser to let me locate the original Qt source code.

Xcode或LLDB中是否有等效功能?

Is there an equivalent function in Xcode or LLDB?

推荐答案

调试信息记录了QT源文件生成时的位置.您可以通过以下方式找到此信息:

The debug information records the location of the QT source files when they were built. You can find this information by doing:

  (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行,并查看文件"条目的内容.假设它是

but substitute some QT function for "main". Then look at the CompileUnit line and see what the "file" entry says. Suppose it says

"/BuildDirectory/sources/SomeSubdirectory/SomeFile.cpp"

现在大概您已经下载了QT源,并且它们位于您本地计算机上的某个位置,例如

Now presumably you've downloaded the QT sources, and they live somewhere on your local machine, say in

"/Users/ME/QT/sources"

因此,您要做的就是告诉lldb:当您看到源于/BuildDirectory/sources的源文件时,请查看/Users/ME/QT/sources."您可以通过lldb"target.source-map"设置来实现.在此示例中,您将说:

So what you want to do is tell lldb: "when you see a source file rooted at /BuildDirectory/sources, look in /Users/ME/QT/sources instead." You do that with the lldb "target.source-map" setting. In this example, you would say:

(lldb) settings set target.source-map /BuildDirectory/sources /Users/ME/QT/sources

您可以在命令行中键入该命令,也可以将其放入您的.lldbinit文件中,以进行更常规的使用. lldb将自动更新其源映射,但是如果您在Xcode中运行,则在发出命令以使其更新后必须执行一次步骤.

You can type that in on the command line or put it in your .lldbinit file for more general use. lldb will update its source maps automatically, but if you are running in Xcode, you'll have to step once after issuing the command to get it to update.

这篇关于Xcode等同于Visual Studio的“查找源"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆