# HG changeset patch # User sla # Date 1408973928 -7200 # Mon Aug 25 15:38:48 2014 +0200 # Node ID c4c37604679cd3a10744ad6e395b57f89578caad # Parent 6e125fc5592524edd126973a0ec4edb112fbac4c imported patch 8043981-remove-jpda diff --git a/make/CompileDemos.gmk b/make/CompileDemos.gmk --- a/make/CompileDemos.gmk +++ b/make/CompileDemos.gmk @@ -334,34 +334,6 @@ ################################################################################################## -$(JDK_OUTPUTDIR)/demo/jpda/com/sun/tools/example/README: \ - $(JDK_TOPDIR)/src/demo/share/jpda/com/sun/tools/example/README - $(call install-file) - $(CHMOD) -f ug+w $@ - -$(eval $(call SetupArchive,JPDA_JAR, \ - $(JDK_OUTPUTDIR)/demo/jpda/com/sun/tools/example/README, \ - SRCS := $(JDK_TOPDIR)/src/demo/share/jpda \ - $(JDK_TOPDIR)/src/jdk.jdi/share/classes \ - $(JDK_OUTPUTDIR)/demo/jpda/com/sun/tools/example, \ - INCLUDES := com/sun/tools/example README, \ - SUFFIXES := .java .html .jj README, \ - JAR := $(JDK_OUTPUTDIR)/demo/jpda/examples.jar, \ - MANIFEST := $(JDK_TOPDIR)/make/data/mainmanifest/manifest.mf, \ - EXTRA_MANIFEST_ATTR := Main-Class:$$(SPACE), \ - SKIP_METAINF := true)) - -$(eval $(call SetupZipArchive,JPDA_ZIP, \ - SRC := $(JDK_TOPDIR)/src/demo/share/jpda \ - $(JDK_TOPDIR)/src/jdk.jdi/share/classes, \ - INCLUDES := com/sun/tools/example, \ - SUFFIXES := .java .html .jj README, \ - ZIP := $(JDK_OUTPUTDIR)/demo/jpda/src.zip)) - -BUILD_DEMOS += $(JPDA_JAR) $(JPDA_ZIP) - -################################################################################################## - $(JDK_OUTPUTDIR)/demo/management/index.html: $(DEMO_SHARE_SRC)/management/index.html $(call install-file) $(CHMOD) -f ug+w $@ diff --git a/src/demo/share/jpda/com/sun/tools/example/README b/src/demo/share/jpda/com/sun/tools/example/README deleted file mode 100644 --- a/src/demo/share/jpda/com/sun/tools/example/README +++ /dev/null @@ -1,3 +0,0 @@ -Please refer to the documentation in: - - doc/index.html diff --git a/src/demo/share/jpda/com/sun/tools/example/debug/bdi/AccessWatchpointSpec.java b/src/demo/share/jpda/com/sun/tools/example/debug/bdi/AccessWatchpointSpec.java deleted file mode 100644 --- a/src/demo/share/jpda/com/sun/tools/example/debug/bdi/AccessWatchpointSpec.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code 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 - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * This source code is provided to illustrate the usage of a given feature - * or technique and has been deliberately simplified. Additional steps - * required for a production-quality application, such as security checks, - * input validation and proper error handling, might not be present in - * this sample code. - */ - - -package com.sun.tools.example.debug.bdi; - -import com.sun.jdi.*; - -public class AccessWatchpointSpec extends WatchpointSpec { - - AccessWatchpointSpec(EventRequestSpecList specs, - ReferenceTypeSpec refSpec, String fieldId) { - super(specs, refSpec, fieldId); - } - - /** - * The 'refType' is known to match. - */ - @Override - void resolve(ReferenceType refType) throws InvalidTypeException, - NoSuchFieldException { - if (!(refType instanceof ClassType)) { - throw new InvalidTypeException(); - } - Field field = refType.fieldByName(fieldId); - if (field == null) { - throw new NoSuchFieldException(fieldId); - } - setRequest(refType.virtualMachine().eventRequestManager() - .createAccessWatchpointRequest(field)); - } - - @Override - public boolean equals(Object obj) { - return (obj instanceof AccessWatchpointSpec) && super.equals(obj); - } -} diff --git a/src/demo/share/jpda/com/sun/tools/example/debug/bdi/AmbiguousMethodException.java b/src/demo/share/jpda/com/sun/tools/example/debug/bdi/AmbiguousMethodException.java deleted file mode 100644 --- a/src/demo/share/jpda/com/sun/tools/example/debug/bdi/AmbiguousMethodException.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code 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 - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * This source code is provided to illustrate the usage of a given feature - * or technique and has been deliberately simplified. Additional steps - * required for a production-quality application, such as security checks, - * input validation and proper error handling, might not be present in - * this sample code. - */ - - -package com.sun.tools.example.debug.bdi; - -public class AmbiguousMethodException extends Exception -{ - - private static final long serialVersionUID = 7793370943251707514L; - - public AmbiguousMethodException() - { - super(); - } - - public AmbiguousMethodException(String s) - { - super(s); - } -} diff --git a/src/demo/share/jpda/com/sun/tools/example/debug/bdi/BreakpointSpec.java b/src/demo/share/jpda/com/sun/tools/example/debug/bdi/BreakpointSpec.java deleted file mode 100644 --- a/src/demo/share/jpda/com/sun/tools/example/debug/bdi/BreakpointSpec.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code 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 - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * This source code is provided to illustrate the usage of a given feature - * or technique and has been deliberately simplified. Additional steps - * required for a production-quality application, such as security checks, - * input validation and proper error handling, might not be present in - * this sample code. - */ - - -package com.sun.tools.example.debug.bdi; - -public abstract class BreakpointSpec extends EventRequestSpec { - - BreakpointSpec(EventRequestSpecList specs, ReferenceTypeSpec refSpec) { - super(specs, refSpec); - } - - @Override - void notifySet(SpecListener listener, SpecEvent evt) { - listener.breakpointSet(evt); - } - - @Override - void notifyDeferred(SpecListener listener, SpecEvent evt) { - listener.breakpointDeferred(evt); - } - - @Override - void notifyResolved(SpecListener listener, SpecEvent evt) { - listener.breakpointResolved(evt); - } - - @Override - void notifyDeleted(SpecListener listener, SpecEvent evt) { - listener.breakpointDeleted(evt); - } - - @Override - void notifyError(SpecListener listener, SpecErrorEvent evt) { - listener.breakpointError(evt); - } -} diff --git a/src/demo/share/jpda/com/sun/tools/example/debug/bdi/ChildSession.java b/src/demo/share/jpda/com/sun/tools/example/debug/bdi/ChildSession.java deleted file mode 100644 --- a/src/demo/share/jpda/com/sun/tools/example/debug/bdi/ChildSession.java +++ /dev/null @@ -1,309 +0,0 @@ -/* - * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code 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 - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * This source code is provided to illustrate the usage of a given feature - * or technique and has been deliberately simplified. Additional steps - * required for a production-quality application, such as security checks, - * input validation and proper error handling, might not be present in - * this sample code. - */ - - -package com.sun.tools.example.debug.bdi; - -import com.sun.jdi.*; -import com.sun.jdi.connect.LaunchingConnector; -import com.sun.jdi.connect.Connector; -import com.sun.jdi.connect.VMStartException; -import com.sun.jdi.connect.IllegalConnectorArgumentsException; -import java.io.*; -import java.util.Map; -import javax.swing.SwingUtilities; - - -class ChildSession extends Session { - - private Process process; - - private PrintWriter in; - private BufferedReader out; - private BufferedReader err; - - private InputListener input; - private OutputListener output; - private OutputListener error; - - public ChildSession(ExecutionManager runtime, - String userVMArgs, String cmdLine, - InputListener input, - OutputListener output, - OutputListener error, - OutputListener diagnostics) { - this(runtime, getVM(diagnostics, userVMArgs, cmdLine), - input, output, error, diagnostics); - } - - public ChildSession(ExecutionManager runtime, - LaunchingConnector connector, - Map arguments, - InputListener input, - OutputListener output, - OutputListener error, - OutputListener diagnostics) { - this(runtime, generalGetVM(diagnostics, connector, arguments), - input, output, error, diagnostics); - } - - private ChildSession(ExecutionManager runtime, - VirtualMachine vm, - InputListener input, - OutputListener output, - OutputListener error, - OutputListener diagnostics) { - super(vm, runtime, diagnostics); - this.input = input; - this.output = output; - this.error = error; - } - - @Override - public boolean attach() { - - if (!connectToVMProcess()) { - diagnostics.putString("Could not launch VM"); - return false; - } - - /* - * Create a Thread that will retrieve and display any output. - * Needs to be high priority, else debugger may exit before - * it can be displayed. - */ - - //### Rename InputWriter and OutputReader classes - //### Thread priorities cribbed from ttydebug. Think about them. - - OutputReader outputReader = - new OutputReader("output reader", "output", - out, output, diagnostics); - outputReader.setPriority(Thread.MAX_PRIORITY-1); - outputReader.start(); - - OutputReader errorReader = - new OutputReader("error reader", "error", - err, error, diagnostics); - errorReader.setPriority(Thread.MAX_PRIORITY-1); - errorReader.start(); - - InputWriter inputWriter = - new InputWriter("input writer", in, input); - inputWriter.setPriority(Thread.MAX_PRIORITY-1); - inputWriter.start(); - - if (!super.attach()) { - if (process != null) { - process.destroy(); - process = null; - } - return false; - } - - //### debug - //System.out.println("IO after attach: "+ inputWriter + " " + outputReader + " "+ errorReader); - - return true; - } - - @Override - public void detach() { - - //### debug - //System.out.println("IO before detach: "+ inputWriter + " " + outputReader + " "+ errorReader); - - super.detach(); - - /* - inputWriter.quit(); - outputReader.quit(); - errorReader.quit(); - */ - - if (process != null) { - process.destroy(); - process = null; - } - - } - - /** - * Launch child java interpreter, return host:port - */ - - static private void dumpStream(OutputListener diagnostics, - InputStream stream) throws IOException { - BufferedReader in = - new BufferedReader(new InputStreamReader(stream)); - String line; - while ((line = in.readLine()) != null) { - diagnostics.putString(line); - } - } - - static private void dumpFailedLaunchInfo(OutputListener diagnostics, - Process process) { - try { - dumpStream(diagnostics, process.getErrorStream()); - dumpStream(diagnostics, process.getInputStream()); - } catch (IOException e) { - diagnostics.putString("Unable to display process output: " + - e.getMessage()); - } - } - - static private VirtualMachine getVM(OutputListener diagnostics, - String userVMArgs, - String cmdLine) { - VirtualMachineManager manager = Bootstrap.virtualMachineManager(); - LaunchingConnector connector = manager.defaultConnector(); - Map arguments = connector.defaultArguments(); - arguments.get("options").setValue(userVMArgs); - arguments.get("main").setValue(cmdLine); - return generalGetVM(diagnostics, connector, arguments); - } - - static private VirtualMachine generalGetVM(OutputListener diagnostics, - LaunchingConnector connector, - Map arguments) { - VirtualMachine vm = null; - try { - diagnostics.putString("Starting child."); - vm = connector.launch(arguments); - } catch (IOException ioe) { - diagnostics.putString("Unable to start child: " + ioe.getMessage()); - } catch (IllegalConnectorArgumentsException icae) { - diagnostics.putString("Unable to start child: " + icae.getMessage()); - } catch (VMStartException vmse) { - diagnostics.putString("Unable to start child: " + vmse.getMessage() + '\n'); - dumpFailedLaunchInfo(diagnostics, vmse.process()); - } - return vm; - } - - private boolean connectToVMProcess() { - if (vm == null) { - return false; - } - process = vm.process(); - in = new PrintWriter(new OutputStreamWriter(process.getOutputStream())); - //### Note small buffer sizes! - out = new BufferedReader(new InputStreamReader(process.getInputStream()), 1); - err = new BufferedReader(new InputStreamReader(process.getErrorStream()), 1); - return true; - } - - /** - * Threads to handle application input/output. - */ - - private static class OutputReader extends Thread { - - private String streamName; - private BufferedReader stream; - private OutputListener output; - private OutputListener diagnostics; - private boolean running = true; - private char[] buffer = new char[512]; - - OutputReader(String threadName, - String streamName, - BufferedReader stream, - OutputListener output, - OutputListener diagnostics) { - super(threadName); - this.streamName = streamName; - this.stream = stream; - this.output = output; - this.diagnostics = diagnostics; - } - - @Override - public void run() { - try { - int count; - while (running && (count = stream.read(buffer, 0, 512)) != -1) { - if (count > 0) { - // Run in Swing event dispatcher thread. - final String chars = new String(buffer, 0, count); - SwingUtilities.invokeLater(new Runnable() { - @Override - public void run() { - output.putString(chars); - } - }); - } - //### Should we sleep briefly here? - } - } catch (IOException e) { - // Run in Swing event dispatcher thread. - SwingUtilities.invokeLater(new Runnable() { - @Override - public void run() { - diagnostics.putString("IO error reading " + - streamName + - " stream of child java interpreter"); - } - }); - } - } - } - - private static class InputWriter extends Thread { - - private PrintWriter stream; - private InputListener input; - private boolean running = true; - - InputWriter(String threadName, - PrintWriter stream, - InputListener input) { - super(threadName); - this.stream = stream; - this.input = input; - } - - @Override - public void run() { - String line; - while (running) { - line = input.getLine(); - stream.println(line); - // Should not be needed for println above! - stream.flush(); - } - } - } - -} diff --git a/src/demo/share/jpda/com/sun/tools/example/debug/bdi/EvaluationException.java b/src/demo/share/jpda/com/sun/tools/example/debug/bdi/EvaluationException.java deleted file mode 100644 --- a/src/demo/share/jpda/com/sun/tools/example/debug/bdi/EvaluationException.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code 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 - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * This source code is provided to illustrate the usage of a given feature - * or technique and has been deliberately simplified. Additional steps - * required for a production-quality application, such as security checks, - * input validation and proper error handling, might not be present in - * this sample code. - */ - - -package com.sun.tools.example.debug.bdi; - -public class EvaluationException extends Exception { - - private static final long serialVersionUID = 4947109680354951694L; -} diff --git a/src/demo/share/jpda/com/sun/tools/example/debug/bdi/EventRequestSpec.java b/src/demo/share/jpda/com/sun/tools/example/debug/bdi/EventRequestSpec.java deleted file mode 100644 --- a/src/demo/share/jpda/com/sun/tools/example/debug/bdi/EventRequestSpec.java +++ /dev/null @@ -1,168 +0,0 @@ -/* - * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code 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 - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * This source code is provided to illustrate the usage of a given feature - * or technique and has been deliberately simplified. Additional steps - * required for a production-quality application, such as security checks, - * input validation and proper error handling, might not be present in - * this sample code. - */ - - -package com.sun.tools.example.debug.bdi; - -import com.sun.jdi.*; -import com.sun.jdi.request.EventRequest; - -abstract public class EventRequestSpec { - - static final int STATUS_UNRESOLVED = 1; - static final int STATUS_RESOLVED = 2; - static final int STATUS_ERROR = 3; - - static final Object specPropertyKey = "spec"; - - final EventRequestSpecList specs; - final ReferenceTypeSpec refSpec; - EventRequest request = null; - - int status = STATUS_UNRESOLVED; - - EventRequestSpec(EventRequestSpecList specs, ReferenceTypeSpec refSpec) { - this.specs = specs; - this.refSpec = refSpec; - } - - void setRequest(EventRequest request) { - this.request = request; - request.putProperty(specPropertyKey, this); - request.enable(); - } - - /** - * The 'refType' is known to match. - */ - abstract void resolve(ReferenceType refType) throws Exception; - - abstract void notifySet(SpecListener listener, SpecEvent evt); - abstract void notifyDeferred(SpecListener listener, SpecEvent evt); - abstract void notifyResolved(SpecListener listener, SpecEvent evt); - abstract void notifyDeleted(SpecListener listener, SpecEvent evt); - abstract void notifyError(SpecListener listener, SpecErrorEvent evt); - - /** - * The 'refType' is known to match. - */ - void resolveNotify(ReferenceType refType) { - try { - resolve(refType); - status = STATUS_RESOLVED; - specs.notifyResolved(this); - } catch(Exception exc) { - status = STATUS_ERROR; - specs.notifyError(this, exc); - } - } - - /** - * See if 'refType' matches and resolve. - */ - void attemptResolve(ReferenceType refType) { - if (!isResolved() && refSpec.matches(refType)) { - resolveNotify(refType); - } - } - - void attemptImmediateResolve(VirtualMachine vm) { - // try to resolve immediately - for (ReferenceType refType : vm.allClasses()) { - if (refSpec.matches(refType)) { - try { - resolve(refType); - status = STATUS_RESOLVED; - specs.notifySet(this); - } catch(Exception exc) { - status = STATUS_ERROR; - specs.notifyError(this, exc); - } - return; - } - } - specs.notifyDeferred(this); - } - - public EventRequest getEventRequest() { - return request; - } - - /** - * @return true if this spec has been resolved. - */ - public boolean isResolved() { - return status == STATUS_RESOLVED; - } - - /** - * @return true if this spec has not yet been resolved. - */ - public boolean isUnresolved() { - return status == STATUS_UNRESOLVED; - } - - /** - * @return true if this spec is unresolvable due to error. - */ - public boolean isErroneous() { - return status == STATUS_ERROR; - } - - public String getStatusString() { - switch (status) { - case STATUS_RESOLVED: - return "resolved"; - case STATUS_UNRESOLVED: - return "deferred"; - case STATUS_ERROR: - return "erroneous"; - } - return "unknown"; - } - - boolean isJavaIdentifier(String s) { - return Utils.isJavaIdentifier(s); - } - - public String errorMessageFor(Exception e) { - if (e instanceof IllegalArgumentException) { - return ("Invalid command syntax"); - } else if (e instanceof RuntimeException) { - // A runtime exception that we were not expecting - throw (RuntimeException)e; - } else { - return ("Internal error; unable to set" + this); - } - } -} diff --git a/src/demo/share/jpda/com/sun/tools/example/debug/bdi/EventRequestSpecList.java b/src/demo/share/jpda/com/sun/tools/example/debug/bdi/EventRequestSpecList.java deleted file mode 100644 --- a/src/demo/share/jpda/com/sun/tools/example/debug/bdi/EventRequestSpecList.java +++ /dev/null @@ -1,187 +0,0 @@ -/* - * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code 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 - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * This source code is provided to illustrate the usage of a given feature - * or technique and has been deliberately simplified. Additional steps - * required for a production-quality application, such as security checks, - * input validation and proper error handling, might not be present in - * this sample code. - */ - - -package com.sun.tools.example.debug.bdi; - -import com.sun.jdi.*; -import com.sun.jdi.request.*; - -import java.util.*; - -class EventRequestSpecList { - - // all specs - private List eventRequestSpecs = Collections.synchronizedList( - new ArrayList()); - - final ExecutionManager runtime; - - EventRequestSpecList(ExecutionManager runtime) { - this.runtime = runtime; - } - - /** - * Resolve all deferred eventRequests waiting for 'refType'. - */ - void resolve(ReferenceType refType) { - synchronized(eventRequestSpecs) { - for (EventRequestSpec spec : eventRequestSpecs) { - spec.attemptResolve(refType); - } - } - } - - void install(EventRequestSpec ers, VirtualMachine vm) { - synchronized (eventRequestSpecs) { - eventRequestSpecs.add(ers); - } - if (vm != null) { - ers.attemptImmediateResolve(vm); - } - } - - BreakpointSpec - createClassLineBreakpoint(String classPattern, int line) { - ReferenceTypeSpec refSpec = - new PatternReferenceTypeSpec(classPattern); - return new LineBreakpointSpec(this, refSpec, line); - } - - BreakpointSpec - createSourceLineBreakpoint(String sourceName, int line) { - ReferenceTypeSpec refSpec = - new SourceNameReferenceTypeSpec(sourceName, line); - return new LineBreakpointSpec(this, refSpec, line); - } - - BreakpointSpec - createMethodBreakpoint(String classPattern, - String methodId, List methodArgs) { - ReferenceTypeSpec refSpec = - new PatternReferenceTypeSpec(classPattern); - return new MethodBreakpointSpec(this, refSpec, - methodId, methodArgs); - } - - ExceptionSpec - createExceptionIntercept(String classPattern, - boolean notifyCaught, - boolean notifyUncaught) { - ReferenceTypeSpec refSpec = - new PatternReferenceTypeSpec(classPattern); - return new ExceptionSpec(this, refSpec, - notifyCaught, notifyUncaught); - } - - AccessWatchpointSpec - createAccessWatchpoint(String classPattern, String fieldId) { - ReferenceTypeSpec refSpec = - new PatternReferenceTypeSpec(classPattern); - return new AccessWatchpointSpec(this, refSpec, fieldId); - } - - ModificationWatchpointSpec - createModificationWatchpoint(String classPattern, String fieldId) { - ReferenceTypeSpec refSpec = - new PatternReferenceTypeSpec(classPattern); - return new ModificationWatchpointSpec(this, refSpec, fieldId); - } - - void delete(EventRequestSpec ers) { - EventRequest request = ers.getEventRequest(); - synchronized (eventRequestSpecs) { - eventRequestSpecs.remove(ers); - } - if (request != null) { - request.virtualMachine().eventRequestManager() - .deleteEventRequest(request); - } - notifyDeleted(ers); - //### notify delete - here? - } - - List eventRequestSpecs() { - // We need to make a copy to avoid synchronization problems - synchronized (eventRequestSpecs) { - return new ArrayList(eventRequestSpecs); - } - } - - // -------- notify routines -------------------- - - @SuppressWarnings("unchecked") - private Vector specListeners() { - return (Vector)runtime.specListeners.clone(); - } - - void notifySet(EventRequestSpec spec) { - Vector l = specListeners(); - SpecEvent evt = new SpecEvent(spec); - for (int i = 0; i < l.size(); i++) { - spec.notifySet(l.elementAt(i), evt); - } - } - - void notifyDeferred(EventRequestSpec spec) { - Vector l = specListeners(); - SpecEvent evt = new SpecEvent(spec); - for (int i = 0; i < l.size(); i++) { - spec.notifyDeferred(l.elementAt(i), evt); - } - } - - void notifyDeleted(EventRequestSpec spec) { - Vector l = specListeners(); - SpecEvent evt = new SpecEvent(spec); - for (int i = 0; i < l.size(); i++) { - spec.notifyDeleted(l.elementAt(i), evt); - } - } - - void notifyResolved(EventRequestSpec spec) { - Vector l = specListeners(); - SpecEvent evt = new SpecEvent(spec); - for (int i = 0; i < l.size(); i++) { - spec.notifyResolved(l.elementAt(i), evt); - } - } - - void notifyError(EventRequestSpec spec, Exception exc) { - Vector l = specListeners(); - SpecErrorEvent evt = new SpecErrorEvent(spec, exc); - for (int i = 0; i < l.size(); i++) { - spec.notifyError(l.elementAt(i), evt); - } - } -} diff --git a/src/demo/share/jpda/com/sun/tools/example/debug/bdi/ExceptionSpec.java b/src/demo/share/jpda/com/sun/tools/example/debug/bdi/ExceptionSpec.java deleted file mode 100644 --- a/src/demo/share/jpda/com/sun/tools/example/debug/bdi/ExceptionSpec.java +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code 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 - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * This source code is provided to illustrate the usage of a given feature - * or technique and has been deliberately simplified. Additional steps - * required for a production-quality application, such as security checks, - * input validation and proper error handling, might not be present in - * this sample code. - */ - - -package com.sun.tools.example.debug.bdi; - -import com.sun.jdi.ReferenceType; - -public class ExceptionSpec extends EventRequestSpec { - - boolean notifyCaught; - boolean notifyUncaught; - - ExceptionSpec(EventRequestSpecList specs, ReferenceTypeSpec refSpec, - boolean notifyCaught, boolean notifyUncaught) - { - super(specs, refSpec); - this.notifyCaught = notifyCaught; - this.notifyUncaught = notifyUncaught; - } - - @Override - void notifySet(SpecListener listener, SpecEvent evt) { - listener.exceptionInterceptSet(evt); - } - - @Override - void notifyDeferred(SpecListener listener, SpecEvent evt) { - listener.exceptionInterceptDeferred(evt); - } - - @Override - void notifyResolved(SpecListener listener, SpecEvent evt) { - listener.exceptionInterceptResolved(evt); - } - - @Override - void notifyDeleted(SpecListener listener, SpecEvent evt) { - listener.exceptionInterceptDeleted(evt); - } - - @Override - void notifyError(SpecListener listener, SpecErrorEvent evt) { - listener.exceptionInterceptError(evt); - } - - /** - * The 'refType' is known to match. - */ - @Override - void resolve(ReferenceType refType) { - setRequest(refType.virtualMachine().eventRequestManager() - .createExceptionRequest(refType, - notifyCaught, notifyUncaught)); - } - - @Override - public int hashCode() { - return refSpec.hashCode(); - } - - @Override - public boolean equals(Object obj) { - if (obj instanceof ExceptionSpec) { - ExceptionSpec es = (ExceptionSpec)obj; - - return refSpec.equals(es.refSpec); - } else { - return false; - } - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder("exception catch "); - sb.append(refSpec.toString()); - return sb.toString(); - } -} diff --git a/src/demo/share/jpda/com/sun/tools/example/debug/bdi/ExecutionManager.java b/src/demo/share/jpda/com/sun/tools/example/debug/bdi/ExecutionManager.java deleted file mode 100644 --- a/src/demo/share/jpda/com/sun/tools/example/debug/bdi/ExecutionManager.java +++ /dev/null @@ -1,824 +0,0 @@ -/* - * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code 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 - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * This source code is provided to illustrate the usage of a given feature - * or technique and has been deliberately simplified. Additional steps - * required for a production-quality application, such as security checks, - * input validation and proper error handling, might not be present in - * this sample code. - */ - - -package com.sun.tools.example.debug.bdi; - -import com.sun.jdi.*; -import com.sun.jdi.request.*; -import com.sun.jdi.connect.*; -import com.sun.tools.example.debug.expr.ExpressionParser; -import com.sun.tools.example.debug.expr.ParseException; - -import java.io.*; -import java.util.*; - -import com.sun.tools.example.debug.event.*; - -import javax.swing.SwingUtilities; - -/** - * Move this towards being only state and functionality - * that spans across Sessions (and thus VMs). - */ -public class ExecutionManager { - - private Session session; - - /** - * Get/set JDI trace mode. - */ - int traceMode = VirtualMachine.TRACE_NONE; - - ////////////////// Listener registration ////////////////// - - // Session Listeners - - ArrayList sessionListeners = new ArrayList(); - - public void addSessionListener(SessionListener listener) { - sessionListeners.add(listener); - } - - public void removeSessionListener(SessionListener listener) { - sessionListeners.remove(listener); - } - - // Spec Listeners - - ArrayList specListeners = new ArrayList(); - - public void addSpecListener(SpecListener cl) { - specListeners.add(cl); - } - - public void removeSpecListener(SpecListener cl) { - specListeners.remove(cl); - } - - // JDI Listeners - - ArrayList jdiListeners = new ArrayList(); - - /** - * Adds a JDIListener - */ - public void addJDIListener(JDIListener jl) { - jdiListeners.add(jl); - } - - /** - * Adds a JDIListener - at the specified position - */ - public void addJDIListener(int index, JDIListener jl) { - jdiListeners.add(index, jl); - } - - /** - * Removes a JDIListener - */ - public void removeJDIListener(JDIListener jl) { - jdiListeners.remove(jl); - } - - // App Echo Listeners - - private ArrayList appEchoListeners = new ArrayList(); - - public void addApplicationEchoListener(OutputListener l) { - appEchoListeners.add(l); - } - - public void removeApplicationEchoListener(OutputListener l) { - appEchoListeners.remove(l); - } - - // App Output Listeners - - private ArrayList appOutputListeners = new ArrayList(); - - public void addApplicationOutputListener(OutputListener l) { - appOutputListeners.add(l); - } - - public void removeApplicationOutputListener(OutputListener l) { - appOutputListeners.remove(l); - } - - // App Error Listeners - - private ArrayList appErrorListeners = new ArrayList(); - - public void addApplicationErrorListener(OutputListener l) { - appErrorListeners.add(l); - } - - public void removeApplicationErrorListener(OutputListener l) { - appErrorListeners.remove(l); - } - - // Diagnostic Listeners - - private ArrayList diagnosticsListeners = new ArrayList(); - - public void addDiagnosticsListener(OutputListener l) { - diagnosticsListeners.add(l); - } - - public void removeDiagnosticsListener(OutputListener l) { - diagnosticsListeners.remove(l); - } - - /////////// End Listener Registration ////////////// - - //### We probably don't want this public - public VirtualMachine vm() { - return session == null ? null : session.vm; - } - - void ensureActiveSession() throws NoSessionException { - if (session == null) { - throw new NoSessionException(); - } - } - - public EventRequestManager eventRequestManager() { - return vm() == null ? null : vm().eventRequestManager(); - } - - /** - * Get JDI trace mode. - */ - public int getTraceMode(int mode) { - return traceMode; - } - - /** - * Set JDI trace mode. - */ - public void setTraceMode(int mode) { - traceMode = mode; - if (session != null) { - session.setTraceMode(mode); - } - } - - /** - * Determine if VM is interrupted, i.e, present and not running. - */ - public boolean isInterrupted() /* should: throws NoSessionException */ { -// ensureActiveSession(); - return session.interrupted; - } - - /** - * Return a list of ReferenceType objects for all - * currently loaded classes and interfaces. - * Array types are not returned. - */ - public List allClasses() throws NoSessionException { - ensureActiveSession(); - return vm().allClasses(); - } - - /** - * Return a ReferenceType object for the currently - * loaded class or interface whose fully-qualified - * class name is specified, else return null if there - * is none. - * - * In general, we must return a list of types, because - * multiple class loaders could have loaded a class - * with the same fully-qualified name. - */ - public List findClassesByName(String name) throws NoSessionException { - ensureActiveSession(); - return vm().classesByName(name); - } - - /** - * Return a list of ReferenceType objects for all - * currently loaded classes and interfaces whose name - * matches the given pattern. The pattern syntax is - * open to some future revision, but currently consists - * of a fully-qualified class name in which the first - * component may optionally be a "*" character, designating - * an arbitrary prefix. - */ - public List findClassesMatchingPattern(String pattern) - throws NoSessionException { - ensureActiveSession(); - List result = new ArrayList(); //### Is default size OK? - if (pattern.startsWith("*.")) { - // Wildcard matches any leading package name. - pattern = pattern.substring(1); - for (ReferenceType type : vm().allClasses()) { - if (type.name().endsWith(pattern)) { - result.add(type); - } - } - return result; - } else { - // It's a class name. - return vm().classesByName(pattern); - } - } - - /* - * Return a list of ThreadReference objects corresponding - * to the threads that are currently active in the VM. - * A thread is removed from the list just before the - * thread terminates. - */ - - public List allThreads() throws NoSessionException { - ensureActiveSession(); - return vm().allThreads(); - } - - /* - * Return a list of ThreadGroupReference objects corresponding - * to the top-level threadgroups that are currently active in the VM. - * Note that a thread group may be empty, or contain no threads as - * descendents. - */ - - public List topLevelThreadGroups() throws NoSessionException { - ensureActiveSession(); - return vm().topLevelThreadGroups(); - } - - /* - * Return the system threadgroup. - */ - - public ThreadGroupReference systemThreadGroup() - throws NoSessionException { - ensureActiveSession(); - return vm().topLevelThreadGroups().get(0); - } - - /* - * Evaluate an expression. - */ - - public Value evaluate(final StackFrame f, String expr) - throws ParseException, - InvocationException, - InvalidTypeException, - ClassNotLoadedException, - NoSessionException, - IncompatibleThreadStateException { - ExpressionParser.GetFrame frameGetter = null; - ensureActiveSession(); - if (f != null) { - frameGetter = new ExpressionParser.GetFrame() { - @Override - public StackFrame get() /* throws IncompatibleThreadStateException */ { - return f; - } - }; - } - return ExpressionParser.evaluate(expr, vm(), frameGetter); - } - - - /* - * Start a new VM. - */ - - public void run(boolean suspended, - String vmArgs, - String className, - String args) throws VMLaunchFailureException { - - endSession(); - - //### Set a breakpoint on 'main' method. - //### Would be cleaner if we could just bring up VM already suspended. - if (suspended) { - //### Set breakpoint at 'main(java.lang.String[])'. - List argList = new ArrayList(1); - argList.add("java.lang.String[]"); - createMethodBreakpoint(className, "main", argList); - } - - String cmdLine = className + " " + args; - - startSession(new ChildSession(this, vmArgs, cmdLine, - appInput, appOutput, appError, - diagnostics)); - } - - /* - * Attach to an existing VM. - */ - public void attach(String portName) throws VMLaunchFailureException { - endSession(); - - //### Changes made here for connectors have broken the - //### the 'Session' abstraction. The 'Session.attach()' - //### method is intended to encapsulate all of the various - //### ways in which session start-up can fail. (maddox 12/18/98) - - /* - * Now that attaches and launches both go through Connectors, - * it may be worth creating a new subclass of Session for - * attach sessions. - */ - VirtualMachineManager mgr = Bootstrap.virtualMachineManager(); - AttachingConnector connector = mgr.attachingConnectors().get(0); - Map arguments = connector.defaultArguments(); - arguments.get("port").setValue(portName); - - Session newSession = internalAttach(connector, arguments); - if (newSession != null) { - startSession(newSession); - } - } - - private Session internalAttach(AttachingConnector connector, - Map arguments) { - try { - VirtualMachine vm = connector.attach(arguments); - return new Session(vm, this, diagnostics); - } catch (IOException ioe) { - diagnostics.putString("\n Unable to attach to target VM: " + - ioe.getMessage()); - } catch (IllegalConnectorArgumentsException icae) { - diagnostics.putString("\n Invalid connector arguments: " + - icae.getMessage()); - } - return null; - } - - private Session internalListen(ListeningConnector connector, - Map arguments) { - try { - VirtualMachine vm = connector.accept(arguments); - return new Session(vm, this, diagnostics); - } catch (IOException ioe) { - diagnostics.putString( - "\n Unable to accept connection to target VM: " + - ioe.getMessage()); - } catch (IllegalConnectorArgumentsException icae) { - diagnostics.putString("\n Invalid connector arguments: " + - icae.getMessage()); - } - return null; - } - - /* - * Connect via user specified arguments - * @return true on success - */ - public boolean explictStart(Connector connector, Map arguments) - throws VMLaunchFailureException { - Session newSession = null; - - endSession(); - - if (connector instanceof LaunchingConnector) { - // we were launched, use ChildSession - newSession = new ChildSession(this, (LaunchingConnector)connector, - arguments, - appInput, appOutput, appError, - diagnostics); - } else if (connector instanceof AttachingConnector) { - newSession = internalAttach((AttachingConnector)connector, - arguments); - } else if (connector instanceof ListeningConnector) { - newSession = internalListen((ListeningConnector)connector, - arguments); - } else { - diagnostics.putString("\n Unknown connector: " + connector); - } - if (newSession != null) { - startSession(newSession); - } - return newSession != null; - } - - /* - * Detach from VM. If VM was started by debugger, terminate it. - */ - public void detach() throws NoSessionException { - ensureActiveSession(); - endSession(); - } - - private void startSession(Session s) throws VMLaunchFailureException { - if (!s.attach()) { - throw new VMLaunchFailureException(); - } - session = s; - EventRequestManager em = vm().eventRequestManager(); - ClassPrepareRequest classPrepareRequest = em.createClassPrepareRequest(); - //### We must allow the deferred breakpoints to be resolved before - //### we continue executing the class. We could optimize if there - //### were no deferred breakpoints outstanding for a particular class. - //### Can we do this with JDI? - classPrepareRequest.setSuspendPolicy(EventRequest.SUSPEND_ALL); - classPrepareRequest.enable(); - ClassUnloadRequest classUnloadRequest = em.createClassUnloadRequest(); - classUnloadRequest.setSuspendPolicy(EventRequest.SUSPEND_NONE); - classUnloadRequest.enable(); - ThreadStartRequest threadStartRequest = em.createThreadStartRequest(); - threadStartRequest.setSuspendPolicy(EventRequest.SUSPEND_NONE); - threadStartRequest.enable(); - ThreadDeathRequest threadDeathRequest = em.createThreadDeathRequest(); - threadDeathRequest.setSuspendPolicy(EventRequest.SUSPEND_NONE); - threadDeathRequest.enable(); - ExceptionRequest exceptionRequest = - em.createExceptionRequest(null, false, true); - exceptionRequest.setSuspendPolicy(EventRequest.SUSPEND_ALL); - exceptionRequest.enable(); - validateThreadInfo(); - session.interrupted = true; - notifySessionStart(); - } - - void endSession() { - if (session != null) { - session.detach(); - session = null; - invalidateThreadInfo(); - notifySessionDeath(); - } - } - - /* - * Suspend all VM activity. - */ - - public void interrupt() throws NoSessionException { - ensureActiveSession(); - vm().suspend(); - //### Is it guaranteed that the interrupt has happened? - validateThreadInfo(); - session.interrupted = true; - notifyInterrupted(); - } - - /* - * Resume interrupted VM. - */ - - public void go() throws NoSessionException, VMNotInterruptedException { - ensureActiveSession(); - invalidateThreadInfo(); - session.interrupted = false; - notifyContinued(); - vm().resume(); - } - - /* - * Stepping. - */ - void clearPreviousStep(ThreadReference thread) { - /* - * A previous step may not have completed on this thread; - * if so, it gets removed here. - */ - EventRequestManager mgr = vm().eventRequestManager(); - for (StepRequest request : mgr.stepRequests()) { - if (request.thread().equals(thread)) { - mgr.deleteEventRequest(request); - break; - } - } - } - - private void generalStep(ThreadReference thread, int size, int depth) - throws NoSessionException { - ensureActiveSession(); - invalidateThreadInfo(); - session.interrupted = false; - notifyContinued(); - - clearPreviousStep(thread); - EventRequestManager reqMgr = vm().eventRequestManager(); - StepRequest request = reqMgr.createStepRequest(thread, - size, depth); - // We want just the next step event and no others - request.addCountFilter(1); - request.enable(); - vm().resume(); - } - - public void stepIntoInstruction(ThreadReference thread) - throws NoSessionException { - generalStep(thread, StepRequest.STEP_MIN, StepRequest.STEP_INTO); - } - - public void stepOverInstruction(ThreadReference thread) - throws NoSessionException { - generalStep(thread, StepRequest.STEP_MIN, StepRequest.STEP_OVER); - } - - public void stepIntoLine(ThreadReference thread) - throws NoSessionException, - AbsentInformationException { - generalStep(thread, StepRequest.STEP_LINE, StepRequest.STEP_INTO); - } - - public void stepOverLine(ThreadReference thread) - throws NoSessionException, - AbsentInformationException { - generalStep(thread, StepRequest.STEP_LINE, StepRequest.STEP_OVER); - } - - public void stepOut(ThreadReference thread) - throws NoSessionException { - generalStep(thread, StepRequest.STEP_MIN, StepRequest.STEP_OUT); - } - - /* - * Thread control. - */ - - public void suspendThread(ThreadReference thread) throws NoSessionException { - ensureActiveSession(); - thread.suspend(); - } - - public void resumeThread(ThreadReference thread) throws NoSessionException { - ensureActiveSession(); - thread.resume(); - } - - public void stopThread(ThreadReference thread) throws NoSessionException { - ensureActiveSession(); - //### Need an exception now. Which one to use? - //thread.stop(); - } - - /* - * ThreadInfo objects -- Allow query of thread status and stack. - */ - - private List threadInfoList = new LinkedList(); - //### Should be weak! (in the value, not the key) - private HashMap threadInfoMap = new HashMap(); - - public ThreadInfo threadInfo(ThreadReference thread) { - if (session == null || thread == null) { - return null; - } - ThreadInfo info = threadInfoMap.get(thread); - if (info == null) { - //### Should not hardcode initial frame count and prefetch here! - //info = new ThreadInfo(thread, 10, 10); - info = new ThreadInfo(thread); - if (session.interrupted) { - info.validate(); - } - threadInfoList.add(info); - threadInfoMap.put(thread, info); - } - return info; - } - - void validateThreadInfo() { - session.interrupted = true; - for (ThreadInfo threadInfo : threadInfoList) { - threadInfo.validate(); - } - } - - private void invalidateThreadInfo() { - if (session != null) { - session.interrupted = false; - for (ThreadInfo threadInfo : threadInfoList) { - threadInfo.invalidate(); - } - } - } - - void removeThreadInfo(ThreadReference thread) { - ThreadInfo info = threadInfoMap.get(thread); - if (info != null) { - info.invalidate(); - threadInfoMap.remove(thread); - threadInfoList.remove(info); - } - } - - /* - * Listen for Session control events. - */ - - private void notifyInterrupted() { - ArrayList l = new ArrayList(sessionListeners); - EventObject evt = new EventObject(this); - for (int i = 0; i < l.size(); i++) { - l.get(i).sessionInterrupt(evt); - } - } - - private void notifyContinued() { - ArrayList l = new ArrayList(sessionListeners); - EventObject evt = new EventObject(this); - for (int i = 0; i < l.size(); i++) { - l.get(i).sessionContinue(evt); - } - } - - private void notifySessionStart() { - ArrayList l = new ArrayList(sessionListeners); - EventObject evt = new EventObject(this); - for (int i = 0; i < l.size(); i++) { - l.get(i).sessionStart(evt); - } - } - - private void notifySessionDeath() { -/*** noop for now - ArrayList l = new ArrayList(sessionListeners); - EventObject evt = new EventObject(this); - for (int i = 0; i < l.size(); i++) { - ((SessionListener)l.get(i)).sessionDeath(evt); - } -****/ - } - - /* - * Listen for input and output requests from the application - * being debugged. These are generated only when the debuggee - * is spawned as a child of the debugger. - */ - - private Object inputLock = new Object(); - private LinkedList inputBuffer = new LinkedList(); - - private void resetInputBuffer() { - synchronized (inputLock) { - inputBuffer = new LinkedList(); - } - } - - public void sendLineToApplication(String line) { - synchronized (inputLock) { - inputBuffer.addFirst(line); - inputLock.notifyAll(); - } - } - - private InputListener appInput = new InputListener() { - @Override - public String getLine() { - // Don't allow reader to be interrupted -- catch and retry. - String line = null; - while (line == null) { - synchronized (inputLock) { - try { - while (inputBuffer.size() < 1) { - inputLock.wait(); - } - line = inputBuffer.removeLast(); - } catch (InterruptedException e) {} - } - } - // We must not be holding inputLock here, as the listener - // that we call to echo a line might call us re-entrantly - // to provide another line of input. - // Run in Swing event dispatcher thread. - final String input = line; - SwingUtilities.invokeLater(new Runnable() { - @Override - public void run() { - echoInputLine(input); - } - }); - return line; - } - }; - - private static String newline = System.getProperty("line.separator"); - - private void echoInputLine(String line) { - ArrayList l = new ArrayList(appEchoListeners); - for (int i = 0; i < l.size(); i++) { - OutputListener ol = l.get(i); - ol.putString(line); - ol.putString(newline); - } - } - - private OutputListener appOutput = new OutputListener() { - @Override - public void putString(String string) { - ArrayList l = new ArrayList(appEchoListeners); - for (int i = 0; i < l.size(); i++) { - l.get(i).putString(string); - } - } - }; - - private OutputListener appError = new OutputListener() { - @Override - public void putString(String string) { - ArrayList l = new ArrayList(appEchoListeners); - for (int i = 0; i < l.size(); i++) { - l.get(i).putString(string); - } - } - }; - - private OutputListener diagnostics = new OutputListener() { - @Override - public void putString(String string) { - ArrayList l = new ArrayList(diagnosticsListeners); - for (int i = 0; i < l.size(); i++) { - l.get(i).putString(string); - } - } - }; - - ///////////// Spec Request Creation/Deletion/Query /////////// - - private EventRequestSpecList specList = new EventRequestSpecList(this); - - public BreakpointSpec - createSourceLineBreakpoint(String sourceName, int line) { - return specList.createSourceLineBreakpoint(sourceName, line); - } - - public BreakpointSpec - createClassLineBreakpoint(String classPattern, int line) { - return specList.createClassLineBreakpoint(classPattern, line); - } - - public BreakpointSpec - createMethodBreakpoint(String classPattern, - String methodId, List methodArgs) { - return specList.createMethodBreakpoint(classPattern, - methodId, methodArgs); - } - - public ExceptionSpec - createExceptionIntercept(String classPattern, - boolean notifyCaught, - boolean notifyUncaught) { - return specList.createExceptionIntercept(classPattern, - notifyCaught, - notifyUncaught); - } - - public AccessWatchpointSpec - createAccessWatchpoint(String classPattern, String fieldId) { - return specList.createAccessWatchpoint(classPattern, fieldId); - } - - public ModificationWatchpointSpec - createModificationWatchpoint(String classPattern, String fieldId) { - return specList.createModificationWatchpoint(classPattern, - fieldId); - } - - public void delete(EventRequestSpec spec) { - specList.delete(spec); - } - - void resolve(ReferenceType refType) { - specList.resolve(refType); - } - - public void install(EventRequestSpec spec) { - specList.install(spec, vm()); - } - - public List eventRequestSpecs() { - return specList.eventRequestSpecs(); - } -} diff --git a/src/demo/share/jpda/com/sun/tools/example/debug/bdi/FrameIndexOutOfBoundsException.java b/src/demo/share/jpda/com/sun/tools/example/debug/bdi/FrameIndexOutOfBoundsException.java deleted file mode 100644 --- a/src/demo/share/jpda/com/sun/tools/example/debug/bdi/FrameIndexOutOfBoundsException.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code 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 - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * This source code is provided to illustrate the usage of a given feature - * or technique and has been deliberately simplified. Additional steps - * required for a production-quality application, such as security checks, - * input validation and proper error handling, might not be present in - * this sample code. - */ - - -package com.sun.tools.example.debug.bdi; - -public class FrameIndexOutOfBoundsException extends IndexOutOfBoundsException { - - private static final long serialVersionUID = -4870148107027371437L; -} diff --git a/src/demo/share/jpda/com/sun/tools/example/debug/bdi/InputListener.java b/src/demo/share/jpda/com/sun/tools/example/debug/bdi/InputListener.java deleted file mode 100644 --- a/src/demo/share/jpda/com/sun/tools/example/debug/bdi/InputListener.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code 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 - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * This source code is provided to illustrate the usage of a given feature - * or technique and has been deliberately simplified. Additional steps - * required for a production-quality application, such as security checks, - * input validation and proper error handling, might not be present in - * this sample code. - */ - - -package com.sun.tools.example.debug.bdi; - -public interface InputListener { - String getLine(); -} diff --git a/src/demo/share/jpda/com/sun/tools/example/debug/bdi/JDIEventSource.java b/src/demo/share/jpda/com/sun/tools/example/debug/bdi/JDIEventSource.java deleted file mode 100644 --- a/src/demo/share/jpda/com/sun/tools/example/debug/bdi/JDIEventSource.java +++ /dev/null @@ -1,193 +0,0 @@ -/* - * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code 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 - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * This source code is provided to illustrate the usage of a given feature - * or technique and has been deliberately simplified. Additional steps - * required for a production-quality application, such as security checks, - * input validation and proper error handling, might not be present in - * this sample code. - */ - - -package com.sun.tools.example.debug.bdi; - -import com.sun.jdi.*; -import com.sun.jdi.event.*; - -import com.sun.tools.example.debug.event.*; - -import javax.swing.SwingUtilities; - -/** - */ -class JDIEventSource extends Thread { - - private /*final*/ EventQueue queue; - private /*final*/ Session session; - private /*final*/ ExecutionManager runtime; - private final JDIListener firstListener = new FirstListener(); - - private boolean wantInterrupt; //### Hack - - /** - * Create event source. - */ - JDIEventSource(Session session) { - super("JDI Event Set Dispatcher"); - this.session = session; - this.runtime = session.runtime; - this.queue = session.vm.eventQueue(); - } - - @Override - public void run() { - try { - runLoop(); - } catch (Exception exc) { - //### Do something different for InterruptedException??? - // just exit - } - session.running = false; - } - - private void runLoop() throws InterruptedException { - AbstractEventSet es; - do { - EventSet jdiEventSet = queue.remove(); - es = AbstractEventSet.toSpecificEventSet(jdiEventSet); - session.interrupted = es.suspendedAll(); - dispatchEventSet(es); - } while(!(es instanceof VMDisconnectEventSet)); - } - - //### Gross foul hackery! - private void dispatchEventSet(final AbstractEventSet es) { - SwingUtilities.invokeLater(new Runnable() { - @Override - public void run() { - boolean interrupted = es.suspendedAll(); - es.notify(firstListener); - boolean wantInterrupt = JDIEventSource.this.wantInterrupt; - for (JDIListener jl : session.runtime.jdiListeners) { - es.notify(jl); - } - if (interrupted && !wantInterrupt) { - session.interrupted = false; - //### Catch here is a hack - try { - session.vm.resume(); - } catch (VMDisconnectedException ee) {} - } - if (es instanceof ThreadDeathEventSet) { - ThreadReference t = ((ThreadDeathEventSet)es).getThread(); - session.runtime.removeThreadInfo(t); - } - } - }); - } - - private void finalizeEventSet(AbstractEventSet es) { - if (session.interrupted && !wantInterrupt) { - session.interrupted = false; - //### Catch here is a hack - try { - session.vm.resume(); - } catch (VMDisconnectedException ee) {} - } - if (es instanceof ThreadDeathEventSet) { - ThreadReference t = ((ThreadDeathEventSet)es).getThread(); - session.runtime.removeThreadInfo(t); - } - } - - //### This is a Hack, deal with it - private class FirstListener implements JDIListener { - - @Override - public void accessWatchpoint(AccessWatchpointEventSet e) { - session.runtime.validateThreadInfo(); - wantInterrupt = true; - } - - @Override - public void classPrepare(ClassPrepareEventSet e) { - wantInterrupt = false; - runtime.resolve(e.getReferenceType()); - } - - @Override - public void classUnload(ClassUnloadEventSet e) { - wantInterrupt = false; - } - - @Override - public void exception(ExceptionEventSet e) { - wantInterrupt = true; - } - - @Override - public void locationTrigger(LocationTriggerEventSet e) { - session.runtime.validateThreadInfo(); - wantInterrupt = true; - } - - @Override - public void modificationWatchpoint(ModificationWatchpointEventSet e) { - session.runtime.validateThreadInfo(); - wantInterrupt = true; - } - - @Override - public void threadDeath(ThreadDeathEventSet e) { - wantInterrupt = false; - } - - @Override - public void threadStart(ThreadStartEventSet e) { - wantInterrupt = false; - } - - @Override - public void vmDeath(VMDeathEventSet e) { - //### Should have some way to notify user - //### that VM died before the session ended. - wantInterrupt = false; - } - - @Override - public void vmDisconnect(VMDisconnectEventSet e) { - //### Notify user? - wantInterrupt = false; - session.runtime.endSession(); - } - - @Override - public void vmStart(VMStartEventSet e) { - //### Do we need to do anything with it? - wantInterrupt = false; - } - } -} diff --git a/src/demo/share/jpda/com/sun/tools/example/debug/bdi/LineBreakpointSpec.java b/src/demo/share/jpda/com/sun/tools/example/debug/bdi/LineBreakpointSpec.java deleted file mode 100644 --- a/src/demo/share/jpda/com/sun/tools/example/debug/bdi/LineBreakpointSpec.java +++ /dev/null @@ -1,130 +0,0 @@ -/* - * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code 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 - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * This source code is provided to illustrate the usage of a given feature - * or technique and has been deliberately simplified. Additional steps - * required for a production-quality application, such as security checks, - * input validation and proper error handling, might not be present in - * this sample code. - */ - - -package com.sun.tools.example.debug.bdi; - -import com.sun.jdi.*; -import java.util.List; - -public class LineBreakpointSpec extends BreakpointSpec { - int lineNumber; - - LineBreakpointSpec(EventRequestSpecList specs, - ReferenceTypeSpec refSpec, int lineNumber) { - super(specs, refSpec); - this.lineNumber = lineNumber; - } - - /** - * The 'refType' is known to match. - */ - @Override - void resolve(ReferenceType refType) throws InvalidTypeException, - LineNotFoundException { - if (!(refType instanceof ClassType)) { - throw new InvalidTypeException(); - } - Location location = location((ClassType)refType); - setRequest(refType.virtualMachine().eventRequestManager() - .createBreakpointRequest(location)); - } - - private Location location(ClassType clazz) throws - LineNotFoundException { - Location location = null; - try { - List locs = clazz.locationsOfLine(lineNumber()); - if (locs.size() == 0) { - throw new LineNotFoundException(); - } - // TODO handle multiple locations - location = locs.get(0); - if (location.method() == null) { - throw new LineNotFoundException(); - } - } catch (AbsentInformationException e) { - /* - * TO DO: throw something more specific, or allow - * AbsentInfo exception to pass through. - */ - throw new LineNotFoundException(); - } - return location; - } - - public int lineNumber() { - return lineNumber; - } - - @Override - public int hashCode() { - return refSpec.hashCode() + lineNumber; - } - - @Override - public boolean equals(Object obj) { - if (obj instanceof LineBreakpointSpec) { - LineBreakpointSpec breakpoint = (LineBreakpointSpec)obj; - - return refSpec.equals(breakpoint.refSpec) && - (lineNumber == breakpoint.lineNumber); - } else { - return false; - } - } - - @Override - public String errorMessageFor(Exception e) { - if (e instanceof LineNotFoundException) { - return ("No code at line " + lineNumber() + " in " + refSpec); - } else if (e instanceof InvalidTypeException) { - return ("Breakpoints can be located only in classes. " + - refSpec + " is an interface or array"); - } else { - return super.errorMessageFor( e); - } - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder("breakpoint "); - sb.append(refSpec.toString()); - sb.append(':'); - sb.append(lineNumber); - sb.append(" ("); - sb.append(getStatusString()); - sb.append(')'); - return sb.toString(); - } -} diff --git a/src/demo/share/jpda/com/sun/tools/example/debug/bdi/LineNotFoundException.java b/src/demo/share/jpda/com/sun/tools/example/debug/bdi/LineNotFoundException.java deleted file mode 100644 --- a/src/demo/share/jpda/com/sun/tools/example/debug/bdi/LineNotFoundException.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code 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 - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * This source code is provided to illustrate the usage of a given feature - * or technique and has been deliberately simplified. Additional steps - * required for a production-quality application, such as security checks, - * input validation and proper error handling, might not be present in - * this sample code. - */ - - -package com.sun.tools.example.debug.bdi; - -public class LineNotFoundException extends Exception -{ - - private static final long serialVersionUID = -5630418117861587582L; - - public LineNotFoundException() - { - super(); - } - - public LineNotFoundException(String s) - { - super(s); - } -} diff --git a/src/demo/share/jpda/com/sun/tools/example/debug/bdi/MalformedMemberNameException.java b/src/demo/share/jpda/com/sun/tools/example/debug/bdi/MalformedMemberNameException.java deleted file mode 100644 --- a/src/demo/share/jpda/com/sun/tools/example/debug/bdi/MalformedMemberNameException.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code 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 - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * This source code is provided to illustrate the usage of a given feature - * or technique and has been deliberately simplified. Additional steps - * required for a production-quality application, such as security checks, - * input validation and proper error handling, might not be present in - * this sample code. - */ - - -package com.sun.tools.example.debug.bdi; - -class MalformedMemberNameException extends Exception { - - private static final long serialVersionUID = -7726664097374844485L; - - public MalformedMemberNameException() { - super(); - } - - public MalformedMemberNameException(String s) { - super(s); - } -} diff --git a/src/demo/share/jpda/com/sun/tools/example/debug/bdi/MethodBreakpointSpec.java b/src/demo/share/jpda/com/sun/tools/example/debug/bdi/MethodBreakpointSpec.java deleted file mode 100644 --- a/src/demo/share/jpda/com/sun/tools/example/debug/bdi/MethodBreakpointSpec.java +++ /dev/null @@ -1,346 +0,0 @@ -/* - * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code 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 - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * This source code is provided to illustrate the usage of a given feature - * or technique and has been deliberately simplified. Additional steps - * required for a production-quality application, such as security checks, - * input validation and proper error handling, might not be present in - * this sample code. - */ - - -package com.sun.tools.example.debug.bdi; - -import com.sun.jdi.*; -import java.util.ArrayList; -import java.util.List; - -public class MethodBreakpointSpec extends BreakpointSpec { - String methodId; - List methodArgs; - - MethodBreakpointSpec(EventRequestSpecList specs, - ReferenceTypeSpec refSpec, - String methodId, List methodArgs) { - super(specs, refSpec); - this.methodId = methodId; - this.methodArgs = methodArgs; - } - - /** - * The 'refType' is known to match. - */ - @Override - void resolve(ReferenceType refType) throws MalformedMemberNameException, - AmbiguousMethodException, - InvalidTypeException, - NoSuchMethodException, - NoSessionException { - if (!isValidMethodName(methodId)) { - throw new MalformedMemberNameException(methodId); - } - if (!(refType instanceof ClassType)) { - throw new InvalidTypeException(); - } - Location location = location((ClassType)refType); - setRequest(refType.virtualMachine().eventRequestManager() - .createBreakpointRequest(location)); - } - - private Location location(ClassType clazz) throws - AmbiguousMethodException, - NoSuchMethodException, - NoSessionException { - Method method = findMatchingMethod(clazz); - Location location = method.location(); - return location; - } - - public String methodName() { - return methodId; - } - - public List methodArgs() { - return methodArgs; - } - - @Override - public int hashCode() { - return refSpec.hashCode() + - ((methodId != null) ? methodId.hashCode() : 0) + - ((methodArgs != null) ? methodArgs.hashCode() : 0); - } - - @Override - public boolean equals(Object obj) { - if (obj instanceof MethodBreakpointSpec) { - MethodBreakpointSpec breakpoint = (MethodBreakpointSpec)obj; - - return methodId.equals(breakpoint.methodId) && - methodArgs.equals(breakpoint.methodArgs) && - refSpec.equals(breakpoint.refSpec); - } else { - return false; - } - } - - @Override - public String errorMessageFor(Exception e) { - if (e instanceof AmbiguousMethodException) { - return ("Method " + methodName() + " is overloaded; specify arguments"); - /* - * TO DO: list the methods here - */ - } else if (e instanceof NoSuchMethodException) { - return ("No method " + methodName() + " in " + refSpec); - } else if (e instanceof InvalidTypeException) { - return ("Breakpoints can be located only in classes. " + - refSpec + " is an interface or array"); - } else { - return super.errorMessageFor( e); - } - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder("breakpoint "); - sb.append(refSpec.toString()); - sb.append('.'); - sb.append(methodId); - if (methodArgs != null) { - boolean first = true; - sb.append('('); - for (String name : methodArgs) { - if (!first) { - sb.append(','); - } - sb.append(name); - first = false; - } - sb.append(")"); - } - sb.append(" ("); - sb.append(getStatusString()); - sb.append(')'); - return sb.toString(); - } - - private boolean isValidMethodName(String s) { - return isJavaIdentifier(s) || - s.equals("") || - s.equals(""); - } - - /* - * Compare a method's argument types with a Vector of type names. - * Return true if each argument type has a name identical to the - * corresponding string in the vector (allowing for varargs) - * and if the number of arguments in the method matches the - * number of names passed - */ - private boolean compareArgTypes(Method method, List nameList) { - List argTypeNames = method.argumentTypeNames(); - - // If argument counts differ, we can stop here - if (argTypeNames.size() != nameList.size()) { - return false; - } - - // Compare each argument type's name - int nTypes = argTypeNames.size(); - for (int i = 0; i < nTypes; ++i) { - String comp1 = argTypeNames.get(i); - String comp2 = nameList.get(i); - if (! comp1.equals(comp2)) { - /* - * We have to handle varargs. EG, the - * method's last arg type is xxx[] - * while the nameList contains xxx... - * Note that the nameList can also contain - * xxx[] in which case we don't get here. - */ - if (i != nTypes - 1 || - !method.isVarArgs() || - !comp2.endsWith("...")) { - return false; - } - /* - * The last types differ, it is a varargs - * method and the nameList item is varargs. - * We just have to compare the type names, eg, - * make sure we don't have xxx[] for the method - * arg type and yyy... for the nameList item. - */ - int comp1Length = comp1.length(); - if (comp1Length + 1 != comp2.length()) { - // The type names are different lengths - return false; - } - // We know the two type names are the same length - if (!comp1.regionMatches(0, comp2, 0, comp1Length - 2)) { - return false; - } - // We do have xxx[] and xxx... as the last param type - return true; - } - } - - return true; - } - - private VirtualMachine vm() { - return request.virtualMachine(); - } - - /** - * Remove unneeded spaces and expand class names to fully - * qualified names, if necessary and possible. - */ - private String normalizeArgTypeName(String name) throws NoSessionException { - /* - * Separate the type name from any array modifiers, - * stripping whitespace after the name ends. - */ - int i = 0; - StringBuilder typePart = new StringBuilder(); - StringBuilder arrayPart = new StringBuilder(); - name = name.trim(); - int nameLength = name.length(); - /* - * For varargs, there can be spaces before the ... but not - * within the ... So, we will just ignore the ... - * while stripping blanks. - */ - boolean isVarArgs = name.endsWith("..."); - if (isVarArgs) { - nameLength -= 3; - } - - while (i < nameLength) { - char c = name.charAt(i); - if (Character.isWhitespace(c) || c == '[') { - break; // name is complete - } - typePart.append(c); - i++; - } - while (i < nameLength) { - char c = name.charAt(i); - if ( (c == '[') || (c == ']')) { - arrayPart.append(c); - } else if (!Character.isWhitespace(c)) { - throw new IllegalArgumentException( - "Invalid argument type name"); - - } - i++; - } - - name = typePart.toString(); - - /* - * When there's no sign of a package name already, - * try to expand the - * the name to a fully qualified class name - */ - if ((name.indexOf('.') == -1) || name.startsWith("*.")) { - try { - List refs = specs.runtime.findClassesMatchingPattern(name); - if (refs.size() > 0) { //### ambiguity??? - name = ((ReferenceType)(refs.get(0))).name(); - } - } catch (IllegalArgumentException e) { - // We'll try the name as is - } - } - name += arrayPart.toString(); - if (isVarArgs) { - name += "..."; - } - return name; - } - - /* - * Attempt an unambiguous match of the method name and - * argument specification to a method. If no arguments - * are specified, the method must not be overloaded. - * Otherwise, the argument types much match exactly - */ - private Method findMatchingMethod(ClassType clazz) - throws AmbiguousMethodException, - NoSuchMethodException, - NoSessionException { - - // Normalize the argument string once before looping below. - List argTypeNames = null; - if (methodArgs() != null) { - argTypeNames = new ArrayList(methodArgs().size()); - for (String name : methodArgs()) { - name = normalizeArgTypeName(name); - argTypeNames.add(name); - } - } - - // Check each method in the class for matches - Method firstMatch = null; // first method with matching name - Method exactMatch = null; // (only) method with same name & sig - int matchCount = 0; // > 1 implies overload - for (Method candidate : clazz.methods()) { - if (candidate.name().equals(methodName())) { - matchCount++; - - // Remember the first match in case it is the only one - if (matchCount == 1) { - firstMatch = candidate; - } - - // If argument types were specified, check against candidate - if ((argTypeNames != null) - && compareArgTypes(candidate, argTypeNames) == true) { - exactMatch = candidate; - break; - } - } - } - - // Determine method for breakpoint - Method method = null; - if (exactMatch != null) { - // Name and signature match - method = exactMatch; - } else if ((argTypeNames == null) && (matchCount > 0)) { - // At least one name matched and no arg types were specified - if (matchCount == 1) { - method = firstMatch; // Only one match; safe to use it - } else { - throw new AmbiguousMethodException(); - } - } else { - throw new NoSuchMethodException(methodName()); - } - return method; - } -} diff --git a/src/demo/share/jpda/com/sun/tools/example/debug/bdi/MethodNotFoundException.java b/src/demo/share/jpda/com/sun/tools/example/debug/bdi/MethodNotFoundException.java deleted file mode 100644 --- a/src/demo/share/jpda/com/sun/tools/example/debug/bdi/MethodNotFoundException.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code 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 - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * This source code is provided to illustrate the usage of a given feature - * or technique and has been deliberately simplified. Additional steps - * required for a production-quality application, such as security checks, - * input validation and proper error handling, might not be present in - * this sample code. - */ - - -package com.sun.tools.example.debug.bdi; - -public class MethodNotFoundException extends Exception -{ - private static final long serialVersionUID = -2064968107599632609L; - - public MethodNotFoundException() - { - super(); - } - - public MethodNotFoundException(String s) - { - super(s); - } -} diff --git a/src/demo/share/jpda/com/sun/tools/example/debug/bdi/ModificationWatchpointSpec.java b/src/demo/share/jpda/com/sun/tools/example/debug/bdi/ModificationWatchpointSpec.java deleted file mode 100644 --- a/src/demo/share/jpda/com/sun/tools/example/debug/bdi/ModificationWatchpointSpec.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code 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 - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * This source code is provided to illustrate the usage of a given feature - * or technique and has been deliberately simplified. Additional steps - * required for a production-quality application, such as security checks, - * input validation and proper error handling, might not be present in - * this sample code. - */ - - -package com.sun.tools.example.debug.bdi; - -import com.sun.jdi.*; - -public class ModificationWatchpointSpec extends WatchpointSpec { - - ModificationWatchpointSpec(EventRequestSpecList specs, - ReferenceTypeSpec refSpec, String fieldId) { - super(specs, refSpec, fieldId); - } - - /** - * The 'refType' is known to match. - */ - @Override - void resolve(ReferenceType refType) throws InvalidTypeException, - NoSuchFieldException { - if (!(refType instanceof ClassType)) { - throw new InvalidTypeException(); - } - Field field = refType.fieldByName(fieldId); - if (field == null) { - throw new NoSuchFieldException(fieldId); - } - setRequest(refType.virtualMachine().eventRequestManager() - .createModificationWatchpointRequest(field)); - } - - @Override - public boolean equals(Object obj) { - return (obj instanceof ModificationWatchpointSpec) && - super.equals(obj); - } -} diff --git a/src/demo/share/jpda/com/sun/tools/example/debug/bdi/NoSessionException.java b/src/demo/share/jpda/com/sun/tools/example/debug/bdi/NoSessionException.java deleted file mode 100644 --- a/src/demo/share/jpda/com/sun/tools/example/debug/bdi/NoSessionException.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code 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 - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * This source code is provided to illustrate the usage of a given feature - * or technique and has been deliberately simplified. Additional steps - * required for a production-quality application, such as security checks, - * input validation and proper error handling, might not be present in - * this sample code. - */ - - -package com.sun.tools.example.debug.bdi; - -public class NoSessionException extends Exception { - - private static final long serialVersionUID = -7324357828115128603L; -} diff --git a/src/demo/share/jpda/com/sun/tools/example/debug/bdi/NoThreadException.java b/src/demo/share/jpda/com/sun/tools/example/debug/bdi/NoThreadException.java deleted file mode 100644 --- a/src/demo/share/jpda/com/sun/tools/example/debug/bdi/NoThreadException.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code 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 - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * This source code is provided to illustrate the usage of a given feature - * or technique and has been deliberately simplified. Additional steps - * required for a production-quality application, such as security checks, - * input validation and proper error handling, might not be present in - * this sample code. - */ - - -package com.sun.tools.example.debug.bdi; - -public class NoThreadException extends Exception { - - private static final long serialVersionUID = 1846613539928921998L; - -} diff --git a/src/demo/share/jpda/com/sun/tools/example/debug/bdi/OutputListener.java b/src/demo/share/jpda/com/sun/tools/example/debug/bdi/OutputListener.java deleted file mode 100644 --- a/src/demo/share/jpda/com/sun/tools/example/debug/bdi/OutputListener.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code 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 - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * This source code is provided to illustrate the usage of a given feature - * or technique and has been deliberately simplified. Additional steps - * required for a production-quality application, such as security checks, - * input validation and proper error handling, might not be present in - * this sample code. - */ - - -package com.sun.tools.example.debug.bdi; - -public interface OutputListener { - void putString(String str); - //void putLine(String line); -} diff --git a/src/demo/share/jpda/com/sun/tools/example/debug/bdi/ParseException.java b/src/demo/share/jpda/com/sun/tools/example/debug/bdi/ParseException.java deleted file mode 100644 --- a/src/demo/share/jpda/com/sun/tools/example/debug/bdi/ParseException.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code 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 - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * This source code is provided to illustrate the usage of a given feature - * or technique and has been deliberately simplified. Additional steps - * required for a production-quality application, such as security checks, - * input validation and proper error handling, might not be present in - * this sample code. - */ - - -package com.sun.tools.example.debug.bdi; - -// dummy placeholder for javaCC-generated code. - -public class ParseException extends Exception {} diff --git a/src/demo/share/jpda/com/sun/tools/example/debug/bdi/PatternReferenceTypeSpec.java b/src/demo/share/jpda/com/sun/tools/example/debug/bdi/PatternReferenceTypeSpec.java deleted file mode 100644 --- a/src/demo/share/jpda/com/sun/tools/example/debug/bdi/PatternReferenceTypeSpec.java +++ /dev/null @@ -1,108 +0,0 @@ -/* - * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code 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 - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * This source code is provided to illustrate the usage of a given feature - * or technique and has been deliberately simplified. Additional steps - * required for a production-quality application, such as security checks, - * input validation and proper error handling, might not be present in - * this sample code. - */ - - -package com.sun.tools.example.debug.bdi; - -import com.sun.jdi.*; -import java.util.StringTokenizer; - -class PatternReferenceTypeSpec implements ReferenceTypeSpec { - final boolean isWild; - final String classId; - - PatternReferenceTypeSpec(String classId) -// throws ClassNotFoundException - { -// checkClassName(classId); - isWild = classId.startsWith("*."); - if (isWild) { - this.classId = classId.substring(1); - } else { - this.classId = classId; - } - } - - /** - * Does the specified ReferenceType match this spec. - */ - @Override - public boolean matches(ReferenceType refType) { - if (isWild) { - return refType.name().endsWith(classId); - } else { - return refType.name().equals(classId); - } - } - - @Override - public int hashCode() { - return classId.hashCode(); - } - - @Override - public boolean equals(Object obj) { - if (obj instanceof PatternReferenceTypeSpec) { - PatternReferenceTypeSpec spec = (PatternReferenceTypeSpec)obj; - - return classId.equals(spec.classId) && (isWild == spec.isWild); - } else { - return false; - } - } - - private void checkClassName(String className) throws ClassNotFoundException { - // Do stricter checking of class name validity on deferred - // because if the name is invalid, it will - // never match a future loaded class, and we'll be silent - // about it. - StringTokenizer tokenizer = new StringTokenizer(className, "."); - boolean first = true; - while (tokenizer.hasMoreTokens()) { - String token = tokenizer.nextToken(); - // Each dot-separated piece must be a valid identifier - // and the first token can also be "*". (Note that - // numeric class ids are not permitted. They must - // match a loaded class.) - if (!Utils.isJavaIdentifier(token) && !(first && token.equals("*"))) { - throw new ClassNotFoundException(); - } - first = false; - } - } - - @Override - public String toString() { - return isWild? "*" + classId : classId; - } -} diff --git a/src/demo/share/jpda/com/sun/tools/example/debug/bdi/ReferenceTypeSpec.java b/src/demo/share/jpda/com/sun/tools/example/debug/bdi/ReferenceTypeSpec.java deleted file mode 100644 --- a/src/demo/share/jpda/com/sun/tools/example/debug/bdi/ReferenceTypeSpec.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code 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 - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * This source code is provided to illustrate the usage of a given feature - * or technique and has been deliberately simplified. Additional steps - * required for a production-quality application, such as security checks, - * input validation and proper error handling, might not be present in - * this sample code. - */ - - -package com.sun.tools.example.debug.bdi; - -import com.sun.jdi.*; - -interface ReferenceTypeSpec { - /** - * Does the specified ReferenceType match this spec. - */ - boolean matches(ReferenceType refType); - - @Override - int hashCode(); - - @Override - boolean equals(Object obj); -} diff --git a/src/demo/share/jpda/com/sun/tools/example/debug/bdi/Session.java b/src/demo/share/jpda/com/sun/tools/example/debug/bdi/Session.java deleted file mode 100644 --- a/src/demo/share/jpda/com/sun/tools/example/debug/bdi/Session.java +++ /dev/null @@ -1,105 +0,0 @@ -/* - * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code 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 - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * This source code is provided to illustrate the usage of a given feature - * or technique and has been deliberately simplified. Additional steps - * required for a production-quality application, such as security checks, - * input validation and proper error handling, might not be present in - * this sample code. - */ - - -package com.sun.tools.example.debug.bdi; - -import com.sun.jdi.VirtualMachine; -import com.sun.jdi.VMDisconnectedException; - -/** - * Our repository of what we know about the state of one - * running VM. - */ -class Session { - - final VirtualMachine vm; - final ExecutionManager runtime; - final OutputListener diagnostics; - - boolean running = true; // Set false by JDIEventSource - boolean interrupted = false; // Set false by JDIEventSource - - private JDIEventSource eventSourceThread = null; - private int traceFlags; - private boolean dead = false; - - public Session(VirtualMachine vm, ExecutionManager runtime, - OutputListener diagnostics) { - this.vm = vm; - this.runtime = runtime; - this.diagnostics = diagnostics; - this.traceFlags = VirtualMachine.TRACE_NONE; - } - - /** - * Determine if VM is interrupted, i.e, present and not running. - */ - public boolean isInterrupted() { - return interrupted; - } - - public void setTraceMode(int traceFlags) { - this.traceFlags = traceFlags; - if (!dead) { - vm.setDebugTraceMode(traceFlags); - } - } - - public boolean attach() { - vm.setDebugTraceMode(traceFlags); - diagnostics.putString("Connected to VM"); - eventSourceThread = new JDIEventSource(this); - eventSourceThread.start(); - return true; - } - - public void detach() { - if (!dead) { - eventSourceThread.interrupt(); - eventSourceThread = null; - //### The VM may already be disconnected - //### if the debuggee did a System.exit(). - //### Exception handler here is a kludge, - //### Rather, there are many other places - //### where we need to handle this exception, - //### and initiate a detach due to an error - //### condition, e.g., connection failure. - try { - vm.dispose(); - } catch (VMDisconnectedException ee) {} - dead = true; - diagnostics.putString("Disconnected from VM"); - } - } -} diff --git a/src/demo/share/jpda/com/sun/tools/example/debug/bdi/SessionListener.java b/src/demo/share/jpda/com/sun/tools/example/debug/bdi/SessionListener.java deleted file mode 100644 --- a/src/demo/share/jpda/com/sun/tools/example/debug/bdi/SessionListener.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code 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 - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * This source code is provided to illustrate the usage of a given feature - * or technique and has been deliberately simplified. Additional steps - * required for a production-quality application, such as security checks, - * input validation and proper error handling, might not be present in - * this sample code. - */ - - -package com.sun.tools.example.debug.bdi; - -import java.util.EventObject; -import java.util.EventListener; - -public interface SessionListener extends EventListener { - - void sessionStart(EventObject e); - - void sessionInterrupt(EventObject e); - void sessionContinue(EventObject e); -} diff --git a/src/demo/share/jpda/com/sun/tools/example/debug/bdi/SourceNameReferenceTypeSpec.java b/src/demo/share/jpda/com/sun/tools/example/debug/bdi/SourceNameReferenceTypeSpec.java deleted file mode 100644 --- a/src/demo/share/jpda/com/sun/tools/example/debug/bdi/SourceNameReferenceTypeSpec.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code 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 - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * This source code is provided to illustrate the usage of a given feature - * or technique and has been deliberately simplified. Additional steps - * required for a production-quality application, such as security checks, - * input validation and proper error handling, might not be present in - * this sample code. - */ - - -package com.sun.tools.example.debug.bdi; - -import com.sun.jdi.*; - -class SourceNameReferenceTypeSpec implements ReferenceTypeSpec { - final String sourceName; - final int linenumber; - - SourceNameReferenceTypeSpec(String sourceName, int linenumber) { - this.sourceName = sourceName; - this.linenumber = linenumber; - } - - /** - * Does the specified ReferenceType match this spec. - */ - @Override - public boolean matches(ReferenceType refType) { - try { - if (refType.sourceName().equals(sourceName)) { - try { - refType.locationsOfLine(linenumber); - // if we don't throw an exception then it was found - return true; - } catch(AbsentInformationException exc) { - } catch(ObjectCollectedException exc) { - } - } - } catch(AbsentInformationException exc) { - // for sourceName(), fall through - } - return false; - } - - @Override - public int hashCode() { - return sourceName.hashCode() + linenumber; - } - - @Override - public boolean equals(Object obj) { - if (obj instanceof SourceNameReferenceTypeSpec) { - SourceNameReferenceTypeSpec spec = (SourceNameReferenceTypeSpec)obj; - - return sourceName.equals(spec.sourceName) && - (linenumber == spec.linenumber); - } else { - return false; - } - } - - @Override - public String toString() { - return sourceName + "@" + linenumber; - } -} diff --git a/src/demo/share/jpda/com/sun/tools/example/debug/bdi/SpecErrorEvent.java b/src/demo/share/jpda/com/sun/tools/example/debug/bdi/SpecErrorEvent.java deleted file mode 100644 --- a/src/demo/share/jpda/com/sun/tools/example/debug/bdi/SpecErrorEvent.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code 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 - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * This source code is provided to illustrate the usage of a given feature - * or technique and has been deliberately simplified. Additional steps - * required for a production-quality application, such as security checks, - * input validation and proper error handling, might not be present in - * this sample code. - */ - - -package com.sun.tools.example.debug.bdi; - -public class SpecErrorEvent extends SpecEvent { - - private static final long serialVersionUID = 8162634387866409578L; - private Exception reason; - - public SpecErrorEvent(EventRequestSpec eventRequestSpec, - Exception reason) { - super(eventRequestSpec); - this.reason = reason; - } - - public Exception getReason() { - return reason; - } -} diff --git a/src/demo/share/jpda/com/sun/tools/example/debug/bdi/SpecEvent.java b/src/demo/share/jpda/com/sun/tools/example/debug/bdi/SpecEvent.java deleted file mode 100644 --- a/src/demo/share/jpda/com/sun/tools/example/debug/bdi/SpecEvent.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code 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 - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * This source code is provided to illustrate the usage of a given feature - * or technique and has been deliberately simplified. Additional steps - * required for a production-quality application, such as security checks, - * input validation and proper error handling, might not be present in - * this sample code. - */ - - -package com.sun.tools.example.debug.bdi; - -import java.util.EventObject; - -import com.sun.jdi.request.EventRequest; - -public class SpecEvent extends EventObject { - - private static final long serialVersionUID = 4820735456787276230L; - private EventRequestSpec eventRequestSpec; - - public SpecEvent(EventRequestSpec eventRequestSpec) { - super(eventRequestSpec.specs); - this.eventRequestSpec = eventRequestSpec; - } - - public EventRequestSpec getEventRequestSpec() { - return eventRequestSpec; - } - - public EventRequest getEventRequest() { - return eventRequestSpec.getEventRequest(); - } -} diff --git a/src/demo/share/jpda/com/sun/tools/example/debug/bdi/SpecListener.java b/src/demo/share/jpda/com/sun/tools/example/debug/bdi/SpecListener.java deleted file mode 100644 --- a/src/demo/share/jpda/com/sun/tools/example/debug/bdi/SpecListener.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code 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 - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * This source code is provided to illustrate the usage of a given feature - * or technique and has been deliberately simplified. Additional steps - * required for a production-quality application, such as security checks, - * input validation and proper error handling, might not be present in - * this sample code. - */ - - -package com.sun.tools.example.debug.bdi; - -import java.util.EventListener; - -public interface SpecListener extends EventListener { - - void breakpointSet(SpecEvent e); - void breakpointDeferred(SpecEvent e); - void breakpointDeleted(SpecEvent e); - void breakpointResolved(SpecEvent e); - void breakpointError(SpecErrorEvent e); - - void watchpointSet(SpecEvent e); - void watchpointDeferred(SpecEvent e); - void watchpointDeleted(SpecEvent e); - void watchpointResolved(SpecEvent e); - void watchpointError(SpecErrorEvent e); - - void exceptionInterceptSet(SpecEvent e); - void exceptionInterceptDeferred(SpecEvent e); - void exceptionInterceptDeleted(SpecEvent e); - void exceptionInterceptResolved(SpecEvent e); - void exceptionInterceptError(SpecErrorEvent e); -} diff --git a/src/demo/share/jpda/com/sun/tools/example/debug/bdi/ThreadGroupIterator.java b/src/demo/share/jpda/com/sun/tools/example/debug/bdi/ThreadGroupIterator.java deleted file mode 100644 --- a/src/demo/share/jpda/com/sun/tools/example/debug/bdi/ThreadGroupIterator.java +++ /dev/null @@ -1,117 +0,0 @@ -/* - * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code 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 - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * This source code is provided to illustrate the usage of a given feature - * or technique and has been deliberately simplified. Additional steps - * required for a production-quality application, such as security checks, - * input validation and proper error handling, might not be present in - * this sample code. - */ - - -package com.sun.tools.example.debug.bdi; - -import com.sun.jdi.ThreadGroupReference; -import java.util.List; -import java.util.Stack; -import java.util.ArrayList; -import java.util.Iterator; - -/** - * Descend the tree of thread groups. - * @author Robert G. Field - */ -public class ThreadGroupIterator implements Iterator { - private final Stack> stack - = new Stack>(); - - public ThreadGroupIterator(List tgl) { - push(tgl); - } - - public ThreadGroupIterator(ThreadGroupReference tg) { - List tgl = new ArrayList(); - tgl.add(tg); - push(tgl); - } - -/* - ThreadGroupIterator() { - this(Env.vm().topLevelThreadGroups()); - } -*/ - - private Iterator top() { - return stack.peek(); - } - - /** - * The invariant in this class is that the top iterator - * on the stack has more elements. If the stack is - * empty, there is no top. This method assures - * this invariant. - */ - private void push(List tgl) { - stack.push(tgl.iterator()); - while (!stack.isEmpty() && !top().hasNext()) { - stack.pop(); - } - } - - @Override - public boolean hasNext() { - return !stack.isEmpty(); - } - - @Override - public ThreadGroupReference next() { - return nextThreadGroup(); - } - - public ThreadGroupReference nextThreadGroup() { - ThreadGroupReference tg = top().next(); - push(tg.threadGroups()); - return tg; - } - - @Override - public void remove() { - throw new UnsupportedOperationException(); - } - -/* - static ThreadGroupReference find(String name) { - ThreadGroupIterator tgi = new ThreadGroupIterator(); - while (tgi.hasNext()) { - ThreadGroupReference tg = tgi.nextThreadGroup(); - if (tg.name().equals(name)) { - return tg; - } - } - return null; - } -*/ -} diff --git a/src/demo/share/jpda/com/sun/tools/example/debug/bdi/ThreadInfo.java b/src/demo/share/jpda/com/sun/tools/example/debug/bdi/ThreadInfo.java deleted file mode 100644 --- a/src/demo/share/jpda/com/sun/tools/example/debug/bdi/ThreadInfo.java +++ /dev/null @@ -1,126 +0,0 @@ -/* - * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code 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 - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * This source code is provided to illustrate the usage of a given feature - * or technique and has been deliberately simplified. Additional steps - * required for a production-quality application, such as security checks, - * input validation and proper error handling, might not be present in - * this sample code. - */ - - -package com.sun.tools.example.debug.bdi; - -import com.sun.jdi.*; - -//### Should handle target VM death or connection failure cleanly. - -public class ThreadInfo { - - private ThreadReference thread; - private int status; - - private int frameCount; - - Object userObject; // User-supplied annotation. - - private boolean interrupted = false; - - private void assureInterrupted() throws VMNotInterruptedException { - if (!interrupted) { - throw new VMNotInterruptedException(); - } - } - - ThreadInfo (ThreadReference thread) { - this.thread = thread; - this.frameCount = -1; - } - - public ThreadReference thread() { - return thread; - } - - public int getStatus() throws VMNotInterruptedException { - assureInterrupted(); - update(); - return status; - } - - public int getFrameCount() throws VMNotInterruptedException { - assureInterrupted(); - update(); - return frameCount; - } - - public StackFrame getFrame(int index) throws VMNotInterruptedException { - assureInterrupted(); - update(); - try { - return thread.frame(index); - } catch (IncompatibleThreadStateException e) { - // Should not happen - interrupted = false; - throw new VMNotInterruptedException(); - } - } - - public Object getUserObject() { - return userObject; - } - - public void setUserObject(Object obj) { - userObject = obj; - } - - // Refresh upon first access after cache is cleared. - - void update() throws VMNotInterruptedException { - if (frameCount == -1) { - try { - status = thread.status(); - frameCount = thread.frameCount(); - } catch (IncompatibleThreadStateException e) { - // Should not happen - interrupted = false; - throw new VMNotInterruptedException(); - } - } - } - - // Called from 'ExecutionManager'. - - void validate() { - interrupted = true; - } - - void invalidate() { - interrupted = false; - frameCount = -1; - status = ThreadReference.THREAD_STATUS_UNKNOWN; - } - -} diff --git a/src/demo/share/jpda/com/sun/tools/example/debug/bdi/ThreadIterator.java b/src/demo/share/jpda/com/sun/tools/example/debug/bdi/ThreadIterator.java deleted file mode 100644 --- a/src/demo/share/jpda/com/sun/tools/example/debug/bdi/ThreadIterator.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code 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 - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * This source code is provided to illustrate the usage of a given feature - * or technique and has been deliberately simplified. Additional steps - * required for a production-quality application, such as security checks, - * input validation and proper error handling, might not be present in - * this sample code. - */ - - -package com.sun.tools.example.debug.bdi; - -import com.sun.jdi.ThreadGroupReference; -import com.sun.jdi.ThreadReference; -import java.util.List; -import java.util.Iterator; - -public class ThreadIterator implements Iterator { - Iterator it = null; - ThreadGroupIterator tgi; - - public ThreadIterator(ThreadGroupReference tg) { - tgi = new ThreadGroupIterator(tg); - } - - //### make this package access only? - public ThreadIterator(List tgl) { - tgi = new ThreadGroupIterator(tgl); - } - - @Override - public boolean hasNext() { - while (it == null || !it.hasNext()) { - if (!tgi.hasNext()) { - return false; // no more - } - it = tgi.nextThreadGroup().threads().iterator(); - } - return true; - } - - @Override - public ThreadReference next() { - return it.next(); - } - - public ThreadReference nextThread() { - return next(); - } - - @Override - public void remove() { - throw new UnsupportedOperationException(); - } -} diff --git a/src/demo/share/jpda/com/sun/tools/example/debug/bdi/Utils.java b/src/demo/share/jpda/com/sun/tools/example/debug/bdi/Utils.java deleted file mode 100644 --- a/src/demo/share/jpda/com/sun/tools/example/debug/bdi/Utils.java +++ /dev/null @@ -1,190 +0,0 @@ -/* - * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code 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 - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * This source code is provided to illustrate the usage of a given feature - * or technique and has been deliberately simplified. Additional steps - * required for a production-quality application, such as security checks, - * input validation and proper error handling, might not be present in - * this sample code. - */ - - -package com.sun.tools.example.debug.bdi; //### does it belong here? - -import com.sun.jdi.*; - -public class Utils { - - /** - * Return the thread status description. - */ - public static String getStatus(ThreadReference thr) { - int status = thr.status(); - String result; - switch (status) { - case ThreadReference.THREAD_STATUS_UNKNOWN: - result = "unknown status"; - break; - case ThreadReference.THREAD_STATUS_ZOMBIE: - result = "zombie"; - break; - case ThreadReference.THREAD_STATUS_RUNNING: - result = "running"; - break; - case ThreadReference.THREAD_STATUS_SLEEPING: - result = "sleeping"; - break; - case ThreadReference.THREAD_STATUS_MONITOR: - result = "waiting to acquire a monitor lock"; - break; - case ThreadReference.THREAD_STATUS_WAIT: - result = "waiting on a condition"; - break; - default: - result = ""; - } - if (thr.isSuspended()) { - result += " (suspended)"; - } - return result; - } - - /** - * Return a description of an object. - */ - public static String description(ObjectReference ref) { - ReferenceType clazz = ref.referenceType(); - long id = ref.uniqueID(); //### TODO use real id - if (clazz == null) { - return toHex(id); - } else { - return "(" + clazz.name() + ")" + toHex(id); - } - } - - /** - * Convert a long to a hexadecimal string. - */ - public static String toHex(long n) { - char s1[] = new char[16]; - char s2[] = new char[18]; - - // Store digits in reverse order. - int i = 0; - do { - long d = n & 0xf; - s1[i++] = (char)((d < 10) ? ('0' + d) : ('a' + d - 10)); - } while ((n >>>= 4) > 0); - - // Now reverse the array. - s2[0] = '0'; - s2[1] = 'x'; - int j = 2; - while (--i >= 0) { - s2[j++] = s1[i]; - } - return new String(s2, 0, j); - } - - /** - * Convert hexadecimal strings to longs. - */ - public static long fromHex(String hexStr) { - String str = hexStr.startsWith("0x") ? - hexStr.substring(2).toLowerCase() : hexStr.toLowerCase(); - if (hexStr.length() == 0) { - throw new NumberFormatException(); - } - - long ret = 0; - for (int i = 0; i < str.length(); i++) { - int c = str.charAt(i); - if (c >= '0' && c <= '9') { - ret = (ret * 16) + (c - '0'); - } else if (c >= 'a' && c <= 'f') { - ret = (ret * 16) + (c - 'a' + 10); - } else { - throw new NumberFormatException(); - } - } - return ret; - } - - - /* - * The next two methods are used by this class and by EventHandler - * to print consistent locations and error messages. - */ - public static String locationString(Location loc) { - return loc.declaringType().name() + - "." + loc.method().name() + "(), line=" + - loc.lineNumber(); - } - -//### UNUSED. -/************************ - private String typedName(Method method) { - // TO DO: Use method.signature() instead of method.arguments() so that - // we get sensible results for classes without debugging info - StringBuffer buf = new StringBuffer(); - buf.append(method.name()); - buf.append("("); - Iterator it = method.arguments().iterator(); - while (it.hasNext()) { - buf.append(((LocalVariable)it.next()).typeName()); - if (it.hasNext()) { - buf.append(","); - } - } - buf.append(")"); - return buf.toString(); - } -************************/ - - public static boolean isValidMethodName(String s) { - return isJavaIdentifier(s) || - s.equals("") || - s.equals(""); - } - - public static boolean isJavaIdentifier(String s) { - if (s.length() == 0) { - return false; - } - int cp = s.codePointAt(0); - if (! Character.isJavaIdentifierStart(cp)) { - return false; - } - for (int i = Character.charCount(cp); i < s.length(); i += Character.charCount(cp)) { - cp = s.codePointAt(i); - if (! Character.isJavaIdentifierPart(cp)) { - return false; - } - } - return true; - } - -} diff --git a/src/demo/share/jpda/com/sun/tools/example/debug/bdi/VMLaunchFailureException.java b/src/demo/share/jpda/com/sun/tools/example/debug/bdi/VMLaunchFailureException.java deleted file mode 100644 --- a/src/demo/share/jpda/com/sun/tools/example/debug/bdi/VMLaunchFailureException.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code 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 - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * This source code is provided to illustrate the usage of a given feature - * or technique and has been deliberately simplified. Additional steps - * required for a production-quality application, such as security checks, - * input validation and proper error handling, might not be present in - * this sample code. - */ - - -package com.sun.tools.example.debug.bdi; - -public class VMLaunchFailureException extends Exception { - - private static final long serialVersionUID = -2439646729274310108L; -} diff --git a/src/demo/share/jpda/com/sun/tools/example/debug/bdi/VMNotInterruptedException.java b/src/demo/share/jpda/com/sun/tools/example/debug/bdi/VMNotInterruptedException.java deleted file mode 100644 --- a/src/demo/share/jpda/com/sun/tools/example/debug/bdi/VMNotInterruptedException.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code 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 - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * This source code is provided to illustrate the usage of a given feature - * or technique and has been deliberately simplified. Additional steps - * required for a production-quality application, such as security checks, - * input validation and proper error handling, might not be present in - * this sample code. - */ - - -package com.sun.tools.example.debug.bdi; - -public class VMNotInterruptedException extends Exception { - - private static final long serialVersionUID = 8111074582188765600L; -} diff --git a/src/demo/share/jpda/com/sun/tools/example/debug/bdi/WatchpointSpec.java b/src/demo/share/jpda/com/sun/tools/example/debug/bdi/WatchpointSpec.java deleted file mode 100644 --- a/src/demo/share/jpda/com/sun/tools/example/debug/bdi/WatchpointSpec.java +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code 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 - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * This source code is provided to illustrate the usage of a given feature - * or technique and has been deliberately simplified. Additional steps - * required for a production-quality application, such as security checks, - * input validation and proper error handling, might not be present in - * this sample code. - */ - - -package com.sun.tools.example.debug.bdi; - -public abstract class WatchpointSpec extends EventRequestSpec { - final String fieldId; - - WatchpointSpec(EventRequestSpecList specs, - ReferenceTypeSpec refSpec, String fieldId) { - super(specs, refSpec); - this.fieldId = fieldId; -// if (!isJavaIdentifier(fieldId)) { -// throw new MalformedMemberNameException(fieldId); -// } - } - - @Override - void notifySet(SpecListener listener, SpecEvent evt) { - listener.watchpointSet(evt); - } - - @Override - void notifyDeferred(SpecListener listener, SpecEvent evt) { - listener.watchpointDeferred(evt); - } - - @Override - void notifyResolved(SpecListener listener, SpecEvent evt) { - listener.watchpointResolved(evt); - } - - @Override - void notifyDeleted(SpecListener listener, SpecEvent evt) { - listener.watchpointDeleted(evt); - } - - @Override - void notifyError(SpecListener listener, SpecErrorEvent evt) { - listener.watchpointError(evt); - } - - @Override - public int hashCode() { - return refSpec.hashCode() + fieldId.hashCode() + - getClass().hashCode(); - } - - @Override - public boolean equals(Object obj) { - if (obj instanceof WatchpointSpec) { - WatchpointSpec watchpoint = (WatchpointSpec)obj; - - return fieldId.equals(watchpoint.fieldId) && - refSpec.equals(watchpoint.refSpec) && - getClass().equals(watchpoint.getClass()); - } else { - return false; - } - } - - @Override - public String errorMessageFor(Exception e) { - if (e instanceof NoSuchFieldException) { - return ("No field " + fieldId + " in " + refSpec); - } else { - return super.errorMessageFor(e); - } - } -} diff --git a/src/demo/share/jpda/com/sun/tools/example/debug/event/AbstractEventSet.java b/src/demo/share/jpda/com/sun/tools/example/debug/event/AbstractEventSet.java deleted file mode 100644 --- a/src/demo/share/jpda/com/sun/tools/example/debug/event/AbstractEventSet.java +++ /dev/null @@ -1,272 +0,0 @@ -/* - * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code 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 - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * This source code is provided to illustrate the usage of a given feature - * or technique and has been deliberately simplified. Additional steps - * required for a production-quality application, such as security checks, - * input validation and proper error handling, might not be present in - * this sample code. - */ - - -package com.sun.tools.example.debug.event; - -import com.sun.jdi.*; -import com.sun.jdi.event.*; -import com.sun.jdi.request.*; - -import java.util.*; - -public abstract class AbstractEventSet extends EventObject implements EventSet { - - private static final long serialVersionUID = 2772717574222076977L; - private final EventSet jdiEventSet; - final Event oneEvent; - - /** - */ - AbstractEventSet(EventSet jdiEventSet) { - super(jdiEventSet.virtualMachine()); - this.jdiEventSet = jdiEventSet; - this.oneEvent = eventIterator().nextEvent(); - } - - public static AbstractEventSet toSpecificEventSet(EventSet jdiEventSet) { - Event evt = jdiEventSet.eventIterator().nextEvent(); - if (evt instanceof LocatableEvent) { - if (evt instanceof ExceptionEvent) { - return new ExceptionEventSet(jdiEventSet); - } else if (evt instanceof WatchpointEvent) { - if (evt instanceof AccessWatchpointEvent) { - return new AccessWatchpointEventSet(jdiEventSet); - } else { - return new ModificationWatchpointEventSet(jdiEventSet); - } - } else { - return new LocationTriggerEventSet(jdiEventSet); - } - } else if (evt instanceof ClassPrepareEvent) { - return new ClassPrepareEventSet(jdiEventSet); - } else if (evt instanceof ClassUnloadEvent) { - return new ClassUnloadEventSet(jdiEventSet); - } else if (evt instanceof ThreadDeathEvent) { - return new ThreadDeathEventSet(jdiEventSet); - } else if (evt instanceof ThreadStartEvent) { - return new ThreadStartEventSet(jdiEventSet); - } else if (evt instanceof VMDeathEvent) { - return new VMDeathEventSet(jdiEventSet); - } else if (evt instanceof VMDisconnectEvent) { - return new VMDisconnectEventSet(jdiEventSet); - } else if (evt instanceof VMStartEvent) { - return new VMStartEventSet(jdiEventSet); - } else { - throw new IllegalArgumentException("Unknown event " + evt); - } - } - - public abstract void notify(JDIListener listener); - - // Implement Mirror - - @Override - public VirtualMachine virtualMachine() { - return jdiEventSet.virtualMachine(); - } - - public VirtualMachine getVirtualMachine() { - return jdiEventSet.virtualMachine(); - } - - // Implement EventSet - - /** - * Returns the policy used to suspend threads in the target VM - * for this event set. This policy is selected from the suspend - * policies for each event's request. The one that suspends the - * most threads is chosen when the event occurs in the target VM - * and that policy is returned here. See - * com.sun.jdi.request.EventRequest for the possible policy values. - * - * @return the integer suspendPolicy - */ - public int getSuspendPolicy() { - return jdiEventSet.suspendPolicy(); - } - - @Override - public void resume() { - jdiEventSet.resume(); - } - - @Override - public int suspendPolicy() { - return jdiEventSet.suspendPolicy(); - } - - public boolean suspendedAll() { - return jdiEventSet.suspendPolicy() == EventRequest.SUSPEND_ALL; - } - - public boolean suspendedEventThread() { - return jdiEventSet.suspendPolicy() == EventRequest.SUSPEND_EVENT_THREAD; - } - - public boolean suspendedNone() { - return jdiEventSet.suspendPolicy() == EventRequest.SUSPEND_NONE; - } - - /** - * Return an iterator specific to {@link Event} objects. - */ - @Override - public EventIterator eventIterator() { - return jdiEventSet.eventIterator(); - } - - - // Implement java.util.Set (by pass through) - - /** - * Returns the number of elements in this set (its cardinality). If this - * set contains more than Integer.MAX_VALUE elements, returns - * Integer.MAX_VALUE. - * - * @return the number of elements in this set (its cardinality). - */ - @Override - public int size() { - return jdiEventSet.size(); - } - - /** - * Returns true if this set contains no elements. - * - * @return true if this set contains no elements. - */ - @Override - public boolean isEmpty() { - return jdiEventSet.isEmpty(); - } - - /** - * Returns true if this set contains the specified element. More - * formally, returns true if and only if this set contains an - * element e such that (o==null ? e==null : - * o.equals(e)). - * - * @return true if this set contains the specified element. - */ - @Override - public boolean contains(Object o) { - return jdiEventSet.contains(o); - } - - /** - * Returns an iterator over the elements in this set. The elements are - * returned in no particular order (unless this set is an instance of some - * class that provides a guarantee). - * - * @return an iterator over the elements in this set. - */ - @Override - public Iterator iterator() { - return jdiEventSet.iterator(); - } - - /** - * Returns an array containing all of the elements in this set. - * Obeys the general contract of the Collection.toArray method. - * - * @return an array containing all of the elements in this set. - */ - @Override - public Object[] toArray() { - return jdiEventSet.toArray(); - } - - /** - * Returns an array containing all of the elements in this set whose - * runtime type is that of the specified array. Obeys the general - * contract of the Collection.toArray(Object[]) method. - * - * @param a the array into which the elements of this set are to - * be stored, if it is big enough { - return jdiEventSet.XXX(); - } otherwise, a new array of the - * same runtime type is allocated for this purpose. - * @return an array containing the elements of this set. - * @throws ArrayStoreException the runtime type of a is not a supertype - * of the runtime type of every element in this set. - */ - @Override - public T[] toArray(T a[]) { - return jdiEventSet.toArray(a); - } - - // Bulk Operations - - /** - * Returns true if this set contains all of the elements of the - * specified collection. If the specified collection is also a set, this - * method returns true if it is a subset of this set. - * - * @param c collection to be checked for containment in this set. - * @return true if this set contains all of the elements of the - * specified collection. - */ - @Override - public boolean containsAll(Collection c) { - return jdiEventSet.containsAll(c); - } - - - // Make the rest of Set unmodifiable - - @Override - public boolean add(Event e){ - throw new UnsupportedOperationException(); - } - @Override - public boolean remove(Object o) { - throw new UnsupportedOperationException(); - } - @Override - public boolean addAll(Collection coll) { - throw new UnsupportedOperationException(); - } - @Override - public boolean removeAll(Collection coll) { - throw new UnsupportedOperationException(); - } - @Override - public boolean retainAll(Collection coll) { - throw new UnsupportedOperationException(); - } - @Override - public void clear() { - throw new UnsupportedOperationException(); - } -} diff --git a/src/demo/share/jpda/com/sun/tools/example/debug/event/AccessWatchpointEventSet.java b/src/demo/share/jpda/com/sun/tools/example/debug/event/AccessWatchpointEventSet.java deleted file mode 100644 --- a/src/demo/share/jpda/com/sun/tools/example/debug/event/AccessWatchpointEventSet.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code 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 - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * This source code is provided to illustrate the usage of a given feature - * or technique and has been deliberately simplified. Additional steps - * required for a production-quality application, such as security checks, - * input validation and proper error handling, might not be present in - * this sample code. - */ - - -package com.sun.tools.example.debug.event; - -import com.sun.jdi.event.*; - -public class AccessWatchpointEventSet extends WatchpointEventSet { - - private static final long serialVersionUID = -2620394219156607673L; - - AccessWatchpointEventSet(EventSet jdiEventSet) { - super(jdiEventSet); - } - - @Override - public void notify(JDIListener listener) { - listener.accessWatchpoint(this); - } -} diff --git a/src/demo/share/jpda/com/sun/tools/example/debug/event/ClassPrepareEventSet.java b/src/demo/share/jpda/com/sun/tools/example/debug/event/ClassPrepareEventSet.java deleted file mode 100644 --- a/src/demo/share/jpda/com/sun/tools/example/debug/event/ClassPrepareEventSet.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code 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 - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * This source code is provided to illustrate the usage of a given feature - * or technique and has been deliberately simplified. Additional steps - * required for a production-quality application, such as security checks, - * input validation and proper error handling, might not be present in - * this sample code. - */ - - -package com.sun.tools.example.debug.event; - -import com.sun.jdi.*; -import com.sun.jdi.event.*; - -public class ClassPrepareEventSet extends AbstractEventSet { - - private static final long serialVersionUID = 5958493423581010491L; - - ClassPrepareEventSet(EventSet jdiEventSet) { - super(jdiEventSet); - } - - /** - * Returns the thread in which this event has occurred. - * - * @return a {@link ThreadReference} which mirrors the event's thread in - * the target VM. - */ - public ThreadReference getThread() { - return ((ClassPrepareEvent)oneEvent).thread(); - } - - - /** - * Returns the reference type for which this event was generated. - * - * @return a {@link ReferenceType} which mirrors the class, interface, or - * array which has been linked. - */ - public ReferenceType getReferenceType() { - return ((ClassPrepareEvent)oneEvent).referenceType(); - } - - @Override - public void notify(JDIListener listener) { - listener.classPrepare(this); - } -} diff --git a/src/demo/share/jpda/com/sun/tools/example/debug/event/ClassUnloadEventSet.java b/src/demo/share/jpda/com/sun/tools/example/debug/event/ClassUnloadEventSet.java deleted file mode 100644 --- a/src/demo/share/jpda/com/sun/tools/example/debug/event/ClassUnloadEventSet.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code 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 - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * This source code is provided to illustrate the usage of a given feature - * or technique and has been deliberately simplified. Additional steps - * required for a production-quality application, such as security checks, - * input validation and proper error handling, might not be present in - * this sample code. - */ - - -package com.sun.tools.example.debug.event; - -import com.sun.jdi.event.*; - -public class ClassUnloadEventSet extends AbstractEventSet { - - private static final long serialVersionUID = 8370341450345835866L; - - ClassUnloadEventSet(EventSet jdiEventSet) { - super(jdiEventSet); - } - - /** - * Returns the name of the class that has been unloaded. - */ - public String getClassName() { - return ((ClassUnloadEvent)oneEvent).className(); - } - - /** - * Returns the JNI-style signature of the class that has been unloaded. - */ - public String getClassSignature() { - return ((ClassUnloadEvent)oneEvent).classSignature(); - } - - @Override - public void notify(JDIListener listener) { - listener.classUnload(this); - } -} diff --git a/src/demo/share/jpda/com/sun/tools/example/debug/event/ExceptionEventSet.java b/src/demo/share/jpda/com/sun/tools/example/debug/event/ExceptionEventSet.java deleted file mode 100644 --- a/src/demo/share/jpda/com/sun/tools/example/debug/event/ExceptionEventSet.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code 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 - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * This source code is provided to illustrate the usage of a given feature - * or technique and has been deliberately simplified. Additional steps - * required for a production-quality application, such as security checks, - * input validation and proper error handling, might not be present in - * this sample code. - */ - - -package com.sun.tools.example.debug.event; - -import com.sun.jdi.*; -import com.sun.jdi.event.*; - -public class ExceptionEventSet extends LocatableEventSet { - - private static final long serialVersionUID = 5328140167954640711L; - - ExceptionEventSet(EventSet jdiEventSet) { - super(jdiEventSet); - } - - /** - * Gets the thrown exception object. The exception object is - * an instance of java.lang.Throwable or a subclass in the - * target VM. - * - * @return an {@link ObjectReference} which mirrors the thrown object in - * the target VM. - */ - public ObjectReference getException() { - return ((ExceptionEvent)oneEvent).exception(); - } - - /** - * Gets the location where the exception will be caught. An exception - * is considered to be caught if, at the point of the throw, the - * current location is dynamically enclosed in a try statement that - * handles the exception. (See the JVM specification for details). - * If there is such a try statement, the catch location is the - * first code index of the appropriate catch clause. - *

