文档

Debug

In the Configuration Parameters dialog box, use parameters on the诊断窗格和调试参数以配置模型,以便将生成的代码和构建过程设置为调试。您可以设置适用于模型汇编阶段,目标语言代码生成阶段或两者的参数。

如果您编写用于自定义目标,集成旧版代码或开发新块的TLC代码,下表中的参数将有所帮助。

到... 选择...
在MATLAB中显示代码生成期间的进度信息®命令窗口

Verbose build编译器输出也显示。

Prevent the build process from deleting the模型。rtw从构建末尾的构建文件夹中的文件

保留.rtw文件如果要修改目标文件,此参数将很有用,在这种情况下,您需要查看模型。rtwfile.

指示TLC剖道师分析代码生成期间执行的TLC代码的性能并生成报告 个人资料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。或者,输入参数-dc为了the系统目标文件参数代码生成窗格。To start the debugger and run a debugger script, enter-DF文件名为了系统目标文件
生成一个包含统计信息的报告,指示代码生成器在代码生成过程中读取每行TLC代码的每行多少次 生成代码时启动TLC覆盖范围。或者,输入参数-dg为了theSystem Target File参数代码生成窗格。
如果用户提供的TLC文件包含一个%断言directive that evaluates to错误的

启用TLC断言。Alternatively, you can use MATLAB commands to control TLC assertion handling.

To set the flag on or off, use theset_param命令。默认值关闭。

set_param(型号,'tlcassertion','| off')

要检查当前设置,请使用get_param

get_param(型号,'tlcassertion')
Detect loss of tunability

Detect loss of tunability(万博1manbetxsimulink)在诊断>数据有效性窗格。当将表达式降低为数字表达式时,您可以使用此参数报告可调性的丧失。如果可调工作区变量通过掩码初始化代码修改,或者在无支撑的操作员或函数的算术表达式中使用,则可能发生这种情况。万博1manbetx可能的值是:

  • 没有任何- 无通知可能会发生可调性。

  • 警告- 可调性丧失会产生警告(默认)。

  • error- 可调性丧失会产生错误。

有关支持的运营商和功能的列表万博1manbetx,请参见可调表达限制

启用模型验证(断言)块

Model Verification block enabling(万博1manbetxSimulink)。使用此参数启用或禁用模型验证块,例如断言,检查静态间隙和相关范围检查块。诊断适用于生成的代码和仿真行为。例如,当模型验证块在s功能中时,仿真和代码生成忽略了此参数。可能的值是:

  • 用户本地设置

  • 启用全部

  • Disable All

对于未禁用的断言块,模型生成的代码包括以下语句之一,具体取决于块输入信号类型(分别是布尔,真实或整数)。

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

默认情况下,utAssert不更改生成的代码。为了断言流产执行,您必须通过指定以下内容来启用它们make_rtw命令代码生成>制作命令范围:

make_rtw opts =“  -  ddoasserts”

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

make_rtwOPTS="-DDOASSERTS -DPRINT_ASSERTS"

utAssert被定义为#define utassert(EXP)断言(EXP)

自定义断言行为,提供您自己的定义utAssert在覆盖默认值的手写标头文件中utassert.h。For details on how to include a customized header file in generated code, seeIntegrate External Code by Using Model Configuration Parameters

在加速器模式下运行模型时,Simulink万博1manbetx®引擎呼叫自身以执行断言块,而不是使用生成的代码。因此,当断言失败时,仍然调用用户定义的回调。

For more information about the TLC debugging options, see Debugging on目标语言编译器。Also, consider using the Model Advisor as a tool for troubleshooting model builds.

Related Topics

Was this topic helpful?