The line pointed to by the arrow is the next line to be executed.
Short Commands
r: run
c: continue
b: break
n: next
Enter: repeat last command
s (step): step into a function
q: quit
How to Use LLDB
-
Generate source-level debug information:
gcc -g hello.c -
Run LLDB on the executable:
lldb a.out -
Run the program:
(lldb) run
Setting Breakpoints
(lldb) breakpoint set -f demo.cpp -l 10
(lldb) br s -f demo.cpp -l 10
(lldb) b demo.cpp:10
Breakpoints with Symbols
On a function:
(lldb) b square
On a class method:
(lldb) b Demo::demo
Inside a namespace:
(lldb) b LLDBDemo::add
Manipulating Breakpoints
Listing breakpoints:
(lldb) br list
Deleting breakpoints:
(lldb) br del 1
(lldb) br del
Stepping Around
Step over:
(lldb) next
(lldb) n
Step into:
(lldb) step
(lldb) s
Step out:
(lldb) finish
Continue:
(lldb) continue
(lldb) c
Inspecting Variables
Print variable contents:
(lldb) p varname
(lldb) print varname
Frame variables (see all visible variables):
(lldb) frame variable
(lldb) fr v
Current line:
(lldb) frame select
Backtrace and Frames
Backtrace:
(lldb) bt
Switching frames:
(lldb) frame select 0
(lldb) f 2
Using Watchpoints
Program must be running to set watchpoints.
Global variable:
(lldb) watchpoint set variable globalVariable
(lldb) watchpoint set variable -w read | write | read_write globalVariable
Member variable:
(lldb) b main
(lldb) run
(lldb) w s v d.memberVar
Terminating
Kill process:
(lldb) kill
Exiting:
(lldb) quit
(lldb) q
Additional Tips
- Repeat last command: Press
Enter - Set breakpoint at function:
b mainorb func_name - Print variable:
print varnameorp varname - Print all variables:
fr v - Show help:
helporhelp <command>