On this page

Support for Other IDEs and Toolchains

This chapter is about specialized IDEs and build systems, most of them for embedded systems.

IAR Embedded Workbench

The following recipe requires

  • Coco 7.5.3 or later
  • IAR Embedded Workbench, version 9.x or later

Both packages must already be installed.

In the current version of Coco, only the ARM toolchain of IAR Embedded Workbench is supported.

Configuring with CocoSetup

Before IAR Embedded Workbench can be used for code coverage, the IAR toolchain must be configured with the CocoSetup program.

What we need to do is a so-called "in place" configuration: The directory with the build tools (compiler, linker, archiver, and supporting programs) is copied to a backup directory, while the build tools are each replaced with wrappers, each of which is a copy of the CoverageScanner compiler wrapper. In a compilation, the wrappers can then instrument the code and then run the tools in the backup directory that they replace.

  • Windows.

    On Windows, IAR is typically installed in C:\iar, therefore the command line for CocoSetup will be

    C:\mydir>cocosetup C:\iar --in-place
  • Linux.

    On Linux, IAR is installed in a system directory for which a normal user has no write access. CocoSetup must therefore run with su or sudo in order to do the required changes.

    On the other hand, it must also do some trial compilations and instrumentations for feature tests. These must run from the account that has the licenses for the toolchain and for Coco. This account can be given to CocoSetup with the command line option --as-user (short form -u).

    Since the typical installation location of IAR under Linux is in the directory /opt/iar, the command line for CocoSetup could be:

    $ sudo cocosetup /opt/iar --in-place --as-user $USER

    The parameter $USER is an environment variable and will be replaced with the name of the account who runs sudo. You can also replace it with an actual user name.

Finding the toolchain directory

(In this subsection, we describe the situation for Linux since the Windows steps are essentially the same.)

With the command line as given above, CocoSetup runs in an interactive mode.

As a first step, it determines the actual location of the compiler toolchain, which is not in /opt/iar but in one of its subdirectories. (We could have given the actual directory as parameter to CocoSetup, but it is more convenient if the program searches for the right directory.)


Choose a toolchain directory:

    /usr/bin
--> /opt/iar
    Another directory

Use the <Up> and <Down> arrows to move and <Enter> to select the answer.

The directory /opt/iar is already selected, so pressing Enter is enough.

Directory /opt/iar contains no toolchain
Do you want to search recursively in its subdirectories? [Yn]

We are asked whether we should start a recursive search in the subdirectories. The default answer is "Yes", so pressing Enter is enough to continue.


Choose one of these subdirectories:

--> /opt/iar/ewarmc-10.10.1.24733/arm/bin
    None of these

Use the <Up> and <Down> arrows to move and <Enter> to select the answer.

CocoSetup now lists the subdirectories of /opt/iar that contain a toolchain. There is only one toolchain, and we can see from its path that it is probably an ARM toolchain.

Pressing Enter lets us go to the next step.

Choosing the toolchain


Directory /opt/iar/ewarmc-10.10.1.24733/arm/bin contains the following toolchains:

    Toolchain  C, C++, Linker, Archiver
    ---------  ------------------------
[ ] iar-arm    iccarm, iccarm, ilinkarm, iarchive

Use the <Up> and <Down> arrows to move, <Space> to select an entry and <Enter> to finish.

Now we see that the directory contains one toolchain, iar-arm, and which tools it consists of. To use the toolchain, press Space and then Enter.

Confirming the choices

Configuring the toolchain(s) iar-arm of directory /opt/iar/ewarmc-10.10.1.24733/arm/bin.

Do you want to configure the directory in-place? [Yn]

At the end, CocoSetup asks for a confirmation of our decision to set the --in-place parameter. Since in-place configuration is necessary for IAR, we press Enter again.

Summary
-------

Configure the toolchain in place
Toolchains to configure: iar-arm
Toolchain directory: /opt/iar/ewarmc-10.10.1.24733/arm/bin
Backup for the original toolchain: /opt/iar/ewarmc-10.10.1.24733/arm/bin.cocosetup

Command line: cocosetup /opt/iar/ewarmc-10.10.1.24733/arm/bin -c iar-arm --in-place -u someone

Do you want to do this? [Yn]

At the end of the interactive phase of this CocoSetup call, we see a summary of the actions that Coco will do next. There is also a command line with which one can create the same configuration without going into interactive mode.

Press Enter to confirm the actions, and CocoSetup does all the configuration work.

