You enable debugging for a chart when you set a breakpoint. A breakpoint indicates a point at which Stateflow® halts execution of a chart that you are simulating. You can then view Stateflow data and the MATLAB® workspace to examine the status of the chart.
Depending on the type of object, you can set different breakpoints.
|Object Type:||Breakpoint Type:|
On Chart Entry — Stop execution before entering the chart.
On State Entry — Stop execution before performing the state entry actions.
During State — Stop execution before performing the state during actions.
On State Exit — Stop execution after performing the state exit actions.
When Transition is Valid — Stop execution after the transition tests valid, but before taking the transition.
When Transition is Tested — Stop execution before testing the transition to see if it is a valid path. If no condition exists on the transition, this breakpoint is not available.
|Graphical or truth table functions|
During Function Call — Stop execution before calling the function.
Start of Broadcast — Stop execution before broadcasting the event.
End of Broadcast — Stop execution after a Stateflow object reads the event.
You can set both types of breakpoints for local events, but only Start of Broadcast for input events.
Breakpoints appear as a circular badge in the associated object.
For example, the following chart contains breakpoints on state
the transition from
The badge can represent one or more breakpoints on an object.
Hover your cursor over the badge to see which breakpoints are set.
For example, the badge on state
On represents two
breakpoints: On State Entry and During State.
To set a breakpoint on the entry to a chart, right-click inside the chart and select Set Breakpoint on Chart Entry.
To set a breakpoint on a graphical object in a chart:
Right-click the object.
Select Set Breakpoints.
Choose the breakpoint type.
To set breakpoints for an event, use the Properties dialog box.
Open the Properties dialog box for the event.
Choose the breakpoint type, and select the check box.
Clicking the breakpoint badge opens the Breakpoints dialog box. You can add or clear breakpoints by selecting the check box next to the breakpoint type.
Selecting Manage breakpoints opens the Stateflow Breakpoints and Watch window. In this window, you can manage conditions for all breakpoints. For each breakpoint, you can:
Enable the breakpoint
Disable the breakpoint
Clear the breakpoint
View the hit count, or number of times a breakpoint has been encountered during simulation.
For more information, see Manage Stateflow Breakpoints and Watch Data.
When simulation stops at a breakpoint, the chart provides visual indicators of active elements and the currently executing object. The chart highlights active elements in blue and the currently executing object in green. For example, the following chart contains a breakpoint on entry in the HIGH state, a substate of On.
When simulation stops at the breakpoint:
The active On state appears highlighted in blue.
The currently executing HIGH substate appears highlighted in green, along with an execution status badge , indicating execution stopped at state entry.
When you hover the cursor over the badge, a tooltip is displayed, indicating:
Where execution stopped
Current event, if the chart is processing a local or input event