LLDB is a next generation, high performance debugger that is the default debugger in Xcode on Mac OS X. It supports modern multi-threaded programs and has up-to-date language support for C, C++, and Objective-C. LLDB is extensible through a Python scripting interface and plug-in architecture. It allows users to set breakpoints, watchpoints, and hooks to examine variables and threads.
2. Overview
LLDB is a next generation, high performance
debugger
Available under the standard LLVM license,
an open source ‘BSD-Style’ license
Default debugger in Xcode on MAC OS X
3. Features
Supports modern multi-threaded program
Upto date language support for C, C++,
Objective C
Extensible : Python scriptable and use a
plug-in architecture
5. Execution
(lldb) r / run (run)
(lldb) s / step (source level single step in)
(lldb) n / next (source level single step over)
(lldb) si / ni (instruction level single step in)
(lldb) finish (step out of currently selected
frame)
6. Hooks
(lldb) target stop-hook add
Enter your stop hook command(s). Type ‘DONE’ to end.
> print i
> DONE
Stop hook #1 added
(lldb) n
(int) $32 = 1
7. Breakpoint
(lldb) b main (Set a break point at all function named
main)
(lldb) b test.c:12 (Set a breakpoint in file test.c at line
12)
(lldb) b -[NSString stringWithFormat:]
(lldb) br s -S count / br set -S
vtDataCenterFetchComplete:userData:
(lldb) br delete [n]
8. Watchpoint
(lldb) watch set var -w write global_var (set
write watchpoint)
(lldb) watch set exp -w write -- my_ptr (set
write watchpoint in pointer)
(lldb) watch set var -w read global_var (set read
watchpoint)
(lldb) watch modify -c ‘(global==5)’ (set
condition on watchpoint)
9. Examining Variables
(lldb) frame variable (show arguments for the
current frame)
(lldb) frame v -a (--no-args) (show the local
variables for the current frame)
(lldb) frame v isChanged (p isChanged)
(lldb) target v (show the global/static variables)
(lldb) print a_var / po a_var
10. Examining Thread state
(lldb) thread backtrace (show the stack
backtrace)
(lldb) bt
(lldb) up (select the stack frame that called
the current stack frame)
(lldb) down (select the stack frame that is
called by the current stack frame)
11. Executable & Shared
Library
(lldb) image list (list the main executable and
all dependent shared libraries)
(lldb) image dump sections (dump all sections
from the main executable and any shared
libraries)
12. LLDB Python
(lldb) script help(lldb)
(lldb) script help(lldb.SBFrame)
(lldb) script (Python interpreter)
Define New Command with Python
Define New Breakpoint action with Python
13. Tips
Alias
(lldb) command alias bfl breakpoint set -f
%1 -l %2
(lldb) bfl foo.c 12
Init file
Reads the file ~/.lldbinit at startup
14. Examples
br set -S invalidateCache
br set -S
vtDataCenterFetchComplete:userData:
watch set var -w read selectedDate