classpath-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[cp-patches] [PATCH/JDWP] Event filters


From: Keith Seitz
Subject: [cp-patches] [PATCH/JDWP] Event filters
Date: Fri, 26 Aug 2005 14:52:51 -0700
User-agent: Mozilla Thunderbird 1.0.6-1.1.fc4 (X11/20050720)

Hi,

I've committed the attached mega-patch which defines all the event "filters". Not all of them are implemented and some of them probably never will be (those associated with stepping, for example).

In these cases "filter" is a bit of a misnomer. Some of the filters are passive -- they're for setting up the appropriate notification conditions.

Nonetheless, this is how JDWP classifies/groups these things, so I've kept it the same. Any filter can be queried for its conditions.

Keith

ChangeLog
2005-08-26  Keith Seitz  <address@hidden>

        * gnu/classpath/jdwp/event/filters/IEventFilter.java: New file.
        Describes the interface used for event filtering managed by
        the event manager.
        * gnu/classpath/jdwp/event/filters/ClassExcludeFilter.java: New
        file.
        * gnu/classpath/jdwp/event/filters/ClassMatchFilter.java: New
        file.
        * gnu/classpath/jdwp/event/filters/ClassOnlyFilter.java: New
        file.
        * gnu/classpath/jdwp/event/filters/ConditionalFilter.java: New
        file.
        * gnu/classpath/jdwp/event/filters/CountFilter.java: New file.
        * gnu/classpath/jdwp/event/filters/ExceptionOnlyFilter.java: New
         file.
        * gnu/classpath/jdwp/event/filters/FieldOnlyFilter.java: New
        file.
        * gnu/classpath/jdwp/event/filters/InstanceOnlyFilter.java: New
        file.
        * gnu/classpath/jdwp/event/filters/LocationOnlyFilter.java: New
        file.
        * gnu/classpath/jdwp/event/filters/StepFilter.java: New file.
        * gnu/classpath/jdwp/event/filters/ThreadOnlyFilter.java: New
        file.
