Go up to the main documents page (md)
Both gdb and lldb are excellent debuggers. 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. However, a bug with LLVM prevents it from working inside a Ubuntu VirtualBox image (see here for the bug tracker about this issue). Thus, we are going to use gdb instead of lldb, even though we will continue to use the clang++ compiler.
Both debuggers can debug code compiled by either compiler. The only real differences, as far as this class is concerned, have to do with some of the commands. There are other differences between the debuggers, but those differences are not commands that we will see in this course. The full list of commands can be found on the GDB command summary page and the LLDB command summary page.
The majority of the commands are the same; this document only highlights the commands that are different between the two debuggers. The categories listed below match those on the two specific debugger pages (GDB command summary and LLDB command summary).
Assembly-specific commands
info registers
for gdb, registers read
for lldbset disassembly-flavor intel
for gdb, settings set target.x86-disassembly-flavor intel
for lldbdisassemble (function)
for gdb,
disassemble --name (function)
for lldbProgram execution
start
in gdb; there is no direct equivalent in
lldb (but you can do it via two commands: b main
and
run
)list
in gdb, f
in
lldbBreakpoints
info break
in gdb, breakpoint
list
in lldbdelete
(or just d
)
in gdb, breakpoint delete
in lldbdelete (num)
in gdb, breakpoint delete (num)
in lldbExamining data
info
locals
in gdb, frame variable
in lldbset variable
(var) = (value)
in gdb, expr (var) = (value)
in
lldb