Main Content

Options Files for Polyspace Analysis

To adapt the Polyspace® analysis configuration to your development environment and requirements, you have to modify the default configuration through command-line options such as -compiler. Options files are a convenient way to collect multiple options together and reuse them across projects.

What Are Options Files

Options files are text files with one option per line. For instance, the content of an options file can look like this:

# Options for Polyspace analysis
# Options apply to all projects in Controller module
-compiler visual16.x
-D _WIN32
-code-behavior-specifications "Z:\utils\polyspace\forbiddenfunctions.xml"
The lines starting with # represent comments for better readability. These lines are ignored during analysis.

Specifying Options Files

Depending on the platform where you run analysis, you can specify an options file in one of the following ways.

Command Line

At the command line (and in scripts), specify an options file as argument to the option -options-file.

For instance, instead of the command:

polyspace-bug-finder -sources file.c -compiler visual16.x -D _WIN32 -code-behavior-specifications "Z:\utils\polyspace\forbiddenfunctions.xml"
Save this content:
-compiler visual16.x
-D _WIN32
-code-behavior-specifications "Z:\utils\polyspace\forbiddenfunctions.xml"
In a file options.txt in the path Z:\utils\polyspace\ and shorten the command to:
polyspace-bug-finder -sources file.c -options-file "Z:\utils\polyspace\options.txt"

You can use options files with these Polyspace commands:

  • polyspace-bug-finder

  • polyspace-bug-finder-server

  • polyspace-bug-finder-access

  • polyspace-code-prover

  • polyspace-code-prover-server

IDEs

If you run Polyspace as You Code™ using IDE extensions, you typically specify three groups of options differently:

Options GroupExtension Settings

Build options: You can extract build options from existing artifacts such as build commands and JSON compilation database.

You can also collect all build options in an options file and specify the option file path in the appropriate extension setting.

  • Visual Studio CodeAnalysis Options > Manual Setup > Build Setting : Polyspace Build Options File

  • Visual Studio®Get from Polyspace build options file (in section Build Configuration)

  • Eclipse™ — Get from Polyspace build options file (in section Build Configuration)

Checkers: You can select checkers using a checkers selection wizard.

See Configure Checkers.

Other remaining options: All remaining options can be collected in a second options file that goes into the appropriate extension setting.

  • Visual Studio CodeAnalysis Options > Manual Setup: Other Analysis Options

  • Visual Studio — Analysis Options > Other Analysis Options File

  • Eclipse — Analysis options file

If you use options files both for build options and other options, the result is the same as specifying a single options file with the other options appended to the build options. See also Specifying Multiple Options Files.

For more information on IDE extensions, see:

Polyspace Platform User Interface

In the Polyspace Platform user interface you typically do not need to use an options file. You can specify most options directly in the Configuration pane of the user interface.

However, some options are available only at the command line and do not have a counterpart in the user interface. If you need to specify multiple command-line-only options, you can collect them in an options file, for instance commandLineStyleOptions.txt. Then, click Configuration on the toolstrip to open the project configuration. On the Static Analysis tab, navigate to Advanced and specify the absolute path of the options file in the Other field:

-options-file C:\psconfig\commandLineStyleOptions.txt

Specifying Multiple Options Files

You can specify multiple options files in an analysis. For instance, at the command line, you can enter:

polyspace-bug-finder -sources file.c -options-file opts1.txt -options-file opts2.txt

When you specify multiple options files in an analysis, all options from the options files are appended to the analysis command. For instance, the preceding command has the same effect as using a single options file that places the content of opts1.txt above opts2.txt.

If an option appears in multiple files with conflicting arguments, the argument in the last options file prevails. For instance, in the preceding command, if opts1.txt contains:

-checkers all
-misra3 all
And opts2.txt contains:
-misra3 single-unit-rules
The analysis uses only the argument single-unit-rules for the option -misra3.

You can use this stacking of options files to override options. For instance, suppose you use a read-only options file that applies to your entire team but want to override some of the options in the file. You can override the options by using a second options file that you create and specifying your options file after the team-wide options file.

You can also specify the option -options-file within an options file and aggregate several options files in this way.

See Also

Topics