[hg] main-silver: #214416: Compute the hit counts manually for f...

  • From:
  • To:
  • Subject: [hg] main-silver: #214416: Compute the hit counts manually for f...
  • Date: Sat, 01 Dec 2012 13:36:49 -0800

changeset 67f99b254ac7 in main-silver ((none))
details: http://hg.netbeans.org/main-silver/rev/67f99b254ac7
description:
        #214416: Compute the hit counts manually for field and method 
breakpoints in case that they use more than one event request.

diffstat:

 
debugger.jpda/src/org/netbeans/modules/debugger/jpda/breakpoints/BreakpointImpl.java
       |  42 +++++++++-
 
debugger.jpda/src/org/netbeans/modules/debugger/jpda/breakpoints/FieldBreakpointImpl.java
  |  16 ++-
 
debugger.jpda/src/org/netbeans/modules/debugger/jpda/breakpoints/MethodBreakpointImpl.java
 |  12 ++-
 
debugger.jpda/src/org/netbeans/modules/debugger/jpda/breakpoints/ThreadBreakpointImpl.java
 |  42 +--------
 4 files changed, 67 insertions(+), 45 deletions(-)

diffs (232 lines):

diff --git 
a/debugger.jpda/src/org/netbeans/modules/debugger/jpda/breakpoints/BreakpointImpl.java
 
b/debugger.jpda/src/org/netbeans/modules/debugger/jpda/breakpoints/BreakpointImpl.java
--- 
a/debugger.jpda/src/org/netbeans/modules/debugger/jpda/breakpoints/BreakpointImpl.java
+++ 
b/debugger.jpda/src/org/netbeans/modules/debugger/jpda/breakpoints/BreakpointImpl.java
@@ -119,6 +119,8 @@
     private EvaluatorExpression compiledCondition;
     private List<EventRequest>  requests = new ArrayList<EventRequest>();
     private int                 hitCountFilter = 0;
+    private int                 customHitCount;
+    private int                 customHitCountFilter = 0;
 
     protected BreakpointImpl (JPDABreakpoint p, BreakpointsReader reader, 
JPDADebuggerImpl debugger, Session session) {
         this.debugger = debugger;
@@ -243,7 +245,11 @@
     }
 
     protected void addEventRequest (EventRequest r) throws 
