开发者

How does a historical debugger work?

A historical debugger is able to revert program state (including current instruction) to a former state. How is this possible in managed or unmanaged environments? I can't imagine that the debugger takes a st开发者_如何学Goate shot of the whole system on every instruction.


One way to do this is to record the sources of non-determinism in the system (I/O, interrupts) and take state snapshots at various intervals. This way, you can "rewind" by restoring to a previous snapshot and playing forward using the recorded non-determinism until you hit your desired point in the past.

For example, imagine this timeline:

1    2           3     4
|    |           |     |
  1. Program start
  2. State snapshot taken by historical debugger
  3. The point in time to which the user wants to rewind
  4. Now

Suppose the user wants to rewind to point 3. You can do that by restoring the system state (e.g. memory, registers) to point 2 and letting the system execute as usual until it hits point 3. When data is needed from disk, the network, or some other non-deterministic source, the historical debugger can use its recorded information to provide the data. To the user, it appears that the state of the program was simply restored to point 3.

I believe this is a simplified view of how VMWare's Replay Debugger works (see also the tech talk).


Well, most importantly, they don't snapshot at every instruction just at various "points of interest" (for example, when an exception is thrown, when certain methods are called, etc). For example, Microsoft's IntelliTrace (in VS2010) snapshots on access to the file system and registry, interactions with WinForms UI and so on.

Secondly, it doesn't snapshot the entire program state. For example, when you access a file, IntelliTrace records the name of the file, the access permissions you asked for and so on - but you can't just go back to that point and look at the state of every single global variable.

I don't know about other historical debuggers, but that's how IntelliTrace works in VS2010, anyway.


It probably takes a snapshot of the state every time, but only retains the deltas between the states (of course, it's impossible to say exactly how any given one really works without looking at its code).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