15.5 Replaying a Debug Session

CodeView can automatically create a “tape” (a disk file) with the debugging instructions and input data you entered when testing a program. The tape can then be “replayed” to repeat the debugging process. You initiate recording by choosing the History On command from the Run menu. Choosing History On a second time terminates recording. The recording is saved in the .CVH file in the current directory.

Dynamic replay has several uses. The most obvious is repeating a debug session for the corrected version of a program. Dynamic replay usually works with slightly modified programs. However, the more you change the program, the less likely the new version will replay reliably.

You can also use the recording as a bookmark. You can quit after a long debugging session, then pick up the session later in the same place.

Summary: Dynamic replay makes it easy to correct a mistake.

Most importantly, dynamic replay allows you to back up when you make an error or overshoot the section of code with the bug. This feature is important because not all bugs appear on the first path of execution you try.

For example, you might have to manually execute a procedure many times before its bug appears. If you then enter a command that alters the machine's or program's status, thereby losing the information you need to find the cause of the bug, you would have to restart the program and manually repeat every debugging step to return to that point. Even worse, if you don't remember the exact sequence of events that exposed the bug, it could take hours to reproduce them.

Dynamic replay of a recorded tape eliminates this problem. Choose the Undo command from the Run menu to automatically restart the program and continuously execute every command up to (but not including) the last one you entered. You can repeat this process as many times as you like until you return to the desired point in execution.

You can add additional steps to an existing tape. Choose History On, then choose Replay. When replay has completed, perform whatever new debugging steps you want, then choose History On a second time to terminate recording. The new tape contains both the original and the added commands.

NOTE:

CodeView records only those mouse commands that apply to CodeView. Mouse commands recognized by the application being debugged are not recorded.

Replay Limitations under OS/2

There are some limitations to dynamic replay when debugging under OS/2:

The program must not respond to asynchronous events. Replay under Presentation Manager is not currently supported because of this restriction.

Breakpoints must be specified at specific source lines or for specific symbols (rather than by absolute addresses), or replay may fail.

Single-thread programs behave normally during replay. However, one of the threads in a multithread program may cause an asynchronous event, violating the first restriction in this list. Multithread programs are therefore more likely to fail during replay.

Multiprocess replay will fail. Each new process invokes a new CodeView session. The existence of multiple sessions makes it impractical to record the sequence of events if you execute commands in a session other than the original session.