This then replaces the tools in /opt/iar/ewarmc-10.10.1.24733/arm/bin with Coco wrappers, but they are not yet activated: So far, compilation works the same as before. The way in which Coco is activated is described below in a later section.

Configuring with the Build Environment Selector

Note: Skip this section if CocoSetup was already used.

On Windows, there is also another, older way to configure IAR coverage, namely with the Build Environment Selection program.

You can find it in the Coco install folder under the name BuildEnvironmentSelection.exe.

In the main window, select the correct installation folder for your IAR binary folder and click Install IAR Support:

Build Environment Selection

Activating code coverage

The next step is to activate code coverage in IAR. Open Project > Options > C/C++ Compiler > Extra Options:

Compiler Extra Options

Enable the checkbox and type --cs-on (and other options, if necessary) into the field. Also add this to the linker settings by selecting Project > Options > Linker > Extra Options:

Linker Extra Options

Enable the checkbox and type the same options as before into the field. To deactivate Coco, uncheck the two checkboxes or remove the extra options.

CygWin

To install the CoverageScanner compiler wrapper for GCC and G++ on CygWin:

  1. Open the Build Environment Selection application (<Windows Coco>\toolselector.exe).
  2. Select the item CygWin - www.cygwin.com.
  3. Click Install CygWin Support. The build environment selection dialog then displays the list of generated compiler wrappers.

Open then the CygWin console and compile your application with csgcc instead of gcc (or csg++ instead of g++).

Scratchbox

If Coco is installed on the root file system, a compiler wrapper is created for each compiler supported by Scratchbox. To invoke CoverageScanner, prepend cs to the name of the cross-compiler.

Note: Installation option: 1) Installation on the local machine (need to be root).

TI C6000 CGT6

There is no standard location to install this compiler. However, TI compiler Coco wrappers are installed in %squishcoco%\TI.

To instrument programs that are built with the TI cl6x compiler, you must either

  • Add the Coco compiler wrappers to your PATH (before the actual compiler), or
  • run the Build Environment Selection, which, when given an install location of the TI compiler, will move the original executables to a different directory and place wrappers in the original location.

With the second approach, the wrappers will simply pass on the command line arguments to the underlying compilers unless --cs-on is passed as a command line argument or found in the COVERAGESCANNER_ARGS environment variable, in which case, Coco instrumentation happens.

To install CoverageScanner compiler wrapper for the TI C6000 cl6x toolchain:

  1. Open the Build Environment Selection application (%squishcoco%\toolselector.exe).
  2. Select the item TI CGT 6.
  3. Select the directory to which the TI CGT 6 compiler is installed installed (for example, C:\Desktop\TI).
  4. Click Install TI Support and wait for the confirmation that the tools are generated.

Synopsys Metaware Designware ARC

There is no support for Metaware compilers yet in the Build Environment Selection, so don't bother looking for Metaware there. However, Squish Coco provides wrappers for 2 Metaware compilers: ccac and arac.

After the Metaware compiler is installed on Windows, an environment variable, METAWARE_ROOT is defined, and the compiler is installed below that directory. The installer adds these directories to your PATH: %METAWARE_ROOT%\arc\bin;%METAWARE_ROOT%\ide.

For it to be possible to instrument your builds, add the directory of the Coco Metaware wrappers to the start of your PATH. If you are using the command shell, it looks like this:

set PATH=%squishcoco%\Metaware;%PATH%

To instrument programs with one of our compiler wrappers, add --cs-on and whatever other coveragescanner arguments you like to the COVERAGESCANNER_ARGS environment variable.

set COVERAGESCANNER_ARGS=--cs-on --cs-mcdc

After that, you can run gmake from the command line to build your application, and you should get an instrumented build.

Alternately, from the Metaware IDE, you can set these environment variables from Project - Properties - C/C++ Build - Environment.

To setup code coverage for a project, go to Manage Configurations - New and create a new configuration called CodeCoverage. Select it, and set it to Active.

Next, set the PATH and the COVERAGESCANNER_ARGS in the Environment section.

After this, the IDE should be able to build instrumented executables of your project.

If you no longer want code coverage, switch back to one of the previous build configurations.

ARM Keil μVision

