Reverse debugging with gdb

I managed to work with gdb's reverse debugging finally. That means I can step back in time, step to the previous lines and back to the callers, not only back out the backtrace.

It should work since version 7.0 but got it working only today. The first times I got annoyed by the warning:

Breakpoint 1, ...
(gdb) target record
(gdb) rn
Target child does not support this command.

Hmm... I knew nothing about target "child" and I read that those should work fine: Native i386-linux ('target record'), Native amd64-linux ('target record')

This is because I used the gdb command run. Now I changed my .gdbinit to use start and continue and set proper breakpoints, and rn (reverse-next aka previous) works fine. I feel stupid.

$ cat .gdbinit

set breakpoint pending on
start
b potion_vm
b potion_jit_proto
continue
target record-core
b core/vm.c:508
continue

define pd
  call potion_dump(P, $arg0)
end

$ make -s bin/potion-s && gdb-7.6 --args bin/potion-s -Dctv -B test/closures/default1.pn ...

(gdb) rn

and now I can go backwards from my breakpoint.

Note that record-full slows down my experience a lot, even on a tiny program, so I only use record-core, and only after leaving out the initialization. So I set a first breakpoint, set on recording and continue from there.

1 Comment

Surely "reverse debugging" is the process of inserting bugs into your code?!

About Reini Urban

user-pic Working at cPanel on cperl, B::C (the perl-compiler), parrot, B::Generate, cygwin perl and more guts, keeping the system alive.