GDB record patch make GDB support Reversible Debugging. It make GDB disassemble the instruction that will be executed to get which memory and register will be changed and record them to record all program running message. Through these on the use of this information to achieve the implementation of the GDB Reversible Debugging function. Record 0.1.3 support sysenter syscall. Then it can be use with Linux kernel 2.6 system call.(In the before, I just tested record on Linux kernel 2.4. So I forgot that the syscall in Linux kernel 2.6 is different with Linux kernel 2.4. Sorry about it.) The other change of record 0.1.3 is that the GDB prompt will auto change to "(rec)" when the record function is started. And it will change to "(rev)" when the reverse function is started. When the record function is stooped, the GDB prompt will be change back to "(gdb)" It make GDB mode is more clear than before. (I always forgot the mode of GDB when I use the record function. So I add this function. ) More information can be obtained want to http://sourceforge.net/projects/record/. You can get the patch and the GDB that patched in there. Record patch add 3 commands to GDB: record(rec) Use to start the record and reverse function. stoprecord(srec) Use to stop the record and reverse function. reverse(rev) When the record and reverse function is started, It use to set GDB to the reverse debug mode or the normal debug mode. When GDB is set to the reverse debug mode, you can use GDB commands (Such as continue, step, print) to control and debug the program. To make and install the GDB record patch 0.1.3 with GDB-6.8: tar vxjf gdb-6.8.tar.bz2 cp gdb-6.8-record-0.1.3.patch gdb-6.8/ cd gdb-6.8 patch -p1 < gdb-6.8-record-0.1.3.patch cd .. mkdir bgdb68 cd bgdb68 ../gdb-6.8/configure make make install gdbrecord The following is how to use the record: cat 1.c int a = 0; void cool2 () { printf ("a = %d\n", a); } int cool () { a += 3; cool2(); return (a); } int main() { int b = 0; int c = 1; printf ("a = %d b = %d c = %d\n", a, b, c); b = cool (); printf ("a = %d b = %d c = %d\n", a, b, c); c += 1; printf ("a = %d b = %d c = %d\n", a, b, c); a -= 2; printf ("a = %d b = %d c = %d\n", a, b, c); return (0); } gcc -g 1.c gdbrecord a.out GNU gdb 6.8 Record 0.1.3 Copyright (C) 2008 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "i686-pc-linux-gnu"... Setting up the environment for debugging gdb. Function "internal_error" not defined. Make breakpoint pending on future shared library load? (y or [n]) [answered N; input not from terminal] Function "info_command" not defined. Make breakpoint pending on future shared library load? (y or [n]) [answered N; input not from terminal] /media/disk/bgdb68/gdb/.gdbinit:8: Error in sourced command file: No breakpoint number 0. (gdb) b main Breakpoint 1 at 0x80483c1: file 1.c, line 19. (gdb) r a.out Starting program: /media/disk/bgdb68/gdb/a.out a.out Breakpoint 1, main () at 1.c:19 19 int b = 0; (gdb) rec record: record and reverse function is started. (rec) n During symbol reading, incomplete CFI data; unspecified registers (e.g., eax) at 0x80483be. 20 int c = 1; (rec) 22 printf ("a = %d b = %d c = %d\n", a, b, c); (rec) During symbol reading, incomplete CFI data; DW_CFA_restore unspecified register ebp (#5) at 0xffffe411. a = 0 b = 0 c = 1 23 b = cool (); (rec) b Breakpoint 2 at 0x80483f3: file 1.c, line 23. (rec) rev record: GDB is set to reverse debug mode. (rev) n 0x080483ee 22 printf ("a = %d b = %d c = %d\n", a, b, c); (rev) 20 int c = 1; (rev) rev record: GDB is set to normal debug mode. (rec) c Continuing. Breakpoint 2, main () at 1.c:23 23 b = cool (); (rec) n a = 3 24 printf ("a = %d b = %d c = %d\n", a, b, c); (rec) c Continuing. a = 3 b = 3 c = 1 a = 3 b = 3 c = 2 a = 1 b = 3 c = 2 The next instruction is syscall exit_group. It will make the program exit. Do you want to pause the program.([y] or n) 0xffffe405 in __kernel_vsyscall () record: record pause the program. (rec) rev record: GDB is set to reverse debug mode. (rev) c Continuing. Breakpoint 2, main () at 1.c:23 23 b = cool (); (rev) c Continuing. Breakpoint 1, main () at 1.c:19 19 int b = 0; (rev) c Continuing. record: running to the begin of record list. main () at 1.c:19 19 int b = 0; (rev) rev record: GDB is set to normal debug mode. (rec) n 20 int c = 1; (rec) 22 printf ("a = %d b = %d c = %d\n", a, b, c); (rec) rec record: record and reverse function has already been started. (rec) srec record: record and reverse function is stopped. (gdb) c Continuing. a = 0 b = 0 c = 1 Breakpoint 2, main () at 1.c:23 23 b = cool (); (gdb) c Continuing. a = 3 a = 3 b = 3 c = 1 a = 3 b = 3 c = 2 a = 1 b = 3 c = 2 Program exited normally. (gdb) quit Breakpoint 1 at 0x80483c1: file 1.c, line 19. (gdb) r a.out Starting program: /media/disk/bgdb68/gdb/a.out a.out Breakpoint 1, main () at 1.c:19 19 int b = 0; (gdb) rec record: record and reverse function is started. (rec) n During symbol reading, incomplete CFI data; unspecified registers (e.g., eax) at 0x80483be. 20 int c = 1; (rec) 22 printf ("a = %d b = %d c = %d\n", a, b, c); (rec) During symbol reading, incomplete CFI data; DW_CFA_restore unspecified register ebp (#5) at 0xffffe411. a = 0 b = 0 c = 1 23 b = cool (); (rec) b Breakpoint 2 at 0x80483f3: file 1.c, line 23. (rec) rev record: GDB is set to reverse debug mode. (rev) n 0x080483ee 22 printf ("a = %d b = %d c = %d\n", a, b, c); (rev) 20 int c = 1; (rev) rev record: GDB is set to normal debug mode. (rec) c Continuing. Breakpoint 2, main () at 1.c:23 23 b = cool (); (rec) n a = 3 24 printf ("a = %d b = %d c = %d\n", a, b, c); (rec) c Continuing. a = 3 b = 3 c = 1 a = 3 b = 3 c = 2 a = 1 b = 3 c = 2 The next instruction is syscall exit_group. It will make the program exit. Do you want to pause the program.([y] or n) 0xffffe405 in __kernel_vsyscall () record: record pause the program. (rec) rev record: GDB is set to reverse debug mode. (rev) c Continuing. Breakpoint 2, main () at 1.c:23 23 b = cool (); (rev) c Continuing. Breakpoint 1, main () at 1.c:19 19 int b = 0; (rev) c Continuing. record: running to the begin of record list. main () at 1.c:19 19 int b = 0; (rev) rev record: GDB is set to normal debug mode. (rec) n 20 int c = 1; (rec) 22 printf ("a = %d b = %d c = %d\n", a, b, c); (rec) rec record: record and reverse function has already been started. (rec) srec record: record and reverse function is stopped. (gdb) c Continuing. a = 0 b = 0 c = 1 Breakpoint 2, main () at 1.c:23 23 b = cool (); (gdb) c Continuing. a = 3 a = 3 b = 3 c = 1 a = 3 b = 3 c = 2 a = 1 b = 3 c = 2 Program exited normally. (gdb) quit