Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

LLDB - setting source code path

According to the official guideline of lldb, the ability to view source code during debug session (using the command source list) is done by setting new pathname for source files.

i.e. if i compiled my project in /tmp on one computer and deployed it on another computer where the source code reside in /Users/Src/ , i should type settings set target.source-map /tmp /Users/Src from running lldb in the deployment machine.

However, what happens if i got the executable from someone else, and don't know the build directory. and maybe the source-code is organized differently from where is was built (but the file contents is the same).

my questions are :

  1. Does lldb know how to search for matching source file recursively in the supplied path ?

  2. How can I get the original pathname form the mach-o executable ?

here's the formal description of the command :

Remap source file pathnames for the debug session. If your source files are no longer located in the same location as when the program was built --- maybe the program was built on a different computer --- you need to tell the debugger how to find the sources at their local file path instead of the build system's file path.

like image 519
Zohar81 Avatar asked Nov 07 '16 08:11

Zohar81


1 Answers

If you know a function name in the code in question, do:

(lldb) image lookup -vn <FunctionName> <BinaryImageNameContainingFunction>

and look for the CompileUnit entry. The path given there is the path lldb got from the debug information.

like image 83
Jim Ingham Avatar answered Oct 04 '22 04:10

Jim Ingham