- IAR Embedded Workbench for Arm 10.10.x
- C-SPY Debugging
- The C-SPY command line utility—cspybat
- Using C-SPY in batch mode
Using C-SPY in batch mode
You can execute C-SPY in batch mode if you use the command line utility cspybat, installed in the directory common\bin.
Starting cspybat
Using a JSON launch file
The most convenient way to start cspybat is to generate and use a launch.json file. This file can also be used with Visual Studio Code.
The command syntax is:
iarbuild
project.ewp -launch_json [buildconfig]For example, this command:
iarbuild project.ewp -launch_json Debug
adds the Debug configuration to the file
launch.json.You can also create this file in the IDE by choosing Debug>Launch Configuration>Export as JSON.
Use this file by specifying
--launch_file launch.jsonas options to the cspybat command on the command line. If you have more than one build configuration, use--launch_configto specify which one, for example:cspybat --launch_file launch.json --launch_config Debug
For more information, see Saving and loading debugger launch settings.
Using an auto-generated batch file
You can also start cspybat using a batch file.

An easy way to create a batch file in the IDE is to use one of the batch files that C-SPY automatically generates when you start C-SPY in the IDE.
C-SPY generates a batch file
project.buildconfig.cspy_launch_json.batevery time C-SPY is initialized. In addition, this file is generated:launch.json, which contains options specific tocspybatand the C-SPY driver you are using
You can find the files in the directory
$PROJ_DIR$\settings. The files contain the same settings as the IDE uses, and provide hints about additional options that you can use.Invoke the
project.buildconfig.cspy_launch_json.batfile on the command line to startcspybat.

On the command line, you can create a batch file using
iarbuild:iarbuild
project.ewp -cspybat_cmds [buildconfig] -output_typefiletypeFor example, this command:
iarbuild project.ewp -cspybat_cmds Debug -output_type bat
will create the batch file
project.Debug.cspy.bat.Invoke the
project.Debug.cspy.batfile on the command line to startcspybat.The file type can be another shell or batch type, for example
shif you work in a Linux environment.
Note
It is also possible to start an interactive debug session in the Embedded Workbench GUI. For more information, see Starting a debug session from the command line.
Output
When you run cspybat, these types of output can be produced:
Terminal output from cspybat itself
All such terminal output is directed to
stderr. Note that if you runcspybatfrom the command line without any arguments, thecspybatversion number and all available options including brief descriptions are directed tostdoutand displayed on your screen.Terminal output from the application you are debugging
All such terminal output is directed to
stdout, provided that you have used the‑‑pluginoption. See ‑‑plugin.Error return codes
cspybatreturns status information to the host operating system that can be tested in a batch file. For successful, the valueint0is returned, and for unsuccessful the valueint1is returned.
Invocation syntax
The invocation syntax for cspybat is:
cspybatprocessor_DLLdriver_DLLdebug_file[cspybat_options]‑‑backenddriver_options
Note
In those cases where a filename is required you are recommended to give a full path to the filename. For the DLL files it is mandatory.
Parameters
The parameters are:
Parameter | Description |
|---|---|
| The path to the processor-specific DLL file—available in |
| The path to the C-SPY driver DLL file—available in |
| The object file that you want to debug (filename extension |
| The command line options that you want to pass to |
| Marks the beginning of the parameters to the C-SPY driver; all options that follow will be sent to the driver. Note that this option is mandatory. |
| The command line options that you want to pass to the C-SPY driver. Note that some of these options are mandatory and some are optional. For information about each option, see Reference information on C-SPY command line options. |