8

Possible Duplicate:
Bidirectional (or reverse) debugging

I've looked up the Omniscient Debugger (http://www.lambdacs.com/debugger/ODBDescription.html), but it's specific to Java. Is there any debugger with this same functionality for native apps, i.e., C/C++?

I haven't made myself clear. I'd like to break on bogus data values/code paths, and then "rollback", debug backwards, until I find the error in the code/logic/design.

I know I can debug step-by-step "forwardly", I want to do the same backwards, so the debugger would need to save its context in each step.

Community
  • 1
  • 1
Spidey
  • 2,508
  • 2
  • 28
  • 38
  • 1
    I think gdb can do this. Just add -g to your compile flags – Wug Aug 27 '12 at 20:11
  • Many, (all?), IDE-based development environments have a built-in debugger that can show the stack frames, (locals, function returns), by source code line. Then there's gdb for command-line stuff.. – Martin James Aug 27 '12 at 20:14
  • That's one of the main functions of any debugger. Which debuggers have you looked at? There is a list on Wikipedia that you can consult. – Lubo Antonov Aug 27 '12 at 20:55
  • I know of no such program, and I _highly_ doubt there will be one in the next 20 years. The memory usage on such a thing would be _incredible_. – Mooing Duck Aug 27 '12 at 21:48
  • I don't need to track heap usage/changes, just the stack state. Take a look at ODB, it seems to do what I need, but only with Java code. – Spidey Aug 27 '12 at 22:08
  • I have used such a tool, it is not "20 years in the future" as suggested here, but I am not sure if it is publicly available. See: http://www.osronline.com/showthread.cfm?link=129469 – asveikau Aug 28 '12 at 00:08
  • @MooingDuck I'm pretty sure there is (http://research.cs.wisc.edu/areas/pl/seminar/fall05/Bhansali.ppt). Too bad I cannot share it.. – Todd Li Aug 28 '12 at 00:09
  • 3
    @MooingDuck, GDB has had it for three years http://sourceware.org/gdb/wiki/ReverseDebug and TotalView has similar functionality, http://www.roguewave.com/products/totalview/replayengine.aspx – Jonathan Wakely Aug 28 '12 at 00:13
  • Worth noting that you've completely changed the meaning of the question by specifying stepping backwards - which makes most of the comments and answers nonsense... – John Carter Aug 28 '12 at 00:15
  • Sorry for the badly written question, I didn't mean to confuse you. I had the problem for so long that the question was clear enough in my head. – Spidey Aug 28 '12 at 12:51
  • 1
    on windows the tool is time travel debugging https://learn.microsoft.com/en-us/windows-hardware/drivers/debugger/time-travel-debugging-overview – ColdCat Jun 18 '18 at 16:42

5 Answers5

8

In addition to the stack traces to examine past instructions already mentioned here on x86 targets newer gdb also supports recorded program execution and stepping backwards which should come pretty close to what you are looking for.

Benjamin Bannier
  • 55,163
  • 11
  • 60
  • 80
6

GDB version 7.0 (due September 2009) will be the first public release of gdb to support reverse debugging (the ability to make the program being debugged step and continue in reverse)

ADDENDUM:

Visual Studio 2010 and higher supports "Historical Debugging" ("IntelliTrace"):

paulsm4
  • 114,292
  • 17
  • 138
  • 190
  • Visual Studio can only do this for .NET applications written in C# or Visual Basic. As the article says, "IntelliTrace does not support debugging C++" – RyanCu Oct 19 '15 at 03:51
2

I think you should use GDB for C/C++. You have some stack trace options and you'll be able to set breakpoints in your program and run it step by step.

Check at http://www.cs.cmu.edu/~gilpin/tutorial/#3.5 or find other tutorials on the web.

Hope it helps.

Tim Tosi
  • 305
  • 2
  • 8
  • 2
    @templatetypedef this answer was given before stepping backwards was editted in as a requirement (sigh), though actually GDB *does* support this (requires GDB >=7): http://sourceware.org/gdb/wiki/ReverseDebug – John Carter Aug 28 '12 at 00:18
0

gdb has commands up n and down n to select (n)frames up or down.

Probably this can help.

Mihai Iorga
  • 39,330
  • 16
  • 106
  • 107
ankur
  • 74
  • 4
-2

For linux GDB is suggested while for Windows windbg is better.

perilbrain
  • 7,961
  • 2
  • 27
  • 35
  • 1
    I spent loads of time getting WinDbg to work with my current project, only to find out that it does not support reverse debugging. – David Mar 24 '13 at 00:00