How does reverse debugging work?

I’m a gdb maintainer and one of the authors of the new reverse debugging. I’d be happy to talk about how it works. As several people have speculated, you need to save enough machine state that you can restore later. There are a number of schemes, one of which is to simply save the registers or memory locations that are modified by each machine instruction. Then, to “undo” that instruction, you just revert the data in those registers or memory locations.

Yes, it is expensive, but modern cpus are so fast that when you are interactive anyway (doing stepping or breakpoints), you don’t really notice it that much.

Leave a Comment