Products & Services Solutions Academia Support User Community Company

Learn more about Real-Time Workshop   

Enabling Instrumentation for Debugging


Use parameters on the Diagnostics and Real-Time Workshop > Debug panes of the Configuration Parameter dialog box to configure a model such that generated code and the build process are optimized for troubleshooting. 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.

To...Select...
Display progress information during code generation in the MATLAB Command WindowVerbose build.Compiler output also displays.
Prevent the build process from deleting the model.rtw file from the build directory at the end of the buildRetain .rtw file. This parameter is useful if you are modifying the target files, in which case you need to look at the model.rtw file.
Instruct the TLC profiler to analyze the performance of TLC code executed during code generation and generate a reportProfile TLC. The report is in HTML format and can be read in your Web browser.
Start the TLC debugger during code generationStart TLC debugger when generating code. Alternatively, enter the argument -dc for the System Target File parameter on the Real-Time Workshop pane. To start the debugger and run a debugger script, enter -df filename for System Target File.
Generate a report containing statistics indicating how many times the Real-Time Workshop code generator reads each line of TLC code during code generationStart TLC coverage when generating code. Alternatively, enter the argument -dg for the System Target File parameter on the Real-Time Workshop pane.
Halt a build if any user-supplied TLC file contains an %assert directive that evaluates to FALSEEnable TLC assertion. Alternatively, you can use MATLAB commands to control TLC assertion handling.

To set the flag on or off, use the set_param command. The default is off.

set_param(model, 'TLCAssertion', 'on|off') 

To check the current setting, use get_param.

get_param(model, 'TLCAssertion')
Detect loss of tunabilityDiagnostics > Data Validity > Detect loss of tunability. 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:
  • none — Loss of tunability can occur without notification.

  • warning — Loss of tunability generates a warning (default).

  • error — Loss of tunability generates an error.

For a list of supported operators and functions, see Tunable Expression Limitations

Enable model verification (assertion) blocks Diagnostics > Data Validity > 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 has the same affect on generated code as it does on simulation behavior. For example, simulation and code generation ignore this parameter when model verification blocks are inside an S-function. Possible values are:
  • User local settings

  • Enable All

  • Disable All

For Assertion blocks not disabled, generated code for a model includes one of the following statements, at appropriate locations, depending on the blocks input signal type (Boolean, real, or integer, respectively).

utAssert(input_signal);
utAssert(input_signal != 0.0);
utAssert(input_signal != 0);

By default, utAssert has no effect in generated code. For assertions to abort execution, you must enable them by specifying the followingmake_rtw command for Real-Time Workshop > Make command:

make_rtw OPTS="-DDOASSERTS"

Use the following variant if you want triggered assertions to print the assertion statement instead of aborting execution:

make_rtw OPTS="-DDOASSERTS -DPRINT_ASSERTS"

utAssert is defined as #define utAssert(exp) assert(exp).

To customize assertion behavior, provide your own definition of utAssert in a hand-coded header file that overrides the default utAssert.h. For details on how to include a customized header file in generated code, see Integrating External Code Using Model Configuration Parameters.

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.

See the Target Language Compiler documentation for details. Also, consider using the Model Advisor as a tool for troubleshooting model builds.

For descriptions of Debug pane parameters, see Real-Time Workshop Pane: Debug in the Real-Time Workshop reference documentation.

  


Related Products & Applications

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.

 © 1984-2009- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS