8

Hmm... My teacher, some of my classmates and I are going to build a Debugger project. We hope that our debugger is interactive, that is, when codes are typed in, the result will be displayed somewhere few seconds later, and the result changes while the input code changes. On the other hand, while running, we can rollback to the former line or breakpoints.

In accordance with my teacher's word, the technique "Time Travel Debugging" will be involved while programming. I searched some project that maintained by others but I can poorly understand the code and there are no introductions about this technique in any of those README files.

reference: https://github.com/mattgodbolt/compiler-explorer

Stephen.W
  • 1,649
  • 13
  • 14
  • 5
    Is your teacher a fan of Dr. Who, perhaps? "Time Travel Compiling" is not a standard term. It seems like a phrase that they coined. You could ask them what they mean by it. – John Coleman Feb 08 '17 at 03:16
  • It's about being able to set a breakpoint in a debugger and then step *backwards* through statements to see the state of the runtime environment at points *before* the breakpoint. – Pointy Feb 08 '17 at 03:23
  • And it doesn't really have a whole lot to do with *compilers*, really; it's a runtime system thing. Well, I *guess* a compiler could generate code to maintain some sort of audit context, but that seems like a really weird way of doing things. – Pointy Feb 08 '17 at 03:24
  • It is not standard to call compiler to an interpreter, which seems to be what it is going to be implemented @JohnColeman – Germán Diago Feb 08 '17 at 04:03
  • @GermánDiago The exact phrase "Time Travel Compiling" currently gathers just 5 Google hits, with 3 of them being due to this very question, so in that sense it is genuinely not a standard term. It is somewhat difficult to think of natural sounding 3-word phrases that garner so few hits. – John Coleman Feb 08 '17 at 04:09
  • 1
    Of interest: [OCaml - The debugger (ocamldebug)](http://caml.inria.fr/pub/docs/manual-ocaml-4.00/manual030.html#toc126) OCaml also has time travel debugging. – Guy Coder Feb 08 '17 at 12:03
  • 1
    Of interest: [Visual Studio IntelliTrace](https://msdn.microsoft.com/en-us/library/dd264915.aspx) – Guy Coder Feb 08 '17 at 19:32

2 Answers2

11

This is most commonly known as "time travel debugging", and is often associated with "Functional Reactive Programming". (Those are terms which you can easily search.) There are some reasonably accessible documents on the Elm Language blog (for example, time travel made easy), but I'd suggest you start at the beginning rather than diving into the middle and having to time travel your understanding (some pun intended :-))

Strictly speaking, time travel debugging is something that happens at runtime, but it is much easier if you are programming in a functional language (such as Haskell, Elm, OCAML, or various others, for which time-travelling debuggers have been implemented), and compiling these languages (yes, they are compiled) involves some interesting concepts.

Elm compiles to javascript, which makes it relatively easy to experiment with.

Have fun with the project.

asgs
  • 3,928
  • 6
  • 39
  • 54
rici
  • 234,347
  • 28
  • 237
  • 341
  • AFAIK it can be used with all pure functional programming, why are you limiting it to just functional reactive? – Guy Coder Feb 08 '17 at 12:06
  • @Guy: I'm not. In fact, it can be used with non-functional programming as well; there is a time-travel debugger for javascript, which is decidedly not a functional programming language. What I said is that it is often associated with FRP, which was intended to give some pointers to OP to search more information. I added OCAML to the list of functional language in the second paragraph. – rici Feb 08 '17 at 19:07
  • You might also want to mention, [Visual Studio IntelliTrace](https://msdn.microsoft.com/en-us/library/dd264915.aspx) – Guy Coder Feb 08 '17 at 19:34
  • @GuyCoder: Unless there is a reference for the implementation strategy of VS IntelliTrace, I don't see how the fact that it exists helps someone who is trying to build such a project. I suppose that it is of interest that such a thing exists, but many such things exist and some of them have accessible information about the way they were designed. – rici Feb 08 '17 at 20:03
4

Time travel debugging is also known as reverse debugging. In layman terms, you can debug the same lines again and again (without stopping/restarting the app).

For example, you're debugging a method which threw an exception at line 10, to find the cause of exception you can again execute that method from a prior point let's say line 4 without restarting the complete debugging process. it's all real-time and pretty efficient.

I've used this feature in Visual Studio.

GorvGoyl
  • 42,508
  • 29
  • 229
  • 225