Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does a historical debugger work?

Tags:

debugging

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 state shot of the whole system on every instruction.

like image 572
mafu Avatar asked May 18 '10 23:05

mafu


People also ask

What is debugger and how it works?

A debugger is a software tool that can help the software development process by identifying coding errors at various stages of the operating system or application development. Some debuggers will analyze a test run to see what lines of code were not executed.

What is the process of debugging?

Definition: Debugging is the process of detecting and removing of existing and potential errors (also called as 'bugs') in a software code that can cause it to behave unexpectedly or crash. To prevent incorrect operation of a software or system, debugging is used to find and resolve bugs or defects.

How does a debugger help your coding?

Debugging means to run your code step by step in a debugging tool like Visual Studio, to find the exact point where you made a programming mistake. You then understand what corrections you need to make in your code and debugging tools often allow you to make temporary changes so you can continue running the program.

Who was the first debugger?

The terms "bug" and "debugging" are popularly attributed to Admiral Grace Hopper in the 1940s. While she was working on a Mark II computer at Harvard University, her associates discovered a moth stuck in a relay and thereby impeding operation, whereupon she remarked that they were "debugging" the system.


1 Answers

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).

like image 131
Chris Schmich Avatar answered Sep 21 '22 18:09

Chris Schmich