diff options
Diffstat (limited to 'gcc-4.4.3/libjava/classpath/gnu/classpath/jdwp/event')
26 files changed, 3325 insertions, 0 deletions
diff --git a/gcc-4.4.3/libjava/classpath/gnu/classpath/jdwp/event/BreakpointEvent.java b/gcc-4.4.3/libjava/classpath/gnu/classpath/jdwp/event/BreakpointEvent.java new file mode 100644 index 000000000..abf280d6e --- /dev/null +++ b/gcc-4.4.3/libjava/classpath/gnu/classpath/jdwp/event/BreakpointEvent.java @@ -0,0 +1,117 @@ +/* BreakpointEvent.java -- An event specifying that the interpreter + has hit a breakpoint + Copyright (C) 2006 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; + +import gnu.classpath.jdwp.JdwpConstants; +import gnu.classpath.jdwp.VMIdManager; +import gnu.classpath.jdwp.id.ThreadId; +import gnu.classpath.jdwp.util.Location; + +import java.io.DataOutputStream; +import java.io.IOException; + +/** + * "Notification of a breakpoint in the target VM. The breakpoint event is + * generated before the code at its location is executed." + * + * @author Keith Seitz (keiths@redhat.com) + */ +public class BreakpointEvent + extends Event +{ + // The thread in which this event occurred + private Thread _thread; + + // Location where breakpoint occurred + private Location _location; + + //object instance + private Object _instance; + + /** + * Constructs a new BreakpointEvent + * + * @param thread thread in which event occurred + * @param loc location where breakpoint occurred + * @param instance object instance + */ + public BreakpointEvent(Thread thread, Location loc, Object instance) + { + super(JdwpConstants.EventKind.BREAKPOINT); + _thread = thread; + _location = loc; + _instance = instance; + } + + /** + * Returns a specific filtering parameter for this event. + * Valid types are thread and location. + * + * @param type the type of parameter desired + * @returns the desired parameter or null + */ + public Object getParameter(int type) + { + if (type == EVENT_THREAD) + return _thread; + else if (type == EVENT_LOCATION) + return _location; + else if (type == EVENT_INSTANCE) + return _instance; + + return null; + } + + /** + * Writes the event to the given stream + * + * @param outStream the output stream to write the event to + */ + protected void _writeData (DataOutputStream outStream) + throws IOException + { + VMIdManager idm = VMIdManager.getDefault(); + ThreadId tid = (ThreadId) idm.getObjectId(_thread); + + tid.write(outStream); + _location.write(outStream); + } +} diff --git a/gcc-4.4.3/libjava/classpath/gnu/classpath/jdwp/event/ClassPrepareEvent.java b/gcc-4.4.3/libjava/classpath/gnu/classpath/jdwp/event/ClassPrepareEvent.java new file mode 100644 index 000000000..5341daa42 --- /dev/null +++ b/gcc-4.4.3/libjava/classpath/gnu/classpath/jdwp/event/ClassPrepareEvent.java @@ -0,0 +1,147 @@ +/* ClassPrepareEvent.java -- An event specifying that a class has been + prepared by the virtual machine + 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; + +import gnu.classpath.jdwp.JdwpConstants; +import gnu.classpath.jdwp.VMIdManager; +import gnu.classpath.jdwp.id.ReferenceTypeId; +import gnu.classpath.jdwp.id.ThreadId; +import gnu.classpath.jdwp.util.JdwpString; +import gnu.classpath.jdwp.util.Signature; + +import java.io.DataOutputStream; +import java.io.IOException; + +/** + * "Notification of a class prepare in the target VM. See the JVM + * specification for a definition of class preparation. Class prepare + * events are not generated for primtiive classes (for example, + * <code>java.lang.Integer.TYPE</code>)." -- JDWP 1.4.2 + * + * @author Keith Seitz (keiths@redhat.com) + */ +public class ClassPrepareEvent + extends Event +{ + // The thread in which this event occurred + private Thread _thread; + + // The class that was prepared + private Class _class; + + // Prepare flags + private int _status; + + /** + * Class has been verified + */ + public static final int STATUS_VERIFIED + = JdwpConstants.ClassStatus.VERIFIED; + + /** + * Class has been prepared + */ + public static final int STATUS_PREPARED + = JdwpConstants.ClassStatus.PREPARED; + + /** + * Class has been initialized + */ + public static final int STATUS_INITIALIZED + = JdwpConstants.ClassStatus.INITIALIZED; + + /** + * Error preparing class + */ + public static final int STATUS_ERROR + = JdwpConstants.ClassStatus.ERROR; + + /** + * Constructs a new <code>ClassPrepareEvent</code> + * + * @param thread thread in which event occurred + * @param clazz class which was prepared + * @param flags prepare status flags + */ + public ClassPrepareEvent (Thread thread, Class clazz, int flags) + { + super (JdwpConstants.EventKind.CLASS_PREPARE); + _thread = thread; + _class = clazz; + _status = flags; + } + + /** + * Returns a specific filtering parameter for this event. + * Valid types are thread and class. + * + * @param type the type of parameter desired + * @returns the desired parameter or <code>null</code> + */ + public Object getParameter (int type) + { + if (type == EVENT_THREAD) + return _thread; + else if (type == EVENT_CLASS) + return _class; + + return null; + } + + /** + * Writes the event to the given stream + * + * @param outStream the output stream to write the event to + */ + protected void _writeData (DataOutputStream outStream) + throws IOException + { + VMIdManager idm = VMIdManager.getDefault(); + ThreadId tid = (ThreadId) idm.getObjectId (_thread); + ReferenceTypeId rid = idm.getReferenceTypeId (_class); + + tid.write (outStream); + rid.writeTagged (outStream); + JdwpString.writeString (outStream, + Signature.computeClassSignature (_class)); + outStream.writeInt (_status); + } +} diff --git a/gcc-4.4.3/libjava/classpath/gnu/classpath/jdwp/event/ClassUnloadEvent.java b/gcc-4.4.3/libjava/classpath/gnu/classpath/jdwp/event/ClassUnloadEvent.java new file mode 100644 index 000000000..4ba8bc806 --- /dev/null +++ b/gcc-4.4.3/libjava/classpath/gnu/classpath/jdwp/event/ClassUnloadEvent.java @@ -0,0 +1,96 @@ +/* ClassUnloadEvent.java -- event generated when a class is unloaded + Copyright (C) 2006 Free Software Foundation, Inc. + + 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 + 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; + +import gnu.classpath.jdwp.JdwpConstants; +import gnu.classpath.jdwp.VMIdManager; +import gnu.classpath.jdwp.util.JdwpString; + +import java.io.DataOutputStream; +import java.io.IOException; + +/** + * "Notification of a class unload in the target VM" -- JDWP 1.4.2 + * + * @author Kyle Galloway (kgallowa@redhat.com) + */ +public class ClassUnloadEvent + extends Event +{ + //signature directly from VM + private String _signature; + + /** + * Constructs a new <code>ClassUnloadEvent</code> + * + * @param signature the signature reported from the VM + */ + public ClassUnloadEvent(String signature) + { + super(JdwpConstants.EventKind.CLASS_UNLOAD); + _signature = signature; + } + + /** + * Returns a specific filtering parameter for this event. Class is the only + * valid type. + * + * @param type the type of parameter desired + * @returns the desired parameter or <code>null</code> + */ + public Object getParameter(int type) + { + + return null; + } + + /** + * Writes the event to the given stream + * + * @param outStream the output stream to write the event to + */ + protected void _writeData(DataOutputStream outStream) + throws IOException + { + VMIdManager idm = VMIdManager.getDefault(); + + JdwpString.writeString(outStream, _signature); + } + +} diff --git a/gcc-4.4.3/libjava/classpath/gnu/classpath/jdwp/event/Event.java b/gcc-4.4.3/libjava/classpath/gnu/classpath/jdwp/event/Event.java new file mode 100644 index 000000000..c89b25cb9 --- /dev/null +++ b/gcc-4.4.3/libjava/classpath/gnu/classpath/jdwp/event/Event.java @@ -0,0 +1,180 @@ +/* Event.java -- a base class for all event types + Copyright (C) 2005, 2007 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; + +import gnu.classpath.jdwp.JdwpConstants; +import gnu.classpath.jdwp.transport.JdwpCommandPacket; +import gnu.classpath.jdwp.transport.JdwpPacket; + +import java.io.DataOutputStream; +import java.io.IOException; + +/** + * This class is a base class for all VM->debugger event + * notifications. + * + * @author Keith Seitz (keiths@redhat.com) + */ +public abstract class Event +{ + /** + * The class of the object in which the event occurred + */ + public static final int EVENT_CLASS = 1; + + /** + * The thread where the event occurred + */ + public static final int EVENT_THREAD = 2; + + /** + * The location where an event occurred + */ + public static final int EVENT_LOCATION = 3; + + /** + * The instance of the class where the event occurred + */ + public static final int EVENT_INSTANCE = 4; + + /** + * The field acted on by an event + */ + public static final int EVENT_FIELD = 5; + + /** + * The class of the exception for ExceptionEvent + */ + public static final int EVENT_EXCEPTION_CLASS = 6; + + /** + * Whether this exception was caught (only valid for ExceptionEvents) + */ + public static final int EVENT_EXCEPTION_CAUGHT = 7; + + // The kind of event represented by this event + private byte _eventKind; + + /** + * Constructs an <code>Event</code> of the given kind + * + * @param kind the type of event + */ + public Event (byte kind) + { + _eventKind = kind; + } + + /** + * Returns the event type of this event + * + * @returns the event kind + */ + public byte getEventKind () + { + return _eventKind; + } + + /** + * Abstract function used by implementing classes to fill in the + * event-specific data. Note that request ID is automatically added + * by this class (since it appears in all event notifications). + * + * @param outStream the stream to which to write data + */ + protected abstract void _writeData (DataOutputStream outStream) + throws IOException; + + /** + * Returns a specific filtering parameter for this event. For example, + * most events may be filtered by thread. Consequently, a call to this + * method with <code>ThreadId.class</code> should return a + * <code>Thread</code>. + * + * @param type the type of parameter to return + * @returns the parameter (not the ID) or <code>null</code> if none is + * is defined for this event + */ + public abstract Object getParameter (int type); + + /** + * Converts the events into to a single JDWP Event.COMPOSITE packet + * + * @param dos the stream to which to write data + * @param events the events to package into the packet + * @param requests the corresponding event requests + * @param suspendPolicy the suspend policy enforced by the VM + * @returns a <code>JdwpPacket</code> of the events + */ + public static JdwpPacket toPacket (DataOutputStream dos, + Event[] events, + EventRequest[] requests, + byte suspendPolicy) + { + JdwpPacket pkt; + try + { + dos.writeByte (suspendPolicy); + dos.writeInt (events.length); + for (int i = 0; i < events.length; ++i) + _toData (dos, events[i], requests[i]); + + pkt + = new JdwpCommandPacket (JdwpConstants.CommandSet.Event.CS_VALUE, + JdwpConstants.CommandSet.Event.COMPOSITE); + } + catch (IOException ioe) + { + pkt = null; + } + + return pkt; + } + + // Helper function for toPacket + private static void _toData (DataOutputStream dos, Event event, + EventRequest request) + throws IOException + { + dos.writeByte (event._eventKind); + dos.writeInt (request.getId ()); + event._writeData (dos); + } +} diff --git a/gcc-4.4.3/libjava/classpath/gnu/classpath/jdwp/event/EventManager.java b/gcc-4.4.3/libjava/classpath/gnu/classpath/jdwp/event/EventManager.java new file mode 100644 index 000000000..aa3d5d629 --- /dev/null +++ b/gcc-4.4.3/libjava/classpath/gnu/classpath/jdwp/event/EventManager.java @@ -0,0 +1,305 @@ +/* EventManager.java -- event management and notification infrastructure + Copyright (C) 2005, 2006, 2007 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; + +import gnu.classpath.jdwp.Jdwp; +import gnu.classpath.jdwp.VMVirtualMachine; +import gnu.classpath.jdwp.exception.InvalidEventTypeException; +import gnu.classpath.jdwp.exception.JdwpException; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Hashtable; +import java.util.Iterator; + +/** + * Manages event requests and filters event notifications. + * + * The purpose of this class is actually two-fold: + * + * 1) Maintain a list of event requests from the debugger + * 2) Filter event notifications from the VM + * + * If an event request arrives from the debugger, the back-end will + * call {@link #requestEvent}, which will first check for a valid event. + * If it is valid, <code>EventManager</code> will record the request + * internally and register the event with the virtual machine, which may + * choose to handle the request itself (as is likely the case with + * breakpoints and other execution-related events), or it may decide to + * allow the <code>EventManager</code> to handle notifications and all + * filtering (which is convenient for other events such as class (un)loading). + * + * @author Keith Seitz (keiths@redhat.com) + */ +public class EventManager +{ + // Single instance + private static EventManager _instance = null; + + // maps event (EVENT_*) to lists of EventRequests + private Hashtable _requests = null; + + /** + * Returns an instance of the event manager + * + * @return the event manager + */ + public static EventManager getDefault() + { + if (_instance == null) + _instance = new EventManager(); + + return _instance; + } + + // Private constructs a new <code>EventManager</code> + private EventManager () + { + _requests = new Hashtable (); + + // Add lists for all the event types + _requests.put (new Byte (EventRequest.EVENT_SINGLE_STEP), + new Hashtable ()); + _requests.put (new Byte (EventRequest.EVENT_BREAKPOINT), + new Hashtable ()); + _requests.put (new Byte (EventRequest.EVENT_FRAME_POP), + new Hashtable ()); + _requests.put (new Byte (EventRequest.EVENT_EXCEPTION), + new Hashtable ()); + _requests.put (new Byte (EventRequest.EVENT_USER_DEFINED), + new Hashtable ()); + _requests.put (new Byte (EventRequest.EVENT_THREAD_START), + new Hashtable ()); + _requests.put (new Byte (EventRequest.EVENT_THREAD_END), + new Hashtable ()); + _requests.put (new Byte (EventRequest.EVENT_CLASS_PREPARE), + new Hashtable ()); + _requests.put (new Byte (EventRequest.EVENT_CLASS_UNLOAD), + new Hashtable ()); + _requests.put (new Byte (EventRequest.EVENT_CLASS_LOAD), + new Hashtable ()); + _requests.put (new Byte (EventRequest.EVENT_FIELD_ACCESS), + new Hashtable ()); + _requests.put (new Byte (EventRequest.EVENT_FIELD_MODIFY), + new Hashtable ()); + _requests.put (new Byte (EventRequest.EVENT_METHOD_ENTRY), + new Hashtable ()); + _requests.put (new Byte (EventRequest.EVENT_METHOD_EXIT), + new Hashtable ()); + _requests.put (new Byte (EventRequest.EVENT_VM_INIT), + new Hashtable ()); + _requests.put (new Byte (EventRequest.EVENT_VM_DEATH), + new Hashtable ()); + + // Add auto-generated event notifications + // only two: VM_INIT, VM_DEATH + try + { + byte sp = (Jdwp.suspendOnStartup() + ? EventRequest.SUSPEND_THREAD : EventRequest.SUSPEND_NONE); + requestEvent (new EventRequest (0, + EventRequest.EVENT_VM_INIT, sp)); + requestEvent (new EventRequest (0, + EventRequest.EVENT_VM_DEATH, + EventRequest.SUSPEND_NONE)); + } + catch (JdwpException e) + { + // This can't happen + } + } + + /** + * Returns all requests for the given event. This method will only + * be used if the <code>EventManager</code> is handling event filtering. + * + * @param event the event + * @return requests that are interested in this event + * or <code>null</code> if none (and event should not be sent) + * @throws IllegalArgumentException for invalid event kind + */ + public EventRequest[] getEventRequests(Event event) + { + ArrayList interestedEvents = new ArrayList(); + Hashtable requests; + Byte kind = new Byte(event.getEventKind()); + requests = (Hashtable) _requests.get(kind); + if (requests == null) + { + // Did not get a valid event type + throw new IllegalArgumentException("invalid event kind: " + kind); + } + + // Loop through the requests. Must look at ALL requests in order + // to evaluate all filters (think count filter). + Iterator rIter = requests.values().iterator(); + while (rIter.hasNext()) + { + EventRequest request = (EventRequest) rIter.next(); + if (request.matches(event)) + interestedEvents.add(request); + } + + EventRequest[] r = new EventRequest[interestedEvents.size()]; + interestedEvents.toArray(r); + return r; + } + + /** + * Requests monitoring of an event. + * + * The debugger registers for event notification through + * an event filter. If no event filter is specified for an event + * in the VM, it is assumed that the debugger is not interested in + * receiving notifications of this event. + * + * The virtual machine will be notified of the request. + * + * @param request the request to monitor + * @throws InvalidEventTypeException for invalid event kind + * @throws JdwpException for other errors involving request + */ + public void requestEvent (EventRequest request) + throws JdwpException + { + // Add request to request list + Hashtable requests; + Byte kind = new Byte (request.getEventKind ()); + requests = (Hashtable) _requests.get (kind); + if (requests == null) + { + // Did not get a valid event type + throw new InvalidEventTypeException (request.getEventKind ()); + } + + // Register the event with the VM + VMVirtualMachine.registerEvent (request); + requests.put (new Integer (request.getId ()), request); + } + + /** + * Deletes the given request from the management table + * + * @param kind the event kind + * @param id the ID of the request to delete + * @throws IllegalArgumentException for invalid event kind + * @throws JdwpException for other errors deleting request + */ + public void deleteRequest (byte kind, int id) + throws JdwpException + { + Hashtable requests; + requests = (Hashtable) _requests.get (new Byte (kind)); + if (requests == null) + { + // Did not get a valid event type + throw new IllegalArgumentException ("invalid event kind: " + kind); + } + + Integer iid = new Integer (id); + EventRequest request = (EventRequest) requests.get (iid); + if (request != null) + { + VMVirtualMachine.unregisterEvent (request); + requests.remove (iid); + } + } + + /** + * Clears all the requests for a given event + * + * @param kind the event kind + * @throws IllegalArgumentException for invalid event kind + * @throws JdwpException for error clearing events + */ + public void clearRequests (byte kind) + throws JdwpException + { + Hashtable requests = (Hashtable) _requests.get (new Byte (kind)); + if (requests == null) + { + // Did not get a valid event type + throw new IllegalArgumentException ("invalid event kind: " + kind); + } + + VMVirtualMachine.clearEvents (kind); + requests.clear (); + } + + /** + * Returns a given event request for an event + * + * @param kind the kind of event for the request + * @param id the integer request id to return + * @return the request for the given event kind with the given id + * (or <code>null</code> if not found) + * @throws IllegalArgumentException for invalid event kind + */ + public EventRequest getRequest (byte kind, int id) + { + Hashtable requests = (Hashtable) _requests.get (new Byte (kind)); + if (requests == null) + { + // Did not get a valid event type + throw new IllegalArgumentException ("invalid event kind: " + kind); + } + + return (EventRequest) requests.get (new Integer (id)); + } + + /** + * Returns all requests of the given event kind + * + * @param kind the event kind + * @returns a <code>Collection</code> of all the registered requests + * @throws IllegalArgumentException for invalid event kind + */ + public Collection getRequests (byte kind) + { + Hashtable requests = (Hashtable) _requests.get (new Byte (kind)); + if (requests == null) + { + // Did not get a valid event type + throw new IllegalArgumentException ("invalid event kind: " + kind); + } + + return requests.values (); + } +} diff --git a/gcc-4.4.3/libjava/classpath/gnu/classpath/jdwp/event/EventRequest.java b/gcc-4.4.3/libjava/classpath/gnu/classpath/jdwp/event/EventRequest.java new file mode 100644 index 000000000..34637f6a2 --- /dev/null +++ b/gcc-4.4.3/libjava/classpath/gnu/classpath/jdwp/event/EventRequest.java @@ -0,0 +1,383 @@ +/* EventRequest.java -- an event request from the debugger + Copyright (C) 2005, 2006 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; + +import gnu.classpath.jdwp.JdwpConstants; +import gnu.classpath.jdwp.event.filters.*; +import gnu.classpath.jdwp.exception.JdwpIllegalArgumentException; +import java.util.Collection; +import java.util.Iterator; +import java.util.LinkedList; + +/** + * A class which represents a request by the debugger for an event + * in the VM. <code>EventRequest</code>s usually have event filters + * associated with them, which allow the debugger to specify conditions + * under which the notification should be sent (specific thread, specific + * class, ignore count, etc). + * + * @author Keith Seitz (keiths@redhat.com) + */ +public class EventRequest +{ + /* + * Event types + */ + + /** + * Single step event + */ + public static final byte EVENT_SINGLE_STEP = + JdwpConstants.EventKind.SINGLE_STEP; + + /** + * Breakpoint event + */ + public static final byte EVENT_BREAKPOINT = + JdwpConstants.EventKind.BREAKPOINT; + + /** + * Frame pop event + */ + public static final byte EVENT_FRAME_POP = + JdwpConstants.EventKind.FRAME_POP; + + /** + * Exception event + */ + public static final byte EVENT_EXCEPTION = + JdwpConstants.EventKind.EXCEPTION; + + /** + * User-defined event + */ + public static final byte EVENT_USER_DEFINED = + JdwpConstants.EventKind.USER_DEFINED; + + /** + * Thread start event + */ + public static final byte EVENT_THREAD_START = + JdwpConstants.EventKind.THREAD_START; + + /** + * Thread end/death event + */ + public static final byte EVENT_THREAD_END = + JdwpConstants.EventKind.THREAD_END; + + /** + * Class prepare event + */ + public static final byte EVENT_CLASS_PREPARE = + JdwpConstants.EventKind.CLASS_PREPARE; + + /** + * Class unload event + */ + public static final byte EVENT_CLASS_UNLOAD = + JdwpConstants.EventKind.CLASS_UNLOAD; + + /** + * Class load event + */ + public static final byte EVENT_CLASS_LOAD = + JdwpConstants.EventKind.CLASS_LOAD; + + /** + * Field access event + */ + public static final byte EVENT_FIELD_ACCESS = + JdwpConstants.EventKind.FIELD_ACCESS; + + /** + * Field modify event + */ + public static final byte EVENT_FIELD_MODIFY = + JdwpConstants.EventKind.FIELD_MODIFICATION; + + /** + * Method entry event + */ + public static final byte EVENT_METHOD_ENTRY = + JdwpConstants.EventKind.METHOD_ENTRY; + + /** + * Method exit event + */ + public static final byte EVENT_METHOD_EXIT = + JdwpConstants.EventKind.METHOD_EXIT; + + /** + * Virtual machine initialization/start + */ + public static final byte EVENT_VM_INIT = + JdwpConstants.EventKind.VM_INIT; + + /** + * Virutal machine death + */ + public static final byte EVENT_VM_DEATH = + JdwpConstants.EventKind.VM_DEATH; + + + /* + * Suspend policies + */ + + /** + * Do not suspend any threads + */ + public static final byte SUSPEND_NONE = + JdwpConstants.SuspendPolicy.NONE; + + /** + * Suspend the thread in which the event occurred + */ + public static final byte SUSPEND_THREAD = + JdwpConstants.SuspendPolicy.EVENT_THREAD; + + /** + * Suspend all threads + */ + public static final byte SUSPEND_ALL = + JdwpConstants.SuspendPolicy.ALL; + + // ID of last EventRequest + private static int _last_id = 0; + private static Object _idLock = new Object (); + + // A list of filters + private LinkedList _filters; + + // The ID of this request + private int _id; + + // The suspend policy to enforce when this event occurs + private byte _suspendPolicy; + + // Kind of event requested + private byte _kind; + + /** + * Construct a new <code>EventRequest</code> + * + * @param kind the kind of event requested + * @param suspendPolicy how to suspend threads when event occurs + */ + public EventRequest (byte kind, byte suspendPolicy) + { + _filters = new LinkedList (); + synchronized (_idLock) + { + _id = ++_last_id; + } + _kind = kind; + _suspendPolicy = suspendPolicy; + } + + /** + * Construct a new <code>EventRequest</code> with the given ID + * + * @param id the id of the request to create + * @param kind the kind of event requested + * @param suspendPolicy how to suspend threads when event occurs + */ + public EventRequest (int id, byte kind, byte suspendPolicy) + { + _filters = new LinkedList (); + _kind = kind; + _suspendPolicy = suspendPolicy; + } + + /** + * Creates a new event filter, adding it to this request + * + * @param filter the filter to add + * @throws JdwpIllegalArgumentException if an invalid or illegal filter + * is added to the request + */ + public void addFilter (IEventFilter filter) + throws JdwpIllegalArgumentException + { + // Check validity of filter for this request + boolean valid = true; + + Class clazz = filter.getClass (); + if (clazz == ClassExcludeFilter.class) + { + if (_kind == EVENT_THREAD_START + || _kind == EVENT_THREAD_END) + valid = false; + } + else if (clazz == ClassMatchFilter.class) + { + if (_kind == EVENT_THREAD_START + || _kind == EVENT_THREAD_END) + valid = false; + } + else if (clazz == ClassOnlyFilter.class) + { + if (_kind == EVENT_CLASS_UNLOAD + || _kind == EVENT_THREAD_START + || _kind == EVENT_THREAD_END) + valid = false; + } + else if (clazz == ConditionalFilter.class) + { + // JDWP 1.4 does not say much about this + } + else if (clazz == CountFilter.class) + { + // may be used with any event + } + else if (clazz == ExceptionOnlyFilter.class) + { + if (_kind != EVENT_EXCEPTION) + valid = false; + } + else if (clazz == FieldOnlyFilter.class) + { + if (_kind != EVENT_FIELD_ACCESS + && _kind != EVENT_FIELD_MODIFY) + valid = false; + } + else if (clazz == InstanceOnlyFilter.class) + { + if (_kind == EVENT_CLASS_PREPARE + || _kind == EVENT_CLASS_UNLOAD + || _kind == EVENT_THREAD_START + || _kind == EVENT_THREAD_END) + valid = false; + } + else if (clazz == LocationOnlyFilter.class) + { + if (_kind != EVENT_BREAKPOINT + && _kind != EVENT_FIELD_ACCESS + && _kind != EVENT_FIELD_MODIFY + && _kind != EVENT_SINGLE_STEP + && _kind != EVENT_EXCEPTION) + valid = false; + } + else if (clazz == StepFilter.class) + { + if (_kind != EVENT_SINGLE_STEP) + valid = false; + } + else if (clazz == ThreadOnlyFilter.class) + { + if (_kind == EVENT_CLASS_UNLOAD) + valid = false; + } + + if (!valid) + { + String msg = ("cannot use " + filter.getClass ().getName () + + " with class unload events"); + throw new JdwpIllegalArgumentException (msg); + } + + // Add filter to list + _filters.add (filter); + } + + /** + * Returns the filters attached to this request + */ + public Collection getFilters () + { + return _filters; + } + + /** + * Returns the suspend policy for this request + */ + public byte getSuspendPolicy () + { + return _suspendPolicy; + } + + /** + * Returns the request id of this request + */ + public int getId () + { + return _id; + } + + /** + * Sets the id of the request (used for auto-generated events) + */ + public void setId (int id) + { + _id = id; + } + + /** + * Returns the kind of event for this request + */ + public byte getEventKind () + { + return _kind; + } + + /** + * Determines whether the given event matches this request + * + * @param theEvent the event to compare to + */ + public boolean matches (Event theEvent) + { + boolean matches = true; + + // Loop through filters; all must match + // Note that we must allow EVERY filter to evaluate. This way + // things like CountFilter will work. + Iterator iter = _filters.iterator (); + while (iter.hasNext ()) + { + IEventFilter filter = (IEventFilter) iter.next (); + if (!filter.matches (theEvent)) + matches = false; + } + + return matches; + } +} diff --git a/gcc-4.4.3/libjava/classpath/gnu/classpath/jdwp/event/ExceptionEvent.java b/gcc-4.4.3/libjava/classpath/gnu/classpath/jdwp/event/ExceptionEvent.java new file mode 100644 index 000000000..1bb339969 --- /dev/null +++ b/gcc-4.4.3/libjava/classpath/gnu/classpath/jdwp/event/ExceptionEvent.java @@ -0,0 +1,157 @@ +/* ExceptionEvent.java -- an event specifying an exception has been thrown + Copyright (C) 2006 Free Software Foundation, Inc. + + 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 + 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; + +import gnu.classpath.jdwp.JdwpConstants; +import gnu.classpath.jdwp.VMIdManager; +import gnu.classpath.jdwp.id.ObjectId; +import gnu.classpath.jdwp.id.ThreadId; +import gnu.classpath.jdwp.util.Location; + +import java.io.DataOutputStream; +import java.io.IOException; + +/** + * Notification from the VM that an exception has occurred along with where it + * occurred, and if and where it was caught. + * + * @author Kyle Galloway (kgallowa@redhat.com) + */ +public class ExceptionEvent + extends Event +{ + //object instance + private Object _instance; + + // the exception thrown + private Throwable _exception; + + // the thread in which the exception occurred + private Thread _thread; + + // the location where the exception was thrown + private Location _location; + + //the location where the exception was caught + private Location _catchLocation; + + //the class where the exeption was thrown + private Class _klass; + + /** + * Constructs a new <code>ExceptionEvent</code> where the exception was + * caught. + * + * @param exception the throwable object that generated the event + * @param thread the thread where the exception occurred + * @param location the location where the exception was thrown + * @param catchLocation the location where the exception was caught + * @param instance the instance that threw the exception + */ + public ExceptionEvent(Throwable exception, Thread thread, Location location, + Location catchLocation, Class clazz, Object instance) + { + super(JdwpConstants.EventKind.EXCEPTION); + _exception = exception; + _thread = thread; + _location = location; + _catchLocation = catchLocation; + _klass = clazz; + _instance = instance; + } + + /** + * Returns a specific filtering parameter for this event. Valid types are + * thread, location, and catchLocation. + * + * @param type the type of parameter desired + * @returns the desired parameter or null + */ + public Object getParameter(int type) + { + if (type == EVENT_THREAD) + return _thread; + else if (type == EVENT_LOCATION) + return _location; + else if (type == EVENT_INSTANCE) + return _instance; + else if (type == EVENT_CLASS) + return _klass; + else if (type == EVENT_EXCEPTION_CLASS) + return _exception.getClass(); + else if (type == EVENT_EXCEPTION_CAUGHT) + if (_catchLocation.getMethod() != null) + return Boolean.TRUE; + else + return Boolean.FALSE; + + return null; + } + + /** + * Sets the catchLocation, used for exceptions that are caught in different + * stack frames from where they are thrown. + * + * @param catchLoc the location of the catch + */ + public void setCatchLoc(Location catchLoc) + { + _catchLocation = catchLoc; + } + + /** + * Writes the event to the given stream + * + * @param outStream the output stream to write the event to + * @throws IOException + */ + protected void _writeData(DataOutputStream outStream) + throws IOException + { + VMIdManager idm = VMIdManager.getDefault(); + ThreadId tid = (ThreadId) idm.getObjectId(_thread); + ObjectId oid = idm.getObjectId(_exception); + + tid.write(outStream); + _location.write(outStream); + oid.writeTagged(outStream); + _catchLocation.write(outStream); + + } +} diff --git a/gcc-4.4.3/libjava/classpath/gnu/classpath/jdwp/event/MethodEntryEvent.java b/gcc-4.4.3/libjava/classpath/gnu/classpath/jdwp/event/MethodEntryEvent.java new file mode 100644 index 000000000..40c0516c7 --- /dev/null +++ b/gcc-4.4.3/libjava/classpath/gnu/classpath/jdwp/event/MethodEntryEvent.java @@ -0,0 +1,118 @@ +/* MethodEntryEvent.java -- an event specifying that a method has been invoked + Copyright (C) 2006 Free Software Foundation, Inc. + + 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 + 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; + +import gnu.classpath.jdwp.JdwpConstants; +import gnu.classpath.jdwp.VMIdManager; +import gnu.classpath.jdwp.id.ThreadId; +import gnu.classpath.jdwp.util.Location; + +import java.io.DataOutputStream; +import java.io.IOException; + +/** + * Notification from the VM that that a method has been invoked + * + * @author Kyle Galloway (kgallowa@redhat.com) + */ +public class MethodEntryEvent + extends Event +{ + // The thread where the event occurred + private Thread _thread; + + // the location where the event occurred + private Location _location; + + //object instance + private Object _instance; + + /** + * Constructs a new <code>MethodEntryEvent</code> + * + * @param thread the thread where the exception occurred + * @param location the location single stepped to + * @param instance instance from which the method was called + */ + public MethodEntryEvent(Thread thread, Location location, Object instance) + { + super(JdwpConstants.EventKind.METHOD_ENTRY); + _thread = thread; + _location = location; + _instance = instance; + } + + /** + * Returns a specific filtering parameter for this event. Valid types are + * thread and location + * + * @param type the type of parameter desired + * @returns the desired parameter or null + */ + public Object getParameter(int type) + { + if (type == EVENT_THREAD) + return _thread; + else if (type == EVENT_LOCATION) + return _location; + else if (type == EVENT_INSTANCE) + return _instance; + else if (type == EVENT_CLASS) + return _instance.getClass(); + + return null; + } + + /** + * Writes the event to the given stream + * + * @param outStream the output stream to write the event to + * @throws IOException + */ + protected void _writeData(DataOutputStream outStream) + throws IOException + { + VMIdManager idm = VMIdManager.getDefault(); + ThreadId tid = (ThreadId) idm.getObjectId(_thread); + + tid.write(outStream); + _location.write(outStream); + } + +} diff --git a/gcc-4.4.3/libjava/classpath/gnu/classpath/jdwp/event/MethodExitEvent.java b/gcc-4.4.3/libjava/classpath/gnu/classpath/jdwp/event/MethodExitEvent.java new file mode 100644 index 000000000..ce03dd264 --- /dev/null +++ b/gcc-4.4.3/libjava/classpath/gnu/classpath/jdwp/event/MethodExitEvent.java @@ -0,0 +1,115 @@ +/* MethodExitEvent.java -- an event specifying that a method has returned + Copyright (C) 2006 Free Software Foundation, Inc. + + 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 + 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; + +import gnu.classpath.jdwp.JdwpConstants; +import gnu.classpath.jdwp.VMIdManager; +import gnu.classpath.jdwp.id.ThreadId; +import gnu.classpath.jdwp.util.Location; + +import java.io.DataOutputStream; +import java.io.IOException; + +/** + * Notification from the VM that that a method has returned + * + * @author Kyle Galloway (kgallowa@redhat.com) + */ +public class MethodExitEvent + extends Event +{ + // The thread where the event occurred + private Thread _thread; + + // the location where the event occurred + private Location _location; + + // object instance + private Object _instance; + + /** + * Constructs a new <code>MethodExitEvent</code> + * + * @param thread the thread where the exception occurred + * @param location the location single stepped to + * @param instance the instance from which the method was called + */ + public MethodExitEvent(Thread thread, Location location, Object instance) + { + super(JdwpConstants.EventKind.METHOD_EXIT); + _thread = thread; + _location = location; + _instance = instance; + } + + /** + * Returns a specific filtering parameter for this event. Valid types are + * thread and location + * + * @param type the type of parameter desired + * @returns the desired parameter or null + */ + public Object getParameter(int type) + { + if (type == EVENT_THREAD) + return _thread; + else if (type == EVENT_LOCATION) + return _location; + else if (type == EVENT_CLASS) + return _instance.getClass(); + + return null; + } + + /** + * Writes the event to the given stream + * + * @param outStream the output stream to write the event to + * @throws IOException + */ + protected void _writeData(DataOutputStream outStream) + throws IOException + { + VMIdManager idm = VMIdManager.getDefault(); + ThreadId tid = (ThreadId) idm.getObjectId(_thread); + + tid.write(outStream); + _location.write(outStream); + } +} diff --git a/gcc-4.4.3/libjava/classpath/gnu/classpath/jdwp/event/SingleStepEvent.java b/gcc-4.4.3/libjava/classpath/gnu/classpath/jdwp/event/SingleStepEvent.java new file mode 100644 index 000000000..cd69dd99d --- /dev/null +++ b/gcc-4.4.3/libjava/classpath/gnu/classpath/jdwp/event/SingleStepEvent.java @@ -0,0 +1,121 @@ +/* SingleStepEvent.java -- an event specifying that a single step has + compleated + Copyright (C) 2006 Free Software Foundation, Inc. + + 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 + 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; + +import gnu.classpath.jdwp.JdwpConstants; +import gnu.classpath.jdwp.VMIdManager; +import gnu.classpath.jdwp.id.ThreadId; +import gnu.classpath.jdwp.util.Location; + +import java.io.DataOutputStream; +import java.io.IOException; + + +/** + * Notification from the VM that a single step has compleated including the + * thread and location stepped to + * + * @author Kyle Galloway (kgallowa@redhat.com) + */ +public class SingleStepEvent + extends Event +{ + // the thread where the event occurred + private Thread _thread; + + // the location where the event occurred + private Location _location; + + //object instance + private Object _instance; + + /** + * Constructs a new <code>SingleStepEvent</code> + * + * @param thread the thread where the exception occurred + * @param location the location single stepped to + * @param instance the instance in which the single step occurred + */ + public SingleStepEvent(Thread thread, Location location, Object instance) + { + super(JdwpConstants.EventKind.SINGLE_STEP); + _thread = thread; + _location = location; + _instance = instance; + } + + /** + * Returns a specific filtering parameter for this event. Valid types are + * thread and location + * + * @param type the type of parameter desired + * @returns the desired parameter or null + */ + public Object getParameter(int type) + { + if (type == EVENT_THREAD) + return _thread; + else if (type == EVENT_LOCATION) + return _location; + else if (type == EVENT_INSTANCE) + return _instance; + else if (type == EVENT_CLASS) + return _instance.getClass(); + + return null; + } + + /** + * Writes the event to the given stream + * + * @param outStream the output stream to write the event to + * @throws IOException + */ + protected void _writeData(DataOutputStream outStream) + throws IOException + { + VMIdManager idm = VMIdManager.getDefault(); + ThreadId tid = (ThreadId) idm.getObjectId(_thread); + + tid.write(outStream); + _location.write(outStream); + } + +} diff --git a/gcc-4.4.3/libjava/classpath/gnu/classpath/jdwp/event/ThreadEndEvent.java b/gcc-4.4.3/libjava/classpath/gnu/classpath/jdwp/event/ThreadEndEvent.java new file mode 100644 index 000000000..c665428fb --- /dev/null +++ b/gcc-4.4.3/libjava/classpath/gnu/classpath/jdwp/event/ThreadEndEvent.java @@ -0,0 +1,105 @@ +/* ThreadEndEvent.java -- An event specifying that a thread has died + 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; + +import gnu.classpath.jdwp.JdwpConstants; +import gnu.classpath.jdwp.VMIdManager; +import gnu.classpath.jdwp.id.ThreadId; + +import java.io.DataOutputStream; +import java.io.IOException; + +/** + * "Notification of a completed thread in the target VM. The notification + * is generated by the dying thread before it terminates. Because of this + * timing, it is possible for VirtualMachine.allThreads to return this + * thread after this event is received. + * + * <p>Note that this event gives no information about the lifetime of the + * thread object. It may or may not be collected soon depending on what + * references exist in the target VM." -- JDWP 1.4.2 + * + * @author Keith Seitz (keiths@redhat.com) + */ +public class ThreadEndEvent + extends Event +{ + private Thread _thread; + + /** + * Constructs a new <code>ThreadEndEvent</code> + * + * @param thread the deceased thread + */ + public ThreadEndEvent (Thread thread) + { + super (JdwpConstants.EventKind.THREAD_END); + _thread = thread; + } + + /** + * Returns a specific filtering parameter for this event. + * Valid types are ThreadId. + * + * @param type the type of parameter desired + * @returns the desired parameter or <code>null</code> + */ + public Object getParameter (int type) + { + if (type == EVENT_THREAD) + return _thread; + + return null; + } + + /** + * Writes the event to the given stream + * + * @param outStream the output stream to write the event to + */ + protected void _writeData (DataOutputStream outStream) + throws IOException + { + VMIdManager idm = VMIdManager.getDefault(); + ThreadId tid = (ThreadId) idm.getObjectId (_thread); + tid.write (outStream); + } +} + diff --git a/gcc-4.4.3/libjava/classpath/gnu/classpath/jdwp/event/ThreadStartEvent.java b/gcc-4.4.3/libjava/classpath/gnu/classpath/jdwp/event/ThreadStartEvent.java new file mode 100644 index 000000000..4eff4409e --- /dev/null +++ b/gcc-4.4.3/libjava/classpath/gnu/classpath/jdwp/event/ThreadStartEvent.java @@ -0,0 +1,109 @@ +/* ThreadStartEvent.java -- An event specifying that a new thread + has started in the virtual machine + Copyright (C) 2005, 2007 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; + +import gnu.classpath.jdwp.JdwpConstants; +import gnu.classpath.jdwp.VMIdManager; +import gnu.classpath.jdwp.id.ThreadId; + +import java.io.DataOutputStream; +import java.io.IOException; + +/** + * "Notification of a new running thread in the target VM. The new + * thread can be the result of a call to {@link java.lang.Thread#start} or + * the result of attaching a new thread to the VM though JNI. The + * notification is generated by the new thread some time before its + * execution starts. Because of this timing, it is possible to receive + * other events for the thread before this event is received. (Notably, + * Method Entry Events and Method Exit Events might occur during thread + * initialization. It is also possible for the VirtualMachine AllThreads + * command to return a thread before its thread start event is received. + * + * <p>Note that this event gives no information about the creation of the + * thread object which may have happened much earlier, depending on the + * VM being debugged." -- JDWP 1.4.2 + * + * @author Keith Seitz (keiths@redhat.com) + */ +public class ThreadStartEvent + extends Event +{ + private Thread _thread; + + /** + * Constructs a new ThreadStartEvent object + * + * @param thread the thread ID in which event occurred + */ + public ThreadStartEvent (Thread thread) { + super (JdwpConstants.EventKind.THREAD_START); + _thread = thread; + } + + /** + * Returns a specific filtering parameter for this event. + * Valid types are ThreadId. + * + * @param type the type of parameter desired + * @returns the desired parameter or <code>null</code> + */ + public Object getParameter (int type) + { + if (type == EVENT_THREAD) + return _thread; + + return null; + } + + /** + * Writes the event to the given stream + * + * @param outStream the output stream to write the event to + */ + protected void _writeData (DataOutputStream outStream) + throws IOException + { + VMIdManager idm = VMIdManager.getDefault(); + ThreadId tid = (ThreadId) idm.getObjectId (_thread); + tid.write (outStream); + } +} diff --git a/gcc-4.4.3/libjava/classpath/gnu/classpath/jdwp/event/VmDeathEvent.java b/gcc-4.4.3/libjava/classpath/gnu/classpath/jdwp/event/VmDeathEvent.java new file mode 100644 index 000000000..a729bd47e --- /dev/null +++ b/gcc-4.4.3/libjava/classpath/gnu/classpath/jdwp/event/VmDeathEvent.java @@ -0,0 +1,83 @@ +/* VmDeathEvent.java -- An event specifying that the VM has terminated + 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; + +import gnu.classpath.jdwp.JdwpConstants; + +import java.io.DataOutputStream; +import java.io.IOException; + +/** + * Event notifying the debugger that the virtual machine has terminated. + * + * @author Keith Seitz (keiths@redhat.com) + */ +public class VmDeathEvent + extends Event +{ + /** + * Constructs a new VmDeathEvent object + */ + public VmDeathEvent () + { + super (JdwpConstants.EventKind.VM_DEATH); + } + + /** + * Returns a specific filtering parameter for this event. + * This event has no valid types. + * + * @param type the type of parameter desired + * @returns the desired parameter or <code>null</code> + */ + public Object getParameter (int type) + { + return null; + } + + /** + * Writes out event-specific data + */ + protected void _writeData (DataOutputStream outStream) + throws IOException + { + // no data (request ID done by VMIdManager) + } +} diff --git a/gcc-4.4.3/libjava/classpath/gnu/classpath/jdwp/event/VmInitEvent.java b/gcc-4.4.3/libjava/classpath/gnu/classpath/jdwp/event/VmInitEvent.java new file mode 100644 index 000000000..1ed63b247 --- /dev/null +++ b/gcc-4.4.3/libjava/classpath/gnu/classpath/jdwp/event/VmInitEvent.java @@ -0,0 +1,94 @@ +/* VmInitEvent.java -- An event specifying that the VM has started + 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; + +import gnu.classpath.jdwp.JdwpConstants; +import gnu.classpath.jdwp.VMIdManager; +import gnu.classpath.jdwp.id.ThreadId; + +import java.io.DataOutputStream; +import java.io.IOException; + +/** + * "Notification of initialization of a target VM. This event is + * received before the main thread is started and before any application + * code has been executed." -- JDWP 1.4.2 + * + * @author Keith Seitz (keiths@redhat.com) + */ +public class VmInitEvent + extends Event +{ + private Thread _initialThread; + + /** + * Constructs a <code>VmInitEvent</code> object + * + * @param thread the initial thread + */ + public VmInitEvent (Thread thread) + { + super (JdwpConstants.EventKind.VM_INIT); + _initialThread = thread; + } + + /** + * Returns a specific filtering parameter for this event. + * This event has no valid types. + * + * @param type the type of parameter desired + * @returns the desired parameter or <code>null</code> + */ + public Object getParameter (int type) + { + return null; + } + + /** + * Writes out event-specific data + */ + protected void _writeData (DataOutputStream outStream) + throws IOException + { + VMIdManager idm = VMIdManager.getDefault(); + ThreadId tid = (ThreadId) idm.getObjectId (_initialThread); + tid.write (outStream); + } +} diff --git a/gcc-4.4.3/libjava/classpath/gnu/classpath/jdwp/event/filters/ClassExcludeFilter.java b/gcc-4.4.3/libjava/classpath/gnu/classpath/jdwp/event/filters/ClassExcludeFilter.java new file mode 100644 index 000000000..c8ec51c75 --- /dev/null +++ b/gcc-4.4.3/libjava/classpath/gnu/classpath/jdwp/event/filters/ClassExcludeFilter.java @@ -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 (keiths@redhat.com) + */ +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); + } +} diff --git a/gcc-4.4.3/libjava/classpath/gnu/classpath/jdwp/event/filters/ClassMatchFilter.java b/gcc-4.4.3/libjava/classpath/gnu/classpath/jdwp/event/filters/ClassMatchFilter.java new file mode 100644 index 000000000..a89843169 --- /dev/null +++ b/gcc-4.4.3/libjava/classpath/gnu/classpath/jdwp/event/filters/ClassMatchFilter.java @@ -0,0 +1,112 @@ +/* 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; + +/** + * An event filter which includes events matching a + * specified class pattern (exact match or start/end with "*"). + * + * @author Keith Seitz (keiths@redhat.com) + */ +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 (Event.EVENT_CLASS); + if (type != null) + { + 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); + } + + return false; + } +} diff --git a/gcc-4.4.3/libjava/classpath/gnu/classpath/jdwp/event/filters/ClassOnlyFilter.java b/gcc-4.4.3/libjava/classpath/gnu/classpath/jdwp/event/filters/ClassOnlyFilter.java new file mode 100644 index 000000000..455cac6c0 --- /dev/null +++ b/gcc-4.4.3/libjava/classpath/gnu/classpath/jdwp/event/filters/ClassOnlyFilter.java @@ -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 (keiths@redhat.com) + */ +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 (Event.EVENT_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; + } +} diff --git a/gcc-4.4.3/libjava/classpath/gnu/classpath/jdwp/event/filters/ConditionalFilter.java b/gcc-4.4.3/libjava/classpath/gnu/classpath/jdwp/event/filters/ConditionalFilter.java new file mode 100644 index 000000000..645a70f42 --- /dev/null +++ b/gcc-4.4.3/libjava/classpath/gnu/classpath/jdwp/event/filters/ConditionalFilter.java @@ -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 (keiths@redhat.com) + */ +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 conditional 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; + } +} diff --git a/gcc-4.4.3/libjava/classpath/gnu/classpath/jdwp/event/filters/CountFilter.java b/gcc-4.4.3/libjava/classpath/gnu/classpath/jdwp/event/filters/CountFilter.java new file mode 100644 index 000000000..46148a504 --- /dev/null +++ b/gcc-4.4.3/libjava/classpath/gnu/classpath/jdwp/event/filters/CountFilter.java @@ -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 (keiths@redhat.com) + */ +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; + } +} diff --git a/gcc-4.4.3/libjava/classpath/gnu/classpath/jdwp/event/filters/ExceptionOnlyFilter.java b/gcc-4.4.3/libjava/classpath/gnu/classpath/jdwp/event/filters/ExceptionOnlyFilter.java new file mode 100644 index 000000000..8bb56ed78 --- /dev/null +++ b/gcc-4.4.3/libjava/classpath/gnu/classpath/jdwp/event/filters/ExceptionOnlyFilter.java @@ -0,0 +1,123 @@ +/* ExceptionOnlyFilter.java -- filter for excetions by caught/uncaught and type + Copyright (C) 2005, 2006 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 (keiths@redhat.com) + */ +public class ExceptionOnlyFilter + implements IEventFilter +{ + private ReferenceTypeId _refId; + private boolean _caught; + private boolean _uncaught; + + /** + * Constructs a new ExceptionOnlyFilter + * + * @param refId ID of the exception to report(null for all exceptions) + * @param caught Report caught exceptions + * @param uncaught Report uncaught exceptions + * @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; + } + + + /** + * Does the given event match the filter? + * + * @param event the <code>Event</code> to scrutinize + */ + public boolean matches(Event event) + { + boolean classMatch = true; + + // if not allowing all exceptions check if the exception matches + if (_refId != null) + { + try + { + Class klass + = (Class) event.getParameter(Event.EVENT_EXCEPTION_CLASS); + classMatch = klass == _refId.getType(); + } + catch (InvalidClassException ex) + { + classMatch = false; + } + } + + // check against the caught and uncaught options + Boolean caught + = (Boolean) event.getParameter(Event.EVENT_EXCEPTION_CAUGHT); + + return classMatch && ((caught.booleanValue()) ? _caught : _uncaught); + } + +} diff --git a/gcc-4.4.3/libjava/classpath/gnu/classpath/jdwp/event/filters/FieldOnlyFilter.java b/gcc-4.4.3/libjava/classpath/gnu/classpath/jdwp/event/filters/FieldOnlyFilter.java new file mode 100644 index 000000000..20a9edf22 --- /dev/null +++ b/gcc-4.4.3/libjava/classpath/gnu/classpath/jdwp/event/filters/FieldOnlyFilter.java @@ -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 (keiths@redhat.com) + */ +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 InvalidFieldException 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"); + } +} diff --git a/gcc-4.4.3/libjava/classpath/gnu/classpath/jdwp/event/filters/IEventFilter.java b/gcc-4.4.3/libjava/classpath/gnu/classpath/jdwp/event/filters/IEventFilter.java new file mode 100644 index 000000000..4a2b5431b --- /dev/null +++ b/gcc-4.4.3/libjava/classpath/gnu/classpath/jdwp/event/filters/IEventFilter.java @@ -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 {@link 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 (keiths@redhat.com) + */ +public interface IEventFilter +{ + /** + * Does the given event match the filter? + * + * @param event the <code>Event</code> to scrutinize + */ + public boolean matches (Event event); +} diff --git a/gcc-4.4.3/libjava/classpath/gnu/classpath/jdwp/event/filters/InstanceOnlyFilter.java b/gcc-4.4.3/libjava/classpath/gnu/classpath/jdwp/event/filters/InstanceOnlyFilter.java new file mode 100644 index 000000000..bda5b27d6 --- /dev/null +++ b/gcc-4.4.3/libjava/classpath/gnu/classpath/jdwp/event/filters/InstanceOnlyFilter.java @@ -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 (keiths@redhat.com) + */ +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 (Event.EVENT_INSTANCE); + if (eventInstance != null) + { + Object myInstance = _instance.getReference().get (); + return ((myInstance != null) && (myInstance == eventInstance)); + } + + return false; + } +} diff --git a/gcc-4.4.3/libjava/classpath/gnu/classpath/jdwp/event/filters/LocationOnlyFilter.java b/gcc-4.4.3/libjava/classpath/gnu/classpath/jdwp/event/filters/LocationOnlyFilter.java new file mode 100644 index 000000000..a3125371c --- /dev/null +++ b/gcc-4.4.3/libjava/classpath/gnu/classpath/jdwp/event/filters/LocationOnlyFilter.java @@ -0,0 +1,94 @@ +/* LocationOnlyFilter.java -- filter on location + Copyright (C) 2005, 2006, 2007 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 (keiths@redhat.com) + */ +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) + { + Location loc = (Location) event.getParameter(Event.EVENT_LOCATION); + if (loc != null) + return (getLocation().equals(loc)); + + return false; + } +} diff --git a/gcc-4.4.3/libjava/classpath/gnu/classpath/jdwp/event/filters/StepFilter.java b/gcc-4.4.3/libjava/classpath/gnu/classpath/jdwp/event/filters/StepFilter.java new file mode 100644 index 000000000..fd412716c --- /dev/null +++ b/gcc-4.4.3/libjava/classpath/gnu/classpath/jdwp/event/filters/StepFilter.java @@ -0,0 +1,126 @@ +/* StepFilter.java -- a step filter + Copyright (C) 2005, 2007 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." + * + * This "filter" is not really a filter. It is simply a way to communicate + * stepping information in a convenient way between the JDWP backend and + * the virtual machine. + * + * Consequently, this "filter" always matches. + * + * @author Keith Seitz (keiths@redhat.com) + */ +public class StepFilter + implements IEventFilter +{ + private ThreadId _tid; + private int _size; + private int _depth; + + /** + * Constructs a new StepFilter + * + * @param tid ID of the thread in which to step + * @param size size of each step + * @param depth relative call stack limit + * @throws InvalidThreadException if thread is invalid + */ + public StepFilter (ThreadId tid, int size, int depth) + throws InvalidThreadException + { + if (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 gnu.classpath.jdwp.JdwpConstants.StepSize + */ + public int getSize () + { + return _size; + } + + /** + * Returns the relative call stack limit (into, over, out) + * + * @return how to step + * @see gnu.classpath.jdwp.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) + { + return true; + } +} diff --git a/gcc-4.4.3/libjava/classpath/gnu/classpath/jdwp/event/filters/ThreadOnlyFilter.java b/gcc-4.4.3/libjava/classpath/gnu/classpath/jdwp/event/filters/ThreadOnlyFilter.java new file mode 100644 index 000000000..bc1eab883 --- /dev/null +++ b/gcc-4.4.3/libjava/classpath/gnu/classpath/jdwp/event/filters/ThreadOnlyFilter.java @@ -0,0 +1,101 @@ +/* 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.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 (keiths@redhat.com) + */ +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 (Event.EVENT_THREAD); + if (thread != null) + { + Thread eventThread = (Thread) thread; + Thread myThread = (Thread) _tid.getReference().get (); + return (eventThread == myThread); + } + + return false; + } +} |