Learn LLDB in 1 minute
A no nonsense recipe for using LLDB
Published in
May 5, 2024
Introduction
For some reason most tutorials do not cover straight away the most common debugging case:
- load the program,
- set a breakpoint,
- run it,
- inspect variables,
- go step by step,
- continue until next breakpoint and
- repeat.
LLDB in 1 minute
- Ensure that you are compiling for debugging. I use
-g -O0
as$CFLAGS
in my makefile. - Launch the debugger:
lldb myprogram
- Set up the breakpoint for a function named
read_tokens
present in filetokens.c
:breakpoint set -name extract_tokes
- Set the command line arguments:
settings set target.run-args file.txt
- Run the program:
run
- Inspect a variable with
p I
(wherei
is the name of the variable). - Continue the execution with
continue
.
More advanced use cases
See the many bloated tutorials in the internet.