Setting conditional breakpoints

In most circumstances programs can be successfully debugged by setting breakpoints, running the program and examining data. There are some problems which are difficult to debug using simple breakpoints. For example an iterative loop which goes wrong on the 1563th iteration would be very time consuming to debug. You could add extra code to the program to allow SDBG to activate a breakpoint on the 1562nd loop. However, a quicker method is to use a conditional breakpoint. A conditional breakpoint is one which only activates when a given condition is satisfied.

A conditional breakpoint is formed in three parts. Firstly there is an initial delay. This is the number of times the breakpoint has to be executed before it will activate. Secondly there is a repeated delay. This allows you to activate a breakpoint at predetermined intervals. Thirdly, there is an optional expression. When a breakpoint is about to activate, the expression will be evaluated. The breakpoint will only activate if the result of the expression is non-zero.

When you press Shift+F2 an input box will be displayed. You should type into this box the number of times the breakpoint can be executed before it is activated. Entering '5' will cause the breakpoint to activated the 5th time this line is executed. You will then be asked for the number of executions between subsequent breakpoints. You will finally be given an input box into which you can type an expression that will control whether a breakpoint activates or not. You can leave this expression blank if it is not required.

The following table gives examples for the three settings:

 

Requirement

Initial number

Repeat number

Expression

Stop after the 198th iteration

198

1

 

Stop after the 7th iteration and every subsequent 11th

7

11

 

Stop when eps is greater than 1

1

1

eps >1

Stop when eps is greater than 1 and I know this is after the 654th iteration

654

1

eps >1

 

You should note that there is a speed penalty if SDBG has to calculate the result of an expression. Indeed a small speed penalty will result from setting any breakpoint. This is in direct proportion to the number of breakpoints encountered.

You can set the initial delay to zero. This implies that the breakpoint will never activate which can be useful when trying to establish how many times a certain point is reached. You can cancel a conditional breakpoint by moving the cursor to the line and pressing either F2 or Shift+F2. In fact the standard breakpoint is a conditional breakpoint with the delays set to one. You can display the status of all system breakpoints with the 'breakpoints' command.

 

 

Basket
Empty
 
Copyright © 1999-2024 Silverfrost Limited