(Preface: I\'m pretty new to C/C++ and I don\'t really know how debugging in native code actually works.)
Some sources say that gdb and lldb can debug any program co
In theory you should be able to debug a GCC-built program with lldb and an LLVM-built program with gdb. In both cases you should compile with -g
.
This is because both compilers generate object files in the same format (e.g., on Linux, both will generate ELF files with DWARF debug info) and both debuggers know how to parse that format.
In practice, both compilers push some data into the debug info that only their respective debugger knows how to consume. However:
-gdwarf-2
over -g
should only generate standard-compliant DWARF.Notice that you can also debug programs without debug info (not compiled with -g
), but you'll be limited to low-level information in the debugger - assembly code, memory and registers - and will not be able to see high level constructs such as line numbers, function names, mapping between variable names and their content, etc.