Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 300617

Summary: [breakpoints] Breakpoint hit count should only increase if condition is met
Product: [Eclipse Project] JDT Reporter: Markus Keller <markus.kell.r>
Component: DebugAssignee: JDT-Debug-Inbox <jdt-debug-inbox>
Status: CLOSED WONTFIX QA Contact:
Severity: normal    
Priority: P3 CC: darin.eclipse, Michael_Rennie
Version: 3.6   
Target Milestone: ---   
Hardware: PC   
OS: Mac OS X - Carbon (unsup.)   
Whiteboard: stalebug

Description Markus Keller CLA 2010-01-24 14:23:41 EST
I20100119-0800

The hit count of a breakpoint should only increase if the given condition is actually met.

E.g. debug this:

public class Try {
    public static void main(String[] args) {
        for (int i = 0; i < 20; i++) {
            System.out.println(i); // breakpoint
        }
    }
}

I made some experiments e.g. with:
- hit count: 5, condition (if true): i%2 == 0
- hit count: 5, condition (if true): i > 10

=> It looks like the hit count always gets incremented when the breakpoint is being passed. The condition is *only* evaluated when the hit counter matches the hit count. Before and after, the condition is never evaluated.

I can't think of many use cases where that would actually be useful. A better strategy would be to match the condition every time the target line is executed, and to only update the match counter when a condition indicates a match. This would e.g. allow me to set a breakpoint in Display#filterEvent(Event) that stops at second occurrence of a KeyDown event.
Comment 1 Darin Wright CLA 2010-01-26 22:15:14 EST
This seems like a reasonable behavior. The hit count implementation for line breakpoints is performed by the VM (i.e. native behavior). Since the condition is evaluated client side, we get the behavior that is present now - i.e. we aren't even told that the breakpoint is hit until the hit count is satisfied. However we could process the hit count client side rather than relying on the native debug interface.

Although it is a change in behavior, I don't expect it would surprise anyone.
Comment 2 Eclipse Genie CLA 2019-03-04 14:35:53 EST
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.