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:
MISRA C:2012. See MISRA C:2012 Directives and Rules.
Code metrics. See Code Metrics.
Stack usage metrics. See Stack Usage Metrics.
Run-time checks. See Run-Time Checks.
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
. Substitutepolyspaceroot
\polyspace\examples\cxx\Bug_Finder_Example\sources\numerical.cpolyspaceroot
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.
Run Bug Finder on
numerical.c
to check for coding rule standard violations, and then store the results in a folder namedBFResults
. For instance, at the command line, enter:The command runs Bug Finder onpolyspace-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
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.
Navigate to
and open the fileCurrent Folder
\BFResultsps_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.
Run Code Prover on
numerical.c
to check for run-time issues and to calculate stack usage metrics. Store the results in a folder namedCPResults
. For instance, at the command line, enter:The command runs Code Prover onpolyspace-code-prover -sources “polyspaceroot\polyspace\examples\cxx\Bug_Finder_Example\sources\numerical.c” -results-dir CPResults -stack-usage -lang c -main-generator
numerical.c
and stores the results in a folder namedCPResults
. Becausenumerical.c
does not have amain()
function, specify the optionVerify module or library (-main-generator)
.Navigate to
and open the fileCurrent Folder
\CPResultsps_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
.
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 Code Prover Report Template.
Start the report generation by using the command
polyspace-report-generator
. Specify the templateDeveloper.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
polyspace-report-generator
| polyspace-code-prover