MATLAB Examples

Analyze Generated Code Using Polyspace Bug Finder

If you generate C or C++ code from models using Embedded Coder, you can check the generated code for run-time errors. Polyspace Bug Finder identifies run-time errors, concurrency issues, security vulnerabilities, and other defects in C and C++ embedded software..

This example contains a demo model from which you can generate code and then analyze the generated code.


Open Model

Open and explore the example model. The model contains a controller subsystem, which itself contains many subsystems. One of the subsystems has some issues that can lead to run-time errors in the generated code.


Generate and Analyze Code

Generate code from the controller subsystem or one of the subsystems underneath. Then, run Polyspace Bug Finder on the generated code. You can trace back from defects found in the generated code to corresponding blocks in the model. You can also check for coding rule violations and add annotations on blocks to justify the violations. For details, see Analyze Code Generated from Simulink Subsystem.

The controller subsystem also contains an S-Function block. You can separately analyze the C code that the S-Function block refers to. For details, see Analyze S-Function Code.