Adding watchpoints
A watchpoint is a special breakpoint that stops the execution of an
application whenever the value of a given expression changes.
There are several ways to set a watchpoint in the CDT debugger.
To set a watchpoint on a global variable
- Select a variable in the Outline view or the C/C++ Project view.
- Click Run > Toggle Watchpoint or select Toggle Watchpoint from the variable's pop-up menu.
- In the Add Watchpoint dialog box, do any of the following:
- To stop execution when the watch expression is read, select the Read check box.
- To stop execution when the watch expression is written to, select the Write check box.
- Click OK.
- The watchpoint appears in the Breakpoints view list.
Repeating the steps 1-2 on the same variable will remove the watchpoint.
To set a watchpoint on an arbitrary expression
- Open the Breakpoints view.
- Select Add Watchpoint from the view's context menu.
- In the Add Watchpoint (C/C++) dialog box, type an
expression in the Expression to watch field. The expression may be
anything that can be evaluated to an address.
- Follow the step 3-4 from above.
C/C++ Development perspective
Working with breakpoints and watchpoints
Run and Debug dialog box