To enable the code coverage analysis, compile the project with Coco compiler wrapper for ARM and enable the code coverage analysis during the compilation:

  1. To install CoverageScanner compiler wrapper for the ARM® Keil® μVision toolchain:
    1. Open the Build Environment Selection application (<Windows Coco>\toolselector.exe).
    2. Select the item ARM-Keil.
    3. Select the directory to which the ARM Keil μVision compilers are installed (for example, C:\Keil_v5\ARM).
    4. Click Install ARM-Keil Support and wait for the confirmation that the tools are generated.
  2. Activate the code coverage analysis during the compilation:
    1. Click Project > Option for Target.
    2. On the C/C++ tab, add --cs-on into the Misc Controls field.

    3. On the Linker tab, add --cs-on into the Misc Controls field.

Arm DS

To enable the code coverage analysis for an Arm DS project, compile it with Coco compiler wrapper for ARM and enable the code coverage analysis during the compilation:

  1. To install CoverageScanner compiler wrapper for the Arm DS toolchain:
    1. Open the Build Environment Selection application (<Windows Coco>\toolselector.exe).
    2. Select the item ARM-DS.

      Installation of Arm DS support in Build Environment Selection

    3. Select the directory o which the Arm DS compilers are installed (for example, C:\Program Files\DS-5 v5.29.3)
    4. Click Install ARM-DS Support and wait for the confirmation that the tools are generated.

      Confirmation of the installation of Arm DS support

  2. Activate the code coverage analysis during the compilation:
    1. Click Project > Properties.
    2. On the Arm C/C++ Compiler 5 tab, add --cs-on into the Miscellaneous field.

      Activating the code coverage analysis for an Arm compiler

    3. On the Arm Linker 5 tab, add --cs-on into the Misc Controls field.

      Activating the code coverage analysis for an Arm linker

To upload the coverage data from the target to the host, define some custom I/O functions and trigger the coverage generation by calling __coveragescanner_save(). Due to the fact that Arm DS supports semi-hostings extensions, the simplest way is to use it to generate the execution report directly on the host file system.

For that modify the main() function to add a call to __coveragescanner_set_custom_io(), __coveragescanner_filename() and __coveragescanner_save() as in the following sample:

#include <stdio.h>

#ifdef __COVERAGESCANNER__
static int csfputs(const char *s, void *stream)
{
  return fputs(s, (FILE *)stream);
}

static void *csfopenappend(const char *path)
{
  return (void*)fopen(path,"a+");
}

static int csfclose(void *fp)
{
  return fclose((FILE*)fp);
}
#endif

int main() {
#ifdef __COVERAGESCANNER__
  __coveragescanner_set_custom_io( NULL,
      csfputs,
      csfopenappend,
      NULL,
      NULL,
      csfclose,
      NULL);
  __coveragescanner_filename( "c:\\tmp\\test_arm5_csexe" ); /* destination file on the host file system */
#endif
  .......
#ifdef __COVERAGESCANNER__
    __coveragescanner_save(); /* saves the execution report */
#endif
        return 0;
}

The project can now be rebuilt and a project file with the extension .afx.csmes will be generated. This file can be opened in CoverageBrowser. Execute then the target application and wait until __coveragescanner_save() is called. A file c:\tmp\test_arm5_csexe will be generated (hard coded in our sample). Import and analyze it using CoverageBrowser as in the following screenshot:

Code coverage of an Arm DS project

Note: The extension of an execution report is usually .csexe but the semi-hosting implementation provided by ARM removes the file extensions. It is necessary to remove the default file filter in the import dialog of CoverageBrowser to be able to import it.

Green Hills Software MULTI Launcher

Installation

To install CoverageScanner compiler wrapper for the Green Hills® Software toolchain:

  1. Open the Build Environment Selection application (<Windows Coco>\toolselector.exe).
  2. Select the item Green Hills.
  3. Select the directory to which the Green Hills Software compilers are installed.
  4. Click Install Green Hills Support and wait for the confirmation dialog the tools are generated.

Command line tools

The command line tools for the Green Hills Software compiler are installed in the folder squishcoco of the installed native toolchain. For example, if the native toolchain is installed under c:\ghs\comp_201426, the Coco compiler wrappers are installed under c:\ghs\comp_201426\squishcoco.

The compiler wrappers completely replace the Green Hills Software toolchain. To activate the code coverage analysis, add the parameter --cs-on to the compiler arguments.

CoverageScanner library

To save an execution report:

  1. Provide to the CoverageScanner library a list of I/O functions which let you upload the coverage information to the host.
  2. Save manually the coverage report on a specific trigger.

