Reputation: 23302
I am debugging a program that has a lot of for loops, each one with hundreds of values to loop through.
Within all this, I'd like to determine that behaviour of a variable when it reaches a certain value.
However, to do so, I would have to manually cycle step through all the loops and make sure not to space out. It would take me hours.
Is there a way to set a breakpoint that only activates when the variable is a certain value?
Upvotes: 1
Views: 167
Reputation: 117856
Create a conditional breakpoint. These can be set up to break when
the value at an address changes, which is useful if you are looking for when a variable is set
the value of a variable equals a particular value, which is the case you are looking for
There are other nice uses of conditional breakpoints so you don't have to put a hard breakpoint as you noted.
Upvotes: 3
Reputation: 121
Just insert in the cycle something like
If(Variable==value)
{
int unuseful=0;
}
and set the breakpoint on the operation inside the if
Upvotes: 3
Reputation: 325
What you're looking for is called conditional breakpoints.
Visual Studio 2010 does support conditional breakpoints, you can just create your breakpoint, right click it and then click on Condition.
Upvotes: 6