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.
Conditions
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!
Monday, December 22, 2008
Subscribe to:
Post Comments (Atom)
4 comments:
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.
Jacek
Notatnik Projektanta Java EE
Some of this stuff was published in the first issue of polish magazine Java Express: http://dworld.pl/javaexpress/numer/1.html
Very useful for me! Thanks for pointing that out :-)
Things are going swimmingly. achat levitra I suggest you to visit a site on which there are many articles on a theme interesting you.
Post a Comment