Xcode equivalent of Visual Studio's “Find Source”

后端 未结 1 1101
粉色の甜心
粉色の甜心 2021-01-06 13:09

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 fun

相关标签:
1条回答
  • 2021-01-06 13:57

    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"
    

    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"
    

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

    "/Users/ME/QT/sources"
    

    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
    

    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.

    0 讨论(0)
提交回复
热议问题