Use the Toggle Watchpoint command to set a watchpoint on a global variable in a C/C++ editor view. A watchpoint suspends program execution when the memory location that you specify is accessed with a write or read operation and it's based on the access setting. Watchpoints can also be added directly in the Variables, Breakpoints, Outline, and the Memory Rendering views.
The debugger halts program execution on the line of source code that triggered the watchpoint. This is different than a breakpoint, which halts program execution prior to executing the line of source code on which the breakpoint is set.
Figure 1. Add Watchpoint window
Name | Description |
---|---|
Expression to watch |
If not already entered, you can enter any arbitrary memory location for watching. |
Units | Define the size of the units to monitor. This setting defaults to the size of the variable to watch. If an arbitrary memory address is entered, then the default unit size is set to 1 byte. Once you enable the units checkbox, you're must enter a value for it. |
Access: Write/Read | Check the appropriate access type to trigger the watchpoint for the specified memory location. |
The following steps work with C/C++ editor views, as well as the Variables, Breakpoints, and Outline views:
NOTE Watchpoints are shown in the Outline view, while breakpoints are not.
The global variable is highlighted in the source file.
The Add Watchpoint window appears (Figure 1).
Click to set a checkmark in the Write, Read, or both checkboxes at once.
The Add Watchpoint window closes, the new watchpoint appears in the Breakpoints view list, and the appropriate watchpoint status icon appears in the marker bar next to the global variable.
The global variable is highlighted in the source file.
The Add Watchpoint window appears (Figure 1).
Click to set a checkmark in the Write, Read, or both checkboxes at once.
The Add Watchpoint window closes, the new watchpoint appears in the Breakpoints view list, and the appropriate watchpoint status icon appears in the marker bar next to the global variable.