LazerBanana
LazerBanana

Reputation: 7211

Enable breakpoint after a number of hits

I want to debug a huge collection of 760000 records but in record 54000 it hangs and I want to debug the loop but don't want to continue 54000 times manually.

Is it possible to put a condition in IntelliJ to stop the thread after a number of iterations?

I Don't know the exact size of the collection as it is an Iterable and I don't know how to get the index.

Edit: I guess I could work around it and edit the code to insert the counter in the loop and create a condition on a breakpoint to stop on the iteration I suspect wrong.

for (Item item: iterable) {
counter++;
}

And then condition the breakpoint.

counter==54000

But unfortunately, I can't amend the code to add that counter.

*Using Community Edition of IntelliJ

Upvotes: 6

Views: 2125

Answers (2)

Marc
Marc

Reputation: 1976

Right click on the breakpoint in question. It will open a small dialog box with a few options. Select More at the bottom. Now you will see a context menu where you can set "pass count".

You can enter it in that box, regardless of whether you want to set other special conditions on your breakpoint.

Upvotes: 5

Alex
Alex

Reputation: 457

Place a break point as usual, then right-click on it -> Properties. In the opened dialog there is a "Condition" edit box, here you could put your expression.

Upvotes: 0

Related Questions