The lldb Debugger ======================================== (2020) Compile a binary with debugging information (minimally, `-g`): ``` 🐚 $ clang -O0 -gfull -Wall -Wextra -pedantic hello.c -o hello ``` Run the binary in the lldb debugger: ``` 🐚 $ lldb ./hello ``` lldb commands tend to follow this syntax: ``` [-options [option-value]] [argument [argument...]] ``` lldb has extensive help available. ``` (lldb) help Debugger commands: apropos -- List debugger commands related to a word or subject. breakpoint -- Commands for operating on breakpoints (see 'help b' for shorthand.) bugreport -- Commands for creating domain-specific bug reports. command -- Commands for managing custom LLDB commands. … ``` Use either lldb noun-verb commands or aliases to the equivalent gdb commands: - `thread step-in` or `step` or `s`: next line (will step into any function call) - `thread step-over` or `next` or `n`: next line in current thread (step over function call) - `thread step-out` or `finish`: exit this scope Set break point. Watch. Links ---------------------------------------- - https://en.wikipedia.org/wiki/LLDB_(debugger) - https://lldb.llvm.org/use/map.html - https://lldb.llvm.org/use/tutorial.html - https://clang.llvm.org/docs/ClangCommandLineReference.html#debug-information-generation - https://developer.apple.com/library/archive/documentation/IDEs/Conceptual/gdb_to_lldb_transition_guide/document/lldb-command-examples.html - https://towardsdatascience.com/an-introduction-to-debugging-in-c-and-lldb-part-i-e3c51991f83a - https://towardsdatascience.com/an-introduction-to-debugging-in-c-and-lldb-part-i-e3c51991f83a