Table of Contents
1. Build a program with debugging symbols
To use your program in the debugger you need to make sure to build
it with the -g flag:
g++ FILENAME.cpp -g -o PROG.exe
2. Start the debugger, load your program
Run the debugger with the program executable second to load it into the debugger program.
lldb PROG.exe
3. Debugger prompt
When the program is running you'll see a prompt where you can
enter commands. The prompt begins with (lldb).
4. Debugging commands
| Command | What it does |
|---|---|
run |
Runs the program as normal |
breakpoint set -name FUNCTION |
Sets a breakpoint at the start of the named function. |
breakpoint set --file FILENAME --line LINENUM |
Set a breakpoint on a specific line of a source file |
continue |
Continues the program run when in a paused state |
bt |
View the backtrace of function calls at the current point. |
print VARNAME |
Displays the value of a variable |
expr --raw -- PTRNAME |
View address pointed to by PTRNAME. |
next |
Step (over) to the next line (won't enter function calls) |
step |
Step (into) the next line (will enter function calls) |