diff options
author | Guilhem Lavaux <guilhem@kaffe.org> | 2006-07-09 16:59:05 +0000 |
---|---|---|
committer | Guilhem Lavaux <guilhem@kaffe.org> | 2006-07-09 16:59:05 +0000 |
commit | 8f2887fc8c74aae0d541cbd59ea36c37d420267d (patch) | |
tree | adfecf70948384fcc6aa9cae41103dc4551d1b53 /gnu/classpath | |
parent | 4714fb23de2d811f49438611ac0d13ccd302e1ea (diff) | |
download | classpath-8f2887fc8c74aae0d541cbd59ea36c37d420267d.tar.gz |
2006-07-09 Guilhem Lavaux <guilhem@kaffe.org>
* Merged HEAD as of 2006-06-09 0:00.
Diffstat (limited to 'gnu/classpath')
25 files changed, 1130 insertions, 58 deletions
diff --git a/gnu/classpath/debug/TeeInputStream.java b/gnu/classpath/debug/TeeInputStream.java new file mode 100644 index 000000000..ef6b2ed3d --- /dev/null +++ b/gnu/classpath/debug/TeeInputStream.java @@ -0,0 +1,98 @@ +/* TeeInputStream.java + Copyright (C) 2006 Free Software Foundation, Inc. + +This file is a 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 of the License, 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; 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.debug; + +import java.io.*; + +/** + * An input stream that copies all its input to a byte sink. + * + * @author Chris Burdess + */ +public class TeeInputStream + extends InputStream +{ + + private final InputStream in; + private final OutputStream out; + + /** + * Constructs a tee input stream. + * @param in the underlying input stream + * @param out the output sink + */ + public TeeInputStream(InputStream in, OutputStream out) + { + this.in = in; + this.out = out; + } + + public int read() + throws IOException + { + int ret = in.read(); + out.write(ret); + out.flush(); + return ret; + } + + public int read(byte[] b, int off, int len) + throws IOException + { + int ret = in.read(b, off, len); + if (ret != -1) + { + out.write(b, off, ret); + out.flush(); + } + return ret; + } + + public void close() + throws IOException + { + in.close(); + out.close(); + } + + public final boolean markSupported() + { + return false; + } + +} diff --git a/gnu/classpath/debug/TeeOutputStream.java b/gnu/classpath/debug/TeeOutputStream.java new file mode 100644 index 000000000..cff60894a --- /dev/null +++ b/gnu/classpath/debug/TeeOutputStream.java @@ -0,0 +1,93 @@ +/* TeeOutputStream.java + Copyright (C) 2006 Free Software Foundation, Inc. + +This file is a 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 of the License, 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; 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.debug; + +import java.io.*; + +/** + * An output stream that copies all its output to an additional byte sink. + * + * @author Chris Burdess + */ +public class TeeOutputStream + extends OutputStream +{ + + private final OutputStream out; + private final OutputStream sink; + + /** + * Constructs a tee output stream. + * @param out the underlying output stream + * @param sink the output sink + */ + public TeeOutputStream(OutputStream out, OutputStream sink) + { + this.out = out; + this.sink = sink; + } + + public void write(int c) + throws IOException + { + out.write(c); + sink.write(c); + } + + public void write(byte[] b, int off, int len) + throws IOException + { + out.write(b, off, len); + sink.write(b, off, len); + } + + public void flush() + throws IOException + { + out.flush(); + sink.flush(); + } + + public void close() + throws IOException + { + out.close(); + sink.close(); + } + +} diff --git a/gnu/classpath/debug/TeeReader.java b/gnu/classpath/debug/TeeReader.java new file mode 100644 index 000000000..8fa742e21 --- /dev/null +++ b/gnu/classpath/debug/TeeReader.java @@ -0,0 +1,98 @@ +/* TeeReader.java + Copyright (C) 2006 Free Software Foundation, Inc. + +This file is a 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 of the License, 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; 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.debug; + +import java.io.*; + +/** + * A reader that copies all characters read to an output sink. + * + * @author Chris Burdess + */ +public class TeeReader + extends Reader +{ + + private final Reader in; + private final Writer out; + + /** + * Constructs a tee reader. + * @param in the input + * @param out the output sink + */ + public TeeReader(Reader in, Writer out) + { + this.in = in; + this.out = out; + } + + public int read() + throws IOException + { + int ret = in.read(); + out.write(ret); + out.flush(); + return ret; + } + + public int read(char[] b, int off, int len) + throws IOException + { + int ret = in.read(b, off, len); + if (ret != -1) + { + out.write(b, off, ret); + out.flush(); + } + return ret; + } + + public void close() + throws IOException + { + in.close(); + out.close(); + } + + public final boolean markSupported() + { + return false; + } + +} diff --git a/gnu/classpath/debug/TeeWriter.java b/gnu/classpath/debug/TeeWriter.java new file mode 100644 index 000000000..f226c2165 --- /dev/null +++ b/gnu/classpath/debug/TeeWriter.java @@ -0,0 +1,93 @@ +/* TeeWriter.java + Copyright (C) 2006 Free Software Foundation, Inc. + +This file is a 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 of the License, 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; 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.debug; + +import java.io.*; + +/** + * A writer that copies all its output to an additional character sink. + * + * @author Chris Burdess + */ +public class TeeWriter + extends Writer +{ + + private final Writer out; + private final Writer sink; + + /** + * Constructs a tee writer. + * @param out the underlying writer + * @param sink the output sink + */ + public TeeWriter(Writer out, Writer sink) + { + this.out = out; + this.sink = sink; + } + + public void write(int c) + throws IOException + { + out.write(c); + sink.write(c); + } + + public void write(char[] b, int off, int len) + throws IOException + { + out.write(b, off, len); + sink.write(b, off, len); + } + + public void flush() + throws IOException + { + out.flush(); + sink.flush(); + } + + public void close() + throws IOException + { + out.close(); + sink.close(); + } + +} diff --git a/gnu/classpath/jdwp/Jdwp.java b/gnu/classpath/jdwp/Jdwp.java index 7141214ef..e63a9a353 100644 --- a/gnu/classpath/jdwp/Jdwp.java +++ b/gnu/classpath/jdwp/Jdwp.java @@ -56,6 +56,9 @@ import java.util.HashMap; /** * Main interface from the virtual machine to the JDWP back-end. * + * The thread created by this class is only used for initialization. + * Once it exits, the JDWP backend is fully initialized. + * * @author Keith Seitz (keiths@redhat.com) */ public class Jdwp @@ -65,7 +68,8 @@ public class Jdwp private static Jdwp _instance = null; /** - * Are we debugging? + * Are we debugging? Only true if debugging + * *and* initialized. */ public static boolean isDebugging = false; @@ -89,13 +93,16 @@ public class Jdwp // A thread group for the JDWP threads private ThreadGroup _group; + // Initialization synchronization + private Object _initLock = new Object (); + private int _initCount = 0; + /** * constructor */ public Jdwp () { _shutdown = false; - isDebugging = true; _instance = this; } @@ -271,17 +278,52 @@ public class Jdwp } } + /** + * Allows subcomponents to specify that they are + * initialized. + * + * Subcomponents include JdwpConnection and PacketProcessor. + */ + public void subcomponentInitialized () + { + synchronized (_initLock) + { + ++_initCount; + _initLock.notify (); + } + } + public void run () { try { _doInitialization (); + + /* We need a little internal synchronization here, so that + when this thread dies, the back-end will be fully initialized, + ready to start servicing the VM and debugger. */ + synchronized (_initLock) + { + while (_initCount != 2) + _initLock.wait (); + } + _initLock = null; } catch (Throwable t) { System.out.println ("Exception in JDWP back-end: " + t); System.exit (1); } + + /* Force creation of the EventManager. If the event manager + has not been created when isDebugging is set, it is possible + that the VM will call Jdwp.notify (which uses EventManager) + while the EventManager is being created (or at least this is + a problem with gcj/gij). */ + EventManager.getDefault(); + + // Now we are finally ready and initialized + isDebugging = true; } // A helper function to process the configure string "-Xrunjdwp:..." diff --git a/gnu/classpath/jdwp/event/BreakpointEvent.java b/gnu/classpath/jdwp/event/BreakpointEvent.java index be429f487..abf280d6e 100644 --- a/gnu/classpath/jdwp/event/BreakpointEvent.java +++ b/gnu/classpath/jdwp/event/BreakpointEvent.java @@ -62,18 +62,23 @@ public class BreakpointEvent // 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) + public BreakpointEvent(Thread thread, Location loc, Object instance) { super(JdwpConstants.EventKind.BREAKPOINT); _thread = thread; _location = loc; + _instance = instance; } /** @@ -83,12 +88,14 @@ public class BreakpointEvent * @param type the type of parameter desired * @returns the desired parameter or null */ - public Object getParameter(Class type) + public Object getParameter(int type) { - if (type == ThreadId.class) + if (type == EVENT_THREAD) return _thread; - else if (type == Location.class) + else if (type == EVENT_LOCATION) return _location; + else if (type == EVENT_INSTANCE) + return _instance; return null; } diff --git a/gnu/classpath/jdwp/event/ClassPrepareEvent.java b/gnu/classpath/jdwp/event/ClassPrepareEvent.java index 22cede0c5..5341daa42 100644 --- a/gnu/classpath/jdwp/event/ClassPrepareEvent.java +++ b/gnu/classpath/jdwp/event/ClassPrepareEvent.java @@ -116,11 +116,11 @@ public class ClassPrepareEvent * @param type the type of parameter desired * @returns the desired parameter or <code>null</code> */ - public Object getParameter (Class type) + public Object getParameter (int type) { - if (type == ThreadId.class) + if (type == EVENT_THREAD) return _thread; - else if (type == ReferenceTypeId.class) + else if (type == EVENT_CLASS) return _class; return null; diff --git a/gnu/classpath/jdwp/event/ClassUnloadEvent.java b/gnu/classpath/jdwp/event/ClassUnloadEvent.java new file mode 100644 index 000000000..4ba8bc806 --- /dev/null +++ b/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/gnu/classpath/jdwp/event/Event.java b/gnu/classpath/jdwp/event/Event.java index 14e5b78fc..e91108a61 100644 --- a/gnu/classpath/jdwp/event/Event.java +++ b/gnu/classpath/jdwp/event/Event.java @@ -54,6 +54,41 @@ import java.io.IOException; */ 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; @@ -97,7 +132,7 @@ public abstract class Event * @returns the parameter (not the ID) or <code>null</code> if none is * is defined for this event */ - public abstract Object getParameter (Class type); + public abstract Object getParameter (int type); /** * Converts this event into to a JDWP packet diff --git a/gnu/classpath/jdwp/event/EventManager.java b/gnu/classpath/jdwp/event/EventManager.java index eb0c3ddb7..54a7b0831 100644 --- a/gnu/classpath/jdwp/event/EventManager.java +++ b/gnu/classpath/jdwp/event/EventManager.java @@ -1,5 +1,5 @@ /* EventManager.java -- event management and notification infrastructure - Copyright (C) 2005 Free Software Foundation + Copyright (C) 2005, 2006 Free Software Foundation This file is part of GNU Classpath. @@ -69,7 +69,7 @@ import java.util.Iterator; public class EventManager { // Single instance - private static EventManager _instance = new EventManager (); + private static EventManager _instance = null; // maps event (EVENT_*) to lists of EventRequests private Hashtable _requests = null; @@ -79,8 +79,11 @@ public class EventManager * * @return the event manager */ - public static EventManager getDefault () + public static EventManager getDefault() { + if (_instance == null) + _instance = new EventManager(); + return _instance; } diff --git a/gnu/classpath/jdwp/event/ExceptionEvent.java b/gnu/classpath/jdwp/event/ExceptionEvent.java new file mode 100644 index 000000000..a51e69c8f --- /dev/null +++ b/gnu/classpath/jdwp/event/ExceptionEvent.java @@ -0,0 +1,144 @@ +/* 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; + + /** + * 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, Object instance) + { + super(JdwpConstants.EventKind.EXCEPTION); + _exception = exception; + _thread = thread; + _location = location; + _catchLocation = catchLocation; + _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 _instance.getClass(); + else if (type == EVENT_EXCEPTION_CLASS) + return _exception.getClass(); + else if (type == EVENT_EXCEPTION_CAUGHT) + if (_catchLocation != null) + return new Boolean(true); + else + return new Boolean(false); + + 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); + ObjectId oid = idm.getObjectId(_exception); + + tid.write(outStream); + _location.write(outStream); + oid.writeTagged(outStream); + if(_catchLocation != null) + _catchLocation.write(outStream); + else + outStream.write(0); + } +} diff --git a/gnu/classpath/jdwp/event/MethodEntryEvent.java b/gnu/classpath/jdwp/event/MethodEntryEvent.java new file mode 100644 index 000000000..40c0516c7 --- /dev/null +++ b/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/gnu/classpath/jdwp/event/MethodExitEvent.java b/gnu/classpath/jdwp/event/MethodExitEvent.java new file mode 100644 index 000000000..ce03dd264 --- /dev/null +++ b/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/gnu/classpath/jdwp/event/SingleStepEvent.java b/gnu/classpath/jdwp/event/SingleStepEvent.java new file mode 100644 index 000000000..cd69dd99d --- /dev/null +++ b/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/gnu/classpath/jdwp/event/ThreadEndEvent.java b/gnu/classpath/jdwp/event/ThreadEndEvent.java index 768b216de..c665428fb 100644 --- a/gnu/classpath/jdwp/event/ThreadEndEvent.java +++ b/gnu/classpath/jdwp/event/ThreadEndEvent.java @@ -81,9 +81,9 @@ public class ThreadEndEvent * @param type the type of parameter desired * @returns the desired parameter or <code>null</code> */ - public Object getParameter (Class type) + public Object getParameter (int type) { - if (type == ThreadId.class) + if (type == EVENT_THREAD) return _thread; return null; diff --git a/gnu/classpath/jdwp/event/ThreadStartEvent.java b/gnu/classpath/jdwp/event/ThreadStartEvent.java index 2fa207917..f9c507dfb 100644 --- a/gnu/classpath/jdwp/event/ThreadStartEvent.java +++ b/gnu/classpath/jdwp/event/ThreadStartEvent.java @@ -86,9 +86,9 @@ public class ThreadStartEvent * @param type the type of parameter desired * @returns the desired parameter or <code>null</code> */ - public Object getParameter (Class type) + public Object getParameter (int type) { - if (type == ThreadId.class) + if (type == EVENT_THREAD) return _thread; return null; diff --git a/gnu/classpath/jdwp/event/VmDeathEvent.java b/gnu/classpath/jdwp/event/VmDeathEvent.java index 160ef6ace..a729bd47e 100644 --- a/gnu/classpath/jdwp/event/VmDeathEvent.java +++ b/gnu/classpath/jdwp/event/VmDeathEvent.java @@ -67,7 +67,7 @@ public class VmDeathEvent * @param type the type of parameter desired * @returns the desired parameter or <code>null</code> */ - public Object getParameter (Class type) + public Object getParameter (int type) { return null; } diff --git a/gnu/classpath/jdwp/event/VmInitEvent.java b/gnu/classpath/jdwp/event/VmInitEvent.java index dd228e935..1ed63b247 100644 --- a/gnu/classpath/jdwp/event/VmInitEvent.java +++ b/gnu/classpath/jdwp/event/VmInitEvent.java @@ -76,7 +76,7 @@ public class VmInitEvent * @param type the type of parameter desired * @returns the desired parameter or <code>null</code> */ - public Object getParameter (Class type) + public Object getParameter (int type) { return null; } diff --git a/gnu/classpath/jdwp/event/filters/ClassMatchFilter.java b/gnu/classpath/jdwp/event/filters/ClassMatchFilter.java index 62a3a74fe..a89843169 100644 --- a/gnu/classpath/jdwp/event/filters/ClassMatchFilter.java +++ b/gnu/classpath/jdwp/event/filters/ClassMatchFilter.java @@ -41,7 +41,6 @@ package gnu.classpath.jdwp.event.filters; import gnu.classpath.jdwp.event.Event; import gnu.classpath.jdwp.exception.InvalidStringException; -import gnu.classpath.jdwp.id.ReferenceTypeId; /** * An event filter which includes events matching a @@ -91,7 +90,7 @@ public class ClassMatchFilter */ public boolean matches (Event event) { - Object type = event.getParameter (ReferenceTypeId.class); + Object type = event.getParameter (Event.EVENT_CLASS); if (type != null) { Class eventClass = (Class) type; diff --git a/gnu/classpath/jdwp/event/filters/ClassOnlyFilter.java b/gnu/classpath/jdwp/event/filters/ClassOnlyFilter.java index e4bf06cf9..455cac6c0 100644 --- a/gnu/classpath/jdwp/event/filters/ClassOnlyFilter.java +++ b/gnu/classpath/jdwp/event/filters/ClassOnlyFilter.java @@ -87,7 +87,7 @@ public class ClassOnlyFilter */ public boolean matches (Event event) { - Object type = event.getParameter (ReferenceTypeId.class); + Object type = event.getParameter (Event.EVENT_CLASS); if (type != null) { try diff --git a/gnu/classpath/jdwp/event/filters/ExceptionOnlyFilter.java b/gnu/classpath/jdwp/event/filters/ExceptionOnlyFilter.java index cf6c0704d..8bb56ed78 100644 --- a/gnu/classpath/jdwp/event/filters/ExceptionOnlyFilter.java +++ b/gnu/classpath/jdwp/event/filters/ExceptionOnlyFilter.java @@ -1,5 +1,5 @@ -/* ExceptionOnlyFilter.java -- - Copyright (C) 2005 Free Software Foundation +/* ExceptionOnlyFilter.java -- filter for excetions by caught/uncaught and type + Copyright (C) 2005, 2006 Free Software Foundation This file is part of GNU Classpath. @@ -61,7 +61,7 @@ public class ExceptionOnlyFilter /** * Constructs a new ExceptionOnlyFilter * - * @param refId ID of the exception to report + * @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 @@ -70,8 +70,8 @@ public class ExceptionOnlyFilter boolean uncaught) throws InvalidClassException { - if (refId == null || refId.getReference().get () == null) - throw new InvalidClassException (refId.getId ()); + if (refId != null && refId.getReference().get() == null) + throw new InvalidClassException(refId.getId()); _refId = refId; _caught = caught; @@ -88,34 +88,36 @@ public class ExceptionOnlyFilter return _refId; } - /** - * Report caught exceptions? - * - * @return whether to report caught exceptions - */ - public boolean forCaught () - { - return _caught; - } - - /** - * Report uncaught exceptions? - * - * @return whether to report uncaught exceptions - */ - public boolean forUncaught () - { - return _uncaught; - } - + /** * Does the given event match the filter? - * - * @param event the <code>Event</code> to scrutinize + * + * @param event the <code>Event</code> to scrutinize */ - public boolean matches (Event event) + public boolean matches(Event event) { - // FIXME - throw new RuntimeException ("ExceptionOnlyFilter.matches not implemented"); + 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/gnu/classpath/jdwp/event/filters/InstanceOnlyFilter.java b/gnu/classpath/jdwp/event/filters/InstanceOnlyFilter.java index 130749b4b..bda5b27d6 100644 --- a/gnu/classpath/jdwp/event/filters/InstanceOnlyFilter.java +++ b/gnu/classpath/jdwp/event/filters/InstanceOnlyFilter.java @@ -89,7 +89,7 @@ public class InstanceOnlyFilter */ public boolean matches (Event event) { - Object eventInstance = event.getParameter (ObjectId.class); + Object eventInstance = event.getParameter (Event.EVENT_INSTANCE); if (eventInstance != null) { Object myInstance = _instance.getReference().get (); diff --git a/gnu/classpath/jdwp/event/filters/ThreadOnlyFilter.java b/gnu/classpath/jdwp/event/filters/ThreadOnlyFilter.java index 2c7a0f135..bc1eab883 100644 --- a/gnu/classpath/jdwp/event/filters/ThreadOnlyFilter.java +++ b/gnu/classpath/jdwp/event/filters/ThreadOnlyFilter.java @@ -65,7 +65,7 @@ public class ThreadOnlyFilter public ThreadOnlyFilter (ThreadId tid) throws InvalidThreadException { - if (tid.getReference().get () == null) + if (tid == null || tid.getReference().get () == null) throw new InvalidThreadException (tid.getId ()); _tid = tid; @@ -88,7 +88,7 @@ public class ThreadOnlyFilter */ public boolean matches (Event event) { - Object thread = event.getParameter (ThreadId.class); + Object thread = event.getParameter (Event.EVENT_THREAD); if (thread != null) { Thread eventThread = (Thread) thread; diff --git a/gnu/classpath/jdwp/processor/PacketProcessor.java b/gnu/classpath/jdwp/processor/PacketProcessor.java index 9e281f217..4df3f4728 100644 --- a/gnu/classpath/jdwp/processor/PacketProcessor.java +++ b/gnu/classpath/jdwp/processor/PacketProcessor.java @@ -1,6 +1,6 @@ /* PacketProcessor.java -- a thread which processes command packets from the debugger - Copyright (C) 2005 Free Software Foundation + Copyright (C) 2005, 2006 Free Software Foundation This file is part of GNU Classpath. @@ -137,6 +137,10 @@ public class PacketProcessor */ public Object run () { + // Notify initialization thread (gnu.classpath.jdwp.Jdwp) that + // the PacketProcessor thread is ready. + Jdwp.getDefault().subcomponentInitialized (); + try { while (!_shutdown) @@ -144,7 +148,7 @@ public class PacketProcessor _processOnePacket (); } } - catch (IOException ex) + catch (Exception ex) { ex.printStackTrace(); } diff --git a/gnu/classpath/jdwp/transport/JdwpConnection.java b/gnu/classpath/jdwp/transport/JdwpConnection.java index f008bbd00..82a2380bb 100644 --- a/gnu/classpath/jdwp/transport/JdwpConnection.java +++ b/gnu/classpath/jdwp/transport/JdwpConnection.java @@ -1,5 +1,5 @@ /* JdwpConnection.java -- A JDWP-speaking connection - Copyright (C) 2005 Free Software Foundation + Copyright (C) 2005, 2006 Free Software Foundation This file is part of GNU Classpath. @@ -165,6 +165,10 @@ public class JdwpConnection */ public void run () { + // Notify initialization thread (gnu.classpath.jdwp.Jdwp) that + // the JdwpConnection thread is ready. + Jdwp.getDefault().subcomponentInitialized (); + while (!_shutdown) { try |