主要内容

run

运行 Polyspace 分析

语法

run(proj, product)

说明

status = run(proj, product) 使用 polyspace.Project 对象 proj 中指定的配置运行 Polyspace® Bug Finder™Polyspace Code Prover™ 分析。分析结果也存储在 proj 中。

输入参数

全部展开

包含配置和结果的 Polyspace 工程,指定为 polyspace.Project 对象。

要运行的分析类型。

输出参量

全部展开

分析状态。如果分析成功,则状态为 false。否则为 true

分析可能因多种原因而失败,包括:

  • 您提供了不存在的源文件。

  • 所有文件都未进行编译。即使仅有一个文件进行了编译,只要您未将 StopWithCompileError 属性设置为 true,分析仍会成功并返回 false 状态。

可能有许多其他原因会导致分析失败。如果分析失败,请在结果文件夹中检查日志文件。您可以使用 polyspace.Project 对象的 Configuration 属性查看结果文件夹:

proj = polyspace.Project;
proj.Configuration.ResultsDir
日志文件名为 Polyspace_R20##n_ProjectName_date-time.log

示例

全部展开

对演示文件 numerical.c 运行 Polyspace Bug Finder 分析。配置以下选项:

  • 指定 GCC 4.9 为编译器。

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

proj = polyspace.Project

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

% Run analysis
bfStatus = run(proj, 'bugFinder');

% Read results
bfSummary = proj.Results.getSummary('defects');

版本历史记录

在 R2017b 中推出