Documentation

Set Breakpoints to Debug Charts

Types of Breakpoints

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:
Charts

On Chart Entry — Stop execution before entering the chart.

States

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.

Transitions

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.

Events

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 On and the transition from On to Off.

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.

Set a Breakpoint for a Stateflow Object

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:

  1. Right-click the object.

  2. Select Set Breakpoints.

  3. Choose the breakpoint type.

To set breakpoints for events and objects in state transition tables, use the Properties dialog box.

  1. Open the Properties dialog box for the object or event.

  2. 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 Data window. In this window, you can manage conditions for all breakpoints. For each breakpoint, you can:

  • Set conditions

  • 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.

Visual Indication of Execution at Breakpoints

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

    • Simulation time

    • Current event, if the chart is processing a local or input event

Was this topic helpful?