Learn LLDB in 1 minute

A no nonsense recipe for using LLDB

Mario Emmanuel
The Console
May 5, 2024

--

Image generated by the author via AI

Introduction

For some reason most tutorials do not cover straight away the most common debugging case:

  1. load the program,
  2. set a breakpoint,
  3. run it,
  4. inspect variables,
  5. go step by step,
  6. continue until next breakpoint and
  7. repeat.

LLDB in 1 minute

  1. Ensure that you are compiling for debugging. I use -g -O0 as $CFLAGS in my makefile.
  2. Launch the debugger: lldb myprogram
  3. Set up the breakpoint for a function named read_tokens present in file tokens.c: breakpoint set -name extract_tokes
  4. Set the command line arguments: settings set target.run-args file.txt
  5. Run the program: run
  6. Inspect a variable with p I (where i is the name of the variable).
  7. Continue the execution with continue.

More advanced use cases

See the many bloated tutorials in the internet.

--

--