Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

LLDB equivalent of gdb "directory" command for specifying source search path?

Looking for the lldb equivalent of the gdb "directory" command to add search paths for finding missing source code (or possibly similar functionality within xcode)?

Thanks in advance!

like image 599
IODEV Avatar asked Oct 19 '12 11:10

IODEV


People also ask

Is LLDB the same as GDB?

In brief, LLDB and GDB are two debuggers. The main difference between LLDB and GDB is that in LLDB, the programmer can debug programs written in C, Objective C and C++ while, in GDB, the programmer can debug programs written in Ada, C, C++, Objective C, Pascal, FORTRAN and Go.

Is LLDB compatible with GDB?

The standard LLDB installation provides you with an extensive set of commands designed to be compatible with familiar GDB commands. In addition to using the standard configuration, you can easily customize LLDB to suit your needs. Both GDB and LLDB are of course excellent debuggers without doubt.

What is GDB LLDB?

GDB is part of the GNU framework, and was created to work alongside of g++ , which is the GNU C++ compiler. LLDB is part of the LLVM framework, and was created to work alongside of clang++ , which is the LLVM C++ compiler. Ideally, you would use the debugger of the same framework that the compiler is part of.

How do I point GDB to my sources?

When you start GDB, its source path includes only ' $cdir ' and ' $cwd ', in that order. To add other directories, use the directory command. The search path is used to find both program source files and GDB script files (read using the ' -command ' option and ' source ' command).


1 Answers

The target.source-map setting allows you define a series of a => b path remappings in the debug session. It's not identical to the gdb dir command, which is a list of directories to search for source files by base name, but you can solve the same problems with source-map. Here's an example where I move a source file to a hidden directory after compiling:

% cd /tmp
% echo 'int main () { }' > a.c
% clang -g a.c
% mkdir hide
% mv a.c hide/
% xcrun lldb a.out
(lldb) settings set target.source-map /tmp /tmp/hide
(lldb) l -f a.c
   1    int main () { }
(lldb) br se -n main
Breakpoint created: 1: name = 'main', locations = 1
(lldb) r
Process 21674 launched: '/private/tmp/a.out' (x86_64)
Process 21674 stopped
* thread #1: tid = 0x1f03, 0x0000000100000f49 a.out`main + 9 at a.c:1, stop reason = breakpoint 1.1
    #0: 0x0000000100000f49 a.out`main + 9 at a.c:1
-> 1    int main () { }
(lldb) 

For more information about this setting, type set list target.source-map in lldb. fwiw you might have discovered this in lldb by doing apropos path which will list all commands/settings that have the word path in the name/description. Seeing that there was a setting by this name, you'd do settings list to see the list of settings and find out that it's filed under target..

like image 168
Jason Molenda Avatar answered Oct 16 '22 08:10

Jason Molenda