Previous - Up - Next

4.4   Hindsight


Note: Hindsight requires a special license. This section can be skipped if Hindsight is not available.

Hindsight enables the simulation to run backwards in time. To enable Hindsight, we have to set an initial time bookmark. Time bookmarks are set with the set-bookmark command.

simics>  set-bookmark booted
simics>  c


Note: Typing c is a shorthand for continue.

To demonstrate the possibilities Hindsight gives, we will accidentally remove an important file on the simulated system. Enter the following commands in the simulated system's terminal:

root@firststeps: ~# rm /bin/ls
root@firststeps: ~# ls /
ls: No such file or directory

The program ls has been removed. You can no longer list the contents of a directory. Let us use Hindsight to recover ls.

ptime is a useful command that shows the number of executed instructions and the current simulated time. We will use it to show that the time have advanced backwards.

[press control-C]
simics>  ptime
processor                 steps             cycles    time [s]
cpu0                16667617210        16667617210     166.676
simics> 

The skip-to command can be used to quickly jump to a previous point in time. We will use the bookmark we created before as our time-travel destination. Note that it is not possible to reverse past the first bookmark.

simics>  skip-to bookmark = booted
simics>  ptime
processor                 steps             cycles    time [s]
cpu0                13586370338        13586370338     135.864
simics> 

The system is now in the state it was before the file was erased. Now, we run forward again.

simics>  c

When you type something in the terminal, you will notice that it does not respond any longer! Instead the same commands as before will be replayed.

This behavior is intentional, and keeps the deterministic property of the simulation, which is invaluable when debugging. Keystrokes, network traffic and any other input is replayed until the last known time is reached.

In our example, this is not what we want. To erase all knowledge about the future, run the clear-recorder command.

[press control-C]
simics>  skip-to bookmark = booted
simics>  clear-recorder
Replay of recorded input finished; Simics is now running normally
simics>  c

Resume the simulation and enter the following command:

root@firststeps: ~# ls /
LICENSE     dev         host        lost+found  proc        tmp
bin         etc         lib         mnt         root        usr
boot        home        linuxrc     opt         sbin        var
root@firststeps: ~#

ls works again!

You can read more about Hindsight in chapter 22.

Previous - Up - Next