Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How get a breakpoint on variable write in Visual Studio?

How I can set breakpoint on variable change (I think this is write access) in Visual Studio?

like image 204
user694655 Avatar asked Jun 03 '11 07:06

user694655


2 Answers

This is referred to as a Data Breakpoint in Visual Studio. To create one you'll need the address of the variable in question (just add &variableName) to the watch or immediate window. Then do the following

  1. Debug -> New Breakpoint -> New Data Breakpoint
  2. Enter the address in and size of the value in bytes

Note: This is only supported for C++ applications. Managed languages don't support data break points.

like image 200
JaredPar Avatar answered Oct 22 '22 07:10

JaredPar


You need to add "Has Changed" condition to your breakpoint. To do this:

  1. Set breakpoint on the line you want it to break when your variable is changed.
  2. Right-click red dot icon, select "Condition".
  3. Enter your variable name and select "Has Changed" option.

You may find more information in this MSDN how-to.

like image 22
Yuri Stuken Avatar answered Oct 22 '22 07:10

Yuri Stuken