set breakpoints to debug charts -凯发k8网页登录

main content

set breakpoints to debug charts

you enable debugging for a stateflow® chart when you set a breakpoint. a breakpoint is a point on a stateflow chart that pauses the simulation so you can examine the status of the chart. while simulation is paused, you can view stateflow data, interact with the matlab® workspace, and step through the simulation.

breakpoints appear as circular red badges. for example, this chart contains breakpoints on the upshifting state and the transition from steady_state to upshifting.

stateflow chart with breakpoints on a state and a transition.

set a breakpoint for a stateflow object

you can set breakpoints on charts, states, transitions, graphical or truth table functions, and events.

breakpoints on charts

to set a breakpoint on a chart, right-click inside the chart and select set breakpoint on chart entry. this type of breakpoint pauses the simulation before entering the chart.

to remove the breakpoint, right-click inside the chart and clear the set breakpoint on chart entry option.

breakpoints on states and transitions

you can set different types of breakpoints on states and transitions.

objectbreakpoint type
state

on state entry — pause the simulation before performing the state entry actions.

during state — pause the simulation before performing the state during actions.

on state exit — pause the simulation after performing the state exit actions.

transition

when transition is tested — pause the simulation before testing that the transition is a valid path. if no condition exists on the transition, this breakpoint type is not available.

when transition is valid — pause the simulation after the transition is valid, but before taking the transition.

to set a breakpoint on a state or transition, right-click the state or transition and select set breakpoint. for states, the default breakpoints are 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.

breakpoints on stateflow functions

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 pauses the simulation before calling the function.

to remove the breakpoint, right-click the function and clear the set breakpoint during function call option.

breakpoints on events

you can select two types of breakpoints on events:

  • start of broadcast — pause the simulation before broadcasting the event.

  • end of broadcast — pause the simulation after a stateflow object reads the event.

available breakpoints depend on the scope of the event.

scope of eventstart of broadcastend of broadcast
localavailableavailable
inputavailablenot available
outputnot availablenot available

to set or clear breakpoints on an event, use the property inspector or the model explorer to modify the debugger breakpoints properties. for more information, see .

change breakpoint types

a breakpoint badge can represent more than one type of breakpoint. to see a tooltip that lists the breakpoint types that are set on a stateflow object, point to its badge. in this example, the badge on the state upshifting represents two breakpoint types: on state entry and during state.

tooltip that shows the breakpoint types on a state.

to change the type of breakpoint on an object, click the breakpoint badge. in the breakpoints dialog box, you can select a different configuration of breakpoints, depending on the object type.

breakpoints dialog box for a state.

clearing all of the check boxes in the breakpoints dialog box removes the breakpoint.

add breakpoint conditions

to limit the number of times that the simulation stops at a breakpoint, add a condition to the breakpoint. by default, a stateflow chart pauses whenever it reaches a breakpoint. when you add a condition to a breakpoint, the chart pauses at the breakpoint only when the condition is true.

to add a condition to a breakpoint:

  1. on the debug tab, click breakpoints list to open the stateflow breakpoints and watch window. alternatively, you can open the breakpoints and watch window by clicking the breakpoints list link in the breakpoints dialog box.

  2. select the breakpoints tab. the breakpoints tab lists all of the breakpoints in the chart. for more information, see manage breakpoints through the breakpoints and watch window.

  3. under the condition column, enter a condition for the breakpoint. you can use any valid matlab expression that combines numerical values and stateflow data objects that are in scope at the breakpoint.

note

you cannot use message data in a breakpoint condition expression.

for example, this chart has a breakpoint on the transition from steady_state to upshifting. this breakpoint stops the simulation every time that the transition is tested, even if the value of speed is far below up_th.

tooltip that shows the breakpoint types on a transition.

to inspect the chart before the transition is taken, you want the breakpoint to pause the simulation only when the value of speed is approaching the value of up_th. when you set the condition speed > up_th-2 on the breakpoint, the simulation pauses only when the value of speed is within 2 of the value of up_th.

breakpoints pane of the stateflow breakpoints and watch window.

when the simulation pauses, you can inspect the values of the variables speed and up_th and step through the simulation. for more information, see and .

manage breakpoints through the breakpoints and watch window

you can manage all of the breakpoints in the chart in the stateflow breakpoints and watch window. to open the breakpoints and watch window, on the debug tab, click breakpoints list. alternatively, open the breakpoints dialog box and click the breakpoints list link.

  • to see a list of all of the breakpoints and their associated conditions, select the breakpoints tab.

  • to inspect data and message values, select the watch tab. for more information, see .

tip

you can also manage the breakpoints in your stateflow chart by using the breakpoint list in the simulink® editor. for more information, see (simulink).

disable and reenable breakpoints

to disable a breakpoint without deleting its associated condition, clear the check box next to the breakpoint name. for example, in this chart, the breakpoint on the during state breakpoint for the upshifting state is disabled.

breakpoints pane of the stateflow breakpoints and watch window.

if you disable all the breakpoints for a graphical object, its breakpoint badge changes color from red to gray. if there is at least one breakpoint enabled for an object, the breakpoint badge remains red.

to reenable a breakpoint, select the box next to the breakpoint name. to disable or reenable all breakpoints, clear or select the check box at the top of the window.

remove breakpoints

to remove a breakpoint from the chart, point to the name of the breakpoint and click the remove this breakpoint icon that appears to the right of the name. when you remove a breakpoint, you also delete its associated condition.

remove this breakpoint icon in the stateflow breakpoints and watch window.

view breakpoint hits

the hits column displays the number of times that the simulation has paused on each breakpoint. when you change the condition for a breakpoint, the chart resets the number of hits.

save and restore breakpoints

breakpoints persist during a matlab session. when you close a model, its breakpoints remain in the breakpoints and watch window. if you reopen a model during the same matlab session, all of the breakpoints and their associated conditions are restored.

you can save the breakpoint and watch data lists and reload them in a later matlab session. to save a snapshot of the breakpoint and watch data lists, at the top of the breakpoints and watch window, click the save current breakpoints and watches icon. to restore a snapshot, click the load breakpoints and watches icon.

related topics

    网站地图