Repository navigation
GDB Reference
A concise command reference and curated learning directory for GNU GDB (GDB/MI3), mapped to GridLock's graphical debugging workstation and built-in GDB Console.
Compile C, C++, and Fortran targets with DWARF debug symbols so source lines, local variables, macros, and call frames resolve cleanly in both standalone GDB and GridLock:
| Flag Combination | Purpose |
|---|---|
-g3 -O0 |
Full DWARF symbols plus preprocessor macro expansion (#define) with no optimization reordering (recommended for interactive debugging). |
-Og -g |
Debug-friendly optimization level for performance-sensitive HPC kernels that are too slow at -O0. |
-fno-omit-frame-pointer |
Preserves the frame pointer (RBP) for reliable stack unwinding across optimized frames and signal handlers. |
-fcheck=bounds,do,mem |
GFortran runtime array-bounds and loop checks alongside -g -O0 (see Fortran + OpenMP Tutorial). |
gdb ./app # Load binary and enter interactive prompt
gdb --args ./app --steps 100 # Pass CLI arguments to the inferior program
gdb -p <pid> # Attach to an already-running process
gdb ./app core.12345 # Post-mortem inspection of a core dumpTip
Using GDB Inside GridLock: GridLock launches GDB in GDB/MI3 mode (--quiet --nx -iex "set debuginfod enabled off" --interpreter=mi3) and routes interactive commands you type in the GDB Console (Alt+4) to the currently focused MPI rank (or broadcast across all ranks). To load your personal ~/.gdbinit and custom Python pretty-printers, enable Load user .gdbinit / Python pretty-printers in Preferences -> Debugger (disabled by default for safety).
| Command | Short | Description | GridLock Equivalent |
|---|---|---|---|
run [args] |
r |
Start target execution from main
|
Run Target (Alt+R) |
continue |
c |
Resume execution until next stop |
Continue (F5) |
next |
n |
Step over next source line |
Step Over (F10) |
step |
s |
Step into function call |
Step Into (F11) |
finish |
fin |
Run until current function returns |
Step Out (Shift+F11) |
until [line] |
u |
Run until a later line or loop exit |
Run to Cursor (Ctrl+F10) |
break file:line |
b |
Set breakpoint at source line or function | Click editor gutter (F9) |
break func if cond |
b ... if |
Conditional breakpoint (stop only when cond is true) |
Right-click gutter -> Edit Condition... |
watch expr |
Hardware write watchpoint (stop when expr changes) |
Right-click variable -> Add Data Watchpoint | |
rwatch expr / awatch expr
|
Stop on read (rwatch) or read/write (awatch) |
Add Data Watchpoint (Read / Access mode) | |
info breakpoints |
i b |
List all breakpoints and watchpoints with IDs | Breakpoint popover / gutter |
delete [id] |
d |
Delete breakpoint by ID (or all if omitted) | Click gutter marker / Clear All |
disable [id] / enable [id]
|
Toggle breakpoint without removing it | Right-click gutter -> Disable / Enable |
| Command | Short | Description | GridLock Equivalent |
|---|---|---|---|
backtrace [N] |
bt |
Print call stack (optionally top N frames) |
Call Stack dock |
bt full |
Print call stack including local variables for every frame | Call Stack + Variables dock | |
frame N |
f N |
Select stack frame N for inspection |
Click frame row in Call Stack |
up / down
|
Move one frame up (caller) or down (callee) | Select adjacent row in Call Stack | |
info threads |
List all OS / OpenMP threads in current rank | Threads selector in Call Stack | |
thread N |
Switch active inspection context to thread N
|
Click thread entry | |
thread apply all bt |
t a a bt |
Print backtraces across all threads at once | GDB Console |
| Command | Short | Description | GridLock Equivalent |
|---|---|---|---|
print expr |
p expr |
Evaluate and print a C/C++/Fortran expression | Evaluator dock / inline hover |
p/x expr / p/t expr
|
Print in hexadecimal (/x) or binary (/t) |
Programmer's Calculator (Ctrl+Alt+C) |
|
p *ptr@len |
Print len contiguous elements starting at ptr (C/C++) |
Array & Field Plotter (Ctrl+Alt+G) |
|
display expr |
Auto-print expr on every stop |
WATCH dock (DifferentialGrid) |
|
ptype var |
Print full static/struct type definition of var
|
Variables dock type column | |
info locals |
Print all local variables in the current stack frame | Variables dock | |
x/16gx addr |
Examine 16 giant-words (8-byte hex) starting at addr
|
Memory dock (MemView) |
|
disassemble /m func |
disas |
Disassemble function interleaved with source lines |
Disassembly view (Space for CFG) |
info registers |
i r |
Print general-purpose CPU registers | Registers dock |
GridLock's Timeline reverse stepping and Copy-on-Write Checkpoints (Ctrl+Alt+K) drive these native GDB primitives under the hood:
| Command | Short | Description |
|---|---|---|
record full |
Begin recording instruction execution history for reverse stepping | |
reverse-next |
rn |
Step backward one source line (stepping over calls) |
reverse-step |
rs |
Step backward into the previous function call |
reverse-continue |
rc |
Run backward until the previous breakpoint or watchpoint hit |
checkpoint |
Fork a lightweight Copy-on-Write snapshot of the current process state | |
info checkpoints |
List active saved process checkpoints | |
restart N |
Restore execution and memory state back to checkpoint N
|
-
Manual CLI Multi-Rank Launch: Without a parallel frontend, debugging
NMPI ranks manually requires spawning separate terminals (for examplempirun -np 4 xterm -e gdb ./app) or sleeping at startup and runninggdb -p <pid>in separate shells. -
GridLock Multi-Rank Coordination: GridLock automates MPMD per-rank
GDB/MI3orchestration across up to256ranks in one workstation, letting you switch between All Ranks and Focused Rank stepping, compare variable values across ranks in WATCH, inspect wait-for deadlocks in MPI Diagnostics, and attach to already-running OpenMPI, MPICH, PMIx, or Slurm jobs viaFile -> Attach to Process...(Ctrl+Alt+P).
- Official GNU GDB User Manual - Complete authoritative reference for all GDB commands, Python scripting, and remote targets.
- Official GDB/MI (Machine Interface) Specification - Line-oriented protocol specification used by GridLock's backend coordinator and sanitized trace exporter.
- Official GDB Quick Reference Card (PDF) - Printable two-page GNU GDB command summary card.
- Beej's Quick Guide to GDB - Approachable, practical walkthrough covering breakpoints, TUI mode, watchpoints, and core files.
-
UMD / RMS GDB Cheat Sheet & Tutorial Handout (PDF) - Concise university lab reference covering stack frames,
xmemory formats, and pointer inspection. - Red Hat Developer: The GDB Developer's GNU Debugger Tutorial - Multi-part guide by GDB maintainers covering workflows, Python pretty-printers, and diagnostics.
- CppCon / Greg Law ("Give me 15 minutes & I'll change your view of GDB"): Watch on YouTube - Fast-paced tour of TUI mode, Python scripting, reverse debugging, and power-user shortcuts.
- Chris Kanich: GDB Debugging Tutorial Series (University of Illinois Chicago): Watch on YouTube - Clear step-by-step C/systems debugging lessons covering frames, memory examination, and segmentation faults.
- Jacob Sorber: Practical C/C++ Debugging with GDB: Watch on YouTube - Short, focused videos on breakpoints, watchpoints, core dumps, and debugging segfaults.
- Low Level Learning: GDB & Binary/Reverse Debugging Walkthroughs: Watch on YouTube - Hands-on demonstrations of assembly-level inspection, registers, stack layouts, and binary analysis.
- OpenMPI / HPC Multi-Rank GDB Debugging Walkthroughs: Watch on YouTube - Practical walkthroughs for attaching GDB to multi-rank MPI processes and diagnosing parallel hangs.
GridLock Repository | Releases | Report an Issue | Roadmap | Accessibility | License (MIT)
Documentation mirrored from docs/ on master.
Getting Started & Tutorials
Debugging Workflows
- UI & Debugging Manual
- Server Rack View
- MPI Diagnostics & HPC
- OpenMP OMPD Inspector
- Memory, RE & Profiling
- Struct Layout & Cache Lines
- Reference Manual & Packages
Customization & Reference
- Configuration & Themes
- Keyboard Shortcuts
- GDB Reference & Cheat Sheet
- Screenshot Gallery
- Engineering Roadmap
Extending & Architecture