Making the most of Eclipse’s breakpoint conditions in the debugger

Not many developers I’ve come across are aware that Eclipse has this feature, but sometime setting conditions on breakpoints can save you a ton of time, especially if you’re stepping through the same lines again and again in a loop waiting for a condition to occur that you need to debug.

Once you have a breakpoint in place (double-clicking in the left hand column next to the line you’re interested in), go to your Breakpoints view in the Debug perspective. Right-click the breakpoint and select ‘Breakpoint properties’. In the middle of the dialog box that appears there is a text area where you can enter an expression that will either trigger the breakpoint when the expression is true, or when the condition changes, depending on the value of the radio button you select. In the textarea you can type an expression that you want to get evaluated, for example ‘secondsRemaining ==1’ (without the quotes). With the ‘condition is true’ radio button selected, this breakpoint will now only trigger when secondsRemaining (a variable that is in scope where my breakpoint is) has the value of 1. Easy.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.