Contenido principal

polyspace-bug-finder

(System Command) Run a Bug Finder analysis on Windows, Linux, or other command line

Description

The polyspace-bug-finder system command runs a Polyspace® Bug Finder™ analysis at the command line using analysis options specified as command-line flags or using an options file.

Note

This Polyspace command is available in polyspaceroot\polyspace\bin. Here, polyspaceroot is the Polyspace installation folder, for instance, C:\Program Files\Polyspace\R2026a (see also Installation Folder). To avoid typing the full path to this command, add this location to the PATH environment variable in your operating system.

polyspace-bug-finder [options] runs a Bug Finder analysis if your current folder contains a sources subfolder with source files (.c or .cxx files). Bug Finder analyzes the source files in the sources folder and its subfolders.

polyspace-bug-finder -sources sourceFiles [options] runs a Bug Finder analysis on the source file(s) sourceFiles. You can customize the analysis with additional options.

example

polyspace-bug-finder -sources-list-file listOfSources [options] runs a Bug Finder analysis on the source files listed in the text file listOfSources. You can customize the analysis with additional options. Using a sources list file is recommended when you have many source files spread over multiple folders. By keeping the list of sources in a text file, you can control the scope of your analysis and add sources to the analysis without moving the source files to the sources folder.

polyspace-bug-finder -options-file optFile runs a Bug Finder analysis with the options specified in the option file. When you have many analysis options, an options file makes it easier to run the same analysis again.

example

polyspace-bug-finder -h[elp] lists a summary of possible analysis options.

Examples

collapse all

Run a local Bug Finder analysis by specifying analysis options at the command line itself. This example uses source files from a demo Polyspace Bug Finder example. To run this example, replace polyspaceroot with the path to your Polyspace installation, for example C:\Program Files\Polyspace\R2026a.

Run an analysis on numerical.c and programming.c, checking for MISRA C™:2012 mandatory rules, programming and numerical defects, and using GNU 4.7 compiler settings. This example command is split by ^ characters for readability. In practice, you can put all commands on one line.

polyspace-bug-finder -sources ^
polyspaceroot\polyspace\examples\cxx\Bug_Finder_Example\sources\numerical.c,^
polyspaceroot\polyspace\examples\cxx\Bug_Finder_Example\sources\programming.c ^
-compiler gnu4.7 -misra3 mandatory -checkers numerical,programming ^
-author jlittle -prog myProject -results-dir C:\Polyspace_Workspace\Results\

Open the results.

polyspace C:\Polyspace_Workspace\Results\ps_results.psbf

To rerun the analysis, you must rerun it from the command line.

Run a local Bug Finder analysis by specifying analysis options using an options file. This example uses source files from a demo Polyspace Bug Finder example. To run this example, replace polyspaceroot with the path to your Polyspace installation, for example C:\Program Files\Polyspace\R2026a.

Save this text to a text file called myOptionsFile.txt.

# Options for analyzing numerical.c and programming.c
-sources polyspaceroot\polyspace\examples\cxx\Bug_Finder_Example\sources\numerical.c
-sources polyspaceroot\polyspace\examples\cxx\Bug_Finder_Example\sources\programming.c
-compiler gnu4.7
-misra3 mandatory
-checkers numerical,programming 
-author jlittle 
-prog myProject 
-results-dir C:\Polyspace_Workspace\Results\

Run the analysis with the options specified in the text file.

polyspace-bug-finder -options-file myOptionsFile.txt

Open the results.

polyspace C:\Polyspace_Workspace\Results\ps_results.psbf

To rerun the analysis, you must rerun it from the command line.

For more information on options files, see Options Files for Polyspace Analysis.

Input Arguments

collapse all

Comma-separated C or C++ source file names, specified as a string. If the files are not in the current folder (pwd), sourceFiles must include a full or relative path. To avoid errors because of paths with spaces, add quotes " " around the path. You can also use wildcards to analyze all source files with .c or .cpp extension in a specific folder. For more information, see Application source files (-sources).

If your current folder contains a sources subfolder with the source files, you can omit the -sources flag. The analysis considers files in sources and all subfolders under sources. To include multiple folders in your analysis, add all the folders for the analysis to the sources folder before running the command.

Example: myFile.c, "C:\mySources\myFile1.c,C:\mySources\myFile2.c"

Text file which lists the name of C or C++ files, specified as a string. If the files are not in the current folder (pwd), listOfSources must include a full or relative path. To avoid errors because of paths with spaces, add quotes " " around the path.

To analyze source files from multiple folders without moving the source files, list the full or relative path of the source files in a text file and specify the file as input to this option. For more information, see Application source files (-sources-list-file).

Example: filename.txt, "C:\ps_analysis\source_files.txt"

Analysis options and their corresponding values, specified by the option name and if applicable value. For syntax specifications, see the individual analysis option reference pages.

Example: -lang C-CPP -compiler diab

Text file listing analysis options and values, specified as a string. For more information, see -options-file.

Example: opts.txt, "C:\ps_analysis\options.txt"

Tips

If you run the command as part of a script, check the exit status to confirm a successful analysis. The command returns zero on a successful analysis. A nonzero return value means that the analysis failed and was not completed. For instance, if the analyzed file does not compile, the command returns a nonzero value. If some of the files do not compile when you are analyzing multiple files, the command completes analysis on the files that do compile and returns zero. It is possible to stop analysis if a file does not compile. See Stop analysis if a file does not compile (-stop-if-compile-error).

After running the command, you can check the %ERRORLEVEL% variable in Windows® command line to confirm a successful analysis.

Version History

Introduced in R2013b