diff options
author | mark <mark@138bc75d-0d04-0410-961f-82ee72b054a4> | 2006-08-14 23:12:35 +0000 |
---|---|---|
committer | mark <mark@138bc75d-0d04-0410-961f-82ee72b054a4> | 2006-08-14 23:12:35 +0000 |
commit | ffde862e033a0825e1e9972a89c0f1f80b261a8e (patch) | |
tree | 97037d2c09c8384d80531f67ec36a01205df6bdb /libjava/classpath/gnu/classpath/jdwp | |
parent | b415ff10527e977c3758234fd930e2c027bfa17d (diff) | |
download | ppe42-gcc-ffde862e033a0825e1e9972a89c0f1f80b261a8e.tar.gz ppe42-gcc-ffde862e033a0825e1e9972a89c0f1f80b261a8e.zip |
2006-08-14 Mark Wielaard <mark@klomp.org>
Imported GNU Classpath 0.92
* HACKING: Add more importing hints. Update automake version
requirement.
* configure.ac (gconf-peer): New enable AC argument.
Add --disable-gconf-peer and --enable-default-preferences-peer
to classpath configure when gconf is disabled.
* scripts/makemake.tcl: Set gnu/java/util/prefs/gconf and
gnu/java/awt/dnd/peer/gtk to bc. Classify
gnu/java/security/Configuration.java as generated source file.
* gnu/java/lang/management/VMGarbageCollectorMXBeanImpl.java,
gnu/java/lang/management/VMMemoryPoolMXBeanImpl.java,
gnu/java/lang/management/VMClassLoadingMXBeanImpl.java,
gnu/java/lang/management/VMRuntimeMXBeanImpl.java,
gnu/java/lang/management/VMMemoryManagerMXBeanImpl.java,
gnu/java/lang/management/VMThreadMXBeanImpl.java,
gnu/java/lang/management/VMMemoryMXBeanImpl.java,
gnu/java/lang/management/VMCompilationMXBeanImpl.java: New VM stub
classes.
* java/lang/management/VMManagementFactory.java: Likewise.
* java/net/VMURLConnection.java: Likewise.
* gnu/java/nio/VMChannel.java: Likewise.
* java/lang/Thread.java (getState): Add stub implementation.
* java/lang/Class.java (isEnum): Likewise.
* java/lang/Class.h (isEnum): Likewise.
* gnu/awt/xlib/XToolkit.java (getClasspathTextLayoutPeer): Removed.
* javax/naming/spi/NamingManager.java: New override for StackWalker
functionality.
* configure, sources.am, Makefile.in, gcj/Makefile.in,
include/Makefile.in, testsuite/Makefile.in: Regenerated.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@116139 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libjava/classpath/gnu/classpath/jdwp')
25 files changed, 805 insertions, 72 deletions
diff --git a/libjava/classpath/gnu/classpath/jdwp/Jdwp.java b/libjava/classpath/gnu/classpath/jdwp/Jdwp.java index 7141214ef26..e63a9a353dd 100644 --- a/libjava/classpath/gnu/classpath/jdwp/Jdwp.java +++ b/libjava/classpath/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/libjava/classpath/gnu/classpath/jdwp/event/BreakpointEvent.java b/libjava/classpath/gnu/classpath/jdwp/event/BreakpointEvent.java index be429f4873a..abf280d6ec6 100644 --- a/libjava/classpath/gnu/classpath/jdwp/event/BreakpointEvent.java +++ b/libjava/classpath/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/libjava/classpath/gnu/classpath/jdwp/event/ClassPrepareEvent.java b/libjava/classpath/gnu/classpath/jdwp/event/ClassPrepareEvent.java index 22cede0c50a..5341daa42b5 100644 --- a/libjava/classpath/gnu/classpath/jdwp/event/ClassPrepareEvent.java +++ b/libjava/classpath/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/libjava/classpath/gnu/classpath/jdwp/event/ClassUnloadEvent.java b/libjava/classpath/gnu/classpath/jdwp/event/ClassUnloadEvent.java new file mode 100644 index 00000000000..4ba8bc80666 --- /dev/null +++ b/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/libjava/classpath/gnu/classpath/jdwp/event/Event.java b/libjava/classpath/gnu/classpath/jdwp/event/Event.java index 14e5b78fc14..e91108a61a8 100644 --- a/libjava/classpath/gnu/classpath/jdwp/event/Event.java +++ b/libjava/classpath/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/libjava/classpath/gnu/classpath/jdwp/event/EventManager.java b/libjava/classpath/gnu/classpath/jdwp/event/EventManager.java index eb0c3ddb7d2..54a7b08312d 100644 --- a/libjava/classpath/gnu/classpath/jdwp/event/EventManager.java +++ b/libjava/classpath/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/libjava/classpath/gnu/classpath/jdwp/event/ExceptionEvent.java b/libjava/classpath/gnu/classpath/jdwp/event/ExceptionEvent.java new file mode 100644 index 00000000000..1303c09be76 --- /dev/null +++ b/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 new Boolean(true); + else + return new 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/libjava/classpath/gnu/classpath/jdwp/event/MethodEntryEvent.java b/libjava/classpath/gnu/classpath/jdwp/event/MethodEntryEvent.java new file mode 100644 index 00000000000..40c0516c716 --- /dev/null +++ b/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/libjava/classpath/gnu/classpath/jdwp/event/MethodExitEvent.java b/libjava/classpath/gnu/classpath/jdwp/event/MethodExitEvent.java new file mode 100644 index 00000000000..ce03dd264e2 --- /dev/null +++ b/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/libjava/classpath/gnu/classpath/jdwp/event/SingleStepEvent.java b/libjava/classpath/gnu/classpath/jdwp/event/SingleStepEvent.java new file mode 100644 index 00000000000..cd69dd99d6b --- /dev/null +++ b/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/libjava/classpath/gnu/classpath/jdwp/event/ThreadEndEvent.java b/libjava/classpath/gnu/classpath/jdwp/event/ThreadEndEvent.java index 768b216de0c..c665428fb6a 100644 --- a/libjava/classpath/gnu/classpath/jdwp/event/ThreadEndEvent.java +++ b/libjava/classpath/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/libjava/classpath/gnu/classpath/jdwp/event/ThreadStartEvent.java b/libjava/classpath/gnu/classpath/jdwp/event/ThreadStartEvent.java index 2fa20791716..f9c507dfb16 100644 --- a/libjava/classpath/gnu/classpath/jdwp/event/ThreadStartEvent.java +++ b/libjava/classpath/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/libjava/classpath/gnu/classpath/jdwp/event/VmDeathEvent.java b/libjava/classpath/gnu/classpath/jdwp/event/VmDeathEvent.java index 160ef6acea1..a729bd47ec0 100644 --- a/libjava/classpath/gnu/classpath/jdwp/event/VmDeathEvent.java +++ b/libjava/classpath/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/libjava/classpath/gnu/classpath/jdwp/event/VmInitEvent.java b/libjava/classpath/gnu/classpath/jdwp/event/VmInitEvent.java index dd228e935cf..1ed63b24799 100644 --- a/libjava/classpath/gnu/classpath/jdwp/event/VmInitEvent.java +++ b/libjava/classpath/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/libjava/classpath/gnu/classpath/jdwp/event/filters/ClassMatchFilter.java b/libjava/classpath/gnu/classpath/jdwp/event/filters/ClassMatchFilter.java index 62a3a74fe54..a8984316957 100644 --- a/libjava/classpath/gnu/classpath/jdwp/event/filters/ClassMatchFilter.java +++ b/libjava/classpath/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/libjava/classpath/gnu/classpath/jdwp/event/filters/ClassOnlyFilter.java b/libjava/classpath/gnu/classpath/jdwp/event/filters/ClassOnlyFilter.java index e4bf06cf961..455cac6c04c 100644 --- a/libjava/classpath/gnu/classpath/jdwp/event/filters/ClassOnlyFilter.java +++ b/libjava/classpath/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/libjava/classpath/gnu/classpath/jdwp/event/filters/ExceptionOnlyFilter.java b/libjava/classpath/gnu/classpath/jdwp/event/filters/ExceptionOnlyFilter.java index cf6c0704daf..8bb56ed78f7 100644 --- a/libjava/classpath/gnu/classpath/jdwp/event/filters/ExceptionOnlyFilter.java +++ b/libjava/classpath/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/libjava/classpath/gnu/classpath/jdwp/event/filters/InstanceOnlyFilter.java b/libjava/classpath/gnu/classpath/jdwp/event/filters/InstanceOnlyFilter.java index 130749b4b8a..bda5b27d6c1 100644 --- a/libjava/classpath/gnu/classpath/jdwp/event/filters/InstanceOnlyFilter.java +++ b/libjava/classpath/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/libjava/classpath/gnu/classpath/jdwp/event/filters/ThreadOnlyFilter.java b/libjava/classpath/gnu/classpath/jdwp/event/filters/ThreadOnlyFilter.java index 2c7a0f1359e..bc1eab883d3 100644 --- a/libjava/classpath/gnu/classpath/jdwp/event/filters/ThreadOnlyFilter.java +++ b/libjava/classpath/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/libjava/classpath/gnu/classpath/jdwp/processor/ClassTypeCommandSet.java b/libjava/classpath/gnu/classpath/jdwp/processor/ClassTypeCommandSet.java index f60da7b7021..a3a7ca05e59 100644 --- a/libjava/classpath/gnu/classpath/jdwp/processor/ClassTypeCommandSet.java +++ b/libjava/classpath/gnu/classpath/jdwp/processor/ClassTypeCommandSet.java @@ -106,8 +106,12 @@ public class ClassTypeCommandSet Class clazz = refId.getType(); Class superClazz = clazz.getSuperclass(); - ReferenceTypeId clazzId = idMan.getReferenceTypeId(superClazz); - clazzId.write(os); + if (superClazz == null) { + os.writeLong(0L); + } else { + ReferenceTypeId clazzId = idMan.getReferenceTypeId(superClazz); + clazzId.write(os); + } } private void executeSetValues(ByteBuffer bb, DataOutputStream os) diff --git a/libjava/classpath/gnu/classpath/jdwp/processor/EventRequestCommandSet.java b/libjava/classpath/gnu/classpath/jdwp/processor/EventRequestCommandSet.java index e4b1b602ef5..59cfb94d39b 100644 --- a/libjava/classpath/gnu/classpath/jdwp/processor/EventRequestCommandSet.java +++ b/libjava/classpath/gnu/classpath/jdwp/processor/EventRequestCommandSet.java @@ -147,7 +147,7 @@ public class EventRequestCommandSet if (id == 0) refId = null; else - refId = idMan.readReferenceTypeId(bb); + refId = idMan.getReferenceType(id); boolean caught = (bb.get() == 0) ? false : true; boolean unCaught = (bb.get() == 0) ? false : true; filter = new ExceptionOnlyFilter(refId, caught, unCaught); diff --git a/libjava/classpath/gnu/classpath/jdwp/processor/PacketProcessor.java b/libjava/classpath/gnu/classpath/jdwp/processor/PacketProcessor.java index 9e281f217f2..4df3f472875 100644 --- a/libjava/classpath/gnu/classpath/jdwp/processor/PacketProcessor.java +++ b/libjava/classpath/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/libjava/classpath/gnu/classpath/jdwp/processor/ThreadGroupReferenceCommandSet.java b/libjava/classpath/gnu/classpath/jdwp/processor/ThreadGroupReferenceCommandSet.java index ba36251f665..103199a2b6e 100644 --- a/libjava/classpath/gnu/classpath/jdwp/processor/ThreadGroupReferenceCommandSet.java +++ b/libjava/classpath/gnu/classpath/jdwp/processor/ThreadGroupReferenceCommandSet.java @@ -103,8 +103,12 @@ public class ThreadGroupReferenceCommandSet ObjectId oid = idMan.readObjectId(bb); ThreadGroup group = (ThreadGroup) oid.getObject(); ThreadGroup parent = group.getParent(); - ObjectId parentId = idMan.getObjectId(parent); - parentId.write(os); + if (parent == null) { + os.writeLong(0L); + } else { + ObjectId parentId = idMan.getObjectId(parent); + parentId.write(os); + } } private void executeChildren(ByteBuffer bb, DataOutputStream os) diff --git a/libjava/classpath/gnu/classpath/jdwp/transport/JdwpConnection.java b/libjava/classpath/gnu/classpath/jdwp/transport/JdwpConnection.java index f008bbd00ca..82a2380bb7b 100644 --- a/libjava/classpath/gnu/classpath/jdwp/transport/JdwpConnection.java +++ b/libjava/classpath/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 diff --git a/libjava/classpath/gnu/classpath/jdwp/util/Location.java b/libjava/classpath/gnu/classpath/jdwp/util/Location.java index 005b12c2bb2..89e81e563a1 100644 --- a/libjava/classpath/gnu/classpath/jdwp/util/Location.java +++ b/libjava/classpath/gnu/classpath/jdwp/util/Location.java @@ -94,18 +94,40 @@ public class Location * @param os stream to write to * @throws IOException when an error occurs writing to the stream */ - public void write(DataOutputStream os) + public void write(DataOutputStream os) throws IOException { - VMIdManager idm = VMIdManager.getDefault(); - ClassReferenceTypeId crti = (ClassReferenceTypeId) - idm.getReferenceTypeId(method.getDeclaringClass()); - - crti.writeTagged(os); - method.writeId(os); - os.writeLong(index); + // check if this is an empty location + if (method != null) + { + VMIdManager idm = VMIdManager.getDefault(); + ClassReferenceTypeId crti = + (ClassReferenceTypeId) + idm.getReferenceTypeId(method.getDeclaringClass()); + + crti.writeTagged(os); + method.writeId(os); + os.writeLong(index); + } + else + { + os.writeByte(1); + os.writeLong((long) 0); + os.writeLong((long) 0); + os.writeLong((long) 0); + } } - + + /** + * Sets up an empty location + * + * @return new Location (setup as empty) + */ + public static Location getEmptyLocation() + { + return new Location(null, 0); + } + /** * Gets the method of this location * |