## Setting and Removing Watchpoints

You create a watchpoint to monitor a value in a specified memory location. 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.

#### Setting watchpoints

Right-click in the Breakpoints view and choose the Add Watchpoint (C/C++)... command to open the Add Watchpoint window. 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. Use the Add Watchpoint window to specify the memory location, its memory size, unit size, and define whether the watchpoint triggers on a read, write, or on both operations. Watchpoints can also be added directly in the Variables, Outline, and the Memory Rendering views.

Figure 1. Add Watchpoint window

##### Table 1. Add Watchpoint options

Name | Description
--- | ---
Expression to watch | If not already entered, you can enter any arbitrary memory location for watching.
Memory space | Not supported.
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. This setting is shown as a unique icon in the Breakpoints view next to the listed watchpoint. The following list shows the resolved version of the icons used to indicate the type of watchpoint set: Read only () Write only () Read/Write ()

#### Removing Watchpoints

In the Breakpoints view, locate the watchpoint to remove and:

- Right-click the watchpoint and choose Remove from the context menu

#### Other references

- Watchpoints overview