To save a coverage report, use the following code snippet (add this code in an event handler which should trigger the report generation):

#ifdef __COVERAGESCANNER__
    __coveragescanner_save();
    __coveragescanner_clear();
#endif

To provide the I/O functions, call __coveragescanner_set_custom_io() in the main() function of the application. At least three functions need to be provided by __coveragescanner_set_custom_io():

  1. An equivalent function of fopen() which opens the execution report file (with the extension .csexe) in append mode.
  2. An equivalent function of fclose().
  3. An equivalent function of fputs() to transfer the contents.

For example, the following code writes an execution report to the local file system using the C file API.

#ifdef __COVERAGESCANNER__
static int csfputs(const char *s, void *stream) { return fputs(s, (FILE *)stream); }
static void *csfopenappend(const char *path)    { return (void*)fopen(path,"a+");  }
static int csfclose(void *fp)                   { return fclose((FILE*)fp);        }
#endif

int main()
{
#ifdef __COVERAGESCANNER__
    __coveragescanner_set_custom_io( NULL,
            csfputs,
            csfopenappend,
            NULL,
            NULL,
            csfclose,
            NULL);
#endif
....
}

QNX Software Momentics IDE

Installation

To install CoverageScanner compiler wrapper for the QNX® Software toolchain:

  1. Open the Build Environment Selection application (<Windows Coco>\toolselector.exe).
  2. Select the item QNX.
  3. Select the directory on which the QNX Software toolchain is installed. By default, it is c:\Users\<account>\qnx700.
  4. Click Install QNX Support and wait for the confirmation that the tools are generated.

Configuration

Once the installation process is done, activate and configure the Coco parameters for a selected build mode. Or create a dedicated mode just for the code coverage, which is a better practice.

QNX Software 7.0

Proceed as follows:

  1. Open QNX Momentics IDE.
  2. Load the project to instrument.
  3. Open the project's preferences with the menu Project > Properties.

    Project settings on Momentics IDE 7.0

  4. Select C++ Build > Environment and add the variable COVERAGESCANNER_ARGS with the value --cs-on. You can specify additional settings. For example, to enable the MC/DC instrumentation, add --cs-mcdc.
  5. Rebuild your project to find in your build folder the instrumentation database <project_name>.csmes. You can then execute your application and import the generated .csexe file into it.

QNX Software 7.1

Proceed as follows:

  1. Open QNX Momentics IDE.
  2. Load the project to instrument.
  3. Open the project's preferences with the menu Project > Properties.

    Project settings on Momentics IDE 7.1

  4. Select QNX C/C++ Project > Compiler, and in Other Options enter --cs-on. To enable the MC/DC instrumentation add also --cs-mcdc.
  5. Select QNX C/C++ Project > Linker, and in Other Options enter --cs-on.
  6. Rebuild your project to find in your build folder the instrumentation database <project_name>.csmes. You can then execute your application and import the generated .csexe file into it.

Instrumenting without modifying the project

To instrument a QNX Software Momentics project without modifying it, create a small batch file which sets the variable COVERAGESCANNER_ARGS and start the IDE.

For example:

set COVERAGESCANNER_ARGS=--cs-on
C:\QNX\QNX_Momentics_IDE\qde.exe

Then rebuild the project to instrument it.

VxWorks support on Linux

To activate Coco on Wind River's Workstation:

  1. Start Wind River's Workbench
  2. Select your project in the Project Explorer window and click on the entry Properties in the context menu.
  3. Select the build properties, the compiler toolchain, and click on the Variables tab.
  4. Search for the TOOL_PATH variable and replace the /bin string at the end with /squishcoco:

    Setting the TOOL_PATH variable

After this change, the project can be compiled with CoverageScanner or the native toolchain. To use CoverageScanner, add the option --cs-on to the command line arguments of the compiler and the linker:

  1. Start the Wind River Workbench
  2. Select your project in the Project Explorer window and click Properties of the context menu.
  3. Select the build properties, the compiler toolchain, and click on the Tools tab.
  4. Select the entry C-Compiler in the Build Tool combo box and add to the content of the Tool Flags field the argument --cs-on:

    Tool flags

  5. Do the same for the C++-Compiler and the Linker tool.

With these settings, a file with the extension .vxe.csmes is generated when the code is compiled. It contains the complete instrumented code and can be inspected with CoverageBrowser. The resulting target application will then create a file with the suffix .csexe after it has run.

