A watch breakpoint is a type of breakpoint that is triggered whenever
execution changes data at a specific address. You use this type of breakpoint
when you want to see where and how a variable is being changed in your program.
About this task
To set a watch breakpoint, do the following:
Procedure
- Right-click in the Breakpoints view and select from the
pop-up menu. This will invoke the Add a Watch Breakpoint wizard,
from which you will complete all other steps.
Note: You
can also open the Add a Watch Breakpoint wizard by
right-clicking inside the editor and choosing Add Watch Breakpoint from
the pop-up menu. This also works in the LPEX editor, but only if you are in
a debug session already. Variables do not have an address if the program has
not been started.
- In the Expression field, enter the name
of the expression where the breakpoint is to be set. If you highlight a variable
in the editor when you invoke the Add a Watch Breakpoint wizard, the Expression
field of this dialog will be pre-filled with the variable.
For C/C++, an expression is the name of
a variable or any other expression that resolves to a storage address. For
example, a dereferenced pointer is an expression.
- Enter the number of bytes of the address or expression you want
to watch in the Number of bytes to watch field, or
choose the number of bytes to watch from the field's drop-down menu. The expression
will be evaluated and the result used as an address where the watch will start.
The default value of this field is 0, which means that the entire length of
the variable is watched.
- If you do not wish to set the frequency of the breakpoint, click
Finish to set the breakpoint and dismiss the Add
a Watch Breakpoint wizard.
- If you wish to set the frequency of the breakpoint, click Next >.
In the resulting wizard page, you use the Frequency controls to tell the debugger
when to stop on a breakpoint and when to skip it. The debugger keeps track
of how many times each breakpoint is encountered. The fields in this section
tell the debugger on which encounter of a breakpoint the debugger should first
stop, how often it should stop, and on which encounter the debugger should
no longer stop. The following parameters are used to set the breakpoint frequency:
- From: Enter the first breakpoint encounter you
want the debugger to stop on. For example, if you want the debugger to skip
over the breakpoint the first five times it is encountered, enter "6".
- To: Enter the last breakpoint encounter you want
the debugger to stop on. For example, if you want it to start ignoring the
breakpoint after the 20th encounter, enter "20". To have it always stop on
the breakpoint, enter "Infinity".
- Every: Enter the frequency with which you want
the debugger to stop on this breakpoint. For example, if you want it to stop
on only one out of every four it encounters, enter "4".
Note: Other than the "Infinity" value, any frequency setting that you
enter should be a numeric value. If you enter an alphabetic value, the debugger
will use the default value for the field in which the alphabetic value was
entered.
When you are finished setting the frequency, click Finish to
set the breakpoint and dismiss the Add a Watch Breakpoint wizard.
Results
In the Add a Watch Breakpoint wizard, all
fields must be completed with valid entries before the breakpoint can be set.
Note that the default frequency does not have to be changed.