Process Record Tutorial
This is a short tutorial on how to use gdb's Process Record feature.
Process Record lets you:
- Record a program's execution and play it back.
Debug a program in reverse (see Reverse Debugging).
Contents
Quick Start
To get started using process record, all you need is gdb version 7.0 or later, and an x86 computer running Linux. And, of course, a program to debug. Here's a simple one:
int xyz; int bar () { xyz = 2; /* break in bar */ return 1; } int foo () { xyz = 1; /* break in foo */ return bar (); } int main () { xyz = 0; /* break in main */ foo (); return (xyz == 2 ? 0 : 1); } /* end of main */
Compile this program (with -g of course), and load it into gdb, then do the following.
(gdb) break main (gdb) run (gdb) record
This will turn on process recording, which will now record all subsequent instructions executed by the program being debugged.
Note that you can start process recording at any point (not just at main). You may choose to start it later, or even earlier. The only restriction is that your program has to be running (so you have to type "run" before "record"). If you want to start recording from the very first instruction of your program, you can do it like this:
(gdb) break _start (gdb) run (gdb) record