History

My first initial commit with all of mine experimental changes.

Dmitry Kabak (userdima committed 13 years ago

Commit d37b88d1 parent 3f5b46618352 files · +2598093 −-8690Browse files

Showing the changes to java/pkg/com/sun/tools/example/debug/bdi (38 of 18352 files). Show all

Unified · Split

38 files
  1. java/pkg/com/sun/tools/example/debug/bdi/AccessWatchpointSpec.java +58 −0
  2. java/pkg/com/sun/tools/example/debug/bdi/AmbiguousMethodException.java +42 −0
  3. java/pkg/com/sun/tools/example/debug/bdi/BreakpointSpec.java +58 −0
  4. java/pkg/com/sun/tools/example/debug/bdi/ChildSession.java +300 −0
  5. java/pkg/com/sun/tools/example/debug/bdi/EvaluationException.java +31 −0
  6. java/pkg/com/sun/tools/example/debug/bdi/EventRequestSpec.java +159 −0
  7. java/pkg/com/sun/tools/example/debug/bdi/EventRequestSpecList.java +178 −0
  8. java/pkg/com/sun/tools/example/debug/bdi/ExceptionSpec.java +100 −0
  9. java/pkg/com/sun/tools/example/debug/bdi/ExecutionManager.java +815 −0
  10. java/pkg/com/sun/tools/example/debug/bdi/FrameIndexOutOfBoundsException.java +31 −0
  11. java/pkg/com/sun/tools/example/debug/bdi/InputListener.java +30 −0
  12. java/pkg/com/sun/tools/example/debug/bdi/JDIEventSource.java +184 −0
  13. java/pkg/com/sun/tools/example/debug/bdi/LineBreakpointSpec.java +121 −0
  14. java/pkg/com/sun/tools/example/debug/bdi/LineNotFoundException.java +42 −0
  15. java/pkg/com/sun/tools/example/debug/bdi/MalformedMemberNameException.java +39 −0
  16. java/pkg/com/sun/tools/example/debug/bdi/MethodBreakpointSpec.java +337 −0
  17. java/pkg/com/sun/tools/example/debug/bdi/MethodNotFoundException.java +41 −0
  18. java/pkg/com/sun/tools/example/debug/bdi/ModificationWatchpointSpec.java +59 −0
  19. java/pkg/com/sun/tools/example/debug/bdi/NoSessionException.java +31 −0
  20. java/pkg/com/sun/tools/example/debug/bdi/NoThreadException.java +32 −0
  21. java/pkg/com/sun/tools/example/debug/bdi/OutputListener.java +31 −0
  22. java/pkg/com/sun/tools/example/debug/bdi/ParseException.java +30 −0
  23. java/pkg/com/sun/tools/example/debug/bdi/PatternReferenceTypeSpec.java +99 −0
  24. java/pkg/com/sun/tools/example/debug/bdi/ReferenceTypeSpec.java +41 −0
  25. java/pkg/com/sun/tools/example/debug/bdi/Session.java +96 −0
  26. java/pkg/com/sun/tools/example/debug/bdi/SessionListener.java +37 −0
  27. java/pkg/com/sun/tools/example/debug/bdi/SourceNameReferenceTypeSpec.java +81 −0
  28. java/pkg/com/sun/tools/example/debug/bdi/SpecErrorEvent.java +42 −0
  29. java/pkg/com/sun/tools/example/debug/bdi/SpecEvent.java +49 −0
  30. java/pkg/com/sun/tools/example/debug/bdi/SpecListener.java +49 −0
  31. java/pkg/com/sun/tools/example/debug/bdi/ThreadGroupIterator.java +108 −0
  32. java/pkg/com/sun/tools/example/debug/bdi/ThreadInfo.java +117 −0
  33. java/pkg/com/sun/tools/example/debug/bdi/ThreadIterator.java +70 −0
  34. java/pkg/com/sun/tools/example/debug/bdi/Utils.java +181 −0
  35. java/pkg/com/sun/tools/example/debug/bdi/VMLaunchFailureException.java +31 −0
  36. java/pkg/com/sun/tools/example/debug/bdi/VMNotInterruptedException.java +31 −0
  37. java/pkg/com/sun/tools/example/debug/bdi/WatchpointSpec.java +92 −0
  38. java/pkg/com/sun/tools/example/debug/bdi/mkfile +44 −0
java/pkg/com/sun/tools/example/debug/bdi/AccessWatchpointSpec.java+58−0
@@ -0,0 +1,58 @@
1+/*
2+ * Copyright (c) 1999, Oracle and/or its affiliates. All rights reserved.
3+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+ *
5+ * This code is free software; you can redistribute it and/or modify it
6+ * under the terms of the GNU General Public License version 2 only, as
7+ * published by the Free Software Foundation. Oracle designates this
8+ * particular file as subject to the "Classpath" exception as provided
9+ * by Oracle in the LICENSE file that accompanied this code.
10+ *
11+ * This code is distributed in the hope that it will be useful, but WITHOUT
12+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+ * version 2 for more details (a copy is included in the LICENSE file that
15+ * accompanied this code).
16+ *
17+ * You should have received a copy of the GNU General Public License version
18+ * 2 along with this work; if not, write to the Free Software Foundation,
19+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+ *
21+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+ * or visit www.oracle.com if you need additional information or have any
23+ * questions.
24+ */
25+
26+package com.sun.tools.example.debug.bdi;
27+
28+import com.sun.jdi.*;
29+
30+public class AccessWatchpointSpec extends WatchpointSpec {
31+
32+ AccessWatchpointSpec(EventRequestSpecList specs,
33+ ReferenceTypeSpec refSpec, String fieldId) {
34+ super(specs, refSpec, fieldId);
35+ }
36+
37+ /**
38+ * The 'refType' is known to match.
39+ */
40+ @Override
41+ void resolve(ReferenceType refType) throws InvalidTypeException,
42+ NoSuchFieldException {
43+ if (!(refType instanceof ClassType)) {
44+ throw new InvalidTypeException();
45+ }
46+ Field field = refType.fieldByName(fieldId);
47+ if (field == null) {
48+ throw new NoSuchFieldException(fieldId);
49+ }
50+ setRequest(refType.virtualMachine().eventRequestManager()
51+ .createAccessWatchpointRequest(field));
52+ }
53+
54+ @Override
55+ public boolean equals(Object obj) {
56+ return (obj instanceof AccessWatchpointSpec) && super.equals(obj);
57+ }
58+}
java/pkg/com/sun/tools/example/debug/bdi/AmbiguousMethodException.java+42−0
@@ -0,0 +1,42 @@
1+/*
2+ * Copyright (c) 1998, 1999, Oracle and/or its affiliates. All rights reserved.
3+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+ *
5+ * This code is free software; you can redistribute it and/or modify it
6+ * under the terms of the GNU General Public License version 2 only, as
7+ * published by the Free Software Foundation. Oracle designates this
8+ * particular file as subject to the "Classpath" exception as provided
9+ * by Oracle in the LICENSE file that accompanied this code.
10+ *
11+ * This code is distributed in the hope that it will be useful, but WITHOUT
12+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+ * version 2 for more details (a copy is included in the LICENSE file that
15+ * accompanied this code).
16+ *
17+ * You should have received a copy of the GNU General Public License version
18+ * 2 along with this work; if not, write to the Free Software Foundation,
19+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+ *
21+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+ * or visit www.oracle.com if you need additional information or have any
23+ * questions.
24+ */
25+
26+package com.sun.tools.example.debug.bdi;
27+
28+public class AmbiguousMethodException extends Exception
29+{
30+
31+ private static final long serialVersionUID = 7793370943251707514L;
32+
33+ public AmbiguousMethodException()
34+ {
35+ super();
36+ }
37+
38+ public AmbiguousMethodException(String s)
39+ {
40+ super(s);
41+ }
42+}
java/pkg/com/sun/tools/example/debug/bdi/BreakpointSpec.java+58−0
@@ -0,0 +1,58 @@
1+/*
2+ * Copyright (c) 1999, Oracle and/or its affiliates. All rights reserved.
3+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+ *
5+ * This code is free software; you can redistribute it and/or modify it
6+ * under the terms of the GNU General Public License version 2 only, as
7+ * published by the Free Software Foundation. Oracle designates this
8+ * particular file as subject to the "Classpath" exception as provided
9+ * by Oracle in the LICENSE file that accompanied this code.
10+ *
11+ * This code is distributed in the hope that it will be useful, but WITHOUT
12+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+ * version 2 for more details (a copy is included in the LICENSE file that
15+ * accompanied this code).
16+ *
17+ * You should have received a copy of the GNU General Public License version
18+ * 2 along with this work; if not, write to the Free Software Foundation,
19+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+ *
21+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+ * or visit www.oracle.com if you need additional information or have any
23+ * questions.
24+ */
25+
26+package com.sun.tools.example.debug.bdi;
27+
28+public abstract class BreakpointSpec extends EventRequestSpec {
29+
30+ BreakpointSpec(EventRequestSpecList specs, ReferenceTypeSpec refSpec) {
31+ super(specs, refSpec);
32+ }
33+
34+ @Override
35+ void notifySet(SpecListener listener, SpecEvent evt) {
36+ listener.breakpointSet(evt);
37+ }
38+
39+ @Override
40+ void notifyDeferred(SpecListener listener, SpecEvent evt) {
41+ listener.breakpointDeferred(evt);
42+ }
43+
44+ @Override
45+ void notifyResolved(SpecListener listener, SpecEvent evt) {
46+ listener.breakpointResolved(evt);
47+ }
48+
49+ @Override
50+ void notifyDeleted(SpecListener listener, SpecEvent evt) {
51+ listener.breakpointDeleted(evt);
52+ }
53+
54+ @Override
55+ void notifyError(SpecListener listener, SpecErrorEvent evt) {
56+ listener.breakpointError(evt);
57+ }
58+}
java/pkg/com/sun/tools/example/debug/bdi/ChildSession.java+300−0
@@ -0,0 +1,300 @@
1+/*
2+ * Copyright (c) 1998, 1999, Oracle and/or its affiliates. All rights reserved.
3+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+ *
5+ * This code is free software; you can redistribute it and/or modify it
6+ * under the terms of the GNU General Public License version 2 only, as
7+ * published by the Free Software Foundation. Oracle designates this
8+ * particular file as subject to the "Classpath" exception as provided
9+ * by Oracle in the LICENSE file that accompanied this code.
10+ *
11+ * This code is distributed in the hope that it will be useful, but WITHOUT
12+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+ * version 2 for more details (a copy is included in the LICENSE file that
15+ * accompanied this code).
16+ *
17+ * You should have received a copy of the GNU General Public License version
18+ * 2 along with this work; if not, write to the Free Software Foundation,
19+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+ *
21+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+ * or visit www.oracle.com if you need additional information or have any
23+ * questions.
24+ */
25+
26+package com.sun.tools.example.debug.bdi;
27+
28+import com.sun.jdi.*;
29+import com.sun.jdi.connect.LaunchingConnector;
30+import com.sun.jdi.connect.Connector;
31+import com.sun.jdi.connect.VMStartException;
32+import com.sun.jdi.connect.IllegalConnectorArgumentsException;
33+import java.io.*;
34+import java.util.Map;
35+import javax.swing.SwingUtilities;
36+
37+
38+class ChildSession extends Session {
39+
40+ private Process process;
41+
42+ private PrintWriter in;
43+ private BufferedReader out;
44+ private BufferedReader err;
45+
46+ private InputListener input;
47+ private OutputListener output;
48+ private OutputListener error;
49+
50+ public ChildSession(ExecutionManager runtime,
51+ String userVMArgs, String cmdLine,
52+ InputListener input,
53+ OutputListener output,
54+ OutputListener error,
55+ OutputListener diagnostics) {
56+ this(runtime, getVM(diagnostics, userVMArgs, cmdLine),
57+ input, output, error, diagnostics);
58+ }
59+
60+ public ChildSession(ExecutionManager runtime,
61+ LaunchingConnector connector,
62+ Map<String, Connector.Argument> arguments,
63+ InputListener input,
64+ OutputListener output,
65+ OutputListener error,
66+ OutputListener diagnostics) {
67+ this(runtime, generalGetVM(diagnostics, connector, arguments),
68+ input, output, error, diagnostics);
69+ }
70+
71+ private ChildSession(ExecutionManager runtime,
72+ VirtualMachine vm,
73+ InputListener input,
74+ OutputListener output,
75+ OutputListener error,
76+ OutputListener diagnostics) {
77+ super(vm, runtime, diagnostics);
78+ this.input = input;
79+ this.output = output;
80+ this.error = error;
81+ }
82+
83+ @Override
84+ public boolean attach() {
85+
86+ if (!connectToVMProcess()) {
87+ diagnostics.putString("Could not launch VM");
88+ return false;
89+ }
90+
91+ /*
92+ * Create a Thread that will retrieve and display any output.
93+ * Needs to be high priority, else debugger may exit before
94+ * it can be displayed.
95+ */
96+
97+ //### Rename InputWriter and OutputReader classes
98+ //### Thread priorities cribbed from ttydebug. Think about them.
99+
100+ OutputReader outputReader =
101+ new OutputReader("output reader", "output",
102+ out, output, diagnostics);
103+ outputReader.setPriority(Thread.MAX_PRIORITY-1);
104+ outputReader.start();
105+
106+ OutputReader errorReader =
107+ new OutputReader("error reader", "error",
108+ err, error, diagnostics);
109+ errorReader.setPriority(Thread.MAX_PRIORITY-1);
110+ errorReader.start();
111+
112+ InputWriter inputWriter =
113+ new InputWriter("input writer", in, input);
114+ inputWriter.setPriority(Thread.MAX_PRIORITY-1);
115+ inputWriter.start();
116+
117+ if (!super.attach()) {
118+ if (process != null) {
119+ process.destroy();
120+ process = null;
121+ }
122+ return false;
123+ }
124+
125+ //### debug
126+ //System.out.println("IO after attach: "+ inputWriter + " " + outputReader + " "+ errorReader);
127+
128+ return true;
129+ }
130+
131+ @Override
132+ public void detach() {
133+
134+ //### debug
135+ //System.out.println("IO before detach: "+ inputWriter + " " + outputReader + " "+ errorReader);
136+
137+ super.detach();
138+
139+ /*
140+ inputWriter.quit();
141+ outputReader.quit();
142+ errorReader.quit();
143+ */
144+
145+ if (process != null) {
146+ process.destroy();
147+ process = null;
148+ }
149+
150+ }
151+
152+ /**
153+ * Launch child java interpreter, return host:port
154+ */
155+
156+ static private void dumpStream(OutputListener diagnostics,
157+ InputStream stream) throws IOException {
158+ BufferedReader in =
159+ new BufferedReader(new InputStreamReader(stream));
160+ String line;
161+ while ((line = in.readLine()) != null) {
162+ diagnostics.putString(line);
163+ }
164+ }
165+
166+ static private void dumpFailedLaunchInfo(OutputListener diagnostics,
167+ Process process) {
168+ try {
169+ dumpStream(diagnostics, process.getErrorStream());
170+ dumpStream(diagnostics, process.getInputStream());
171+ } catch (IOException e) {
172+ diagnostics.putString("Unable to display process output: " +
173+ e.getMessage());
174+ }
175+ }
176+
177+ static private VirtualMachine getVM(OutputListener diagnostics,
178+ String userVMArgs,
179+ String cmdLine) {
180+ VirtualMachineManager manager = Bootstrap.virtualMachineManager();
181+ LaunchingConnector connector = manager.defaultConnector();
182+ Map<String, Connector.Argument> arguments = connector.defaultArguments();
183+ arguments.get("options").setValue(userVMArgs);
184+ arguments.get("main").setValue(cmdLine);
185+ return generalGetVM(diagnostics, connector, arguments);
186+ }
187+
188+ static private VirtualMachine generalGetVM(OutputListener diagnostics,
189+ LaunchingConnector connector,
190+ Map<String, Connector.Argument> arguments) {
191+ VirtualMachine vm = null;
192+ try {
193+ diagnostics.putString("Starting child.");
194+ vm = connector.launch(arguments);
195+ } catch (IOException ioe) {
196+ diagnostics.putString("Unable to start child: " + ioe.getMessage());
197+ } catch (IllegalConnectorArgumentsException icae) {
198+ diagnostics.putString("Unable to start child: " + icae.getMessage());
199+ } catch (VMStartException vmse) {
200+ diagnostics.putString("Unable to start child: " + vmse.getMessage() + '\n');
201+ dumpFailedLaunchInfo(diagnostics, vmse.process());
202+ }
203+ return vm;
204+ }
205+
206+ private boolean connectToVMProcess() {
207+ if (vm == null) {
208+ return false;
209+ }
210+ process = vm.process();
211+ in = new PrintWriter(new OutputStreamWriter(process.getOutputStream()));
212+ //### Note small buffer sizes!
213+ out = new BufferedReader(new InputStreamReader(process.getInputStream()), 1);
214+ err = new BufferedReader(new InputStreamReader(process.getErrorStream()), 1);
215+ return true;
216+ }
217+
218+ /**
219+ * Threads to handle application input/output.
220+ */
221+
222+ private static class OutputReader extends Thread {
223+
224+ private String streamName;
225+ private BufferedReader stream;
226+ private OutputListener output;
227+ private OutputListener diagnostics;
228+ private boolean running = true;
229+ private char[] buffer = new char[512];
230+
231+ OutputReader(String threadName,
232+ String streamName,
233+ BufferedReader stream,
234+ OutputListener output,
235+ OutputListener diagnostics) {
236+ super(threadName);
237+ this.streamName = streamName;
238+ this.stream = stream;
239+ this.output = output;
240+ this.diagnostics = diagnostics;
241+ }
242+
243+ @Override
244+ public void run() {
245+ try {
246+ int count;
247+ while (running && (count = stream.read(buffer, 0, 512)) != -1) {
248+ if (count > 0) {
249+ // Run in Swing event dispatcher thread.
250+ final String chars = new String(buffer, 0, count);
251+ SwingUtilities.invokeLater(new Runnable() {
252+ @Override
253+ public void run() {
254+ output.putString(chars);
255+ }
256+ });
257+ }
258+ //### Should we sleep briefly here?
259+ }
260+ } catch (IOException e) {
261+ // Run in Swing event dispatcher thread.
262+ SwingUtilities.invokeLater(new Runnable() {
263+ @Override
264+ public void run() {
265+ diagnostics.putString("IO error reading " +
266+ streamName +
267+ " stream of child java interpreter");
268+ }
269+ });
270+ }
271+ }
272+ }
273+
274+ private static class InputWriter extends Thread {
275+
276+ private PrintWriter stream;
277+ private InputListener input;
278+ private boolean running = true;
279+
280+ InputWriter(String threadName,
281+ PrintWriter stream,
282+ InputListener input) {
283+ super(threadName);
284+ this.stream = stream;
285+ this.input = input;
286+ }
287+
288+ @Override
289+ public void run() {
290+ String line;
291+ while (running) {
292+ line = input.getLine();
293+ stream.println(line);
294+ // Should not be needed for println above!
295+ stream.flush();
296+ }
297+ }
298+ }
299+
300+}
java/pkg/com/sun/tools/example/debug/bdi/EvaluationException.java+31−0
@@ -0,0 +1,31 @@
1+/*
2+ * Copyright (c) 1998, 1999, Oracle and/or its affiliates. All rights reserved.
3+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+ *
5+ * This code is free software; you can redistribute it and/or modify it
6+ * under the terms of the GNU General Public License version 2 only, as
7+ * published by the Free Software Foundation. Oracle designates this
8+ * particular file as subject to the "Classpath" exception as provided
9+ * by Oracle in the LICENSE file that accompanied this code.
10+ *
11+ * This code is distributed in the hope that it will be useful, but WITHOUT
12+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+ * version 2 for more details (a copy is included in the LICENSE file that
15+ * accompanied this code).
16+ *
17+ * You should have received a copy of the GNU General Public License version
18+ * 2 along with this work; if not, write to the Free Software Foundation,
19+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+ *
21+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+ * or visit www.oracle.com if you need additional information or have any
23+ * questions.
24+ */
25+
26+package com.sun.tools.example.debug.bdi;
27+
28+public class EvaluationException extends Exception {
29+
30+ private static final long serialVersionUID = 4947109680354951694L;
31+}
java/pkg/com/sun/tools/example/debug/bdi/EventRequestSpec.java+159−0
@@ -0,0 +1,159 @@
1+/*
2+ * Copyright (c) 1999, 2008, Oracle and/or its affiliates. All rights reserved.
3+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+ *
5+ * This code is free software; you can redistribute it and/or modify it
6+ * under the terms of the GNU General Public License version 2 only, as
7+ * published by the Free Software Foundation. Oracle designates this
8+ * particular file as subject to the "Classpath" exception as provided
9+ * by Oracle in the LICENSE file that accompanied this code.
10+ *
11+ * This code is distributed in the hope that it will be useful, but WITHOUT
12+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+ * version 2 for more details (a copy is included in the LICENSE file that
15+ * accompanied this code).
16+ *
17+ * You should have received a copy of the GNU General Public License version
18+ * 2 along with this work; if not, write to the Free Software Foundation,
19+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+ *
21+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+ * or visit www.oracle.com if you need additional information or have any
23+ * questions.
24+ */
25+
26+package com.sun.tools.example.debug.bdi;
27+
28+import com.sun.jdi.*;
29+import com.sun.jdi.request.EventRequest;
30+
31+abstract public class EventRequestSpec {
32+
33+ static final int STATUS_UNRESOLVED = 1;
34+ static final int STATUS_RESOLVED = 2;
35+ static final int STATUS_ERROR = 3;
36+
37+ static final Object specPropertyKey = "spec";
38+
39+ final EventRequestSpecList specs;
40+ final ReferenceTypeSpec refSpec;
41+ EventRequest request = null;
42+
43+ int status = STATUS_UNRESOLVED;
44+
45+ EventRequestSpec(EventRequestSpecList specs, ReferenceTypeSpec refSpec) {
46+ this.specs = specs;
47+ this.refSpec = refSpec;
48+ }
49+
50+ void setRequest(EventRequest request) {
51+ this.request = request;
52+ request.putProperty(specPropertyKey, this);
53+ request.enable();
54+ }
55+
56+ /**
57+ * The 'refType' is known to match.
58+ */
59+ abstract void resolve(ReferenceType refType) throws Exception;
60+
61+ abstract void notifySet(SpecListener listener, SpecEvent evt);
62+ abstract void notifyDeferred(SpecListener listener, SpecEvent evt);
63+ abstract void notifyResolved(SpecListener listener, SpecEvent evt);
64+ abstract void notifyDeleted(SpecListener listener, SpecEvent evt);
65+ abstract void notifyError(SpecListener listener, SpecErrorEvent evt);
66+
67+ /**
68+ * The 'refType' is known to match.
69+ */
70+ void resolveNotify(ReferenceType refType) {
71+ try {
72+ resolve(refType);
73+ status = STATUS_RESOLVED;
74+ specs.notifyResolved(this);
75+ } catch(Exception exc) {
76+ status = STATUS_ERROR;
77+ specs.notifyError(this, exc);
78+ }
79+ }
80+
81+ /**
82+ * See if 'refType' matches and resolve.
83+ */
84+ void attemptResolve(ReferenceType refType) {
85+ if (!isResolved() && refSpec.matches(refType)) {
86+ resolveNotify(refType);
87+ }
88+ }
89+
90+ void attemptImmediateResolve(VirtualMachine vm) {
91+ // try to resolve immediately
92+ for (ReferenceType refType : vm.allClasses()) {
93+ if (refSpec.matches(refType)) {
94+ try {
95+ resolve(refType);
96+ status = STATUS_RESOLVED;
97+ specs.notifySet(this);
98+ } catch(Exception exc) {
99+ status = STATUS_ERROR;
100+ specs.notifyError(this, exc);
101+ }
102+ return;
103+ }
104+ }
105+ specs.notifyDeferred(this);
106+ }
107+
108+ public EventRequest getEventRequest() {
109+ return request;
110+ }
111+
112+ /**
113+ * @return true if this spec has been resolved.
114+ */
115+ public boolean isResolved() {
116+ return status == STATUS_RESOLVED;
117+ }
118+
119+ /**
120+ * @return true if this spec has not yet been resolved.
121+ */
122+ public boolean isUnresolved() {
123+ return status == STATUS_UNRESOLVED;
124+ }
125+
126+ /**
127+ * @return true if this spec is unresolvable due to error.
128+ */
129+ public boolean isErroneous() {
130+ return status == STATUS_ERROR;
131+ }
132+
133+ public String getStatusString() {
134+ switch (status) {
135+ case STATUS_RESOLVED:
136+ return "resolved";
137+ case STATUS_UNRESOLVED:
138+ return "deferred";
139+ case STATUS_ERROR:
140+ return "erroneous";
141+ }
142+ return "unknown";
143+ }
144+
145+ boolean isJavaIdentifier(String s) {
146+ return Utils.isJavaIdentifier(s);
147+ }
148+
149+ public String errorMessageFor(Exception e) {
150+ if (e instanceof IllegalArgumentException) {
151+ return ("Invalid command syntax");
152+ } else if (e instanceof RuntimeException) {
153+ // A runtime exception that we were not expecting
154+ throw (RuntimeException)e;
155+ } else {
156+ return ("Internal error; unable to set" + this);
157+ }
158+ }
159+}
java/pkg/com/sun/tools/example/debug/bdi/EventRequestSpecList.java+178−0
@@ -0,0 +1,178 @@
1+/*
2+ * Copyright (c) 1999, 2008, Oracle and/or its affiliates. All rights reserved.
3+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+ *
5+ * This code is free software; you can redistribute it and/or modify it
6+ * under the terms of the GNU General Public License version 2 only, as
7+ * published by the Free Software Foundation. Oracle designates this
8+ * particular file as subject to the "Classpath" exception as provided
9+ * by Oracle in the LICENSE file that accompanied this code.
10+ *
11+ * This code is distributed in the hope that it will be useful, but WITHOUT
12+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+ * version 2 for more details (a copy is included in the LICENSE file that
15+ * accompanied this code).
16+ *
17+ * You should have received a copy of the GNU General Public License version
18+ * 2 along with this work; if not, write to the Free Software Foundation,
19+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+ *
21+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+ * or visit www.oracle.com if you need additional information or have any
23+ * questions.
24+ */
25+
26+package com.sun.tools.example.debug.bdi;
27+
28+import com.sun.jdi.*;
29+import com.sun.jdi.request.*;
30+
31+import java.util.*;
32+
33+class EventRequestSpecList {
34+
35+ // all specs
36+ private List<EventRequestSpec> eventRequestSpecs = Collections.synchronizedList(
37+ new ArrayList<EventRequestSpec>());
38+
39+ final ExecutionManager runtime;
40+
41+ EventRequestSpecList(ExecutionManager runtime) {
42+ this.runtime = runtime;
43+ }
44+
45+ /**
46+ * Resolve all deferred eventRequests waiting for 'refType'.
47+ */
48+ void resolve(ReferenceType refType) {
49+ synchronized(eventRequestSpecs) {
50+ for (EventRequestSpec spec : eventRequestSpecs) {
51+ spec.attemptResolve(refType);
52+ }
53+ }
54+ }
55+
56+ void install(EventRequestSpec ers, VirtualMachine vm) {
57+ synchronized (eventRequestSpecs) {
58+ eventRequestSpecs.add(ers);
59+ }
60+ if (vm != null) {
61+ ers.attemptImmediateResolve(vm);
62+ }
63+ }
64+
65+ BreakpointSpec
66+ createClassLineBreakpoint(String classPattern, int line) {
67+ ReferenceTypeSpec refSpec =
68+ new PatternReferenceTypeSpec(classPattern);
69+ return new LineBreakpointSpec(this, refSpec, line);
70+ }
71+
72+ BreakpointSpec
73+ createSourceLineBreakpoint(String sourceName, int line) {
74+ ReferenceTypeSpec refSpec =
75+ new SourceNameReferenceTypeSpec(sourceName, line);
76+ return new LineBreakpointSpec(this, refSpec, line);
77+ }
78+
79+ BreakpointSpec
80+ createMethodBreakpoint(String classPattern,
81+ String methodId, List<String> methodArgs) {
82+ ReferenceTypeSpec refSpec =
83+ new PatternReferenceTypeSpec(classPattern);
84+ return new MethodBreakpointSpec(this, refSpec,
85+ methodId, methodArgs);
86+ }
87+
88+ ExceptionSpec
89+ createExceptionIntercept(String classPattern,
90+ boolean notifyCaught,
91+ boolean notifyUncaught) {
92+ ReferenceTypeSpec refSpec =
93+ new PatternReferenceTypeSpec(classPattern);
94+ return new ExceptionSpec(this, refSpec,
95+ notifyCaught, notifyUncaught);
96+ }
97+
98+ AccessWatchpointSpec
99+ createAccessWatchpoint(String classPattern, String fieldId) {
100+ ReferenceTypeSpec refSpec =
101+ new PatternReferenceTypeSpec(classPattern);
102+ return new AccessWatchpointSpec(this, refSpec, fieldId);
103+ }
104+
105+ ModificationWatchpointSpec
106+ createModificationWatchpoint(String classPattern, String fieldId) {
107+ ReferenceTypeSpec refSpec =
108+ new PatternReferenceTypeSpec(classPattern);
109+ return new ModificationWatchpointSpec(this, refSpec, fieldId);
110+ }
111+
112+ void delete(EventRequestSpec ers) {
113+ EventRequest request = ers.getEventRequest();
114+ synchronized (eventRequestSpecs) {
115+ eventRequestSpecs.remove(ers);
116+ }
117+ if (request != null) {
118+ request.virtualMachine().eventRequestManager()
119+ .deleteEventRequest(request);
120+ }
121+ notifyDeleted(ers);
122+ //### notify delete - here?
123+ }
124+
125+ List<EventRequestSpec> eventRequestSpecs() {
126+ // We need to make a copy to avoid synchronization problems
127+ synchronized (eventRequestSpecs) {
128+ return new ArrayList<EventRequestSpec>(eventRequestSpecs);
129+ }
130+ }
131+
132+ // -------- notify routines --------------------
133+
134+ @SuppressWarnings("unchecked")
135+ private Vector<SpecListener> specListeners() {
136+ return (Vector<SpecListener>)runtime.specListeners.clone();
137+ }
138+
139+ void notifySet(EventRequestSpec spec) {
140+ Vector<SpecListener> l = specListeners();
141+ SpecEvent evt = new SpecEvent(spec);
142+ for (int i = 0; i < l.size(); i++) {
143+ spec.notifySet(l.elementAt(i), evt);
144+ }
145+ }
146+
147+ void notifyDeferred(EventRequestSpec spec) {
148+ Vector<SpecListener> l = specListeners();
149+ SpecEvent evt = new SpecEvent(spec);
150+ for (int i = 0; i < l.size(); i++) {
151+ spec.notifyDeferred(l.elementAt(i), evt);
152+ }
153+ }
154+
155+ void notifyDeleted(EventRequestSpec spec) {
156+ Vector<SpecListener> l = specListeners();
157+ SpecEvent evt = new SpecEvent(spec);
158+ for (int i = 0; i < l.size(); i++) {
159+ spec.notifyDeleted(l.elementAt(i), evt);
160+ }
161+ }
162+
163+ void notifyResolved(EventRequestSpec spec) {
164+ Vector<SpecListener> l = specListeners();
165+ SpecEvent evt = new SpecEvent(spec);
166+ for (int i = 0; i < l.size(); i++) {
167+ spec.notifyResolved(l.elementAt(i), evt);
168+ }
169+ }
170+
171+ void notifyError(EventRequestSpec spec, Exception exc) {
172+ Vector<SpecListener> l = specListeners();
173+ SpecErrorEvent evt = new SpecErrorEvent(spec, exc);
174+ for (int i = 0; i < l.size(); i++) {
175+ spec.notifyError(l.elementAt(i), evt);
176+ }
177+ }
178+}
java/pkg/com/sun/tools/example/debug/bdi/ExceptionSpec.java+100−0
@@ -0,0 +1,100 @@
1+/*
2+ * Copyright (c) 1999, Oracle and/or its affiliates. All rights reserved.
3+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+ *
5+ * This code is free software; you can redistribute it and/or modify it
6+ * under the terms of the GNU General Public License version 2 only, as
7+ * published by the Free Software Foundation. Oracle designates this
8+ * particular file as subject to the "Classpath" exception as provided
9+ * by Oracle in the LICENSE file that accompanied this code.
10+ *
11+ * This code is distributed in the hope that it will be useful, but WITHOUT
12+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+ * version 2 for more details (a copy is included in the LICENSE file that
15+ * accompanied this code).
16+ *
17+ * You should have received a copy of the GNU General Public License version
18+ * 2 along with this work; if not, write to the Free Software Foundation,
19+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+ *
21+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+ * or visit www.oracle.com if you need additional information or have any
23+ * questions.
24+ */
25+
26+package com.sun.tools.example.debug.bdi;
27+
28+import com.sun.jdi.ReferenceType;
29+
30+public class ExceptionSpec extends EventRequestSpec {
31+
32+ boolean notifyCaught;
33+ boolean notifyUncaught;
34+
35+ ExceptionSpec(EventRequestSpecList specs, ReferenceTypeSpec refSpec,
36+ boolean notifyCaught, boolean notifyUncaught)
37+ {
38+ super(specs, refSpec);
39+ this.notifyCaught = notifyCaught;
40+ this.notifyUncaught = notifyUncaught;
41+ }
42+
43+ @Override
44+ void notifySet(SpecListener listener, SpecEvent evt) {
45+ listener.exceptionInterceptSet(evt);
46+ }
47+
48+ @Override
49+ void notifyDeferred(SpecListener listener, SpecEvent evt) {
50+ listener.exceptionInterceptDeferred(evt);
51+ }
52+
53+ @Override
54+ void notifyResolved(SpecListener listener, SpecEvent evt) {
55+ listener.exceptionInterceptResolved(evt);
56+ }
57+
58+ @Override
59+ void notifyDeleted(SpecListener listener, SpecEvent evt) {
60+ listener.exceptionInterceptDeleted(evt);
61+ }
62+
63+ @Override
64+ void notifyError(SpecListener listener, SpecErrorEvent evt) {
65+ listener.exceptionInterceptError(evt);
66+ }
67+
68+ /**
69+ * The 'refType' is known to match.
70+ */
71+ @Override
72+ void resolve(ReferenceType refType) {
73+ setRequest(refType.virtualMachine().eventRequestManager()
74+ .createExceptionRequest(refType,
75+ notifyCaught, notifyUncaught));
76+ }
77+
78+ @Override
79+ public int hashCode() {
80+ return refSpec.hashCode();
81+ }
82+
83+ @Override
84+ public boolean equals(Object obj) {
85+ if (obj instanceof ExceptionSpec) {
86+ ExceptionSpec es = (ExceptionSpec)obj;
87+
88+ return refSpec.equals(es.refSpec);
89+ } else {
90+ return false;
91+ }
92+ }
93+
94+ @Override
95+ public String toString() {
96+ StringBuffer buffer = new StringBuffer("exception catch ");
97+ buffer.append(refSpec.toString());
98+ return buffer.toString();
99+ }
100+}
java/pkg/com/sun/tools/example/debug/bdi/ExecutionManager.java+815−0
@@ -0,0 +1,815 @@
1+/*
2+ * Copyright (c) 1998, 2008, Oracle and/or its affiliates. All rights reserved.
3+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+ *
5+ * This code is free software; you can redistribute it and/or modify it
6+ * under the terms of the GNU General Public License version 2 only, as
7+ * published by the Free Software Foundation. Oracle designates this
8+ * particular file as subject to the "Classpath" exception as provided
9+ * by Oracle in the LICENSE file that accompanied this code.
10+ *
11+ * This code is distributed in the hope that it will be useful, but WITHOUT
12+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+ * version 2 for more details (a copy is included in the LICENSE file that
15+ * accompanied this code).
16+ *
17+ * You should have received a copy of the GNU General Public License version
18+ * 2 along with this work; if not, write to the Free Software Foundation,
19+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+ *
21+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+ * or visit www.oracle.com if you need additional information or have any
23+ * questions.
24+ */
25+
26+package com.sun.tools.example.debug.bdi;
27+
28+import com.sun.jdi.*;
29+import com.sun.jdi.request.*;
30+import com.sun.jdi.connect.*;
31+import com.sun.tools.example.debug.expr.ExpressionParser;
32+import com.sun.tools.example.debug.expr.ParseException;
33+
34+import java.io.*;
35+import java.util.*;
36+
37+import com.sun.tools.example.debug.event.*;
38+
39+import javax.swing.SwingUtilities;
40+
41+/**
42+ * Move this towards being only state and functionality
43+ * that spans across Sessions (and thus VMs).
44+ */
45+public class ExecutionManager {
46+
47+ private Session session;
48+
49+ /**
50+ * Get/set JDI trace mode.
51+ */
52+ int traceMode = VirtualMachine.TRACE_NONE;
53+
54+ ////////////////// Listener registration //////////////////
55+
56+ // Session Listeners
57+
58+ ArrayList<SessionListener> sessionListeners = new ArrayList<SessionListener>();
59+
60+ public void addSessionListener(SessionListener listener) {
61+ sessionListeners.add(listener);
62+ }
63+
64+ public void removeSessionListener(SessionListener listener) {
65+ sessionListeners.remove(listener);
66+ }
67+
68+ // Spec Listeners
69+
70+ ArrayList<SpecListener> specListeners = new ArrayList<SpecListener>();
71+
72+ public void addSpecListener(SpecListener cl) {
73+ specListeners.add(cl);
74+ }
75+
76+ public void removeSpecListener(SpecListener cl) {
77+ specListeners.remove(cl);
78+ }
79+
80+ // JDI Listeners
81+
82+ ArrayList<JDIListener> jdiListeners = new ArrayList<JDIListener>();
83+
84+ /**
85+ * Adds a JDIListener
86+ */
87+ public void addJDIListener(JDIListener jl) {
88+ jdiListeners.add(jl);
89+ }
90+
91+ /**
92+ * Adds a JDIListener - at the specified position
93+ */
94+ public void addJDIListener(int index, JDIListener jl) {
95+ jdiListeners.add(index, jl);
96+ }
97+
98+ /**
99+ * Removes a JDIListener
100+ */
101+ public void removeJDIListener(JDIListener jl) {
102+ jdiListeners.remove(jl);
103+ }
104+
105+ // App Echo Listeners
106+
107+ private ArrayList<OutputListener> appEchoListeners = new ArrayList<OutputListener>();
108+
109+ public void addApplicationEchoListener(OutputListener l) {
110+ appEchoListeners.add(l);
111+ }
112+
113+ public void removeApplicationEchoListener(OutputListener l) {
114+ appEchoListeners.remove(l);
115+ }
116+
117+ // App Output Listeners
118+
119+ private ArrayList<OutputListener> appOutputListeners = new ArrayList<OutputListener>();
120+
121+ public void addApplicationOutputListener(OutputListener l) {
122+ appOutputListeners.add(l);
123+ }
124+
125+ public void removeApplicationOutputListener(OutputListener l) {
126+ appOutputListeners.remove(l);
127+ }
128+
129+ // App Error Listeners
130+
131+ private ArrayList<OutputListener> appErrorListeners = new ArrayList<OutputListener>();
132+
133+ public void addApplicationErrorListener(OutputListener l) {
134+ appErrorListeners.add(l);
135+ }
136+
137+ public void removeApplicationErrorListener(OutputListener l) {
138+ appErrorListeners.remove(l);
139+ }
140+
141+ // Diagnostic Listeners
142+
143+ private ArrayList<OutputListener> diagnosticsListeners = new ArrayList<OutputListener>();
144+
145+ public void addDiagnosticsListener(OutputListener l) {
146+ diagnosticsListeners.add(l);
147+ }
148+
149+ public void removeDiagnosticsListener(OutputListener l) {
150+ diagnosticsListeners.remove(l);
151+ }
152+
153+ /////////// End Listener Registration //////////////
154+
155+ //### We probably don't want this public
156+ public VirtualMachine vm() {
157+ return session == null ? null : session.vm;
158+ }
159+
160+ void ensureActiveSession() throws NoSessionException {
161+ if (session == null) {
162+ throw new NoSessionException();
163+ }
164+ }
165+
166+ public EventRequestManager eventRequestManager() {
167+ return vm() == null ? null : vm().eventRequestManager();
168+ }
169+
170+ /**
171+ * Get JDI trace mode.
172+ */
173+ public int getTraceMode(int mode) {
174+ return traceMode;
175+ }
176+
177+ /**
178+ * Set JDI trace mode.
179+ */
180+ public void setTraceMode(int mode) {
181+ traceMode = mode;
182+ if (session != null) {
183+ session.setTraceMode(mode);
184+ }
185+ }
186+
187+ /**
188+ * Determine if VM is interrupted, i.e, present and not running.
189+ */
190+ public boolean isInterrupted() /* should: throws NoSessionException */ {
191+// ensureActiveSession();
192+ return session.interrupted;
193+ }
194+
195+ /**
196+ * Return a list of ReferenceType objects for all
197+ * currently loaded classes and interfaces.
198+ * Array types are not returned.
199+ */
200+ public List<ReferenceType> allClasses() throws NoSessionException {
201+ ensureActiveSession();
202+ return vm().allClasses();
203+ }
204+
205+ /**
206+ * Return a ReferenceType object for the currently
207+ * loaded class or interface whose fully-qualified
208+ * class name is specified, else return null if there
209+ * is none.
210+ *
211+ * In general, we must return a list of types, because
212+ * multiple class loaders could have loaded a class
213+ * with the same fully-qualified name.
214+ */
215+ public List<ReferenceType> findClassesByName(String name) throws NoSessionException {
216+ ensureActiveSession();
217+ return vm().classesByName(name);
218+ }
219+
220+ /**
221+ * Return a list of ReferenceType objects for all
222+ * currently loaded classes and interfaces whose name
223+ * matches the given pattern. The pattern syntax is
224+ * open to some future revision, but currently consists
225+ * of a fully-qualified class name in which the first
226+ * component may optionally be a "*" character, designating
227+ * an arbitrary prefix.
228+ */
229+ public List<ReferenceType> findClassesMatchingPattern(String pattern)
230+ throws NoSessionException {
231+ ensureActiveSession();
232+ List<ReferenceType> result = new ArrayList<ReferenceType>(); //### Is default size OK?
233+ if (pattern.startsWith("*.")) {
234+ // Wildcard matches any leading package name.
235+ pattern = pattern.substring(1);
236+ for (ReferenceType type : vm().allClasses()) {
237+ if (type.name().endsWith(pattern)) {
238+ result.add(type);
239+ }
240+ }
241+ return result;
242+ } else {
243+ // It's a class name.
244+ return vm().classesByName(pattern);
245+ }
246+ }
247+
248+ /*
249+ * Return a list of ThreadReference objects corresponding
250+ * to the threads that are currently active in the VM.
251+ * A thread is removed from the list just before the
252+ * thread terminates.
253+ */
254+
255+ public List<ThreadReference> allThreads() throws NoSessionException {
256+ ensureActiveSession();
257+ return vm().allThreads();
258+ }
259+
260+ /*
261+ * Return a list of ThreadGroupReference objects corresponding
262+ * to the top-level threadgroups that are currently active in the VM.
263+ * Note that a thread group may be empty, or contain no threads as
264+ * descendents.
265+ */
266+
267+ public List<ThreadGroupReference> topLevelThreadGroups() throws NoSessionException {
268+ ensureActiveSession();
269+ return vm().topLevelThreadGroups();
270+ }
271+
272+ /*
273+ * Return the system threadgroup.
274+ */
275+
276+ public ThreadGroupReference systemThreadGroup()
277+ throws NoSessionException {
278+ ensureActiveSession();
279+ return vm().topLevelThreadGroups().get(0);
280+ }
281+
282+ /*
283+ * Evaluate an expression.
284+ */
285+
286+ public Value evaluate(final StackFrame f, String expr)
287+ throws ParseException,
288+ InvocationException,
289+ InvalidTypeException,
290+ ClassNotLoadedException,
291+ NoSessionException,
292+ IncompatibleThreadStateException {
293+ ExpressionParser.GetFrame frameGetter = null;
294+ ensureActiveSession();
295+ if (f != null) {
296+ frameGetter = new ExpressionParser.GetFrame() {
297+ @Override
298+ public StackFrame get() /* throws IncompatibleThreadStateException */ {
299+ return f;
300+ }
301+ };
302+ }
303+ return ExpressionParser.evaluate(expr, vm(), frameGetter);
304+ }
305+
306+
307+ /*
308+ * Start a new VM.
309+ */
310+
311+ public void run(boolean suspended,
312+ String vmArgs,
313+ String className,
314+ String args) throws VMLaunchFailureException {
315+
316+ endSession();
317+
318+ //### Set a breakpoint on 'main' method.
319+ //### Would be cleaner if we could just bring up VM already suspended.
320+ if (suspended) {
321+ //### Set breakpoint at 'main(java.lang.String[])'.
322+ List<String> argList = new ArrayList<String>(1);
323+ argList.add("java.lang.String[]");
324+ createMethodBreakpoint(className, "main", argList);
325+ }
326+
327+ String cmdLine = className + " " + args;
328+
329+ startSession(new ChildSession(this, vmArgs, cmdLine,
330+ appInput, appOutput, appError,
331+ diagnostics));
332+ }
333+
334+ /*
335+ * Attach to an existing VM.
336+ */
337+ public void attach(String portName) throws VMLaunchFailureException {
338+ endSession();
339+
340+ //### Changes made here for connectors have broken the
341+ //### the 'Session' abstraction. The 'Session.attach()'
342+ //### method is intended to encapsulate all of the various
343+ //### ways in which session start-up can fail. (maddox 12/18/98)
344+
345+ /*
346+ * Now that attaches and launches both go through Connectors,
347+ * it may be worth creating a new subclass of Session for
348+ * attach sessions.
349+ */
350+ VirtualMachineManager mgr = Bootstrap.virtualMachineManager();
351+ AttachingConnector connector = mgr.attachingConnectors().get(0);
352+ Map<String, Connector.Argument> arguments = connector.defaultArguments();
353+ arguments.get("port").setValue(portName);
354+
355+ Session newSession = internalAttach(connector, arguments);
356+ if (newSession != null) {
357+ startSession(newSession);
358+ }
359+ }
360+
361+ private Session internalAttach(AttachingConnector connector,
362+ Map<String, Connector.Argument> arguments) {
363+ try {
364+ VirtualMachine vm = connector.attach(arguments);
365+ return new Session(vm, this, diagnostics);
366+ } catch (IOException ioe) {
367+ diagnostics.putString("\n Unable to attach to target VM: " +
368+ ioe.getMessage());
369+ } catch (IllegalConnectorArgumentsException icae) {
370+ diagnostics.putString("\n Invalid connector arguments: " +
371+ icae.getMessage());
372+ }
373+ return null;
374+ }
375+
376+ private Session internalListen(ListeningConnector connector,
377+ Map<String, Connector.Argument> arguments) {
378+ try {
379+ VirtualMachine vm = connector.accept(arguments);
380+ return new Session(vm, this, diagnostics);
381+ } catch (IOException ioe) {
382+ diagnostics.putString(
383+ "\n Unable to accept connection to target VM: " +
384+ ioe.getMessage());
385+ } catch (IllegalConnectorArgumentsException icae) {
386+ diagnostics.putString("\n Invalid connector arguments: " +
387+ icae.getMessage());
388+ }
389+ return null;
390+ }
391+
392+ /*
393+ * Connect via user specified arguments
394+ * @return true on success
395+ */
396+ public boolean explictStart(Connector connector, Map<String, Connector.Argument> arguments)
397+ throws VMLaunchFailureException {
398+ Session newSession = null;
399+
400+ endSession();
401+
402+ if (connector instanceof LaunchingConnector) {
403+ // we were launched, use ChildSession
404+ newSession = new ChildSession(this, (LaunchingConnector)connector,
405+ arguments,
406+ appInput, appOutput, appError,
407+ diagnostics);
408+ } else if (connector instanceof AttachingConnector) {
409+ newSession = internalAttach((AttachingConnector)connector,
410+ arguments);
411+ } else if (connector instanceof ListeningConnector) {
412+ newSession = internalListen((ListeningConnector)connector,
413+ arguments);
414+ } else {
415+ diagnostics.putString("\n Unknown connector: " + connector);
416+ }
417+ if (newSession != null) {
418+ startSession(newSession);
419+ }
420+ return newSession != null;
421+ }
422+
423+ /*
424+ * Detach from VM. If VM was started by debugger, terminate it.
425+ */
426+ public void detach() throws NoSessionException {
427+ ensureActiveSession();
428+ endSession();
429+ }
430+
431+ private void startSession(Session s) throws VMLaunchFailureException {
432+ if (!s.attach()) {
433+ throw new VMLaunchFailureException();
434+ }
435+ session = s;
436+ EventRequestManager em = vm().eventRequestManager();
437+ ClassPrepareRequest classPrepareRequest = em.createClassPrepareRequest();
438+ //### We must allow the deferred breakpoints to be resolved before
439+ //### we continue executing the class. We could optimize if there
440+ //### were no deferred breakpoints outstanding for a particular class.
441+ //### Can we do this with JDI?
442+ classPrepareRequest.setSuspendPolicy(EventRequest.SUSPEND_ALL);
443+ classPrepareRequest.enable();
444+ ClassUnloadRequest classUnloadRequest = em.createClassUnloadRequest();
445+ classUnloadRequest.setSuspendPolicy(EventRequest.SUSPEND_NONE);
446+ classUnloadRequest.enable();
447+ ThreadStartRequest threadStartRequest = em.createThreadStartRequest();
448+ threadStartRequest.setSuspendPolicy(EventRequest.SUSPEND_NONE);
449+ threadStartRequest.enable();
450+ ThreadDeathRequest threadDeathRequest = em.createThreadDeathRequest();
451+ threadDeathRequest.setSuspendPolicy(EventRequest.SUSPEND_NONE);
452+ threadDeathRequest.enable();
453+ ExceptionRequest exceptionRequest =
454+ em.createExceptionRequest(null, false, true);
455+ exceptionRequest.setSuspendPolicy(EventRequest.SUSPEND_ALL);
456+ exceptionRequest.enable();
457+ validateThreadInfo();
458+ session.interrupted = true;
459+ notifySessionStart();
460+ }
461+
462+ void endSession() {
463+ if (session != null) {
464+ session.detach();
465+ session = null;
466+ invalidateThreadInfo();
467+ notifySessionDeath();
468+ }
469+ }
470+
471+ /*
472+ * Suspend all VM activity.
473+ */
474+
475+ public void interrupt() throws NoSessionException {
476+ ensureActiveSession();
477+ vm().suspend();
478+ //### Is it guaranteed that the interrupt has happened?
479+ validateThreadInfo();
480+ session.interrupted = true;
481+ notifyInterrupted();
482+ }
483+
484+ /*
485+ * Resume interrupted VM.
486+ */
487+
488+ public void go() throws NoSessionException, VMNotInterruptedException {
489+ ensureActiveSession();
490+ invalidateThreadInfo();
491+ session.interrupted = false;
492+ notifyContinued();
493+ vm().resume();
494+ }
495+
496+ /*
497+ * Stepping.
498+ */
499+ void clearPreviousStep(ThreadReference thread) {
500+ /*
501+ * A previous step may not have completed on this thread;
502+ * if so, it gets removed here.
503+ */
504+ EventRequestManager mgr = vm().eventRequestManager();
505+ for (StepRequest request : mgr.stepRequests()) {
506+ if (request.thread().equals(thread)) {
507+ mgr.deleteEventRequest(request);
508+ break;
509+ }
510+ }
511+ }
512+
513+ private void generalStep(ThreadReference thread, int size, int depth)
514+ throws NoSessionException {
515+ ensureActiveSession();
516+ invalidateThreadInfo();
517+ session.interrupted = false;
518+ notifyContinued();
519+
520+ clearPreviousStep(thread);
521+ EventRequestManager reqMgr = vm().eventRequestManager();
522+ StepRequest request = reqMgr.createStepRequest(thread,
523+ size, depth);
524+ // We want just the next step event and no others
525+ request.addCountFilter(1);
526+ request.enable();
527+ vm().resume();
528+ }
529+
530+ public void stepIntoInstruction(ThreadReference thread)
531+ throws NoSessionException {
532+ generalStep(thread, StepRequest.STEP_MIN, StepRequest.STEP_INTO);
533+ }
534+
535+ public void stepOverInstruction(ThreadReference thread)
536+ throws NoSessionException {
537+ generalStep(thread, StepRequest.STEP_MIN, StepRequest.STEP_OVER);
538+ }
539+
540+ public void stepIntoLine(ThreadReference thread)
541+ throws NoSessionException,
542+ AbsentInformationException {
543+ generalStep(thread, StepRequest.STEP_LINE, StepRequest.STEP_INTO);
544+ }
545+
546+ public void stepOverLine(ThreadReference thread)
547+ throws NoSessionException,
548+ AbsentInformationException {
549+ generalStep(thread, StepRequest.STEP_LINE, StepRequest.STEP_OVER);
550+ }
551+
552+ public void stepOut(ThreadReference thread)
553+ throws NoSessionException {
554+ generalStep(thread, StepRequest.STEP_MIN, StepRequest.STEP_OUT);
555+ }
556+
557+ /*
558+ * Thread control.
559+ */
560+
561+ public void suspendThread(ThreadReference thread) throws NoSessionException {
562+ ensureActiveSession();
563+ thread.suspend();
564+ }
565+
566+ public void resumeThread(ThreadReference thread) throws NoSessionException {
567+ ensureActiveSession();
568+ thread.resume();
569+ }
570+
571+ public void stopThread(ThreadReference thread) throws NoSessionException {
572+ ensureActiveSession();
573+ //### Need an exception now. Which one to use?
574+ //thread.stop();
575+ }
576+
577+ /*
578+ * ThreadInfo objects -- Allow query of thread status and stack.
579+ */
580+
581+ private List<ThreadInfo> threadInfoList = new LinkedList<ThreadInfo>();
582+ //### Should be weak! (in the value, not the key)
583+ private HashMap<ThreadReference, ThreadInfo> threadInfoMap = new HashMap<ThreadReference, ThreadInfo>();
584+
585+ public ThreadInfo threadInfo(ThreadReference thread) {
586+ if (session == null || thread == null) {
587+ return null;
588+ }
589+ ThreadInfo info = threadInfoMap.get(thread);
590+ if (info == null) {
591+ //### Should not hardcode initial frame count and prefetch here!
592+ //info = new ThreadInfo(thread, 10, 10);
593+ info = new ThreadInfo(thread);
594+ if (session.interrupted) {
595+ info.validate();
596+ }
597+ threadInfoList.add(info);
598+ threadInfoMap.put(thread, info);
599+ }
600+ return info;
601+ }
602+
603+ void validateThreadInfo() {
604+ session.interrupted = true;
605+ for (ThreadInfo threadInfo : threadInfoList) {
606+ threadInfo.validate();
607+ }
608+ }
609+
610+ private void invalidateThreadInfo() {
611+ if (session != null) {
612+ session.interrupted = false;
613+ for (ThreadInfo threadInfo : threadInfoList) {
614+ threadInfo.invalidate();
615+ }
616+ }
617+ }
618+
619+ void removeThreadInfo(ThreadReference thread) {
620+ ThreadInfo info = threadInfoMap.get(thread);
621+ if (info != null) {
622+ info.invalidate();
623+ threadInfoMap.remove(thread);
624+ threadInfoList.remove(info);
625+ }
626+ }
627+
628+ /*
629+ * Listen for Session control events.
630+ */
631+
632+ private void notifyInterrupted() {
633+ ArrayList<SessionListener> l = new ArrayList<SessionListener>(sessionListeners);
634+ EventObject evt = new EventObject(this);
635+ for (int i = 0; i < l.size(); i++) {
636+ l.get(i).sessionInterrupt(evt);
637+ }
638+ }
639+
640+ private void notifyContinued() {
641+ ArrayList<SessionListener> l = new ArrayList<SessionListener>(sessionListeners);
642+ EventObject evt = new EventObject(this);
643+ for (int i = 0; i < l.size(); i++) {
644+ l.get(i).sessionContinue(evt);
645+ }
646+ }
647+
648+ private void notifySessionStart() {
649+ ArrayList<SessionListener> l = new ArrayList<SessionListener>(sessionListeners);
650+ EventObject evt = new EventObject(this);
651+ for (int i = 0; i < l.size(); i++) {
652+ l.get(i).sessionStart(evt);
653+ }
654+ }
655+
656+ private void notifySessionDeath() {
657+/*** noop for now
658+ ArrayList<SessionListener> l = new ArrayList<SessionListener>(sessionListeners);
659+ EventObject evt = new EventObject(this);
660+ for (int i = 0; i < l.size(); i++) {
661+ ((SessionListener)l.get(i)).sessionDeath(evt);
662+ }
663+****/
664+ }
665+
666+ /*
667+ * Listen for input and output requests from the application
668+ * being debugged. These are generated only when the debuggee
669+ * is spawned as a child of the debugger.
670+ */
671+
672+ private Object inputLock = new Object();
673+ private LinkedList<String> inputBuffer = new LinkedList<String>();
674+
675+ private void resetInputBuffer() {
676+ synchronized (inputLock) {
677+ inputBuffer = new LinkedList<String>();
678+ }
679+ }
680+
681+ public void sendLineToApplication(String line) {
682+ synchronized (inputLock) {
683+ inputBuffer.addFirst(line);
684+ inputLock.notifyAll();
685+ }
686+ }
687+
688+ private InputListener appInput = new InputListener() {
689+ @Override
690+ public String getLine() {
691+ // Don't allow reader to be interrupted -- catch and retry.
692+ String line = null;
693+ while (line == null) {
694+ synchronized (inputLock) {
695+ try {
696+ while (inputBuffer.size() < 1) {
697+ inputLock.wait();
698+ }
699+ line = inputBuffer.removeLast();
700+ } catch (InterruptedException e) {}
701+ }
702+ }
703+ // We must not be holding inputLock here, as the listener
704+ // that we call to echo a line might call us re-entrantly
705+ // to provide another line of input.
706+ // Run in Swing event dispatcher thread.
707+ final String input = line;
708+ SwingUtilities.invokeLater(new Runnable() {
709+ @Override
710+ public void run() {
711+ echoInputLine(input);
712+ }
713+ });
714+ return line;
715+ }
716+ };
717+
718+ private static String newline = System.getProperty("line.separator");
719+
720+ private void echoInputLine(String line) {
721+ ArrayList<OutputListener> l = new ArrayList<OutputListener>(appEchoListeners);
722+ for (int i = 0; i < l.size(); i++) {
723+ OutputListener ol = l.get(i);
724+ ol.putString(line);
725+ ol.putString(newline);
726+ }
727+ }
728+
729+ private OutputListener appOutput = new OutputListener() {
730+ @Override
731+ public void putString(String string) {
732+ ArrayList<OutputListener> l = new ArrayList<OutputListener>(appEchoListeners);
733+ for (int i = 0; i < l.size(); i++) {
734+ l.get(i).putString(string);
735+ }
736+ }
737+ };
738+
739+ private OutputListener appError = new OutputListener() {
740+ @Override
741+ public void putString(String string) {
742+ ArrayList<OutputListener> l = new ArrayList<OutputListener>(appEchoListeners);
743+ for (int i = 0; i < l.size(); i++) {
744+ l.get(i).putString(string);
745+ }
746+ }
747+ };
748+
749+ private OutputListener diagnostics = new OutputListener() {
750+ @Override
751+ public void putString(String string) {
752+ ArrayList<OutputListener> l = new ArrayList<OutputListener>(diagnosticsListeners);
753+ for (int i = 0; i < l.size(); i++) {
754+ l.get(i).putString(string);
755+ }
756+ }
757+ };
758+
759+ ///////////// Spec Request Creation/Deletion/Query ///////////
760+
761+ private EventRequestSpecList specList = new EventRequestSpecList(this);
762+
763+ public BreakpointSpec
764+ createSourceLineBreakpoint(String sourceName, int line) {
765+ return specList.createSourceLineBreakpoint(sourceName, line);
766+ }
767+
768+ public BreakpointSpec
769+ createClassLineBreakpoint(String classPattern, int line) {
770+ return specList.createClassLineBreakpoint(classPattern, line);
771+ }
772+
773+ public BreakpointSpec
774+ createMethodBreakpoint(String classPattern,
775+ String methodId, List<String> methodArgs) {
776+ return specList.createMethodBreakpoint(classPattern,
777+ methodId, methodArgs);
778+ }
779+
780+ public ExceptionSpec
781+ createExceptionIntercept(String classPattern,
782+ boolean notifyCaught,
783+ boolean notifyUncaught) {
784+ return specList.createExceptionIntercept(classPattern,
785+ notifyCaught,
786+ notifyUncaught);
787+ }
788+
789+ public AccessWatchpointSpec
790+ createAccessWatchpoint(String classPattern, String fieldId) {
791+ return specList.createAccessWatchpoint(classPattern, fieldId);
792+ }
793+
794+ public ModificationWatchpointSpec
795+ createModificationWatchpoint(String classPattern, String fieldId) {
796+ return specList.createModificationWatchpoint(classPattern,
797+ fieldId);
798+ }
799+
800+ public void delete(EventRequestSpec spec) {
801+ specList.delete(spec);
802+ }
803+
804+ void resolve(ReferenceType refType) {
805+ specList.resolve(refType);
806+ }
807+
808+ public void install(EventRequestSpec spec) {
809+ specList.install(spec, vm());
810+ }
811+
812+ public List<EventRequestSpec> eventRequestSpecs() {
813+ return specList.eventRequestSpecs();
814+ }
815+}
java/pkg/com/sun/tools/example/debug/bdi/FrameIndexOutOfBoundsException.java+31−0
@@ -0,0 +1,31 @@
1+/*
2+ * Copyright (c) 1998, 1999, Oracle and/or its affiliates. All rights reserved.
3+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+ *
5+ * This code is free software; you can redistribute it and/or modify it
6+ * under the terms of the GNU General Public License version 2 only, as
7+ * published by the Free Software Foundation. Oracle designates this
8+ * particular file as subject to the "Classpath" exception as provided
9+ * by Oracle in the LICENSE file that accompanied this code.
10+ *
11+ * This code is distributed in the hope that it will be useful, but WITHOUT
12+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+ * version 2 for more details (a copy is included in the LICENSE file that
15+ * accompanied this code).
16+ *
17+ * You should have received a copy of the GNU General Public License version
18+ * 2 along with this work; if not, write to the Free Software Foundation,
19+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+ *
21+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+ * or visit www.oracle.com if you need additional information or have any
23+ * questions.
24+ */
25+
26+package com.sun.tools.example.debug.bdi;
27+
28+public class FrameIndexOutOfBoundsException extends IndexOutOfBoundsException {
29+
30+ private static final long serialVersionUID = -4870148107027371437L;
31+}
java/pkg/com/sun/tools/example/debug/bdi/InputListener.java+30−0
@@ -0,0 +1,30 @@
1+/*
2+ * Copyright (c) 1998, 1999, Oracle and/or its affiliates. All rights reserved.
3+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+ *
5+ * This code is free software; you can redistribute it and/or modify it
6+ * under the terms of the GNU General Public License version 2 only, as
7+ * published by the Free Software Foundation. Oracle designates this
8+ * particular file as subject to the "Classpath" exception as provided
9+ * by Oracle in the LICENSE file that accompanied this code.
10+ *
11+ * This code is distributed in the hope that it will be useful, but WITHOUT
12+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+ * version 2 for more details (a copy is included in the LICENSE file that
15+ * accompanied this code).
16+ *
17+ * You should have received a copy of the GNU General Public License version
18+ * 2 along with this work; if not, write to the Free Software Foundation,
19+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+ *
21+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+ * or visit www.oracle.com if you need additional information or have any
23+ * questions.
24+ */
25+
26+package com.sun.tools.example.debug.bdi;
27+
28+public interface InputListener {
29+ String getLine();
30+}
java/pkg/com/sun/tools/example/debug/bdi/JDIEventSource.java+184−0
@@ -0,0 +1,184 @@
1+/*
2+ * Copyright (c) 1999, 2008, Oracle and/or its affiliates. All rights reserved.
3+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+ *
5+ * This code is free software; you can redistribute it and/or modify it
6+ * under the terms of the GNU General Public License version 2 only, as
7+ * published by the Free Software Foundation. Oracle designates this
8+ * particular file as subject to the "Classpath" exception as provided
9+ * by Oracle in the LICENSE file that accompanied this code.
10+ *
11+ * This code is distributed in the hope that it will be useful, but WITHOUT
12+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+ * version 2 for more details (a copy is included in the LICENSE file that
15+ * accompanied this code).
16+ *
17+ * You should have received a copy of the GNU General Public License version
18+ * 2 along with this work; if not, write to the Free Software Foundation,
19+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+ *
21+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+ * or visit www.oracle.com if you need additional information or have any
23+ * questions.
24+ */
25+
26+package com.sun.tools.example.debug.bdi;
27+
28+import com.sun.jdi.*;
29+import com.sun.jdi.event.*;
30+
31+import com.sun.tools.example.debug.event.*;
32+
33+import javax.swing.SwingUtilities;
34+
35+/**
36+ */
37+class JDIEventSource extends Thread {
38+
39+ private /*final*/ EventQueue queue;
40+ private /*final*/ Session session;
41+ private /*final*/ ExecutionManager runtime;
42+ private final JDIListener firstListener = new FirstListener();
43+
44+ private boolean wantInterrupt; //### Hack
45+
46+ /**
47+ * Create event source.
48+ */
49+ JDIEventSource(Session session) {
50+ super("JDI Event Set Dispatcher");
51+ this.session = session;
52+ this.runtime = session.runtime;
53+ this.queue = session.vm.eventQueue();
54+ }
55+
56+ @Override
57+ public void run() {
58+ try {
59+ runLoop();
60+ } catch (Exception exc) {
61+ //### Do something different for InterruptedException???
62+ // just exit
63+ }
64+ session.running = false;
65+ }
66+
67+ private void runLoop() throws InterruptedException {
68+ AbstractEventSet es;
69+ do {
70+ EventSet jdiEventSet = queue.remove();
71+ es = AbstractEventSet.toSpecificEventSet(jdiEventSet);
72+ session.interrupted = es.suspendedAll();
73+ dispatchEventSet(es);
74+ } while(!(es instanceof VMDisconnectEventSet));
75+ }
76+
77+ //### Gross foul hackery!
78+ private void dispatchEventSet(final AbstractEventSet es) {
79+ SwingUtilities.invokeLater(new Runnable() {
80+ @Override
81+ public void run() {
82+ boolean interrupted = es.suspendedAll();
83+ es.notify(firstListener);
84+ boolean wantInterrupt = JDIEventSource.this.wantInterrupt;
85+ for (JDIListener jl : session.runtime.jdiListeners) {
86+ es.notify(jl);
87+ }
88+ if (interrupted && !wantInterrupt) {
89+ session.interrupted = false;
90+ //### Catch here is a hack
91+ try {
92+ session.vm.resume();
93+ } catch (VMDisconnectedException ee) {}
94+ }
95+ if (es instanceof ThreadDeathEventSet) {
96+ ThreadReference t = ((ThreadDeathEventSet)es).getThread();
97+ session.runtime.removeThreadInfo(t);
98+ }
99+ }
100+ });
101+ }
102+
103+ private void finalizeEventSet(AbstractEventSet es) {
104+ if (session.interrupted && !wantInterrupt) {
105+ session.interrupted = false;
106+ //### Catch here is a hack
107+ try {
108+ session.vm.resume();
109+ } catch (VMDisconnectedException ee) {}
110+ }
111+ if (es instanceof ThreadDeathEventSet) {
112+ ThreadReference t = ((ThreadDeathEventSet)es).getThread();
113+ session.runtime.removeThreadInfo(t);
114+ }
115+ }
116+
117+ //### This is a Hack, deal with it
118+ private class FirstListener implements JDIListener {
119+
120+ @Override
121+ public void accessWatchpoint(AccessWatchpointEventSet e) {
122+ session.runtime.validateThreadInfo();
123+ wantInterrupt = true;
124+ }
125+
126+ @Override
127+ public void classPrepare(ClassPrepareEventSet e) {
128+ wantInterrupt = false;
129+ runtime.resolve(e.getReferenceType());
130+ }
131+
132+ @Override
133+ public void classUnload(ClassUnloadEventSet e) {
134+ wantInterrupt = false;
135+ }
136+
137+ @Override
138+ public void exception(ExceptionEventSet e) {
139+ wantInterrupt = true;
140+ }
141+
142+ @Override
143+ public void locationTrigger(LocationTriggerEventSet e) {
144+ session.runtime.validateThreadInfo();
145+ wantInterrupt = true;
146+ }
147+
148+ @Override
149+ public void modificationWatchpoint(ModificationWatchpointEventSet e) {
150+ session.runtime.validateThreadInfo();
151+ wantInterrupt = true;
152+ }
153+
154+ @Override
155+ public void threadDeath(ThreadDeathEventSet e) {
156+ wantInterrupt = false;
157+ }
158+
159+ @Override
160+ public void threadStart(ThreadStartEventSet e) {
161+ wantInterrupt = false;
162+ }
163+
164+ @Override
165+ public void vmDeath(VMDeathEventSet e) {
166+ //### Should have some way to notify user
167+ //### that VM died before the session ended.
168+ wantInterrupt = false;
169+ }
170+
171+ @Override
172+ public void vmDisconnect(VMDisconnectEventSet e) {
173+ //### Notify user?
174+ wantInterrupt = false;
175+ session.runtime.endSession();
176+ }
177+
178+ @Override
179+ public void vmStart(VMStartEventSet e) {
180+ //### Do we need to do anything with it?
181+ wantInterrupt = false;
182+ }
183+ }
184+}
java/pkg/com/sun/tools/example/debug/bdi/LineBreakpointSpec.java+121−0
@@ -0,0 +1,121 @@
1+/*
2+ * Copyright (c) 1999, 2008, Oracle and/or its affiliates. All rights reserved.
3+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+ *
5+ * This code is free software; you can redistribute it and/or modify it
6+ * under the terms of the GNU General Public License version 2 only, as
7+ * published by the Free Software Foundation. Oracle designates this
8+ * particular file as subject to the "Classpath" exception as provided
9+ * by Oracle in the LICENSE file that accompanied this code.
10+ *
11+ * This code is distributed in the hope that it will be useful, but WITHOUT
12+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+ * version 2 for more details (a copy is included in the LICENSE file that
15+ * accompanied this code).
16+ *
17+ * You should have received a copy of the GNU General Public License version
18+ * 2 along with this work; if not, write to the Free Software Foundation,
19+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+ *
21+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+ * or visit www.oracle.com if you need additional information or have any
23+ * questions.
24+ */
25+
26+package com.sun.tools.example.debug.bdi;
27+
28+import com.sun.jdi.*;
29+import java.util.List;
30+
31+public class LineBreakpointSpec extends BreakpointSpec {
32+ int lineNumber;
33+
34+ LineBreakpointSpec(EventRequestSpecList specs,
35+ ReferenceTypeSpec refSpec, int lineNumber) {
36+ super(specs, refSpec);
37+ this.lineNumber = lineNumber;
38+ }
39+
40+ /**
41+ * The 'refType' is known to match.
42+ */
43+ @Override
44+ void resolve(ReferenceType refType) throws InvalidTypeException,
45+ LineNotFoundException {
46+ if (!(refType instanceof ClassType)) {
47+ throw new InvalidTypeException();
48+ }
49+ Location location = location((ClassType)refType);
50+ setRequest(refType.virtualMachine().eventRequestManager()
51+ .createBreakpointRequest(location));
52+ }
53+
54+ private Location location(ClassType clazz) throws
55+ LineNotFoundException {
56+ Location location = null;
57+ try {
58+ List<Location> locs = clazz.locationsOfLine(lineNumber());
59+ if (locs.size() == 0) {
60+ throw new LineNotFoundException();
61+ }
62+ // TODO handle multiple locations
63+ location = locs.get(0);
64+ if (location.method() == null) {
65+ throw new LineNotFoundException();
66+ }
67+ } catch (AbsentInformationException e) {
68+ /*
69+ * TO DO: throw something more specific, or allow
70+ * AbsentInfo exception to pass through.
71+ */
72+ throw new LineNotFoundException();
73+ }
74+ return location;
75+ }
76+
77+ public int lineNumber() {
78+ return lineNumber;
79+ }
80+
81+ @Override
82+ public int hashCode() {
83+ return refSpec.hashCode() + lineNumber;
84+ }
85+
86+ @Override
87+ public boolean equals(Object obj) {
88+ if (obj instanceof LineBreakpointSpec) {
89+ LineBreakpointSpec breakpoint = (LineBreakpointSpec)obj;
90+
91+ return refSpec.equals(breakpoint.refSpec) &&
92+ (lineNumber == breakpoint.lineNumber);
93+ } else {
94+ return false;
95+ }
96+ }
97+
98+ @Override
99+ public String errorMessageFor(Exception e) {
100+ if (e instanceof LineNotFoundException) {
101+ return ("No code at line " + lineNumber() + " in " + refSpec);
102+ } else if (e instanceof InvalidTypeException) {
103+ return ("Breakpoints can be located only in classes. " +
104+ refSpec + " is an interface or array");
105+ } else {
106+ return super.errorMessageFor( e);
107+ }
108+ }
109+
110+ @Override
111+ public String toString() {
112+ StringBuffer buffer = new StringBuffer("breakpoint ");
113+ buffer.append(refSpec.toString());
114+ buffer.append(':');
115+ buffer.append(lineNumber);
116+ buffer.append(" (");
117+ buffer.append(getStatusString());
118+ buffer.append(')');
119+ return buffer.toString();
120+ }
121+}
java/pkg/com/sun/tools/example/debug/bdi/LineNotFoundException.java+42−0
@@ -0,0 +1,42 @@
1+/*
2+ * Copyright (c) 1998, 1999, Oracle and/or its affiliates. All rights reserved.
3+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+ *
5+ * This code is free software; you can redistribute it and/or modify it
6+ * under the terms of the GNU General Public License version 2 only, as
7+ * published by the Free Software Foundation. Oracle designates this
8+ * particular file as subject to the "Classpath" exception as provided
9+ * by Oracle in the LICENSE file that accompanied this code.
10+ *
11+ * This code is distributed in the hope that it will be useful, but WITHOUT
12+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+ * version 2 for more details (a copy is included in the LICENSE file that
15+ * accompanied this code).
16+ *
17+ * You should have received a copy of the GNU General Public License version
18+ * 2 along with this work; if not, write to the Free Software Foundation,
19+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+ *
21+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+ * or visit www.oracle.com if you need additional information or have any
23+ * questions.
24+ */
25+
26+package com.sun.tools.example.debug.bdi;
27+
28+public class LineNotFoundException extends Exception
29+{
30+
31+ private static final long serialVersionUID = -5630418117861587582L;
32+
33+ public LineNotFoundException()
34+ {
35+ super();
36+ }
37+
38+ public LineNotFoundException(String s)
39+ {
40+ super(s);
41+ }
42+}
java/pkg/com/sun/tools/example/debug/bdi/MalformedMemberNameException.java+39−0
@@ -0,0 +1,39 @@
1+/*
2+ * Copyright (c) 1999, Oracle and/or its affiliates. All rights reserved.
3+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+ *
5+ * This code is free software; you can redistribute it and/or modify it
6+ * under the terms of the GNU General Public License version 2 only, as
7+ * published by the Free Software Foundation. Oracle designates this
8+ * particular file as subject to the "Classpath" exception as provided
9+ * by Oracle in the LICENSE file that accompanied this code.
10+ *
11+ * This code is distributed in the hope that it will be useful, but WITHOUT
12+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+ * version 2 for more details (a copy is included in the LICENSE file that
15+ * accompanied this code).
16+ *
17+ * You should have received a copy of the GNU General Public License version
18+ * 2 along with this work; if not, write to the Free Software Foundation,
19+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+ *
21+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+ * or visit www.oracle.com if you need additional information or have any
23+ * questions.
24+ */
25+
26+package com.sun.tools.example.debug.bdi;
27+
28+class MalformedMemberNameException extends Exception {
29+
30+ private static final long serialVersionUID = -7726664097374844485L;
31+
32+ public MalformedMemberNameException() {
33+ super();
34+ }
35+
36+ public MalformedMemberNameException(String s) {
37+ super(s);
38+ }
39+}
java/pkg/com/sun/tools/example/debug/bdi/MethodBreakpointSpec.java+337−0
@@ -0,0 +1,337 @@
1+/*
2+ * Copyright (c) 1999, 2008, Oracle and/or its affiliates. All rights reserved.
3+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+ *
5+ * This code is free software; you can redistribute it and/or modify it
6+ * under the terms of the GNU General Public License version 2 only, as
7+ * published by the Free Software Foundation. Oracle designates this
8+ * particular file as subject to the "Classpath" exception as provided
9+ * by Oracle in the LICENSE file that accompanied this code.
10+ *
11+ * This code is distributed in the hope that it will be useful, but WITHOUT
12+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+ * version 2 for more details (a copy is included in the LICENSE file that
15+ * accompanied this code).
16+ *
17+ * You should have received a copy of the GNU General Public License version
18+ * 2 along with this work; if not, write to the Free Software Foundation,
19+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+ *
21+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+ * or visit www.oracle.com if you need additional information or have any
23+ * questions.
24+ */
25+
26+package com.sun.tools.example.debug.bdi;
27+
28+import com.sun.jdi.*;
29+import java.util.ArrayList;
30+import java.util.List;
31+
32+public class MethodBreakpointSpec extends BreakpointSpec {
33+ String methodId;
34+ List<String> methodArgs;
35+
36+ MethodBreakpointSpec(EventRequestSpecList specs,
37+ ReferenceTypeSpec refSpec,
38+ String methodId, List<String> methodArgs) {
39+ super(specs, refSpec);
40+ this.methodId = methodId;
41+ this.methodArgs = methodArgs;
42+ }
43+
44+ /**
45+ * The 'refType' is known to match.
46+ */
47+ @Override
48+ void resolve(ReferenceType refType) throws MalformedMemberNameException,
49+ AmbiguousMethodException,
50+ InvalidTypeException,
51+ NoSuchMethodException,
52+ NoSessionException {
53+ if (!isValidMethodName(methodId)) {
54+ throw new MalformedMemberNameException(methodId);
55+ }
56+ if (!(refType instanceof ClassType)) {
57+ throw new InvalidTypeException();
58+ }
59+ Location location = location((ClassType)refType);
60+ setRequest(refType.virtualMachine().eventRequestManager()
61+ .createBreakpointRequest(location));
62+ }
63+
64+ private Location location(ClassType clazz) throws
65+ AmbiguousMethodException,
66+ NoSuchMethodException,
67+ NoSessionException {
68+ Method method = findMatchingMethod(clazz);
69+ Location location = method.location();
70+ return location;
71+ }
72+
73+ public String methodName() {
74+ return methodId;
75+ }
76+
77+ public List<String> methodArgs() {
78+ return methodArgs;
79+ }
80+
81+ @Override
82+ public int hashCode() {
83+ return refSpec.hashCode() +
84+ ((methodId != null) ? methodId.hashCode() : 0) +
85+ ((methodArgs != null) ? methodArgs.hashCode() : 0);
86+ }
87+
88+ @Override
89+ public boolean equals(Object obj) {
90+ if (obj instanceof MethodBreakpointSpec) {
91+ MethodBreakpointSpec breakpoint = (MethodBreakpointSpec)obj;
92+
93+ return methodId.equals(breakpoint.methodId) &&
94+ methodArgs.equals(breakpoint.methodArgs) &&
95+ refSpec.equals(breakpoint.refSpec);
96+ } else {
97+ return false;
98+ }
99+ }
100+
101+ @Override
102+ public String errorMessageFor(Exception e) {
103+ if (e instanceof AmbiguousMethodException) {
104+ return ("Method " + methodName() + " is overloaded; specify arguments");
105+ /*
106+ * TO DO: list the methods here
107+ */
108+ } else if (e instanceof NoSuchMethodException) {
109+ return ("No method " + methodName() + " in " + refSpec);
110+ } else if (e instanceof InvalidTypeException) {
111+ return ("Breakpoints can be located only in classes. " +
112+ refSpec + " is an interface or array");
113+ } else {
114+ return super.errorMessageFor( e);
115+ }
116+ }
117+
118+ @Override
119+ public String toString() {
120+ StringBuffer buffer = new StringBuffer("breakpoint ");
121+ buffer.append(refSpec.toString());
122+ buffer.append('.');
123+ buffer.append(methodId);
124+ if (methodArgs != null) {
125+ boolean first = true;
126+ buffer.append('(');
127+ for (String name : methodArgs) {
128+ if (!first) {
129+ buffer.append(',');
130+ }
131+ buffer.append(name);
132+ first = false;
133+ }
134+ buffer.append(")");
135+ }
136+ buffer.append(" (");
137+ buffer.append(getStatusString());
138+ buffer.append(')');
139+ return buffer.toString();
140+ }
141+
142+ private boolean isValidMethodName(String s) {
143+ return isJavaIdentifier(s) ||
144+ s.equals("<init>") ||
145+ s.equals("<clinit>");
146+ }
147+
148+ /*
149+ * Compare a method's argument types with a Vector of type names.
150+ * Return true if each argument type has a name identical to the
151+ * corresponding string in the vector (allowing for varargs)
152+ * and if the number of arguments in the method matches the
153+ * number of names passed
154+ */
155+ private boolean compareArgTypes(Method method, List<String> nameList) {
156+ List<String> argTypeNames = method.argumentTypeNames();
157+
158+ // If argument counts differ, we can stop here
159+ if (argTypeNames.size() != nameList.size()) {
160+ return false;
161+ }
162+
163+ // Compare each argument type's name
164+ int nTypes = argTypeNames.size();
165+ for (int i = 0; i < nTypes; ++i) {
166+ String comp1 = argTypeNames.get(i);
167+ String comp2 = nameList.get(i);
168+ if (! comp1.equals(comp2)) {
169+ /*
170+ * We have to handle varargs. EG, the
171+ * method's last arg type is xxx[]
172+ * while the nameList contains xxx...
173+ * Note that the nameList can also contain
174+ * xxx[] in which case we don't get here.
175+ */
176+ if (i != nTypes - 1 ||
177+ !method.isVarArgs() ||
178+ !comp2.endsWith("...")) {
179+ return false;
180+ }
181+ /*
182+ * The last types differ, it is a varargs
183+ * method and the nameList item is varargs.
184+ * We just have to compare the type names, eg,
185+ * make sure we don't have xxx[] for the method
186+ * arg type and yyy... for the nameList item.
187+ */
188+ int comp1Length = comp1.length();
189+ if (comp1Length + 1 != comp2.length()) {
190+ // The type names are different lengths
191+ return false;
192+ }
193+ // We know the two type names are the same length
194+ if (!comp1.regionMatches(0, comp2, 0, comp1Length - 2)) {
195+ return false;
196+ }
197+ // We do have xxx[] and xxx... as the last param type
198+ return true;
199+ }
200+ }
201+
202+ return true;
203+ }
204+
205+ private VirtualMachine vm() {
206+ return request.virtualMachine();
207+ }
208+
209+ /**
210+ * Remove unneeded spaces and expand class names to fully
211+ * qualified names, if necessary and possible.
212+ */
213+ private String normalizeArgTypeName(String name) throws NoSessionException {
214+ /*
215+ * Separate the type name from any array modifiers,
216+ * stripping whitespace after the name ends.
217+ */
218+ int i = 0;
219+ StringBuffer typePart = new StringBuffer();
220+ StringBuffer arrayPart = new StringBuffer();
221+ name = name.trim();
222+ int nameLength = name.length();
223+ /*
224+ * For varargs, there can be spaces before the ... but not
225+ * within the ... So, we will just ignore the ...
226+ * while stripping blanks.
227+ */
228+ boolean isVarArgs = name.endsWith("...");
229+ if (isVarArgs) {
230+ nameLength -= 3;
231+ }
232+
233+ while (i < nameLength) {
234+ char c = name.charAt(i);
235+ if (Character.isWhitespace(c) || c == '[') {
236+ break; // name is complete
237+ }
238+ typePart.append(c);
239+ i++;
240+ }
241+ while (i < nameLength) {
242+ char c = name.charAt(i);
243+ if ( (c == '[') || (c == ']')) {
244+ arrayPart.append(c);
245+ } else if (!Character.isWhitespace(c)) {
246+ throw new IllegalArgumentException(
247+ "Invalid argument type name");
248+
249+ }
250+ i++;
251+ }
252+
253+ name = typePart.toString();
254+
255+ /*
256+ * When there's no sign of a package name already,
257+ * try to expand the
258+ * the name to a fully qualified class name
259+ */
260+ if ((name.indexOf('.') == -1) || name.startsWith("*.")) {
261+ try {
262+ List<?> refs = specs.runtime.findClassesMatchingPattern(name);
263+ if (refs.size() > 0) { //### ambiguity???
264+ name = ((ReferenceType)(refs.get(0))).name();
265+ }
266+ } catch (IllegalArgumentException e) {
267+ // We'll try the name as is
268+ }
269+ }
270+ name += arrayPart.toString();
271+ if (isVarArgs) {
272+ name += "...";
273+ }
274+ return name;
275+ }
276+
277+ /*
278+ * Attempt an unambiguous match of the method name and
279+ * argument specification to a method. If no arguments
280+ * are specified, the method must not be overloaded.
281+ * Otherwise, the argument types much match exactly
282+ */
283+ private Method findMatchingMethod(ClassType clazz)
284+ throws AmbiguousMethodException,
285+ NoSuchMethodException,
286+ NoSessionException {
287+
288+ // Normalize the argument string once before looping below.
289+ List<String> argTypeNames = null;
290+ if (methodArgs() != null) {
291+ argTypeNames = new ArrayList<String>(methodArgs().size());
292+ for (String name : methodArgs()) {
293+ name = normalizeArgTypeName(name);
294+ argTypeNames.add(name);
295+ }
296+ }
297+
298+ // Check each method in the class for matches
299+ Method firstMatch = null; // first method with matching name
300+ Method exactMatch = null; // (only) method with same name & sig
301+ int matchCount = 0; // > 1 implies overload
302+ for (Method candidate : clazz.methods()) {
303+ if (candidate.name().equals(methodName())) {
304+ matchCount++;
305+
306+ // Remember the first match in case it is the only one
307+ if (matchCount == 1) {
308+ firstMatch = candidate;
309+ }
310+
311+ // If argument types were specified, check against candidate
312+ if ((argTypeNames != null)
313+ && compareArgTypes(candidate, argTypeNames) == true) {
314+ exactMatch = candidate;
315+ break;
316+ }
317+ }
318+ }
319+
320+ // Determine method for breakpoint
321+ Method method = null;
322+ if (exactMatch != null) {
323+ // Name and signature match
324+ method = exactMatch;
325+ } else if ((argTypeNames == null) && (matchCount > 0)) {
326+ // At least one name matched and no arg types were specified
327+ if (matchCount == 1) {
328+ method = firstMatch; // Only one match; safe to use it
329+ } else {
330+ throw new AmbiguousMethodException();
331+ }
332+ } else {
333+ throw new NoSuchMethodException(methodName());
334+ }
335+ return method;
336+ }
337+}
java/pkg/com/sun/tools/example/debug/bdi/MethodNotFoundException.java+41−0
@@ -0,0 +1,41 @@
1+/*
2+ * Copyright (c) 1998, 1999, Oracle and/or its affiliates. All rights reserved.
3+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+ *
5+ * This code is free software; you can redistribute it and/or modify it
6+ * under the terms of the GNU General Public License version 2 only, as
7+ * published by the Free Software Foundation. Oracle designates this
8+ * particular file as subject to the "Classpath" exception as provided
9+ * by Oracle in the LICENSE file that accompanied this code.
10+ *
11+ * This code is distributed in the hope that it will be useful, but WITHOUT
12+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+ * version 2 for more details (a copy is included in the LICENSE file that
15+ * accompanied this code).
16+ *
17+ * You should have received a copy of the GNU General Public License version
18+ * 2 along with this work; if not, write to the Free Software Foundation,
19+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+ *
21+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+ * or visit www.oracle.com if you need additional information or have any
23+ * questions.
24+ */
25+
26+package com.sun.tools.example.debug.bdi;
27+
28+public class MethodNotFoundException extends Exception
29+{
30+ private static final long serialVersionUID = -2064968107599632609L;
31+
32+ public MethodNotFoundException()
33+ {
34+ super();
35+ }
36+
37+ public MethodNotFoundException(String s)
38+ {
39+ super(s);
40+ }
41+}
java/pkg/com/sun/tools/example/debug/bdi/ModificationWatchpointSpec.java+59−0
@@ -0,0 +1,59 @@
1+/*
2+ * Copyright (c) 1999, Oracle and/or its affiliates. All rights reserved.
3+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+ *
5+ * This code is free software; you can redistribute it and/or modify it
6+ * under the terms of the GNU General Public License version 2 only, as
7+ * published by the Free Software Foundation. Oracle designates this
8+ * particular file as subject to the "Classpath" exception as provided
9+ * by Oracle in the LICENSE file that accompanied this code.
10+ *
11+ * This code is distributed in the hope that it will be useful, but WITHOUT
12+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+ * version 2 for more details (a copy is included in the LICENSE file that
15+ * accompanied this code).
16+ *
17+ * You should have received a copy of the GNU General Public License version
18+ * 2 along with this work; if not, write to the Free Software Foundation,
19+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+ *
21+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+ * or visit www.oracle.com if you need additional information or have any
23+ * questions.
24+ */
25+
26+package com.sun.tools.example.debug.bdi;
27+
28+import com.sun.jdi.*;
29+
30+public class ModificationWatchpointSpec extends WatchpointSpec {
31+
32+ ModificationWatchpointSpec(EventRequestSpecList specs,
33+ ReferenceTypeSpec refSpec, String fieldId) {
34+ super(specs, refSpec, fieldId);
35+ }
36+
37+ /**
38+ * The 'refType' is known to match.
39+ */
40+ @Override
41+ void resolve(ReferenceType refType) throws InvalidTypeException,
42+ NoSuchFieldException {
43+ if (!(refType instanceof ClassType)) {
44+ throw new InvalidTypeException();
45+ }
46+ Field field = refType.fieldByName(fieldId);
47+ if (field == null) {
48+ throw new NoSuchFieldException(fieldId);
49+ }
50+ setRequest(refType.virtualMachine().eventRequestManager()
51+ .createModificationWatchpointRequest(field));
52+ }
53+
54+ @Override
55+ public boolean equals(Object obj) {
56+ return (obj instanceof ModificationWatchpointSpec) &&
57+ super.equals(obj);
58+ }
59+}
java/pkg/com/sun/tools/example/debug/bdi/NoSessionException.java+31−0
@@ -0,0 +1,31 @@
1+/*
2+ * Copyright (c) 1998, 1999, Oracle and/or its affiliates. All rights reserved.
3+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+ *
5+ * This code is free software; you can redistribute it and/or modify it
6+ * under the terms of the GNU General Public License version 2 only, as
7+ * published by the Free Software Foundation. Oracle designates this
8+ * particular file as subject to the "Classpath" exception as provided
9+ * by Oracle in the LICENSE file that accompanied this code.
10+ *
11+ * This code is distributed in the hope that it will be useful, but WITHOUT
12+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+ * version 2 for more details (a copy is included in the LICENSE file that
15+ * accompanied this code).
16+ *
17+ * You should have received a copy of the GNU General Public License version
18+ * 2 along with this work; if not, write to the Free Software Foundation,
19+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+ *
21+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+ * or visit www.oracle.com if you need additional information or have any
23+ * questions.
24+ */
25+
26+package com.sun.tools.example.debug.bdi;
27+
28+public class NoSessionException extends Exception {
29+
30+ private static final long serialVersionUID = -7324357828115128603L;
31+}
java/pkg/com/sun/tools/example/debug/bdi/NoThreadException.java+32−0
@@ -0,0 +1,32 @@
1+/*
2+ * Copyright (c) 1998, 1999, Oracle and/or its affiliates. All rights reserved.
3+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+ *
5+ * This code is free software; you can redistribute it and/or modify it
6+ * under the terms of the GNU General Public License version 2 only, as
7+ * published by the Free Software Foundation. Oracle designates this
8+ * particular file as subject to the "Classpath" exception as provided
9+ * by Oracle in the LICENSE file that accompanied this code.
10+ *
11+ * This code is distributed in the hope that it will be useful, but WITHOUT
12+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+ * version 2 for more details (a copy is included in the LICENSE file that
15+ * accompanied this code).
16+ *
17+ * You should have received a copy of the GNU General Public License version
18+ * 2 along with this work; if not, write to the Free Software Foundation,
19+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+ *
21+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+ * or visit www.oracle.com if you need additional information or have any
23+ * questions.
24+ */
25+
26+package com.sun.tools.example.debug.bdi;
27+
28+public class NoThreadException extends Exception {
29+
30+ private static final long serialVersionUID = 1846613539928921998L;
31+
32+}
java/pkg/com/sun/tools/example/debug/bdi/OutputListener.java+31−0
@@ -0,0 +1,31 @@
1+/*
2+ * Copyright (c) 1998, 1999, Oracle and/or its affiliates. All rights reserved.
3+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+ *
5+ * This code is free software; you can redistribute it and/or modify it
6+ * under the terms of the GNU General Public License version 2 only, as
7+ * published by the Free Software Foundation. Oracle designates this
8+ * particular file as subject to the "Classpath" exception as provided
9+ * by Oracle in the LICENSE file that accompanied this code.
10+ *
11+ * This code is distributed in the hope that it will be useful, but WITHOUT
12+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+ * version 2 for more details (a copy is included in the LICENSE file that
15+ * accompanied this code).
16+ *
17+ * You should have received a copy of the GNU General Public License version
18+ * 2 along with this work; if not, write to the Free Software Foundation,
19+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+ *
21+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+ * or visit www.oracle.com if you need additional information or have any
23+ * questions.
24+ */
25+
26+package com.sun.tools.example.debug.bdi;
27+
28+public interface OutputListener {
29+ void putString(String str);
30+ //void putLine(String line);
31+}
java/pkg/com/sun/tools/example/debug/bdi/ParseException.java+30−0
@@ -0,0 +1,30 @@
1+/*
2+ * Copyright (c) 1998, 1999, Oracle and/or its affiliates. All rights reserved.
3+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+ *
5+ * This code is free software; you can redistribute it and/or modify it
6+ * under the terms of the GNU General Public License version 2 only, as
7+ * published by the Free Software Foundation. Oracle designates this
8+ * particular file as subject to the "Classpath" exception as provided
9+ * by Oracle in the LICENSE file that accompanied this code.
10+ *
11+ * This code is distributed in the hope that it will be useful, but WITHOUT
12+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+ * version 2 for more details (a copy is included in the LICENSE file that
15+ * accompanied this code).
16+ *
17+ * You should have received a copy of the GNU General Public License version
18+ * 2 along with this work; if not, write to the Free Software Foundation,
19+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+ *
21+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+ * or visit www.oracle.com if you need additional information or have any
23+ * questions.
24+ */
25+
26+package com.sun.tools.example.debug.bdi;
27+
28+// dummy placeholder for javaCC-generated code.
29+
30+public class ParseException extends Exception {}
java/pkg/com/sun/tools/example/debug/bdi/PatternReferenceTypeSpec.java+99−0
@@ -0,0 +1,99 @@
1+/*
2+ * Copyright (c) 1999, 2003, Oracle and/or its affiliates. All rights reserved.
3+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+ *
5+ * This code is free software; you can redistribute it and/or modify it
6+ * under the terms of the GNU General Public License version 2 only, as
7+ * published by the Free Software Foundation. Oracle designates this
8+ * particular file as subject to the "Classpath" exception as provided
9+ * by Oracle in the LICENSE file that accompanied this code.
10+ *
11+ * This code is distributed in the hope that it will be useful, but WITHOUT
12+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+ * version 2 for more details (a copy is included in the LICENSE file that
15+ * accompanied this code).
16+ *
17+ * You should have received a copy of the GNU General Public License version
18+ * 2 along with this work; if not, write to the Free Software Foundation,
19+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+ *
21+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+ * or visit www.oracle.com if you need additional information or have any
23+ * questions.
24+ */
25+
26+package com.sun.tools.example.debug.bdi;
27+
28+import com.sun.jdi.*;
29+import java.util.StringTokenizer;
30+
31+class PatternReferenceTypeSpec implements ReferenceTypeSpec {
32+ final boolean isWild;
33+ final String classId;
34+
35+ PatternReferenceTypeSpec(String classId)
36+// throws ClassNotFoundException
37+ {
38+// checkClassName(classId);
39+ isWild = classId.startsWith("*.");
40+ if (isWild) {
41+ this.classId = classId.substring(1);
42+ } else {
43+ this.classId = classId;
44+ }
45+ }
46+
47+ /**
48+ * Does the specified ReferenceType match this spec.
49+ */
50+ @Override
51+ public boolean matches(ReferenceType refType) {
52+ if (isWild) {
53+ return refType.name().endsWith(classId);
54+ } else {
55+ return refType.name().equals(classId);
56+ }
57+ }
58+
59+ @Override
60+ public int hashCode() {
61+ return classId.hashCode();
62+ }
63+
64+ @Override
65+ public boolean equals(Object obj) {
66+ if (obj instanceof PatternReferenceTypeSpec) {
67+ PatternReferenceTypeSpec spec = (PatternReferenceTypeSpec)obj;
68+
69+ return classId.equals(spec.classId) && (isWild == spec.isWild);
70+ } else {
71+ return false;
72+ }
73+ }
74+
75+ private void checkClassName(String className) throws ClassNotFoundException {
76+ // Do stricter checking of class name validity on deferred
77+ // because if the name is invalid, it will
78+ // never match a future loaded class, and we'll be silent
79+ // about it.
80+ StringTokenizer tokenizer = new StringTokenizer(className, ".");
81+ boolean first = true;
82+ while (tokenizer.hasMoreTokens()) {
83+ String token = tokenizer.nextToken();
84+ // Each dot-separated piece must be a valid identifier
85+ // and the first token can also be "*". (Note that
86+ // numeric class ids are not permitted. They must
87+ // match a loaded class.)
88+ if (!Utils.isJavaIdentifier(token) && !(first && token.equals("*"))) {
89+ throw new ClassNotFoundException();
90+ }
91+ first = false;
92+ }
93+ }
94+
95+ @Override
96+ public String toString() {
97+ return isWild? "*" + classId : classId;
98+ }
99+}
java/pkg/com/sun/tools/example/debug/bdi/ReferenceTypeSpec.java+41−0
@@ -0,0 +1,41 @@
1+/*
2+ * Copyright (c) 1999, Oracle and/or its affiliates. All rights reserved.
3+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+ *
5+ * This code is free software; you can redistribute it and/or modify it
6+ * under the terms of the GNU General Public License version 2 only, as
7+ * published by the Free Software Foundation. Oracle designates this
8+ * particular file as subject to the "Classpath" exception as provided
9+ * by Oracle in the LICENSE file that accompanied this code.
10+ *
11+ * This code is distributed in the hope that it will be useful, but WITHOUT
12+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+ * version 2 for more details (a copy is included in the LICENSE file that
15+ * accompanied this code).
16+ *
17+ * You should have received a copy of the GNU General Public License version
18+ * 2 along with this work; if not, write to the Free Software Foundation,
19+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+ *
21+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+ * or visit www.oracle.com if you need additional information or have any
23+ * questions.
24+ */
25+
26+package com.sun.tools.example.debug.bdi;
27+
28+import com.sun.jdi.*;
29+
30+interface ReferenceTypeSpec {
31+ /**
32+ * Does the specified ReferenceType match this spec.
33+ */
34+ boolean matches(ReferenceType refType);
35+
36+ @Override
37+ int hashCode();
38+
39+ @Override
40+ boolean equals(Object obj);
41+}
java/pkg/com/sun/tools/example/debug/bdi/Session.java+96−0
@@ -0,0 +1,96 @@
1+/*
2+ * Copyright (c) 1998, 1999, Oracle and/or its affiliates. All rights reserved.
3+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+ *
5+ * This code is free software; you can redistribute it and/or modify it
6+ * under the terms of the GNU General Public License version 2 only, as
7+ * published by the Free Software Foundation. Oracle designates this
8+ * particular file as subject to the "Classpath" exception as provided
9+ * by Oracle in the LICENSE file that accompanied this code.
10+ *
11+ * This code is distributed in the hope that it will be useful, but WITHOUT
12+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+ * version 2 for more details (a copy is included in the LICENSE file that
15+ * accompanied this code).
16+ *
17+ * You should have received a copy of the GNU General Public License version
18+ * 2 along with this work; if not, write to the Free Software Foundation,
19+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+ *
21+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+ * or visit www.oracle.com if you need additional information or have any
23+ * questions.
24+ */
25+
26+package com.sun.tools.example.debug.bdi;
27+
28+import com.sun.jdi.VirtualMachine;
29+import com.sun.jdi.VMDisconnectedException;
30+
31+/**
32+ * Our repository of what we know about the state of one
33+ * running VM.
34+ */
35+class Session {
36+
37+ final VirtualMachine vm;
38+ final ExecutionManager runtime;
39+ final OutputListener diagnostics;
40+
41+ boolean running = true; // Set false by JDIEventSource
42+ boolean interrupted = false; // Set false by JDIEventSource
43+
44+ private JDIEventSource eventSourceThread = null;
45+ private int traceFlags;
46+ private boolean dead = false;
47+
48+ public Session(VirtualMachine vm, ExecutionManager runtime,
49+ OutputListener diagnostics) {
50+ this.vm = vm;
51+ this.runtime = runtime;
52+ this.diagnostics = diagnostics;
53+ this.traceFlags = VirtualMachine.TRACE_NONE;
54+ }
55+
56+ /**
57+ * Determine if VM is interrupted, i.e, present and not running.
58+ */
59+ public boolean isInterrupted() {
60+ return interrupted;
61+ }
62+
63+ public void setTraceMode(int traceFlags) {
64+ this.traceFlags = traceFlags;
65+ if (!dead) {
66+ vm.setDebugTraceMode(traceFlags);
67+ }
68+ }
69+
70+ public boolean attach() {
71+ vm.setDebugTraceMode(traceFlags);
72+ diagnostics.putString("Connected to VM");
73+ eventSourceThread = new JDIEventSource(this);
74+ eventSourceThread.start();
75+ return true;
76+ }
77+
78+ public void detach() {
79+ if (!dead) {
80+ eventSourceThread.interrupt();
81+ eventSourceThread = null;
82+ //### The VM may already be disconnected
83+ //### if the debuggee did a System.exit().
84+ //### Exception handler here is a kludge,
85+ //### Rather, there are many other places
86+ //### where we need to handle this exception,
87+ //### and initiate a detach due to an error
88+ //### condition, e.g., connection failure.
89+ try {
90+ vm.dispose();
91+ } catch (VMDisconnectedException ee) {}
92+ dead = true;
93+ diagnostics.putString("Disconnected from VM");
94+ }
95+ }
96+}
java/pkg/com/sun/tools/example/debug/bdi/SessionListener.java+37−0
@@ -0,0 +1,37 @@
1+/*
2+ * Copyright (c) 1999, Oracle and/or its affiliates. All rights reserved.
3+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+ *
5+ * This code is free software; you can redistribute it and/or modify it
6+ * under the terms of the GNU General Public License version 2 only, as
7+ * published by the Free Software Foundation. Oracle designates this
8+ * particular file as subject to the "Classpath" exception as provided
9+ * by Oracle in the LICENSE file that accompanied this code.
10+ *
11+ * This code is distributed in the hope that it will be useful, but WITHOUT
12+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+ * version 2 for more details (a copy is included in the LICENSE file that
15+ * accompanied this code).
16+ *
17+ * You should have received a copy of the GNU General Public License version
18+ * 2 along with this work; if not, write to the Free Software Foundation,
19+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+ *
21+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+ * or visit www.oracle.com if you need additional information or have any
23+ * questions.
24+ */
25+
26+package com.sun.tools.example.debug.bdi;
27+
28+import java.util.EventObject;
29+import java.util.EventListener;
30+
31+public interface SessionListener extends EventListener {
32+
33+ void sessionStart(EventObject e);
34+
35+ void sessionInterrupt(EventObject e);
36+ void sessionContinue(EventObject e);
37+}
java/pkg/com/sun/tools/example/debug/bdi/SourceNameReferenceTypeSpec.java+81−0
@@ -0,0 +1,81 @@
1+/*
2+ * Copyright (c) 1999, Oracle and/or its affiliates. All rights reserved.
3+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+ *
5+ * This code is free software; you can redistribute it and/or modify it
6+ * under the terms of the GNU General Public License version 2 only, as
7+ * published by the Free Software Foundation. Oracle designates this
8+ * particular file as subject to the "Classpath" exception as provided
9+ * by Oracle in the LICENSE file that accompanied this code.
10+ *
11+ * This code is distributed in the hope that it will be useful, but WITHOUT
12+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+ * version 2 for more details (a copy is included in the LICENSE file that
15+ * accompanied this code).
16+ *
17+ * You should have received a copy of the GNU General Public License version
18+ * 2 along with this work; if not, write to the Free Software Foundation,
19+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+ *
21+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+ * or visit www.oracle.com if you need additional information or have any
23+ * questions.
24+ */
25+
26+package com.sun.tools.example.debug.bdi;
27+
28+import com.sun.jdi.*;
29+
30+class SourceNameReferenceTypeSpec implements ReferenceTypeSpec {
31+ final String sourceName;
32+ final int linenumber;
33+
34+ SourceNameReferenceTypeSpec(String sourceName, int linenumber) {
35+ this.sourceName = sourceName;
36+ this.linenumber = linenumber;
37+ }
38+
39+ /**
40+ * Does the specified ReferenceType match this spec.
41+ */
42+ @Override
43+ public boolean matches(ReferenceType refType) {
44+ try {
45+ if (refType.sourceName().equals(sourceName)) {
46+ try {
47+ refType.locationsOfLine(linenumber);
48+ // if we don't throw an exception then it was found
49+ return true;
50+ } catch(AbsentInformationException exc) {
51+ } catch(ObjectCollectedException exc) {
52+ }
53+ }
54+ } catch(AbsentInformationException exc) {
55+ // for sourceName(), fall through
56+ }
57+ return false;
58+ }
59+
60+ @Override
61+ public int hashCode() {
62+ return sourceName.hashCode() + linenumber;
63+ }
64+
65+ @Override
66+ public boolean equals(Object obj) {
67+ if (obj instanceof SourceNameReferenceTypeSpec) {
68+ SourceNameReferenceTypeSpec spec = (SourceNameReferenceTypeSpec)obj;
69+
70+ return sourceName.equals(spec.sourceName) &&
71+ (linenumber == spec.linenumber);
72+ } else {
73+ return false;
74+ }
75+ }
76+
77+ @Override
78+ public String toString() {
79+ return sourceName + "@" + linenumber;
80+ }
81+}
java/pkg/com/sun/tools/example/debug/bdi/SpecErrorEvent.java+42−0
@@ -0,0 +1,42 @@
1+/*
2+ * Copyright (c) 1999, Oracle and/or its affiliates. All rights reserved.
3+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+ *
5+ * This code is free software; you can redistribute it and/or modify it
6+ * under the terms of the GNU General Public License version 2 only, as
7+ * published by the Free Software Foundation. Oracle designates this
8+ * particular file as subject to the "Classpath" exception as provided
9+ * by Oracle in the LICENSE file that accompanied this code.
10+ *
11+ * This code is distributed in the hope that it will be useful, but WITHOUT
12+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+ * version 2 for more details (a copy is included in the LICENSE file that
15+ * accompanied this code).
16+ *
17+ * You should have received a copy of the GNU General Public License version
18+ * 2 along with this work; if not, write to the Free Software Foundation,
19+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+ *
21+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+ * or visit www.oracle.com if you need additional information or have any
23+ * questions.
24+ */
25+
26+package com.sun.tools.example.debug.bdi;
27+
28+public class SpecErrorEvent extends SpecEvent {
29+
30+ private static final long serialVersionUID = 8162634387866409578L;
31+ private Exception reason;
32+
33+ public SpecErrorEvent(EventRequestSpec eventRequestSpec,
34+ Exception reason) {
35+ super(eventRequestSpec);
36+ this.reason = reason;
37+ }
38+
39+ public Exception getReason() {
40+ return reason;
41+ }
42+}
java/pkg/com/sun/tools/example/debug/bdi/SpecEvent.java+49−0
@@ -0,0 +1,49 @@
1+/*
2+ * Copyright (c) 1999, Oracle and/or its affiliates. All rights reserved.
3+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+ *
5+ * This code is free software; you can redistribute it and/or modify it
6+ * under the terms of the GNU General Public License version 2 only, as
7+ * published by the Free Software Foundation. Oracle designates this
8+ * particular file as subject to the "Classpath" exception as provided
9+ * by Oracle in the LICENSE file that accompanied this code.
10+ *
11+ * This code is distributed in the hope that it will be useful, but WITHOUT
12+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+ * version 2 for more details (a copy is included in the LICENSE file that
15+ * accompanied this code).
16+ *
17+ * You should have received a copy of the GNU General Public License version
18+ * 2 along with this work; if not, write to the Free Software Foundation,
19+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+ *
21+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+ * or visit www.oracle.com if you need additional information or have any
23+ * questions.
24+ */
25+
26+package com.sun.tools.example.debug.bdi;
27+
28+import java.util.EventObject;
29+
30+import com.sun.jdi.request.EventRequest;
31+
32+public class SpecEvent extends EventObject {
33+
34+ private static final long serialVersionUID = 4820735456787276230L;
35+ private EventRequestSpec eventRequestSpec;
36+
37+ public SpecEvent(EventRequestSpec eventRequestSpec) {
38+ super(eventRequestSpec.specs);
39+ this.eventRequestSpec = eventRequestSpec;
40+ }
41+
42+ public EventRequestSpec getEventRequestSpec() {
43+ return eventRequestSpec;
44+ }
45+
46+ public EventRequest getEventRequest() {
47+ return eventRequestSpec.getEventRequest();
48+ }
49+}
java/pkg/com/sun/tools/example/debug/bdi/SpecListener.java+49−0
@@ -0,0 +1,49 @@
1+/*
2+ * Copyright (c) 1999, Oracle and/or its affiliates. All rights reserved.
3+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+ *
5+ * This code is free software; you can redistribute it and/or modify it
6+ * under the terms of the GNU General Public License version 2 only, as
7+ * published by the Free Software Foundation. Oracle designates this
8+ * particular file as subject to the "Classpath" exception as provided
9+ * by Oracle in the LICENSE file that accompanied this code.
10+ *
11+ * This code is distributed in the hope that it will be useful, but WITHOUT
12+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+ * version 2 for more details (a copy is included in the LICENSE file that
15+ * accompanied this code).
16+ *
17+ * You should have received a copy of the GNU General Public License version
18+ * 2 along with this work; if not, write to the Free Software Foundation,
19+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+ *
21+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+ * or visit www.oracle.com if you need additional information or have any
23+ * questions.
24+ */
25+
26+package com.sun.tools.example.debug.bdi;
27+
28+import java.util.EventListener;
29+
30+public interface SpecListener extends EventListener {
31+
32+ void breakpointSet(SpecEvent e);
33+ void breakpointDeferred(SpecEvent e);
34+ void breakpointDeleted(SpecEvent e);
35+ void breakpointResolved(SpecEvent e);
36+ void breakpointError(SpecErrorEvent e);
37+
38+ void watchpointSet(SpecEvent e);
39+ void watchpointDeferred(SpecEvent e);
40+ void watchpointDeleted(SpecEvent e);
41+ void watchpointResolved(SpecEvent e);
42+ void watchpointError(SpecErrorEvent e);
43+
44+ void exceptionInterceptSet(SpecEvent e);
45+ void exceptionInterceptDeferred(SpecEvent e);
46+ void exceptionInterceptDeleted(SpecEvent e);
47+ void exceptionInterceptResolved(SpecEvent e);
48+ void exceptionInterceptError(SpecErrorEvent e);
49+}
java/pkg/com/sun/tools/example/debug/bdi/ThreadGroupIterator.java+108−0
@@ -0,0 +1,108 @@
1+/*
2+ * Copyright (c) 1998, 2008, Oracle and/or its affiliates. All rights reserved.
3+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+ *
5+ * This code is free software; you can redistribute it and/or modify it
6+ * under the terms of the GNU General Public License version 2 only, as
7+ * published by the Free Software Foundation. Oracle designates this
8+ * particular file as subject to the "Classpath" exception as provided
9+ * by Oracle in the LICENSE file that accompanied this code.
10+ *
11+ * This code is distributed in the hope that it will be useful, but WITHOUT
12+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+ * version 2 for more details (a copy is included in the LICENSE file that
15+ * accompanied this code).
16+ *
17+ * You should have received a copy of the GNU General Public License version
18+ * 2 along with this work; if not, write to the Free Software Foundation,
19+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+ *
21+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+ * or visit www.oracle.com if you need additional information or have any
23+ * questions.
24+ */
25+
26+package com.sun.tools.example.debug.bdi;
27+
28+import com.sun.jdi.ThreadGroupReference;
29+import java.util.List;
30+import java.util.Stack;
31+import java.util.ArrayList;
32+import java.util.Iterator;
33+
34+/**
35+ * Descend the tree of thread groups.
36+ * @author Robert G. Field
37+ */
38+public class ThreadGroupIterator implements Iterator<ThreadGroupReference> {
39+ private final Stack<Iterator<ThreadGroupReference>> stack
40+ = new Stack<Iterator<ThreadGroupReference>>();
41+
42+ public ThreadGroupIterator(List<ThreadGroupReference> tgl) {
43+ push(tgl);
44+ }
45+
46+ public ThreadGroupIterator(ThreadGroupReference tg) {
47+ List<ThreadGroupReference> tgl = new ArrayList<ThreadGroupReference>();
48+ tgl.add(tg);
49+ push(tgl);
50+ }
51+
52+/*
53+ ThreadGroupIterator() {
54+ this(Env.vm().topLevelThreadGroups());
55+ }
56+*/
57+
58+ private Iterator<ThreadGroupReference> top() {
59+ return stack.peek();
60+ }
61+
62+ /**
63+ * The invariant in this class is that the top iterator
64+ * on the stack has more elements. If the stack is
65+ * empty, there is no top. This method assures
66+ * this invariant.
67+ */
68+ private void push(List<ThreadGroupReference> tgl) {
69+ stack.push(tgl.iterator());
70+ while (!stack.isEmpty() && !top().hasNext()) {
71+ stack.pop();
72+ }
73+ }
74+
75+ @Override
76+ public boolean hasNext() {
77+ return !stack.isEmpty();
78+ }
79+
80+ @Override
81+ public ThreadGroupReference next() {
82+ return nextThreadGroup();
83+ }
84+
85+ public ThreadGroupReference nextThreadGroup() {
86+ ThreadGroupReference tg = top().next();
87+ push(tg.threadGroups());
88+ return tg;
89+ }
90+
91+ @Override
92+ public void remove() {
93+ throw new UnsupportedOperationException();
94+ }
95+
96+/*
97+ static ThreadGroupReference find(String name) {
98+ ThreadGroupIterator tgi = new ThreadGroupIterator();
99+ while (tgi.hasNext()) {
100+ ThreadGroupReference tg = tgi.nextThreadGroup();
101+ if (tg.name().equals(name)) {
102+ return tg;
103+ }
104+ }
105+ return null;
106+ }
107+*/
108+}
java/pkg/com/sun/tools/example/debug/bdi/ThreadInfo.java+117−0
@@ -0,0 +1,117 @@
1+/*
2+ * Copyright (c) 1998, 2002, Oracle and/or its affiliates. All rights reserved.
3+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+ *
5+ * This code is free software; you can redistribute it and/or modify it
6+ * under the terms of the GNU General Public License version 2 only, as
7+ * published by the Free Software Foundation. Oracle designates this
8+ * particular file as subject to the "Classpath" exception as provided
9+ * by Oracle in the LICENSE file that accompanied this code.
10+ *
11+ * This code is distributed in the hope that it will be useful, but WITHOUT
12+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+ * version 2 for more details (a copy is included in the LICENSE file that
15+ * accompanied this code).
16+ *
17+ * You should have received a copy of the GNU General Public License version
18+ * 2 along with this work; if not, write to the Free Software Foundation,
19+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+ *
21+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+ * or visit www.oracle.com if you need additional information or have any
23+ * questions.
24+ */
25+
26+package com.sun.tools.example.debug.bdi;
27+
28+import com.sun.jdi.*;
29+
30+//### Should handle target VM death or connection failure cleanly.
31+
32+public class ThreadInfo {
33+
34+ private ThreadReference thread;
35+ private int status;
36+
37+ private int frameCount;
38+
39+ Object userObject; // User-supplied annotation.
40+
41+ private boolean interrupted = false;
42+
43+ private void assureInterrupted() throws VMNotInterruptedException {
44+ if (!interrupted) {
45+ throw new VMNotInterruptedException();
46+ }
47+ }
48+
49+ ThreadInfo (ThreadReference thread) {
50+ this.thread = thread;
51+ this.frameCount = -1;
52+ }
53+
54+ public ThreadReference thread() {
55+ return thread;
56+ }
57+
58+ public int getStatus() throws VMNotInterruptedException {
59+ assureInterrupted();
60+ update();
61+ return status;
62+ }
63+
64+ public int getFrameCount() throws VMNotInterruptedException {
65+ assureInterrupted();
66+ update();
67+ return frameCount;
68+ }
69+
70+ public StackFrame getFrame(int index) throws VMNotInterruptedException {
71+ assureInterrupted();
72+ update();
73+ try {
74+ return thread.frame(index);
75+ } catch (IncompatibleThreadStateException e) {
76+ // Should not happen
77+ interrupted = false;
78+ throw new VMNotInterruptedException();
79+ }
80+ }
81+
82+ public Object getUserObject() {
83+ return userObject;
84+ }
85+
86+ public void setUserObject(Object obj) {
87+ userObject = obj;
88+ }
89+
90+ // Refresh upon first access after cache is cleared.
91+
92+ void update() throws VMNotInterruptedException {
93+ if (frameCount == -1) {
94+ try {
95+ status = thread.status();
96+ frameCount = thread.frameCount();
97+ } catch (IncompatibleThreadStateException e) {
98+ // Should not happen
99+ interrupted = false;
100+ throw new VMNotInterruptedException();
101+ }
102+ }
103+ }
104+
105+ // Called from 'ExecutionManager'.
106+
107+ void validate() {
108+ interrupted = true;
109+ }
110+
111+ void invalidate() {
112+ interrupted = false;
113+ frameCount = -1;
114+ status = ThreadReference.THREAD_STATUS_UNKNOWN;
115+ }
116+
117+}
java/pkg/com/sun/tools/example/debug/bdi/ThreadIterator.java+70−0
@@ -0,0 +1,70 @@
1+/*
2+ * Copyright (c) 1998, 2008, Oracle and/or its affiliates. All rights reserved.
3+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+ *
5+ * This code is free software; you can redistribute it and/or modify it
6+ * under the terms of the GNU General Public License version 2 only, as
7+ * published by the Free Software Foundation. Oracle designates this
8+ * particular file as subject to the "Classpath" exception as provided
9+ * by Oracle in the LICENSE file that accompanied this code.
10+ *
11+ * This code is distributed in the hope that it will be useful, but WITHOUT
12+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+ * version 2 for more details (a copy is included in the LICENSE file that
15+ * accompanied this code).
16+ *
17+ * You should have received a copy of the GNU General Public License version
18+ * 2 along with this work; if not, write to the Free Software Foundation,
19+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+ *
21+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+ * or visit www.oracle.com if you need additional information or have any
23+ * questions.
24+ */
25+
26+package com.sun.tools.example.debug.bdi;
27+
28+import com.sun.jdi.ThreadGroupReference;
29+import com.sun.jdi.ThreadReference;
30+import java.util.List;
31+import java.util.Iterator;
32+
33+public class ThreadIterator implements Iterator<ThreadReference> {
34+ Iterator<ThreadReference> it = null;
35+ ThreadGroupIterator tgi;
36+
37+ public ThreadIterator(ThreadGroupReference tg) {
38+ tgi = new ThreadGroupIterator(tg);
39+ }
40+
41+ //### make this package access only?
42+ public ThreadIterator(List<ThreadGroupReference> tgl) {
43+ tgi = new ThreadGroupIterator(tgl);
44+ }
45+
46+ @Override
47+ public boolean hasNext() {
48+ while (it == null || !it.hasNext()) {
49+ if (!tgi.hasNext()) {
50+ return false; // no more
51+ }
52+ it = tgi.nextThreadGroup().threads().iterator();
53+ }
54+ return true;
55+ }
56+
57+ @Override
58+ public ThreadReference next() {
59+ return it.next();
60+ }
61+
62+ public ThreadReference nextThread() {
63+ return next();
64+ }
65+
66+ @Override
67+ public void remove() {
68+ throw new UnsupportedOperationException();
69+ }
70+}
java/pkg/com/sun/tools/example/debug/bdi/Utils.java+181−0
@@ -0,0 +1,181 @@
1+/*
2+ * Copyright (c) 1998, 2003, Oracle and/or its affiliates. All rights reserved.
3+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+ *
5+ * This code is free software; you can redistribute it and/or modify it
6+ * under the terms of the GNU General Public License version 2 only, as
7+ * published by the Free Software Foundation. Oracle designates this
8+ * particular file as subject to the "Classpath" exception as provided
9+ * by Oracle in the LICENSE file that accompanied this code.
10+ *
11+ * This code is distributed in the hope that it will be useful, but WITHOUT
12+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+ * version 2 for more details (a copy is included in the LICENSE file that
15+ * accompanied this code).
16+ *
17+ * You should have received a copy of the GNU General Public License version
18+ * 2 along with this work; if not, write to the Free Software Foundation,
19+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+ *
21+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+ * or visit www.oracle.com if you need additional information or have any
23+ * questions.
24+ */
25+
26+package com.sun.tools.example.debug.bdi; //### does it belong here?
27+
28+import com.sun.jdi.*;
29+
30+public class Utils {
31+
32+ /**
33+ * Return the thread status description.
34+ */
35+ public static String getStatus(ThreadReference thr) {
36+ int status = thr.status();
37+ String result;
38+ switch (status) {
39+ case ThreadReference.THREAD_STATUS_UNKNOWN:
40+ result = "unknown status";
41+ break;
42+ case ThreadReference.THREAD_STATUS_ZOMBIE:
43+ result = "zombie";
44+ break;
45+ case ThreadReference.THREAD_STATUS_RUNNING:
46+ result = "running";
47+ break;
48+ case ThreadReference.THREAD_STATUS_SLEEPING:
49+ result = "sleeping";
50+ break;
51+ case ThreadReference.THREAD_STATUS_MONITOR:
52+ result = "waiting to acquire a monitor lock";
53+ break;
54+ case ThreadReference.THREAD_STATUS_WAIT:
55+ result = "waiting on a condition";
56+ break;
57+ default:
58+ result = "<invalid thread status>";
59+ }
60+ if (thr.isSuspended()) {
61+ result += " (suspended)";
62+ }
63+ return result;
64+ }
65+
66+ /**
67+ * Return a description of an object.
68+ */
69+ public static String description(ObjectReference ref) {
70+ ReferenceType clazz = ref.referenceType();
71+ long id = ref.uniqueID(); //### TODO use real id
72+ if (clazz == null) {
73+ return toHex(id);
74+ } else {
75+ return "(" + clazz.name() + ")" + toHex(id);
76+ }
77+ }
78+
79+ /**
80+ * Convert a long to a hexadecimal string.
81+ */
82+ public static String toHex(long n) {
83+ char s1[] = new char[16];
84+ char s2[] = new char[18];
85+
86+ // Store digits in reverse order.
87+ int i = 0;
88+ do {
89+ long d = n & 0xf;
90+ s1[i++] = (char)((d < 10) ? ('0' + d) : ('a' + d - 10));
91+ } while ((n >>>= 4) > 0);
92+
93+ // Now reverse the array.
94+ s2[0] = '0';
95+ s2[1] = 'x';
96+ int j = 2;
97+ while (--i >= 0) {
98+ s2[j++] = s1[i];
99+ }
100+ return new String(s2, 0, j);
101+ }
102+
103+ /**
104+ * Convert hexadecimal strings to longs.
105+ */
106+ public static long fromHex(String hexStr) {
107+ String str = hexStr.startsWith("0x") ?
108+ hexStr.substring(2).toLowerCase() : hexStr.toLowerCase();
109+ if (hexStr.length() == 0) {
110+ throw new NumberFormatException();
111+ }
112+
113+ long ret = 0;
114+ for (int i = 0; i < str.length(); i++) {
115+ int c = str.charAt(i);
116+ if (c >= '0' && c <= '9') {
117+ ret = (ret * 16) + (c - '0');
118+ } else if (c >= 'a' && c <= 'f') {
119+ ret = (ret * 16) + (c - 'a' + 10);
120+ } else {
121+ throw new NumberFormatException();
122+ }
123+ }
124+ return ret;
125+ }
126+
127+
128+ /*
129+ * The next two methods are used by this class and by EventHandler
130+ * to print consistent locations and error messages.
131+ */
132+ public static String locationString(Location loc) {
133+ return loc.declaringType().name() +
134+ "." + loc.method().name() + "(), line=" +
135+ loc.lineNumber();
136+ }
137+
138+//### UNUSED.
139+/************************
140+ private String typedName(Method method) {
141+ // TO DO: Use method.signature() instead of method.arguments() so that
142+ // we get sensible results for classes without debugging info
143+ StringBuffer buf = new StringBuffer();
144+ buf.append(method.name());
145+ buf.append("(");
146+ Iterator it = method.arguments().iterator();
147+ while (it.hasNext()) {
148+ buf.append(((LocalVariable)it.next()).typeName());
149+ if (it.hasNext()) {
150+ buf.append(",");
151+ }
152+ }
153+ buf.append(")");
154+ return buf.toString();
155+ }
156+************************/
157+
158+ public static boolean isValidMethodName(String s) {
159+ return isJavaIdentifier(s) ||
160+ s.equals("<init>") ||
161+ s.equals("<clinit>");
162+ }
163+
164+ public static boolean isJavaIdentifier(String s) {
165+ if (s.length() == 0) {
166+ return false;
167+ }
168+ int cp = s.codePointAt(0);
169+ if (! Character.isJavaIdentifierStart(cp)) {
170+ return false;
171+ }
172+ for (int i = Character.charCount(cp); i < s.length(); i += Character.charCount(cp)) {
173+ cp = s.codePointAt(i);
174+ if (! Character.isJavaIdentifierPart(cp)) {
175+ return false;
176+ }
177+ }
178+ return true;
179+ }
180+
181+}
java/pkg/com/sun/tools/example/debug/bdi/VMLaunchFailureException.java+31−0
@@ -0,0 +1,31 @@
1+/*
2+ * Copyright (c) 1998, 1999, Oracle and/or its affiliates. All rights reserved.
3+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+ *
5+ * This code is free software; you can redistribute it and/or modify it
6+ * under the terms of the GNU General Public License version 2 only, as
7+ * published by the Free Software Foundation. Oracle designates this
8+ * particular file as subject to the "Classpath" exception as provided
9+ * by Oracle in the LICENSE file that accompanied this code.
10+ *
11+ * This code is distributed in the hope that it will be useful, but WITHOUT
12+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+ * version 2 for more details (a copy is included in the LICENSE file that
15+ * accompanied this code).
16+ *
17+ * You should have received a copy of the GNU General Public License version
18+ * 2 along with this work; if not, write to the Free Software Foundation,
19+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+ *
21+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+ * or visit www.oracle.com if you need additional information or have any
23+ * questions.
24+ */
25+
26+package com.sun.tools.example.debug.bdi;
27+
28+public class VMLaunchFailureException extends Exception {
29+
30+ private static final long serialVersionUID = -2439646729274310108L;
31+}
java/pkg/com/sun/tools/example/debug/bdi/VMNotInterruptedException.java+31−0
@@ -0,0 +1,31 @@
1+/*
2+ * Copyright (c) 1998, 1999, Oracle and/or its affiliates. All rights reserved.
3+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+ *
5+ * This code is free software; you can redistribute it and/or modify it
6+ * under the terms of the GNU General Public License version 2 only, as
7+ * published by the Free Software Foundation. Oracle designates this
8+ * particular file as subject to the "Classpath" exception as provided
9+ * by Oracle in the LICENSE file that accompanied this code.
10+ *
11+ * This code is distributed in the hope that it will be useful, but WITHOUT
12+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+ * version 2 for more details (a copy is included in the LICENSE file that
15+ * accompanied this code).
16+ *
17+ * You should have received a copy of the GNU General Public License version
18+ * 2 along with this work; if not, write to the Free Software Foundation,
19+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+ *
21+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+ * or visit www.oracle.com if you need additional information or have any
23+ * questions.
24+ */
25+
26+package com.sun.tools.example.debug.bdi;
27+
28+public class VMNotInterruptedException extends Exception {
29+
30+ private static final long serialVersionUID = 8111074582188765600L;
31+}
java/pkg/com/sun/tools/example/debug/bdi/WatchpointSpec.java+92−0
@@ -0,0 +1,92 @@
1+/*
2+ * Copyright (c) 1999, Oracle and/or its affiliates. All rights reserved.
3+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+ *
5+ * This code is free software; you can redistribute it and/or modify it
6+ * under the terms of the GNU General Public License version 2 only, as
7+ * published by the Free Software Foundation. Oracle designates this
8+ * particular file as subject to the "Classpath" exception as provided
9+ * by Oracle in the LICENSE file that accompanied this code.
10+ *
11+ * This code is distributed in the hope that it will be useful, but WITHOUT
12+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+ * version 2 for more details (a copy is included in the LICENSE file that
15+ * accompanied this code).
16+ *
17+ * You should have received a copy of the GNU General Public License version
18+ * 2 along with this work; if not, write to the Free Software Foundation,
19+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+ *
21+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+ * or visit www.oracle.com if you need additional information or have any
23+ * questions.
24+ */
25+
26+package com.sun.tools.example.debug.bdi;
27+
28+public abstract class WatchpointSpec extends EventRequestSpec {
29+ final String fieldId;
30+
31+ WatchpointSpec(EventRequestSpecList specs,
32+ ReferenceTypeSpec refSpec, String fieldId) {
33+ super(specs, refSpec);
34+ this.fieldId = fieldId;
35+// if (!isJavaIdentifier(fieldId)) {
36+// throw new MalformedMemberNameException(fieldId);
37+// }
38+ }
39+
40+ @Override
41+ void notifySet(SpecListener listener, SpecEvent evt) {
42+ listener.watchpointSet(evt);
43+ }
44+
45+ @Override
46+ void notifyDeferred(SpecListener listener, SpecEvent evt) {
47+ listener.watchpointDeferred(evt);
48+ }
49+
50+ @Override
51+ void notifyResolved(SpecListener listener, SpecEvent evt) {
52+ listener.watchpointResolved(evt);
53+ }
54+
55+ @Override
56+ void notifyDeleted(SpecListener listener, SpecEvent evt) {
57+ listener.watchpointDeleted(evt);
58+ }
59+
60+ @Override
61+ void notifyError(SpecListener listener, SpecErrorEvent evt) {
62+ listener.watchpointError(evt);
63+ }
64+
65+ @Override
66+ public int hashCode() {
67+ return refSpec.hashCode() + fieldId.hashCode() +
68+ getClass().hashCode();
69+ }
70+
71+ @Override
72+ public boolean equals(Object obj) {
73+ if (obj instanceof WatchpointSpec) {
74+ WatchpointSpec watchpoint = (WatchpointSpec)obj;
75+
76+ return fieldId.equals(watchpoint.fieldId) &&
77+ refSpec.equals(watchpoint.refSpec) &&
78+ getClass().equals(watchpoint.getClass());
79+ } else {
80+ return false;
81+ }
82+ }
83+
84+ @Override
85+ public String errorMessageFor(Exception e) {
86+ if (e instanceof NoSuchFieldException) {
87+ return ("No field " + fieldId + " in " + refSpec);
88+ } else {
89+ return super.errorMessageFor(e);
90+ }
91+ }
92+}
java/pkg/com/sun/tools/example/debug/bdi/mkfile+44−0
@@ -0,0 +1,44 @@
1+<../../../../../../../../mkconfig
2+
3+TARG=\
4+ AccessWatchpointSpec.dis\
5+ AmbiguousMethodException.dis\
6+ BreakpointSpec.dis\
7+ ChildSession.dis\
8+ EvaluationException.dis\
9+ EventRequestSpec.dis\
10+ EventRequestSpecList.dis\
11+ ExceptionSpec.dis\
12+ ExecutionManager.dis\
13+ FrameIndexOutOfBoundsException.dis\
14+ InputListener.dis\
15+ JDIEventSource.dis\
16+ LineBreakpointSpec.dis\
17+ LineNotFoundException.dis\
18+ MalformedMemberNameException.dis\
19+ MethodBreakpointSpec.dis\
20+ MethodNotFoundException.dis\
21+ ModificationWatchpointSpec.dis\
22+ NoSessionException.dis\
23+ NoThreadException.dis\
24+ OutputListener.dis\
25+ ParseException.dis\
26+ PatternReferenceTypeSpec.dis\
27+ ReferenceTypeSpec.dis\
28+ Session.dis\
29+ SessionListener.dis\
30+ SourceNameReferenceTypeSpec.dis\
31+ SpecErrorEvent.dis\
32+ SpecEvent.dis\
33+ SpecListener.dis\
34+ ThreadGroupIterator.dis\
35+ ThreadInfo.dis\
36+ ThreadIterator.dis\
37+ Utils.dis\
38+ VMLaunchFailureException.dis\
39+ VMNotInterruptedException.dis\
40+ WatchpointSpec.dis\
41+
42+DISBIN=$ROOT/java/dis/java/java/com/sun/tools/example/debug/bdi
43+
44+<$ROOT/mkfiles/mkjava

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t