dbx provides three commands or saving all or part of a debugging run and replaying it later:
The save command saves to a file all debugging commands issued from the last run command, rerun command, or debug command up to the save command. This segment of a debugging session is called a debugging run.
In addition to the list of debugging commands issued, the save command saves debugging information associated with the state of the program at the start of the run: breakpoints, display lists, and the like. When you restore a saved run, dbx uses the information in the save-file.
You can save part of a debugging run; that is, the whole run minus a specified number of commands from the last one entered.
If you are not sure where you want to end the run you are saving, use the history command to see a list of the debugging commands issued since the beginning of the session.
Issue the save command at the point at which you want to save an entire debugging.
(dbx) save
To save part of a debugging run, include the number option, where number is the number of commands back from the save command that you do not want saved.
(dbx) save -number
If you save a debugging run without specifying a file name, dbx writes the information to a special file. Each time you save, dbx overwrites this file. However, by giving the save command a filename argument, you can save a debugging run to a file that you can restore later, even if you have saved other debugging runs since the one saved to filename.
Saving a series of runs gives you a set of checkpoints, each one starting farther back in the session. You can restore any one of these saved runs, continue, then reset dbx to the program location and state saved in an earlier run.
To save a debugging run to a file other than the default, include the file name:
(dbx) save filename
After saving a run, you can restore the run using the restore command. dbx uses the information in its save file. When you restore a run, dbx first resets the internal state to what it was at the start of the run, then reissues each of the debugging commands in the saved run.
For exact restoration of a saved debugging run, all the inputs to the run must be exactly the same: arguments to a run-type command, manual inputs, and file inputs.
To restore a saved debugging run
(dbx) restore
To restore a debugging run saved to a file other than the default:
(dbx) restore filename
The replay command is a combination command, equivalent to issuing a save -1 followed immediately by a restore. The replay command takes a negative number argument, which it passes to the save portion of the command. By default, the value of -number is -1, so the replay command works as an undo command, restoring the last run until,but not including the last command issued.
To rep lay the current debugging run, minus the last debugging command issued, type:
(dbx) replay
To replay the current debugging run and stop the run before a specific command, use the –number option, where number is the number of commands back from the last debugging command.
(dbx) replay -number