- * If there are native methods in the call stack at the time of the - * exception, there are important restrictions to note about the - * returned catch location. In such cases, - * it is not possible to predict whether an exception will be handled - * by some native method on the call stack. - * Thus, it is possible that exceptions considered uncaught - * here will, in fact, be handled by a native method and not cause - * termination of the target VM. Also, it cannot be assumed that the - * catch location returned here will ever be reached by the throwing - * thread. If there is - * a native frame between the current location and the catch location, - * the exception might be handled and cleared in that native method - * instead. - * - * @return the {@link Location} where the exception will be caught or null if - * the exception is uncaught. - */ - public Location getCatchLocation() { - return ((ExceptionEvent)oneEvent).catchLocation(); - } - - @Override - public void notify(JDIListener listener) { - listener.exception(this); - } -} diff --git a/src/demo/share/jpda/com/sun/tools/example/debug/event/JDIAdapter.java b/src/demo/share/jpda/com/sun/tools/example/debug/event/JDIAdapter.java deleted file mode 100644 --- a/src/demo/share/jpda/com/sun/tools/example/debug/event/JDIAdapter.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code 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 - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * This source code is provided to illustrate the usage of a given feature - * or technique and has been deliberately simplified. Additional steps - * required for a production-quality application, such as security checks, - * input validation and proper error handling, might not be present in - * this sample code. - */ - - -package com.sun.tools.example.debug.event; - -/** - * The adapter which receives JDI event sets. The methods in this - * class are empty; this class is provided as a convenience for - * easily creating listeners by extending this class and overriding - * only the methods of interest. - */ -public class JDIAdapter implements JDIListener { - - @Override - public void accessWatchpoint(AccessWatchpointEventSet e) { - } - - @Override - public void classPrepare(ClassPrepareEventSet e) { - } - - @Override - public void classUnload(ClassUnloadEventSet e) { - } - - @Override - public void exception(ExceptionEventSet e) { - } - - @Override - public void locationTrigger(LocationTriggerEventSet e) { - } - - @Override - public void modificationWatchpoint(ModificationWatchpointEventSet e) { - } - - @Override - public void threadDeath(ThreadDeathEventSet e) { - } - - @Override - public void threadStart(ThreadStartEventSet e) { - } - - @Override - public void vmDeath(VMDeathEventSet e) { - } - - @Override - public void vmDisconnect(VMDisconnectEventSet e) { - } - - @Override - public void vmStart(VMStartEventSet e) { - } - -} diff --git a/src/demo/share/jpda/com/sun/tools/example/debug/event/JDIListener.java b/src/demo/share/jpda/com/sun/tools/example/debug/event/JDIListener.java deleted file mode 100644 --- a/src/demo/share/jpda/com/sun/tools/example/debug/event/JDIListener.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code 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 - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * This source code is provided to illustrate the usage of a given feature - * or technique and has been deliberately simplified. Additional steps - * required for a production-quality application, such as security checks, - * input validation and proper error handling, might not be present in - * this sample code. - */ - - -package com.sun.tools.example.debug.event; - -import java.util.EventListener; - -public interface JDIListener extends EventListener { - void accessWatchpoint(AccessWatchpointEventSet e); - void classPrepare(ClassPrepareEventSet e); - void classUnload(ClassUnloadEventSet e); - void exception(ExceptionEventSet e); - void locationTrigger(LocationTriggerEventSet e); - void modificationWatchpoint(ModificationWatchpointEventSet e); - void threadDeath(ThreadDeathEventSet e); - void threadStart(ThreadStartEventSet e); - void vmDeath(VMDeathEventSet e); - void vmDisconnect(VMDisconnectEventSet e); - void vmStart(VMStartEventSet e); -} diff --git a/src/demo/share/jpda/com/sun/tools/example/debug/event/LocatableEventSet.java b/src/demo/share/jpda/com/sun/tools/example/debug/event/LocatableEventSet.java deleted file mode 100644 --- a/src/demo/share/jpda/com/sun/tools/example/debug/event/LocatableEventSet.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code 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 - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * This source code is provided to illustrate the usage of a given feature - * or technique and has been deliberately simplified. Additional steps - * required for a production-quality application, such as security checks, - * input validation and proper error handling, might not be present in - * this sample code. - */ - - -package com.sun.tools.example.debug.event; - -import com.sun.jdi.*; -import com.sun.jdi.event.*; - -/** - * Abstract event set for events with location and thread. - */ -public abstract class LocatableEventSet extends AbstractEventSet { - - private static final long serialVersionUID = 1027131209997915620L; - - LocatableEventSet(EventSet jdiEventSet) { - super(jdiEventSet); - } - - /** - * Returns the {@link Location} of this mirror. Depending on context - * and on available debug information, this location will have - * varying precision. - * - * @return the {@link Location} of this mirror. - */ - public Location getLocation() { - return ((LocatableEvent)oneEvent).location(); - } - - /** - * Returns the thread in which this event has occurred. - * - * @return a {@link ThreadReference} which mirrors the event's thread in - * the target VM. - */ - public ThreadReference getThread() { - return ((LocatableEvent)oneEvent).thread(); - } -} diff --git a/src/demo/share/jpda/com/sun/tools/example/debug/event/LocationTriggerEventSet.java b/src/demo/share/jpda/com/sun/tools/example/debug/event/LocationTriggerEventSet.java deleted file mode 100644 --- a/src/demo/share/jpda/com/sun/tools/example/debug/event/LocationTriggerEventSet.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code 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 - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * This source code is provided to illustrate the usage of a given feature - * or technique and has been deliberately simplified. Additional steps - * required for a production-quality application, such as security checks, - * input validation and proper error handling, might not be present in - * this sample code. - */ - - -package com.sun.tools.example.debug.event; - -import com.sun.jdi.event.*; - -public class LocationTriggerEventSet extends LocatableEventSet { - - private static final long serialVersionUID = -3674631710485872487L; - - LocationTriggerEventSet(EventSet jdiEventSet) { - super(jdiEventSet); - } - - @Override - public void notify(JDIListener listener) { - listener.locationTrigger(this); - } -} diff --git a/src/demo/share/jpda/com/sun/tools/example/debug/event/ModificationWatchpointEventSet.java b/src/demo/share/jpda/com/sun/tools/example/debug/event/ModificationWatchpointEventSet.java deleted file mode 100644 --- a/src/demo/share/jpda/com/sun/tools/example/debug/event/ModificationWatchpointEventSet.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code 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 - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * This source code is provided to illustrate the usage of a given feature - * or technique and has been deliberately simplified. Additional steps - * required for a production-quality application, such as security checks, - * input validation and proper error handling, might not be present in - * this sample code. - */ - - -package com.sun.tools.example.debug.event; - -import com.sun.jdi.*; -import com.sun.jdi.event.*; - -public class ModificationWatchpointEventSet extends WatchpointEventSet { - - private static final long serialVersionUID = -680889300856154719L; - - ModificationWatchpointEventSet(EventSet jdiEventSet) { - super(jdiEventSet); - } - - /** - * Value that will be assigned to the field when the instruction - * completes. - */ - public Value getValueToBe() { - return ((ModificationWatchpointEvent)oneEvent).valueToBe(); - } - - @Override - public void notify(JDIListener listener) { - listener.modificationWatchpoint(this); - } -} diff --git a/src/demo/share/jpda/com/sun/tools/example/debug/event/ThreadDeathEventSet.java b/src/demo/share/jpda/com/sun/tools/example/debug/event/ThreadDeathEventSet.java deleted file mode 100644 --- a/src/demo/share/jpda/com/sun/tools/example/debug/event/ThreadDeathEventSet.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code 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 - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * This source code is provided to illustrate the usage of a given feature - * or technique and has been deliberately simplified. Additional steps - * required for a production-quality application, such as security checks, - * input validation and proper error handling, might not be present in - * this sample code. - */ - - -package com.sun.tools.example.debug.event; - -import com.sun.jdi.*; -import com.sun.jdi.event.*; - -public class ThreadDeathEventSet extends AbstractEventSet { - - private static final long serialVersionUID = -8801604712308151331L; - - ThreadDeathEventSet(EventSet jdiEventSet) { - super(jdiEventSet); - } - - /** - * Returns the thread which is terminating. - * - * @return a {@link ThreadReference} which mirrors the event's thread in - * the target VM. - */ - public ThreadReference getThread() { - return ((ThreadDeathEvent)oneEvent).thread(); - } - - @Override - public void notify(JDIListener listener) { - listener.threadDeath(this); - } -} diff --git a/src/demo/share/jpda/com/sun/tools/example/debug/event/ThreadStartEventSet.java b/src/demo/share/jpda/com/sun/tools/example/debug/event/ThreadStartEventSet.java deleted file mode 100644 --- a/src/demo/share/jpda/com/sun/tools/example/debug/event/ThreadStartEventSet.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code 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 - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * This source code is provided to illustrate the usage of a given feature - * or technique and has been deliberately simplified. Additional steps - * required for a production-quality application, such as security checks, - * input validation and proper error handling, might not be present in - * this sample code. - */ - - -package com.sun.tools.example.debug.event; - -import com.sun.jdi.*; -import com.sun.jdi.event.*; - -public class ThreadStartEventSet extends AbstractEventSet { - - private static final long serialVersionUID = -3802096132294933502L; - - ThreadStartEventSet(EventSet jdiEventSet) { - super(jdiEventSet); - } - - /** - * Returns the thread which has started. - * - * @return a {@link ThreadReference} which mirrors the event's thread in - * the target VM. - */ - public ThreadReference getThread() { - return ((ThreadStartEvent)oneEvent).thread(); - } - - @Override - public void notify(JDIListener listener) { - listener.threadStart(this); - } -} diff --git a/src/demo/share/jpda/com/sun/tools/example/debug/event/VMDeathEventSet.java b/src/demo/share/jpda/com/sun/tools/example/debug/event/VMDeathEventSet.java deleted file mode 100644 --- a/src/demo/share/jpda/com/sun/tools/example/debug/event/VMDeathEventSet.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code 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 - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * This source code is provided to illustrate the usage of a given feature - * or technique and has been deliberately simplified. Additional steps - * required for a production-quality application, such as security checks, - * input validation and proper error handling, might not be present in - * this sample code. - */ - - -package com.sun.tools.example.debug.event; - -import com.sun.jdi.event.*; - -public class VMDeathEventSet extends AbstractEventSet { - - private static final long serialVersionUID = 1163097303940092229L; - - VMDeathEventSet(EventSet jdiEventSet) { - super(jdiEventSet); - } - - @Override - public void notify(JDIListener listener) { - listener.vmDeath(this); - } -} diff --git a/src/demo/share/jpda/com/sun/tools/example/debug/event/VMDisconnectEventSet.java b/src/demo/share/jpda/com/sun/tools/example/debug/event/VMDisconnectEventSet.java deleted file mode 100644 --- a/src/demo/share/jpda/com/sun/tools/example/debug/event/VMDisconnectEventSet.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code 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 - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * This source code is provided to illustrate the usage of a given feature - * or technique and has been deliberately simplified. Additional steps - * required for a production-quality application, such as security checks, - * input validation and proper error handling, might not be present in - * this sample code. - */ - - -package com.sun.tools.example.debug.event; - -import com.sun.jdi.event.*; - -public class VMDisconnectEventSet extends AbstractEventSet { - - private static final long serialVersionUID = 7968123152344675342L; - - VMDisconnectEventSet(EventSet jdiEventSet) { - super(jdiEventSet); - } - - @Override - public void notify(JDIListener listener) { - listener.vmDisconnect(this); - } -} diff --git a/src/demo/share/jpda/com/sun/tools/example/debug/event/VMStartEventSet.java b/src/demo/share/jpda/com/sun/tools/example/debug/event/VMStartEventSet.java deleted file mode 100644 --- a/src/demo/share/jpda/com/sun/tools/example/debug/event/VMStartEventSet.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code 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 - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * This source code is provided to illustrate the usage of a given feature - * or technique and has been deliberately simplified. Additional steps - * required for a production-quality application, such as security checks, - * input validation and proper error handling, might not be present in - * this sample code. - */ - - -package com.sun.tools.example.debug.event; - -import com.sun.jdi.*; -import com.sun.jdi.event.*; - -public class VMStartEventSet extends AbstractEventSet { - - private static final long serialVersionUID = -3384957227835478191L; - - VMStartEventSet(EventSet jdiEventSet) { - super(jdiEventSet); - } - - /** - * Returns the initial thread of the VM which has started. - * - * @return a {@link ThreadReference} which mirrors the event's - * thread in the target VM. - */ - public ThreadReference getThread() { - return ((VMStartEvent)oneEvent).thread(); - } - - @Override - public void notify(JDIListener listener) { - listener.vmStart(this); - } -} diff --git a/src/demo/share/jpda/com/sun/tools/example/debug/event/WatchpointEventSet.java b/src/demo/share/jpda/com/sun/tools/example/debug/event/WatchpointEventSet.java deleted file mode 100644 --- a/src/demo/share/jpda/com/sun/tools/example/debug/event/WatchpointEventSet.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code 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 - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * This source code is provided to illustrate the usage of a given feature - * or technique and has been deliberately simplified. Additional steps - * required for a production-quality application, such as security checks, - * input validation and proper error handling, might not be present in - * this sample code. - */ - - -package com.sun.tools.example.debug.event; - -import com.sun.jdi.*; -import com.sun.jdi.event.*; - -public abstract class WatchpointEventSet extends LocatableEventSet { - - private static final long serialVersionUID = 5606285209703845409L; - - WatchpointEventSet(EventSet jdiEventSet) { - super(jdiEventSet); - } - - /** - * Returns the field that is about to be accessed/modified. - * - * @return a {@link Field} which mirrors the field - * in the target VM. - */ - public Field getField() { - return ((WatchpointEvent)oneEvent).field(); - } - - /** - * Returns the object whose field is about to be accessed/modified. - * Return null is the access is to a static field. - * - * @return a {@link ObjectReference} which mirrors the event's - * object in the target VM. - */ - public ObjectReference getObject() { - return ((WatchpointEvent)oneEvent).object(); - } - - /** - * Current value of the field. - */ - public Value getValueCurrent() { - return ((WatchpointEvent)oneEvent).valueCurrent(); - } -} diff --git a/src/demo/share/jpda/com/sun/tools/example/debug/gui/ApplicationTool.java b/src/demo/share/jpda/com/sun/tools/example/debug/gui/ApplicationTool.java deleted file mode 100644 --- a/src/demo/share/jpda/com/sun/tools/example/debug/gui/ApplicationTool.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code 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 - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * This source code is provided to illustrate the usage of a given feature - * or technique and has been deliberately simplified. Additional steps - * required for a production-quality application, such as security checks, - * input validation and proper error handling, might not be present in - * this sample code. - */ - - -package com.sun.tools.example.debug.gui; - -import javax.swing.*; -import java.awt.*; -import java.awt.event.*; - -import com.sun.tools.example.debug.bdi.*; - -public class ApplicationTool extends JPanel { - - private static final long serialVersionUID = 310966063293205714L; - - private ExecutionManager runtime; - - private TypeScript script; - - private static final String PROMPT = "Input:"; - - public ApplicationTool(Environment env) { - - super(new BorderLayout()); - - this.runtime = env.getExecutionManager(); - - this.script = new TypeScript(PROMPT, false); // No implicit echo. - this.add(script); - - script.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - runtime.sendLineToApplication(script.readln()); - } - }); - - runtime.addApplicationEchoListener(new TypeScriptOutputListener(script)); - runtime.addApplicationOutputListener(new TypeScriptOutputListener(script)); - runtime.addApplicationErrorListener(new TypeScriptOutputListener(script)); - - //### should clean up on exit! - - } - - /****** - public void setFont(Font f) { - script.setFont(f); - } - ******/ - -} diff --git a/src/demo/share/jpda/com/sun/tools/example/debug/gui/ClassManager.java b/src/demo/share/jpda/com/sun/tools/example/debug/gui/ClassManager.java deleted file mode 100644 --- a/src/demo/share/jpda/com/sun/tools/example/debug/gui/ClassManager.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code 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 - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * This source code is provided to illustrate the usage of a given feature - * or technique and has been deliberately simplified. Additional steps - * required for a production-quality application, such as security checks, - * input validation and proper error handling, might not be present in - * this sample code. - */ - - -package com.sun.tools.example.debug.gui; - -public class ClassManager { - - // This class is provided primarily for symmetry with - // SourceManager. Currently, it does very little. - // If we add facilities in the future that require that - // class files be read outside of the VM, for example, to - // provide a disassembled view of a class for bytecode-level - // debugging, the required class file management will be done - // here. - - private SearchPath classPath; - - public ClassManager(Environment env) { - this.classPath = new SearchPath(""); - } - - public ClassManager(SearchPath classPath) { - this.classPath = classPath; - } - - /* - * Set path for access to class files. - */ - - public void setClassPath(SearchPath sp) { - classPath = sp; - } - - /* - * Get path for access to class files. - */ - - public SearchPath getClassPath() { - return classPath; - } - -} diff --git a/src/demo/share/jpda/com/sun/tools/example/debug/gui/ClassTreeTool.java b/src/demo/share/jpda/com/sun/tools/example/debug/gui/ClassTreeTool.java deleted file mode 100644 --- a/src/demo/share/jpda/com/sun/tools/example/debug/gui/ClassTreeTool.java +++ /dev/null @@ -1,287 +0,0 @@ -/* - * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code 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 - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * This source code is provided to illustrate the usage of a given feature - * or technique and has been deliberately simplified. Additional steps - * required for a production-quality application, such as security checks, - * input validation and proper error handling, might not be present in - * this sample code. - */ - - -package com.sun.tools.example.debug.gui; - -import java.util.*; - -import javax.swing.*; -import javax.swing.tree.*; -import java.awt.*; -import java.awt.event.*; - -import com.sun.jdi.*; -import com.sun.tools.example.debug.event.*; -import com.sun.tools.example.debug.bdi.*; - -public class ClassTreeTool extends JPanel { - - private static final long serialVersionUID = 526178912591739259L; - - private Environment env; - - private ExecutionManager runtime; - private SourceManager sourceManager; - private ClassManager classManager; - - private JTree tree; - private DefaultTreeModel treeModel; - private ClassTreeNode root; -// private SearchPath sourcePath; - - private CommandInterpreter interpreter; - - private static String HEADING = "CLASSES"; - - public ClassTreeTool(Environment env) { - - super(new BorderLayout()); - - this.env = env; - this.runtime = env.getExecutionManager(); - this.sourceManager = env.getSourceManager(); - - this.interpreter = new CommandInterpreter(env); - - root = createClassTree(HEADING); - treeModel = new DefaultTreeModel(root); - - // Create a tree that allows one selection at a time. - - tree = new JTree(treeModel); - tree.setSelectionModel(new SingleLeafTreeSelectionModel()); - - /****** - // Listen for when the selection changes. - tree.addTreeSelectionListener(new TreeSelectionListener() { - public void valueChanged(TreeSelectionEvent e) { - ClassTreeNode node = (ClassTreeNode) - (e.getPath().getLastPathComponent()); - if (node != null) { - interpreter.executeCommand("view " + node.getReferenceTypeName()); - } - } - }); - ******/ - - MouseListener ml = new MouseAdapter() { - @Override - public void mouseClicked(MouseEvent e) { - int selRow = tree.getRowForLocation(e.getX(), e.getY()); - TreePath selPath = tree.getPathForLocation(e.getX(), e.getY()); - if(selRow != -1) { - if(e.getClickCount() == 1) { - ClassTreeNode node = - (ClassTreeNode)selPath.getLastPathComponent(); - // If user clicks on leaf, select it, and issue 'view' command. - if (node.isLeaf()) { - tree.setSelectionPath(selPath); - interpreter.executeCommand("view " + node.getReferenceTypeName()); - } - } - } - } - }; - tree.addMouseListener(ml); - - JScrollPane treeView = new JScrollPane(tree); - add(treeView); - - // Create listener. - ClassTreeToolListener listener = new ClassTreeToolListener(); - runtime.addJDIListener(listener); - runtime.addSessionListener(listener); - - //### remove listeners on exit! - } - - private class ClassTreeToolListener extends JDIAdapter - implements JDIListener, SessionListener { - - // SessionListener - - @Override - public void sessionStart(EventObject e) { - // Get system classes and any others loaded before attaching. - try { - for (ReferenceType type : runtime.allClasses()) { - root.addClass(type); - } - } catch (VMDisconnectedException ee) { - // VM terminated unexpectedly. - } catch (NoSessionException ee) { - // Ignore. Should not happen. - } - } - - @Override - public void sessionInterrupt(EventObject e) {} - @Override - public void sessionContinue(EventObject e) {} - - // JDIListener - - @Override - public void classPrepare(ClassPrepareEventSet e) { - root.addClass(e.getReferenceType()); - } - - @Override - public void classUnload(ClassUnloadEventSet e) { - root.removeClass(e.getClassName()); - } - - @Override - public void vmDisconnect(VMDisconnectEventSet e) { - // Clear contents of this view. - root = createClassTree(HEADING); - treeModel = new DefaultTreeModel(root); - tree.setModel(treeModel); - } - } - - ClassTreeNode createClassTree(String label) { - return new ClassTreeNode(label, null); - } - - class ClassTreeNode extends DefaultMutableTreeNode { - - private String name; - private ReferenceType refTy; // null for package - - ClassTreeNode(String name, ReferenceType refTy) { - this.name = name; - this.refTy = refTy; - } - - @Override - public String toString() { - return name; - } - - public ReferenceType getReferenceType() { - return refTy; - } - - public String getReferenceTypeName() { - return refTy.name(); - } - - private boolean isPackage() { - return (refTy == null); - } - - @Override - public boolean isLeaf() { - return !isPackage(); - } - - public void addClass(ReferenceType refTy) { - addClass(refTy.name(), refTy); - } - - private void addClass(String className, ReferenceType refTy) { - if (className.equals("")) { - return; - } - int pos = className.indexOf('.'); - if (pos < 0) { - insertNode(className, refTy); - } else { - String head = className.substring(0, pos); - String tail = className.substring(pos + 1); - ClassTreeNode child = insertNode(head, null); - child.addClass(tail, refTy); - } - } - - private ClassTreeNode insertNode(String name, ReferenceType refTy) { - for (int i = 0; i < getChildCount(); i++) { - ClassTreeNode child = (ClassTreeNode)getChildAt(i); - int cmp = name.compareTo(child.toString()); - if (cmp == 0) { - // like-named node already exists - return child; - } else if (cmp < 0) { - // insert new node before the child - ClassTreeNode newChild = new ClassTreeNode(name, refTy); - treeModel.insertNodeInto(newChild, this, i); - return newChild; - } - } - // insert new node after last child - ClassTreeNode newChild = new ClassTreeNode(name, refTy); - treeModel.insertNodeInto(newChild, this, getChildCount()); - return newChild; - } - - public void removeClass(String className) { - if (className.equals("")) { - return; - } - int pos = className.indexOf('.'); - if (pos < 0) { - ClassTreeNode child = findNode(className); - if (!isPackage()) { - treeModel.removeNodeFromParent(child); - } - } else { - String head = className.substring(0, pos); - String tail = className.substring(pos + 1); - ClassTreeNode child = findNode(head); - child.removeClass(tail); - if (isPackage() && child.getChildCount() < 1) { - // Prune non-leaf nodes with no children. - treeModel.removeNodeFromParent(child); - } - } - } - - private ClassTreeNode findNode(String name) { - for (int i = 0; i < getChildCount(); i++) { - ClassTreeNode child = (ClassTreeNode)getChildAt(i); - int cmp = name.compareTo(child.toString()); - if (cmp == 0) { - return child; - } else if (cmp > 0) { - // not found, since children are sorted - return null; - } - } - return null; - } - - } - -} diff --git a/src/demo/share/jpda/com/sun/tools/example/debug/gui/CommandInterpreter.java b/src/demo/share/jpda/com/sun/tools/example/debug/gui/CommandInterpreter.java deleted file mode 100644 --- a/src/demo/share/jpda/com/sun/tools/example/debug/gui/CommandInterpreter.java +++ /dev/null @@ -1,1468 +0,0 @@ -/* - * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code 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 - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * This source code is provided to illustrate the usage of a given feature - * or technique and has been deliberately simplified. Additional steps - * required for a production-quality application, such as security checks, - * input validation and proper error handling, might not be present in - * this sample code. - */ - - -package com.sun.tools.example.debug.gui; - -import java.io.*; -import java.util.*; - -import com.sun.jdi.*; -import com.sun.tools.example.debug.bdi.*; - -public class CommandInterpreter { - - boolean echo; - - Environment env; - - private ContextManager context; - private ExecutionManager runtime; - private ClassManager classManager; - private SourceManager sourceManager; - - private OutputSink out; //### Hack! Should be local in each method used. - private String lastCommand = "help"; - - public CommandInterpreter(Environment env) { - this(env, true); - } - - public CommandInterpreter(Environment env, boolean echo) { - this.env = env; - this.echo = echo; - this.runtime = env.getExecutionManager(); - this.context = env.getContextManager(); - this.classManager = env.getClassManager(); - this.sourceManager = env.getSourceManager(); - } - - private ThreadReference[] threads = null; - - /* - * The numbering of threads is relative to the current set of threads, - * and may be affected by the creation and termination of new threads. - * Commands issued using such thread ids will only give reliable behavior - * relative to what was shown earlier in 'list' commands if the VM is interrupted. - * We need a better scheme. - */ - - private ThreadReference[] threads() throws NoSessionException { - if (threads == null) { - ThreadIterator ti = new ThreadIterator(getDefaultThreadGroup()); - List tlist = new ArrayList(); - while (ti.hasNext()) { - tlist.add(ti.nextThread()); - } - threads = tlist.toArray(new ThreadReference[tlist.size()]); - } - return threads; - } - - private ThreadReference findThread(String idToken) throws NoSessionException { - String id; - ThreadReference thread = null; - if (idToken.startsWith("t@")) { - id = idToken.substring(2); - } else { - id = idToken; - } - try { - ThreadReference[] threads = threads(); - long threadID = Long.parseLong(id, 16); - for (ThreadReference thread2 : threads) { - if (thread2.uniqueID() == threadID) { - thread = thread2; - break; - } - } - if (thread == null) { - //env.failure("No thread for id \"" + idToken + "\""); - env.failure("\"" + idToken + "\" is not a valid thread id."); - } - } catch (NumberFormatException e) { - env.error("Thread id \"" + idToken + "\" is ill-formed."); - thread = null; - } - return thread; - } - - private ThreadIterator allThreads() throws NoSessionException { - threads = null; - //### Why not use runtime.allThreads().iterator() ? - return new ThreadIterator(runtime.topLevelThreadGroups()); - } - - private ThreadIterator currentThreadGroupThreads() throws NoSessionException { - threads = null; - return new ThreadIterator(getDefaultThreadGroup()); - } - - private ThreadGroupIterator allThreadGroups() throws NoSessionException { - threads = null; - return new ThreadGroupIterator(runtime.topLevelThreadGroups()); - } - - private ThreadGroupReference defaultThreadGroup; - - private ThreadGroupReference getDefaultThreadGroup() throws NoSessionException { - if (defaultThreadGroup == null) { - defaultThreadGroup = runtime.systemThreadGroup(); - } - return defaultThreadGroup; - } - - private void setDefaultThreadGroup(ThreadGroupReference tg) { - defaultThreadGroup = tg; - } - - /* - * Command handlers. - */ - - // Command: classes - - private void commandClasses() throws NoSessionException { - OutputSink out = env.getOutputSink(); - //out.println("** classes list **"); - for (ReferenceType refType : runtime.allClasses()) { - out.println(refType.name()); - } - out.show(); - } - - - // Command: methods - - private void commandMethods(StringTokenizer t) throws NoSessionException { - if (!t.hasMoreTokens()) { - env.error("No class specified."); - return; - } - String idClass = t.nextToken(); - ReferenceType cls = findClass(idClass); - if (cls != null) { - List methods = cls.allMethods(); - OutputSink out = env.getOutputSink(); - for (int i = 0; i < methods.size(); i++) { - Method method = methods.get(i); - out.print(method.declaringType().name() + " " + - method.name() + "("); - Iterator it = method.argumentTypeNames().iterator(); - if (it.hasNext()) { - while (true) { - out.print(it.next()); - if (!it.hasNext()) { - break; - } - out.print(", "); - } - } - out.println(")"); - } - out.show(); - } else { - //### Should validate class name syntax. - env.failure("\"" + idClass + "\" is not a valid id or class name."); - } - } - - private ReferenceType findClass(String pattern) throws NoSessionException { - List results = runtime.findClassesMatchingPattern(pattern); - if (results.size() > 0) { - //### Should handle multiple results sensibly. - return results.get(0); - } - return null; - } - - // Command: threads - - private void commandThreads(StringTokenizer t) throws NoSessionException { - if (!t.hasMoreTokens()) { - OutputSink out = env.getOutputSink(); - printThreadGroup(out, getDefaultThreadGroup(), 0); - out.show(); - return; - } - String name = t.nextToken(); - ThreadGroupReference tg = findThreadGroup(name); - if (tg == null) { - env.failure(name + " is not a valid threadgroup name."); - } else { - OutputSink out = env.getOutputSink(); - printThreadGroup(out, tg, 0); - out.show(); - } - } - - private ThreadGroupReference findThreadGroup(String name) throws NoSessionException { - //### Issue: Uniqueness of thread group names is not enforced. - ThreadGroupIterator tgi = allThreadGroups(); - while (tgi.hasNext()) { - ThreadGroupReference tg = tgi.nextThreadGroup(); - if (tg.name().equals(name)) { - return tg; - } - } - return null; - } - - private int printThreadGroup(OutputSink out, ThreadGroupReference tg, int iThread) { - out.println("Group " + tg.name() + ":"); - List tlist = tg.threads(); - int maxId = 0; - int maxName = 0; - for (int i = 0 ; i < tlist.size() ; i++) { - ThreadReference thr = tlist.get(i); - int len = Utils.description(thr).length(); - if (len > maxId) { - maxId = len; - } - String name = thr.name(); - int iDot = name.lastIndexOf('.'); - if (iDot >= 0 && name.length() > iDot) { - name = name.substring(iDot + 1); - } - if (name.length() > maxName) { - maxName = name.length(); - } - } - String maxNumString = String.valueOf(iThread + tlist.size()); - int maxNumDigits = maxNumString.length(); - for (int i = 0 ; i < tlist.size() ; i++) { - ThreadReference thr = tlist.get(i); - char buf[] = new char[80]; - for (int j = 0; j < 79; j++) { - buf[j] = ' '; - } - buf[79] = '\0'; - StringBuilder sbOut = new StringBuilder(); - sbOut.append(buf); - - // Right-justify the thread number at start of output string - String numString = String.valueOf(iThread + i + 1); - sbOut.insert(maxNumDigits - numString.length(), - numString); - sbOut.insert(maxNumDigits, "."); - - int iBuf = maxNumDigits + 2; - sbOut.insert(iBuf, Utils.description(thr)); - iBuf += maxId + 1; - String name = thr.name(); - int iDot = name.lastIndexOf('.'); - if (iDot >= 0 && name.length() > iDot) { - name = name.substring(iDot + 1); - } - sbOut.insert(iBuf, name); - iBuf += maxName + 1; - sbOut.insert(iBuf, Utils.getStatus(thr)); - sbOut.setLength(79); - out.println(sbOut.toString()); - } - for (ThreadGroupReference tg0 : tg.threadGroups()) { - if (!tg.equals(tg0)) { // TODO ref mgt - iThread += printThreadGroup(out, tg0, iThread + tlist.size()); - } - } - return tlist.size(); - } - - // Command: threadgroups - - private void commandThreadGroups() throws NoSessionException { - ThreadGroupIterator it = allThreadGroups(); - int cnt = 0; - OutputSink out = env.getOutputSink(); - while (it.hasNext()) { - ThreadGroupReference tg = it.nextThreadGroup(); - ++cnt; - out.println("" + cnt + ". " + Utils.description(tg) + " " + tg.name()); - } - out.show(); - } - - // Command: thread - - private void commandThread(StringTokenizer t) throws NoSessionException { - if (!t.hasMoreTokens()) { - env.error("Thread number not specified."); - return; - } - ThreadReference thread = findThread(t.nextToken()); - if (thread != null) { - //### Should notify user. - context.setCurrentThread(thread); - } - } - - // Command: threadgroup - - private void commandThreadGroup(StringTokenizer t) throws NoSessionException { - if (!t.hasMoreTokens()) { - env.error("Threadgroup name not specified."); - return; - } - String name = t.nextToken(); - ThreadGroupReference tg = findThreadGroup(name); - if (tg == null) { - env.failure(name + " is not a valid threadgroup name."); - } else { - //### Should notify user. - setDefaultThreadGroup(tg); - } - } - - // Command: run - - private void commandRun(StringTokenizer t) throws NoSessionException { - if (doLoad(false, t)) { - env.notice("Running ..."); - } - } - - // Command: load - - private void commandLoad(StringTokenizer t) throws NoSessionException { - if (doLoad(true, t)) {} - } - - private boolean doLoad(boolean suspended, - StringTokenizer t) throws NoSessionException { - - String clname; - - if (!t.hasMoreTokens()) { - clname = context.getMainClassName(); - if (!clname.equals("")) { - // Run from prevously-set class name. - try { - String vmArgs = context.getVmArguments(); - runtime.run(suspended, - vmArgs, - clname, - context.getProgramArguments()); - return true; - } catch (VMLaunchFailureException e) { - env.failure("Attempt to launch main class \"" + clname + "\" failed."); - } - } else { - env.failure("No main class specified and no current default defined."); - } - } else { - clname = t.nextToken(); - StringBuilder str = new StringBuilder(); - // Allow VM arguments to be specified here? - while (t.hasMoreTokens()) { - String tok = t.nextToken(); - str.append(tok); - if (t.hasMoreTokens()) { - str.append(' '); - } - } - String args = str.toString(); - try { - String vmArgs = context.getVmArguments(); - runtime.run(suspended, vmArgs, clname, args); - context.setMainClassName(clname); - //context.setVmArguments(vmArgs); - context.setProgramArguments(args); - return true; - } catch (VMLaunchFailureException e) { - env.failure("Attempt to launch main class \"" + clname + "\" failed."); - } - } - return false; - } - - // Command: connect - - private void commandConnect(StringTokenizer t) { - try { - LaunchTool.queryAndLaunchVM(runtime); - } catch (VMLaunchFailureException e) { - env.failure("Attempt to connect failed."); - } - } - - // Command: attach - - private void commandAttach(StringTokenizer t) { - String portName; - if (!t.hasMoreTokens()) { - portName = context.getRemotePort(); - if (!portName.equals("")) { - try { - runtime.attach(portName); - } catch (VMLaunchFailureException e) { - env.failure("Attempt to attach to port \"" + portName + "\" failed."); - } - } else { - env.failure("No port specified and no current default defined."); - } - } else { - portName = t.nextToken(); - try { - runtime.attach(portName); - } catch (VMLaunchFailureException e) { - env.failure("Attempt to attach to port \"" + portName + "\" failed."); - } - context.setRemotePort(portName); - } - } - - // Command: detach - - private void commandDetach(StringTokenizer t) throws NoSessionException { - runtime.detach(); - } - - // Command: interrupt - - private void commandInterrupt(StringTokenizer t) throws NoSessionException { - runtime.interrupt(); - } - - // Command: suspend - - private void commandSuspend(StringTokenizer t) throws NoSessionException { - if (!t.hasMoreTokens()) { - // Suspend all threads in the current thread group. - //### Issue: help message says default is all threads. - //### Behavior here agrees with 'jdb', however. - ThreadIterator ti = currentThreadGroupThreads(); - while (ti.hasNext()) { - // TODO - don't suspend debugger threads - ti.nextThread().suspend(); - } - env.notice("All (non-system) threads suspended."); - } else { - while (t.hasMoreTokens()) { - ThreadReference thread = findThread(t.nextToken()); - if (thread != null) { - //thread.suspend(); - runtime.suspendThread(thread); - } - } - } - } - - // Command: resume - - private void commandResume(StringTokenizer t) throws NoSessionException { - if (!t.hasMoreTokens()) { - // Suspend all threads in the current thread group. - //### Issue: help message says default is all threads. - //### Behavior here agrees with 'jdb', however. - ThreadIterator ti = currentThreadGroupThreads(); - while (ti.hasNext()) { - // TODO - don't suspend debugger threads - ti.nextThread().resume(); - } - env.notice("All threads resumed."); - } else { - while (t.hasMoreTokens()) { - ThreadReference thread = findThread(t.nextToken()); - if (thread != null) { - //thread.resume(); - runtime.resumeThread(thread); - } - } - } - } - - // Command: cont - - private void commandCont() throws NoSessionException { - try { - runtime.go(); - } catch (VMNotInterruptedException e) { - //### failure? - env.notice("Target VM is already running."); - } - } - - // Command: step - - private void commandStep(StringTokenizer t) throws NoSessionException{ - ThreadReference current = context.getCurrentThread(); - if (current == null) { - env.failure("No current thread."); - return; - } - try { - if (t.hasMoreTokens() && - t.nextToken().toLowerCase().equals("up")) { - runtime.stepOut(current); - } else { - runtime.stepIntoLine(current); - } - } catch (AbsentInformationException e) { - env.failure("No linenumber information available -- " + - "Try \"stepi\" to step by instructions."); - } - } - - // Command: stepi - - private void commandStepi() throws NoSessionException { - ThreadReference current = context.getCurrentThread(); - if (current == null) { - env.failure("No current thread."); - return; - } - runtime.stepIntoInstruction(current); - } - - // Command: next - - private void commandNext() throws NoSessionException { - ThreadReference current = context.getCurrentThread(); - if (current == null) { - env.failure("No current thread."); - return; - } - try { - runtime.stepOverLine(current); - } catch (AbsentInformationException e) { - env.failure("No linenumber information available -- " + - "Try \"nexti\" to step by instructions."); - } - } - - // Command: nexti (NEW) - - private void commandNexti() throws NoSessionException { - ThreadReference current = context.getCurrentThread(); - if (current == null) { - env.failure("No current thread."); - return; - } - runtime.stepOverInstruction(current); - } - - // Command: kill - - private void commandKill(StringTokenizer t) throws NoSessionException { - //### Should change the way in which thread ids and threadgroup names - //### are distinguished. - if (!t.hasMoreTokens()) { - env.error("Usage: kill or "); - return; - } - while (t.hasMoreTokens()) { - String idToken = t.nextToken(); - ThreadReference thread = findThread(idToken); - if (thread != null) { - runtime.stopThread(thread); - env.notice("Thread " + thread.name() + " killed."); - return; - } else { - /* Check for threadgroup name, NOT skipping "system". */ - //### Should skip "system"? Classic 'jdb' does this. - //### Should deal with possible non-uniqueness of threadgroup names. - ThreadGroupIterator itg = allThreadGroups(); - while (itg.hasNext()) { - ThreadGroupReference tg = itg.nextThreadGroup(); - if (tg.name().equals(idToken)) { - ThreadIterator it = new ThreadIterator(tg); - while (it.hasNext()) { - runtime.stopThread(it.nextThread()); - } - env.notice("Threadgroup " + tg.name() + "killed."); - return; - } - } - env.failure("\"" + idToken + - "\" is not a valid threadgroup or id."); - } - } - } - - - /************* - // TODO - private void commandCatchException(StringTokenizer t) throws NoSessionException {} - // TODO - private void commandIgnoreException(StringTokenizer t) throws NoSessionException {} - *************/ - - // Command: up - - //### Print current frame after command? - - int readCount(StringTokenizer t) { - int cnt = 1; - if (t.hasMoreTokens()) { - String idToken = t.nextToken(); - try { - cnt = Integer.valueOf(idToken).intValue(); - } catch (NumberFormatException e) { - cnt = -1; - } - } - return cnt; - } - - void commandUp(StringTokenizer t) throws NoSessionException { - ThreadReference current = context.getCurrentThread(); - if (current == null) { - env.failure("No current thread."); - return; - } - int nLevels = readCount(t); - if (nLevels <= 0) { - env.error("usage: up [n frames]"); - return; - } - try { - int delta = context.moveCurrentFrameIndex(current, -nLevels); - if (delta == 0) { - env.notice("Already at top of stack."); - } else if (-delta < nLevels) { - env.notice("Moved up " + delta + " frames to top of stack."); - } - } catch (VMNotInterruptedException e) { - env.failure("Target VM must be in interrupted state."); - } - } - - private void commandDown(StringTokenizer t) throws NoSessionException { - ThreadReference current = context.getCurrentThread(); - if (current == null) { - env.failure("No current thread."); - return; - } - int nLevels = readCount(t); - if (nLevels <= 0) { - env.error("usage: down [n frames]"); - return; - } - try { - int delta = context.moveCurrentFrameIndex(current, nLevels); - if (delta == 0) { - env.notice("Already at bottom of stack."); - } else if (delta < nLevels) { - env.notice("Moved down " + delta + " frames to bottom of stack."); - } - } catch (VMNotInterruptedException e) { - env.failure("Target VM must be in interrupted state."); - } - } - - // Command: frame - - private void commandFrame(StringTokenizer t) throws NoSessionException { - ThreadReference current = context.getCurrentThread(); - if (current == null) { - env.failure("No current thread."); - return; - } - if (!t.hasMoreTokens()) { - env.error("usage: frame "); - return; - } - String idToken = t.nextToken(); - int n; - try { - n = Integer.valueOf(idToken).intValue(); - } catch (NumberFormatException e) { - n = 0; - } - if (n <= 0) { - env.error("use positive frame index"); - return; - } - try { - int delta = context.setCurrentFrameIndex(current, n); - if (delta == 0) { - env.notice("Frame unchanged."); - } else if (delta < 0) { - env.notice("Moved up " + -delta + " frames."); - } else { - env.notice("Moved down " + delta + " frames."); - } - } catch (VMNotInterruptedException e) { - env.failure("Target VM must be in interrupted state."); - } - } - - // Command: where - - //### Should we insist that VM be interrupted here? - //### There is an inconsistency between the 'where' command - //### and 'up' and 'down' in this respect. - - private void commandWhere(StringTokenizer t, boolean showPC) - throws NoSessionException { - ThreadReference current = context.getCurrentThread(); - if (!t.hasMoreTokens()) { - if (current == null) { - env.error("No thread specified."); - return; - } - dumpStack(current, showPC); - } else { - String token = t.nextToken(); - if (token.toLowerCase().equals("all")) { - ThreadIterator it = allThreads(); - while (it.hasNext()) { - ThreadReference thread = it.next(); - out.println(thread.name() + ": "); - dumpStack(thread, showPC); - } - } else { - ThreadReference thread = findThread(t.nextToken()); - //### Do we want to set current thread here? - //### Should notify user of change. - if (thread != null) { - context.setCurrentThread(thread); - } - dumpStack(thread, showPC); - } - } - } - - private void dumpStack(ThreadReference thread, boolean showPC) { - //### Check for these. - //env.failure("Thread no longer exists."); - //env.failure("Target VM must be in interrupted state."); - //env.failure("Current thread isn't suspended."); - //### Should handle extremely long stack traces sensibly for user. - List stack = null; - try { - stack = thread.frames(); - } catch (IncompatibleThreadStateException e) { - env.failure("Thread is not suspended."); - } - //### Fix this! - //### Previously mishandled cases where thread was not current. - //### Now, prints all of the stack regardless of current frame. - int frameIndex = 0; - //int frameIndex = context.getCurrentFrameIndex(); - if (stack == null) { - env.failure("Thread is not running (no stack)."); - } else { - OutputSink out = env.getOutputSink(); - int nFrames = stack.size(); - for (int i = frameIndex; i < nFrames; i++) { - StackFrame frame = stack.get(i); - Location loc = frame.location(); - Method meth = loc.method(); - out.print(" [" + (i + 1) + "] "); - out.print(meth.declaringType().name()); - out.print('.'); - out.print(meth.name()); - out.print(" ("); - if (meth.isNative()) { - out.print("native method"); - } else if (loc.lineNumber() != -1) { - try { - out.print(loc.sourceName()); - } catch (AbsentInformationException e) { - out.print(""); - } - out.print(':'); - out.print(loc.lineNumber()); - } - out.print(')'); - if (showPC) { - long pc = loc.codeIndex(); - if (pc != -1) { - out.print(", pc = " + pc); - } - } - out.println(); - } - out.show(); - } - } - - private void listEventRequests() throws NoSessionException { - // Print set breakpoints - List specs = runtime.eventRequestSpecs(); - if (specs.isEmpty()) { - env.notice("No breakpoints/watchpoints/exceptions set."); - } else { - OutputSink out = env.getOutputSink(); - out.println("Current breakpoints/watchpoints/exceptions set:"); - for (EventRequestSpec bp : specs) { - out.println("\t" + bp); - } - out.show(); - } - } - - private BreakpointSpec parseBreakpointSpec(String bptSpec) { - StringTokenizer t = new StringTokenizer(bptSpec); - BreakpointSpec bpSpec = null; -// try { - String token = t.nextToken("@:( \t\n\r"); - // We can't use hasMoreTokens here because it will cause any leading - // paren to be lost. - String rest; - try { - rest = t.nextToken("").trim(); - } catch (NoSuchElementException e) { - rest = null; - } - if ((rest != null) && rest.startsWith("@")) { - t = new StringTokenizer(rest.substring(1)); - String sourceName = token; - String lineToken = t.nextToken(); - int lineNumber = Integer.valueOf(lineToken).intValue(); - if (t.hasMoreTokens()) { - return null; - } - bpSpec = runtime.createSourceLineBreakpoint(sourceName, - lineNumber); - } else if ((rest != null) && rest.startsWith(":")) { - t = new StringTokenizer(rest.substring(1)); - String classId = token; - String lineToken = t.nextToken(); - int lineNumber = Integer.valueOf(lineToken).intValue(); - if (t.hasMoreTokens()) { - return null; - } - bpSpec = runtime.createClassLineBreakpoint(classId, lineNumber); - } else { - // Try stripping method from class.method token. - int idot = token.lastIndexOf('.'); - if ( (idot <= 0) || /* No dot or dot in first char */ - (idot >= token.length() - 1) ) { /* dot in last char */ - return null; - } - String methodName = token.substring(idot + 1); - String classId = token.substring(0, idot); - List argumentList = null; - if (rest != null) { - if (!rest.startsWith("(") || !rest.endsWith(")")) { - //### Should throw exception with error message - //out.println("Invalid method specification: " - // + methodName + rest); - return null; - } - // Trim the parens - //### What about spaces in arglist? - rest = rest.substring(1, rest.length() - 1); - argumentList = new ArrayList(); - t = new StringTokenizer(rest, ","); - while (t.hasMoreTokens()) { - argumentList.add(t.nextToken()); - } - } - bpSpec = runtime.createMethodBreakpoint(classId, - methodName, - argumentList); - } -// } catch (Exception e) { -// env.error("Exception attempting to create breakpoint: " + e); -// return null; -// } - return bpSpec; - } - - private void commandStop(StringTokenizer t) throws NoSessionException { - String token; - - if (!t.hasMoreTokens()) { - listEventRequests(); - } else { - token = t.nextToken(); - // Ignore optional "at" or "in" token. - // Allowed for backward compatibility. - if (token.equals("at") || token.equals("in")) { - if (t.hasMoreTokens()) { - token = t.nextToken(); - } else { - env.error("Missing breakpoint specification."); - return; - } - } - BreakpointSpec bpSpec = parseBreakpointSpec(token); - if (bpSpec != null) { - //### Add sanity-checks for deferred breakpoint. - runtime.install(bpSpec); - } else { - env.error("Ill-formed breakpoint specification."); - } - } - } - - private void commandClear(StringTokenizer t) throws NoSessionException { - if (!t.hasMoreTokens()) { - // Print set breakpoints - listEventRequests(); - return; - } - //### need 'clear all' - BreakpointSpec bpSpec = parseBreakpointSpec(t.nextToken()); - if (bpSpec != null) { - List specs = runtime.eventRequestSpecs(); - - if (specs.isEmpty()) { - env.notice("No breakpoints set."); - } else { - List toDelete = new ArrayList(); - for (EventRequestSpec spec : specs) { - if (spec.equals(bpSpec)) { - toDelete.add(spec); - } - } - // The request used for matching should be found - if (toDelete.size() <= 1) { - env.notice("No matching breakpoint set."); - } - for (EventRequestSpec spec : toDelete) { - runtime.delete(spec); - } - } - } else { - env.error("Ill-formed breakpoint specification."); - } - } - - // Command: list - - private void commandList(StringTokenizer t) throws NoSessionException { - ThreadReference current = context.getCurrentThread(); - if (current == null) { - env.error("No thread specified."); - return; - } - Location loc; - try { - StackFrame frame = context.getCurrentFrame(current); - if (frame == null) { - env.failure("Thread has not yet begun execution."); - return; - } - loc = frame.location(); - } catch (VMNotInterruptedException e) { - env.failure("Target VM must be in interrupted state."); - return; - } - SourceModel source = sourceManager.sourceForLocation(loc); - if (source == null) { - if (loc.method().isNative()) { - env.failure("Current method is native."); - return; - } - env.failure("No source available for " + Utils.locationString(loc) + "."); - return; - } - ReferenceType refType = loc.declaringType(); - int lineno = loc.lineNumber(); - if (t.hasMoreTokens()) { - String id = t.nextToken(); - // See if token is a line number. - try { - lineno = Integer.valueOf(id).intValue(); - } catch (NumberFormatException nfe) { - // It isn't -- see if it's a method name. - List meths = refType.methodsByName(id); - if (meths == null || meths.size() == 0) { - env.failure(id + - " is not a valid line number or " + - "method name for class " + - refType.name()); - return; - } else if (meths.size() > 1) { - env.failure(id + - " is an ambiguous method name in" + - refType.name()); - return; - } - loc = meths.get(0).location(); - lineno = loc.lineNumber(); - } - } - int startLine = (lineno > 4) ? lineno - 4 : 1; - int endLine = startLine + 9; - String sourceLine = source.sourceLine(lineno); - if (sourceLine == null) { - env.failure("" + - lineno + - " is an invalid line number for " + - refType.name()); - } else { - OutputSink out = env.getOutputSink(); - for (int i = startLine; i <= endLine; i++) { - sourceLine = source.sourceLine(i); - if (sourceLine == null) { - break; - } - out.print(i); - out.print("\t"); - if (i == lineno) { - out.print("=> "); - } else { - out.print(" "); - } - out.println(sourceLine); - } - out.show(); - } - } - - // Command: use - // Get or set the source file path list. - - private void commandUse(StringTokenizer t) { - if (!t.hasMoreTokens()) { - out.println(sourceManager.getSourcePath().asString()); - } else { - //### Should throw exception for invalid path. - //### E.g., vetoable property change. - sourceManager.setSourcePath(new SearchPath(t.nextToken())); - } - } - - // Command: sourcepath - // Get or set the source file path list. (Alternate to 'use'.) - - private void commandSourcepath(StringTokenizer t) { - if (!t.hasMoreTokens()) { - out.println(sourceManager.getSourcePath().asString()); - } else { - //### Should throw exception for invalid path. - //### E.g., vetoable property change. - sourceManager.setSourcePath(new SearchPath(t.nextToken())); - } - } - - // Command: classpath - // Get or set the class file path list. - - private void commandClasspath(StringTokenizer t) { - if (!t.hasMoreTokens()) { - out.println(classManager.getClassPath().asString()); - } else { - //### Should throw exception for invalid path. - //### E.g., vetoable property change. - classManager.setClassPath(new SearchPath(t.nextToken())); - } - } - - // Command: view - // Display source for source file or class. - - private void commandView(StringTokenizer t) throws NoSessionException { - if (!t.hasMoreTokens()) { - env.error("Argument required"); - } else { - String name = t.nextToken(); - if (name.endsWith(".java") || - name.indexOf(File.separatorChar) >= 0) { - env.viewSource(name); - } else { - //### JDI crashes taking line number for class. - /***** - ReferenceType cls = findClass(name); - if (cls != null) { - env.viewLocation(cls.location()); - } else { - env.failure("No such class"); - } - *****/ - String fileName = name.replace('.', File.separatorChar) + ".java"; - env.viewSource(fileName); - } - } - } - - // Command: locals - // Print all local variables in current stack frame. - - private void commandLocals() throws NoSessionException { - ThreadReference current = context.getCurrentThread(); - if (current == null) { - env.failure("No default thread specified: " + - "use the \"thread\" command first."); - return; - } - StackFrame frame; - try { - frame = context.getCurrentFrame(current); - if (frame == null) { - env.failure("Thread has not yet created any stack frames."); - return; - } - } catch (VMNotInterruptedException e) { - env.failure("Target VM must be in interrupted state."); - return; - } - - List vars; - try { - vars = frame.visibleVariables(); - if (vars == null || vars.size() == 0) { - env.failure("No local variables"); - return; - } - } catch (AbsentInformationException e) { - env.failure("Local variable information not available." + - " Compile with -g to generate variable information"); - return; - } - - OutputSink out = env.getOutputSink(); - out.println("Method arguments:"); - for (LocalVariable var : vars) { - if (var.isArgument()) { - printVar(out, var, frame); - } - } - out.println("Local variables:"); - for (LocalVariable var : vars) { - if (!var.isArgument()) { - printVar(out, var, frame); - } - } - out.show(); - return; - } - - /** - * Command: monitor - * Monitor an expression - */ - private void commandMonitor(StringTokenizer t) throws NoSessionException { - if (!t.hasMoreTokens()) { - env.error("Argument required"); - } else { - env.getMonitorListModel().add(t.nextToken("")); - } - } - - /** - * Command: unmonitor - * Unmonitor an expression - */ - private void commandUnmonitor(StringTokenizer t) throws NoSessionException { - if (!t.hasMoreTokens()) { - env.error("Argument required"); - } else { - env.getMonitorListModel().remove(t.nextToken("")); - } - } - - // Print a stack variable. - - private void printVar(OutputSink out, LocalVariable var, StackFrame frame) { - out.print(" " + var.name()); - if (var.isVisible(frame)) { - Value val = frame.getValue(var); - out.println(" = " + val.toString()); - } else { - out.println(" is not in scope"); - } - } - - // Command: print - // Evaluate an expression. - - private void commandPrint(StringTokenizer t, boolean dumpObject) throws NoSessionException { - if (!t.hasMoreTokens()) { - //### Probably confused if expresion contains whitespace. - env.error("No expression specified."); - return; - } - ThreadReference current = context.getCurrentThread(); - if (current == null) { - env.failure("No default thread specified: " + - "use the \"thread\" command first."); - return; - } - StackFrame frame; - try { - frame = context.getCurrentFrame(current); - if (frame == null) { - env.failure("Thread has not yet created any stack frames."); - return; - } - } catch (VMNotInterruptedException e) { - env.failure("Target VM must be in interrupted state."); - return; - } - while (t.hasMoreTokens()) { - String expr = t.nextToken(""); - Value val = null; - try { - val = runtime.evaluate(frame, expr); - } catch(Exception e) { - env.error("Exception: " + e); - //### Fix this! - } - if (val == null) { - return; // Error message already printed - } - OutputSink out = env.getOutputSink(); - if (dumpObject && (val instanceof ObjectReference) && - !(val instanceof StringReference)) { - ObjectReference obj = (ObjectReference)val; - ReferenceType refType = obj.referenceType(); - out.println(expr + " = " + val.toString() + " {"); - dump(out, obj, refType, refType); - out.println("}"); - } else { - out.println(expr + " = " + val.toString()); - } - out.show(); - } - } - - private void dump(OutputSink out, - ObjectReference obj, ReferenceType refType, - ReferenceType refTypeBase) { - for (Field field : refType.fields()) { - out.print(" "); - if (!refType.equals(refTypeBase)) { - out.print(refType.name() + "."); - } - out.print(field.name() + ": "); - Object o = obj.getValue(field); - out.println((o == null) ? "null" : o.toString()); // Bug ID 4374471 - } - if (refType instanceof ClassType) { - ClassType sup = ((ClassType)refType).superclass(); - if (sup != null) { - dump(out, obj, sup, refTypeBase); - } - } else if (refType instanceof InterfaceType) { - for (InterfaceType sup : ((InterfaceType)refType).superinterfaces()) { - dump(out, obj, sup, refTypeBase); - } - } - } - - /* - * Display help message. - */ - - private void help() { - out.println("** command list **"); - out.println("threads [threadgroup] -- list threads"); - out.println("thread -- set default thread"); - out.println("suspend [thread id(s)] -- suspend threads (default: all)"); - out.println("resume [thread id(s)] -- resume threads (default: all)"); - out.println("where [thread id] | all -- dump a thread's stack"); - out.println("wherei [thread id] | all -- dump a thread's stack, with pc info"); - out.println("threadgroups -- list threadgroups"); - out.println("threadgroup -- set current threadgroup\n"); -// out.println("print -- print value of expression"); - out.println("dump -- print all object information\n"); -// out.println("eval -- evaluate expression (same as print)"); - out.println("locals -- print all local variables in current stack frame\n"); - out.println("classes -- list currently known classes"); - out.println("methods -- list a class's methods\n"); - out.println("stop [in] .[(argument_type,...)] -- set a breakpoint in a method"); - out.println("stop [at] : -- set a breakpoint at a line"); - out.println("up [n frames] -- move up a thread's stack"); - out.println("down [n frames] -- move down a thread's stack"); - out.println("frame -- to a frame"); - out.println("clear .[(argument_type,...)] -- clear a breakpoint in a method"); - out.println("clear : -- clear a breakpoint at a line"); - out.println("clear -- list breakpoints"); - out.println("step -- execute current line"); - out.println("step up -- execute until the current method returns to its caller"); - out.println("stepi -- execute current instruction"); - out.println("next -- step one line (step OVER calls)"); - out.println("nexti -- step one instruction (step OVER calls)"); - out.println("cont -- continue execution from breakpoint\n"); -// out.println("catch -- break for the specified exception"); -// out.println("ignore -- ignore when the specified exception\n"); - out.println("view classname|filename -- display source file"); - out.println("list [line number|method] -- print source code context at line or method"); - out.println("use -- display or change the source path\n"); -//### new - out.println("sourcepath -- display or change the source path\n"); -//### new - out.println("classpath -- display or change the class path\n"); - out.println("monitor -- evaluate an expression each time the program stops\n"); - out.println("unmonitor -- delete a monitor\n"); - out.println("read -- read and execute a command file\n"); -// out.println("memory -- report memory usage"); -// out.println("gc -- free unused objects\n"); - out.println("run [args] -- start execution of a Java class"); - out.println("run -- re-execute last class run"); - out.println("load [args] -- start execution of a Java class, initially suspended"); - out.println("load -- re-execute last class run, initially suspended"); - out.println("attach -- debug existing process\n"); - out.println("detach -- detach from debuggee process\n"); - out.println("kill -- kill a thread or threadgroup\n"); - out.println("!! -- repeat last command"); - out.println("help (or ?) -- list commands"); - out.println("exit (or quit) -- exit debugger"); - } - - /* - * Execute a command. - */ - - public void executeCommand(String command) { - //### Treatment of 'out' here is dirty... - out = env.getOutputSink(); - if (echo) { - out.println(">>> " + command); - } - StringTokenizer t = new StringTokenizer(command); - try { - String cmd; - if (t.hasMoreTokens()) { - cmd = t.nextToken().toLowerCase(); - lastCommand = cmd; - } else { - cmd = lastCommand; - } - if (cmd.equals("print")) { - commandPrint(t, false); - } else if (cmd.equals("eval")) { - commandPrint(t, false); - } else if (cmd.equals("dump")) { - commandPrint(t, true); - } else if (cmd.equals("locals")) { - commandLocals(); - } else if (cmd.equals("classes")) { - commandClasses(); - } else if (cmd.equals("methods")) { - commandMethods(t); - } else if (cmd.equals("threads")) { - commandThreads(t); - } else if (cmd.equals("thread")) { - commandThread(t); - } else if (cmd.equals("suspend")) { - commandSuspend(t); - } else if (cmd.equals("resume")) { - commandResume(t); - } else if (cmd.equals("cont")) { - commandCont(); - } else if (cmd.equals("threadgroups")) { - commandThreadGroups(); - } else if (cmd.equals("threadgroup")) { - commandThreadGroup(t); - } else if (cmd.equals("run")) { - commandRun(t); - } else if (cmd.equals("load")) { - commandLoad(t); - } else if (cmd.equals("connect")) { - commandConnect(t); - } else if (cmd.equals("attach")) { - commandAttach(t); - } else if (cmd.equals("detach")) { - commandDetach(t); - } else if (cmd.equals("interrupt")) { - commandInterrupt(t); -//### Not implemented. -// } else if (cmd.equals("catch")) { -// commandCatchException(t); -//### Not implemented. -// } else if (cmd.equals("ignore")) { -// commandIgnoreException(t); - } else if (cmd.equals("step")) { - commandStep(t); - } else if (cmd.equals("stepi")) { - commandStepi(); - } else if (cmd.equals("next")) { - commandNext(); - } else if (cmd.equals("nexti")) { - commandNexti(); - } else if (cmd.equals("kill")) { - commandKill(t); - } else if (cmd.equals("where")) { - commandWhere(t, false); - } else if (cmd.equals("wherei")) { - commandWhere(t, true); - } else if (cmd.equals("up")) { - commandUp(t); - } else if (cmd.equals("down")) { - commandDown(t); - } else if (cmd.equals("frame")) { - commandFrame(t); - } else if (cmd.equals("stop")) { - commandStop(t); - } else if (cmd.equals("clear")) { - commandClear(t); - } else if (cmd.equals("list")) { - commandList(t); - } else if (cmd.equals("use")) { - commandUse(t); - } else if (cmd.equals("sourcepath")) { - commandSourcepath(t); - } else if (cmd.equals("classpath")) { - commandClasspath(t); - } else if (cmd.equals("monitor")) { - commandMonitor(t); - } else if (cmd.equals("unmonitor")) { - commandUnmonitor(t); - } else if (cmd.equals("view")) { - commandView(t); -// } else if (cmd.equals("read")) { -// readCommand(t); - } else if (cmd.equals("help") || cmd.equals("?")) { - help(); - } else if (cmd.equals("quit") || cmd.equals("exit")) { - try { - runtime.detach(); - } catch (NoSessionException e) { - // ignore - } - env.terminate(); - } else { - //### Dubious repeat-count feature inherited from 'jdb' - if (t.hasMoreTokens()) { - try { - int repeat = Integer.parseInt(cmd); - String subcom = t.nextToken(""); - while (repeat-- > 0) { - executeCommand(subcom); - } - return; - } catch (NumberFormatException exc) { - } - } - out.println("huh? Try help..."); - out.flush(); - } - } catch (NoSessionException e) { - out.println("There is no currently attached VM session."); - out.flush(); - } catch (Exception e) { - out.println("Internal exception: " + e.toString()); - out.flush(); - System.out.println("JDB internal exception: " + e.toString()); - e.printStackTrace(); - } - out.show(); - } -} diff --git a/src/demo/share/jpda/com/sun/tools/example/debug/gui/CommandTool.java b/src/demo/share/jpda/com/sun/tools/example/debug/gui/CommandTool.java deleted file mode 100644 --- a/src/demo/share/jpda/com/sun/tools/example/debug/gui/CommandTool.java +++ /dev/null @@ -1,342 +0,0 @@ -/* - * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code 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 - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * This source code is provided to illustrate the usage of a given feature - * or technique and has been deliberately simplified. Additional steps - * required for a production-quality application, such as security checks, - * input validation and proper error handling, might not be present in - * this sample code. - */ - - -package com.sun.tools.example.debug.gui; - -import java.io.*; -import java.util.*; - -import javax.swing.*; -import java.awt.BorderLayout; -import java.awt.event.*; - -import com.sun.jdi.*; -import com.sun.jdi.event.*; - -import com.sun.tools.example.debug.bdi.*; -import com.sun.tools.example.debug.event.*; - -public class CommandTool extends JPanel { - - private static final long serialVersionUID = 8613516856378346415L; - - private Environment env; - - private ContextManager context; - private ExecutionManager runtime; - private SourceManager sourceManager; - - private TypeScript script; - - private static final String DEFAULT_CMD_PROMPT = "Command:"; - - public CommandTool(Environment env) { - - super(new BorderLayout()); - - this.env = env; - this.context = env.getContextManager(); - this.runtime = env.getExecutionManager(); - this.sourceManager = env.getSourceManager(); - - script = new TypeScript(DEFAULT_CMD_PROMPT, false); //no echo - this.add(script); - - final CommandInterpreter interpreter = - new CommandInterpreter(env); - - // Establish handler for incoming commands. - - script.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - interpreter.executeCommand(script.readln()); - } - }); - - // Establish ourselves as the listener for VM diagnostics. - - OutputListener diagnosticsListener = - new TypeScriptOutputListener(script, true); - runtime.addDiagnosticsListener(diagnosticsListener); - - // Establish ourselves as the shared debugger typescript. - - env.setTypeScript(new PrintWriter(new TypeScriptWriter(script))); - - // Handle VM events. - - TTYDebugListener listener = new TTYDebugListener(diagnosticsListener); - - runtime.addJDIListener(listener); - runtime.addSessionListener(listener); - runtime.addSpecListener(listener); - context.addContextListener(listener); - - //### remove listeners on exit! - - } - - private class TTYDebugListener implements - JDIListener, SessionListener, SpecListener, ContextListener { - - private OutputListener diagnostics; - - TTYDebugListener(OutputListener diagnostics) { - this.diagnostics = diagnostics; - } - - // JDIListener - - @Override - public void accessWatchpoint(AccessWatchpointEventSet e) { - setThread(e); - for (EventIterator it = e.eventIterator(); it.hasNext(); ) { - it.nextEvent(); - diagnostics.putString("Watchpoint hit: " + - locationString(e)); - } - } - - @Override - public void classPrepare(ClassPrepareEventSet e) { - if (context.getVerboseFlag()) { - String name = e.getReferenceType().name(); - diagnostics.putString("Class " + name + " loaded"); - } - } - - @Override - public void classUnload(ClassUnloadEventSet e) { - if (context.getVerboseFlag()) { - diagnostics.putString("Class " + e.getClassName() + - " unloaded."); - } - } - - @Override - public void exception(ExceptionEventSet e) { - setThread(e); - String name = e.getException().referenceType().name(); - diagnostics.putString("Exception: " + name); - } - - @Override - public void locationTrigger(LocationTriggerEventSet e) { - String locString = locationString(e); - setThread(e); - for (EventIterator it = e.eventIterator(); it.hasNext(); ) { - Event evt = it.nextEvent(); - if (evt instanceof BreakpointEvent) { - diagnostics.putString("Breakpoint hit: " + locString); - } else if (evt instanceof StepEvent) { - diagnostics.putString("Step completed: " + locString); - } else if (evt instanceof MethodEntryEvent) { - diagnostics.putString("Method entered: " + locString); - } else if (evt instanceof MethodExitEvent) { - diagnostics.putString("Method exited: " + locString); - } else { - diagnostics.putString("UNKNOWN event: " + e); - } - } - } - - @Override - public void modificationWatchpoint(ModificationWatchpointEventSet e) { - setThread(e); - for (EventIterator it = e.eventIterator(); it.hasNext(); ) { - it.nextEvent(); - diagnostics.putString("Watchpoint hit: " + - locationString(e)); - } - } - - @Override - public void threadDeath(ThreadDeathEventSet e) { - if (context.getVerboseFlag()) { - diagnostics.putString("Thread " + e.getThread() + - " ended."); - } - } - - @Override - public void threadStart(ThreadStartEventSet e) { - if (context.getVerboseFlag()) { - diagnostics.putString("Thread " + e.getThread() + - " started."); - } - } - - @Override - public void vmDeath(VMDeathEventSet e) { - script.setPrompt(DEFAULT_CMD_PROMPT); - diagnostics.putString("VM exited"); - } - - @Override - public void vmDisconnect(VMDisconnectEventSet e) { - script.setPrompt(DEFAULT_CMD_PROMPT); - diagnostics.putString("Disconnected from VM"); - } - - @Override - public void vmStart(VMStartEventSet e) { - script.setPrompt(DEFAULT_CMD_PROMPT); - diagnostics.putString("VM started"); - } - - // SessionListener - - @Override - public void sessionStart(EventObject e) {} - - @Override - public void sessionInterrupt(EventObject e) { - Thread.yield(); // fetch output - diagnostics.putString("VM interrupted by user."); - script.setPrompt(DEFAULT_CMD_PROMPT); - } - - @Override - public void sessionContinue(EventObject e) { - diagnostics.putString("Execution resumed."); - script.setPrompt(DEFAULT_CMD_PROMPT); - } - - // SpecListener - - @Override - public void breakpointSet(SpecEvent e) { - EventRequestSpec spec = e.getEventRequestSpec(); - diagnostics.putString("Breakpoint set at " + spec + "."); - } - @Override - public void breakpointDeferred(SpecEvent e) { - EventRequestSpec spec = e.getEventRequestSpec(); - diagnostics.putString("Breakpoint will be set at " + - spec + " when its class is loaded."); - } - @Override - public void breakpointDeleted(SpecEvent e) { - EventRequestSpec spec = e.getEventRequestSpec(); - diagnostics.putString("Breakpoint at " + spec.toString() + " deleted."); - } - @Override - public void breakpointResolved(SpecEvent e) { - EventRequestSpec spec = e.getEventRequestSpec(); - diagnostics.putString("Breakpoint resolved to " + spec.toString() + "."); - } - @Override - public void breakpointError(SpecErrorEvent e) { - EventRequestSpec spec = e.getEventRequestSpec(); - diagnostics.putString("Deferred breakpoint at " + - spec + " could not be resolved:" + - e.getReason()); - } - -//### Add info for watchpoints and exceptions - - @Override - public void watchpointSet(SpecEvent e) { - } - @Override - public void watchpointDeferred(SpecEvent e) { - } - @Override - public void watchpointDeleted(SpecEvent e) { - } - @Override - public void watchpointResolved(SpecEvent e) { - } - @Override - public void watchpointError(SpecErrorEvent e) { - } - - @Override - public void exceptionInterceptSet(SpecEvent e) { - } - @Override - public void exceptionInterceptDeferred(SpecEvent e) { - } - @Override - public void exceptionInterceptDeleted(SpecEvent e) { - } - @Override - public void exceptionInterceptResolved(SpecEvent e) { - } - @Override - public void exceptionInterceptError(SpecErrorEvent e) { - } - - - // ContextListener. - - // If the user selects a new current thread or frame, update prompt. - - @Override - public void currentFrameChanged(CurrentFrameChangedEvent e) { - // Update prompt only if affect thread is current. - ThreadReference thread = e.getThread(); - if (thread == context.getCurrentThread()) { - script.setPrompt(promptString(thread, e.getIndex())); - } - } - - } - - private String locationString(LocatableEventSet e) { - Location loc = e.getLocation(); - return "thread=\"" + e.getThread().name() + - "\", " + Utils.locationString(loc); - } - - private void setThread(LocatableEventSet e) { - if (!e.suspendedNone()) { - Thread.yield(); // fetch output - script.setPrompt(promptString(e.getThread(), 0)); - //### Current thread should be set elsewhere, e.g., - //### in ContextManager - //### context.setCurrentThread(thread); - } - } - - private String promptString(ThreadReference thread, int frameIndex) { - if (thread == null) { - return DEFAULT_CMD_PROMPT; - } else { - // Frame indices are presented to user as indexed from 1. - return (thread.name() + "[" + (frameIndex + 1) + "]:"); - } - } -} diff --git a/src/demo/share/jpda/com/sun/tools/example/debug/gui/ContextListener.java b/src/demo/share/jpda/com/sun/tools/example/debug/gui/ContextListener.java deleted file mode 100644 --- a/src/demo/share/jpda/com/sun/tools/example/debug/gui/ContextListener.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code 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 - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * This source code is provided to illustrate the usage of a given feature - * or technique and has been deliberately simplified. Additional steps - * required for a production-quality application, such as security checks, - * input validation and proper error handling, might not be present in - * this sample code. - */ - - -package com.sun.tools.example.debug.gui; - -public interface ContextListener { - void currentFrameChanged(CurrentFrameChangedEvent e); -} diff --git a/src/demo/share/jpda/com/sun/tools/example/debug/gui/ContextManager.java b/src/demo/share/jpda/com/sun/tools/example/debug/gui/ContextManager.java deleted file mode 100644 --- a/src/demo/share/jpda/com/sun/tools/example/debug/gui/ContextManager.java +++ /dev/null @@ -1,362 +0,0 @@ -/* - * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code 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 - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * This source code is provided to illustrate the usage of a given feature - * or technique and has been deliberately simplified. Additional steps - * required for a production-quality application, such as security checks, - * input validation and proper error handling, might not be present in - * this sample code. - */ - - -package com.sun.tools.example.debug.gui; - -import java.io.*; -import java.util.*; - -import com.sun.jdi.*; -import com.sun.tools.example.debug.event.*; -import com.sun.tools.example.debug.bdi.*; - -public class ContextManager { - - private ClassManager classManager; - private ExecutionManager runtime; - - private String mainClassName; - private String vmArguments; - private String commandArguments; - private String remotePort; - - private ThreadReference currentThread; - - private boolean verbose; - - private ArrayList contextListeners = new ArrayList(); - - public ContextManager(Environment env) { - classManager = env.getClassManager(); - runtime = env.getExecutionManager(); - mainClassName = ""; - vmArguments = ""; - commandArguments = ""; - currentThread = null; - - ContextManagerListener listener = new ContextManagerListener(); - runtime.addJDIListener(listener); - runtime.addSessionListener(listener); - } - - // Program execution defaults. - - //### Should there be change listeners for these? - //### They would be needed if we expected a dialog to be - //### synchronized with command input while it was open. - - public String getMainClassName() { - return mainClassName; - } - - public void setMainClassName(String mainClassName) { - this.mainClassName = mainClassName; - } - - public String getVmArguments() { - return processClasspathDefaults(vmArguments); - } - - public void setVmArguments(String vmArguments) { - this.vmArguments = vmArguments; - } - - public String getProgramArguments() { - return commandArguments; - } - - public void setProgramArguments(String commandArguments) { - this.commandArguments = commandArguments; - } - - public String getRemotePort() { - return remotePort; - } - - public void setRemotePort(String remotePort) { - this.remotePort = remotePort; - - } - - - // Miscellaneous debugger session preferences. - - public boolean getVerboseFlag() { - return verbose; - } - - public void setVerboseFlag(boolean verbose) { - this.verbose = verbose; - } - - - // Thread focus. - - public ThreadReference getCurrentThread() { - return currentThread; - } - - public void setCurrentThread(ThreadReference t) { - if (t != currentThread) { - currentThread = t; - notifyCurrentThreadChanged(t); - } - } - - public void setCurrentThreadInvalidate(ThreadReference t) { - currentThread = t; - notifyCurrentFrameChanged(runtime.threadInfo(t), - 0, true); - } - - public void invalidateCurrentThread() { - notifyCurrentFrameChanged(null, 0, true); - } - - - // If a view is displaying the current thread, it may - // choose to indicate which frame is current in the - // sense of the command-line UI. It may also "warp" the - // selection to that frame when changed by an 'up' or 'down' - // command. Hence, a notifier is provided. - - /****** - public int getCurrentFrameIndex() { - return getCurrentFrameIndex(currentThreadInfo); - } - ******/ - - public int getCurrentFrameIndex(ThreadReference t) { - return getCurrentFrameIndex(runtime.threadInfo(t)); - } - - //### Used in StackTraceTool. - public int getCurrentFrameIndex(ThreadInfo tinfo) { - if (tinfo == null) { - return 0; - } - Integer currentFrame = (Integer)tinfo.getUserObject(); - if (currentFrame == null) { - return 0; - } else { - return currentFrame.intValue(); - } - } - - public int moveCurrentFrameIndex(ThreadReference t, int count) throws VMNotInterruptedException { - return setCurrentFrameIndex(t,count, true); - } - - public int setCurrentFrameIndex(ThreadReference t, int newIndex) throws VMNotInterruptedException { - return setCurrentFrameIndex(t, newIndex, false); - } - - public int setCurrentFrameIndex(int newIndex) throws VMNotInterruptedException { - if (currentThread == null) { - return 0; - } else { - return setCurrentFrameIndex(currentThread, newIndex, false); - } - } - - private int setCurrentFrameIndex(ThreadReference t, int x, boolean relative) throws VMNotInterruptedException { - boolean sameThread = t.equals(currentThread); - ThreadInfo tinfo = runtime.threadInfo(t); - if (tinfo == null) { - return 0; - } - int maxIndex = tinfo.getFrameCount()-1; - int oldIndex = getCurrentFrameIndex(tinfo); - int newIndex = relative? oldIndex + x : x; - if (newIndex > maxIndex) { - newIndex = maxIndex; - } else if (newIndex < 0) { - newIndex = 0; - } - if (!sameThread || newIndex != oldIndex) { // don't recurse - setCurrentFrameIndex(tinfo, newIndex); - } - return newIndex - oldIndex; - } - - private void setCurrentFrameIndex(ThreadInfo tinfo, int index) { - tinfo.setUserObject(index); - //### In fact, the value may not have changed at this point. - //### We need to signal that the user attempted to change it, - //### however, so that the selection can be "warped" to the - //### current location. - notifyCurrentFrameChanged(tinfo.thread(), index); - } - - public StackFrame getCurrentFrame() throws VMNotInterruptedException { - return getCurrentFrame(runtime.threadInfo(currentThread)); - } - - public StackFrame getCurrentFrame(ThreadReference t) throws VMNotInterruptedException { - return getCurrentFrame(runtime.threadInfo(t)); - } - - public StackFrame getCurrentFrame(ThreadInfo tinfo) throws VMNotInterruptedException { - int index = getCurrentFrameIndex(tinfo); - try { - // It is possible, though unlikely, that the VM was interrupted - // before the thread created its Java stack. - return tinfo.getFrame(index); - } catch (FrameIndexOutOfBoundsException e) { - return null; - } - } - - public void addContextListener(ContextListener cl) { - contextListeners.add(cl); - } - - public void removeContextListener(ContextListener cl) { - contextListeners.remove(cl); - } - - //### These notifiers are fired only in response to USER-INITIATED changes - //### to the current thread and current frame. When the current thread is set automatically - //### after a breakpoint hit or step completion, no event is generated. Instead, - //### interested parties are expected to listen for the BreakpointHit and StepCompleted - //### events. This convention is unclean, and I believe that it reflects a defect in - //### in the current architecture. Unfortunately, however, we cannot guarantee the - //### order in which various listeners receive a given event, and the handlers for - //### the very same events that cause automatic changes to the current thread may also - //### need to know the current thread. - - private void notifyCurrentThreadChanged(ThreadReference t) { - ThreadInfo tinfo = null; - int index = 0; - if (t != null) { - tinfo = runtime.threadInfo(t); - index = getCurrentFrameIndex(tinfo); - } - notifyCurrentFrameChanged(tinfo, index, false); - } - - private void notifyCurrentFrameChanged(ThreadReference t, int index) { - notifyCurrentFrameChanged(runtime.threadInfo(t), - index, false); - } - - private void notifyCurrentFrameChanged(ThreadInfo tinfo, int index, - boolean invalidate) { - ArrayList l = new ArrayList(contextListeners); - CurrentFrameChangedEvent evt = - new CurrentFrameChangedEvent(this, tinfo, index, invalidate); - for (int i = 0; i < l.size(); i++) { - l.get(i).currentFrameChanged(evt); - } - } - - private class ContextManagerListener extends JDIAdapter - implements SessionListener, JDIListener { - - // SessionListener - - @Override - public void sessionStart(EventObject e) { - invalidateCurrentThread(); - } - - @Override - public void sessionInterrupt(EventObject e) { - setCurrentThreadInvalidate(currentThread); - } - - @Override - public void sessionContinue(EventObject e) { - invalidateCurrentThread(); - } - - // JDIListener - - @Override - public void locationTrigger(LocationTriggerEventSet e) { - setCurrentThreadInvalidate(e.getThread()); - } - - @Override - public void exception(ExceptionEventSet e) { - setCurrentThreadInvalidate(e.getThread()); - } - - @Override - public void vmDisconnect(VMDisconnectEventSet e) { - invalidateCurrentThread(); - } - - } - - - /** - * Add a -classpath argument to the arguments passed to the exec'ed - * VM with the contents of CLASSPATH environment variable, - * if -classpath was not already specified. - * - * @param javaArgs the arguments to the VM being exec'd that - * potentially has a user specified -classpath argument. - * @return a javaArgs whose -classpath option has been added - */ - - private String processClasspathDefaults(String javaArgs) { - if (javaArgs.indexOf("-classpath ") == -1) { - StringBuilder munged = new StringBuilder(javaArgs); - SearchPath classpath = classManager.getClassPath(); - if (classpath.isEmpty()) { - String envcp = System.getProperty("env.class.path"); - if ((envcp != null) && (envcp.length() > 0)) { - munged.append(" -classpath " + envcp); - } - } else { - munged.append(" -classpath " + classpath.asString()); - } - return munged.toString(); - } else { - return javaArgs; - } - } - - private String appendPath(String path1, String path2) { - if (path1 == null || path1.length() == 0) { - return path2 == null ? "." : path2; - } else if (path2 == null || path2.length() == 0) { - return path1; - } else { - return path1 + File.pathSeparator + path2; - } - } - -} diff --git a/src/demo/share/jpda/com/sun/tools/example/debug/gui/CurrentFrameChangedEvent.java b/src/demo/share/jpda/com/sun/tools/example/debug/gui/CurrentFrameChangedEvent.java deleted file mode 100644 --- a/src/demo/share/jpda/com/sun/tools/example/debug/gui/CurrentFrameChangedEvent.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code 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 - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * This source code is provided to illustrate the usage of a given feature - * or technique and has been deliberately simplified. Additional steps - * required for a production-quality application, such as security checks, - * input validation and proper error handling, might not be present in - * this sample code. - */ - - -package com.sun.tools.example.debug.gui; - -import com.sun.jdi.*; -import com.sun.tools.example.debug.bdi.*; -import java.util.EventObject; - -public class CurrentFrameChangedEvent extends EventObject { - - private static final long serialVersionUID = 4214479486546762179L; - private ThreadInfo tinfo; - private int index; - private boolean invalidate; - - public CurrentFrameChangedEvent(Object source, ThreadInfo tinfo, - int index, boolean invalidate) { - super(source); - this.tinfo = tinfo; - this.index = index; - this.invalidate = invalidate; - } - - public ThreadReference getThread() { - return tinfo == null? null : tinfo.thread(); - } - - public ThreadInfo getThreadInfo() { - return tinfo; - } - - public int getIndex() { - return index; - } - - public boolean getInvalidate() { - return invalidate; - } -} diff --git a/src/demo/share/jpda/com/sun/tools/example/debug/gui/Environment.java b/src/demo/share/jpda/com/sun/tools/example/debug/gui/Environment.java deleted file mode 100644 --- a/src/demo/share/jpda/com/sun/tools/example/debug/gui/Environment.java +++ /dev/null @@ -1,165 +0,0 @@ -/* - * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code 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 - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * This source code is provided to illustrate the usage of a given feature - * or technique and has been deliberately simplified. Additional steps - * required for a production-quality application, such as security checks, - * input validation and proper error handling, might not be present in - * this sample code. - */ - - -package com.sun.tools.example.debug.gui; - -import java.io.*; -import com.sun.jdi.*; -import com.sun.tools.example.debug.bdi.*; - -public class Environment { - - private SourceManager sourceManager; - private ClassManager classManager; - private ContextManager contextManager; - private MonitorListModel monitorListModel; - private ExecutionManager runtime; - - private PrintWriter typeScript; - - private boolean verbose; - - public Environment() { - this.classManager = new ClassManager(this); - //### Order of the next three lines is important! (FIX THIS) - this.runtime = new ExecutionManager(); - this.sourceManager = new SourceManager(this); - this.contextManager = new ContextManager(this); - this.monitorListModel = new MonitorListModel(this); - } - - // Services used by debugging tools. - - public SourceManager getSourceManager() { - return sourceManager; - } - - public ClassManager getClassManager() { - return classManager; - } - - public ContextManager getContextManager() { - return contextManager; - } - - public MonitorListModel getMonitorListModel() { - return monitorListModel; - } - - public ExecutionManager getExecutionManager() { - return runtime; - } - - //### TODO: - //### Tools should attach/detach from environment - //### via a property, which should call an 'addTool' - //### method when set to maintain a registry of - //### tools for exit-time cleanup, etc. Tool - //### class constructors should be argument-free, so - //### that they may be instantiated by bean builders. - //### Will also need 'removeTool' in case property - //### value is changed. - // - // public void addTool(Tool t); - // public void removeTool(Tool t); - - public void terminate() { - System.exit(0); - } - - // public void refresh(); // notify all tools to refresh their views - - - // public void addStatusListener(StatusListener l); - // public void removeStatusListener(StatusListener l); - - // public void addOutputListener(OutputListener l); - // public void removeOutputListener(OutputListener l); - - public void setTypeScript(PrintWriter writer) { - typeScript = writer; - } - - public void error(String message) { - if (typeScript != null) { - typeScript.println(message); - } else { - System.out.println(message); - } - } - - public void failure(String message) { - if (typeScript != null) { - typeScript.println(message); - } else { - System.out.println(message); - } - } - - public void notice(String message) { - if (typeScript != null) { - typeScript.println(message); - } else { - System.out.println(message); - } - } - - public OutputSink getOutputSink() { - return new OutputSink(typeScript); - } - - public void viewSource(String fileName) { - //### HACK ### - //### Should use listener here. - com.sun.tools.example.debug.gui.GUI.srcTool.showSourceFile(fileName); - } - - public void viewLocation(Location locn) { - //### HACK ### - //### Should use listener here. - //### Should we use sourceForLocation here? - com.sun.tools.example.debug.gui.GUI.srcTool.showSourceForLocation(locn); - } - - //### Also in 'ContextManager'. Do we need both? - - public boolean getVerboseFlag() { - return verbose; - } - - public void setVerboseFlag(boolean verbose) { - this.verbose = verbose; - } - -} diff --git a/src/demo/share/jpda/com/sun/tools/example/debug/gui/GUI.java b/src/demo/share/jpda/com/sun/tools/example/debug/gui/GUI.java deleted file mode 100644 --- a/src/demo/share/jpda/com/sun/tools/example/debug/gui/GUI.java +++ /dev/null @@ -1,265 +0,0 @@ -/* - * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code 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 - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * This source code is provided to illustrate the usage of a given feature - * or technique and has been deliberately simplified. Additional steps - * required for a production-quality application, such as security checks, - * input validation and proper error handling, might not be present in - * this sample code. - */ - - -package com.sun.tools.example.debug.gui; - -import java.io.*; -import javax.swing.*; -import javax.swing.border.*; -import java.awt.*; -import java.awt.event.*; - -import com.sun.jdi.*; -import com.sun.tools.example.debug.bdi.*; - -public class GUI extends JPanel { - - private static final long serialVersionUID = 3292463234530679091L; - private CommandTool cmdTool; - private ApplicationTool appTool; - //###HACK## - //### There is currently dirty code in Environment that - //### accesses this directly. - //private SourceTool srcTool; - public static SourceTool srcTool; - - private SourceTreeTool sourceTreeTool; - private ClassTreeTool classTreeTool; - private ThreadTreeTool threadTreeTool; - private StackTraceTool stackTool; - private MonitorTool monitorTool; - - public static final String progname = "javadt"; - public static final String version = "1.0Beta"; //### FIX ME. - public static final String windowBanner = "Java(tm) platform Debug Tool"; - - private Font fixedFont = new Font("monospaced", Font.PLAIN, 10); - - private GUI(Environment env) { - setLayout(new BorderLayout()); - - setBorder(new EmptyBorder(5, 5, 5, 5)); - - add(new JDBToolBar(env), BorderLayout.NORTH); - - srcTool = new SourceTool(env); - srcTool.setPreferredSize(new java.awt.Dimension(500, 300)); - srcTool.setTextFont(fixedFont); - - stackTool = new StackTraceTool(env); - stackTool.setPreferredSize(new java.awt.Dimension(500, 100)); - - monitorTool = new MonitorTool(env); - monitorTool.setPreferredSize(new java.awt.Dimension(500, 50)); - - JSplitPane right = new JSplitPane(JSplitPane.VERTICAL_SPLIT, srcTool, - new JSplitPane(JSplitPane.VERTICAL_SPLIT, stackTool, monitorTool)); - - sourceTreeTool = new SourceTreeTool(env); - sourceTreeTool.setPreferredSize(new java.awt.Dimension(200, 450)); - - classTreeTool = new ClassTreeTool(env); - classTreeTool.setPreferredSize(new java.awt.Dimension(200, 450)); - - threadTreeTool = new ThreadTreeTool(env); - threadTreeTool.setPreferredSize(new java.awt.Dimension(200, 450)); - - JTabbedPane treePane = new JTabbedPane(SwingConstants.BOTTOM); - treePane.addTab("Source", null, sourceTreeTool); - treePane.addTab("Classes", null, classTreeTool); - treePane.addTab("Threads", null, threadTreeTool); - - JSplitPane centerTop = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, treePane, right); - - cmdTool = new CommandTool(env); - cmdTool.setPreferredSize(new java.awt.Dimension(700, 150)); - - appTool = new ApplicationTool(env); - appTool.setPreferredSize(new java.awt.Dimension(700, 200)); - - JSplitPane centerBottom = new JSplitPane(JSplitPane.VERTICAL_SPLIT, cmdTool, appTool); - // centerBottom.setPreferredSize(new java.awt.Dimension(700, 350)); - - JSplitPane center = new JSplitPane(JSplitPane.VERTICAL_SPLIT, centerTop, centerBottom); - - add(center, BorderLayout.CENTER); - - - } - - private static void usage() { - String separator = File.pathSeparator; - System.out.println("Usage: " + progname + " "); - System.out.println(); - System.out.println("where options include:"); - System.out.println(" -help print out this message and exit"); - System.out.println(" -sourcepath "); - System.out.println(" list directories in which to look for source files"); - System.out.println(" -remote :"); - System.out.println(" host machine and port number of interpreter to attach to"); - System.out.println(" -dbgtrace [flags] print info for debugging " + progname); - System.out.println(); - System.out.println("options forwarded to debuggee process:"); - System.out.println(" -v -verbose[:class|gc|jni]"); - System.out.println(" turn on verbose mode"); - System.out.println(" -D= set a system property"); - System.out.println(" -classpath "); - System.out.println(" list directories in which to look for classes"); - System.out.println(" -X

Example JDI Applications

-This example download contains the source code and -documentation for three applications written using -the JavaTM Debug Interface (JDI) -of the Java Platform Debugger Architecture (JPDA). -They are provided as educational tools and as starting -points for debugger development. -

-In increasing order of complexity: -

    -
  • Trace displays traces -of program execution. It is very simple (less than 600 lines) -yet uses most of the basic JDI functionality. It is a -good starting point. -
  • Jdb is the command line debugger -distributed with the J2SE SDK. -
  • Javadt is the beginnings of -a GUI debugger. -
-

-Trace is in the trace directory. -Jdb and Javadt share a package, and are under the -debug directory. - -

Required Set-up

- -

Where is JPDA?

-New versions of the J2SE SDK have JPDA included. For -older versions JPDA must be separately downloaded. -
-
SDKs with JPDA included -
J2SE SDK v1.3 and later and J2SE SDK for Linux v1.2.2 -
SDKs requiring JPDA download -
J2SE SDK v1.2.1 and v1.2.2 for Solaris and Windows -
Other SDKs -
Check with vendor -
-

-

Set-up for J2SE SDKs with JPDA included

-Your classpath must include the JDI Library code, which is -in tools.jar in the lib directory. -This is needed for both compiling the example code and -executing it. -

-

Set-up for J2SE SDKs without JPDA - Solaris

-Download JPDA v1.0 from -http://java.sun.com/products/jpda. Follow the -Installation Instructions -found there. Pay particular attention to setting the library -path. -

-Your classpath must include the JDI Library code, which is -in jpda_home/lib/tools.jar. -This is needed for both compiling the example code and -executing it. -

-

Set-up for J2SE SDKs without JPDA - Windows

-Download JPDA v1.0 from -http://java.sun.com/products/jpda. Follow the -Installation Instructions -found there. Be sure to add: -
-        jpda_home\bin
-
-to your path. -

-Your classpath must include the JDI Library code, which is -in jpda_home\lib\tools.jar. -This is needed for both compiling the example code and -executing it. -

-


-
java-debugger@java.sun.com
-

-

-

- - - diff --git a/src/demo/share/jpda/com/sun/tools/example/doc/javadt.html b/src/demo/share/jpda/com/sun/tools/example/doc/javadt.html deleted file mode 100644 --- a/src/demo/share/jpda/com/sun/tools/example/doc/javadt.html +++ /dev/null @@ -1,174 +0,0 @@ - - - Release notes for the javadt debugger - - -

Release notes for the javadt debugger

- -

-As a demonstration of the - -JavaTM Platform Debugger Architecture -we are providing source code for -a simple GUI debugging tool - javadt. -It is included as an example and demonstration of - -JDI. It is not a finished or polished debugger and is -missing many features of importance for real debugging work. -

- -

Invoking javadt

-

-javadt can be run by executing: -

-   java com.sun.tools.example.debug.gui.GUI <options>.. <class-name>
-
-where <class-name> is the name you would normally -place on the java command line. -Note: the path to the JDI Library and to -the compiled javadt class files must be on the class path -used to invoke gui.GUI. -

-For example, you can invoke the javadt debugger as follows: -

-   java com.sun.tools.example.debug.gui.GUI -classpath . Hello
-
-Note: this -classpath option controls the -class path for the Hello application. -Once the window appears, you can issue the 'run' command to begin -execution immediately. It is also -possible to give the class name in the 'run' command, in -which case it may be omitted when invoking the debugger from the -shell. -

-The classpath may also be set from within the debugger, using the -'classpath' command. Currently, other arguments to the VM must be -given on the shell command line when the debugger is initially -invoked. The most recently mentioned classpath, VM arguments, main -class name, and program arguments are retained as defaults for later -'run' and 'load' commands. (Unfortunately, at present, the debugger -will likely crash if you attempt to begin another debugging session -with another debuggee process from within the same invocation of the -debugger. You should exit to the shell and start a new debugger -process.) -

- -

Using javadt

-The javadt normally displays context related to the "current thread", -that is, the thread that most recently encountered a breakpoint, threw -an uncaught exception, or was single-stepped by the user. When -program execution is suspended on account of one of these events, a -current thread exists, and the javadt displays the following information -about it: -

-

    -
  • A stack backtrace. - -
  • The source code surrounding the line corresponding to the - instruction counter for the thread, if the source code is - available. -
-

-In addition, a tabbed pane allows the user to view one of three -additional views: -

-

    -
  • A tree of all source files available on the source path. - -
  • A tree of all loaded class files, organized hierarchically - by package. - -
  • A tree of all active threads, organized hierarchically - by thread group. -
-

-By clicking on the name of a source file, the source view can be -directed to display it. Likewise, clicking on a thread will make that -thread the current thread. These features are normally used while the -program is suspended, e.g, at a breakpoint. Upon resumption and -encountering another breakpoint, for example, the current thread will -be automatically reset and the views will be updated. The views tile -the javadt display, and are adjustable in size. -

-The javadt functionality is rather basic, thus a command-line interaction -window is also provided that allows access to functions that are not -yet exposed in the javadt. In particular, it is necessary to use the -command line in order to set breakpoints and examine variables. The -javadt debugger command interpreter implements roughly a subset of the -jdb - functionality, but adds a few commands of its own. The -'help' command lists the complete set of commands and their function. -Shortcuts for a set of the most common commands is provided on a -button-bar at the top of the display. -

-The program to be debugged may be started either as a child of the -debugger, or the debugger can be attached to an existing process, -provided that its VM is prepared to accept the connection. If the -debuggee is started by the debugger as a child, a line-oriented -interface to its standard input, output, and error streams is provided -in an application interaction pane. -

-The debugger expects to find the program source code on its -sourcepath, set with the 'use' or 'sourcepath' command. If you find -that sources are not being displayed because the sourcepath is -incorrect, you may change it at that time, and the source view will be -immediately updated. -

-The message "No current thread" is often encountered when stepping -through a program. This message does not mean that the thread or -the VM has died, merely that a current thread is undefined. This -situation can easily occur unexpectedly when the program being -stepped is waiting, eg., for input. The VM appears to be stopped, -as it would be after the successful completion of a step, but it -is considered to be "running", not "interrupted". The prompt -in the command interaction pane indicates the state by changing -to a thread name and frame number when the VM is interrupted. -When it is running, the prompt "Command:" is displayed. -

-

Source for javadt

-Full source code for javadt is included under the -debug directory of examples.jar. -Note: these directories also include the -source for jdb. -Source code for these example applications is included to provide concrete -examples for debugger developers. Example code may be used, modified -and redistributed by debugger developers providing they adhere to the -terms in the COPYRIGHT notice. -

-javadt uses the following packages (found under the -debug directory): -

-
gui -
User interface code -
bdi -
Debugger core code -
events -
Event Set code -
expr -
Expression processing code -
-

-

Building javadt

-To build the javadt classes from the -provided source files under the debug directory, -you need only to compile them. No special -options are required, aside from those which set your classpath to -include the JDI Library. -

-

-However, if you want to modify the expression parser in the file -Expr.jj, you will need the - -JavaCC parser generator. -It is available free from -Metamata -(now part of WebGain). -

-


-
java-debugger@java.sun.com
-

-

-

- - diff --git a/src/demo/share/jpda/com/sun/tools/example/doc/jdb.html b/src/demo/share/jpda/com/sun/tools/example/doc/jdb.html deleted file mode 100644 --- a/src/demo/share/jpda/com/sun/tools/example/doc/jdb.html +++ /dev/null @@ -1,104 +0,0 @@ - - - Release notes for the jdb debugger - - -  - - - - - -
-
-

Release notes for the jdb debugger

-
- -

-Home Page - -

-As a demonstration of the - -JavaTM Platform Debugger Architecture -we are providing source code for the jdb debugger, which was -re-written to use - -JDI. - -

-

jdb man pages

-
-jdb man pages for Windows -

-jdb man pages for Solaris -

-

-

Invoking jdb

-The jdb sample can be started by executing: -
-   java com.sun.tools.example.debug.tty.TTY <options>.. <class-name>
-
-where <class-name> is the name you would normally -place on the java command line. The -help -option provides information on options. -

-

-Note: the path to the JDI Library and to -the compiled jdb class files must be on the class path -used to invoke com.sun.tools.example.debug.tty.TTY. - -

-For more information on invoking and connecting, refer to the - -Connection and Invocation Details section of the - -JPDA documentation, -particularly the section on jdb. -

- - -

Source for jdb

-Full source code for jdb is included under the -debug directory of examples.jar. -Note: these directories also include the -source for javadt. -Source code for these example applications is included to provide concrete -examples for debugger developers. Example code may be used, modified -and redistributed by debugger developers providing they adhere to the -terms in the COPYRIGHT notice. -

-jdb uses the following packages (found under the -debug directory): -

-
tty -
Application code -
expr -
Expression processing code -
- -

-

Building jdb

-To completely rebuild the jdb classes from the -provided source files under the debug directory, -you need only to compile them. No special -options are required, aside from those which set your classpath to -include the JDI Library. -

-

-However, if you want to modify the expression parser in the file -Expr.jj, you will need the - -JavaCC parser generator. -It is available free from -Metamata -(now part of WebGain). -

-


-
java-debugger@java.sun.com
-

-

-

- - diff --git a/src/demo/share/jpda/com/sun/tools/example/doc/trace.html b/src/demo/share/jpda/com/sun/tools/example/doc/trace.html deleted file mode 100644 --- a/src/demo/share/jpda/com/sun/tools/example/doc/trace.html +++ /dev/null @@ -1,71 +0,0 @@ - - - - trace example - - -

trace example

- -Trace runs the Java language program passed as an argument and -generates a trace of its execution. Trace is a simple command -line tool that uses the - -Java Debug Interface (JDI). Programs need -not be compiled for debugging since this information is not -used. -

-Trace can be invoked as follows: -

-        java com.sun.tools.example.trace.Trace options class args
-
-Your classpath must include the JDI Library -(see set-up), -the path to the compiled trace class files, -and the path for the application being traced. -

-Available options are: - -

-  -output filename   
-        Set destination for output trace. By default output
-        goes to the terminal.
-
-  -all                 
-        Include system classes in output.  By default
-        java.*, javax.*, sun.* and com.sun.* events are
-        not diplayed.
-
-  -fields
-        Also show assignments into fields.
-
-  -help              
-        Print a help message
-
-
-class is the program to trace. args are the arguments to class. -

- -

Source for trace

-Full source code for trace is included in the -trace directory of examples.jar. -Source code for these example applications is included to provide concrete -examples for debugger developers. Example code may be used, modified -and redistributed by debugger developers providing they adhere to the -terms in the COPYRIGHT notice. - -

-

Building trace

-To completely rebuild the trace classes from the -provided source files in the trace directory, -you need only to compile them. No special -options are required, aside from those which set your classpath to -include the JDI Library. - -

-


-
java-debugger@java.sun.com
-

-

-

- - diff --git a/src/demo/share/jpda/com/sun/tools/example/trace/EventThread.java b/src/demo/share/jpda/com/sun/tools/example/trace/EventThread.java deleted file mode 100644 --- a/src/demo/share/jpda/com/sun/tools/example/trace/EventThread.java +++ /dev/null @@ -1,353 +0,0 @@ -/* - * Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code 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 - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * This source code is provided to illustrate the usage of a given feature - * or technique and has been deliberately simplified. Additional steps - * required for a production-quality application, such as security checks, - * input validation and proper error handling, might not be present in - * this sample code. - */ - - -package com.sun.tools.example.trace; - -import com.sun.jdi.*; -import com.sun.jdi.request.*; -import com.sun.jdi.event.*; - -import java.util.*; -import java.io.PrintWriter; - -/** - * This class processes incoming JDI events and displays them - * - * @author Robert Field - */ -public class EventThread extends Thread { - - private final VirtualMachine vm; // Running VM - private final String[] excludes; // Packages to exclude - private final PrintWriter writer; // Where output goes - - static String nextBaseIndent = ""; // Starting indent for next thread - - private boolean connected = true; // Connected to VM - private boolean vmDied = true; // VMDeath occurred - - // Maps ThreadReference to ThreadTrace instances - private Map traceMap = - new HashMap<>(); - - EventThread(VirtualMachine vm, String[] excludes, PrintWriter writer) { - super("event-handler"); - this.vm = vm; - this.excludes = excludes; - this.writer = writer; - } - - /** - * Run the event handling thread. - * As long as we are connected, get event sets off - * the queue and dispatch the events within them. - */ - @Override - public void run() { - EventQueue queue = vm.eventQueue(); - while (connected) { - try { - EventSet eventSet = queue.remove(); - EventIterator it = eventSet.eventIterator(); - while (it.hasNext()) { - handleEvent(it.nextEvent()); - } - eventSet.resume(); - } catch (InterruptedException exc) { - // Ignore - } catch (VMDisconnectedException discExc) { - handleDisconnectedException(); - break; - } - } - } - - /** - * Create the desired event requests, and enable - * them so that we will get events. - * @param excludes Class patterns for which we don't want events - * @param watchFields Do we want to watch assignments to fields - */ - void setEventRequests(boolean watchFields) { - EventRequestManager mgr = vm.eventRequestManager(); - - // want all exceptions - ExceptionRequest excReq = mgr.createExceptionRequest(null, - true, true); - // suspend so we can step - excReq.setSuspendPolicy(EventRequest.SUSPEND_ALL); - excReq.enable(); - - MethodEntryRequest menr = mgr.createMethodEntryRequest(); - for (int i=0; i 0) { - indent.append("| "); - } - - EventRequestManager mgr = vm.eventRequestManager(); - mgr.deleteEventRequest(event.request()); - } - - void threadDeathEvent(ThreadDeathEvent event) { - indent = new StringBuffer(baseIndent); - println("====== " + thread.name() + " end ======"); - } - } - - /** - * Returns the ThreadTrace instance for the specified thread, - * creating one if needed. - */ - ThreadTrace threadTrace(ThreadReference thread) { - ThreadTrace trace = traceMap.get(thread); - if (trace == null) { - trace = new ThreadTrace(thread); - traceMap.put(thread, trace); - } - return trace; - } - - /** - * Dispatch incoming events - */ - private void handleEvent(Event event) { - if (event instanceof ExceptionEvent) { - exceptionEvent((ExceptionEvent)event); - } else if (event instanceof ModificationWatchpointEvent) { - fieldWatchEvent((ModificationWatchpointEvent)event); - } else if (event instanceof MethodEntryEvent) { - methodEntryEvent((MethodEntryEvent)event); - } else if (event instanceof MethodExitEvent) { - methodExitEvent((MethodExitEvent)event); - } else if (event instanceof StepEvent) { - stepEvent((StepEvent)event); - } else if (event instanceof ThreadDeathEvent) { - threadDeathEvent((ThreadDeathEvent)event); - } else if (event instanceof ClassPrepareEvent) { - classPrepareEvent((ClassPrepareEvent)event); - } else if (event instanceof VMStartEvent) { - vmStartEvent((VMStartEvent)event); - } else if (event instanceof VMDeathEvent) { - vmDeathEvent((VMDeathEvent)event); - } else if (event instanceof VMDisconnectEvent) { - vmDisconnectEvent((VMDisconnectEvent)event); - } else { - throw new Error("Unexpected event type"); - } - } - - /*** - * A VMDisconnectedException has happened while dealing with - * another event. We need to flush the event queue, dealing only - * with exit events (VMDeath, VMDisconnect) so that we terminate - * correctly. - */ - synchronized void handleDisconnectedException() { - EventQueue queue = vm.eventQueue(); - while (connected) { - try { - EventSet eventSet = queue.remove(); - EventIterator iter = eventSet.eventIterator(); - while (iter.hasNext()) { - Event event = iter.nextEvent(); - if (event instanceof VMDeathEvent) { - vmDeathEvent((VMDeathEvent)event); - } else if (event instanceof VMDisconnectEvent) { - vmDisconnectEvent((VMDisconnectEvent)event); - } - } - eventSet.resume(); // Resume the VM - } catch (InterruptedException exc) { - // ignore - } - } - } - - private void vmStartEvent(VMStartEvent event) { - writer.println("-- VM Started --"); - } - - // Forward event for thread specific processing - private void methodEntryEvent(MethodEntryEvent event) { - threadTrace(event.thread()).methodEntryEvent(event); - } - - // Forward event for thread specific processing - private void methodExitEvent(MethodExitEvent event) { - threadTrace(event.thread()).methodExitEvent(event); - } - - // Forward event for thread specific processing - private void stepEvent(StepEvent event) { - threadTrace(event.thread()).stepEvent(event); - } - - // Forward event for thread specific processing - private void fieldWatchEvent(ModificationWatchpointEvent event) { - threadTrace(event.thread()).fieldWatchEvent(event); - } - - void threadDeathEvent(ThreadDeathEvent event) { - ThreadTrace trace = traceMap.get(event.thread()); - if (trace != null) { // only want threads we care about - trace.threadDeathEvent(event); // Forward event - } - } - - /** - * A new class has been loaded. - * Set watchpoints on each of its fields - */ - private void classPrepareEvent(ClassPrepareEvent event) { - EventRequestManager mgr = vm.eventRequestManager(); - List fields = event.referenceType().visibleFields(); - for (Field field : fields) { - ModificationWatchpointRequest req = - mgr.createModificationWatchpointRequest(field); - for (int i=0; i= 0) { - out.write(cbuf, 0, count); - } - out.flush(); - } catch(IOException exc) { - System.err.println("Child I/O Transfer - " + exc); - } - } -} diff --git a/src/demo/share/jpda/com/sun/tools/example/trace/Trace.java b/src/demo/share/jpda/com/sun/tools/example/trace/Trace.java deleted file mode 100644 --- a/src/demo/share/jpda/com/sun/tools/example/trace/Trace.java +++ /dev/null @@ -1,246 +0,0 @@ -/* - * Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code 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 - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * This source code is provided to illustrate the usage of a given feature - * or technique and has been deliberately simplified. Additional steps - * required for a production-quality application, such as security checks, - * input validation and proper error handling, might not be present in - * this sample code. - */ - - -package com.sun.tools.example.trace; - -import com.sun.jdi.VirtualMachine; -import com.sun.jdi.Bootstrap; -import com.sun.jdi.connect.*; - -import java.util.Map; -import java.util.List; - -import java.io.PrintWriter; -import java.io.FileWriter; -import java.io.IOException; - -/** - * This program traces the execution of another program. - * See "java Trace -help". - * It is a simple example of the use of the Java Debug Interface. - * - * @author Robert Field - */ -public class Trace { - - // Running remote VM - private final VirtualMachine vm; - - // Thread transferring remote error stream to our error stream - private Thread errThread = null; - - // Thread transferring remote output stream to our output stream - private Thread outThread = null; - - // Mode for tracing the Trace program (default= 0 off) - private int debugTraceMode = 0; - - // Do we want to watch assignments to fields - private boolean watchFields = false; - - // Class patterns for which we don't want events - private String[] excludes = {"java.*", "javax.*", "sun.*", - "com.sun.*"}; - - /** - * main - */ - public static void main(String[] args) { - new Trace(args); - } - - /** - * Parse the command line arguments. - * Launch target VM. - * Generate the trace. - */ - Trace(String[] args) { - PrintWriter writer = new PrintWriter(System.out); - int inx; - for (inx = 0; inx < args.length; ++inx) { - String arg = args[inx]; - if (arg.charAt(0) != '-') { - break; - } - if (arg.equals("-output")) { - try { - writer = new PrintWriter(new FileWriter(args[++inx])); - } catch (IOException exc) { - System.err.println("Cannot open output file: " + args[inx] - + " - " + exc); - System.exit(1); - } - } else if (arg.equals("-all")) { - excludes = new String[0]; - } else if (arg.equals("-fields")) { - watchFields = true; - } else if (arg.equals("-dbgtrace")) { - debugTraceMode = Integer.parseInt(args[++inx]); - } else if (arg.equals("-help")) { - usage(); - System.exit(0); - } else { - System.err.println("No option: " + arg); - usage(); - System.exit(1); - } - } - if (inx >= args.length) { - System.err.println(" missing"); - usage(); - System.exit(1); - } - StringBuilder sb = new StringBuilder(); - sb.append(args[inx]); - for (++inx; inx < args.length; ++inx) { - sb.append(' '); - sb.append(args[inx]); - } - vm = launchTarget(sb.toString()); - generateTrace(writer); - } - - - /** - * Generate the trace. - * Enable events, start thread to display events, - * start threads to forward remote error and output streams, - * resume the remote VM, wait for the final event, and shutdown. - */ - void generateTrace(PrintWriter writer) { - vm.setDebugTraceMode(debugTraceMode); - EventThread eventThread = new EventThread(vm, excludes, writer); - eventThread.setEventRequests(watchFields); - eventThread.start(); - redirectOutput(); - vm.resume(); - - // Shutdown begins when event thread terminates - try { - eventThread.join(); - errThread.join(); // Make sure output is forwarded - outThread.join(); // before we exit - } catch (InterruptedException exc) { - // we don't interrupt - } - writer.close(); - } - - /** - * Launch target VM. - * Forward target's output and error. - */ - VirtualMachine launchTarget(String mainArgs) { - LaunchingConnector connector = findLaunchingConnector(); - Map arguments = - connectorArguments(connector, mainArgs); - try { - return connector.launch(arguments); - } catch (IOException exc) { - throw new Error("Unable to launch target VM: " + exc); - } catch (IllegalConnectorArgumentsException exc) { - throw new Error("Internal error: " + exc); - } catch (VMStartException exc) { - throw new Error("Target VM failed to initialize: " + - exc.getMessage()); - } - } - - void redirectOutput() { - Process process = vm.process(); - - // Copy target's output and error to our output and error. - errThread = new StreamRedirectThread("error reader", - process.getErrorStream(), - System.err); - outThread = new StreamRedirectThread("output reader", - process.getInputStream(), - System.out); - errThread.start(); - outThread.start(); - } - - /** - * Find a com.sun.jdi.CommandLineLaunch connector - */ - LaunchingConnector findLaunchingConnector() { - List connectors = Bootstrap.virtualMachineManager().allConnectors(); - for (Connector connector : connectors) { - if (connector.name().equals("com.sun.jdi.CommandLineLaunch")) { - return (LaunchingConnector)connector; - } - } - throw new Error("No launching connector"); - } - - /** - * Return the launching connector's arguments. - */ - Map connectorArguments(LaunchingConnector connector, String mainArgs) { - Map arguments = connector.defaultArguments(); - Connector.Argument mainArg = - (Connector.Argument)arguments.get("main"); - if (mainArg == null) { - throw new Error("Bad launching connector"); - } - mainArg.setValue(mainArgs); - - if (watchFields) { - // We need a VM that supports watchpoints - Connector.Argument optionArg = - (Connector.Argument)arguments.get("options"); - if (optionArg == null) { - throw new Error("Bad launching connector"); - } - optionArg.setValue("-classic"); - } - return arguments; - } - - /** - * Print command line usage help - */ - void usage() { - System.err.println("Usage: java Trace "); - System.err.println(" are:"); - System.err.println( -" -output Output trace to "); - System.err.println( -" -all Include system classes in output"); - System.err.println( -" -help Print this help message"); - System.err.println(" is the program to trace"); - System.err.println(" are the arguments to "); - } -} diff --git a/src/demo/share/jpda/com/sun/tools/example/debug/expr/Expr.jj b/src/jdk.jdi/share/classes/com/sun/tools/example/debug/expr/Expr.jj rename from src/demo/share/jpda/com/sun/tools/example/debug/expr/Expr.jj rename to src/jdk.jdi/share/classes/com/sun/tools/example/debug/expr/Expr.jj