主要内容

polyspace.CodeProverResults

MATLAB 读取 Polyspace Code Prover 结果

说明

使用此对象将 Polyspace® Code Prover™ 分析结果读取到 MATLAB® 表中。您可以获取结果的高级概览或详细信息(例如运行时检查的每个实例)。

注意

在从 MATLAB 中运行 Polyspace 之前,必须将已安装的 Polyspace 与 MATLAB 相关联。请参阅将 Polyspace 与 MATLAB 和 Simulink 集成

创建对象

描述

resObj = polyspace.CodeProverResults(resultsFolder) 创建一个对象,用于将一组特定的 Code Prover 结果读取到 MATLAB 表中。使用对象方法读取结果。

示例

proj = polyspace.Project; resObj = proj.Results; 创建一个具有 Results 属性的 polyspace.Project 对象。如果运行 Code Prover 分析,此属性是一个 polyspace.CodeProverResults 对象。

示例

输入参量

全部展开

结果文件夹的名称,指定为字符向量。该文件夹必须直接包含扩展名为 .psbf 的结果文件。即使结果文件位于指定文件夹的子文件夹中,也无法访问。

如果文件夹不在当前文件夹中,则 resultsFolder 必须包含完整路径或相对路径。

示例: 'C:\Polyspace\Results\'

对象函数

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

示例

全部折叠

此示例说明如何从 MATLAB 读取 Code Prover 分析结果。

将演示结果集复制到临时文件夹。

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

创建结果对象。

resObj = polyspace.CodeProverResults(userResPath);

使用对象将结果读取到 MATLAB 表中。

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

对演示文件 single_file_analysis.c 运行 Polyspace Code Prover 分析。配置以下选项:

  • 指定 GCC 4.9 为编译器。

  • 将结果保存在当前工作文件夹的 results 子文件夹中。

  • 指定如果在源代码中不存在 main 函数,则必须生成该函数。

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');

版本历史记录

在 R2017a 中推出