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.

Contents

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.

open_system('psdemo_model_link_sl');

Generate and Analyze Code

Generate code from the controller subsytem 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 docid:bugfinder_ug.mw_ec5db455-afe7-4ff8-977c-69c34a80ca17.

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 docid:bugfinder_ug.bu582ic.