Monday, December 22, 2008

Eclipse Debugger, part II

As I said in the Part I, this time I will focus on the Hit Count property and the Conditions of breakpoints. If you go to the breakpoint's properties (right click on the breakpoint and choose Breakpoint properties... option) you will see two interesting options:

Hit count

When we enable the Hit Count and give some positive integer value X the breakpoint will suspend the execution when it would be hit Xth time.
Lets illustrate this with example. If we consider the following code:

and we set the Hit count of the breakpoint (look at the picture above to see where the breakpoint is placed) to 7 we will find the following output in the Console view before the execution is suspended:

So as you can see the execution was suspended when the breakpoint was hit 7th time.

Sometime everyone faces the situation when we want a breakpoint to be active only if some condition is fulfilled (e.g. we go in the loop through a 1000 elements list o people's names and we want to debug this loop for a particular name and we don't want to go 1000 times through this loop). To see how it works let's take the same code and let's set the condition the following way:
In this case the output in the Console view will look as follows:
The given condition is evaluated in the context of the breakpoint, so we can use all the variables that are available the context. Of course you don't have to use the numerical conditions, any expression that gives boolean answer can be used!


Jacek Laskowski said...

I'm sure it's all well known and described in English (Eclipse documentation or on Eclipse related blogs). It'd be more helpful if it were in Polish, I guess. Will it ever show up in Polish? A short movie would make the trick even better. I bet.

Notatnik Projektanta Java EE

Jakub Jurkiewicz said...

Some of this stuff was published in the first issue of polish magazine Java Express:

xhi2018 said...

Very useful for me! Thanks for pointing that out :-)

Anonymous said...

Things are going swimmingly. achat levitra I suggest you to visit a site on which there are many articles on a theme interesting you.