Master the fundamental concepts of debugging mastery through this focused micro-challenge.
rr is a Mozilla-developed tool that records program execution and allows deterministic replay. Unlike traditional debuggers where heisenbugs disappear on re-run, rr captures the exact execution trace including syscall results and thread scheduling decisions.
rr record ./program captures all non-deterministic inputsrr replay replays execution identically every timeReverse execution commands in GDB+rr:
reverse-continue (rc): Run backwards until a breakpointreverse-step (rs): Step backwards one source linereverse-finish: Run backwards until the current function returnsFor example, you can set a breakpoint at a crash site, then reverse-step to find the exact instruction that corrupted memory.
You will document how rr record-and-replay debugging works with a program containing an intentional off-by-one bug. Deterministic replay lets you go backwards from the symptom to the root cause, which is invaluable for race conditions and intermittent crashes.
Start with rr record ./program to capture a failing run, then rr replay to debug deterministically. Set a breakpoint at the crash, run rc (reverse-continue) to the last write before corruption, then rs (reverse-step) through the suspect code. Mozilla developed rr specifically because intermittent test failures in Firefox were impossible to debug with conventional forward-only GDB sessions.
Write a C program with a simple buggy function and print documentation explaining how rr record-and-replay debugging works.
Requirements:
Three hints are available for this task, revealed one at a time inside the code workspace so you can struggle productively before seeing them.
All starter code and reference implementations are available for your local setup.
View on Github