variableAccess
View C/C++ global variables along with read/write operations
Description
returns the distribution of global variables in a Code Prover result set denoted by the
varList
= variableAccess(resObj
)polyspace.CodeProverResults
object
resObj
. The list also contains all read and write operations on the
global variables.
Examples
Read Global Variables from Existing Results to MATLAB Tables
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 Code Prover Analysis and Read Global Variables to MATLAB Tables
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
resObj
— Code Prover results
polyspace.CodeProverResults
object
Code Prover results set, specified as a polyspace.CodeProverResults
object.
Output Arguments
varList
— Distribution of global variables
table
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:
The columns of the table, see Export Global Variable List.
MATLAB tables, see Tables.
Version History
Introduced in R2017a
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)