Index: apichanges.xml =================================================================== RCS file: /cvs/debuggerjpda/api/apichanges.xml,v retrieving revision 1.21 diff -u -r1.21 apichanges.xml --- apichanges.xml 13 Apr 2007 14:59:28 -0000 1.21 +++ apichanges.xml 14 May 2007 18:17:56 -0000 @@ -530,6 +530,65 @@ + + + Enhance JPDA breakpoints. + + + + + +

+ To catch-up with JDI capabilities and be able to implement new enhancements, +we need to add support for new breakpoint properties into the debugger JPDA API.
+These are mainly class and thread filters and hit counts. +

+

+ Added methods:
+ ExceptionBreakpoint.getClassFilters(), + ExceptionBreakpoint.setClassFilters(), + ExceptionBreakpoint.getClassExclusionFilters(), + ExceptionBreakpoint.setClassExclusionFilters(), + FieldBreakpoint.getInstanceFilters(), + FieldBreakpoint.setInstanceFilters(), + FieldBreakpoint.getThreadFilters(), + FieldBreakpoint.setThreadFilters(), + JPDABreakpoint.getHitCountFilter(), + JPDABreakpoint.getHitCountFilteringStyle(), + JPDABreakpoint.setHitCountFilter(), + LineBreakpoint.getInstanceFilters(), + LineBreakpoint.setInstanceFilters(), + LineBreakpoint.getThreadFilters(), + LineBreakpoint.setThreadFilters(), + MethodBreakpoint.getMethodSignature(), + MethodBreakpoint.setMethodSignature(), + MethodBreakpoint.getInstanceFilters(), + MethodBreakpoint.setInstanceFilters(), + MethodBreakpoint.getThreadFilters(), + MethodBreakpoint.setThreadFilters(). +

+

+ Added fields:
+ ExceptionBreakpoint.PROP_CLASS_FILTERS, + ExceptionBreakpoint.PROP_CLASS_EXCLUSION_FILTERS, + FieldBreakpoint.PROP_INSTANCE_FILTERS, + FieldBreakpoint.PROP_THREAD_FILTERS, + JPDABreakpoint.PROP_HIT_COUNT_FILTER, + JPDABreakpoint.HIT_COUNT_FILTERING_STYLE, + LineBreakpoint.PROP_INSTANCE_FILTERS, + LineBreakpoint.PROP_THREAD_FILTERS, + MethodBreakpoint.PROP_METHOD_SIGNATURE, + MethodBreakpoint.PROP_INSTANCE_FILTERS, + MethodBreakpoint.PROP_THREAD_FILTERS. +

