simulink-debug-commandline

当需要检查仿真引擎在某个模块或特定时间步的内部行为时使用的命令行级方法级调试器。适用触发条件包括:某时间步输出错误、模块产生意外值、状态意外重置、调试模块执行、在 t=X 时查看发生了什么、逐步执行仿真循环、使用 sldebug、探测或跟踪模块的数据与方法调用。此工具针对方法级内部行为排查,而非信号记录或图形化断点。

仓库最近推送
GitHub Stars
160
Forks
12
Issues / PRs
2

安装方式

先用 Prompt 核对来源与依赖。也可下载安装包。

用 AI 助手安装

复制提示词,让助手先核对固定版本和依赖。

查看 Prompt收起 Prompt
先检查当前 Agent 是否已安装 SkillPI Skill Finder。如果尚未安装,请按官方仓库的说明安装并启用:https://github.com/Findskills/skillpi。然后使用 Skill Finder 打开此 SkillPI 详情页并定位 "simulink-debug-commandline":https://skillpi.com/zh/skills/deepskill-f0b511f78de1d6932be9c600a69eab9cebde45b1dd5afa1d4fdc3c653747ee24。安装前核对上游来源和版本:https://github.com/simulink/skills。来源不一致时停止并说明差异。核对通过后,用 Skill Finder 安装目标 Skill,并报告安装路径和来源版本。

来源与配置

github.com

配置方式待核实

请查看原始来源中的适用工具、依赖和权限要求。

安装实测待补充

当需要检查仿真引擎在某个模块或特定时间步的内部行为时使用的命令行级方法级调试器。适用触发条件包括:某时间步输出错误、模块产生意外值、状态意外重置、调试模块执行、在 t=X 时查看发生了什么、逐步执行仿真循环、使用 sldebug、探测或跟踪模块的数据与方法调用。此工具针对方法级内部行为排查,而非信号记录或图形化断点。

0 下载

介绍来源: third_party · simulink · 0.0.1 参考来源

SkillPi 解读

能完成的任务
翻译待完成,请参阅来源文档。
实测状态
未测试

文件浏览

在原站浏览文件 ↗

原始 SKILL.md

打开原文 ↗
Frontmatter
name: simulink-debug-commandline
description: Use when simulation results are wrong for specific blocks or specific time steps and you need to inspect exactly what happens inside the simulation engine at that moment. Trigger on "output is wrong at this time step", "block produces unexpected value", "state resets unexpectedly", "debug block execution", "what happens at t=X", "step through the simulation loop", "use sldebug", "probe block data", "trace block I/O", "debug block methods". This is the method-level debugger — not signal logging (big picture) or graphical breakpoints (set_param).

Command-Line Simulink Debugger (sldebug)

Text-based debugger that steps through the Simulink simulation loop at the engine method level — you see individual block methods (Outputs, Update, Derivatives, InitializeConditions, Enable, Disable) rather than just signal values. For enabled/triggered subsystems, pay special attention to Disable and Enable methods — these can reset or reinitialize block states and are a common source of unexpected behavior.

  • Use sldebug when you've localized unexpected behavior to a few blocks or time steps and need to understand why — which method caused a state change, what the I/O was at that moment, or why the solver chose a particular step size.
  • Don't use sldebug for big-picture analysis. Use signal logging first to identify which blocks and which time range are problematic, then switch to sldebug to zoom in.
  • Decision rule: Use trace for continuous observation, break when you need to pause and decide, strace only for solver behavior.

Default Workflow (Trace + Step Top)

The preferred pattern uses trace points (auto-print block I/O on every method execution, without pausing) combined with step top. One step top shows the complete execution sequence for an entire time step in a single tool call — far more efficient than break → probe → continue loops.

  1. Identify suspect blocks and time range — use model_read / model_overview + signal logging to find which blocks produce wrong output and around which time step.
  2. sldebug('topModelName') — start the debugger in one evaluate_matlab_code call.
  3. slist — find block IDs of suspect blocks. Note the model name prefix if inside a Model Reference.
  4. trace (0)sysIdx:blkIdx for each suspect block — prints U/Y/DSTATE/CSTATE on every method execution. Multiple trace commands can be batched (newline-separated).
  5. tbreak T if needed — skip ahead to the time range of interest.
  6. step top — advance to next major time step. All traced blocks auto-print. Note: the first step top from @0 executes all initialization methods (SetupRunTimeResources, InitializeConditions, Enable) before the first Outputs.Major — watch for unexpected state resets during init.
  7. Repeat step top to observe evolution across time steps. Especially powerful for For Iterator subsystems — one step top shows all iterations.
  8. stop when done.

Use breakpoints (break + probe → step over → continue) only when you need to conditionally examine data at a specific iteration or method before deciding what to do next. Use break ... Outputs or break ... Update to filter to a specific method — without a method name, break catches every method including init.

Session Rules

sldebug is interactive and blocks the MATLAB command window. The session persists across evaluate_matlab_code calls.

  • Batch non-stepping commands (trace, break, untrace, clear, status, probe) in a single call (newline-separated).
  • Stepping/execution commands (step top, step over, continue, stop) should each be in their own call.

