forgodsakehold
forgodsakehold

Reputation: 904

Show Full File Path of Source File When Stepping through Code in lldb

When I step through my code in lldb, there will be an indication of the source file name:

(lldb) s
Process 23824 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = step in
    frame #0: 0x00000001000073b2 clang`llvm::SmallVector<std::__1::pair<void*, unsigned long>, 0u>::SmallVector(this=0x00007ffeefbff080) at SmallVector.h:843

So I can see here we are at line 843 on SmallVector.h.

However, I do not know what's the full file path of this file and I am forced to use Terminal's find to find it. And it becomes a problem if there's more than one file with the same name.

Is there a setting I can change so lldb will dump the full file path?

Upvotes: 3

Views: 1401

Answers (1)

Jim Ingham
Jim Ingham

Reputation: 27110

If you only want one-time printing of this information, you can use the source info command to dump info about a source file. For instance:

(lldb) source info -a $pc

will dump the full path to the source file at the current pc (among other things).

If you want to see full paths in backtraces all the time, you can adjust the lldb setting frame-format which controls the frame printing in backtraces. See:

https://lldb.llvm.org/use/formatting.html

for more details. In your case you want:

settings set frame-format frame #${frame.index}: ${frame.pc}{ ${module.file.basename}{\`${function.name}}}{ at ${line.file.fullpath}:${line.number}}\n

Use settings show frame-format to see the default setting.

Upvotes: 10

Related Questions