+
+ + + + + + +
Index: manifest.mf =================================================================== RCS file: /cvs/debuggerjpda/api/manifest.mf,v retrieving revision 1.22 diff -u -r1.22 manifest.mf --- manifest.mf 12 Apr 2007 09:35:05 -0000 1.22 +++ manifest.mf 14 May 2007 18:17:56 -0000 @@ -1,6 +1,6 @@ Manifest-Version: 1.0 OpenIDE-Module: org.netbeans.api.debugger.jpda/2 OpenIDE-Module-Localizing-Bundle: org/netbeans/api/debugger/jpda/Bundle.properties -OpenIDE-Module-Specification-Version: 2.11 +OpenIDE-Module-Specification-Version: 2.13 OpenIDE-Module-Package-Dependencies: com.sun.jdi[VirtualMachineManager] Index: src/org/netbeans/api/debugger/jpda/ExceptionBreakpoint.java =================================================================== RCS file: /cvs/debuggerjpda/api/src/org/netbeans/api/debugger/jpda/ExceptionBreakpoint.java,v retrieving revision 1.4 diff -u -r1.4 ExceptionBreakpoint.java --- src/org/netbeans/api/debugger/jpda/ExceptionBreakpoint.java 30 Jun 2006 19:04:46 -0000 1.4 +++ src/org/netbeans/api/debugger/jpda/ExceptionBreakpoint.java 14 May 2007 18:17:56 -0000 @@ -13,7 +13,7 @@ * "Portions Copyrighted [year] [name of copyright owner]" * * The Original Software is NetBeans. The Initial Developer of the Original - * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun + * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun * Microsystems, Inc. All Rights Reserved. */ @@ -38,6 +38,10 @@ /** Property name constant */ public static final String PROP_EXCEPTION_CLASS_NAME = "exceptionClassName"; // NOI18N + /** Property name constant */ + public static final String PROP_CLASS_FILTERS = "classFilters"; // NOI18N + /** Property name constant */ + public static final String PROP_CLASS_EXCLUSION_FILTERS = "classExclusionFilters"; // NOI18N /** Property name constant. */ public static final String PROP_CATCH_TYPE = "catchType"; // NOI18N /** Property name constant. */ @@ -51,6 +55,8 @@ public static final int TYPE_EXCEPTION_CATCHED_UNCATCHED = 3; private String exceptionClassName = ""; + private String[] classFilters = new String [0]; + private String[] classExclusionFilters = new String [0]; private int catchType = TYPE_EXCEPTION_UNCATCHED; private String condition = ""; // NOI18N @@ -100,6 +106,48 @@ Object old = exceptionClassName; exceptionClassName = cn; firePropertyChange (PROP_EXCEPTION_CLASS_NAME, old, exceptionClassName); + } + + /** + * Get list of class filters to stop on. + * + * @return list of class filters to stop on + */ + public String[] getClassFilters () { + return classFilters; + } + + /** + * Set list of class filters to stop on. + * + * @param classFilters a new value of class filters property + */ + public void setClassFilters (String[] classFilters) { + if (classFilters == this.classFilters) return; + Object old = this.classFilters; + this.classFilters = classFilters; + firePropertyChange (PROP_CLASS_FILTERS, old, classFilters); + } + + /** + * Get list of class exclusion filters to stop on. + * + * @return list of class exclusion filters to stop on + */ + public String[] getClassExclusionFilters () { + return classExclusionFilters; + } + + /** + * Set list of class exclusion filters to stop on. + * + * @param classExclusionFilters a new value of class exclusion filters property + */ + public void setClassExclusionFilters (String[] classExclusionFilters) { + if (classExclusionFilters == this.classExclusionFilters) return; + Object old = this.classExclusionFilters; + this.classExclusionFilters = classExclusionFilters; + firePropertyChange (PROP_CLASS_EXCLUSION_FILTERS, old, classExclusionFilters); } /** Index: src/org/netbeans/api/debugger/jpda/FieldBreakpoint.java =================================================================== RCS file: /cvs/debuggerjpda/api/src/org/netbeans/api/debugger/jpda/FieldBreakpoint.java,v retrieving revision 1.5 diff -u -r1.5 FieldBreakpoint.java --- src/org/netbeans/api/debugger/jpda/FieldBreakpoint.java 2 Mar 2007 15:10:17 -0000 1.5 +++ src/org/netbeans/api/debugger/jpda/FieldBreakpoint.java 14 May 2007 18:17:56 -0000 @@ -13,12 +13,14 @@ * "Portions Copyrighted [year] [name of copyright owner]" * * The Original Software is NetBeans. The Initial Developer of the Original - * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun + * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun * Microsystems, Inc. All Rights Reserved. */ package org.netbeans.api.debugger.jpda; +import java.util.Map; +import java.util.WeakHashMap; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; import org.netbeans.api.debugger.Breakpoint; @@ -48,6 +50,10 @@ public static final String PROP_CONDITION = "condition"; // NOI18N /** Property name constant. */ public static final String PROP_BREAKPOINT_TYPE = "breakpointType"; // NOI18N + /** Property name constant */ + public static final String PROP_INSTANCE_FILTERS = "instanceFilters"; // NOI18N + /** Property name constant */ + public static final String PROP_THREAD_FILTERS = "threadFilters"; // NOI18N /** Property type value constant. */ public static final int TYPE_ACCESS = 1; @@ -58,6 +64,8 @@ private String fieldName = ""; private int type = TYPE_MODIFICATION; private String condition = ""; // NOI18N + private Map instanceFilters; + private Map threadFilters; private FieldBreakpoint () { @@ -134,6 +142,70 @@ String old = fieldName; fieldName = name; firePropertyChange (PROP_FIELD_NAME, old, fieldName); + } + + /** + * Get the instance filter for a specific debugger session. + * @return The instances or null when there is no instance restriction. + */ + public ObjectVariable[] getInstanceFilters(JPDADebugger session) { + if (instanceFilters != null) { + return instanceFilters.get(session); + } else { + return null; + } + } + + /** + * Set the instance filter for a specific debugger session. This restricts + * the breakpoint to specific instances in that session. + * @param session the debugger session + * @param instances the object instances or null to unset the filter. + */ + public void setInstanceFilters(JPDADebugger session, ObjectVariable[] instances) { + if (instanceFilters == null) { + instanceFilters = new WeakHashMap(); + } + if (instances != null) { + instanceFilters.put(session, instances); + } else { + instanceFilters.remove(session); + } + firePropertyChange(PROP_INSTANCE_FILTERS, null, + instances != null ? + new Object[] { session, instances } : null); + } + + /** + * Get the thread filter for a specific debugger session. + * @return The thread or null when there is no thread restriction. + */ + public JPDAThread[] getThreadFilters(JPDADebugger session) { + if (threadFilters != null) { + return threadFilters.get(session); + } else { + return null; + } + } + + /** + * Set the thread filter for a specific debugger session. This restricts + * the breakpoint to specific threads in that session. + * @param session the debugger session + * @param threads the threads or null to unset the filter. + */ + public void setThreadFilters(JPDADebugger session, JPDAThread[] threads) { + if (threadFilters == null) { + threadFilters = new WeakHashMap(); + } + if (threads != null) { + threadFilters.put(session, threads); + } else { + threadFilters.remove(session); + } + firePropertyChange(PROP_THREAD_FILTERS, null, + threads != null ? + new Object[] { session, threads } : null); } /** Index: src/org/netbeans/api/debugger/jpda/JPDABreakpoint.java =================================================================== RCS file: /cvs/debuggerjpda/api/src/org/netbeans/api/debugger/jpda/JPDABreakpoint.java,v retrieving revision 1.11 diff -u -r1.11 JPDABreakpoint.java --- src/org/netbeans/api/debugger/jpda/JPDABreakpoint.java 4 Aug 2006 14:18:22 -0000 1.11 +++ src/org/netbeans/api/debugger/jpda/JPDABreakpoint.java 14 May 2007 18:17:57 -0000 @@ -13,7 +13,7 @@ * "Portions Copyrighted [year] [name of copyright owner]" * * The Original Software is NetBeans. The Initial Developer of the Original - * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun + * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun * Microsystems, Inc. All Rights Reserved. */ @@ -44,6 +44,8 @@ public static final String PROP_HIDDEN = "hidden"; // NOI18N /** Property name constant. */ public static final String PROP_PRINT_TEXT = "printText"; // NOI18N + /** Property name constant. */ + public static final String PROP_HIT_COUNT_FILTER = "hitCountFilter"; // NOI18N /** Suspend property value constant. */ public static final int SUSPEND_ALL = EventRequest.SUSPEND_ALL; @@ -51,7 +53,8 @@ public static final int SUSPEND_EVENT_THREAD = EventRequest.SUSPEND_EVENT_THREAD; /** Suspend property value constant. */ public static final int SUSPEND_NONE = EventRequest.SUSPEND_NONE; - + + public static enum HIT_COUNT_FILTERING_STYLE { EQUAL, GREATER, MULTIPLE } // private variables ..................................................... @@ -60,6 +63,8 @@ private boolean hidden = false; private int suspend = SUSPEND_ALL; private String printText; + private int hitCountFilter; + private HIT_COUNT_FILTERING_STYLE hitCountFilteringStyle; private Collection breakpointListeners = new HashSet(); @@ -88,6 +93,39 @@ int old = suspend; suspend = s; firePropertyChange (PROP_SUSPEND, new Integer (old), new Integer (s)); + } + + /** + * Get the hit count filter. + * @return a positive hit count filter, or zero when no hit count filter is set. + */ + public int getHitCountFilter() { + return hitCountFilter; + } + + /** + * Get the style of hit count filtering. + * @return the style of hit count filtering, or null when no count filter is set. + */ + public HIT_COUNT_FILTERING_STYLE getHitCountFilteringStyle() { + return hitCountFilteringStyle; + } + + /** + * Set the hit count filter and the style of filtering. + * @param hitCountFilter a positive hit count filter, or zero to unset the filter. + * @param hitCountFilteringStyle the style of hit count filtering. + */ + public void setHitCountFilter(int hitCountFilter, HIT_COUNT_FILTERING_STYLE hitCountFilteringStyle) { + if (hitCountFilter == this.hitCountFilter && hitCountFilteringStyle == this.hitCountFilteringStyle) { + return ; + } + if (hitCountFilteringStyle == null && hitCountFilter > 0) { + throw new NullPointerException("hitCountFilteringStyle must not be null."); + } + this.hitCountFilter = hitCountFilter; + this.hitCountFilteringStyle = hitCountFilteringStyle; + firePropertyChange(PROP_HIT_COUNT_FILTER, null, new Object[] { hitCountFilter, hitCountFilteringStyle }); } /** Index: src/org/netbeans/api/debugger/jpda/LineBreakpoint.java =================================================================== RCS file: /cvs/debuggerjpda/api/src/org/netbeans/api/debugger/jpda/LineBreakpoint.java,v retrieving revision 1.19 diff -u -r1.19 LineBreakpoint.java --- src/org/netbeans/api/debugger/jpda/LineBreakpoint.java 2 Mar 2007 15:10:17 -0000 1.19 +++ src/org/netbeans/api/debugger/jpda/LineBreakpoint.java 14 May 2007 18:17:58 -0000 @@ -13,7 +13,7 @@ * "Portions Copyrighted [year] [name of copyright owner]" * * The Original Software is NetBeans. The Initial Developer of the Original - * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun + * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun * Microsystems, Inc. All Rights Reserved. */ @@ -21,6 +21,8 @@ import java.net.MalformedURLException; import java.net.URL; +import java.util.Map; +import java.util.WeakHashMap; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; import org.netbeans.api.debugger.Breakpoint; @@ -66,6 +68,10 @@ public static final String PROP_STRATUM = "stratum"; // NOI18N /** Property name constant. */ public static final String PROP_PREFERRED_CLASS_NAME = "classNamePreferred"; // NOI18N + /** Property name constant */ + public static final String PROP_INSTANCE_FILTERS = "instanceFilters"; // NOI18N + /** Property name constant */ + public static final String PROP_THREAD_FILTERS = "threadFilters"; // NOI18N private String url = ""; // NOI18N private int lineNumber; @@ -74,6 +80,8 @@ private String sourcePath = null; private String stratum = "Java"; // NOI18N private String className = null; + private Map instanceFilters; + private Map threadFilters; private LineBreakpoint (String url) { @@ -153,6 +161,70 @@ ); } + /** + * Get the instance filter for a specific debugger session. + * @return The instances or null when there is no instance restriction. + */ + public ObjectVariable[] getInstanceFilters(JPDADebugger session) { + if (instanceFilters != null) { + return instanceFilters.get(session); + } else { + return null; + } + } + + /** + * Set the instance filter for a specific debugger session. This restricts + * the breakpoint to specific instances in that session. + * @param session the debugger session + * @param instances the object instances or null to unset the filter. + */ + public void setInstanceFilters(JPDADebugger session, ObjectVariable[] instances) { + if (instanceFilters == null) { + instanceFilters = new WeakHashMap(); + } + if (instances != null) { + instanceFilters.put(session, instances); + } else { + instanceFilters.remove(session); + } + firePropertyChange(PROP_INSTANCE_FILTERS, null, + instances != null ? + new Object[] { session, instances } : null); + } + + /** + * Get the thread filter for a specific debugger session. + * @return The thread or null when there is no thread restriction. + */ + public JPDAThread[] getThreadFilters(JPDADebugger session) { + if (threadFilters != null) { + return threadFilters.get(session); + } else { + return null; + } + } + + /** + * Set the thread filter for a specific debugger session. This restricts + * the breakpoint to specific threads in that session. + * @param session the debugger session + * @param threads the threads or null to unset the filter. + */ + public void setThreadFilters(JPDADebugger session, JPDAThread[] threads) { + if (threadFilters == null) { + threadFilters = new WeakHashMap(); + } + if (threads != null) { + threadFilters.put(session, threads); + } else { + threadFilters.remove(session); + } + firePropertyChange(PROP_THREAD_FILTERS, null, + threads != null ? + new Object[] { session, threads } : null); + } + /** * Returns condition. * Index: src/org/netbeans/api/debugger/jpda/MethodBreakpoint.java =================================================================== RCS file: /cvs/debuggerjpda/api/src/org/netbeans/api/debugger/jpda/MethodBreakpoint.java,v retrieving revision 1.9 diff -u -r1.9 MethodBreakpoint.java --- src/org/netbeans/api/debugger/jpda/MethodBreakpoint.java 2 Mar 2007 15:10:18 -0000 1.9 +++ src/org/netbeans/api/debugger/jpda/MethodBreakpoint.java 14 May 2007 18:17:59 -0000 @@ -13,12 +13,14 @@ * "Portions Copyrighted [year] [name of copyright owner]" * * The Original Software is NetBeans. The Initial Developer of the Original - * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun + * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun * Microsystems, Inc. All Rights Reserved. */ package org.netbeans.api.debugger.jpda; +import java.util.Map; +import java.util.WeakHashMap; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; import org.netbeans.api.debugger.Breakpoint; @@ -42,6 +44,8 @@ /** Property name constant */ public static final String PROP_METHOD_NAME = "methodName"; // NOI18N + /** Property name constant */ + public static final String PROP_METHOD_SIGNATURE = "signature"; // NOI18N /** Property name constant. */ public static final String PROP_BREAKPOINT_TYPE = "breakpointtType"; // NOI18N /** Property name constant. */ @@ -50,6 +54,10 @@ public static final String PROP_CLASS_FILTERS = "classFilters"; // NOI18N /** Property name constant */ public static final String PROP_CLASS_EXCLUSION_FILTERS = "classExclusionFilters"; // NOI18N + /** Property name constant */ + public static final String PROP_INSTANCE_FILTERS = "instanceFilters"; // NOI18N + /** Property name constant */ + public static final String PROP_THREAD_FILTERS = "threadFilters"; // NOI18N /** Breakpoint type property value constant. */ public static final int TYPE_METHOD_ENTRY = 1; @@ -60,8 +68,11 @@ private String[] classFilters = new String [0]; private String[] classExclusionFilters = new String [0]; private String methodName = ""; + private String methodSignature; private int breakpointType = TYPE_METHOD_ENTRY; private String condition = ""; + private Map instanceFilters; + private Map threadFilters; private MethodBreakpoint () { @@ -122,6 +133,36 @@ } /** + * Get the JNI-style signature of the method to stop on. + * + * @return JNI-style signature of the method to stop on + * @see com.sun.jdi.TypeComponent#signature + */ + public String getMethodSignature () { + return methodSignature; + } + + /** + * Set JNI-style signature of the method to stop on. + * + * @param signature the JNI-style signature of the method to stop on + * @see com.sun.jdi.TypeComponent#signature + */ + public void setMethodSignature (String signature) { + if (signature != null) { + signature = signature.trim(); + } + if ((signature == methodSignature) || + ((signature != null) && signature.equals (methodSignature))) { + + return; + } + String old = methodSignature; + methodSignature = signature; + firePropertyChange (PROP_METHOD_SIGNATURE, old, signature); + } + + /** * Returns condition. * * @return cond a condition @@ -208,6 +249,70 @@ this.classExclusionFilters = classExclusionFilters; firePropertyChange (PROP_CLASS_EXCLUSION_FILTERS, old, classExclusionFilters); } + + /** + * Get the instance filter for a specific debugger session. + * @return The instances or null when there is no instance restriction. + */ + public ObjectVariable[] getInstanceFilters(JPDADebugger session) { + if (instanceFilters != null) { + return instanceFilters.get(session); + } else { + return null; + } + } + + /** + * Set the instance filter for a specific debugger session. This restricts + * the breakpoint to specific instances in that session. + * @param session the debugger session + * @param instances the object instances or null to unset the filter. + */ + public void setInstanceFilters(JPDADebugger session, ObjectVariable[] instances) { + if (instanceFilters == null) { + instanceFilters = new WeakHashMap(); + } + if (instances != null) { + instanceFilters.put(session, instances); + } else { + instanceFilters.remove(session); + } + firePropertyChange(PROP_INSTANCE_FILTERS, null, + instances != null ? + new Object[] { session, instances } : null); + } + + /** + * Get the thread filter for a specific debugger session. + * @return The thread or null when there is no thread restriction. + */ + public JPDAThread[] getThreadFilters(JPDADebugger session) { + if (threadFilters != null) { + return threadFilters.get(session); + } else { + return null; + } + } + + /** + * Set the thread filter for a specific debugger session. This restricts + * the breakpoint to specific threads in that session. + * @param session the debugger session + * @param threads the threads or null to unset the filter. + */ + public void setThreadFilters(JPDADebugger session, JPDAThread[] threads) { + if (threadFilters == null) { + threadFilters = new WeakHashMap(); + } + if (threads != null) { + threadFilters.put(session, threads); + } else { + threadFilters.remove(session); + } + firePropertyChange(PROP_THREAD_FILTERS, null, + threads != null ? + new Object[] { session, threads } : null); + } /** * Returns a string representation of this object. @@ -215,7 +320,8 @@ * @return a string representation of the object */ public String toString () { - return "MethodBreakpoint " + java.util.Arrays.asList(classFilters).toString() + "." + methodName; + return "MethodBreakpoint " + java.util.Arrays.asList(classFilters).toString() + "." + methodName + + ((methodSignature != null) ? " '"+methodSignature+"'" : ""); } private static final class MethodBreakpointImpl extends MethodBreakpoint implements ChangeListener {