How to: Set a Data Breakpoint (Native Only)
This topic applies to:
Visual Studio Edition |
Visual Basic |
C# |
C++ |
J# |
Express Edition |
No |
No |
Native |
No |
Standard Edition |
No |
No |
Native |
No |
Pro/Team Edition |
No |
No |
Native |
No |
Data breakpoints allow you to break execution when the value stored at a specified memory location changes.
You can set data breakpoints in break mode only.
Addresses of variables change from one debugging session to the next. For this reason, data breakpoints are automatically disabled at the end of each debugging session. If you attach a data breakpoint to a local variable, the data breakpoint remains enabled when the function ends. The memory address it is attached to no longer has the same meaning, however, so the results of such a breakpoint are unpredictable. If you set a data breakpoint on a local variable, it is best to remove or disable it before the function ends.
Visual Studio currently supports setting four data breakpoints per project.
Note |
---|
The dialog boxes and menu commands you see might differ from those described in Help depending on your active settings or edition. To change your settings, choose Import and Export Settings on the Tools menu. For more information, see Visual Studio Settings. |
How to Set a Memory Change Breakpoint
From the Debug Menu, choose New Breakpoint and click New Data Breakpoint
—or—
in the Breakpoints window Menu, click the New dropdown and choose New Data Breakpoint.
The New Breakpoint dialog box appears.
In the Address box, enter a memory address or expression that evaluates to a memory address. For example,
&foo
to break when the contents of variablefoo
change.In the Byte Count box, enter the number of bytes you want the debugger to watch. For example, if you enter
4
, the debugger will watch the four bytes starting at&foo
and break if any of those bytes change value.Click OK.