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. While simulation is halted, you can view Stateflow data and interact with the MATLAB® workspace to examine the status of the chart.
Breakpoints appear as circular red badges. For example, this chart contains breakpoints on
On and on the transition from
You can set breakpoints on charts, states, transitions, graphical or truth table functions, and events.
To set a breakpoint on a chart, right-click inside the chart and select Set Breakpoint on Chart Entry. This type of breakpoint stops simulation before entering the chart.
To remove the breakpoint, right-click inside the chart and clear the Set Breakpoint on Chart Entry option.
You can set different types of breakpoints on states and transitions.
To set a breakpoint on a state or transition, right-click the state or
transition and select Set Breakpoint. For states, the default
On State Entry and
During State. For transitions, the default breakpoint is
When Transition is Valid. To change the type of
breakpoint, click the breakpoint badge and select a different configuration of
breakpoints. For more information, see Change Breakpoint Types.
To remove the breakpoint, right-click the state or transition and select Clear Breakpoint.
To set a breakpoint on a graphical or truth table function, right-click the function and select Set Breakpoint During Function Call. This type of breakpoint stops simulation before calling the function.
To remove the breakpoint, right-click the function and clear the Set Breakpoint During Function Call option.
You can select two types of breakpoints on events:
Start of Broadcast — Stop
simulation before broadcasting the event.
End of Broadcast — Stop simulation
after a Stateflow object reads the event.
Available breakpoints depend on the scope of the event.
|Scope of Event||Start of Broadcast||End of Broadcast|
|Not available||Not available|
To set or clear breakpoints for an event, modify the Debugger Breakpoints properties through the Property Inspector or the Model Explorer. For more information, see Set Properties for an Event.
Breakpoints appear as circular red badges. A breakpoint badge can represent more than
one type of breakpoint. To see a tooltip listing the breakpoint types set for a Stateflow object, point to its badge. For example, the badge on the state
On represents two breakpoint types:
To change the type of breakpoint for an object, click the breakpoint badge. In the Breakpoints dialog box, you can select a different configuration of breakpoints, depending on the object type.
Clearing all of the check boxes in the Breakpoints dialog box removes the breakpoint.
Clicking the Manage breakpoints link 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 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, Stateflow enters debugging mode.
The MATLAB command prompt changes to
The Symbols window displays the value of each data object in the chart.
The chart highlights active elements in blue and the currently executing object in green.
For example, this chart contains a breakpoint on entry in the
state, a substate of
On. When simulation stops at the breakpoint, the
active state (
On) appears highlighted in blue and the currently executing
HIGH) appears highlighted in green.
An execution status badge appears in the graphical object where execution pauses.
Execution stopped before entering a chart or state.
Execution stopped in a state
Execution stopped after exiting a state.
Execution stopped before testing a transition.
Execution stopped before taking a valid transition.
To see execution status, point to the badge. A tooltip indicates:
Where the execution stopped
Current event (in the presence of a local or input event)
To view data values in the chart, point to a chart object. A tooltip displays:
The value of each data and message that the selected object uses
Temporal information (in the presence of a temporal logic operator)
For more information, see Watch Data in the Stateflow Chart.
After simulation stops at a breakpoint, you can continue chart execution from the Stateflow Editor toolbar, at the MATLAB command prompt, or by selecting a keyboard shortcut.
|Toolbar Icon||Option||Command||Description||Keyboard Shortcut|
Continue simulation to the next breakpoint.
Advance to the next step in the chart execution. At the chart level, possible steps include:
For more information, see Execution of a Stateflow Chart.
From a state or transition action that calls a function, advance to the first executable statement in the function.
From a statement in a function containing another function call, advance to the first executable statement in the second function.
Otherwise, advance to the next step in the chart execution. (See Step Over.)
From a function call, return to the statement calling the function.
Otherwise, continue simulation to the next breakpoint. (See Continue.)
Exit debug mode and pause simulation before next time step.
Exit debug mode and stop simulation.
In state or transition actions containing more than one statement, you can step through the individual statements one at a time by selecting Step Over. Stateflow highlights each statement before executing it. To execute a group of statements together, right-click the last statement in the group and select Run To Cursor.