lldb is the llvm debugger, which I frequently use for debugging
C and C++ programs on OS X and Linux. I access it through
iCompile using icompile --lldb
, but you can launch
it from the command line directly as well. Below are the most
common commands that I use when
debugging. The GDB
to LLDB reference in the manual contains more exotic ones should
you require them. lldb has a complete Python interpreter within it,
so if you're familiar with that language you can use it to run
very sophisticated command sets on breakpoints or just interact
using Python syntax instead of debugger-specific syntax.
Run (or restart) the program. |
r
|
See the call stack (backtrace) |
bt
|
Change the current stack frame to the third back from the top of the stack |
f 3
|
Show all variables and function arguments in the current frame |
fr v
|
Show the value of variable name in the current stack frame
|
p name
|
Set a breakpoint at all functions named "main" |
b main
|
Set a breakpoint in file main.cpp at line 10 |
b main.cpp:10
|
Break on all exceptions (Linux) |
break set -E c++
|
Break on all exceptions (OS X) |
break set -n __cxa_throw
|
List all breakpoints |
breakpoint list
|
Delete breakpoint #2 from the list |
breakpoint delete 2
|
Step over the next expression (don't recurse into it) |
s
|
Step over the into expression (recurse into function calls) |
n
|
Step over the into expression (recurse into function calls) |
n
|
Continue execution until the end of the current call frame |
finish
|
Continue execution until the next breakpoint or assertion |
c
|