When you make a breakpoint conditional, the debugger pauses when a certain condition is met. When a breakpoint is first set, the debugger pauses the program execution each time the breakpoint is encountered. However, using the Edit Breakpoints dialog, you can customize breakpoints so that they are activated only in certain conditions.
The Conditions tab in the
Breakpoint dialog is where you enter an expression that is evaluated
each time the debugger encounters the breakpoint while executing the
program. If the expression evaluates to
true
, then the breakpoint pauses the program. If the
condition evaluates to false
, then the debugger does not stop at that breakpoint location.
For example, suppose you want a breakpoint to pause on a line of code only when the variable mediumCount is greater than 10.
To set a breakpoint condition:
mediumCount > 10
You can enter any valid Java language expression in the Edit Breakpoint
dialog, but all symbols in the expression must be accessible from the
breakpoint's location, and the expression cannot contain any method
calls. For an exception breakpoint, you may want to use the exception
object in your condition by using _throw
.
The Pass Count field specifies the number of times that a breakpoint must be passed for the breakpoint to be activated. Pass counts are useful when you think that a loop is failing on the nth iteration. The debugger pauses the program the nth time that the breakpoint is encountered during the program run. The default value is 1.
If the Pass Count column is shown in the Breakpoints window, you can see the pass count value decrement each time the breakpoint line of code is encountered during the program execution. If the pass count equals 1 when the breakpoint line is encountered, the breakpoint is activated, and the program pauses at that line.
When pass counts are used together with breakpoint conditions, the
breakpoint pauses the program execution the
nth time that the condition is
true
; the condition must be
true
for the pass count to be decremented.
About Breakpoints
Setting Source
Breakpoints
Using
Acceptable Legal Java Expressions in the Debugger
Copyright © 1997, 2004, Oracle. All rights reserved.