This file is created on the target file system. It can then be transferred to the host and imported into the .vxe.csmes file to create a report.

A video that illustrates the content of this chapter is available on https://youtube.com/watch?v=bMxMV6qHsYU.

LLVM Clang

The LLVM toolchain should already be installed. Execute the Build Environment Selection program after the installation of Coco. You can find it in the Coco installation folder with the name toolselector.exe.

In the main window, select the correct installation folder for your LLVM binary folder and click Install LLVM Support:

Build Environment Selection

After the installation, the Clang compiler supports CoverageScanner's command line arguments (--cs-on, --cs-hit, --cs-mcdc, and so on) and can be used to instrument C/C++ code.

TASKING support

The TriCore Eclipse IDE from TASKING should already be installed. Execute the Build Environment Selection program after the installation of Coco. You can find it in the Coco install folder with the name toolselector.exe. In the main window, select TASKING VX-Toolset for TriCore, and click Install TASKING Support:

Build Environment Selection

The next step is to activate the code coverage support in the Eclipse IDE. Open TriCore Eclipse IDE, click the top of your project and in the context menu, select Properties.

In the project's configuration dialog, select C/C++ Build > Settings. The complete compiler and linker settings will be displayed. Select C/C++ Compiler > Miscellaneous. You should see then an additional argument as in the following screenshot:

Compiler Extra Options

Add --cs-on to enable the code coverage analysis for the compiler.

Then do the same for the linker, select Linker > Miscellaneous, and add --cs-on to the additional arguments:

Linker Extra Options

To instrument the embedded application, rebuild it. A .csmes file is generated upon the compilation.

But to see the coverage, it is necessary to provide a set of functions that permit uploading it to the host. The TASKING simulator supports ARM's semi-hosting function which permits writing to files directly from the target to the host's file system. You can use this to generate the execution report (.csexe file) but on real hardware, it may be necessary to use other implementations.

For the setup, add the following lines to the source containing the main function:

#include <stdio.h>

#ifdef __COVERAGESCANNER__
static int csfputs(const char *s, void *stream)
{
  return fputs(s, (FILE *)stream);
}

static void *csfopenappend(const char *path)
{
  return (void*)fopen(path,"a+");
}

static int csfclose(void *fp)
{
  return fclose((FILE*)fp);
}
#endif

Then in the first lines of the main() function, configure these functions as handlers:

int main( int argc, char *argv[] )
{
#ifdef __COVERAGESCANNER__
    __coveragescanner_set_custom_io(
        NULL,
        csfputs,
        csfopenappend,
        NULL,
        NULL,
        csfclose,
        NULL
        );
#endif

    ......
}

Then, at the location where the execution report should be saved, add the following lines:

#ifdef __COVERAGESCANNER__
    __coveragescanner_save();
#endif

VisualDSP

To enable the code coverage analysis, compile the project with a Coco compiler wrapper and enable the code coverage analysis during the compilation in the VisualDSP® configuration:

  1. Click Project > Project Options.
  2. In Compile > General, add --cs-on into the Additional options field.

    Activating the code coverage analysis for the compiler

  3. In Link > General, add --cs-on into the Additional options field.

    Activating the code coverage analysis for the linker

  4. Rebuild your project.

On most embedded targets, it is necessary to provide a dedicated I/O since no file systems are available for storing the code coverage information. Also, since embedded applications generally never exit, it is often necessary to implement an event handler which saves the execution report upon the reception of a specific trigger.

The simulator emulates the support of a file system. To save the coverage report on the current build directory, it is only necessary to register in the first lines of the main() a custom file I/O which uses the standard C file API.

For example:

#ifdef __COVERAGESCANNER__
static int csfputs(const char *s, void *stream) { return fputs(s, (FILE *)stream); }
static void *csfopenappend(const char *path)    { return (void*)fopen(path,"a+");  }
static int csfclose(void *fp)                   { return fclose((FILE*)fp);        }
#endif

int main()
{
#ifdef __COVERAGESCANNER__
    __coveragescanner_set_custom_io( NULL,
            csfputs,
            csfopenappend,
            NULL,
            NULL,
            csfclose,
            NULL);
#endif
....
}

To record a coverage report when a specific trigger occurs, add the following source code lines in its handler:

#ifdef __COVERAGESCANNER__
    __coveragescanner_save();
    __coveragescanner_clear();
#endif

Coco v7.6.0 ©2026 The Qt Company Ltd.
Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.