9 COMMAND RECORDING & PLAYBACK

This chapter contains the following sections:

Recording Commands
Entering Comments
Suspend Recording
Resume Recording
Check Recording Status
Close File for Recording
Command Recording Example
Playing Back Command Files
Setting the Type of Playback
Calling Other Playback Files
Quitting Playback Mode
Command Line Batch Processing
Logging
Setting up Logging
Recording Commands and Logging Screen Output
Command Window Log File Example
Suspending and Resuming Output Log
Closing the Output Log File
Startup Options
CrossView Pro Command History Mechanism

9.1 Recording Commands

CrossView Pro lets you save a series of CrossView Pro commands to the file of your choice. This is record mode. You can re-load a saved file to repeat parts of debugging tasks or replay a debugging session (up to the point where you left the last time).

Record mode means that all CrossView Pro commands from the keyboard, mouse or menu are recorded to a disk file. The debugger can read this file and execute the commands as if they were entered into the Command Window. This is called playback mode, see more about playback mode later in this chapter.

Record and playback modes can never be active at the same time.

You can only record CrossView Pro commands. When recording on CrossView Pro command level, all commands that you type in the Command Window, as well as the CrossView Pro command language equivalents of dialog actions and menu selections are saved in a file. When you want to record commands entered in the Emulator Command Window, you have to turn on CrossView-Emulator I/O logging (see the section Logging in this chapter).

From the Command Window you control record mode using either the mouse or keyboard commands. To start or setup recording:

From the menu system:

Enter the > command with the name of the file to start recording. For example, enter:

After you invoke this command, CrossView Pro saves every executed command, whether using the mouse or manually typed into the Command Window, to the file session.cmd.

FUNCTION: Save CrossView Pro commands to a file.

COMMAND: > filename

FUNCTION: Save CrossView Pro commands to a file and force flushing.

COMMAND: >! filename

9.1.1 Entering Comments

Every command, whether typed into the Command Window or the result of a mouse or menu action goes into the recording file. To add comments to a file recording CrossView Pro commands, enclose text typed in the Command Window with C comments delimiters, "/*" and "*/". When logging emulator commands, refer to your emulator documentation for the appropriate comment characters.

9.1.2 Suspend Recording

This function acts like the pause button on a tape recorder: the recording mechanism stays in place, but suspends temporarily. CrossView Pro does not save to file any commands you enter while you suspend recording, but the file remains open and ready to accept input. To suspend recording:

Select the Tools | Record... menu item to view the Record dialog box. Click on the Suspend button.

In the Command Window, use the >f command (for "false").

FUNCTION: Suspend recording.

COMMAND: >f

9.1.3 Resume Recording

This function is the counterpart of the suspend recording function. CrossView Pro resumes adding commands to the current record file. Any new command you enter appears in the file; they do not affect the commands already saved.

Select the Tools | Record... menu item to view the Record dialog box. Click on the Resume button to resume recording.

In the Command Window, use the >t command (for "true").

FUNCTION: Resume command recording.

COMMAND: >t

9.1.4 Check Recording Status

If at any point you do not remember whether recording is on or off, check by:

Selecting the Tools | Record... menu item. If record mode is active, the Stop button is enabled. If the Start and OK buttons are enabled, record mode is off.

Enter the > command in the Command Window.

This command shows the status of the recording and logging mechanism. For example, if you enter > you might see:

The > command gives you the status for the different recording mechanisms. Output logging and target communication logging are described below.

9.1.5 Close File for Recording

Closing a file for recording differs from suspending recording in that when you close a file, you may not add any more commands to it. If you were to start recording again using the same filename, the old commands in the file would be deleted. (Note that this does not exclude editing the file manually by some other means, since the file is saved as ASCII text.)

Select the Tools | Record... menu item to view the Record dialog box. Click on the Stop button to stop recording.

Enter the >c command to close the file:

FUNCTION: Close command recording file.

COMMAND: >c

9.1.6 Command Recording Example

For example, consider the following command sequence (from the Command Window):

This series starts with a command to record to a file named session.cmd. The blank line above represents a carriage return. After the last command, c, if you were to view this file, it contains:

The saved command file contains simply the commands, without any output. Note that commands entered while recording was suspended (l b and sum) do not appear in the file. Carriage returns are not recognized as commands.

9.2 Playing Back Command Files

Once you have recorded a set of CrossView Pro commands, you can play them back to recreate a debugging session or repeat often-used sequences. Running the debugger while reading commands from a file is playback mode.

Remember that for a file to be played back, it can only contain CrossView Pro or emulator commands. For this reason, screen output files cannot be used in playback mode. Refer to the Recording Commands section earlier in this chapter for more information.

