LLDB cheatsheet

You,lldb

LLDB Cheat Sheet

Setup and Basics

CommandAliasDescription
lldb <program>Launch LLDB with a specific program.
runrStart or restart the program.
quitqExit LLDB.

Breakpoints

CommandAliasDescription
breakpoint set --file <file> --line <n>bSet a breakpoint at a specific file and line.
breakpoint listList all breakpoints.
breakpoint deleteDelete all breakpoints.
breakpoint delete <id>Delete a specific breakpoint by ID.

Navigating Execution

CommandAliasDescription
stepsStep into the next line or function call.
nextnStep over the current line (skips stepping into functions).
finishStep out of the current function and return to the caller.
continuecResume execution until the next breakpoint or program ends.
thread backtracebtDisplay the current thread's call stack.

Inspecting Code and Variables

CommandAliasDescription
frame variablevShow all variables in the current frame.
frame variable <name>Show a specific variable in the current frame.
print <expression>pEvaluate and print the value of an expression or variable.
frame infoShow information about the current frame.

Working with Threads and Frames

CommandAliasDescription
thread listList all threads in the program.
thread select <id>Switch to a specific thread by ID.
frame select <id>Switch to a specific frame in the call stack.
thread step-inStep into the current thread’s execution.

Examining Memory

CommandDescription
memory read <address>Read memory at a specific address.
memory write <address> <value>Write a value to a specific memory address.

Environment Variables

CommandDescription
settings set target.env-vars <key>=<value>Set an environment variable for the target program.
settings show target.env-varsShow all environment variables set for the target.

Advanced Commands

CommandDescription
watchpoint set variable <var>Stop execution when a variable is modified.
disassembleShow the disassembly of the current function.
expression <expr>Evaluate and execute a new expression.

Shortcuts for Workflow

ScenarioCommands
Step into a function callstep or s
Skip over a function callnext or n
Exit the current functionfinish
Resume executioncontinue or c
Inspect all variablesframe variable or v
Check where you areframe info
View the call stackthread backtrace or bt

Example Workflow

  1. Set a breakpoint:
    (lldb) breakpoint set --file main.rs --line 10
  2. Run the program:
    (lldb) run
  3. Step through the code:
     (lldb) step
  4. Inspect variables:
    (lldb) frame variable
  5. Continue execution:
    (lldb) continue