代码分析和追溯
通过使用报告、可追溯性和 Polyspace® 静态代码分析产品来手动验证生成的代码
生成代码后,请通过分析代码度量、接口、替换和代码生成假设,确保代码满足您的要求。代码生成报告会提供有关生成代码的这些方面的信息。您可以评估代码并修改模型,以生成满足您要求的代码。
要验证生成的代码,请使用代码追溯在代码行及其对应的模型元素之间导航。您可以从代码中的超链接追溯到模型元素,也可以从模型元素追溯到代码行。您还可以包含从生成的代码到模型元素要求的链接。
函数
rtwtrace | Trace a block to generated code in code generation report |
主题
代码分析
- Check Code Generation Assumptions
Use standalone workflow to check code generator assumptions. - Analyze Code Replacements in Generated Code
The Code Replacements Report section in the code generation report documents the code replacement library (CRL) functions that were used for code replacements during code generation. - Generate Static Code Metrics Report for Simulink Model
When generating code, generate a report that includes static code metrics, such as, the number of lines of code, size of global variables, and the number of reads and writes. - Static Code Metrics
The code generator performs static analysis of the generated C or C++ code and provides these metrics in the static code metrics report in the code generation report. - Analyze Generated Data Code Interface Report
Use the code interface report to see documentation of the generated code data interfaces, including model entry-point functions and data interfaces. - Analyze Generated Service Code Interface Report
Use the code interface report to see documentation of the generated code service interface, including execution functions and services. - Log Program Execution Results
Log data to a MAT-file during execution of generated code.
代码追溯
- Verify Generated Code by Using Code Tracing
Code tracing enables navigation between generated code and its corresponding elements in a model. - Trace Simulink Model Elements in Generated Code
Trace Simulink® model elements by using code-to-model and model-to-code traceability in the code generation report. - Trace Stateflow Elements in Generated Code
Trace different Stateflow® elements to corresponding lines in generated code. - Reload Existing Traceability Information
Example of how to reload existing traceability information for a model. - Customize Traceability Reports
Obtain complete mapping between model elements and generated code. - Use Traceability in MATLAB Function Blocks
Trace between source code and generated code in a MATLAB Function block.