InternalExceptionWrapper, VMDisconnectedExceptionWrapper, 
ObjectCollectedExceptionWrapper, InvalidRequestStateExceptionWrapper {
-        addEventRequest(r, false);
+        addEventRequest(r, customHitCountFilter != 0);
+    }
+    
+    protected final void setCustomHitCountFilter(int customHitCountFilter) {
+        this.customHitCountFilter = customHitCountFilter;
     }
     
     synchronized protected void addEventRequest (EventRequest r, boolean 
ignoreHitCount) throws InternalExceptionWrapper, 
VMDisconnectedExceptionWrapper, ObjectCollectedExceptionWrapper, 
InvalidRequestStateExceptionWrapper {
@@ -342,6 +348,34 @@
     private final Map<Event, Variable> processedReturnVariable = new 
HashMap<Event, Variable>();
     private final Map<Event, Throwable> conditionException = new 
HashMap<Event, Throwable>();
 
+    private Boolean processCustomHitCount() {
+        if (customHitCountFilter > 0) {
+            customHitCount++;
+            switch (breakpoint.getHitCountFilteringStyle()) {
+                case MULTIPLE:
+                    if ((customHitCount % customHitCountFilter) != 0) {
+                        return false;
+                    }
+                    break;
+                case EQUAL:
+                    if (customHitCountFilter != customHitCount) {
+                        return false;
+                    }
+                    customHitCountFilter = 0;
+                    removeAllEventRequests();
+                    break;
+                case GREATER:
+                    if (customHitCount <= customHitCountFilter) {
+                        return false;
+                    }
+                    break;
+                default:
+                    throw new 
IllegalStateException(getBreakpoint().getHitCountFilteringStyle().name());
+            }
+        }
+        return null;
+    }
+
     public boolean processCondition(
             Event event,
             String condition,
@@ -358,8 +392,13 @@
             Value returnValue,
             ObjectReference contextValue) {
 
+        Boolean CHCprocessed = processCustomHitCount();
+        if (CHCprocessed != null) {
+            return CHCprocessed.booleanValue();
+        }
         try {
             EventRequest request = EventWrapper.request(event);
+            if (customHitCountFilter == 0) {
             if (hitCountFilter > 0) {
                 EventRequestWrapper.disable(request);
                 //event.request().addCountFilter(hitCountFilter);
@@ -371,6 +410,7 @@
                 removeEventRequest(request);
                 addEventRequest(createEventRequest(request), true);
             }
+            }
 
             Variable variable = null;
             if (getBreakpoint() instanceof MethodBreakpoint &&
diff --git 
a/debugger.jpda/src/org/netbeans/modules/debugger/jpda/breakpoints/FieldBreakpointImpl.java
 
b/debugger.jpda/src/org/netbeans/modules/debugger/jpda/breakpoints/FieldBreakpointImpl.java
--- 
a/debugger.jpda/src/org/netbeans/modules/debugger/jpda/breakpoints/FieldBreakpointImpl.java
+++ 
b/debugger.jpda/src/org/netbeans/modules/debugger/jpda/breakpoints/FieldBreakpointImpl.java
@@ -164,23 +164,27 @@
     @Override
     protected void classLoaded (List<ReferenceType> referenceTypes) {
         boolean submitted = false;
+        int type = breakpoint.getBreakpointType();
+        boolean fieldAccessType = (type & FieldBreakpoint.TYPE_ACCESS) != 0;
+        boolean fieldModificationType = (type & 
FieldBreakpoint.TYPE_MODIFICATION) != 0;
+        int customHitCountFilter = breakpoint.getHitCountFilter();
+        if (!(fieldAccessType && fieldModificationType)) {
+            customHitCountFilter = 0; // Use the JDI's HC filtering
+        }
+        setCustomHitCountFilter(customHitCountFilter);
         for (ReferenceType referenceType : referenceTypes) {
             try {
                 Field f = ReferenceTypeWrapper.fieldByName (referenceType, 
breakpoint.getFieldName ());
                 if (f == null) {
                     continue;
                 }
-                if ( (breakpoint.getBreakpointType () &
-                      FieldBreakpoint.TYPE_ACCESS) != 0
-                ) {
+                if (fieldAccessType) {
                     AccessWatchpointRequest awr = EventRequestManagerWrapper.
                         createAccessWatchpointRequest 
(getEventRequestManager (), f);
                     setFilters(awr);
                     addEventRequest (awr);
                 }
-                if ( (breakpoint.getBreakpointType () &
-                      FieldBreakpoint.TYPE_MODIFICATION) != 0
-                ) {
+                if (fieldModificationType) {
                     ModificationWatchpointRequest mwr = 
EventRequestManagerWrapper.
                         createModificationWatchpointRequest 
(getEventRequestManager (), f);
                     setFilters(mwr);
diff --git 
a/debugger.jpda/src/org/netbeans/modules/debugger/jpda/breakpoints/MethodBreakpointImpl.java
 
b/debugger.jpda/src/org/netbeans/modules/debugger/jpda/breakpoints/MethodBreakpointImpl.java
--- 
a/debugger.jpda/src/org/netbeans/modules/debugger/jpda/breakpoints/MethodBreakpointImpl.java
+++ 
b/debugger.jpda/src/org/netbeans/modules/debugger/jpda/breakpoints/MethodBreakpointImpl.java
@@ -298,6 +298,14 @@
     protected void classLoaded (List<ReferenceType> referenceTypes) {
         boolean submitted = false;
         String invalidMessage = null;
+        int type = breakpoint.getBreakpointType();
+        boolean methodEntryType = (type & 
MethodBreakpoint.TYPE_METHOD_ENTRY) != 0;
+        boolean methodExitType = (type & MethodBreakpoint.TYPE_METHOD_EXIT) 
!= 0;
+        int customHitCountFilter = breakpoint.getHitCountFilter();
+        if (!(methodEntryType && methodExitType)) {
+            customHitCountFilter = 0; // Use the JDI's HC filtering
+        }
+        setCustomHitCountFilter(customHitCountFilter);
         for (ReferenceType referenceType : referenceTypes) {
             Iterator methods;
             try {
@@ -329,7 +337,7 @@
                                                  (signature == null ||
                                                   
egualMethodSignatures(signature, TypeComponentWrapper.signature(method)))) {
 
-                        if ((breakpoint.getBreakpointType() & 
MethodBreakpoint.TYPE_METHOD_ENTRY) != 0) {
+                        if (methodEntryType) {
                             if (MethodWrapper.location(method) != null && 
!MethodWrapper.isNative(method)) {
                                 Location location = 
MethodWrapper.location(method);
                                 BreakpointRequest br = 
EventRequestManagerWrapper.
@@ -372,7 +380,7 @@
                                 
entryMethodNames.add(TypeComponentWrapper.name (method));
                             }
                         }
-                        if ((breakpoint.getBreakpointType() & 
MethodBreakpoint.TYPE_METHOD_EXIT) != 0) {
+                        if (methodExitType) {
                             if (exitReq == null) {
                                 exitReq = EventRequestManagerWrapper.
                                         
createMethodExitRequest(getEventRequestManager());
diff --git 
a/debugger.jpda/src/org/netbeans/modules/debugger/jpda/breakpoints/ThreadBreakpointImpl.java
 
b/debugger.jpda/src/org/netbeans/modules/debugger/jpda/breakpoints/ThreadBreakpointImpl.java
--- 
a/debugger.jpda/src/org/netbeans/modules/debugger/jpda/breakpoints/ThreadBreakpointImpl.java
+++ 
b/debugger.jpda/src/org/netbeans/modules/debugger/jpda/breakpoints/ThreadBreakpointImpl.java
@@ -80,9 +80,6 @@
     // variables 
...............................................................
 
     private ThreadBreakpoint              breakpoint;
-    private int                           hitCount;
-    private int                           hitCountFilter;
-
 
     // init 
....................................................................
     
@@ -101,26 +98,23 @@
             int type = breakpoint.getBreakpointType();
             boolean threadStartedType = (type & 
ThreadBreakpoint.TYPE_THREAD_STARTED) != 0;
             boolean threadDeathType = (type & 
ThreadBreakpoint.TYPE_THREAD_DEATH) != 0;
-            boolean ignoreEventHitCount = false;
-            int hitCountFilter = breakpoint.getHitCountFilter();
-            if (threadStartedType && threadDeathType) {
-                if (hitCountFilter > 0) {
-                    this.hitCountFilter = hitCountFilter;
-                    ignoreEventHitCount = true;
+            int customHitCountFilter = breakpoint.getHitCountFilter();
+            if (!(threadStartedType && threadDeathType)) {
+                customHitCountFilter = 0; // Use the JDI's HC filtering
                 }
-            }
+            setCustomHitCountFilter(customHitCountFilter);
             //boolean bothType = threadStartedType && threadDeathType;
             if (threadStartedType) {
                 ThreadStartRequest tsr = EventRequestManagerWrapper.
                     createThreadStartRequest(getEventRequestManager());
-                addEventRequest (tsr, ignoreEventHitCount);
+                addEventRequest (tsr);
             }
             if (threadDeathType) {
                 VirtualMachine vm = getVirtualMachine();
                 if (vm != null) {
                     ThreadDeathRequest tdr = EventRequestManagerWrapper.
                         
createThreadDeathRequest(VirtualMachineWrapper.eventRequestManager(vm));
-                    addEventRequest (tdr, ignoreEventHitCount);
+                    addEventRequest (tdr);
                 }
             }
         } catch (InternalExceptionWrapper e) {
@@ -144,30 +138,6 @@
 
     @Override
     public boolean processCondition(Event event) {
-        if (hitCountFilter > 0) {
-            hitCount++;
-            switch (breakpoint.getHitCountFilteringStyle()) {
-                case MULTIPLE:
-                    if ((hitCount % hitCountFilter) != 0) {
-                        return false;
-                    }
-                    break;
-                case EQUAL:
-                    if (hitCountFilter != hitCount) {
-                        return false;
-                    }
-                    hitCountFilter = 0;
-                    removeAllEventRequests();
-                    break;
-                case GREATER:
-                    if (hitCount <= hitCountFilter) {
-                        return false;
-                    }
-                    break;
-                default:
-                    throw new 
IllegalStateException(getBreakpoint().getHitCountFilteringStyle().name());
-            }
-        }
         return processCondition(event, null, null, null);
     }
 

[hg] main-silver: #214416: Compute the hit counts manually for f...

mentlicher 12/01/2012

Project Features

About this Project

Debugger was started in November 2009, is owned by tpavek, and has 29 members.
By use of this website, you agree to the NetBeans Policies and Terms of Use (revision 20131025.e7cbc9d). © 2013, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo
 
 
Close
loading
Please Confirm
Close