Break when a value changes using the Visual Studio debugger

FlySwat picture FlySwat · Oct 2, 2008 · Viewed 139.8k times · Source

Is there a way to place a watch on variable and only have Visual Studio break when that value changes?

It would make it so much easier to find tricky state issues.

Can this be done?

Breakpoint conditions still need a breakpoint set, and I'd rather set a watch and let Visual Studio set the breakpoints at state changes.

Answer

AShelly picture AShelly · Oct 2, 2008

In the Visual Studio 2005 menu:

Debug -> New Breakpoint -> New Data Breakpoint

Enter:

&myVariable