Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 certain amount of the loop ??

like image 531
numerical25 Avatar asked May 24 '10 23:05

numerical25


People also ask

How do I skip a loop in debugging?

You can add a breakpoint after the loop and click F8 (resume). The debugger will stop on the next found breakpoint, e.g. you will have skipped the loop(s).

How do I skip the code while debugging in Visual Studio?

You can also click on the line you want to skip to and hit Ctrl+F10 (Run to Cursor).

How do I skip a breakpoint in Visual Studio?

You can select "Disable All Breakpoints" from the Debug menu. This and then continue with F5 . You could set this up as a keyboard shortcut under Tools/Options/Keyboard.


2 Answers

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.

like image 187
Troubadour Avatar answered Sep 27 '22 17:09

Troubadour


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.

like image 33
vad Avatar answered Sep 27 '22 19:09

vad