Main Content

Generate Report Containing Polyspace Bug Finder and Polyspace Code Prover Results

To obtain a report that contains the Code Prover results, all code metrics, and coding rule violations, run the command polyspace-report-generator. Generate a combined report containing these results:

For more information, see polyspace-report-generator.

Code Prover does not check for violations of coding standards, such as MISRA C:2012. Use Bug Finder to check for coding rule violations. Code Prover computes the stack usage code metrics only. The other code metrics are calculated by Bug Finder.

Prerequisite

  • Before generating the report, confirm that your installed Polyspace® version is R2021b or later.

  • To use the C source file used in this example, navigate to polyspaceroot\polyspace\examples\cxx\Bug_Finder_Example\sources\numerical.c. Substitute polyspaceroot with your Polyspace installation path, for instance, C:\Program Files\Polyspace\R2024b. See also Installation Folder.

Obtain Code Metrics and Coding Rules Results by Using Bug Finder

Run a Bug Finder analysis and store the results.

  1. Run Bug Finder on numerical.c to check for coding rule standard violations, and then store the results in a folder named BFResults. For instance, at the command line, enter:

    polyspace-bug-finder -sources “polyspaceroot\polyspace\examples\cxx\Bug_Finder_Example\sources\numerical.c” -results-dir BFResults -code-metrics -misra3 all-rules -lang c -checkers none
    The command runs Bug Finder on numerical.c and stores the results in a folder named BFResults. Bug Finder checks for violations of MISRA C:2012 coding rules and computes the code metrics.

    In the next steps, Code Prover performs an exhaustive check for run-time errors and other issues. In such a case, activating the Bug Finder defects might be redundant. Polyspace Report Generator does not support putting Code Prover run-time errors and Bug Finder defects in the same report. The defect checkers are deactivated in this step.

  2. Navigate to Current Folder\BFResults and open the file ps_results.psbf. Verify that the results contain MISRA C;2012 violations and code metrics results.

Obtain Run Time Check and Stack Usage Results by Using Code Prover

Run a Code Prover analysis and store the results.

  1. Run Code Prover on numerical.c to check for run-time issues and to calculate stack usage metrics. Store the results in a folder named CPResults. For instance, at the command line, enter:

    polyspace-code-prover -sources “polyspaceroot\polyspace\examples\cxx\Bug_Finder_Example\sources\numerical.c” -results-dir CPResults -stack-usage -lang c -main-generator
    The command runs Code Prover on numerical.c and stores the results in a folder named CPResults. Because numerical.c does not have a main() function, specify the option Verify module or library (-main-generator) (Polyspace Code Prover).

  2. Navigate to Current Folder\CPResults and open the file ps_results.pscp. Verify that the results contain run-time checks and stack usage results.

Generate a Combined Report

After generating the Bug Finder and Code Prover results, summarize the results into a single report. To generate the report, specify an appropriate template and the results folders as inputs to the command polyspace-report-generator.

  1. Before executing the report generation command, select an appropriate template. For this example, the report must contain a chapter each for code metrics, Code Prover runtime checks, and MISRA C:2012 violations. The template Developer.rpt accommodates all of these results.

    To include additional chapters about coding standards such as AUTOSAR C++14 or CERT C/C++, modify the existing templates. See Customize Existing Bug Finder Report Template.

  2. Start the report generation by using the command polyspace-report-generator. Specify the template Developer.rpt as the input to -template. Provide the folders containing the Bug Finder and Code Prover results as inputs to -results-dir. At the command line, enter:

    polyspace-report-generator -template "polyspaceroot\toolbox\polyspace\psrptgen\templates\Developer.rpt" -results-dir “CPResults”,”BFResults” -output-name combined_report -format PDF

The file combined_report.pdf is saved in your current folder. Open the file and verify that the report contains code metrics, Code Prover run-time checks, and MISRA C:2012 violations.

See Also

|

Related Topics