Ashwin Gupta
Ashwin Gupta

Reputation: 2197

How to skip to a specified iteration of a for loop in Eclipse debugger?

I've recently learned to use the debugger (yeah :D) and I am trying to debug a program that uses nested for loops to look for certain colors through a BufferedImage. The image is 1920 * 1080 pixels so the loops go through quite a few iterations. I seem to have an error in this so I tried adding a breakpoint in the loops. I know that my error is occuring at x = 300, y = 900. The issue is, I have to hit F8 for each iteration of the loop. Obviously, I'd rather not go through 270,000 iterations before getting to my error. Is there anyway I can specify what iteration of the for loop I want the debugger to jump to?

for (int x = 0; x < img.getHeight(); x++) {
    for (int y = 0; y < img.getWidth(); y++) { 
         //breakpoint here
         //some code here
    }
}

Otherwise, if this isn't possible, is there some other debug procedure I could attempt?

Upvotes: 2

Views: 2956

Answers (1)

Brian
Brian

Reputation: 13571

Eclipse supports Hit count for breakpoints.

Right click on your break point -> Breakpoint Properties

enter image description here

Set Hit count as 270000, the program will stop when it hits this line for the 270000th time.

enter image description here

Upvotes: 8

Related Questions