Java – Dependent Breakpoints


Is it possible to add Dependent Breakpoints(Not a Conditional Bp) ( Breakpoint1 is enabled if B2 is enabled etc..) in Eclipse…
I know it is possible in Intellij IDea ..but havent found a way to get this working in Eclipse.


Best Solution

Eclipse thus far only supports conditional breakpoints, where the execution will suspend if a condition supplied evaluates to true. Thus, you could set the conditional of your breakpoint to be

objectReference == null

and eclipse will hit that break point if and only if that condition evaluates to true. These expressions can be as complex as you would like, but they can only reference values from your source code, not values from the eclipse environment (thus, you can't hit a second break point if a first one was hit, like you originally asked for). This conditional logic can be accessed by right clicking on a breakpoint and selecting "Breakpoint Properties...".

Instead, what I've found helpful is the "Run to Line" ability ([ctrl]+R, in the Run menu). When you're insertion point is on any later line while the execution is suspended, you can use the "Run to line" command to continue execution to that point in the source as if there was a break point set there. In essence, it basically sets and unsets a temporary breakpoint on the line of code your insertion point is at. The greatest part of the command is that it works across files, so that you can hit a break point in one file, go to the file where you would place the dependent break point, [ctrl]+R to that line in the second file. Its a great way to "breakpoint" to a specific line in a file without setting a full breakpoint that will be hit everytime.