Main Content

polyspace.CodeProverResults

Read Polyspace Code Prover results from MATLAB

Description

Read Polyspace® Code Prover™ analysis results to MATLAB® tables by using this object. You can obtain a high-level overview of results or details such as each instance of a run-time check.

Note

Before you run Polyspace from MATLAB, you must link your Polyspace and MATLAB installations. See Integrate Polyspace with MATLAB and Simulink.

Creation

Description

resObj = polyspace.CodeProverResults(resultsFolder) creates an object for reading a specific set of Code Prover results into MATLAB tables. Use the object methods to read the results.

example

proj = polyspace.Project; resObj = proj.Results; creates a polyspace.Project object with a Results property. If you run a Code Prover analysis, this property is a polyspace.CodeProverResults object.

example

Input Arguments

expand all

Name of result folder, specified as a character vector. The folder must directly contain the results file with extension .psbf. Even if the results file resides in a subfolder of the specified folder, it cannot be accessed.

If the folder is not in the current folder, resultsFolder must include a full or relative path.

Example: 'C:\Polyspace\Results\'

Object Functions

getSummaryView number of Polyspace results organized by results type (Bug Finder) or color and file (Code Prover)
getResultsView all instances of Bug Finder or Code Prover results
variableAccessView C/C++ global variables along with read/write operations

Examples

collapse all

This example shows how to read Code Prover analysis results from MATLAB.

Copy a demo result set to a temporary folder.

resPath = fullfile(polyspaceroot,'polyspace','examples','cxx','Code_Prover_Example',...
'Module_1','CP_Result');
userResPath = tempname;
copyfile(resPath,userResPath);

Create the results object.

resObj = polyspace.CodeProverResults(userResPath);

Read results to MATLAB tables using the object.

resSummary = getSummary (resObj);
resTable = getResults (resObj);

Run a Polyspace Code Prover analysis on the demo file single_file_analysis.c. Configure these options:

  • Specify GCC 4.9 as your compiler.

  • Save the results in a results subfolder of the current working folder.

  • Specify that a main function must be generated, if it does not exist in the source code.

proj = polyspace.Project;

% Configure analysis
proj.Configuration.Sources = {fullfile(polyspaceroot, 'polyspace', 'examples',...
    'cxx', 'Code_Prover_Example', 'sources', 'single_file_analysis.c')};
proj.Configuration.TargetCompiler.Compiler = 'gnu4.9';
proj.Configuration.ResultsDir = fullfile(pwd,'results');
proj.Configuration.CodeProverVerification.MainGenerator = true;


% Run analysis
cpStatus = run(proj, 'codeProver');

% Read results
resObj = proj.Results;
cpSummary = getResults(resObj, 'readable');

Version History

Introduced in R2017a