| |||
| Home > Working with the CLI > Command scripts > Example command script | |||
Example 1.1 shows a command script that:
connects to a target
loads an image
defines a user-defined macro to display the value of a variable in the image
sets a breakpoint that runs the user-defined macro to display the value of a variable when the breakpoint is activated.
Example 1.1. Sample command script
ERROR=ABORT // Abort if error occurs when processing the script
WAIT=ON // Wait for each command to finish
// Log the output from the image
STDIOLOG ON='c:\myprojects\project1\stdoutput.txt'
/* Connect to the ARM_Cortex-A8 model with ISSM */
CONNECT @ARM_Cortex-A8@ISSM
/* Load the project1.axf image from myprojects directory */
LOAD/r 'c:\myprojects\project1\Debug\project1.axf'
/* Define macro to print a value (must be defined after image load) */
define /R int printval(thisVal)
int thisVal;
{
/* Print the value of the myvar variable when the
breakpoint is activated */
$PRINTVALUE thisVal$;
return 1; // continue execution after breakpoint is activated
}
.
// Scope to main() so that we can set a
// breakpoint using a line number
SCOPE main
/* Set a breakpoint at line 149 in project1.c */
BREAKINSTRUCTION \PROJECT1\#149:1 ; printval(myvar)
GO // Run the image
STDIOLOG OFF // Close the log file
UNLOAD 1 // Unload the image
DELFILE 1 // Remove the symbol definitions
DISCONNECT @ARM_Cortex-A8@ISSM // Disconnect from the target
WAIT=OFF