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
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:
>session.cmd
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
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.
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:
From the Tools menu, select Record... to open the Record dialog box. Click on the Suspend button.
In the Command Window, use the >f
command (for "false").
FUNCTION: Suspend recording.
COMMAND: >f
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.
From the Tools menu, select Record... to open 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
If at any point you do not remember whether recording is on or off, check by:
From the Tools menu, select Record... 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:
> Output logging is OFF Command recording is ON Target communication logging is OFF
The > command gives you the status for the different recording mechanisms. Output logging and target communication logging are described below.
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.)
From the Tools menu, select Record... to open the Record dialog box. Click on the Stop button to stop recording.
Enter the >c command
to close the file:
>c
FUNCTION: Close command recording file.
COMMAND: >c
For example, consider the following command sequence (from the Command Window):
>session.cmd ----- Start Recording to File initval p 12 ----- Carriage Return >f ----- Suspend Recording l b sum >t ----- Resume Recording /* This is a comment! */ >c
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:
initval p 12 /* This is a comment! */
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.
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. From the Tools menu, select Playback | CrossView... to open the CrossView Playback dialog box, or select Playback | Emulator... to open 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 enable 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.
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:
<session.cmd load and execute all the commands
The << command causes
CrossView Pro to playback commands one at a time, similar to single-stepping through code. For example:
<<session.cmd read a command from the file.
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
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.
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.
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/XP/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 and target settings 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 .elf file, downloads the code, runs the code and exits.
N hello.elf load the symbols dn download the program __exit bi set a breakpoint at the exit point R run the program $pc optional: show the program counter q y exit CrossView Pro
where hello.c contains
#include <stdio.h> void main() { printf("Hello World!\n"); }
4. Copy the .elf 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/XP/NT/2000:
start /wait c:\ctc\bin\xfwtc --timeout=120 -tcfg tsim.cfg -p session.cmd -R session.log
UNIX:
xfwtc --timeout=120 -tcfg tsim.cfg -p session.cmd -R session.log
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.
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:
From Tools menu, select Log
| Command Input/ Output..., Log | CrossView-Emulator I/O... or Log | CrossView-GDI Accesses...
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.
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:
>>screen.log
You can force flushing by using the >>! filename command as in:
>>!screen.log
You can open up a log file for Emulator
Output by using the >& filename command as in:
>&target.log
You can force flushing by using the >&! filename command as in:
>&!target.log
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
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.
For example, if you entered the following commands:
>>screen.log initval l a
The output file, screen.log, contains:
> initval initval = 0 > l a no assertions
You can resume and suspend the Logging process from the menu or from the Command Window:
From Tools menu, select Log
| Command Input/ Output..., Log | CrossView-Emulator I/O... or 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
To close the output file:
From Tools menu, select Log
| Command Input/ Output..., Log | CrossView-Emulator I/O... or 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
When starting up CrossView Pro you may immediately start recording or playing back files. For instance,
xfwtc fact -p session
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:
xfwtc fact -r session
This command records all your commands (just like the > command) to the file session, while:
xfwtc fact -R session
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.
From the Project menu, select Project Options...
Expand the CrossView Pro entry and select Logging. Enter your record and playback
filenames.
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.