Index: gnu/classpath/jdwp/event/filters/ClassExcludeFilter.java
===================================================================
RCS file: gnu/classpath/jdwp/event/filters/ClassExcludeFilter.java
diff -N gnu/classpath/jdwp/event/filters/ClassExcludeFilter.java
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ gnu/classpath/jdwp/event/filters/ClassExcludeFilter.java    26 Aug 2005 
21:45:22 -0000
@@ -0,0 +1,75 @@
+/* ClassExcludeFilter.java -- filter on class name (exclusive)
+   Copyright (C) 2005 Free Software Foundation
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.classpath.jdwp.event.filters;
+
+import gnu.classpath.jdwp.event.Event;
+import gnu.classpath.jdwp.exception.InvalidStringException;
+
+/**
+ * An event filter which excludes events matching a 
+ * specified class pattern (exact match or start/end with "*").
+ *
+ * @author Keith Seitz  (address@hidden)
+ */
+public class ClassExcludeFilter
+  extends ClassMatchFilter
+{
+  /**
+   * Constructs a new <code>ClassExcludeFilter</code>
+   *
+   * @param  pattern  the pattern to use
+   * @throws InvalidStringException  if pattern is invalid
+   */
+  public ClassExcludeFilter (String pattern)
+    throws InvalidStringException
+  {
+    super (pattern);
+  }
+
+  /**
+   * Does the given event match the filter?
+   *
+   * @param event  the <code>Event</code> to scrutinize
+   */
+  public boolean matches (Event event)
+  {
+    return !super.matches (event);
+  }
+}
Index: gnu/classpath/jdwp/event/filters/ClassMatchFilter.java
===================================================================
RCS file: gnu/classpath/jdwp/event/filters/ClassMatchFilter.java
diff -N gnu/classpath/jdwp/event/filters/ClassMatchFilter.java
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ gnu/classpath/jdwp/event/filters/ClassMatchFilter.java      26 Aug 2005 
21:45:22 -0000
@@ -0,0 +1,122 @@
+/* ClassMatchFilter.java -- filter on class name (inclusive)
+   Copyright (C) 2005 Free Software Foundation
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.classpath.jdwp.event.filters;
+
+import gnu.classpath.jdwp.event.Event;
+import gnu.classpath.jdwp.exception.InvalidStringException;
+import gnu.classpath.jdwp.exception.InvalidClassException;
+import gnu.classpath.jdwp.id.ReferenceTypeId;
+
+/**
+ * An event filter which includes events matching a 
+ * specified class pattern (exact match or start/end with "*").
+ *
+ * @author Keith Seitz  (address@hidden)
+ */
+public class ClassMatchFilter
+  implements IEventFilter
+{
+  // Pattern to match
+  private String _pattern;
+
+  /**
+   * Constructs a new <code>ClassMatchFilter</code>
+   *
+   * @param  pattern  the pattern to use
+   * @throws InvalidStringException  if pattern is invalid
+   */
+  public ClassMatchFilter (String pattern)
+    throws InvalidStringException
+  {
+    int index = pattern.indexOf ('*');
+    if (index != -1 && index != 0 && index != (pattern.length () - 1))
+      {
+       // '*' must be first char or last char
+       throw new InvalidStringException ("pattern may be an exact match or "
+                                         + "start/end with \"*\"");
+      }
+    _pattern = pattern;
+  }
+
+  /**
+   * Returns the pattern to be matched
+   *
+   * @return the pattern
+   */
+  public String getPattern ()
+  {
+    return _pattern;
+  }
+
+  /**
+   * Does the given event match the filter?
+   *
+   * @param event  the <code>Event</code> to scrutinize
+   */
+  public boolean matches (Event event)
+  {
+    Object type = event.getParameter (ReferenceTypeId.class);
+    if (type != null)
+      {
+       try
+         {
+           Class eventClass = (Class) type;
+           String name = eventClass.getName ();
+
+           if (_pattern.startsWith ("*"))
+             return name.endsWith (_pattern.substring (1));
+           else if (_pattern.endsWith ("*"))
+             {
+               int end = _pattern.length () - 1;
+               return name.startsWith (_pattern.substring (0, end));
+             }
+           else
+             return name.matches (_pattern);
+         }
+       catch (InvalidClassException ice)
+         {
+           // the class is no longer valid
+           return false;
+         }
+      }
+
+    return false;
+  }
+}
Index: gnu/classpath/jdwp/event/filters/ClassOnlyFilter.java
===================================================================
RCS file: gnu/classpath/jdwp/event/filters/ClassOnlyFilter.java
diff -N gnu/classpath/jdwp/event/filters/ClassOnlyFilter.java
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ gnu/classpath/jdwp/event/filters/ClassOnlyFilter.java       26 Aug 2005 
21:45:22 -0000
@@ -0,0 +1,109 @@
+/* ClassOnlyFilter.java -- filter on specific class
+   Copyright (C) 2005 Free Software Foundation
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.classpath.jdwp.event.filters;
+
+import gnu.classpath.jdwp.event.Event;
+import gnu.classpath.jdwp.exception.InvalidClassException;
+import gnu.classpath.jdwp.id.ReferenceTypeId;
+
+/**
+ * An event filter which filters out events in uninteresting
+ * classes.
+ *
+ * @author Keith Seitz  (address@hidden)
+ */
+public class ClassOnlyFilter
+  implements IEventFilter
+{
+  // Class ID for which to filter
+  private ReferenceTypeId _id;
+
+  /**
+   * Constructs a new <code>ClassOnlyFilter</code>
+   *
+   * @param refId  the reference type id for a class for which events
+   *               will be reported
+   * @throws InvalidClassException if the ID is no longer valid
+   */
+  public ClassOnlyFilter (ReferenceTypeId refId)
+    throws InvalidClassException
+  {
+    // validity check
+    refId.getType ();
+    _id = refId;
+  }
+
+  /**
+   * Returns the class to which to restrict events
+   *
+   * @return the class's ID
+   */
+  public ReferenceTypeId getType ()
+  {
+    return _id;
+  }
+
+  /**
+   * Does the given event match the filter?
+   *
+   * @param event  the <code>Event</code> to scrutinize
+   */
+  public boolean matches (Event event)
+  {
+    Object type = event.getParameter (ReferenceTypeId.class);
+    if (type != null)
+      {
+       try
+         {
+           Class clazz = _id.getType ();
+           Class eventClass = (Class) type;
+           if (clazz.isAssignableFrom (eventClass))
+             return true;
+         }
+       catch (InvalidClassException ice)
+         {
+           // class is no longer valid
+           return false;
+         }
+      }
+
+    return false;
+  }
+}
Index: gnu/classpath/jdwp/event/filters/ConditionalFilter.java
===================================================================
RCS file: gnu/classpath/jdwp/event/filters/ConditionalFilter.java
diff -N gnu/classpath/jdwp/event/filters/ConditionalFilter.java
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ gnu/classpath/jdwp/event/filters/ConditionalFilter.java     26 Aug 2005 
21:45:22 -0000
@@ -0,0 +1,82 @@
+/* ConditionalFilter.java -- conditional expression filter
+   Copyright (C) 2005 Free Software Foundation
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.classpath.jdwp.event.filters;
+
+import gnu.classpath.jdwp.event.Event;
+import gnu.classpath.jdwp.exception.NotImplementedException;
+
+/**
+ * An event filter which allows expression conditionals.
+ * Note that in JDWP 1.4, this class is marked "for the
+ * future".
+ *
+ * @author Keith Seitz  (address@hidden)
+ */
+public class ConditionalFilter
+  implements IEventFilter
+{
+  // private ConditionalId _exprId;
+
+  /**
+   * Constructs a new <code>ConditionalFilter</code> with the
+   * given conditional.
+   *
+   * <p><b>NOTE:</b> This filter is marked "for the future",
+   * i.e, there is no way to actually use this yet.
+   *
+   * @param  cond  the conditional expression
+   * @throws NotImplementedException if used
+   */
+  public ConditionalFilter (Object conditional)
+    throws NotImplementedException
+  {
+    throw new NotImplementedException ("conditional filters");
+  }
+
+  /**
+   * Does the given event match the filter?
+   *
+   * @param event  the <code>Event</code> to scrutinize
+   */
+  public boolean matches (Event event)
+  {
+    return false;
+  }
+}
Index: gnu/classpath/jdwp/event/filters/CountFilter.java
===================================================================
RCS file: gnu/classpath/jdwp/event/filters/CountFilter.java
diff -N gnu/classpath/jdwp/event/filters/CountFilter.java
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ gnu/classpath/jdwp/event/filters/CountFilter.java   26 Aug 2005 21:45:22 
-0000
@@ -0,0 +1,95 @@
+/* CountFilter.java -- a step filter
+   Copyright (C) 2005 Free Software Foundation
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.classpath.jdwp.event.filters;
+
+import gnu.classpath.jdwp.event.Event;
+import gnu.classpath.jdwp.exception.InvalidCountException;
+
+/**
+ * An ignore count filter.
+ *
+ * @author Keith Seitz  (address@hidden)
+ */
+public class CountFilter
+  implements IEventFilter
+{
+  // the count
+  private int _count;
+
+  /**
+   * Constructs a new <code>CountFilter</code> with the given count.
+   *
+   * @param  count  the number of times the event will be ignored
+   * @throws InvalidCountException if count is invalid (< 1)
+   */
+  public CountFilter (int count)
+    throws InvalidCountException
+  {
+    // Check for valid count
+    if (count < 1)
+      throw new InvalidCountException (count);
+
+    _count = count;
+  }
+
+  /**
+   * Returns the ignore count
+   *
+   * @return the number of times the event should be ignored
+   */
+  public int getCount ()
+  {
+    return _count;
+  }
+
+  /**
+   * Does the given event match the filter?
+   *
+   * @param event  the <code>Event</code> to scrutinize
+   */
+  public boolean matches (Event event)
+  {
+    // This filter only relies on its count
+    if (--_count == 0)
+      return true;
+
+    return false;
+  }
+}
Index: gnu/classpath/jdwp/event/filters/ExceptionOnlyFilter.java
===================================================================
RCS file: gnu/classpath/jdwp/event/filters/ExceptionOnlyFilter.java
diff -N gnu/classpath/jdwp/event/filters/ExceptionOnlyFilter.java
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ gnu/classpath/jdwp/event/filters/ExceptionOnlyFilter.java   26 Aug 2005 
21:45:22 -0000
@@ -0,0 +1,121 @@
+/* ExceptionOnlyFilter.java -- 
+   Copyright (C) 2005 Free Software Foundation
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.classpath.jdwp.event.filters;
+
+import gnu.classpath.jdwp.event.Event;
+import gnu.classpath.jdwp.exception.InvalidClassException;
+import gnu.classpath.jdwp.id.ReferenceTypeId;
+
+/**
+ * Restricts reported exceptions by their class and whether they are caught
+ * or uncaught.
+ * 
+ * This modifier can be used with exception event kinds only.
+ *
+ * @author Keith Seitz  (address@hidden)
+ */
+public class ExceptionOnlyFilter
+  implements IEventFilter
+{
+  private ReferenceTypeId _refId;
+  private boolean _caught;
+  private boolean _uncaught;
+
+  /**
+   * Constructs a new <code>ExceptionOnlyFilter</code>
+   *
+   * @param  refid
+   * @param  caught
+   * @param  uncaught
+   * @throws InvalidClassException if refid is invalid
+   */
+  public ExceptionOnlyFilter (ReferenceTypeId refId, boolean caught,
+                             boolean uncaught)
+    throws InvalidClassException
+  {
+    if (refId == null || refId.getReference().get () == null)
+      throw new InvalidClassException (refId.getId ());
+
+    _refId = refId;
+    _caught = caught;
+    _uncaught = uncaught;
+  }
+
+  /**
+   * Returns the exception class to report (<code>null</code> for all)
+   *
+   * @return the class's ID
+   */
+  public ReferenceTypeId getType ()
+  {
+    return _refId;
+  }
+
+  /**
+   * Report caught exceptions?
+   *
+   * @return whether to report caught exceptions
+   */
+  public boolean forCaught ()
+  {
+    return _caught;
+  }
+
+  /**
+   * Report uncaught exceptions?
+   *
+   * @return whether to report uncaught exceptions
+   */
+  public boolean forUncaught ()
+  {
+    return _uncaught;
+  }
+
+  /**
+   * Does the given event match the filter?
+   *
+   * @param event  the <code>Event</code> to scrutinize
+   */
+  public boolean matches (Event event)
+  {
+    // FIXME
+    throw new RuntimeException ("ExceptionOnlyFilter.matches not implemented");
+  }
+}
Index: gnu/classpath/jdwp/event/filters/FieldOnlyFilter.java
===================================================================
RCS file: gnu/classpath/jdwp/event/filters/FieldOnlyFilter.java
diff -N gnu/classpath/jdwp/event/filters/FieldOnlyFilter.java
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ gnu/classpath/jdwp/event/filters/FieldOnlyFilter.java       26 Aug 2005 
21:45:22 -0000
@@ -0,0 +1,112 @@
+/* FieldOnlyFilter.java -- filter on field
+   Copyright (C) 2005 Free Software Foundation
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.classpath.jdwp.event.filters;
+
+import gnu.classpath.jdwp.event.Event;
+import gnu.classpath.jdwp.exception.InvalidClassException;
+import gnu.classpath.jdwp.exception.InvalidFieldException;
+import gnu.classpath.jdwp.id.ReferenceTypeId;
+
+/**
+ * Restricts reported events to those that occur for a given field.
+ * 
+ * This modifier can be used with field access and field modification event
+ * kinds only.
+ *
+ * @author Keith Seitz  (address@hidden)
+ */
+public class FieldOnlyFilter
+  implements IEventFilter
+{
+  private ReferenceTypeId _refId;
+  private ReferenceTypeId _fieldId;
+
+  /**
+   * Constructs a new <code>FieldOnlyFilter</code>.
+   *
+   * @param  refId  class for field
+   * @param  fid    field
+   * @throws InvalidClassException if class is invalid
+   * @throws InvalidFieldExcpetion if field is invalid
+   */
+  public FieldOnlyFilter (ReferenceTypeId refId, /*Field*/ReferenceTypeId fid)
+    throws InvalidClassException, InvalidFieldException
+  {
+    if (refId == null || refId.getReference().get () == null)
+      throw new InvalidClassException (refId.getId ());
+
+    if (fid == null)
+      throw new InvalidFieldException (fid.getId ());
+
+    _refId = refId;
+    _fieldId = fid;
+  }
+
+  /**
+   * Returns the class in which the field is declared 
+   *
+   * @return the class's id
+   */
+  public ReferenceTypeId getType ()
+  {
+    return _refId;
+  }
+
+  /**
+   * Returns the field for which to restrict events
+   *
+   * @return the field's id
+   */
+  public ReferenceTypeId getField ()
+  {
+    return _fieldId;
+  }
+
+  /**
+   * Does the given event match the filter?
+   *
+   * @param event  the <code>Event</code> to scrutinize
+   */
+  public boolean matches (Event event)
+  {
+    // FIXME
+    throw new RuntimeException ("FieldOnlyFilter.matches not implemented");
+  }
+}
Index: gnu/classpath/jdwp/event/filters/IEventFilter.java
===================================================================
RCS file: gnu/classpath/jdwp/event/filters/IEventFilter.java
diff -N gnu/classpath/jdwp/event/filters/IEventFilter.java
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ gnu/classpath/jdwp/event/filters/IEventFilter.java  26 Aug 2005 21:45:22 
-0000
@@ -0,0 +1,65 @@
+/* IEventFilter.java -- an interface for event filters
+   Copyright (C) 2005 Free Software Foundation
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.classpath.jdwp.event.filters;
+
+import gnu.classpath.jdwp.event.Event;
+
+/**
+ * An interface for event filters. The debugger registers an event
+ * filter for a given event when it is interested in receiving
+ * notifications about that event from the VM.
+ *
+ * <p>Filters are attached to address@hidden 
gnu.classpath.jdwp.event.EventRequest}s
+ * in order to allow the debugger to specify that an event should be sent
+ * only when the filters for the event request all match.
+ *
+ * <p>No filters means "send all notifications".
+ *
+ * @author Keith Seitz  (address@hidden)
+ */
+public interface IEventFilter
+{
+  /**
+   * Does the given event match the filter?
+   *
+   * @param event  the <code>Event</code> to scrutinize
+   */
+  public boolean matches (Event event);
+}
Index: gnu/classpath/jdwp/event/filters/InstanceOnlyFilter.java
===================================================================
RCS file: gnu/classpath/jdwp/event/filters/InstanceOnlyFilter.java
diff -N gnu/classpath/jdwp/event/filters/InstanceOnlyFilter.java
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ gnu/classpath/jdwp/event/filters/InstanceOnlyFilter.java    26 Aug 2005 
21:45:22 -0000
@@ -0,0 +1,101 @@
+/* InstanceOnlyFilter.java -- filter on instance
+   Copyright (C) 2005 Free Software Foundation
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.classpath.jdwp.event.filters;
+
+import gnu.classpath.jdwp.event.Event;
+import gnu.classpath.jdwp.exception.InvalidObjectException;
+import gnu.classpath.jdwp.id.ObjectId;
+
+/**
+ * Restricts reported events to those whose active 'this' object is the
+ * given object. Match value is the null object for static methods.
+ * 
+ * This modifier can be used with any event kind except class prepare,
+ * class unload, thread start, and thread end. Introduced in JDWP version 1.4.
+ *
+ * @author Keith Seitz  (address@hidden)
+ */
+public class InstanceOnlyFilter
+  implements IEventFilter
+{
+  private ObjectId _instance;
+
+  /**
+   * Constructs a new <code>InstanceOnlyFilter</code>.
+   *
+   * @param  oid  the object to which to restrict events (may be null)
+   * @throws InvalidObjectException if Object is invalid
+   */
+  public InstanceOnlyFilter (ObjectId oid)
+    throws InvalidObjectException
+  {
+    if (oid != null && oid.getReference().get () == null)
+      throw new InvalidObjectException (oid.getId ());
+
+    _instance = oid;
+  }
+
+  /**
+   * Returns the instance to which to restrict events
+   *
+   * @return the object's ID
+   */
+  public ObjectId getInstance ()
+  {
+    return _instance;
+  }
+
+  /**
+   * Does the given event match the filter?
+   *
+   * @param event  the <code>Event</code> to scrutinize
+   */
+  public boolean matches (Event event)
+  {
+    Object eventInstance = event.getParameter (ObjectId.class);
+    if (eventInstance != null)
+      {
+       Object myInstance = _instance.getReference().get ();
+       return ((myInstance != null) && (myInstance == eventInstance));
+      }
+
+    return false;
+  }
+}
Index: gnu/classpath/jdwp/event/filters/LocationOnlyFilter.java
===================================================================
RCS file: gnu/classpath/jdwp/event/filters/LocationOnlyFilter.java
diff -N gnu/classpath/jdwp/event/filters/LocationOnlyFilter.java
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ gnu/classpath/jdwp/event/filters/LocationOnlyFilter.java    26 Aug 2005 
21:45:22 -0000
@@ -0,0 +1,91 @@
+/* LocationOnlyFilter.java -- filter on location
+   Copyright (C) 2005 Free Software Foundation
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.classpath.jdwp.event.filters;
+
+import gnu.classpath.jdwp.event.Event;
+import gnu.classpath.jdwp.exception.InvalidLocationException;
+import gnu.classpath.jdwp.util.Location;
+
+/**
+ * Restricts reported events to those that occur at the given location.
+ *
+ * May be used with breakpoint, field access, field modification, step,
+ * and exception event kinds.
+ *
+ * @author Keith Seitz  (address@hidden)
+ */
+public class LocationOnlyFilter
+  implements IEventFilter
+{
+  private Location _location;
+
+  /**
+   * Constructs a new <code>LocationOnlyFilter</code>.
+   *
+   * @param  loc  the location for which to report events
+   * @throws InvalidLocationException if location is invalid
+   */
+  public LocationOnlyFilter (Location loc)
+    throws InvalidLocationException
+  {
+    _location = loc;
+  }
+
+  /**
+   * Returns the location at which to restrict events
+   *
+   * @return the location
+   */
+  public Location getLocation ()
+  {
+    return _location;
+  }
+
+  /**
+   * Does the given event match the filter?
+   *
+   * @param event  the <code>Event</code> to scrutinize
+   */
+  public boolean matches (Event event)
+  {
+    // FIXME
+    throw new RuntimeException ("LocationOnlyFilter.matches not implemented");
+  }
+}
Index: gnu/classpath/jdwp/event/filters/StepFilter.java
===================================================================
RCS file: gnu/classpath/jdwp/event/filters/StepFilter.java
diff -N gnu/classpath/jdwp/event/filters/StepFilter.java
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ gnu/classpath/jdwp/event/filters/StepFilter.java    26 Aug 2005 21:45:22 
-0000
@@ -0,0 +1,119 @@
+/* StepFilter.java -- a step filter
+   Copyright (C) 2005 Free Software Foundation
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.classpath.jdwp.event.filters;
+
+import gnu.classpath.jdwp.event.Event;
+import gnu.classpath.jdwp.exception.InvalidThreadException;
+import gnu.classpath.jdwp.id.ThreadId;
+
+/**
+ * An event filter which restricts reported step events to those which
+ * satisfy depth and size constraints. This modifier can only be used with
+ * step event kinds.
+ *
+ * @author Keith Seitz  (address@hidden)
+ */
+public class StepFilter
+  implements IEventFilter
+{
+  private ThreadId _tid;
+  private int _size;
+  private int _depth;
+
+  /**
+   * Constructs a new <code>StepFilter</code> with the given count.
+   *
+   * @param  count  the number of times the event will be ignored
+   * @throws InvalidThreadException if thread is invalid
+   */
+  public StepFilter (ThreadId tid, int size, int depth)
+    throws InvalidThreadException
+  {
+    if (tid == null | tid.getReference().get () == null)
+      throw new InvalidThreadException (tid.getId ());
+
+    _tid = tid;
+    _size = size;
+    _depth = depth;
+  }
+
+  /**
+   * Returns the thread in which to step
+   *
+   * @return the thread's ID
+   */
+  public ThreadId getThread ()
+  {
+    return _tid;
+  }
+
+  /**
+   * Returns the size of each step (insn, line)
+   *
+   * @return the step size
+   * @see JdwpConstants.StepSize
+   */
+  public int getSize ()
+  {
+    return _size;
+  }
+
+  /**
+   * Returns the relative call stack limit (into, over, out)
+   *
+   * @return how to step
+   * @see JdwpConstants.StepDepth
+   */
+  public int getDepth ()
+  {
+    return _depth;
+  }
+
+  /**
+   * Does the given event match the filter?
+   *
+   * @param event  the <code>Event</code> to scrutinize
+   */
+  public boolean matches (Event event)
+  {
+    // FIXME
+    throw new RuntimeException ("StepFilter.matches not implemented");
+  }
+}
Index: gnu/classpath/jdwp/event/filters/ThreadOnlyFilter.java
===================================================================
RCS file: gnu/classpath/jdwp/event/filters/ThreadOnlyFilter.java
diff -N gnu/classpath/jdwp/event/filters/ThreadOnlyFilter.java
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ gnu/classpath/jdwp/event/filters/ThreadOnlyFilter.java      26 Aug 2005 
21:45:22 -0000
@@ -0,0 +1,102 @@
+/* ThreadOnlyFilter.java -- a thread filter
+   Copyright (C) 2005 Free Software Foundation
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.classpath.jdwp.event.filters;
+
+import gnu.classpath.jdwp.Jdwp;
+import gnu.classpath.jdwp.event.Event;
+import gnu.classpath.jdwp.exception.InvalidThreadException;
+import gnu.classpath.jdwp.id.ThreadId;
+
+/**
+ * An event filter which allows only events within a specific
+ * thread
+ *
+ * @author Keith Seitz  (address@hidden)
+ */
+public class ThreadOnlyFilter
+  implements IEventFilter
+{
+  // the thread
+  private ThreadId _tid;
+
+  /**
+   * Constructs a new <code>ThreadOnlyFilter</code> for the given
+   * thread id
+   *
+   * @param tid  ID of the thread on which to filter
+   * @throws InvalidThreadException if the thread is not valid
+   */
+  public ThreadOnlyFilter (ThreadId tid)
+    throws InvalidThreadException
+  {
+    if (tid == null | tid.getReference().get () == null)
+      throw new InvalidThreadException (tid.getId ());
+
+    _tid = tid;
+  }
+
+  /**
+   * Returns the thread in which to restrict events
+   *
+   * @return the thread's ID
+   */
+  public ThreadId getThread ()
+  {
+    return _tid;
+  }
+
+  /**
+   * Does the given event match the filter?
+   *
+   * @param event  the <code>Event</code> to scrutinize
+   */
+  public boolean matches (Event event)
+  {
+    Object thread = event.getParameter (ThreadId.class);
+    if (thread != null)
+      {
+       Thread eventThread = (Thread) thread;
+       Thread myThread = (Thread) _tid.getReference().get ();
+       return (eventThread == myThread);
+      }
+
+    return false;
+  }
+}

reply via email to

[Prev in Thread] Current Thread [Next in Thread]