Thursday, May 20, 2010

Intellij IDEA debugging trick

Recently discovered one nice debugging feature in Intellij IDEA.

Sometimes it is needed to stop on breakpoint after some other breakpoint was executed. For example there is next code:


5:void method(int i) {
6: init();
7: doStuff(i);

You want to stop on line 7 when parameter is 4. Using only basic breakpoints, you will have to skip 3 first stops or use some breakpoints conditions, which is not always handy for some types of parameters.

In Intellij there is nice feature, that let's you specify dependency between breakpoints. So, in this example, you will have to put breakpoint 1 on line 4 and breakpoint 2 on line 7 and configure breakpoint 2 to depend on breakpoint 1. Then breakpoint 2 will only stop after breakpoint 1 was executed.

Nice feature that saved some time for me.

No comments:

Post a Comment