Time travel is here, at least when it comes to debugging


At CppCon 2017, the Time Travel Debugging team (TTD) came through with a present for all the developers out there: A reverse debugging tool!

Time Travel Debugging captures a trace of the program being executed so that the run can be replayed later. When you load the trace in the debugger, you can jump to any point in the program's execution, be it forward or backward. Single-stepping backward through the code lets you trace backward where a bad value came from. You can set write breakpoints on memory and then ask the program to execute backward: The breakpoint will fire when the memory was previously written. Again, this lets you trace backward where a bad value came from.

(As noted in the talk, this is similar in many ways to the rr project, but differs in many was as well.)

Bonus chatter: I helped out with the replay portion of this project some time ago. I wrote the second version of the jitter's register allocator, as well as implementing some of the opcodes. I'm told that some of my code has since been removed, but other parts remain.

Comments (6)
  1. Anon says:

    On ARM systems Lauterbach debuggers with ETM do a really good job of this. You can set the system up to hit a breakpoint when something interesting happens and then step back in time from there to see how it got there.

  2. Lev says:

    So does it dump the entire memory of the process after each CPU instruction?

    1. snarf says:

      Or maybe just keep a history of writes…

    2. Zan Lynx' says:

      It doesn’t have to do that. It could record a snapshot of modified pages and register state. It only has to do that at certain points like system calls or access to non-local state.

      Like a movie encoding, it can play things backward by moving to a snapshot and running forward N steps, then back up by again running forward N-1 steps, or by recording everything for each of N steps.

      1. skSdnW says:

        GetTickCount and some other time/date stuff are not syscalls and just access a special page in memory. I wonder how they deal with that.

    3. Michael says:

      A link to the paper describing the pre-product version is available through here: https://mobile.twitter.com/JamesMcNellis/status/912545386320896000
      The tweet he replies to has a link to a paper about rr.

Comments are closed.

Skip to main content