Block Addressing

Blocks are identified by (taskIdx)sysIdx:blkIdx — e.g., (0)0:1, (1)0:3. Use slist to find IDs. Always include the parenthesized task index.

Component Meaning
taskIdx 0 for continuous, 1+ for discrete rates
sysIdx System index (0 = root)
blkIdx Block index in the sorted execution list

Model References: Prefix commands with the referenced model name — break mRefChild (0)1:3, probe mRefChild (0)1:3. Without the prefix, the debugger reports "system not found".

Synthesized blocks: slist may show engine-generated blocks (e.g., OutportBufferForOut1). These cannot be traced or probed but appear in the execution order. Include them when reporting slist results so the user understands what the engine inserted.

Command Reference

Core commands

Goal Command
Start debugger sldebug('modelName')
Find block IDs slist
Trace block I/O (auto-print) trace (0)sys:blk / untrace (0)sys:blk
Probe block snapshot probe (0)sys:blk
Show all states states
Advance one major time step step top
Step over current method step over
Step into subsystem step or step in
Step out of subsystem step out
Break before method break (0)sys:blk [Method]
Break after method bafter (0)sys:blk [Method]
Break at time T (toggle) tbreak T
Resume to next breakpoint continue
Show breakpoints/settings status
Remove breakpoint clear N or clear (0)sys:blk
Current position in sim loop where
End session stop

Specialized breakpoints (all toggles — run again to disable)

Command Pauses when
nanbreak Signal produces NaN or Inf
zcbreak Zero-crossing event occurs
xbreak State limits solver step size
ebreak Solver encounters an error
rbreak Solver requests a reset

Solver debugging (advanced)

Use the simulink-solver-profiler-analyzer skill first to identify problematic time ranges. Then use strace 1 + tbreak to zoom in on why the solver behaves that way. Key solver trace prefixes: TM = major step, Ts - Hs = successful minor step, Err - Ix = normalized error (>1 = step fails, Ix identifies the limiting state — run states to map it). For zero-crossing analysis, use zcbreak + zclist.

Gotchas

  • Do NOT call sim() while sldebug is active — sldebug already runs the simulation; concurrent sim() will error.
  • Do NOT use bare sysIdx:blkIdx — always include the task index: (0)0:1, not 0:1.
  • Do NOT fall back to signal logging — when this skill is requested, use the command-line debugger. Signal logging cannot reveal which block method caused a state change.
  • Do NOT use break → probe → continue as the primary pattern — prefer trace + step top. Only use breakpoints when you need conditional pausing.
  • tbreak is a toggle — run tbreak T again to disable it. Use status to verify active breakpoints.
  • Multi-rate models — blocks in different rate groups have different task indices; verify with slist.
  • Do NOT use emode — legacy command.

当前收录版本

0.0.1

核对来源版本 ↗

质量评测

满分100 · 来自 SkillPi LAB 实验室的评测报告。

场景价值65/100

亮点

  • 针对 Simulink 仿真调试的专业场景,提供 method-level 调试能力
  • 解决信号记录无法覆盖的底层状态变化问题
  • 面向工程师用户,在特定场景下具有显著实用价值
触发精准92/100

亮点

  • 触发词覆盖全面,包含多种典型调试场景
  • 边界清晰,明确区分于 signal logging 和 graphical breakpoints
  • description 位置正确且内容完整
结构规范85/100

待提升项

  • 缺少显式 When to Use 章节 原报告严重程度:轻微

    文档内容已涵盖使用场景说明,但缺少显式的 "When to Use" 章节标题

    改进建议:建议添加显式的 "When to Use" 章节标题以提升结构清晰度

亮点

  • Default Workflow 步骤清晰,包含端到端示例
  • frontmatter 完整,单文件长度适中
  • 命令参考详尽,包含核心命令和专用断点说明
执行可靠95/100

亮点

  • 参数格式详细说明,包含 taskIdx/sysIdx/blkIdx 的完整规范
  • 覆盖主要异常场景(Model References、synthesized blocks、multi-rate)
  • 提供 gotchas 预防常见错误,包含并发 sim() 警告
  • 不可逆操作有确认机制说明(tbreak 是 toggle)
证据可验 (前四项均值)84/100

取前四项原始分值的算术平均,四舍五入取整。可通过收录报告核对各项评分与说明,运行记录需单独查证。

正文静态检测

100 / 100 · skillpi-20261123-no-r3-v1

正文未命中当前规则。

分数仅反映正文中的规则命中,供使用前参考。附件与运行行为不在此评分范围内。

权限与使用前检查

根据当前主文档自动整理,命中内容可能是示例或防护说明;不是实际权限声明,也未覆盖附件、外部依赖或运行行为。

未从主文档识别到上述常见操作,不能据此判断无需权限或没有风险。

本站展示提示不会授予权限。涉及文件改动、密钥、外部发送或费用时,仍由你使用的工具按需确认。

安全评级与访问范围

safe · 静态证据核验,不代表运行安全保证。

使用前请由宿主核对并授权实际文件读写、外部服务和联网目的地;本站的核验不会授予任何运行权限。