65

gdb implemented support for reverse debugging in 2009 (with gdb 7.0). I never heard about it until 2012. Now I find it extremely useful for certain types of debugging problems. I wished that I heard of it before.

Correct me if I'm wrong but my impression is that the technique is still rarely used and most people don't know that it exists. Why?

Do you know of any programming communities where the use of reverse debugging is common?

Background information:

10
  • 47
    For the benefit of those who don't know it exists, what is reverse debugging? Commented Jan 4, 2013 at 14:58
  • 5
    MS called their system intellitrace which appears to be similar to what you call revese debugging, it could be a matter of multiple names depending on enviorment making it seem less used.
    – Ryathal
    Commented Jan 4, 2013 at 15:12
  • 2
    Just for what it's worth: it's really much older than you realize -- Microsoft supported it in QuickC (around 1989 or '90, if memory serves). Commented Jan 4, 2013 at 19:41
  • 43
    @MasonWheeler, clearly reverse debugging is the act of adding bugs to code. I disagree with the OP's premise that this is an uncommon practice.
    – Ben Lee
    Commented Jan 7, 2013 at 19:51
  • 3
    @BenLee, we call that rebugging.
    – OldFart
    Commented Jan 31, 2013 at 15:14

5 Answers 5

28

For one, running in debug mode with recording on is very expensive compared to even normal debug mode; it also consumes a lot more memory.

It is easier to decrease the granularity from line level to function call level. For example, the standard debugger in eclipse allows you to "drop to frame," which is essentially a jump back to the start of the function with a reset of all the parameters (nothing done on the heap is reverted, and finally blocks are not executed, so it is not a true reverse debugger; be careful about that).

Note that this has been available for several years now and works hand in hand with hot-code replacement.

3
  • 1
    Very good answer. I can confirm that recording is expensive. You have to enable it just before you enter the critical part of your application, which is not always trivial. I also agree that "drop to frame" is often good enough. It does not work well with loops or recursive algorithms, though. Commented Jan 4, 2013 at 15:49
  • 3
    That's until rr (rr-project.org). speed while recording an execution using rr is barely slower. You can then replay, step in, rewind, set watchers in your favourite IDE (github.com/mozilla/rr/wiki/Using-rr-in-an-IDE)... The way you debug your code will never be the same.
    – jyavenard
    Commented Aug 24, 2017 at 12:31
  • rr doesn't seem to support anything outside x86/amd64... Commented Feb 29, 2020 at 4:51
11

As mentioned already, performance is key e.g. with gdb's reversible debugging, running something like gzip sees a slowdown of 50,000x compared to running natively. There are commercial alternatives however: I work for Undo undo.io, and our UndoDB product does the same but with a slowdown of less than 2x. There are other commercial reversible debuggers available too.

3
  • 1
    Interesting, I will definitely give it a try. In several articles, it is stated that it is free for non-commercial usage but I found no information confirming that on your homepage. Is it still true? Thanks for disclosing your affiliation. Commented Jan 6, 2013 at 15:18
  • 3
    What are the prices for the Starter and Professional versions of UndoDB? I don't see them on the UndoDB editions page.
    – tcrosley
    Commented Jan 6, 2013 at 20:18
  • 3
    How are you guys comparing to Mozilla's rr? Commented Sep 9, 2017 at 3:27
10

For an overview of the technology choices and products, see a series of blog posts I wrote about a year ago (and some follow-ups since):

My feeling for why it is used so little is that it requires special hardware, or using a special debugger, or setting up your system right. Most people do not invest the time to get maximum value from their debug tools, unfortunately.

And the fact that the "cheap default" of gdb is almost unusably slow and has quite a few stability problems for everything but the most common target systems.

4

From my experience as a sales engineer for TotalView debugger, people do know that it exists but they don't think it works, regardless of the (acceptable or not) slowdown.

University of Cambridge recently did a survey entitled "Failure to Adopt Reverse Debugging Costs Global Economy $41 Billion Annually".

And coming back to GDB, I've heard (a lot) that slowdown makes it quite unusable on a "real-life" application.

I'd personally love to hear back from more people using reverse debugging on applications others than "Hello world!"

2
  • 6
    I think it would be far better to link this study rather than 'Undo Software' spam pretending to be about study. Commented Mar 14, 2014 at 4:36
  • 1
    At my former job, I worked on building a reverse debugger (ghs.com/products/timemachine.html). We used the debugger internally heavily, and I can tell you, it was incredible. Of course it was great on the really hairy race conditions, but it was more than that. When reverse debugging is on all the time, your mentality about debugging changes. You iterate less, and you can be less careful with how you test your code. You can also save an execution run and send it to someone, so it's great for finding bugs in other people's code.
    – speedplane
    Commented Oct 24, 2016 at 15:55
2

I think it is important to expand a little further on this "reverse" or "historic" debugging. I think to understand complex systems and behavior in those, to replay "events" which make state explicit is absolutely crucial.

What I want to express is that you are not alone in wondering why this technique is not so much applied today or why the related problems are rarely discussed clearly.

So let’s emphasize two very important concepts here:

1.To understand a programming system it is helpful to make state explicit

2.To even further understand a programming system replaying sequences of state (events) can help a lot.

Here are some sources which tackled the problem and proposed or designed solutions for the problem (dealing with state in complex systems):

-Out of the tar bit, paper: http://shaffner.us/cs/papers/tarpit.pdf Main ideas: avoid, isolate or make state explicit

-CQRS http://www.cqrs.nu/ This is a combination of two concepts: Command Query Segregation and Event Sourcing. There exists different implementations ( Java,C# , Scala). The replaying of Tate sequences and the evolving of a domain model are the crucial parts here.

If you really zoom out and see the very broad picture you can already see that with the "rise" of functional programming people are already ((un)consciously ) attracted to fp because it makes state explicit! But that only deal with point one, to address the second one you need another concept which could be "loosely" described as functional reactive programming.

So you might say all well and good but who actually uses CQRS and FRP? I would say (IMO because I don’t have concrete numbers) actually a lot of companies its just that they don’t know the work they do has this terminology. Maybe you google a bit around and you hear from enterprises which use CQRS, there are some success stories already out there. FRP too is rising slowly as an example I could give Netflix: http://techblog.netflix.com/2013/02/rxjava-netflix-api.html Which just released an implementation of RX which is actually .NET based (but has a Javascript implementation too). So People are using these techniques today already, IN THE LARGE to understand complex systems and to make them even better. That is why they use reverse debugging techniques.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.