As with recording, the Command Window controls playback mode. To playback a command file:

Follow these steps:

1. Select the Tools | Playback | CrossView... menu item to view the CrossView Playback dialog box, or select the Tools | Playback | Emulator... menu item to view the Emulator Playback dialog box.

You can choose to playback either CrossView Pro commands or Emulator commands. Open the Emulator Command Window if the playback file contains commands sent directly to your emulator.

2. Type the playback filename or use the Browse... button to select the file. The default filename extension is .cmd.

In the Playback dialog box, you have two additional options: Playback at XVW startup and Continuous playback. CrossView Pro enters playback mode automatically when you start the debugger if you click on the Playback at XVW startup check box in the Playback dialog box. The entire playback file executes if you check the Continuous playback check box.

3. Click on the Execute button to start the playback.

In the Command Window, use the < or << filename command to playback CrossView Pro commands.

On the command line of CrossView Pro give the option -T filename to start CrossView Pro in transparency mode and playback emulator commands. Not available for all execution environments.

9.2.1 Setting the Type of Playback

Enable the Continuous playback check box in the CrossView Playback dialog box to turn on continuous play back of commands.

In the Command Window, there are two commands for the type of playback. The < filename command starts playback. Commands are read from a file and executed without any stop. For example:

The << command causes CrossView Pro to playback commands one at a time, similar to single-stepping through code. For example:

Clicking the Execute button or pressing the Enter key executes the next command.

FUNCTION: Play back a file of CrossView Pro commands.

COMMAND: < filename

FUNCTION: Play back a file of CrossView Pro commands, one command at a time.

COMMAND: << filename

9.2.2 Calling Other Playback Files

A playback file can call another playback file in the course of its execution.

When CrossView Pro creates a command file, it saves all commands in their textual form, whether entered by the mouse or as text. You must edit this file to use the < and << commands.

When the debugger reaches a < or << command in a playback file, playback execution switches to the new file, but does not return to the original file. In other words, you chain playback files but not nest them.

9.2.3 Quitting Playback Mode

Playback mode stops automatically when CrossView Pro reaches the end of the command file. If you want to end playback mode before this point, click the Halt button.

9.3 Command Line Batch Processing

CrossView Pro supports command line batch file processing, but CrossView Pro will halt if a modal dialog is encountered or if the target program contains an endless loop. The command line option --timeout=n_seconds switches CrossView Pro to a different mode of operation, without the two drawbacks mentioned above.

In order to process files in batch mode you have to do the following:

1. Create a temporary directory.

2. Start CrossView Pro from this temporary directory. For Windows 95/98/NT/2000 you can create a separate icon or shortcut to start CrossView Pro, which has the working directory (Start in:) set to the temporary directory.

3. Close all CrossView Pro windows except the Command Window.

4. Exit CrossView Pro (with Save Desktop enabled).

You now have generated an xvw.ini file with minimal GUI overhead.

5. Save the xvw.ini file and remove the temporary directory.

For each batch run of CrossView Pro you have to do the following:

1. Create a temporary directory.

2. Copy the saved xvw.ini file to the temporary directory.

3. Create a command file in the temporary directory.

The following command file session.cmd loads the .abs file, downloads the code, runs the code and exits.

where hello.c contains

4. Copy the .abs file to the temporary directory. This is needed because CrossView Pro changes its working directory when the N command is used.

5. The following line executes CrossView Pro in batch mode and waits for it to finish:

Windows 95/98/Me/NT/2000:

UNIX:

This command must be issued in the temporary directory! After the execution has ended, the file session.log contains a transcript of the commands.

6. Save the output files and clean up (or remove) the temporary directory. This must be done because the xvw.ini file has been modified now. If CrossView Pro would be started again in the temporary directory, the file session.cmd would be executed again.

The --timeout=n_seconds command activates the batch operation mode of CrossView Pro. It causes CrossView Pro to terminate when the specified amount of time has elapsed, which is crucial in batch processing: if a program does not terminate, the timeout will terminate CrossView Pro, so that the next program in the batch can be executed. CrossView Pro will also terminate in the batch mode if a modal dialog pops up, since this requires user interaction to continue. Before CrossView Pro exits, the text in the dialog will be written to the log file. A special case of this dialog is the 'End of program reached' dialog. For this reason, the line __EXIT bi has to be added to the .cmd file, so it is possible to do some things (for example, read registers modified by a machine code program) after the program is finished. If the breakpoint at __EXIT is absent, CrossView Pro immediately exits after having executed the R command, so any consecutive commands will be ignored.

9.4 Logging

Logging means that all output text to a particular window is saved in a file for later use. Two windows allow logging:

"GDI Accesses" can also be logged. This is the information transferred between CrossView Pro and the Debug Instrument (DI).

You can control logging from the Tools menu or from the Command Window.

You can also determine the status of each logging function:

Select the Tools | Log | Command Input/ Output... menu item, the Tools | Log | CrossView-Emulator I/O... menu item or the Tools | Log | CrossView-GDI Accesses... menu item.

If a logging function is is active, the Stop button is enabled. If the Start and OK buttons are enabled, logging is off.

Enter the >> or >& command in the Command Window.

Each type of logging is described in the following section.

The Emulator Output Window is primarily a diagnostic tool. It should be used wisely, since it generates substantial amounts of output, the format of which is emulator dependent. For emulators that have an ASCII interface, the actual command/response dialogue will be displayed. For emulators with a binary interface, CrossView Pro will generate a record of function calls with their associated input and output parameters. This also applies to the GDI Accesses output logging.

9.4.1 Setting up Logging

To setup logging:

From the menu system:

You can open up a log file for CrossView Command Output by using the >> filename command as in:

You can force flushing by using the >>! filename command as in:

You can open up a log file for Emulator Output by using the >& filename command as in:

You can force flushing by using the >&! filename command as in:

FUNCTION: Save CrossView Pro commands and command window output to a file.

COMMAND: >> filename

FUNCTION: Force flushing of CrossView Pro commands and command window output to a file.

COMMAND: >>!filename

FUNCTION: Log target communications.

COMMAND: >& filename

FUNCTION: Force flushing of target communication logging.

COMMAND: >&!filename

9.4.2 Recording Commands and Logging Screen Output

It is possible to have command recording, command output logging and target communication logging on at the same time. That is, you can have one file recording just the CrossView Pro commands, and another file concurrently recording both the commands and the computer responses. Refer to the previous section for information on command record files.

Since the Command Window log file contains both your commands and the computer responses, you cannot use it in playback mode.

9.4.3 Command Window Log File Example

For example, if you entered the following commands:

The output file, screen.log, contains:

9.4.4 Suspending and Resuming Output Log

You can resume and suspend the Logging process from the menu or from the Command Window:

Select Tools | Log | Command Input/Output..., Tools | Log | CrossView - Emulator I/O... or Tools | Log | CrossView - GDI Accesses... to select the appropriate dialog box.

To suspend logging:

Click on the Suspend button.

In the Command Window, use the >>f command for suspending the logging of the Command Output Window. Type >&f to suspend the Emulator Output Window. After you issue this command, CrossView Pro does not save all subsequent commands and their computer responses.

To resume logging:

Click on the Resume button.

In the Command Window, use the >>t command to resume logging the Command Output Window. Type >&t to resume the Emulator Output Window. After you issue this command, CrossView Pro saves all subsequent commands and their computer responses.

FUNCTION: Suspend output logging (logging is false).

COMMAND: >>f

FUNCTION: Resume output logging (logging is true).

COMMAND: >>t

FUNCTION: Suspend target logging (logging is false).

COMMAND: >&f

FUNCTION: Resume target logging (logging is true).

COMMAND: >&t

9.4.5 Closing the Output Log File

To close the output file:

Select Tools | Log | Command Input/Output..., Tools | Log | CrossView - Emulator I/O... or Tools | Log | CrossView - GDI Accesses... to select the appropriate dialog box. Click on the Stop button to stop logging.

Enter the >>c or >&c command in the Command Window to close the Command Output and Emulator Output log files. These commands end the recording for the currently specified output log file.

FUNCTION: Close output log file.

COMMAND: >>c

FUNCTION: Close target log file.

COMMAND: >&c

9.5 Startup Options

When starting up CrossView Pro you may immediately start recording or playing back files. For instance,

plays back the commands in the file session. A -P switch single-steps through each command, prompting you for a return after each. You can also start recording:

This command records all your commands (just like the > command) to the file session, while:

logs your commands and screen output to the file session (just like the >> command).

You can also use the Automatically at CrossView startup option in the Record, Playback, and Log dialogs to immediately start recording, playback or logging at CrossView Pro startup.

You can also enter record and playback files via EDE. Select the Project | Project Options... menu item. Expand the CrossView Pro entry and select Logging. Enter your record and playback filenames.

9.6 CrossView Pro Command History Mechanism

CrossView Pro stores the command history in the list box of the Command Window.

You can select a command from the history list by clicking on it or jumping with the <Tab> key to the history listing and using the arrow keys.. The command appears in the edit field of the Command Window. You may edit the command if you want.

To execute the command, click on the Execute button.

If you do not want to edit the command, double-click on the selected command in the list box to execute the command, or hit the <Return> key.


Copyright © 2002 Altium BV