Skip to main content

IAR Embedded Workbench for Arm 10.10.x

Using C-SPY in batch mode

In this section:

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.

  1. 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.

  2. Use this file by specifying --launch_file launch.json as options to the cspybat command on the command line. If you have more than one build configuration, use --launch_config to 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.

EWICO.png
  1. 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.bat every time C-SPY is initialized. In addition, this file is generated:

    • launch.json, which contains options specific to cspybat and 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.

  2. Invoke the project.buildconfig.cspy_launch_json.bat file on the command line to start cspybat.

CLICO.png
  1. On the command line, you can create a batch file using iarbuild:

    iarbuild project.ewp -cspybat_cmds [buildconfig] -output_type filetype

    For example, this command:

    iarbuild project.ewp -cspybat_cmds Debug -output_type bat

    will create the batch file project.Debug.cspy.bat.

  2. Invoke the project.Debug.cspy.bat file on the command line to start cspybat.

    The file type can be another shell or batch type, for example sh if 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 run cspybat from the command line without any arguments, the cspybat version number and all available options including brief descriptions are directed to stdout and 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 ‑‑plugin option. See ‑‑plugin.

  • Error return codes

    cspybat returns status information to the host operating system that can be tested in a batch file. For successful, the value int 0 is returned, and for unsuccessful the value int 1 is returned.

Invocation syntax

The invocation syntax for cspybat is:

cspybat processor_DLL driver_DLL debug_file
        [cspybat_options] ‑‑backend driver_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

processor_DLL

The path to the processor-specific DLL file—available in arm\bin.

driver_DLL

The path to the C-SPY driver DLL file—available in arm\bin.

debug_file

The object file that you want to debug (filename extension out). See also ‑‑debug_file.

cspybat_options

The command line options that you want to pass to cspybat. Note that these options are optional. For information about each option, see Reference information on C-SPY command line options.

‑‑backend

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.

driver_options

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.

Table 63. cspybat parameters