simulink-debug-commandline
Installation
Review the source and dependencies with a prompt. A package is available to download.
Install with an AI assistant
Copy the prompt so your assistant can review the pinned revision and dependencies first.
View promptHide prompt
Check whether SkillPI Skill Finder is installed for your current agent. If it is missing, install and enable it using the official instructions at https://github.com/Findskills/skillpi. Then use Skill Finder to locate and install "simulink-debug-commandline" from this exact SkillPI detail page: https://skillpi.com/skills/deepskill-f0b511f78de1d6932be9c600a69eab9cebde45b1dd5afa1d4fdc3c653747ee24. Verify the upstream source and version against https://github.com/simulink/skills before installing. If they do not match, stop and report the mismatch. Report the installed path and source version.
Source and setup
github.com
Setup guidance pending
See the original source for supported tools, dependencies, and permissions.
Installation test pending
A command-line, method-level debugger used when you need to inspect the simulator's internal behavior for a specific module or simulation timestep. Trigger conditions include: a timestep produces incorrect output, a module yields unexpected values, state unexpectedly resets, debugging module execution, asking “what happened at t=X”, stepping the simulation loop, using sldebug, probing or tracing module data and method calls. This is for method-level inspection, not signal logging or graphical breakpoints.
Introduction source: third_party · simulink · 0.0.1 Reference
SkillPi interpretation
- Tasks
- 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).
- Testing
- Not tested
Browse files
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
tracefor continuous observation,breakwhen you need to pause and decide,straceonly 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.
- 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. sldebug('topModelName')— start the debugger in oneevaluate_matlab_codecall.slist— find block IDs of suspect blocks. Note the model name prefix if inside a Model Reference.trace (0)sysIdx:blkIdxfor each suspect block — prints U/Y/DSTATE/CSTATE on every method execution. Multipletracecommands can be batched (newline-separated).tbreak Tif needed — skip ahead to the time range of interest.step top— advance to next major time step. All traced blocks auto-print. Note: the firststep topfrom@0executes all initialization methods (SetupRunTimeResources, InitializeConditions, Enable) before the first Outputs.Major — watch for unexpected state resets during init.- Repeat
step topto observe evolution across time steps. Especially powerful for For Iterator subsystems — onestep topshows all iterations. stopwhen 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()whilesldebugis active — sldebug already runs the simulation; concurrentsim()will error. - Do NOT use bare
sysIdx:blkIdx— always include the task index:(0)0:1, not0: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. tbreakis a toggle — runtbreak Tagain to disable it. Usestatusto verify active breakpoints.- Multi-rate models — blocks in different rate groups have different task indices; verify with
slist. - Do NOT use
emode— legacy command.
Current listing version
0.0.1
Safety and assessment details
Quality assessment
Out of 100 · Assessment report from SkillPi LAB.
Highlights
- 针对 Simulink 仿真调试的专业场景,提供 method-level 调试能力
- 解决信号记录无法覆盖的底层状态变化问题
- 面向工程师用户,在特定场景下具有显著实用价值
Highlights
- 触发词覆盖全面,包含多种典型调试场景
- 边界清晰,明确区分于 signal logging 和 graphical breakpoints
- description 位置正确且内容完整
Areas to improve
-
缺少显式 When to Use 章节 Reported severity: Minor
文档内容已涵盖使用场景说明,但缺少显式的 "When to Use" 章节标题
Recommendation: 建议添加显式的 "When to Use" 章节标题以提升结构清晰度
Highlights
- Default Workflow 步骤清晰,包含端到端示例
- frontmatter 完整,单文件长度适中
- 命令参考详尽,包含核心命令和专用断点说明
Highlights
- 参数格式详细说明,包含 taskIdx/sysIdx/blkIdx 的完整规范
- 覆盖主要异常场景(Model References、synthesized blocks、multi-rate)
- 提供 gotchas 预防常见错误,包含并发 sim() 警告
- 不可逆操作有确认机制说明(tbreak 是 toggle)
The arithmetic mean of the first four original scores, rounded to a whole number.
Static text checks
100 / 100 · skillpi-20261123-no-r3-v1
No current rules matched the text.
This score reflects rule matches in the text and is provided for reference before use. It excludes attachments and runtime behavior.
Permissions and checks before use
Automatically summarized from this main document. Matches may be examples or defensive advice; they are not actual permission declarations. Attachments, external dependencies and runtime behavior are not covered.
These common operations were not identified in the main document. This does not mean no permissions or risks exist.
Security rating and access scope
safe · Static evidence review; not a runtime safety guarantee.
Before use, confirm and authorize actual file access, external services and network destinations in your host. This review grants no runtime permissions.
User discussion
No verified reviews yet.