
GDB Cheat Sheet: The Commands You Use Every Day
A GDB command reference grouped by task, with the short form of each command, an example and the case where that command is the wrong choice.
Everything you need to level up your coding skills.

A GDB command reference grouped by task, with the short form of each command, an example and the case where that command is the wrong choice.

Diagnose an S0C4 in a COBOL program on z/OS: read the reason code, find the statement, and check subscripts, linkage parameters and storage with SSRANGE.

Build the perf tool from the Linux source tree with make -C tools/perf, check the feature report, and install it so its version matches the kernel you run.

Find why a KVM guest is slow or stuck by recording kvm tracepoints with trace-cmd and summarizing VM exits by reason with perf kvm stat, with sample output.

Use GDB's print, display, ptype and info locals to read scalars, arrays, structs and pointers, and change output with format letters, @ slices and set print.

Work out how many tracks and cylinders a z/OS dataset needs from record count, LRECL and block size on 3390 DASD, with a worked example and the SPACE parameter.

Sample a program with perf record, rank functions with perf report, and read the Overhead, Command and Symbol columns to find the code that burns your CPU time.

Record simulation waveforms with $dumpfile and $dumpvars, choose which scopes to dump, switch dumping on and off, and read the VCD file Icarus Verilog writes.

Move through a C program one line at a time in GDB with next, step, finish, until and advance, and learn which one to use when a line calls a function.

Find and fix an S0C7 in COBOL: read the CEE3207S message, locate the statement, check packed and zoned fields in the dump, and validate input with IS NUMERIC.

Count cycles, instructions and cache misses with perf stat, then read instructions per cycle and miss ratios to tell compute from memory stalls.

Use GDB's break command with a function name, a line number, file:line, an address or an offset, then list, disable, delete and make breakpoints temporary.
We send one email when a new post is published. No spam.