Debugger : The Set File, Set Output And Cancel Output Commands : DO Clause

DO Clause

With each breakpoint, you can associate a sequence of Debugger commands to be performed each time the breakpoint is reached. You can also specify whether you want the prototype execution to pause after performing these commands, or to continue. To define the command associated with the breakpoint, use the DO clause when setting the breakpoint:

Pdb > SET BREAK label trigger_expression
DO sequence_of_commands END

The DO clause can contain any sequence of Debugger commands separated by semicolons.

For example, each time event e1 occurs, you want to stop and check the current values of conditions and data-items. Instead of retyping in the same commands on each arrival of the breakpoint, you enter them only once when defining the breakpoint:

Pdb > SET BREAK bp_1 e1 DO SHOW COND;
SHOW DATA END
 

Immediately upon reaching the breakpoint, the Debugger suspends the execution and displays the requested values:

Stopped at breakpoint BP_1 on event: E1
Current values of conditions:
chart1:CONNECTED = FALSE
chart2:NORMAL = TRUE
Current values of data-items:
chart2:X = 1
chart3:Y = 2.3

It then places the debugging prototype into debug mode. After examining the values, you may perform more Debugger commands.

If you want to perform the DO clause without suspension of the execution, you put GO as the last command in the DO sequence.

For example:

Pdb > SET BREAK bp_1 e1 DO SHOW COND; SHOW DATA; GO END
 
 

differs from the previous one in that the execution is not stopped after displaying the values. You would not be able to enter more commands at breakpoint bp_1.

If in a DO clause, the GO is followed by other commands, they are ignored by the Debugger.

DO clauses can, themselves, set breakpoints. This may result in nesting of DO clauses, as follows:

Pdb > SET BREAK bp_2 d2 DO SET BREAK bp_3 e3
DO SHOW DATA x END END

 

 

There are no restrictions on the depth of nesting.

A breakpoint can be reached only after the end of the step in which its trigger occurred. This is also the point where the DO clause is initiated. At this time, all that occurred during the last step is available in the DO clause.

At each step, all breakpoints are checked according to the alphabetical order of their labels. Consider, for example, triggers of two breakpoints named a and b which occurred in the same step. If the first has a GO command in its DO clause, the second breakpoint is not reached.