Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jumping over a While loop in Debug mode

Here is the scenario: I put a break point at the beginning of a method that I want to debug... at first lets say there is Part1 in this method that I want to step into/over some of the codes... good... after that there is a While loop that I am NOT interested to step into/over it, I just want to tell the debugger that Hey you yourself run this loop for 10 times and just let me move to Part2 of my code which starts after this While loop , is it possible to do this with debugging options?

so something like this :

BreakPoint : MyMethod
{
Part One of the code : Ok, lets debug it

While Loop : I do not care, Do not want to debug it

Part Two of the code: Yes, I want to debug it too 
}
like image 350
Bohn Avatar asked May 17 '10 13:05

Bohn


People also ask

How do I skip a loop while debugging?

As a user I would suggest the following: make a hotkey to exit the loop in debugging mode, for example ctrl-shift-F11.

How do I skip a step while debugging in Visual Studio?

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

Can you step back in a debugger?

You can use step-back via the new Step Backward and Step Forward icons in the Debug toolbar. These icons navigate the events in the Events Tab. So, if you've just taken a step in live debugging (F10 or F11), you can use the Step Backward button to quickly navigate to the previous step.

What is step over in debug?

Use the Step Over debug command to step over a called program in a debug session. To use the Step Over debug command, enter STEP number-of-statements OVER . The variable number-of-statements is the number of statements of the program that you want to run in the next step before the program is halted again.


1 Answers

Right-click on the line of code you want to run to, and click "Run To Cursor", or you can set a second breakpoint after the loop and just run.

Edit: You kind of asked two questions here. The method above will let you step over the whole loop, regardless of how many iterations it goes through. If you want to only go through the loop body 10 times, add a breakpoint on the last statement of the loop, right-click that line, click "Breakpoint", then "Hit count", then "break when hit count is equal to" and put 10 in the box that appears. This will pause the program after the loop executes 10 times (you will manually have to reposition the current statement), but will NOT break if the loop executes less than 10 times (add an additional breakpoint after the loop as I suggested above).

like image 75
Jon Seigel Avatar answered Nov 01 '22 19:11

Jon Seigel