Main Content

variableAccess

View C/C++ global variables along with read/write operations

Description

varList = variableAccess(resObj) returns the distribution of global variables in a Code Prover result set denoted by the polyspace.CodeProverResults object resObj. The list also contains all read and write operations on the global variables.

example

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 list of global variables to MATLAB tables using the object.

varList = variableAccess(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 = proj.run('codeProver');

% Read results
resObj = proj.Results;
cpSummary = variableAccess(resObj);

Input Arguments

collapse all

Code Prover results set, specified as a polyspace.CodeProverResults object.

Output Arguments

collapse all

Table showing all global variables from a single Code Prover analysis along with read and write operations on them.

  • For each global variable, the table has information such as data type, number of times accessed, and so on.

  • For each read or write operation, the table has information such as file and function name, line number, and so on.

If a particular information is not available for a result, the entry in the table states <undefined>.

For more information on:

Version History

Introduced in R2017a