LLDB Cheatsheet

Basic Commands

CommandDescription
lldb <program>Launch LLDB with a specific program.
run/rStart or restart the program.
quit/qExit LLDB.
Ctrl+DExit LLDB.

Process & Attach

CommandDescription
process attach --name <name>Attach to a process by name.
process attach --pid <pid>Attach to a process by PID.
process attach --name <name> --waitforAttach to process by name when it launches.

Breakpoints

CommandDescription
breakpoint set --name <function>Set a breakpoint at the specified function.
breakpoint set -n <function>Set a breakpoint at the specified function (short form).
breakpoint set -a address <address>Set a software breakpoint.
breakpoint listList all breakpoints.
breakpoint deleteDelete all breakpoints.
Note: Alias: b bp

Execution Control

CommandDescription
step/sStep into the next line or function call.
next/nStep over the current line (skips stepping into functions).
finishStep out of the current function and return to the caller.
continue/cResume execution until the next breakpoint or program ends.

Stack & Frames

CommandDescription
thread backtrace/btDisplay the current thread’s call stack.
frame infoShow information about the current stack frame.
frame variable/vShow all variables in the current frame.
frame variable <name>Show a specific variable in the current frame.

Disassembly

CommandDescription
disassembleDisassemble the current function.
disassemble -fDisassemble from the start of the current frame’s function.
disassemble -pDisassemble around the current PC.
disassemble -n <function>Disassemble entire contents of the given function name.
disassemble -a <address>Disassemble function containing this address.
disassemble -s <start> -e <end>Disassemble from start address to end address.
disassemble -s <start> -c <count>Disassemble <count> instructions starting at address.
disassemble --forceForce disassembly of large functions.
Note: Alias: di dis disas

Memory

CommandDescription
memory read <address>Read memory at a specific address.
memory read <start> <end>Read memory from start to end address.
memory read --binary --outfile <file> <start> <end>Dump memory to a binary file.
memory write <address> <value>Write a value to a specific memory address.

Watchpoints

CommandDescription
watchpoint set variable <var>Stop execution when a variable is modified.
watchpoint set expression -- <address>Set a watchpoint on an address expression.
watchpoint set expression -w write -s <size> -- <address>Watchpoint on write with byte size.
watchpoint listList all watchpoints.
watchpoint deleteDelete all watchpoints.

Registers

CommandDescription
register readShow all general-purpose registers.
register read <reg>Show a specific register.
register write <reg> <value>Write a value to a register.

Expressions & Variables

CommandDescription
expr int $delta = 0xb3000Define a convenience variable with a value.
expr $deltaPrint the value of a convenience variable.
expr $delta = 0xc4000Update the value of an existing convenience variable.
expr (int)$delta + 0x1000Use a convenience variable in an expression.
p/x $deltaPrint a convenience variable in hexadecimal.
breakpoint set -a $delta+0x1234Use a convenience variable in a breakpoint address.
memory read $deltaUse a convenience variable as a memory address.

Note: Convenience variables start with $ and persist for the entire debug session.

iOS Remote Debugging

CommandDescription
iproxy 6666 6666Forward port 6666 from device to localhost (on host).
debugserver 127.0.0.1:6666Start debugserver on device listening on port 6666.
frida-server -l 0.0.0.0 &Start frida-server on device (background).
CommandDescription
platform select remote-iosSelect remote iOS platform for debugging.
process connect connect://localhost:<port>Connect to a remote debug server (e.g., debugserver).
image listList all loaded images/modules.
image dump sections <name>Dump sections of a specific module.
p/x <runtime_address>-0x100000000Calculate ASLR slide from runtime base address.
settings set target.process.stop-on-sharedlibrary-events 1Stop when shared libraries are loaded.
settings set target.process.stop-on-sharedlibrary-events 0Don’t stop when shared libraries are loaded.

Resources: