conditional breakpoints in eclipse

ever debugged through code that processed items of a huge collection?
but you are only interested in the processing of one specific collection?

never mind – there are good news!
Eclipse offers the chance to define conditional breakpoints, that is to specify a condition under which the breakpoint will suspend, if and only if that condition will become true (or alternatively, everytime the condition changes).

what to do

switch to the ‘debug’ perspective and open the view ‘breakpoints’

open the contextmenu of the breakpoint you want to make conditional and select ‘Breakpoint Properties…’

activate the checkbox ‘Enable Condition’.
now you are allowed to type the condition under which circumstances the breakpoint should suspend. you are free to express an arbitrary java expression (in the above mentioned case a boolean expression).
you can refer to any object, which is visible to the point in your source the pointcut is set (ctrl + space will list all referencable objects).
for example, the condition could refer to a property of the longing item of the collection which has an unique value
(like currentItem.getNamedId().equals( “1234567” ) ).

be sure, that the option ‘Suspend when: condition is true’ is activated

suspend policy should be set to ‘Suspend Thread’

That’s it!
The next time you debug through that piece of code, the breakpoint will only suspend, if the specified condition becomes true.

Advertisements

4 Responses to “conditional breakpoints in eclipse”

  1. seiko lk Says:

    セイコー タイ


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: