Below is a cheat sheet for LLDB, the debugger used in Xcode and on macOS.
Basic Commands
Launch an executable:
lldb <executable>
Attach to a process:
lldb -p <pid>
Load a core dump:
lldb -c <core_dump>
Setting Breakpoints
Set a breakpoint at a function:
break set -n <function_name>
Set a breakpoint at a file and line:
break set -f <filename> -l <line_number>
Running and Controlling Execution
Run the program:
run
Continue execution:
continue
Step over (next line):
next
Step into (step into functions):
step
Step out (finish current function):
finish
Viewing Variables
Print a variable:
p <variable_name>
Print multiple variables:
p <var1> <var2> ...
Examine memory at an address:
x/<format> <address>
Examining Stack and Frames
Show the backtrace (call stack):
bt
Select a frame:
frame select <frame_number>
Managing Breakpoints
List all breakpoints:
break list
Enable/Disable breakpoints:
break enable/disable <breakpoint_id>
Delete a breakpoint:
break delete <breakpoint_id>
Debugging Information
Show information about a variable:
image lookup -t <type> <address>
List loaded modules:
image list
Miscellaneous
View register values:
register read
Execute an expression:
expr <expression>
Quit LLDB:
quit
Help and Documentation
Display LLDB help:
help
Get help for a specific command:
help <command>
This cheat sheet covers LLDB commands. Adjust commands based on your specific debugging needs and always refer to the official LLDB documentation for detailed information.