Configure Model for Debugging
In the Configuration Parameters dialog box, use parameters on the Diagnostics pane and debugging parameters to configure a model such that the generated code and the build process are set for debugging. You can set parameters that apply to the model compilation phase, the target language code generation phase, or both.
Parameters in the following table will be helpful if you are writing TLC code for customizing targets, integrating legacy code, or developing new blocks.
|Display progress information during code generation in the MATLAB® Command Window
Verbose build.Compiler output also displays.
|Prevent the build process from deleting the
from the build folder at the end of the build
Retain .rtw file. This parameter is useful if you are modifying the target
files, in which case you need to look at the
|Instruct the TLC profiler to analyze the performance of TLC code executed during code generation and generate a report
|Profile TLC. The report is in HTML format and can be read in your web browser.
|Start the TLC debugger during code generation
|Start TLC debugger when generating code. Alternatively,
enter the argument
-dc for the System target file parameter
on the Code Generation pane. To start the debugger
and run a debugger script, enter
-df filename for System
|Generate a report containing statistics indicating how many times the code generator reads each line of TLC code during code generation
|Start TLC coverage when generating code. Alternatively,
enter the argument
-dg for the System
Target File parameter on the Code Generation pane.
|Halt a build if a user-supplied TLC file contains an
that evaluates to
Enable TLC assertion. Alternatively, you can use MATLAB commands to control TLC assertion handling.
To set the flag on or off, use the
set_param(model, 'TLCAssertion', 'on|off')
To check the current setting, use
|Detect loss of tunability
Detect loss of tunability on the Diagnostics > Data Validity pane. You can use this parameter to report loss of tunability when an expression is reduced to a numeric expression. This can occur if a tunable workspace variable is modified by Mask Initialization code, or is used in an arithmetic expression with unsupported operators or functions. Possible values are:
For a list of supported operators and functions, see Tunable Expression Limitations
|Enable model verification (assertion) blocks
Model Verification block enabling. Use this parameter to enable or disable model verification blocks such as Assert, Check Static Gap, and related range check blocks. The diagnostic applies to generated code and simulation behavior. For example, simulation and code generation ignore this parameter when model verification blocks are inside an S-function. Possible values are:
For Assertion blocks not disabled, generated code for a model includes one of the following statements, depending on the blocks input signal type (Boolean, real, or integer, respectively).
utAssert(input_signal); utAssert(input_signal != 0.0); utAssert(input_signal != 0);
the model contains variant blocks with the
This statement checks that at least one variant choice is active for such variant blocks.
utAssert(<variant condition expression on the block>);
Use the following variant if you want triggered assertions to print the assertion statement instead of aborting execution:
make_rtw OPTS="-DDOASSERTS -DPRINT_ASSERTS"
is defined as
To customize assertion behavior,
provide your own definition of
When running a model in accelerator mode, the Simulink® engine calls back to itself to execute assertion blocks instead of using generated code. Thus, user-defined callbacks are still called when assertions fail.
For more information about the TLC debugging options, see Debugging on Target Language Compiler. Also, consider using the Model Advisor as a tool for troubleshooting model builds. For more information about the Model Advisor, see Run Model Advisor Checks.