GDB: The GNU Project Debugger

GDB and Reverse Debugging

Overview

GDB version 7.0 (due September 2009) will be the first public release of gdb to support reverse debugging (the ability to make the program being debugged step and continue in reverse). See the wiki page here.

Presently, only certain target debugging environments will support reverse debugging. Those targets currently include:

All of those targets, plus any additional ones in the future, will support a common user interface for reverse debugging in gdb, including the new commands:

reverse-continue ('rc') -- Continue program being debugged but run it in reverse

('rc') -- Continue program being debugged but run it in reverse reverse-finish -- Execute backward until just before the selected stack frame is called

-- Execute backward until just before the selected stack frame is called reverse-next ('rn') -- Step program backward, proceeding through subroutine calls.

('rn') -- Step program backward, proceeding through subroutine calls. reverse-nexti ('rni') -- Step backward one instruction, but proceed through called subroutines.

('rni') -- Step backward one instruction, but proceed through called subroutines. reverse-step ('rs') -- Step program backward until it reaches the beginning of a previous source line

('rs') -- Step program backward until it reaches the beginning of a previous source line reverse-stepi -- Step backward exactly one instruction

-- Step backward exactly one instruction set exec-direction (forward/reverse) -- Set direction of execution.

All subsequent execution commands (continue, step, until etc.) will run the program being debugged in the selected direction.

Breakpoints and watchpoints will work in reverse -- allowing you for instance to proceed directly to the previous point at which a variable was modified.

Still to do

Now that the core GDB contains support for reverse debugging, it should be possible to add revese execution support to existing GNU simulators such as the ones built into GDB, as well as non-GNU targets such as valgrind, SID, and qemu.

For greater performance and fidelity in userspace and/or kernel reverse debugging, some work on GNU/Linux as well as other open source kernels might be done.

The built-in GDB target 'Process Record / Replay' currently only supports native reverse debugging on three platforms (i386-linux, amd64-linux, and moxie-elf). Volunteers are needed to extend this functionality to other GNU/Linux platforms, and even to other operating systems.

The FSF and GDB maintainers are eagerly seeking new volunteers and contributions in this area. If anyone reading this is interested in contributing to this leading edge area of research and development, we would welcome your help!

Acknowledgements

Tomas Holmberg contributed MI support for reverse debugging in Eclipse

Oza Pawandeep contributed floating point reverse support for i386

Anthony Green contributed a process record port for moxie-elf

Hui Zhu contributed a process record port for amd64-linux

Hui Zhu contributed the process record framework, along with the original port for i386-linux

Dave Brolley contributed a reversible SID simulator for xstormy16

(Note that sid is not a GNU project, but it is licensed under the GPL.)

(Note that sid is not a GNU project, but it is licensed under the GPL.) Michael Snyder contributed the core gdb framework for reverse debugging

All of the gdb maintainers are to be thanked for invaluable discussion, suggestions, and code review.