开发者

Is it possible to skip over an abitrary amount of a loop during debug?? Visual Studio

I am trying to find an error in my code. The problem is the error occurs in a loop. But the loop iterates about 500 times. Instead of clicking through the loop. Is it possible to skip over a c开发者_C百科ertain amount of the loop ??


VS allows you to set a condition on a breakpoint in terms of variables that are in scope. So, in your case, you can test against the loop counter.


Here is a crude answer:

if ((iter % 10) == 0) {
    int stop = 1;
}

Then place a break-point at "int stop = 1;". Perhaps, there is a better way in VS but this is what I do from time-to-time.


You can assign new values to variables during debug session. Step through the loop statements as many times as you like, then set your loop counter (or whatever other vars maintain loop condition) to terminate the loop.


Just put the breakpoint in the loop like indicated below >>. Use F5 to get to the condition that causes failure so you can loop through the individual pass. How to know where to break is up to you.

for (int i = 0; i < LOOPMAX; i++) {
>>some_proc(i);
  some_other_proc(i);
  some_third_proc(i);
}

By pressing F5 it'll continue running till it gets to the next breakpoint (the next pass through the code). Sure you'll have to hit it 500 times, but that beats some thousands of times. Combine this with @Troubador code above.

PS: This answer IS really simple, but some people don't know they can do this.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