(ddd.info)Undoing Program Execution
6.8 "Undoing" Program Execution
If you take a look at the `Edit => Undo' menu item after an execution
command, you'll find that DDD offers you to undo execution commands
just as other commands. Does this mean that DDD allows you to go
backwards in time, undoing program execution as well as undoing any
side-effects of your program?
Sorry--we must disappoint you. DDD cannot undo what your program
did. (After a little bit of thought, you'll find that this would be
impossible in general.) However, DDD can do something different: it
can show _previously recorded states_ of your program.
After "undoing" an execution command (via `Edit => Undo', or the
`Undo' button), the execution position moves back to the earlier
position and displayed variables take their earlier values. Your
program state is in fact unchanged, but DDD gives you a _view_ on the
earlier state as recorded by DDD.
In this so-called "historic mode", most normal DDD commands that
would query further information from the program are disabled, since
the debugger cannot be queried for the earlier state. However, you can
examine the current execution position, or the displayed variables.
Using `Undo' and `Redo', you can move back and forward in time to
examine how your program got into the present state.
To let you know that you are operating in historic mode, the
execution arrow gets a dashed-line appearance (indicating a past
position); variable displays also come with dashed lines. Furthermore,
the status line informs you that you are seeing an earlier program
Here's how historic mode works: each time your program stops, DDD
collects the current execution position and the values of displayed
variables. Backtrace, thread, and register information is also
collected if the corresponding dialogs are open. When "undoing" an
execution command, DDD updates its view from this collected state
instead of querying the program.
If you want to collect this information without interrupting your
program--within a loop, for instance--you can place a breakpoint with
an associated `cont' command (Note: Breakpoint Commands). When the
breakpoint is hit, DDD will stop, collect the data, and execute the
`cont' command, resuming execution. Using a later `Undo', you can step
back and look at every single loop iteration.
To leave historic mode, you can use `Redo' until you are back in the
current program state. However, any DDD command that refers to program
state will also leave historic mode immediately by applying to the
current program state instead. For instance, `Up' leaves historic mode
immediately and selects an alternate frame in the restored current
If you want to see the history of a specific variable, as recorded
during program stops, you can enter the DDD command
graph history NAME
This returns a list of all previously recorded values of the variable
NAME, using array syntax. Note that NAME must have been displayed at
earlier program stops in order to record values.
automatically generated by info2www version 188.8.131.52