Debug Optimised Builds With -Og and -fvar-tracking
Why GDB shows optimized out and jumps lines at -O2, how GCC -Og and variable tracking keep more values, and what to do when you must debug the real build.
GDB and LLDB, JTAG and SWD with OpenOCD, Valgrind and sanitizers, core dumps, tracing and logic analysers: finding the bug instead of the symptom.
Why GDB shows optimized out and jumps lines at -O2, how GCC -Og and variable tracking keep more values, and what to do when you must debug the real build.

Set up cargo-fuzz 0.13 on a Rust nightly toolchain, fuzz a parser that uses unsafe code, read the crash report and replay, minimize and keep the failing input.

Point GDB at a debuginfod server with DEBUGINFOD_URLS and it downloads matching debug symbols and source for any shared library on demand, keyed by build ID.

Decode an SPI flash ID read and an I2C TMP102 temperature read by hand from logic analyser captures, with sample points, start, stop and ACK bits explained.

Fuzzing feeds a program mutated inputs and watches for crashes. Coverage feedback keeps inputs that reach new code, so an impossible search becomes short.

Attach GDB to a process that is already running with gdb -p or attach, inspect where it is stuck, then detach so it keeps running. Covers permissions.

Use ISPF HEX ON in edit or browse to read COMP-3 packed decimal fields in a dataset, decode sign nibbles by hand, and find the record that causes an S0C7.

Set kernel.perf_event_paranoid, kernel.kptr_restrict and CAP_PERFMON so perf can sample user and kernel code without running everything as root.

Decode the eBPF verifier message invalid access to packet in an XDP program, read the off, size and r values, and add the missing data_end bounds check.

Stop only when it matters. Set a condition with break ... if, change it with condition, skip hits with ignore, and learn what conditions cost on hot paths.

Dispatch on a function code in HLASM with a branch table: range-check and scale the index, then branch through B instructions or an address table.

Use perf annotate to see which assembly instructions and source lines inside a hot function receive the most samples, and how to read skid correctly.
We send one email when a new post is published. No spam.