annotate agent/src/share/classes/sun/jvm/hotspot/CommandProcessor.java @ 12258:69f26e8e09f9

8024760: add more types, fields and constants to VMStructs Reviewed-by: kvn, coleenp
author twisti
date Fri, 13 Sep 2013 16:55:44 -0700
parents 38ea2efa32a7
children de6a9e811145
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 3939
diff changeset
2 * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a61af66fc99e Initial load
duke
parents:
diff changeset
4 *
a61af66fc99e Initial load
duke
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
a61af66fc99e Initial load
duke
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
a61af66fc99e Initial load
duke
parents:
diff changeset
7 * published by the Free Software Foundation.
a61af66fc99e Initial load
duke
parents:
diff changeset
8 *
a61af66fc99e Initial load
duke
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
a61af66fc99e Initial load
duke
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a61af66fc99e Initial load
duke
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a61af66fc99e Initial load
duke
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
a61af66fc99e Initial load
duke
parents:
diff changeset
13 * accompanied this code).
a61af66fc99e Initial load
duke
parents:
diff changeset
14 *
a61af66fc99e Initial load
duke
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
a61af66fc99e Initial load
duke
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
a61af66fc99e Initial load
duke
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a61af66fc99e Initial load
duke
parents:
diff changeset
18 *
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1385
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1385
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1385
diff changeset
21 * questions.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
a61af66fc99e Initial load
duke
parents:
diff changeset
25 package sun.jvm.hotspot;
a61af66fc99e Initial load
duke
parents:
diff changeset
26
8756
686916dc0439 8009457: SA: A small fix on "scanoops" command in CLHSDB
sla
parents: 8750
diff changeset
27 import java.io.BufferedOutputStream;
686916dc0439 8009457: SA: A small fix on "scanoops" command in CLHSDB
sla
parents: 8750
diff changeset
28 import java.io.BufferedReader;
686916dc0439 8009457: SA: A small fix on "scanoops" command in CLHSDB
sla
parents: 8750
diff changeset
29 import java.io.ByteArrayOutputStream;
686916dc0439 8009457: SA: A small fix on "scanoops" command in CLHSDB
sla
parents: 8750
diff changeset
30 import java.io.FileInputStream;
686916dc0439 8009457: SA: A small fix on "scanoops" command in CLHSDB
sla
parents: 8750
diff changeset
31 import java.io.FileOutputStream;
686916dc0439 8009457: SA: A small fix on "scanoops" command in CLHSDB
sla
parents: 8750
diff changeset
32 import java.io.IOException;
686916dc0439 8009457: SA: A small fix on "scanoops" command in CLHSDB
sla
parents: 8750
diff changeset
33 import java.io.InputStreamReader;
686916dc0439 8009457: SA: A small fix on "scanoops" command in CLHSDB
sla
parents: 8750
diff changeset
34 import java.io.PrintStream;
686916dc0439 8009457: SA: A small fix on "scanoops" command in CLHSDB
sla
parents: 8750
diff changeset
35 import java.util.ArrayList;
686916dc0439 8009457: SA: A small fix on "scanoops" command in CLHSDB
sla
parents: 8750
diff changeset
36 import java.util.Arrays;
686916dc0439 8009457: SA: A small fix on "scanoops" command in CLHSDB
sla
parents: 8750
diff changeset
37 import java.util.Comparator;
686916dc0439 8009457: SA: A small fix on "scanoops" command in CLHSDB
sla
parents: 8750
diff changeset
38 import java.util.HashMap;
686916dc0439 8009457: SA: A small fix on "scanoops" command in CLHSDB
sla
parents: 8750
diff changeset
39 import java.util.HashSet;
686916dc0439 8009457: SA: A small fix on "scanoops" command in CLHSDB
sla
parents: 8750
diff changeset
40 import java.util.Iterator;
686916dc0439 8009457: SA: A small fix on "scanoops" command in CLHSDB
sla
parents: 8750
diff changeset
41 import java.util.Stack;
686916dc0439 8009457: SA: A small fix on "scanoops" command in CLHSDB
sla
parents: 8750
diff changeset
42 import java.util.regex.Matcher;
686916dc0439 8009457: SA: A small fix on "scanoops" command in CLHSDB
sla
parents: 8750
diff changeset
43 import java.util.regex.Pattern;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
44
8756
686916dc0439 8009457: SA: A small fix on "scanoops" command in CLHSDB
sla
parents: 8750
diff changeset
45 import sun.jvm.hotspot.ci.ciEnv;
686916dc0439 8009457: SA: A small fix on "scanoops" command in CLHSDB
sla
parents: 8750
diff changeset
46 import sun.jvm.hotspot.code.CodeBlob;
686916dc0439 8009457: SA: A small fix on "scanoops" command in CLHSDB
sla
parents: 8750
diff changeset
47 import sun.jvm.hotspot.code.CodeCacheVisitor;
686916dc0439 8009457: SA: A small fix on "scanoops" command in CLHSDB
sla
parents: 8750
diff changeset
48 import sun.jvm.hotspot.code.NMethod;
686916dc0439 8009457: SA: A small fix on "scanoops" command in CLHSDB
sla
parents: 8750
diff changeset
49 import sun.jvm.hotspot.debugger.Address;
686916dc0439 8009457: SA: A small fix on "scanoops" command in CLHSDB
sla
parents: 8750
diff changeset
50 import sun.jvm.hotspot.debugger.OopHandle;
686916dc0439 8009457: SA: A small fix on "scanoops" command in CLHSDB
sla
parents: 8750
diff changeset
51 import sun.jvm.hotspot.memory.SymbolTable;
686916dc0439 8009457: SA: A small fix on "scanoops" command in CLHSDB
sla
parents: 8750
diff changeset
52 import sun.jvm.hotspot.memory.SystemDictionary;
686916dc0439 8009457: SA: A small fix on "scanoops" command in CLHSDB
sla
parents: 8750
diff changeset
53 import sun.jvm.hotspot.memory.Universe;
686916dc0439 8009457: SA: A small fix on "scanoops" command in CLHSDB
sla
parents: 8750
diff changeset
54 import sun.jvm.hotspot.oops.DefaultHeapVisitor;
686916dc0439 8009457: SA: A small fix on "scanoops" command in CLHSDB
sla
parents: 8750
diff changeset
55 import sun.jvm.hotspot.oops.HeapVisitor;
686916dc0439 8009457: SA: A small fix on "scanoops" command in CLHSDB
sla
parents: 8750
diff changeset
56 import sun.jvm.hotspot.oops.InstanceKlass;
686916dc0439 8009457: SA: A small fix on "scanoops" command in CLHSDB
sla
parents: 8750
diff changeset
57 import sun.jvm.hotspot.oops.Klass;
686916dc0439 8009457: SA: A small fix on "scanoops" command in CLHSDB
sla
parents: 8750
diff changeset
58 import sun.jvm.hotspot.oops.Metadata;
686916dc0439 8009457: SA: A small fix on "scanoops" command in CLHSDB
sla
parents: 8750
diff changeset
59 import sun.jvm.hotspot.oops.Method;
686916dc0439 8009457: SA: A small fix on "scanoops" command in CLHSDB
sla
parents: 8750
diff changeset
60 import sun.jvm.hotspot.oops.MethodData;
686916dc0439 8009457: SA: A small fix on "scanoops" command in CLHSDB
sla
parents: 8750
diff changeset
61 import sun.jvm.hotspot.oops.Oop;
686916dc0439 8009457: SA: A small fix on "scanoops" command in CLHSDB
sla
parents: 8750
diff changeset
62 import sun.jvm.hotspot.oops.RawHeapVisitor;
686916dc0439 8009457: SA: A small fix on "scanoops" command in CLHSDB
sla
parents: 8750
diff changeset
63 import sun.jvm.hotspot.oops.Symbol;
686916dc0439 8009457: SA: A small fix on "scanoops" command in CLHSDB
sla
parents: 8750
diff changeset
64 import sun.jvm.hotspot.oops.UnknownOopException;
686916dc0439 8009457: SA: A small fix on "scanoops" command in CLHSDB
sla
parents: 8750
diff changeset
65 import sun.jvm.hotspot.opto.Compile;
686916dc0439 8009457: SA: A small fix on "scanoops" command in CLHSDB
sla
parents: 8750
diff changeset
66 import sun.jvm.hotspot.opto.InlineTree;
686916dc0439 8009457: SA: A small fix on "scanoops" command in CLHSDB
sla
parents: 8750
diff changeset
67 import sun.jvm.hotspot.runtime.CompiledVFrame;
686916dc0439 8009457: SA: A small fix on "scanoops" command in CLHSDB
sla
parents: 8750
diff changeset
68 import sun.jvm.hotspot.runtime.CompilerThread;
686916dc0439 8009457: SA: A small fix on "scanoops" command in CLHSDB
sla
parents: 8750
diff changeset
69 import sun.jvm.hotspot.runtime.JavaThread;
686916dc0439 8009457: SA: A small fix on "scanoops" command in CLHSDB
sla
parents: 8750
diff changeset
70 import sun.jvm.hotspot.runtime.JavaVFrame;
686916dc0439 8009457: SA: A small fix on "scanoops" command in CLHSDB
sla
parents: 8750
diff changeset
71 import sun.jvm.hotspot.runtime.Threads;
686916dc0439 8009457: SA: A small fix on "scanoops" command in CLHSDB
sla
parents: 8750
diff changeset
72 import sun.jvm.hotspot.runtime.VM;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
73 import sun.jvm.hotspot.tools.ObjectHistogram;
8756
686916dc0439 8009457: SA: A small fix on "scanoops" command in CLHSDB
sla
parents: 8750
diff changeset
74 import sun.jvm.hotspot.tools.PMap;
686916dc0439 8009457: SA: A small fix on "scanoops" command in CLHSDB
sla
parents: 8750
diff changeset
75 import sun.jvm.hotspot.tools.PStack;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
76 import sun.jvm.hotspot.tools.StackTrace;
3939
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
77 import sun.jvm.hotspot.tools.jcore.ClassDump;
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
78 import sun.jvm.hotspot.tools.jcore.ClassFilter;
8756
686916dc0439 8009457: SA: A small fix on "scanoops" command in CLHSDB
sla
parents: 8750
diff changeset
79 import sun.jvm.hotspot.types.CIntegerType;
686916dc0439 8009457: SA: A small fix on "scanoops" command in CLHSDB
sla
parents: 8750
diff changeset
80 import sun.jvm.hotspot.types.Field;
686916dc0439 8009457: SA: A small fix on "scanoops" command in CLHSDB
sla
parents: 8750
diff changeset
81 import sun.jvm.hotspot.types.Type;
686916dc0439 8009457: SA: A small fix on "scanoops" command in CLHSDB
sla
parents: 8750
diff changeset
82 import sun.jvm.hotspot.types.basic.BasicType;
686916dc0439 8009457: SA: A small fix on "scanoops" command in CLHSDB
sla
parents: 8750
diff changeset
83 import sun.jvm.hotspot.ui.classbrowser.HTMLGenerator;
686916dc0439 8009457: SA: A small fix on "scanoops" command in CLHSDB
sla
parents: 8750
diff changeset
84 import sun.jvm.hotspot.ui.tree.CTypeTreeNodeAdapter;
686916dc0439 8009457: SA: A small fix on "scanoops" command in CLHSDB
sla
parents: 8750
diff changeset
85 import sun.jvm.hotspot.ui.tree.OopTreeNodeAdapter;
686916dc0439 8009457: SA: A small fix on "scanoops" command in CLHSDB
sla
parents: 8750
diff changeset
86 import sun.jvm.hotspot.ui.tree.SimpleTreeNode;
686916dc0439 8009457: SA: A small fix on "scanoops" command in CLHSDB
sla
parents: 8750
diff changeset
87 import sun.jvm.hotspot.utilities.AddressOps;
686916dc0439 8009457: SA: A small fix on "scanoops" command in CLHSDB
sla
parents: 8750
diff changeset
88 import sun.jvm.hotspot.utilities.Assert;
686916dc0439 8009457: SA: A small fix on "scanoops" command in CLHSDB
sla
parents: 8750
diff changeset
89 import sun.jvm.hotspot.utilities.HeapProgressThunk;
686916dc0439 8009457: SA: A small fix on "scanoops" command in CLHSDB
sla
parents: 8750
diff changeset
90 import sun.jvm.hotspot.utilities.LivenessPathElement;
686916dc0439 8009457: SA: A small fix on "scanoops" command in CLHSDB
sla
parents: 8750
diff changeset
91 import sun.jvm.hotspot.utilities.MethodArray;
686916dc0439 8009457: SA: A small fix on "scanoops" command in CLHSDB
sla
parents: 8750
diff changeset
92 import sun.jvm.hotspot.utilities.ObjectReader;
686916dc0439 8009457: SA: A small fix on "scanoops" command in CLHSDB
sla
parents: 8750
diff changeset
93 import sun.jvm.hotspot.utilities.PointerFinder;
686916dc0439 8009457: SA: A small fix on "scanoops" command in CLHSDB
sla
parents: 8750
diff changeset
94 import sun.jvm.hotspot.utilities.PointerLocation;
686916dc0439 8009457: SA: A small fix on "scanoops" command in CLHSDB
sla
parents: 8750
diff changeset
95 import sun.jvm.hotspot.utilities.ReversePtrs;
686916dc0439 8009457: SA: A small fix on "scanoops" command in CLHSDB
sla
parents: 8750
diff changeset
96 import sun.jvm.hotspot.utilities.ReversePtrsAnalysis;
686916dc0439 8009457: SA: A small fix on "scanoops" command in CLHSDB
sla
parents: 8750
diff changeset
97 import sun.jvm.hotspot.utilities.RobustOopDeterminator;
686916dc0439 8009457: SA: A small fix on "scanoops" command in CLHSDB
sla
parents: 8750
diff changeset
98 import sun.jvm.hotspot.utilities.SystemDictionaryHelper;
686916dc0439 8009457: SA: A small fix on "scanoops" command in CLHSDB
sla
parents: 8750
diff changeset
99 import sun.jvm.hotspot.utilities.soql.JSJavaFactory;
686916dc0439 8009457: SA: A small fix on "scanoops" command in CLHSDB
sla
parents: 8750
diff changeset
100 import sun.jvm.hotspot.utilities.soql.JSJavaFactoryImpl;
686916dc0439 8009457: SA: A small fix on "scanoops" command in CLHSDB
sla
parents: 8750
diff changeset
101 import sun.jvm.hotspot.utilities.soql.JSJavaScriptEngine;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
102
a61af66fc99e Initial load
duke
parents:
diff changeset
103 public class CommandProcessor {
11054
38ea2efa32a7 8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents: 8756
diff changeset
104
38ea2efa32a7 8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents: 8756
diff changeset
105 volatile boolean quit;
38ea2efa32a7 8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents: 8756
diff changeset
106
0
a61af66fc99e Initial load
duke
parents:
diff changeset
107 public abstract static class DebuggerInterface {
a61af66fc99e Initial load
duke
parents:
diff changeset
108 public abstract HotSpotAgent getAgent();
a61af66fc99e Initial load
duke
parents:
diff changeset
109 public abstract boolean isAttached();
a61af66fc99e Initial load
duke
parents:
diff changeset
110 public abstract void attach(String pid);
a61af66fc99e Initial load
duke
parents:
diff changeset
111 public abstract void attach(String java, String core);
a61af66fc99e Initial load
duke
parents:
diff changeset
112 public abstract void detach();
a61af66fc99e Initial load
duke
parents:
diff changeset
113 public abstract void reattach();
a61af66fc99e Initial load
duke
parents:
diff changeset
114 }
a61af66fc99e Initial load
duke
parents:
diff changeset
115
3939
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
116 public static class BootFilter implements ClassFilter {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
117 public boolean canInclude(InstanceKlass kls) {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
118 return kls.getClassLoader() == null;
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
119 }
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
120 }
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
121
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
122 public static class NonBootFilter implements ClassFilter {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
123 private HashMap emitted = new HashMap();
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
124 public boolean canInclude(InstanceKlass kls) {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
125 if (kls.getClassLoader() == null) return false;
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
126 if (emitted.get(kls.getName()) != null) {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
127 // Since multiple class loaders are being shoved
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
128 // together duplicate classes are a possibilty. For
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
129 // now just ignore them.
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
130 return false;
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
131 }
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
132 emitted.put(kls.getName(), kls);
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
133 return true;
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
134 }
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
135 }
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
136
0
a61af66fc99e Initial load
duke
parents:
diff changeset
137 static class Tokens {
a61af66fc99e Initial load
duke
parents:
diff changeset
138 final String input;
a61af66fc99e Initial load
duke
parents:
diff changeset
139 int i;
a61af66fc99e Initial load
duke
parents:
diff changeset
140 String[] tokens;
a61af66fc99e Initial load
duke
parents:
diff changeset
141 int length;
a61af66fc99e Initial load
duke
parents:
diff changeset
142
a61af66fc99e Initial load
duke
parents:
diff changeset
143 String[] splitWhitespace(String cmd) {
a61af66fc99e Initial load
duke
parents:
diff changeset
144 String[] t = cmd.split("\\s");
a61af66fc99e Initial load
duke
parents:
diff changeset
145 if (t.length == 1 && t[0].length() == 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
146 return new String[0];
a61af66fc99e Initial load
duke
parents:
diff changeset
147 }
a61af66fc99e Initial load
duke
parents:
diff changeset
148 return t;
a61af66fc99e Initial load
duke
parents:
diff changeset
149 }
a61af66fc99e Initial load
duke
parents:
diff changeset
150
a61af66fc99e Initial load
duke
parents:
diff changeset
151 void add(String s, ArrayList t) {
a61af66fc99e Initial load
duke
parents:
diff changeset
152 if (s.length() > 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
153 t.add(s);
a61af66fc99e Initial load
duke
parents:
diff changeset
154 }
a61af66fc99e Initial load
duke
parents:
diff changeset
155 }
a61af66fc99e Initial load
duke
parents:
diff changeset
156
a61af66fc99e Initial load
duke
parents:
diff changeset
157 Tokens(String cmd) {
a61af66fc99e Initial load
duke
parents:
diff changeset
158 input = cmd;
a61af66fc99e Initial load
duke
parents:
diff changeset
159
a61af66fc99e Initial load
duke
parents:
diff changeset
160 // check for quoting
a61af66fc99e Initial load
duke
parents:
diff changeset
161 int quote = cmd.indexOf('"');
a61af66fc99e Initial load
duke
parents:
diff changeset
162 ArrayList t = new ArrayList();
a61af66fc99e Initial load
duke
parents:
diff changeset
163 if (quote != -1) {
a61af66fc99e Initial load
duke
parents:
diff changeset
164 while (cmd.length() > 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
165 if (quote != -1) {
a61af66fc99e Initial load
duke
parents:
diff changeset
166 int endquote = cmd.indexOf('"', quote + 1);
a61af66fc99e Initial load
duke
parents:
diff changeset
167 if (endquote == -1) {
a61af66fc99e Initial load
duke
parents:
diff changeset
168 throw new RuntimeException("mismatched quotes: " + input);
a61af66fc99e Initial load
duke
parents:
diff changeset
169 }
a61af66fc99e Initial load
duke
parents:
diff changeset
170
a61af66fc99e Initial load
duke
parents:
diff changeset
171 String before = cmd.substring(0, quote).trim();
a61af66fc99e Initial load
duke
parents:
diff changeset
172 String quoted = cmd.substring(quote + 1, endquote);
a61af66fc99e Initial load
duke
parents:
diff changeset
173 cmd = cmd.substring(endquote + 1).trim();
a61af66fc99e Initial load
duke
parents:
diff changeset
174 if (before.length() > 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
175 String[] w = splitWhitespace(before);
a61af66fc99e Initial load
duke
parents:
diff changeset
176 for (int i = 0; i < w.length; i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
177 add(w[i], t);
a61af66fc99e Initial load
duke
parents:
diff changeset
178 }
a61af66fc99e Initial load
duke
parents:
diff changeset
179 }
a61af66fc99e Initial load
duke
parents:
diff changeset
180 add(quoted, t);
a61af66fc99e Initial load
duke
parents:
diff changeset
181 quote = cmd.indexOf('"');
a61af66fc99e Initial load
duke
parents:
diff changeset
182 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
183 String[] w = splitWhitespace(cmd);
a61af66fc99e Initial load
duke
parents:
diff changeset
184 for (int i = 0; i < w.length; i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
185 add(w[i], t);
a61af66fc99e Initial load
duke
parents:
diff changeset
186 }
a61af66fc99e Initial load
duke
parents:
diff changeset
187 cmd = "";
a61af66fc99e Initial load
duke
parents:
diff changeset
188
a61af66fc99e Initial load
duke
parents:
diff changeset
189 }
a61af66fc99e Initial load
duke
parents:
diff changeset
190 }
a61af66fc99e Initial load
duke
parents:
diff changeset
191 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
192 String[] w = splitWhitespace(cmd);
a61af66fc99e Initial load
duke
parents:
diff changeset
193 for (int i = 0; i < w.length; i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
194 add(w[i], t);
a61af66fc99e Initial load
duke
parents:
diff changeset
195 }
a61af66fc99e Initial load
duke
parents:
diff changeset
196 }
a61af66fc99e Initial load
duke
parents:
diff changeset
197 tokens = (String[])t.toArray(new String[0]);
a61af66fc99e Initial load
duke
parents:
diff changeset
198 i = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
199 length = tokens.length;
a61af66fc99e Initial load
duke
parents:
diff changeset
200
a61af66fc99e Initial load
duke
parents:
diff changeset
201 //for (int i = 0; i < tokens.length; i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
202 // System.out.println("\"" + tokens[i] + "\"");
a61af66fc99e Initial load
duke
parents:
diff changeset
203 //}
a61af66fc99e Initial load
duke
parents:
diff changeset
204 }
a61af66fc99e Initial load
duke
parents:
diff changeset
205
a61af66fc99e Initial load
duke
parents:
diff changeset
206 String nextToken() {
a61af66fc99e Initial load
duke
parents:
diff changeset
207 return tokens[i++];
a61af66fc99e Initial load
duke
parents:
diff changeset
208 }
a61af66fc99e Initial load
duke
parents:
diff changeset
209 boolean hasMoreTokens() {
a61af66fc99e Initial load
duke
parents:
diff changeset
210 return i < length;
a61af66fc99e Initial load
duke
parents:
diff changeset
211 }
a61af66fc99e Initial load
duke
parents:
diff changeset
212 int countTokens() {
a61af66fc99e Initial load
duke
parents:
diff changeset
213 return length - i;
a61af66fc99e Initial load
duke
parents:
diff changeset
214 }
a61af66fc99e Initial load
duke
parents:
diff changeset
215 void trim(int n) {
a61af66fc99e Initial load
duke
parents:
diff changeset
216 if (length >= n) {
a61af66fc99e Initial load
duke
parents:
diff changeset
217 length -= n;
a61af66fc99e Initial load
duke
parents:
diff changeset
218 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
219 throw new IndexOutOfBoundsException(String.valueOf(n));
a61af66fc99e Initial load
duke
parents:
diff changeset
220 }
a61af66fc99e Initial load
duke
parents:
diff changeset
221 }
a61af66fc99e Initial load
duke
parents:
diff changeset
222 String join(String sep) {
a61af66fc99e Initial load
duke
parents:
diff changeset
223 StringBuffer result = new StringBuffer();
a61af66fc99e Initial load
duke
parents:
diff changeset
224 for (int w = i; w < length; w++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
225 result.append(tokens[w]);
a61af66fc99e Initial load
duke
parents:
diff changeset
226 if (w + 1 < length) {
a61af66fc99e Initial load
duke
parents:
diff changeset
227 result.append(sep);
a61af66fc99e Initial load
duke
parents:
diff changeset
228 }
a61af66fc99e Initial load
duke
parents:
diff changeset
229 }
a61af66fc99e Initial load
duke
parents:
diff changeset
230 return result.toString();
a61af66fc99e Initial load
duke
parents:
diff changeset
231 }
a61af66fc99e Initial load
duke
parents:
diff changeset
232
a61af66fc99e Initial load
duke
parents:
diff changeset
233 String at(int i) {
a61af66fc99e Initial load
duke
parents:
diff changeset
234 if (i < 0 || i >= length) {
a61af66fc99e Initial load
duke
parents:
diff changeset
235 throw new IndexOutOfBoundsException(String.valueOf(i));
a61af66fc99e Initial load
duke
parents:
diff changeset
236 }
a61af66fc99e Initial load
duke
parents:
diff changeset
237 return tokens[i];
a61af66fc99e Initial load
duke
parents:
diff changeset
238 }
a61af66fc99e Initial load
duke
parents:
diff changeset
239 }
a61af66fc99e Initial load
duke
parents:
diff changeset
240
a61af66fc99e Initial load
duke
parents:
diff changeset
241
a61af66fc99e Initial load
duke
parents:
diff changeset
242 abstract class Command {
a61af66fc99e Initial load
duke
parents:
diff changeset
243 Command(String n, String u, boolean ok) {
a61af66fc99e Initial load
duke
parents:
diff changeset
244 name = n;
a61af66fc99e Initial load
duke
parents:
diff changeset
245 usage = u;
a61af66fc99e Initial load
duke
parents:
diff changeset
246 okIfDisconnected = ok;
a61af66fc99e Initial load
duke
parents:
diff changeset
247 }
a61af66fc99e Initial load
duke
parents:
diff changeset
248
a61af66fc99e Initial load
duke
parents:
diff changeset
249 Command(String n, boolean ok) {
a61af66fc99e Initial load
duke
parents:
diff changeset
250 name = n;
a61af66fc99e Initial load
duke
parents:
diff changeset
251 usage = n;
a61af66fc99e Initial load
duke
parents:
diff changeset
252 okIfDisconnected = ok;
a61af66fc99e Initial load
duke
parents:
diff changeset
253 }
a61af66fc99e Initial load
duke
parents:
diff changeset
254
a61af66fc99e Initial load
duke
parents:
diff changeset
255 final String name;
a61af66fc99e Initial load
duke
parents:
diff changeset
256 final String usage;
a61af66fc99e Initial load
duke
parents:
diff changeset
257 final boolean okIfDisconnected;
a61af66fc99e Initial load
duke
parents:
diff changeset
258 abstract void doit(Tokens t);
a61af66fc99e Initial load
duke
parents:
diff changeset
259 void usage() {
a61af66fc99e Initial load
duke
parents:
diff changeset
260 out.println("Usage: " + usage);
a61af66fc99e Initial load
duke
parents:
diff changeset
261 }
a61af66fc99e Initial load
duke
parents:
diff changeset
262
a61af66fc99e Initial load
duke
parents:
diff changeset
263 void printOopValue(Oop oop) {
a61af66fc99e Initial load
duke
parents:
diff changeset
264 if (oop != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
265 Klass k = oop.getKlass();
a61af66fc99e Initial load
duke
parents:
diff changeset
266 Symbol s = k.getName();
a61af66fc99e Initial load
duke
parents:
diff changeset
267 if (s != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
268 out.print("Oop for " + s.asString() + " @ ");
a61af66fc99e Initial load
duke
parents:
diff changeset
269 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
270 out.print("Oop @ ");
a61af66fc99e Initial load
duke
parents:
diff changeset
271 }
a61af66fc99e Initial load
duke
parents:
diff changeset
272 Oop.printOopAddressOn(oop, out);
a61af66fc99e Initial load
duke
parents:
diff changeset
273 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
274 out.print("null");
a61af66fc99e Initial load
duke
parents:
diff changeset
275 }
a61af66fc99e Initial load
duke
parents:
diff changeset
276 }
a61af66fc99e Initial load
duke
parents:
diff changeset
277
a61af66fc99e Initial load
duke
parents:
diff changeset
278 void printNode(SimpleTreeNode node) {
a61af66fc99e Initial load
duke
parents:
diff changeset
279 int count = node.getChildCount();
a61af66fc99e Initial load
duke
parents:
diff changeset
280 for (int i = 0; i < count; i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
281 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
282 SimpleTreeNode field = node.getChild(i);
a61af66fc99e Initial load
duke
parents:
diff changeset
283 if (field instanceof OopTreeNodeAdapter) {
a61af66fc99e Initial load
duke
parents:
diff changeset
284 out.print(field);
a61af66fc99e Initial load
duke
parents:
diff changeset
285 out.print(" ");
a61af66fc99e Initial load
duke
parents:
diff changeset
286 printOopValue(((OopTreeNodeAdapter)field).getOop());
a61af66fc99e Initial load
duke
parents:
diff changeset
287 out.println();
a61af66fc99e Initial load
duke
parents:
diff changeset
288 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
289 out.println(field);
a61af66fc99e Initial load
duke
parents:
diff changeset
290 }
a61af66fc99e Initial load
duke
parents:
diff changeset
291 } catch (Exception e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
292 out.println();
a61af66fc99e Initial load
duke
parents:
diff changeset
293 out.println("Error: " + e);
a61af66fc99e Initial load
duke
parents:
diff changeset
294 if (verboseExceptions) {
a61af66fc99e Initial load
duke
parents:
diff changeset
295 e.printStackTrace(out);
a61af66fc99e Initial load
duke
parents:
diff changeset
296 }
a61af66fc99e Initial load
duke
parents:
diff changeset
297 }
a61af66fc99e Initial load
duke
parents:
diff changeset
298 }
a61af66fc99e Initial load
duke
parents:
diff changeset
299 }
a61af66fc99e Initial load
duke
parents:
diff changeset
300 }
a61af66fc99e Initial load
duke
parents:
diff changeset
301
a61af66fc99e Initial load
duke
parents:
diff changeset
302 void quote(String s) {
a61af66fc99e Initial load
duke
parents:
diff changeset
303 if (s.indexOf(" ") == -1) {
a61af66fc99e Initial load
duke
parents:
diff changeset
304 out.print(s);
a61af66fc99e Initial load
duke
parents:
diff changeset
305 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
306 out.print("\"");
a61af66fc99e Initial load
duke
parents:
diff changeset
307 out.print(s);
a61af66fc99e Initial load
duke
parents:
diff changeset
308 out.print("\"");
a61af66fc99e Initial load
duke
parents:
diff changeset
309 }
a61af66fc99e Initial load
duke
parents:
diff changeset
310 }
a61af66fc99e Initial load
duke
parents:
diff changeset
311
a61af66fc99e Initial load
duke
parents:
diff changeset
312 void dumpType(Type type) {
a61af66fc99e Initial load
duke
parents:
diff changeset
313 out.print("type ");
a61af66fc99e Initial load
duke
parents:
diff changeset
314 quote(type.getName());
a61af66fc99e Initial load
duke
parents:
diff changeset
315 out.print(" ");
a61af66fc99e Initial load
duke
parents:
diff changeset
316 if (type.getSuperclass() != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
317 quote(type.getSuperclass().getName());
a61af66fc99e Initial load
duke
parents:
diff changeset
318 out.print(" ");
a61af66fc99e Initial load
duke
parents:
diff changeset
319 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
320 out.print("null ");
a61af66fc99e Initial load
duke
parents:
diff changeset
321 }
a61af66fc99e Initial load
duke
parents:
diff changeset
322 out.print(type.isOopType());
a61af66fc99e Initial load
duke
parents:
diff changeset
323 out.print(" ");
a61af66fc99e Initial load
duke
parents:
diff changeset
324 if (type.isCIntegerType()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
325 out.print("true ");
a61af66fc99e Initial load
duke
parents:
diff changeset
326 out.print(((CIntegerType)type).isUnsigned());
a61af66fc99e Initial load
duke
parents:
diff changeset
327 out.print(" ");
a61af66fc99e Initial load
duke
parents:
diff changeset
328 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
329 out.print("false false ");
a61af66fc99e Initial load
duke
parents:
diff changeset
330 }
a61af66fc99e Initial load
duke
parents:
diff changeset
331 out.print(type.getSize());
a61af66fc99e Initial load
duke
parents:
diff changeset
332 out.println();
a61af66fc99e Initial load
duke
parents:
diff changeset
333 }
a61af66fc99e Initial load
duke
parents:
diff changeset
334
a61af66fc99e Initial load
duke
parents:
diff changeset
335 void dumpFields(Type type) {
3939
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
336 dumpFields(type, true);
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
337 }
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
338
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
339 void dumpFields(Type type, boolean allowStatic) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
340 Iterator i = type.getFields();
a61af66fc99e Initial load
duke
parents:
diff changeset
341 while (i.hasNext()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
342 Field f = (Field) i.next();
3939
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
343 if (!allowStatic && f.isStatic()) continue;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
344 out.print("field ");
a61af66fc99e Initial load
duke
parents:
diff changeset
345 quote(type.getName());
a61af66fc99e Initial load
duke
parents:
diff changeset
346 out.print(" ");
a61af66fc99e Initial load
duke
parents:
diff changeset
347 out.print(f.getName());
a61af66fc99e Initial load
duke
parents:
diff changeset
348 out.print(" ");
a61af66fc99e Initial load
duke
parents:
diff changeset
349 quote(f.getType().getName());
a61af66fc99e Initial load
duke
parents:
diff changeset
350 out.print(" ");
a61af66fc99e Initial load
duke
parents:
diff changeset
351 out.print(f.isStatic());
a61af66fc99e Initial load
duke
parents:
diff changeset
352 out.print(" ");
a61af66fc99e Initial load
duke
parents:
diff changeset
353 if (f.isStatic()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
354 out.print("0 ");
a61af66fc99e Initial load
duke
parents:
diff changeset
355 out.print(f.getStaticFieldAddress());
a61af66fc99e Initial load
duke
parents:
diff changeset
356 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
357 out.print(f.getOffset());
a61af66fc99e Initial load
duke
parents:
diff changeset
358 out.print(" 0x0");
a61af66fc99e Initial load
duke
parents:
diff changeset
359 }
a61af66fc99e Initial load
duke
parents:
diff changeset
360 out.println();
a61af66fc99e Initial load
duke
parents:
diff changeset
361 }
a61af66fc99e Initial load
duke
parents:
diff changeset
362 }
a61af66fc99e Initial load
duke
parents:
diff changeset
363
a61af66fc99e Initial load
duke
parents:
diff changeset
364
a61af66fc99e Initial load
duke
parents:
diff changeset
365 Address lookup(String symbol) {
a61af66fc99e Initial load
duke
parents:
diff changeset
366 if (symbol.indexOf("::") != -1) {
a61af66fc99e Initial load
duke
parents:
diff changeset
367 String[] parts = symbol.split("::");
a61af66fc99e Initial load
duke
parents:
diff changeset
368 StringBuffer mangled = new StringBuffer("__1c");
a61af66fc99e Initial load
duke
parents:
diff changeset
369 for (int i = 0; i < parts.length; i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
370 int len = parts[i].length();
a61af66fc99e Initial load
duke
parents:
diff changeset
371 if (len >= 26) {
a61af66fc99e Initial load
duke
parents:
diff changeset
372 mangled.append((char)('a' + (len / 26)));
a61af66fc99e Initial load
duke
parents:
diff changeset
373 len = len % 26;
a61af66fc99e Initial load
duke
parents:
diff changeset
374 }
a61af66fc99e Initial load
duke
parents:
diff changeset
375 mangled.append((char)('A' + len));
a61af66fc99e Initial load
duke
parents:
diff changeset
376 mangled.append(parts[i]);
a61af66fc99e Initial load
duke
parents:
diff changeset
377 }
a61af66fc99e Initial load
duke
parents:
diff changeset
378 mangled.append("_");
a61af66fc99e Initial load
duke
parents:
diff changeset
379 symbol = mangled.toString();
a61af66fc99e Initial load
duke
parents:
diff changeset
380 }
a61af66fc99e Initial load
duke
parents:
diff changeset
381 return VM.getVM().getDebugger().lookup(null, symbol);
a61af66fc99e Initial load
duke
parents:
diff changeset
382 }
a61af66fc99e Initial load
duke
parents:
diff changeset
383
a61af66fc99e Initial load
duke
parents:
diff changeset
384 Address parseAddress(String addr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
385 return VM.getVM().getDebugger().parseAddress(addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
386 }
a61af66fc99e Initial load
duke
parents:
diff changeset
387
a61af66fc99e Initial load
duke
parents:
diff changeset
388 private final Command[] commandList = {
a61af66fc99e Initial load
duke
parents:
diff changeset
389 new Command("reattach", true) {
a61af66fc99e Initial load
duke
parents:
diff changeset
390 public void doit(Tokens t) {
a61af66fc99e Initial load
duke
parents:
diff changeset
391 int tokens = t.countTokens();
a61af66fc99e Initial load
duke
parents:
diff changeset
392 if (tokens != 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
393 usage();
a61af66fc99e Initial load
duke
parents:
diff changeset
394 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
395 }
a61af66fc99e Initial load
duke
parents:
diff changeset
396 preAttach();
a61af66fc99e Initial load
duke
parents:
diff changeset
397 debugger.reattach();
a61af66fc99e Initial load
duke
parents:
diff changeset
398 postAttach();
a61af66fc99e Initial load
duke
parents:
diff changeset
399 }
a61af66fc99e Initial load
duke
parents:
diff changeset
400 },
a61af66fc99e Initial load
duke
parents:
diff changeset
401 new Command("attach", "attach pid | exec core", true) {
a61af66fc99e Initial load
duke
parents:
diff changeset
402 public void doit(Tokens t) {
a61af66fc99e Initial load
duke
parents:
diff changeset
403 int tokens = t.countTokens();
a61af66fc99e Initial load
duke
parents:
diff changeset
404 if (tokens == 1) {
a61af66fc99e Initial load
duke
parents:
diff changeset
405 preAttach();
a61af66fc99e Initial load
duke
parents:
diff changeset
406 debugger.attach(t.nextToken());
a61af66fc99e Initial load
duke
parents:
diff changeset
407 postAttach();
a61af66fc99e Initial load
duke
parents:
diff changeset
408 } else if (tokens == 2) {
a61af66fc99e Initial load
duke
parents:
diff changeset
409 preAttach();
a61af66fc99e Initial load
duke
parents:
diff changeset
410 debugger.attach(t.nextToken(), t.nextToken());
a61af66fc99e Initial load
duke
parents:
diff changeset
411 postAttach();
a61af66fc99e Initial load
duke
parents:
diff changeset
412 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
413 usage();
a61af66fc99e Initial load
duke
parents:
diff changeset
414 }
a61af66fc99e Initial load
duke
parents:
diff changeset
415 }
a61af66fc99e Initial load
duke
parents:
diff changeset
416 },
a61af66fc99e Initial load
duke
parents:
diff changeset
417 new Command("detach", false) {
a61af66fc99e Initial load
duke
parents:
diff changeset
418 public void doit(Tokens t) {
a61af66fc99e Initial load
duke
parents:
diff changeset
419 if (t.countTokens() != 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
420 usage();
a61af66fc99e Initial load
duke
parents:
diff changeset
421 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
422 debugger.detach();
a61af66fc99e Initial load
duke
parents:
diff changeset
423 }
a61af66fc99e Initial load
duke
parents:
diff changeset
424 }
a61af66fc99e Initial load
duke
parents:
diff changeset
425 },
a61af66fc99e Initial load
duke
parents:
diff changeset
426 new Command("examine", "examine [ address/count ] | [ address,address]", false) {
a61af66fc99e Initial load
duke
parents:
diff changeset
427 Pattern args1 = Pattern.compile("^(0x[0-9a-f]+)(/([0-9]*)([a-z]*))?$");
a61af66fc99e Initial load
duke
parents:
diff changeset
428 Pattern args2 = Pattern.compile("^(0x[0-9a-f]+),(0x[0-9a-f]+)(/[a-z]*)?$");
a61af66fc99e Initial load
duke
parents:
diff changeset
429
a61af66fc99e Initial load
duke
parents:
diff changeset
430 String fill(Address a, int width) {
a61af66fc99e Initial load
duke
parents:
diff changeset
431 String s = "0x0";
a61af66fc99e Initial load
duke
parents:
diff changeset
432 if (a != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
433 s = a.toString();
a61af66fc99e Initial load
duke
parents:
diff changeset
434 }
a61af66fc99e Initial load
duke
parents:
diff changeset
435 if (s.length() != width) {
a61af66fc99e Initial load
duke
parents:
diff changeset
436 return s.substring(0, 2) + "000000000000000000000".substring(0, width - s.length()) + s.substring(2);
a61af66fc99e Initial load
duke
parents:
diff changeset
437 }
a61af66fc99e Initial load
duke
parents:
diff changeset
438 return s;
a61af66fc99e Initial load
duke
parents:
diff changeset
439 }
a61af66fc99e Initial load
duke
parents:
diff changeset
440
a61af66fc99e Initial load
duke
parents:
diff changeset
441 public void doit(Tokens t) {
a61af66fc99e Initial load
duke
parents:
diff changeset
442 if (t.countTokens() != 1) {
a61af66fc99e Initial load
duke
parents:
diff changeset
443 usage();
a61af66fc99e Initial load
duke
parents:
diff changeset
444 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
445 String arg = t.nextToken();
a61af66fc99e Initial load
duke
parents:
diff changeset
446 Matcher m1 = args1.matcher(arg);
a61af66fc99e Initial load
duke
parents:
diff changeset
447 Matcher m2 = args2.matcher(arg);
a61af66fc99e Initial load
duke
parents:
diff changeset
448 Address start = null;
a61af66fc99e Initial load
duke
parents:
diff changeset
449 Address end = null;
a61af66fc99e Initial load
duke
parents:
diff changeset
450 String format = "";
a61af66fc99e Initial load
duke
parents:
diff changeset
451 int formatSize = (int)VM.getVM().getAddressSize();
a61af66fc99e Initial load
duke
parents:
diff changeset
452
a61af66fc99e Initial load
duke
parents:
diff changeset
453 if (m1.matches()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
454 start = VM.getVM().getDebugger().parseAddress(m1.group(1));
a61af66fc99e Initial load
duke
parents:
diff changeset
455 int count = 1;
a61af66fc99e Initial load
duke
parents:
diff changeset
456 if (m1.group(2) != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
457 count = Integer.parseInt(m1.group(3));
a61af66fc99e Initial load
duke
parents:
diff changeset
458 }
a61af66fc99e Initial load
duke
parents:
diff changeset
459 end = start.addOffsetTo(count * formatSize);
a61af66fc99e Initial load
duke
parents:
diff changeset
460 } else if (m2.matches()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
461 start = VM.getVM().getDebugger().parseAddress(m2.group(1));
a61af66fc99e Initial load
duke
parents:
diff changeset
462 end = VM.getVM().getDebugger().parseAddress(m2.group(2));
a61af66fc99e Initial load
duke
parents:
diff changeset
463 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
464 usage();
a61af66fc99e Initial load
duke
parents:
diff changeset
465 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
466 }
a61af66fc99e Initial load
duke
parents:
diff changeset
467 int line = 80;
a61af66fc99e Initial load
duke
parents:
diff changeset
468 int formatWidth = formatSize * 8 / 4 + 2;
a61af66fc99e Initial load
duke
parents:
diff changeset
469
a61af66fc99e Initial load
duke
parents:
diff changeset
470 out.print(fill(start, formatWidth));
a61af66fc99e Initial load
duke
parents:
diff changeset
471 out.print(": ");
a61af66fc99e Initial load
duke
parents:
diff changeset
472 int width = line - formatWidth - 2;
a61af66fc99e Initial load
duke
parents:
diff changeset
473
a61af66fc99e Initial load
duke
parents:
diff changeset
474 boolean needsPrintln = true;
a61af66fc99e Initial load
duke
parents:
diff changeset
475 while (start != null && start.lessThan(end)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
476 Address val = start.getAddressAt(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
477 out.print(fill(val, formatWidth));
a61af66fc99e Initial load
duke
parents:
diff changeset
478 needsPrintln = true;
a61af66fc99e Initial load
duke
parents:
diff changeset
479 width -= formatWidth;
a61af66fc99e Initial load
duke
parents:
diff changeset
480 start = start.addOffsetTo(formatSize);
a61af66fc99e Initial load
duke
parents:
diff changeset
481 if (width <= formatWidth) {
a61af66fc99e Initial load
duke
parents:
diff changeset
482 out.println();
a61af66fc99e Initial load
duke
parents:
diff changeset
483 needsPrintln = false;
a61af66fc99e Initial load
duke
parents:
diff changeset
484 if (start.lessThan(end)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
485 out.print(fill(start, formatWidth));
a61af66fc99e Initial load
duke
parents:
diff changeset
486 out.print(": ");
a61af66fc99e Initial load
duke
parents:
diff changeset
487 width = line - formatWidth - 2;
a61af66fc99e Initial load
duke
parents:
diff changeset
488 }
a61af66fc99e Initial load
duke
parents:
diff changeset
489 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
490 out.print(" ");
a61af66fc99e Initial load
duke
parents:
diff changeset
491 width -= 1;
a61af66fc99e Initial load
duke
parents:
diff changeset
492 }
a61af66fc99e Initial load
duke
parents:
diff changeset
493 }
a61af66fc99e Initial load
duke
parents:
diff changeset
494 if (needsPrintln) {
a61af66fc99e Initial load
duke
parents:
diff changeset
495 out.println();
a61af66fc99e Initial load
duke
parents:
diff changeset
496 }
a61af66fc99e Initial load
duke
parents:
diff changeset
497 }
a61af66fc99e Initial load
duke
parents:
diff changeset
498 }
a61af66fc99e Initial load
duke
parents:
diff changeset
499 },
6972
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6782
diff changeset
500 new Command("dumpreplaydata", "dumpreplaydata { <address > | -a | <thread_id> }", false) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6782
diff changeset
501 // This is used to dump replay data from ciInstanceKlass, ciMethodData etc
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6782
diff changeset
502 // default file name is replay.txt, also if java crashes in compiler
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6782
diff changeset
503 // thread, this file will be dumped in error processing.
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6782
diff changeset
504 public void doit(Tokens t) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6782
diff changeset
505 if (t.countTokens() != 1) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6782
diff changeset
506 usage();
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6782
diff changeset
507 return;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6782
diff changeset
508 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6782
diff changeset
509 String name = t.nextToken();
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6782
diff changeset
510 Address a = null;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6782
diff changeset
511 try {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6782
diff changeset
512 a = VM.getVM().getDebugger().parseAddress(name);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6782
diff changeset
513 } catch (NumberFormatException e) { }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6782
diff changeset
514 if (a != null) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6782
diff changeset
515 // only nmethod, Method, MethodData and InstanceKlass needed to
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6782
diff changeset
516 // dump replay data
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6782
diff changeset
517
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6782
diff changeset
518 CodeBlob cb = VM.getVM().getCodeCache().findBlob(a);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6782
diff changeset
519 if (cb != null && (cb instanceof NMethod)) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6782
diff changeset
520 ((NMethod)cb).dumpReplayData(out);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6782
diff changeset
521 return;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6782
diff changeset
522 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6782
diff changeset
523 // assume it is Metadata
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6782
diff changeset
524 Metadata meta = Metadata.instantiateWrapperFor(a);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6782
diff changeset
525 if (meta != null) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6782
diff changeset
526 meta.dumpReplayData(out);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6782
diff changeset
527 } else {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6782
diff changeset
528 usage();
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6782
diff changeset
529 return;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6782
diff changeset
530 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6782
diff changeset
531 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6782
diff changeset
532 // Not an address
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6782
diff changeset
533 boolean all = name.equals("-a");
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6782
diff changeset
534 Threads threads = VM.getVM().getThreads();
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6782
diff changeset
535 for (JavaThread thread = threads.first(); thread != null; thread = thread.next()) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6782
diff changeset
536 ByteArrayOutputStream bos = new ByteArrayOutputStream();
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6782
diff changeset
537 thread.printThreadIDOn(new PrintStream(bos));
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6782
diff changeset
538 if (all || bos.toString().equals(name)) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6782
diff changeset
539 if (thread instanceof CompilerThread) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6782
diff changeset
540 CompilerThread ct = (CompilerThread)thread;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6782
diff changeset
541 ciEnv env = ct.env();
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6782
diff changeset
542 if (env != null) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6782
diff changeset
543 env.dumpReplayData(out);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6782
diff changeset
544 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6782
diff changeset
545 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6782
diff changeset
546 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6782
diff changeset
547 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6782
diff changeset
548 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6782
diff changeset
549 },
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6782
diff changeset
550 new Command("buildreplayjars", "buildreplayjars [ all | app | boot ] | [ prefix ]", false) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6782
diff changeset
551 // This is used to dump jar files of all the classes
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6782
diff changeset
552 // loaded in the core. Everything on the bootclasspath
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6782
diff changeset
553 // will go in boot.jar and everything else will go in
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6782
diff changeset
554 // app.jar. Then the classes can be loaded by the replay
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6782
diff changeset
555 // jvm using -Xbootclasspath/p:boot.jar -cp app.jar. boot.jar usually
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6782
diff changeset
556 // not needed, unless changed by jvmti.
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6782
diff changeset
557 public void doit(Tokens t) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6782
diff changeset
558 int tcount = t.countTokens();
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6782
diff changeset
559 if (tcount > 2) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6782
diff changeset
560 usage();
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6782
diff changeset
561 return;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6782
diff changeset
562 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6782
diff changeset
563 try {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6782
diff changeset
564 String prefix = "";
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6782
diff changeset
565 String option = "all"; // default
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6782
diff changeset
566 switch(tcount) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6782
diff changeset
567 case 0:
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6782
diff changeset
568 break;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6782
diff changeset
569 case 1:
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6782
diff changeset
570 option = t.nextToken();
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6782
diff changeset
571 if (!option.equalsIgnoreCase("all") && !option.equalsIgnoreCase("app") &&
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6782
diff changeset
572 !option.equalsIgnoreCase("root")) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6782
diff changeset
573 prefix = option;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6782
diff changeset
574 option = "all";
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6782
diff changeset
575 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6782
diff changeset
576 break;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6782
diff changeset
577 case 2:
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6782
diff changeset
578 option = t.nextToken();
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6782
diff changeset
579 prefix = t.nextToken();
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6782
diff changeset
580 break;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6782
diff changeset
581 default:
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6782
diff changeset
582 usage();
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6782
diff changeset
583 return;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6782
diff changeset
584 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6782
diff changeset
585 if (!option.equalsIgnoreCase("all") && !option.equalsIgnoreCase("app") &&
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6782
diff changeset
586 !option.equalsIgnoreCase("boot")) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6782
diff changeset
587 usage();
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6782
diff changeset
588 return;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6782
diff changeset
589 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6782
diff changeset
590 ClassDump cd = new ClassDump();
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6782
diff changeset
591 if (option.equalsIgnoreCase("all") || option.equalsIgnoreCase("boot")) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6782
diff changeset
592 cd.setClassFilter(new BootFilter());
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6782
diff changeset
593 cd.setJarOutput(prefix + "boot.jar");
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6782
diff changeset
594 cd.run();
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6782
diff changeset
595 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6782
diff changeset
596 if (option.equalsIgnoreCase("all") || option.equalsIgnoreCase("app")) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6782
diff changeset
597 cd.setClassFilter(new NonBootFilter());
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6782
diff changeset
598 cd.setJarOutput(prefix + "app.jar");
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6782
diff changeset
599 cd.run();
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6782
diff changeset
600 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6782
diff changeset
601 } catch (IOException ioe) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6782
diff changeset
602 ioe.printStackTrace();
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6782
diff changeset
603 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6782
diff changeset
604 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6782
diff changeset
605 },
0
a61af66fc99e Initial load
duke
parents:
diff changeset
606 new Command("findpc", "findpc address", false) {
a61af66fc99e Initial load
duke
parents:
diff changeset
607 public void doit(Tokens t) {
a61af66fc99e Initial load
duke
parents:
diff changeset
608 if (t.countTokens() != 1) {
a61af66fc99e Initial load
duke
parents:
diff changeset
609 usage();
a61af66fc99e Initial load
duke
parents:
diff changeset
610 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
611 Address a = VM.getVM().getDebugger().parseAddress(t.nextToken());
a61af66fc99e Initial load
duke
parents:
diff changeset
612 PointerLocation loc = PointerFinder.find(a);
a61af66fc99e Initial load
duke
parents:
diff changeset
613 loc.printOn(out);
a61af66fc99e Initial load
duke
parents:
diff changeset
614 }
a61af66fc99e Initial load
duke
parents:
diff changeset
615 }
a61af66fc99e Initial load
duke
parents:
diff changeset
616 },
2177
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1748
diff changeset
617 new Command("symbol", "symbol address", false) {
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1748
diff changeset
618 public void doit(Tokens t) {
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1748
diff changeset
619 if (t.countTokens() != 1) {
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1748
diff changeset
620 usage();
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1748
diff changeset
621 } else {
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1748
diff changeset
622 Address a = VM.getVM().getDebugger().parseAddress(t.nextToken());
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1748
diff changeset
623 Symbol.create(a).printValueOn(out);
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1748
diff changeset
624 out.println();
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1748
diff changeset
625 }
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1748
diff changeset
626 }
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1748
diff changeset
627 },
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1748
diff changeset
628 new Command("symboltable", "symboltable name", false) {
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1748
diff changeset
629 public void doit(Tokens t) {
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1748
diff changeset
630 if (t.countTokens() != 1) {
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1748
diff changeset
631 usage();
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1748
diff changeset
632 } else {
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1748
diff changeset
633 out.println(SymbolTable.getTheTable().probe(t.nextToken()));
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1748
diff changeset
634 }
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1748
diff changeset
635 }
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1748
diff changeset
636 },
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1748
diff changeset
637 new Command("symboldump", "symboldump", false) {
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1748
diff changeset
638 public void doit(Tokens t) {
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1748
diff changeset
639 SymbolTable.getTheTable().symbolsDo(new SymbolTable.SymbolVisitor() {
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1748
diff changeset
640 public void visit(Symbol sym) {
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1748
diff changeset
641 sym.printValueOn(out);
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1748
diff changeset
642 out.println();
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1748
diff changeset
643 }
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1748
diff changeset
644 });
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1748
diff changeset
645 }
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1748
diff changeset
646 },
3939
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
647 new Command("flags", "flags [ flag | -nd ]", false) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
648 public void doit(Tokens t) {
a61af66fc99e Initial load
duke
parents:
diff changeset
649 int tokens = t.countTokens();
a61af66fc99e Initial load
duke
parents:
diff changeset
650 if (tokens != 0 && tokens != 1) {
a61af66fc99e Initial load
duke
parents:
diff changeset
651 usage();
a61af66fc99e Initial load
duke
parents:
diff changeset
652 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
653 String name = tokens > 0 ? t.nextToken() : null;
3939
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
654 boolean nonDefault = false;
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
655 if (name != null && name.equals("-nd")) {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
656 name = null;
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
657 nonDefault = true;
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
658 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
659
a61af66fc99e Initial load
duke
parents:
diff changeset
660 VM.Flag[] flags = VM.getVM().getCommandLineFlags();
a61af66fc99e Initial load
duke
parents:
diff changeset
661 if (flags == null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
662 out.println("Command Flag info not available (use 1.4.1_03 or later)!");
a61af66fc99e Initial load
duke
parents:
diff changeset
663 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
664 boolean printed = false;
a61af66fc99e Initial load
duke
parents:
diff changeset
665 for (int f = 0; f < flags.length; f++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
666 VM.Flag flag = flags[f];
a61af66fc99e Initial load
duke
parents:
diff changeset
667 if (name == null || flag.getName().equals(name)) {
3939
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
668
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
669 if (nonDefault && flag.getOrigin() == 0) {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
670 // only print flags which aren't their defaults
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
671 continue;
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
672 }
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
673 out.println(flag.getName() + " = " + flag.getValue() + " " + flag.getOrigin());
0
a61af66fc99e Initial load
duke
parents:
diff changeset
674 printed = true;
a61af66fc99e Initial load
duke
parents:
diff changeset
675 }
a61af66fc99e Initial load
duke
parents:
diff changeset
676 }
a61af66fc99e Initial load
duke
parents:
diff changeset
677 if (name != null && !printed) {
a61af66fc99e Initial load
duke
parents:
diff changeset
678 out.println("Couldn't find flag: " + name);
a61af66fc99e Initial load
duke
parents:
diff changeset
679 }
a61af66fc99e Initial load
duke
parents:
diff changeset
680 }
a61af66fc99e Initial load
duke
parents:
diff changeset
681 }
a61af66fc99e Initial load
duke
parents:
diff changeset
682 }
a61af66fc99e Initial load
duke
parents:
diff changeset
683 },
a61af66fc99e Initial load
duke
parents:
diff changeset
684 new Command("help", "help [ command ]", true) {
a61af66fc99e Initial load
duke
parents:
diff changeset
685 public void doit(Tokens t) {
a61af66fc99e Initial load
duke
parents:
diff changeset
686 int tokens = t.countTokens();
a61af66fc99e Initial load
duke
parents:
diff changeset
687 Command cmd = null;
a61af66fc99e Initial load
duke
parents:
diff changeset
688 if (tokens == 1) {
a61af66fc99e Initial load
duke
parents:
diff changeset
689 cmd = findCommand(t.nextToken());
a61af66fc99e Initial load
duke
parents:
diff changeset
690 }
a61af66fc99e Initial load
duke
parents:
diff changeset
691
a61af66fc99e Initial load
duke
parents:
diff changeset
692 if (cmd != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
693 cmd.usage();
a61af66fc99e Initial load
duke
parents:
diff changeset
694 } else if (tokens == 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
695 out.println("Available commands:");
a61af66fc99e Initial load
duke
parents:
diff changeset
696 Object[] keys = commands.keySet().toArray();
a61af66fc99e Initial load
duke
parents:
diff changeset
697 Arrays.sort(keys, new Comparator() {
a61af66fc99e Initial load
duke
parents:
diff changeset
698 public int compare(Object o1, Object o2) {
a61af66fc99e Initial load
duke
parents:
diff changeset
699 return o1.toString().compareTo(o2.toString());
a61af66fc99e Initial load
duke
parents:
diff changeset
700 }
a61af66fc99e Initial load
duke
parents:
diff changeset
701 });
a61af66fc99e Initial load
duke
parents:
diff changeset
702 for (int i = 0; i < keys.length; i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
703 out.print(" ");
a61af66fc99e Initial load
duke
parents:
diff changeset
704 out.println(((Command)commands.get(keys[i])).usage);
a61af66fc99e Initial load
duke
parents:
diff changeset
705 }
a61af66fc99e Initial load
duke
parents:
diff changeset
706 }
a61af66fc99e Initial load
duke
parents:
diff changeset
707 }
a61af66fc99e Initial load
duke
parents:
diff changeset
708 },
a61af66fc99e Initial load
duke
parents:
diff changeset
709 new Command("history", "history", true) {
a61af66fc99e Initial load
duke
parents:
diff changeset
710 public void doit(Tokens t) {
a61af66fc99e Initial load
duke
parents:
diff changeset
711 int tokens = t.countTokens();
a61af66fc99e Initial load
duke
parents:
diff changeset
712 if (tokens != 0 && (tokens != 1 || !t.nextToken().equals("-h"))) {
a61af66fc99e Initial load
duke
parents:
diff changeset
713 usage();
a61af66fc99e Initial load
duke
parents:
diff changeset
714 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
715 }
a61af66fc99e Initial load
duke
parents:
diff changeset
716 boolean printIndex = tokens == 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
717 for (int i = 0; i < history.size(); i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
718 if (printIndex) out.print(i + " ");
a61af66fc99e Initial load
duke
parents:
diff changeset
719 out.println(history.get(i));
a61af66fc99e Initial load
duke
parents:
diff changeset
720 }
a61af66fc99e Initial load
duke
parents:
diff changeset
721 }
a61af66fc99e Initial load
duke
parents:
diff changeset
722 },
6782
5a98bf7d847b 6879063: SA should use hsdis for disassembly
minqi
parents: 6725
diff changeset
723 // decode raw address
5a98bf7d847b 6879063: SA should use hsdis for disassembly
minqi
parents: 6725
diff changeset
724 new Command("dis", "dis address [length]", false) {
5a98bf7d847b 6879063: SA should use hsdis for disassembly
minqi
parents: 6725
diff changeset
725 public void doit(Tokens t) {
5a98bf7d847b 6879063: SA should use hsdis for disassembly
minqi
parents: 6725
diff changeset
726 int tokens = t.countTokens();
5a98bf7d847b 6879063: SA should use hsdis for disassembly
minqi
parents: 6725
diff changeset
727 if (tokens != 1 && tokens != 2) {
5a98bf7d847b 6879063: SA should use hsdis for disassembly
minqi
parents: 6725
diff changeset
728 usage();
5a98bf7d847b 6879063: SA should use hsdis for disassembly
minqi
parents: 6725
diff changeset
729 return;
5a98bf7d847b 6879063: SA should use hsdis for disassembly
minqi
parents: 6725
diff changeset
730 }
5a98bf7d847b 6879063: SA should use hsdis for disassembly
minqi
parents: 6725
diff changeset
731 String name = t.nextToken();
5a98bf7d847b 6879063: SA should use hsdis for disassembly
minqi
parents: 6725
diff changeset
732 Address addr = null;
5a98bf7d847b 6879063: SA should use hsdis for disassembly
minqi
parents: 6725
diff changeset
733 int len = 0x10; // default length
5a98bf7d847b 6879063: SA should use hsdis for disassembly
minqi
parents: 6725
diff changeset
734 try {
5a98bf7d847b 6879063: SA should use hsdis for disassembly
minqi
parents: 6725
diff changeset
735 addr = VM.getVM().getDebugger().parseAddress(name);
5a98bf7d847b 6879063: SA should use hsdis for disassembly
minqi
parents: 6725
diff changeset
736 } catch (NumberFormatException e) {
5a98bf7d847b 6879063: SA should use hsdis for disassembly
minqi
parents: 6725
diff changeset
737 out.println(e);
5a98bf7d847b 6879063: SA should use hsdis for disassembly
minqi
parents: 6725
diff changeset
738 return;
5a98bf7d847b 6879063: SA should use hsdis for disassembly
minqi
parents: 6725
diff changeset
739 }
5a98bf7d847b 6879063: SA should use hsdis for disassembly
minqi
parents: 6725
diff changeset
740 if (tokens == 2) {
5a98bf7d847b 6879063: SA should use hsdis for disassembly
minqi
parents: 6725
diff changeset
741 try {
5a98bf7d847b 6879063: SA should use hsdis for disassembly
minqi
parents: 6725
diff changeset
742 len = Integer.parseInt(t.nextToken());
5a98bf7d847b 6879063: SA should use hsdis for disassembly
minqi
parents: 6725
diff changeset
743 } catch (NumberFormatException e) {
5a98bf7d847b 6879063: SA should use hsdis for disassembly
minqi
parents: 6725
diff changeset
744 out.println(e);
5a98bf7d847b 6879063: SA should use hsdis for disassembly
minqi
parents: 6725
diff changeset
745 return;
5a98bf7d847b 6879063: SA should use hsdis for disassembly
minqi
parents: 6725
diff changeset
746 }
5a98bf7d847b 6879063: SA should use hsdis for disassembly
minqi
parents: 6725
diff changeset
747 }
5a98bf7d847b 6879063: SA should use hsdis for disassembly
minqi
parents: 6725
diff changeset
748 HTMLGenerator generator = new HTMLGenerator(false);
5a98bf7d847b 6879063: SA should use hsdis for disassembly
minqi
parents: 6725
diff changeset
749 out.println(generator.genHTMLForRawDisassembly(addr, len));
5a98bf7d847b 6879063: SA should use hsdis for disassembly
minqi
parents: 6725
diff changeset
750 }
5a98bf7d847b 6879063: SA should use hsdis for disassembly
minqi
parents: 6725
diff changeset
751
5a98bf7d847b 6879063: SA should use hsdis for disassembly
minqi
parents: 6725
diff changeset
752 },
5a98bf7d847b 6879063: SA should use hsdis for disassembly
minqi
parents: 6725
diff changeset
753 // decode codeblob or nmethod
5a98bf7d847b 6879063: SA should use hsdis for disassembly
minqi
parents: 6725
diff changeset
754 new Command("disassemble", "disassemble address", false) {
5a98bf7d847b 6879063: SA should use hsdis for disassembly
minqi
parents: 6725
diff changeset
755 public void doit(Tokens t) {
5a98bf7d847b 6879063: SA should use hsdis for disassembly
minqi
parents: 6725
diff changeset
756 int tokens = t.countTokens();
5a98bf7d847b 6879063: SA should use hsdis for disassembly
minqi
parents: 6725
diff changeset
757 if (tokens != 1) {
5a98bf7d847b 6879063: SA should use hsdis for disassembly
minqi
parents: 6725
diff changeset
758 usage();
5a98bf7d847b 6879063: SA should use hsdis for disassembly
minqi
parents: 6725
diff changeset
759 return;
5a98bf7d847b 6879063: SA should use hsdis for disassembly
minqi
parents: 6725
diff changeset
760 }
5a98bf7d847b 6879063: SA should use hsdis for disassembly
minqi
parents: 6725
diff changeset
761 String name = t.nextToken();
5a98bf7d847b 6879063: SA should use hsdis for disassembly
minqi
parents: 6725
diff changeset
762 Address addr = null;
5a98bf7d847b 6879063: SA should use hsdis for disassembly
minqi
parents: 6725
diff changeset
763 try {
5a98bf7d847b 6879063: SA should use hsdis for disassembly
minqi
parents: 6725
diff changeset
764 addr = VM.getVM().getDebugger().parseAddress(name);
5a98bf7d847b 6879063: SA should use hsdis for disassembly
minqi
parents: 6725
diff changeset
765 } catch (NumberFormatException e) {
5a98bf7d847b 6879063: SA should use hsdis for disassembly
minqi
parents: 6725
diff changeset
766 out.println(e);
5a98bf7d847b 6879063: SA should use hsdis for disassembly
minqi
parents: 6725
diff changeset
767 return;
5a98bf7d847b 6879063: SA should use hsdis for disassembly
minqi
parents: 6725
diff changeset
768 }
5a98bf7d847b 6879063: SA should use hsdis for disassembly
minqi
parents: 6725
diff changeset
769
5a98bf7d847b 6879063: SA should use hsdis for disassembly
minqi
parents: 6725
diff changeset
770 HTMLGenerator generator = new HTMLGenerator(false);
5a98bf7d847b 6879063: SA should use hsdis for disassembly
minqi
parents: 6725
diff changeset
771 out.println(generator.genHTML(addr));
5a98bf7d847b 6879063: SA should use hsdis for disassembly
minqi
parents: 6725
diff changeset
772 }
5a98bf7d847b 6879063: SA should use hsdis for disassembly
minqi
parents: 6725
diff changeset
773 },
5a98bf7d847b 6879063: SA should use hsdis for disassembly
minqi
parents: 6725
diff changeset
774 // print Java bytecode disassembly
5a98bf7d847b 6879063: SA should use hsdis for disassembly
minqi
parents: 6725
diff changeset
775 new Command("jdis", "jdis address", false) {
5a98bf7d847b 6879063: SA should use hsdis for disassembly
minqi
parents: 6725
diff changeset
776 public void doit(Tokens t) {
5a98bf7d847b 6879063: SA should use hsdis for disassembly
minqi
parents: 6725
diff changeset
777 int tokens = t.countTokens();
5a98bf7d847b 6879063: SA should use hsdis for disassembly
minqi
parents: 6725
diff changeset
778 if (tokens != 1) {
5a98bf7d847b 6879063: SA should use hsdis for disassembly
minqi
parents: 6725
diff changeset
779 usage();
5a98bf7d847b 6879063: SA should use hsdis for disassembly
minqi
parents: 6725
diff changeset
780 return;
5a98bf7d847b 6879063: SA should use hsdis for disassembly
minqi
parents: 6725
diff changeset
781 }
5a98bf7d847b 6879063: SA should use hsdis for disassembly
minqi
parents: 6725
diff changeset
782 Address a = VM.getVM().getDebugger().parseAddress(t.nextToken());
5a98bf7d847b 6879063: SA should use hsdis for disassembly
minqi
parents: 6725
diff changeset
783 Method m = (Method)Metadata.instantiateWrapperFor(a);
5a98bf7d847b 6879063: SA should use hsdis for disassembly
minqi
parents: 6725
diff changeset
784 HTMLGenerator html = new HTMLGenerator(false);
5a98bf7d847b 6879063: SA should use hsdis for disassembly
minqi
parents: 6725
diff changeset
785 out.println(html.genHTML(m));
5a98bf7d847b 6879063: SA should use hsdis for disassembly
minqi
parents: 6725
diff changeset
786 }
5a98bf7d847b 6879063: SA should use hsdis for disassembly
minqi
parents: 6725
diff changeset
787 },
1385
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
788 new Command("revptrs", "revptrs address", false) {
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
789 public void doit(Tokens t) {
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
790 int tokens = t.countTokens();
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
791 if (tokens != 1 && (tokens != 2 || !t.nextToken().equals("-c"))) {
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
792 usage();
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
793 return;
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
794 }
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
795 boolean chase = tokens == 2;
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
796 ReversePtrs revptrs = VM.getVM().getRevPtrs();
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
797 if (revptrs == null) {
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
798 out.println("Computing reverse pointers...");
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
799 ReversePtrsAnalysis analysis = new ReversePtrsAnalysis();
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
800 final boolean[] complete = new boolean[1];
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
801 HeapProgressThunk thunk = new HeapProgressThunk() {
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
802 public void heapIterationFractionUpdate(double d) {}
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
803 public synchronized void heapIterationComplete() {
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
804 complete[0] = true;
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
805 notify();
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
806 }
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
807 };
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
808 analysis.setHeapProgressThunk(thunk);
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
809 analysis.run();
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
810 while (!complete[0]) {
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
811 synchronized (thunk) {
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
812 try {
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
813 thunk.wait();
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
814 } catch (Exception e) {
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
815 }
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
816 }
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
817 }
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
818 revptrs = VM.getVM().getRevPtrs();
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
819 out.println("Done.");
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
820 }
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
821 Address a = VM.getVM().getDebugger().parseAddress(t.nextToken());
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
822 if (VM.getVM().getUniverse().heap().isInReserved(a)) {
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
823 OopHandle handle = a.addOffsetToAsOopHandle(0);
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
824 Oop oop = VM.getVM().getObjectHeap().newOop(handle);
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
825 ArrayList ptrs = revptrs.get(oop);
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
826 if (ptrs == null) {
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
827 out.println("no live references to " + a);
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
828 } else {
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
829 if (chase) {
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
830 while (ptrs.size() == 1) {
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
831 LivenessPathElement e = (LivenessPathElement)ptrs.get(0);
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
832 ByteArrayOutputStream bos = new ByteArrayOutputStream();
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
833 Oop.printOopValueOn(e.getObj(), new PrintStream(bos));
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
834 out.println(bos.toString());
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
835 ptrs = revptrs.get(e.getObj());
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
836 }
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
837 } else {
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
838 for (int i = 0; i < ptrs.size(); i++) {
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
839 LivenessPathElement e = (LivenessPathElement)ptrs.get(i);
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
840 ByteArrayOutputStream bos = new ByteArrayOutputStream();
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
841 Oop.printOopValueOn(e.getObj(), new PrintStream(bos));
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
842 out.println(bos.toString());
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
843 oop = e.getObj();
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
844 }
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
845 }
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
846 }
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
847 }
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
848 }
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
849 },
3939
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
850 new Command("printmdo", "printmdo [ -a | expression ]", false) {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
851 // Print every MDO in the heap or the one referenced by expression.
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
852 public void doit(Tokens t) {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
853 if (t.countTokens() != 1) {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
854 usage();
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
855 } else {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
856 String s = t.nextToken();
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
857 if (s.equals("-a")) {
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 3939
diff changeset
858 SystemDictionary sysDict = VM.getVM().getSystemDictionary();
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 3939
diff changeset
859 sysDict.allClassesDo(new SystemDictionary.ClassVisitor() {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 3939
diff changeset
860 public void visit(Klass k) {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 3939
diff changeset
861 if (k instanceof InstanceKlass) {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 3939
diff changeset
862 MethodArray methods = ((InstanceKlass)k).getMethods();
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 3939
diff changeset
863 for (int i = 0; i < methods.length(); i++) {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 3939
diff changeset
864 Method m = methods.at(i);
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 3939
diff changeset
865 MethodData mdo = m.getMethodData();
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 3939
diff changeset
866 if (mdo != null) {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 3939
diff changeset
867 out.println("MethodData " + mdo.getAddress() + " for " +
3939
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
868 "method " + m.getMethodHolder().getName().asString() + "." +
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
869 m.getName().asString() +
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 3939
diff changeset
870 m.getSignature().asString() + "@" + m.getAddress());
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 3939
diff changeset
871 mdo.printDataOn(out);
3939
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
872 }
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 3939
diff changeset
873 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 3939
diff changeset
874 }
3939
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
875 }
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 3939
diff changeset
876 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 3939
diff changeset
877 );
3939
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
878 } else {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
879 Address a = VM.getVM().getDebugger().parseAddress(s);
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 3939
diff changeset
880 MethodData mdo = (MethodData) Metadata.instantiateWrapperFor(a);
3939
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
881 mdo.printDataOn(out);
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
882 }
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
883 }
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
884 }
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
885 },
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 3939
diff changeset
886 new Command("printall", "printall", false) {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 3939
diff changeset
887 // Print every MDO in the heap or the one referenced by expression.
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 3939
diff changeset
888 public void doit(Tokens t) {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 3939
diff changeset
889 if (t.countTokens() != 0) {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 3939
diff changeset
890 usage();
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 3939
diff changeset
891 } else {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 3939
diff changeset
892 SystemDictionary sysDict = VM.getVM().getSystemDictionary();
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 3939
diff changeset
893 sysDict.allClassesDo(new SystemDictionary.ClassVisitor() {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 3939
diff changeset
894 public void visit(Klass k) {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 3939
diff changeset
895 if (k instanceof InstanceKlass && ((InstanceKlass)k).getConstants().getCache() != null) {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 3939
diff changeset
896 MethodArray methods = ((InstanceKlass)k).getMethods();
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 3939
diff changeset
897 for (int i = 0; i < methods.length(); i++) {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 3939
diff changeset
898 Method m = methods.at(i);
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 3939
diff changeset
899 HTMLGenerator gen = new HTMLGenerator(false);
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 3939
diff changeset
900 out.println(gen.genHTML(m));
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 3939
diff changeset
901 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 3939
diff changeset
902 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 3939
diff changeset
903 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 3939
diff changeset
904 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 3939
diff changeset
905 );
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 3939
diff changeset
906 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 3939
diff changeset
907 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 3939
diff changeset
908 },
3939
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
909 new Command("dumpideal", "dumpideal { -a | id }", false) {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
910 // Do a full dump of the nodes reachabile from root in each compiler thread.
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
911 public void doit(Tokens t) {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
912 if (t.countTokens() != 1) {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
913 usage();
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
914 } else {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
915 String name = t.nextToken();
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
916 boolean all = name.equals("-a");
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
917 Threads threads = VM.getVM().getThreads();
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
918 for (JavaThread thread = threads.first(); thread != null; thread = thread.next()) {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
919 ByteArrayOutputStream bos = new ByteArrayOutputStream();
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
920 thread.printThreadIDOn(new PrintStream(bos));
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
921 if (all || bos.toString().equals(name)) {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
922 if (thread instanceof CompilerThread) {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
923 CompilerThread ct = (CompilerThread)thread;
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
924 out.println(ct);
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
925 ciEnv env = ct.env();
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
926 if (env != null) {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
927 Compile c = env.compilerData();
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
928 c.root().dump(9999, out);
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
929 } else {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
930 out.println(" not compiling");
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
931 }
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
932 }
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
933 }
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
934 }
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
935 }
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
936 }
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
937 },
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
938 new Command("dumpcfg", "dumpcfg { -a | id }", false) {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
939 // Dump the PhaseCFG for every compiler thread that has one live.
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
940 public void doit(Tokens t) {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
941 if (t.countTokens() != 1) {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
942 usage();
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
943 } else {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
944 String name = t.nextToken();
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
945 boolean all = name.equals("-a");
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
946 Threads threads = VM.getVM().getThreads();
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
947 for (JavaThread thread = threads.first(); thread != null; thread = thread.next()) {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
948 ByteArrayOutputStream bos = new ByteArrayOutputStream();
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
949 thread.printThreadIDOn(new PrintStream(bos));
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
950 if (all || bos.toString().equals(name)) {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
951 if (thread instanceof CompilerThread) {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
952 CompilerThread ct = (CompilerThread)thread;
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
953 out.println(ct);
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
954 ciEnv env = ct.env();
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
955 if (env != null) {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
956 Compile c = env.compilerData();
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
957 c.cfg().dump(out);
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
958 }
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
959 }
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
960 }
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
961 }
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
962 }
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
963 }
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
964 },
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
965 new Command("dumpilt", "dumpilt { -a | id }", false) {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
966 // dumps the InlineTree of a C2 compile
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
967 public void doit(Tokens t) {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
968 if (t.countTokens() != 1) {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
969 usage();
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
970 } else {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
971 String name = t.nextToken();
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
972 boolean all = name.equals("-a");
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
973 Threads threads = VM.getVM().getThreads();
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
974 for (JavaThread thread = threads.first(); thread != null; thread = thread.next()) {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
975 ByteArrayOutputStream bos = new ByteArrayOutputStream();
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
976 thread.printThreadIDOn(new PrintStream(bos));
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
977 if (all || bos.toString().equals(name)) {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
978 if (thread instanceof CompilerThread) {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
979 CompilerThread ct = (CompilerThread)thread;
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
980 ciEnv env = ct.env();
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
981 if (env != null) {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
982 Compile c = env.compilerData();
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
983 InlineTree ilt = c.ilt();
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
984 if (ilt != null) {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
985 ilt.print(out);
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
986 }
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
987 }
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
988 }
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
989 }
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
990 }
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
991 }
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
992 }
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
993 },
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
994 new Command("vmstructsdump", "vmstructsdump", false) {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
995 public void doit(Tokens t) {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
996 if (t.countTokens() != 0) {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
997 usage();
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
998 return;
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
999 }
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
1000
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
1001 // Dump a copy of the type database in a form that can
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
1002 // be read back.
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
1003 Iterator i = agent.getTypeDataBase().getTypes();
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
1004 // Make sure the types are emitted in an order than can be read back in
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
1005 HashSet emitted = new HashSet();
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
1006 Stack pending = new Stack();
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
1007 while (i.hasNext()) {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
1008 Type n = (Type)i.next();
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
1009 if (emitted.contains(n.getName())) {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
1010 continue;
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
1011 }
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
1012
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
1013 while (n != null && !emitted.contains(n.getName())) {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
1014 pending.push(n);
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
1015 n = n.getSuperclass();
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
1016 }
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
1017 while (!pending.empty()) {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
1018 n = (Type)pending.pop();
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
1019 dumpType(n);
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
1020 emitted.add(n.getName());
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
1021 }
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
1022 }
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
1023 i = agent.getTypeDataBase().getTypes();
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
1024 while (i.hasNext()) {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
1025 dumpFields((Type)i.next(), false);
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
1026 }
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
1027 }
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
1028 },
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
1029
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1030 new Command("inspect", "inspect expression", false) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1031 public void doit(Tokens t) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1032 if (t.countTokens() != 1) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1033 usage();
a61af66fc99e Initial load
duke
parents:
diff changeset
1034 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1035 Address a = VM.getVM().getDebugger().parseAddress(t.nextToken());
a61af66fc99e Initial load
duke
parents:
diff changeset
1036 SimpleTreeNode node = null;
a61af66fc99e Initial load
duke
parents:
diff changeset
1037 if (VM.getVM().getUniverse().heap().isInReserved(a)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1038 OopHandle handle = a.addOffsetToAsOopHandle(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
1039 Oop oop = VM.getVM().getObjectHeap().newOop(handle);
a61af66fc99e Initial load
duke
parents:
diff changeset
1040 node = new OopTreeNodeAdapter(oop, null);
a61af66fc99e Initial load
duke
parents:
diff changeset
1041
a61af66fc99e Initial load
duke
parents:
diff changeset
1042 out.println("instance of " + node.getValue() + " @ " + a +
a61af66fc99e Initial load
duke
parents:
diff changeset
1043 " (size = " + oop.getObjectSize() + ")");
a61af66fc99e Initial load
duke
parents:
diff changeset
1044 } else if (VM.getVM().getCodeCache().contains(a)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1045 CodeBlob blob = VM.getVM().getCodeCache().findBlobUnsafe(a);
a61af66fc99e Initial load
duke
parents:
diff changeset
1046 a = blob.headerBegin();
a61af66fc99e Initial load
duke
parents:
diff changeset
1047 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1048 if (node == null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1049 Type type = VM.getVM().getTypeDataBase().guessTypeForAddress(a);
a61af66fc99e Initial load
duke
parents:
diff changeset
1050 if (type != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1051 out.println("Type is " + type.getName() + " (size of " + type.getSize() + ")");
a61af66fc99e Initial load
duke
parents:
diff changeset
1052 node = new CTypeTreeNodeAdapter(a, type, null);
a61af66fc99e Initial load
duke
parents:
diff changeset
1053 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1054 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1055 if (node != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1056 printNode(node);
a61af66fc99e Initial load
duke
parents:
diff changeset
1057 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1058 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1059 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1060 },
a61af66fc99e Initial load
duke
parents:
diff changeset
1061 new Command("jhisto", "jhisto", false) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1062 public void doit(Tokens t) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1063 ObjectHistogram histo = new ObjectHistogram();
a61af66fc99e Initial load
duke
parents:
diff changeset
1064 histo.run(out, err);
a61af66fc99e Initial load
duke
parents:
diff changeset
1065 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1066 },
a61af66fc99e Initial load
duke
parents:
diff changeset
1067 new Command("jstack", "jstack [-v]", false) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1068 public void doit(Tokens t) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1069 boolean verbose = false;
a61af66fc99e Initial load
duke
parents:
diff changeset
1070 if (t.countTokens() > 0 && t.nextToken().equals("-v")) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1071 verbose = true;
a61af66fc99e Initial load
duke
parents:
diff changeset
1072 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1073 StackTrace jstack = new StackTrace(verbose, true);
a61af66fc99e Initial load
duke
parents:
diff changeset
1074 jstack.run(out);
a61af66fc99e Initial load
duke
parents:
diff changeset
1075 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1076 },
a61af66fc99e Initial load
duke
parents:
diff changeset
1077 new Command("print", "print expression", false) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1078 public void doit(Tokens t) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1079 if (t.countTokens() != 1) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1080 usage();
a61af66fc99e Initial load
duke
parents:
diff changeset
1081 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1082 Address a = VM.getVM().getDebugger().parseAddress(t.nextToken());
a61af66fc99e Initial load
duke
parents:
diff changeset
1083 HTMLGenerator gen = new HTMLGenerator(false);
a61af66fc99e Initial load
duke
parents:
diff changeset
1084 out.println(gen.genHTML(a));
a61af66fc99e Initial load
duke
parents:
diff changeset
1085 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1086 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1087 },
a61af66fc99e Initial load
duke
parents:
diff changeset
1088 new Command("printas", "printas type expression", false) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1089 public void doit(Tokens t) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1090 if (t.countTokens() != 2) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1091 usage();
a61af66fc99e Initial load
duke
parents:
diff changeset
1092 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1093 Type type = agent.getTypeDataBase().lookupType(t.nextToken());
a61af66fc99e Initial load
duke
parents:
diff changeset
1094 Address a = VM.getVM().getDebugger().parseAddress(t.nextToken());
a61af66fc99e Initial load
duke
parents:
diff changeset
1095 CTypeTreeNodeAdapter node = new CTypeTreeNodeAdapter(a, type, null);
a61af66fc99e Initial load
duke
parents:
diff changeset
1096
a61af66fc99e Initial load
duke
parents:
diff changeset
1097 out.println("pointer to " + type + " @ " + a +
a61af66fc99e Initial load
duke
parents:
diff changeset
1098 " (size = " + type.getSize() + ")");
a61af66fc99e Initial load
duke
parents:
diff changeset
1099 printNode(node);
a61af66fc99e Initial load
duke
parents:
diff changeset
1100 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1101 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1102 },
a61af66fc99e Initial load
duke
parents:
diff changeset
1103 new Command("printstatics", "printstatics [ type ]", false) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1104 public void doit(Tokens t) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1105 if (t.countTokens() > 1) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1106 usage();
a61af66fc99e Initial load
duke
parents:
diff changeset
1107 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1108 if (t.countTokens() == 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1109 out.println("All known static fields");
a61af66fc99e Initial load
duke
parents:
diff changeset
1110 printNode(new CTypeTreeNodeAdapter(agent.getTypeDataBase().getTypes()));
a61af66fc99e Initial load
duke
parents:
diff changeset
1111 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1112 Type type = agent.getTypeDataBase().lookupType(t.nextToken());
a61af66fc99e Initial load
duke
parents:
diff changeset
1113 out.println("Static fields of " + type.getName());
a61af66fc99e Initial load
duke
parents:
diff changeset
1114 printNode(new CTypeTreeNodeAdapter(type));
a61af66fc99e Initial load
duke
parents:
diff changeset
1115 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1116 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1117 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1118 },
a61af66fc99e Initial load
duke
parents:
diff changeset
1119 new Command("pmap", "pmap", false) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1120 public void doit(Tokens t) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1121 PMap pmap = new PMap();
a61af66fc99e Initial load
duke
parents:
diff changeset
1122 pmap.run(out, debugger.getAgent().getDebugger());
a61af66fc99e Initial load
duke
parents:
diff changeset
1123 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1124 },
a61af66fc99e Initial load
duke
parents:
diff changeset
1125 new Command("pstack", "pstack [-v]", false) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1126 public void doit(Tokens t) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1127 boolean verbose = false;
a61af66fc99e Initial load
duke
parents:
diff changeset
1128 if (t.countTokens() > 0 && t.nextToken().equals("-v")) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1129 verbose = true;
a61af66fc99e Initial load
duke
parents:
diff changeset
1130 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1131 PStack pstack = new PStack(verbose, true);
a61af66fc99e Initial load
duke
parents:
diff changeset
1132 pstack.run(out, debugger.getAgent().getDebugger());
a61af66fc99e Initial load
duke
parents:
diff changeset
1133 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1134 },
a61af66fc99e Initial load
duke
parents:
diff changeset
1135 new Command("quit", true) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1136 public void doit(Tokens t) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1137 if (t.countTokens() != 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1138 usage();
a61af66fc99e Initial load
duke
parents:
diff changeset
1139 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1140 debugger.detach();
11054
38ea2efa32a7 8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents: 8756
diff changeset
1141 quit = true;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1142 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1143 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1144 },
a61af66fc99e Initial load
duke
parents:
diff changeset
1145 new Command("echo", "echo [ true | false ]", true) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1146 public void doit(Tokens t) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1147 if (t.countTokens() == 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1148 out.println("echo is " + doEcho);
a61af66fc99e Initial load
duke
parents:
diff changeset
1149 } else if (t.countTokens() == 1) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1150 doEcho = Boolean.valueOf(t.nextToken()).booleanValue();
a61af66fc99e Initial load
duke
parents:
diff changeset
1151 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1152 usage();
a61af66fc99e Initial load
duke
parents:
diff changeset
1153 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1154 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1155 },
a61af66fc99e Initial load
duke
parents:
diff changeset
1156 new Command("versioncheck", "versioncheck [ true | false ]", true) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1157 public void doit(Tokens t) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1158 if (t.countTokens() == 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1159 out.println("versioncheck is " +
a61af66fc99e Initial load
duke
parents:
diff changeset
1160 (System.getProperty("sun.jvm.hotspot.runtime.VM.disableVersionCheck") == null));
a61af66fc99e Initial load
duke
parents:
diff changeset
1161 } else if (t.countTokens() == 1) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1162 if (Boolean.valueOf(t.nextToken()).booleanValue()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1163 System.setProperty("sun.jvm.hotspot.runtime.VM.disableVersionCheck", null);
a61af66fc99e Initial load
duke
parents:
diff changeset
1164 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1165 System.setProperty("sun.jvm.hotspot.runtime.VM.disableVersionCheck", "true");
a61af66fc99e Initial load
duke
parents:
diff changeset
1166 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1167 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1168 usage();
a61af66fc99e Initial load
duke
parents:
diff changeset
1169 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1170 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1171 },
a61af66fc99e Initial load
duke
parents:
diff changeset
1172 new Command("scanoops", "scanoops start end [ type ]", false) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1173 public void doit(Tokens t) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1174 if (t.countTokens() != 2 && t.countTokens() != 3) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1175 usage();
a61af66fc99e Initial load
duke
parents:
diff changeset
1176 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1177 long stride = VM.getVM().getAddressSize();
a61af66fc99e Initial load
duke
parents:
diff changeset
1178 Address base = VM.getVM().getDebugger().parseAddress(t.nextToken());
a61af66fc99e Initial load
duke
parents:
diff changeset
1179 Address end = VM.getVM().getDebugger().parseAddress(t.nextToken());
a61af66fc99e Initial load
duke
parents:
diff changeset
1180 Klass klass = null;
a61af66fc99e Initial load
duke
parents:
diff changeset
1181 if (t.countTokens() == 1) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1182 klass = SystemDictionaryHelper.findInstanceKlass(t.nextToken());
8756
686916dc0439 8009457: SA: A small fix on "scanoops" command in CLHSDB
sla
parents: 8750
diff changeset
1183 if (klass == null) {
686916dc0439 8009457: SA: A small fix on "scanoops" command in CLHSDB
sla
parents: 8750
diff changeset
1184 out.println("No such type.");
686916dc0439 8009457: SA: A small fix on "scanoops" command in CLHSDB
sla
parents: 8750
diff changeset
1185 return;
686916dc0439 8009457: SA: A small fix on "scanoops" command in CLHSDB
sla
parents: 8750
diff changeset
1186 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1187 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1188 while (base != null && base.lessThan(end)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1189 long step = stride;
a61af66fc99e Initial load
duke
parents:
diff changeset
1190 OopHandle handle = base.addOffsetToAsOopHandle(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
1191 if (RobustOopDeterminator.oopLooksValid(handle)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1192 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
1193 Oop oop = VM.getVM().getObjectHeap().newOop(handle);
a61af66fc99e Initial load
duke
parents:
diff changeset
1194 if (klass == null || oop.getKlass().isSubtypeOf(klass))
a61af66fc99e Initial load
duke
parents:
diff changeset
1195 out.println(handle.toString() + " " + oop.getKlass().getName().asString());
a61af66fc99e Initial load
duke
parents:
diff changeset
1196 step = oop.getObjectSize();
a61af66fc99e Initial load
duke
parents:
diff changeset
1197 } catch (UnknownOopException ex) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1198 // ok
a61af66fc99e Initial load
duke
parents:
diff changeset
1199 } catch (RuntimeException ex) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1200 ex.printStackTrace();
a61af66fc99e Initial load
duke
parents:
diff changeset
1201 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1202 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1203 base = base.addOffsetTo(step);
a61af66fc99e Initial load
duke
parents:
diff changeset
1204 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1205 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1206 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1207 },
3939
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
1208 new Command("intConstant", "intConstant [ name [ value ] ]", true) {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
1209 public void doit(Tokens t) {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
1210 if (t.countTokens() != 1 && t.countTokens() != 0 && t.countTokens() != 2) {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
1211 usage();
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
1212 return;
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
1213 }
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
1214 HotSpotTypeDataBase db = (HotSpotTypeDataBase)agent.getTypeDataBase();
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
1215 if (t.countTokens() == 1) {
12258
69f26e8e09f9 8024760: add more types, fields and constants to VMStructs
twisti
parents: 11054
diff changeset
1216 String name = t.nextToken();
3939
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
1217 out.println("intConstant " + name + " " + db.lookupIntConstant(name));
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
1218 } else if (t.countTokens() == 0) {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
1219 Iterator i = db.getIntConstants();
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
1220 while (i.hasNext()) {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
1221 String name = (String)i.next();
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
1222 out.println("intConstant " + name + " " + db.lookupIntConstant(name));
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
1223 }
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
1224 } else if (t.countTokens() == 2) {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
1225 String name = t.nextToken();
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
1226 Integer value = Integer.valueOf(t.nextToken());
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
1227 db.addIntConstant(name, value);
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
1228 }
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
1229 }
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
1230 },
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
1231 new Command("longConstant", "longConstant [ name [ value ] ]", true) {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
1232 public void doit(Tokens t) {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
1233 if (t.countTokens() != 1 && t.countTokens() != 0 && t.countTokens() != 2) {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
1234 usage();
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
1235 return;
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
1236 }
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
1237 HotSpotTypeDataBase db = (HotSpotTypeDataBase)agent.getTypeDataBase();
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
1238 if (t.countTokens() == 1) {
12258
69f26e8e09f9 8024760: add more types, fields and constants to VMStructs
twisti
parents: 11054
diff changeset
1239 String name = t.nextToken();
3939
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
1240 out.println("longConstant " + name + " " + db.lookupLongConstant(name));
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
1241 } else if (t.countTokens() == 0) {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
1242 Iterator i = db.getLongConstants();
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
1243 while (i.hasNext()) {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
1244 String name = (String)i.next();
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
1245 out.println("longConstant " + name + " " + db.lookupLongConstant(name));
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
1246 }
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
1247 } else if (t.countTokens() == 2) {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
1248 String name = t.nextToken();
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
1249 Long value = Long.valueOf(t.nextToken());
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
1250 db.addLongConstant(name, value);
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
1251 }
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
1252 }
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
1253 },
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1254 new Command("field", "field [ type [ name fieldtype isStatic offset address ] ]", true) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1255 public void doit(Tokens t) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1256 if (t.countTokens() != 1 && t.countTokens() != 0 && t.countTokens() != 6) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1257 usage();
a61af66fc99e Initial load
duke
parents:
diff changeset
1258 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
1259 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1260 if (t.countTokens() == 1) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1261 Type type = agent.getTypeDataBase().lookupType(t.nextToken());
a61af66fc99e Initial load
duke
parents:
diff changeset
1262 dumpFields(type);
a61af66fc99e Initial load
duke
parents:
diff changeset
1263 } else if (t.countTokens() == 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1264 Iterator i = agent.getTypeDataBase().getTypes();
a61af66fc99e Initial load
duke
parents:
diff changeset
1265 while (i.hasNext()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1266 dumpFields((Type)i.next());
a61af66fc99e Initial load
duke
parents:
diff changeset
1267 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1268 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1269 BasicType containingType = (BasicType)agent.getTypeDataBase().lookupType(t.nextToken());
a61af66fc99e Initial load
duke
parents:
diff changeset
1270
a61af66fc99e Initial load
duke
parents:
diff changeset
1271 String fieldName = t.nextToken();
a61af66fc99e Initial load
duke
parents:
diff changeset
1272
a61af66fc99e Initial load
duke
parents:
diff changeset
1273 // The field's Type must already be in the database -- no exceptions
a61af66fc99e Initial load
duke
parents:
diff changeset
1274 Type fieldType = agent.getTypeDataBase().lookupType(t.nextToken());
a61af66fc99e Initial load
duke
parents:
diff changeset
1275
a61af66fc99e Initial load
duke
parents:
diff changeset
1276 boolean isStatic = Boolean.valueOf(t.nextToken()).booleanValue();
a61af66fc99e Initial load
duke
parents:
diff changeset
1277 long offset = Long.parseLong(t.nextToken());
a61af66fc99e Initial load
duke
parents:
diff changeset
1278 Address staticAddress = parseAddress(t.nextToken());
a61af66fc99e Initial load
duke
parents:
diff changeset
1279 if (isStatic && staticAddress == null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1280 staticAddress = lookup(containingType.getName() + "::" + fieldName);
a61af66fc99e Initial load
duke
parents:
diff changeset
1281 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1282
a61af66fc99e Initial load
duke
parents:
diff changeset
1283 // check to see if the field already exists
a61af66fc99e Initial load
duke
parents:
diff changeset
1284 Iterator i = containingType.getFields();
a61af66fc99e Initial load
duke
parents:
diff changeset
1285 while (i.hasNext()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1286 Field f = (Field) i.next();
a61af66fc99e Initial load
duke
parents:
diff changeset
1287 if (f.getName().equals(fieldName)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1288 if (f.isStatic() != isStatic) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1289 throw new RuntimeException("static/nonstatic mismatch: " + t.input);
a61af66fc99e Initial load
duke
parents:
diff changeset
1290 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1291 if (!isStatic) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1292 if (f.getOffset() != offset) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1293 throw new RuntimeException("bad redefinition of field offset: " + t.input);
a61af66fc99e Initial load
duke
parents:
diff changeset
1294 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1295 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1296 if (!f.getStaticFieldAddress().equals(staticAddress)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1297 throw new RuntimeException("bad redefinition of field location: " + t.input);
a61af66fc99e Initial load
duke
parents:
diff changeset
1298 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1299 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1300 if (f.getType() != fieldType) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1301 throw new RuntimeException("bad redefinition of field type: " + t.input);
a61af66fc99e Initial load
duke
parents:
diff changeset
1302 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1303 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
1304 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1305 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1306
a61af66fc99e Initial load
duke
parents:
diff changeset
1307 // Create field by type
a61af66fc99e Initial load
duke
parents:
diff changeset
1308 HotSpotTypeDataBase db = (HotSpotTypeDataBase)agent.getTypeDataBase();
a61af66fc99e Initial load
duke
parents:
diff changeset
1309 db.createField(containingType,
a61af66fc99e Initial load
duke
parents:
diff changeset
1310 fieldName, fieldType,
a61af66fc99e Initial load
duke
parents:
diff changeset
1311 isStatic,
a61af66fc99e Initial load
duke
parents:
diff changeset
1312 offset,
a61af66fc99e Initial load
duke
parents:
diff changeset
1313 staticAddress);
a61af66fc99e Initial load
duke
parents:
diff changeset
1314
a61af66fc99e Initial load
duke
parents:
diff changeset
1315 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1316 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1317
a61af66fc99e Initial load
duke
parents:
diff changeset
1318 },
a61af66fc99e Initial load
duke
parents:
diff changeset
1319 new Command("tokenize", "tokenize ...", true) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1320 public void doit(Tokens t) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1321 while (t.hasMoreTokens()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1322 out.println("\"" + t.nextToken() + "\"");
a61af66fc99e Initial load
duke
parents:
diff changeset
1323 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1324 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1325 },
a61af66fc99e Initial load
duke
parents:
diff changeset
1326 new Command("type", "type [ type [ name super isOop isInteger isUnsigned size ] ]", true) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1327 public void doit(Tokens t) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1328 if (t.countTokens() != 1 && t.countTokens() != 0 && t.countTokens() != 6) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1329 usage();
a61af66fc99e Initial load
duke
parents:
diff changeset
1330 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
1331 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1332 if (t.countTokens() == 6) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1333 String typeName = t.nextToken();
a61af66fc99e Initial load
duke
parents:
diff changeset
1334 String superclassName = t.nextToken();
a61af66fc99e Initial load
duke
parents:
diff changeset
1335 if (superclassName.equals("null")) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1336 superclassName = null;
a61af66fc99e Initial load
duke
parents:
diff changeset
1337 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1338 boolean isOop = Boolean.valueOf(t.nextToken()).booleanValue();
a61af66fc99e Initial load
duke
parents:
diff changeset
1339 boolean isInteger = Boolean.valueOf(t.nextToken()).booleanValue();
a61af66fc99e Initial load
duke
parents:
diff changeset
1340 boolean isUnsigned = Boolean.valueOf(t.nextToken()).booleanValue();
a61af66fc99e Initial load
duke
parents:
diff changeset
1341 long size = Long.parseLong(t.nextToken());
a61af66fc99e Initial load
duke
parents:
diff changeset
1342
a61af66fc99e Initial load
duke
parents:
diff changeset
1343 BasicType type = null;
a61af66fc99e Initial load
duke
parents:
diff changeset
1344 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
1345 type = (BasicType)agent.getTypeDataBase().lookupType(typeName);
a61af66fc99e Initial load
duke
parents:
diff changeset
1346 } catch (RuntimeException e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1347 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1348 if (type != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1349 if (type.isOopType() != isOop) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1350 throw new RuntimeException("oop mismatch in type definition: " + t.input);
a61af66fc99e Initial load
duke
parents:
diff changeset
1351 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1352 if (type.isCIntegerType() != isInteger) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1353 throw new RuntimeException("integer type mismatch in type definition: " + t.input);
a61af66fc99e Initial load
duke
parents:
diff changeset
1354 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1355 if (type.isCIntegerType() && (((CIntegerType)type).isUnsigned()) != isUnsigned) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1356 throw new RuntimeException("unsigned mismatch in type definition: " + t.input);
a61af66fc99e Initial load
duke
parents:
diff changeset
1357 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1358 if (type.getSuperclass() == null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1359 if (superclassName != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1360 if (type.getSize() == -1) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1361 type.setSuperclass(agent.getTypeDataBase().lookupType(superclassName));
a61af66fc99e Initial load
duke
parents:
diff changeset
1362 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1363 throw new RuntimeException("unexpected superclass in type definition: " + t.input);
a61af66fc99e Initial load
duke
parents:
diff changeset
1364 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1365 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1366 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1367 if (superclassName == null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1368 throw new RuntimeException("missing superclass in type definition: " + t.input);
a61af66fc99e Initial load
duke
parents:
diff changeset
1369 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1370 if (!type.getSuperclass().getName().equals(superclassName)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1371 throw new RuntimeException("incorrect superclass in type definition: " + t.input);
a61af66fc99e Initial load
duke
parents:
diff changeset
1372 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1373 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1374 if (type.getSize() != size) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1375 if (type.getSize() == -1) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1376 type.setSize(size);
a61af66fc99e Initial load
duke
parents:
diff changeset
1377 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1378 throw new RuntimeException("size mismatch in type definition: " + t.input);
a61af66fc99e Initial load
duke
parents:
diff changeset
1379 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1380 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
1381 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1382
a61af66fc99e Initial load
duke
parents:
diff changeset
1383 // Create type
a61af66fc99e Initial load
duke
parents:
diff changeset
1384 HotSpotTypeDataBase db = (HotSpotTypeDataBase)agent.getTypeDataBase();
a61af66fc99e Initial load
duke
parents:
diff changeset
1385 db.createType(typeName, superclassName, isOop, isInteger, isUnsigned, size);
a61af66fc99e Initial load
duke
parents:
diff changeset
1386 } else if (t.countTokens() == 1) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1387 Type type = agent.getTypeDataBase().lookupType(t.nextToken());
a61af66fc99e Initial load
duke
parents:
diff changeset
1388 dumpType(type);
a61af66fc99e Initial load
duke
parents:
diff changeset
1389 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1390 Iterator i = agent.getTypeDataBase().getTypes();
1385
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
1391 // Make sure the types are emitted in an order than can be read back in
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
1392 HashSet emitted = new HashSet();
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
1393 Stack pending = new Stack();
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1394 while (i.hasNext()) {
1385
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
1395 Type n = (Type)i.next();
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
1396 if (emitted.contains(n.getName())) {
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
1397 continue;
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
1398 }
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
1399
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
1400 while (n != null && !emitted.contains(n.getName())) {
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
1401 pending.push(n);
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
1402 n = n.getSuperclass();
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
1403 }
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
1404 while (!pending.empty()) {
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
1405 n = (Type)pending.pop();
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
1406 dumpType(n);
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
1407 emitted.add(n.getName());
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
1408 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1409 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1410 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1411 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1412
a61af66fc99e Initial load
duke
parents:
diff changeset
1413 },
a61af66fc99e Initial load
duke
parents:
diff changeset
1414 new Command("source", "source filename", true) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1415 public void doit(Tokens t) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1416 if (t.countTokens() != 1) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1417 usage();
a61af66fc99e Initial load
duke
parents:
diff changeset
1418 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
1419 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1420 String file = t.nextToken();
a61af66fc99e Initial load
duke
parents:
diff changeset
1421 BufferedReader savedInput = in;
a61af66fc99e Initial load
duke
parents:
diff changeset
1422 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
1423 BufferedReader input = new BufferedReader(new InputStreamReader(new FileInputStream(file)));
a61af66fc99e Initial load
duke
parents:
diff changeset
1424 in = input;
a61af66fc99e Initial load
duke
parents:
diff changeset
1425 run(false);
a61af66fc99e Initial load
duke
parents:
diff changeset
1426 } catch (Exception e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1427 out.println("Error: " + e);
a61af66fc99e Initial load
duke
parents:
diff changeset
1428 if (verboseExceptions) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1429 e.printStackTrace(out);
a61af66fc99e Initial load
duke
parents:
diff changeset
1430 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1431 } finally {
a61af66fc99e Initial load
duke
parents:
diff changeset
1432 in = savedInput;
a61af66fc99e Initial load
duke
parents:
diff changeset
1433 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1434
a61af66fc99e Initial load
duke
parents:
diff changeset
1435 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1436 },
1385
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
1437 new Command("search", "search [ heap | perm | rawheap | codecache | threads ] value", false) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1438 public void doit(Tokens t) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1439 if (t.countTokens() != 2) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1440 usage();
1385
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
1441 return;
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
1442 }
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
1443 String type = t.nextToken();
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
1444 final Address value = VM.getVM().getDebugger().parseAddress(t.nextToken());
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
1445 final long stride = VM.getVM().getAddressSize();
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
1446 if (type.equals("threads")) {
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
1447 Threads threads = VM.getVM().getThreads();
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
1448 for (JavaThread thread = threads.first(); thread != null; thread = thread.next()) {
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
1449 Address base = thread.getBaseOfStackPointer();
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
1450 Address end = thread.getLastJavaSP();
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
1451 if (end == null) continue;
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
1452 if (end.lessThan(base)) {
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
1453 Address tmp = base;
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
1454 base = end;
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
1455 end = tmp;
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
1456 }
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
1457 out.println("Searching " + base + " " + end);
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
1458 while (base != null && base.lessThan(end)) {
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
1459 Address val = base.getAddressAt(0);
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
1460 if (AddressOps.equal(val, value)) {
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
1461 out.println(base);
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
1462 }
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
1463 base = base.addOffsetTo(stride);
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
1464 }
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
1465 }
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
1466 } else if (type.equals("rawheap")) {
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
1467 RawHeapVisitor iterator = new RawHeapVisitor() {
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
1468 public void prologue(long used) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1469 }
1385
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
1470
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
1471 public void visitAddress(Address addr) {
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
1472 Address val = addr.getAddressAt(0);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1473 if (AddressOps.equal(val, value)) {
1385
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
1474 out.println("found at " + addr);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1475 }
1385
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
1476 }
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
1477 public void visitCompOopAddress(Address addr) {
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
1478 Address val = addr.getCompOopAddressAt(0);
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
1479 if (AddressOps.equal(val, value)) {
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
1480 out.println("found at " + addr);
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
1481 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1482 }
1385
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
1483 public void epilogue() {
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
1484 }
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
1485 };
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
1486 VM.getVM().getObjectHeap().iterateRaw(iterator);
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 3939
diff changeset
1487 } else if (type.equals("heap")) {
1385
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
1488 HeapVisitor iterator = new DefaultHeapVisitor() {
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
1489 public boolean doObj(Oop obj) {
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
1490 int index = 0;
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
1491 Address start = obj.getHandle();
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
1492 long end = obj.getObjectSize();
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
1493 while (index < end) {
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
1494 Address val = start.getAddressAt(index);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1495 if (AddressOps.equal(val, value)) {
1385
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
1496 out.println("found in " + obj.getHandle());
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
1497 break;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1498 }
1385
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
1499 index += 4;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1500 }
1385
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
1501 return false;
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
1502 }
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
1503 };
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
1504 VM.getVM().getObjectHeap().iterate(iterator);
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
1505 } else if (type.equals("codecache")) {
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
1506 CodeCacheVisitor v = new CodeCacheVisitor() {
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
1507 public void prologue(Address start, Address end) {
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
1508 }
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
1509 public void visit(CodeBlob blob) {
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
1510 boolean printed = false;
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
1511 Address base = blob.getAddress();
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
1512 Address end = base.addOffsetTo(blob.getSize());
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
1513 while (base != null && base.lessThan(end)) {
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
1514 Address val = base.getAddressAt(0);
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
1515 if (AddressOps.equal(val, value)) {
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
1516 if (!printed) {
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
1517 printed = true;
3388
a80577f854f9 7045513: JSR 292 inlining causes crashes in methodHandleWalk.cpp
never
parents: 2426
diff changeset
1518 try {
a80577f854f9 7045513: JSR 292 inlining causes crashes in methodHandleWalk.cpp
never
parents: 2426
diff changeset
1519 blob.printOn(out);
a80577f854f9 7045513: JSR 292 inlining causes crashes in methodHandleWalk.cpp
never
parents: 2426
diff changeset
1520 } catch (Exception e) {
a80577f854f9 7045513: JSR 292 inlining causes crashes in methodHandleWalk.cpp
never
parents: 2426
diff changeset
1521 out.println("Exception printing blob at " + base);
a80577f854f9 7045513: JSR 292 inlining causes crashes in methodHandleWalk.cpp
never
parents: 2426
diff changeset
1522 e.printStackTrace();
a80577f854f9 7045513: JSR 292 inlining causes crashes in methodHandleWalk.cpp
never
parents: 2426
diff changeset
1523 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1524 }
1385
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
1525 out.println("found at " + base + "\n");
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1526 }
1385
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
1527 base = base.addOffsetTo(stride);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1528 }
1385
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
1529 }
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
1530 public void epilogue() {
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
1531 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1532
a61af66fc99e Initial load
duke
parents:
diff changeset
1533
1385
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
1534 };
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
1535 VM.getVM().getCodeCache().iterate(v);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1536
a61af66fc99e Initial load
duke
parents:
diff changeset
1537 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1538 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1539 },
1040
873ec3787992 6892186: SA does not dump debug info for scalar replaced objects
kvn
parents: 196
diff changeset
1540 new Command("dumpcodecache", "dumpcodecache", false) {
873ec3787992 6892186: SA does not dump debug info for scalar replaced objects
kvn
parents: 196
diff changeset
1541 public void doit(Tokens t) {
873ec3787992 6892186: SA does not dump debug info for scalar replaced objects
kvn
parents: 196
diff changeset
1542 if (t.countTokens() != 0) {
873ec3787992 6892186: SA does not dump debug info for scalar replaced objects
kvn
parents: 196
diff changeset
1543 usage();
873ec3787992 6892186: SA does not dump debug info for scalar replaced objects
kvn
parents: 196
diff changeset
1544 } else {
873ec3787992 6892186: SA does not dump debug info for scalar replaced objects
kvn
parents: 196
diff changeset
1545 final PrintStream fout = out;
873ec3787992 6892186: SA does not dump debug info for scalar replaced objects
kvn
parents: 196
diff changeset
1546 final HTMLGenerator gen = new HTMLGenerator(false);
873ec3787992 6892186: SA does not dump debug info for scalar replaced objects
kvn
parents: 196
diff changeset
1547 CodeCacheVisitor v = new CodeCacheVisitor() {
873ec3787992 6892186: SA does not dump debug info for scalar replaced objects
kvn
parents: 196
diff changeset
1548 public void prologue(Address start, Address end) {
873ec3787992 6892186: SA does not dump debug info for scalar replaced objects
kvn
parents: 196
diff changeset
1549 }
873ec3787992 6892186: SA does not dump debug info for scalar replaced objects
kvn
parents: 196
diff changeset
1550 public void visit(CodeBlob blob) {
1748
3e8fbc61cee8 6978355: renaming for 6961697
twisti
parents: 1552
diff changeset
1551 fout.println(gen.genHTML(blob.contentBegin()));
1040
873ec3787992 6892186: SA does not dump debug info for scalar replaced objects
kvn
parents: 196
diff changeset
1552 }
873ec3787992 6892186: SA does not dump debug info for scalar replaced objects
kvn
parents: 196
diff changeset
1553 public void epilogue() {
873ec3787992 6892186: SA does not dump debug info for scalar replaced objects
kvn
parents: 196
diff changeset
1554 }
873ec3787992 6892186: SA does not dump debug info for scalar replaced objects
kvn
parents: 196
diff changeset
1555
873ec3787992 6892186: SA does not dump debug info for scalar replaced objects
kvn
parents: 196
diff changeset
1556
873ec3787992 6892186: SA does not dump debug info for scalar replaced objects
kvn
parents: 196
diff changeset
1557 };
873ec3787992 6892186: SA does not dump debug info for scalar replaced objects
kvn
parents: 196
diff changeset
1558 VM.getVM().getCodeCache().iterate(v);
873ec3787992 6892186: SA does not dump debug info for scalar replaced objects
kvn
parents: 196
diff changeset
1559 }
873ec3787992 6892186: SA does not dump debug info for scalar replaced objects
kvn
parents: 196
diff changeset
1560 }
873ec3787992 6892186: SA does not dump debug info for scalar replaced objects
kvn
parents: 196
diff changeset
1561 },
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1562 new Command("where", "where { -a | id }", false) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1563 public void doit(Tokens t) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1564 if (t.countTokens() != 1) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1565 usage();
a61af66fc99e Initial load
duke
parents:
diff changeset
1566 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1567 String name = t.nextToken();
a61af66fc99e Initial load
duke
parents:
diff changeset
1568 Threads threads = VM.getVM().getThreads();
a61af66fc99e Initial load
duke
parents:
diff changeset
1569 boolean all = name.equals("-a");
a61af66fc99e Initial load
duke
parents:
diff changeset
1570 for (JavaThread thread = threads.first(); thread != null; thread = thread.next()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1571 ByteArrayOutputStream bos = new ByteArrayOutputStream();
a61af66fc99e Initial load
duke
parents:
diff changeset
1572 thread.printThreadIDOn(new PrintStream(bos));
a61af66fc99e Initial load
duke
parents:
diff changeset
1573 if (all || bos.toString().equals(name)) {
8750
39432a1cefdd 8003348: SA can not read core file on OS
minqi
parents: 6972
diff changeset
1574 out.println("Thread " + bos.toString() + " Address: " + thread.getAddress());
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1575 HTMLGenerator gen = new HTMLGenerator(false);
1385
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
1576 try {
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
1577 out.println(gen.genHTMLForJavaStackTrace(thread));
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
1578 } catch (Exception e) {
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
1579 err.println("Error: " + e);
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
1580 if (verboseExceptions) {
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
1581 e.printStackTrace(err);
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
1582 }
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
1583 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1584 if (!all) return;
a61af66fc99e Initial load
duke
parents:
diff changeset
1585 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1586 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1587 if (!all) out.println("Couldn't find thread " + name);
a61af66fc99e Initial load
duke
parents:
diff changeset
1588 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1589 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1590 },
1385
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
1591 new Command("thread", "thread { -a | id }", false) {
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
1592 public void doit(Tokens t) {
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
1593 if (t.countTokens() != 1) {
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
1594 usage();
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
1595 } else {
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
1596 String name = t.nextToken();
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
1597 Threads threads = VM.getVM().getThreads();
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
1598 boolean all = name.equals("-a");
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
1599 for (JavaThread thread = threads.first(); thread != null; thread = thread.next()) {
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
1600 ByteArrayOutputStream bos = new ByteArrayOutputStream();
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
1601 thread.printThreadIDOn(new PrintStream(bos));
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
1602 if (all || bos.toString().equals(name)) {
8750
39432a1cefdd 8003348: SA can not read core file on OS
minqi
parents: 6972
diff changeset
1603 out.println("Thread " + bos.toString() + " Address " + thread.getAddress());
1385
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
1604 if (!all) return;
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
1605 }
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
1606 }
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
1607 out.println("Couldn't find thread " + name);
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
1608 }
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
1609 }
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
1610 },
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1611
a61af66fc99e Initial load
duke
parents:
diff changeset
1612 new Command("threads", false) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1613 public void doit(Tokens t) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1614 if (t.countTokens() != 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1615 usage();
a61af66fc99e Initial load
duke
parents:
diff changeset
1616 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1617 Threads threads = VM.getVM().getThreads();
a61af66fc99e Initial load
duke
parents:
diff changeset
1618 for (JavaThread thread = threads.first(); thread != null; thread = thread.next()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1619 thread.printThreadIDOn(out);
a61af66fc99e Initial load
duke
parents:
diff changeset
1620 out.println(" " + thread.getThreadName());
a61af66fc99e Initial load
duke
parents:
diff changeset
1621 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1622 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1623 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1624 },
a61af66fc99e Initial load
duke
parents:
diff changeset
1625
a61af66fc99e Initial load
duke
parents:
diff changeset
1626 new Command("livenmethods", false) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1627 public void doit(Tokens t) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1628 if (t.countTokens() != 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1629 usage();
a61af66fc99e Initial load
duke
parents:
diff changeset
1630 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1631 ArrayList nmethods = new ArrayList();
a61af66fc99e Initial load
duke
parents:
diff changeset
1632 Threads threads = VM.getVM().getThreads();
a61af66fc99e Initial load
duke
parents:
diff changeset
1633 HTMLGenerator gen = new HTMLGenerator(false);
a61af66fc99e Initial load
duke
parents:
diff changeset
1634 for (JavaThread thread = threads.first(); thread != null; thread = thread.next()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1635 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
1636 for (JavaVFrame vf = thread.getLastJavaVFrameDbg(); vf != null; vf = vf.javaSender()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1637 if (vf instanceof CompiledVFrame) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1638 NMethod c = ((CompiledVFrame)vf).getCode();
a61af66fc99e Initial load
duke
parents:
diff changeset
1639 if (!nmethods.contains(c)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1640 nmethods.add(c);
a61af66fc99e Initial load
duke
parents:
diff changeset
1641 out.println(gen.genHTML(c));
a61af66fc99e Initial load
duke
parents:
diff changeset
1642 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1643 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1644 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1645 } catch (Exception e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1646 e.printStackTrace();
a61af66fc99e Initial load
duke
parents:
diff changeset
1647 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1648 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1649 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1650 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1651 },
a61af66fc99e Initial load
duke
parents:
diff changeset
1652 new Command("universe", false) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1653 public void doit(Tokens t) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1654 if (t.countTokens() != 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1655 usage();
a61af66fc99e Initial load
duke
parents:
diff changeset
1656 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1657 Universe u = VM.getVM().getUniverse();
a61af66fc99e Initial load
duke
parents:
diff changeset
1658 out.println("Heap Parameters:");
a61af66fc99e Initial load
duke
parents:
diff changeset
1659 u.heap().printOn(out);
a61af66fc99e Initial load
duke
parents:
diff changeset
1660 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1661 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1662 },
a61af66fc99e Initial load
duke
parents:
diff changeset
1663 new Command("verbose", "verbose true | false", true) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1664 public void doit(Tokens t) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1665 if (t.countTokens() != 1) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1666 usage();
a61af66fc99e Initial load
duke
parents:
diff changeset
1667 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1668 verboseExceptions = Boolean.valueOf(t.nextToken()).booleanValue();
a61af66fc99e Initial load
duke
parents:
diff changeset
1669 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1670 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1671 },
a61af66fc99e Initial load
duke
parents:
diff changeset
1672 new Command("assert", "assert true | false", true) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1673 public void doit(Tokens t) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1674 if (t.countTokens() != 1) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1675 usage();
a61af66fc99e Initial load
duke
parents:
diff changeset
1676 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1677 Assert.ASSERTS_ENABLED = Boolean.valueOf(t.nextToken()).booleanValue();
a61af66fc99e Initial load
duke
parents:
diff changeset
1678 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1679 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1680 },
a61af66fc99e Initial load
duke
parents:
diff changeset
1681 };
a61af66fc99e Initial load
duke
parents:
diff changeset
1682
a61af66fc99e Initial load
duke
parents:
diff changeset
1683 private boolean verboseExceptions = false;
a61af66fc99e Initial load
duke
parents:
diff changeset
1684 private ArrayList history = new ArrayList();
a61af66fc99e Initial load
duke
parents:
diff changeset
1685 private HashMap commands = new HashMap();
a61af66fc99e Initial load
duke
parents:
diff changeset
1686 private boolean doEcho = false;
a61af66fc99e Initial load
duke
parents:
diff changeset
1687
a61af66fc99e Initial load
duke
parents:
diff changeset
1688 private Command findCommand(String key) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1689 return (Command)commands.get(key);
a61af66fc99e Initial load
duke
parents:
diff changeset
1690 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1691
a61af66fc99e Initial load
duke
parents:
diff changeset
1692 public void printPrompt() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1693 out.print("hsdb> ");
a61af66fc99e Initial load
duke
parents:
diff changeset
1694 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1695
a61af66fc99e Initial load
duke
parents:
diff changeset
1696 private DebuggerInterface debugger;
a61af66fc99e Initial load
duke
parents:
diff changeset
1697 private HotSpotAgent agent;
a61af66fc99e Initial load
duke
parents:
diff changeset
1698 private JSJavaScriptEngine jsengine;
a61af66fc99e Initial load
duke
parents:
diff changeset
1699 private BufferedReader in;
a61af66fc99e Initial load
duke
parents:
diff changeset
1700 private PrintStream out;
a61af66fc99e Initial load
duke
parents:
diff changeset
1701 private PrintStream err;
a61af66fc99e Initial load
duke
parents:
diff changeset
1702
a61af66fc99e Initial load
duke
parents:
diff changeset
1703 // called before debuggee attach
a61af66fc99e Initial load
duke
parents:
diff changeset
1704 private void preAttach() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1705 // nothing for now..
a61af66fc99e Initial load
duke
parents:
diff changeset
1706 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1707
a61af66fc99e Initial load
duke
parents:
diff changeset
1708 // called after debuggee attach
a61af66fc99e Initial load
duke
parents:
diff changeset
1709 private void postAttach() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1710 // create JavaScript engine and start it
a61af66fc99e Initial load
duke
parents:
diff changeset
1711 jsengine = new JSJavaScriptEngine() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1712 private ObjectReader reader = new ObjectReader();
a61af66fc99e Initial load
duke
parents:
diff changeset
1713 private JSJavaFactory factory = new JSJavaFactoryImpl();
a61af66fc99e Initial load
duke
parents:
diff changeset
1714 public ObjectReader getObjectReader() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1715 return reader;
a61af66fc99e Initial load
duke
parents:
diff changeset
1716 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1717 public JSJavaFactory getJSJavaFactory() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1718 return factory;
a61af66fc99e Initial load
duke
parents:
diff changeset
1719 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1720 protected void quit() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1721 debugger.detach();
11054
38ea2efa32a7 8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents: 8756
diff changeset
1722 quit = true;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1723 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1724 protected BufferedReader getInputReader() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1725 return in;
a61af66fc99e Initial load
duke
parents:
diff changeset
1726 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1727 protected PrintStream getOutputStream() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1728 return out;
a61af66fc99e Initial load
duke
parents:
diff changeset
1729 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1730 protected PrintStream getErrorStream() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1731 return err;
a61af66fc99e Initial load
duke
parents:
diff changeset
1732 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1733 };
a61af66fc99e Initial load
duke
parents:
diff changeset
1734 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
1735 jsengine.defineFunction(this,
a61af66fc99e Initial load
duke
parents:
diff changeset
1736 this.getClass().getMethod("registerCommand",
a61af66fc99e Initial load
duke
parents:
diff changeset
1737 new Class[] {
a61af66fc99e Initial load
duke
parents:
diff changeset
1738 String.class, String.class, String.class
a61af66fc99e Initial load
duke
parents:
diff changeset
1739 }));
a61af66fc99e Initial load
duke
parents:
diff changeset
1740 } catch (NoSuchMethodException exp) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1741 // should not happen, see below...!!
a61af66fc99e Initial load
duke
parents:
diff changeset
1742 exp.printStackTrace();
a61af66fc99e Initial load
duke
parents:
diff changeset
1743 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1744 jsengine.start();
a61af66fc99e Initial load
duke
parents:
diff changeset
1745 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1746
a61af66fc99e Initial load
duke
parents:
diff changeset
1747 public void registerCommand(String cmd, String usage, final String func) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1748 commands.put(cmd, new Command(cmd, usage, false) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1749 public void doit(Tokens t) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1750 final int len = t.countTokens();
a61af66fc99e Initial load
duke
parents:
diff changeset
1751 Object[] args = new Object[len];
a61af66fc99e Initial load
duke
parents:
diff changeset
1752 for (int i = 0; i < len; i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1753 args[i] = t.nextToken();
a61af66fc99e Initial load
duke
parents:
diff changeset
1754 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1755 jsengine.call(func, args);
a61af66fc99e Initial load
duke
parents:
diff changeset
1756 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1757 });
a61af66fc99e Initial load
duke
parents:
diff changeset
1758 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1759
a61af66fc99e Initial load
duke
parents:
diff changeset
1760 public void setOutput(PrintStream o) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1761 out = o;
a61af66fc99e Initial load
duke
parents:
diff changeset
1762 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1763
a61af66fc99e Initial load
duke
parents:
diff changeset
1764 public void setErr(PrintStream e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1765 err = e;
a61af66fc99e Initial load
duke
parents:
diff changeset
1766 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1767
a61af66fc99e Initial load
duke
parents:
diff changeset
1768 public CommandProcessor(DebuggerInterface debugger, BufferedReader in, PrintStream out, PrintStream err) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1769 this.debugger = debugger;
a61af66fc99e Initial load
duke
parents:
diff changeset
1770 this.agent = debugger.getAgent();
a61af66fc99e Initial load
duke
parents:
diff changeset
1771 this.in = in;
a61af66fc99e Initial load
duke
parents:
diff changeset
1772 this.out = out;
a61af66fc99e Initial load
duke
parents:
diff changeset
1773 this.err = err;
a61af66fc99e Initial load
duke
parents:
diff changeset
1774 for (int i = 0; i < commandList.length; i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1775 Command c = commandList[i];
2177
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1748
diff changeset
1776 if (commands.get(c.name) != null) {
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1748
diff changeset
1777 throw new InternalError(c.name + " has multiple definitions");
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1748
diff changeset
1778 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1779 commands.put(c.name, c);
a61af66fc99e Initial load
duke
parents:
diff changeset
1780 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1781 if (debugger.isAttached()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1782 postAttach();
a61af66fc99e Initial load
duke
parents:
diff changeset
1783 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1784 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1785
a61af66fc99e Initial load
duke
parents:
diff changeset
1786
a61af66fc99e Initial load
duke
parents:
diff changeset
1787 public void run(boolean prompt) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1788 // Process interactive commands.
11054
38ea2efa32a7 8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents: 8756
diff changeset
1789 while (!quit) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1790 if (prompt) printPrompt();
a61af66fc99e Initial load
duke
parents:
diff changeset
1791 String ln = null;
a61af66fc99e Initial load
duke
parents:
diff changeset
1792 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
1793 ln = in.readLine();
a61af66fc99e Initial load
duke
parents:
diff changeset
1794 } catch (IOException e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1795 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1796 if (ln == null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1797 if (prompt) err.println("Input stream closed.");
a61af66fc99e Initial load
duke
parents:
diff changeset
1798 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
1799 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1800
3939
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
1801 executeCommand(ln, prompt);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1802 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1803 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1804
1385
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
1805 static Pattern historyPattern = Pattern.compile("((!\\*)|(!\\$)|(!!-?)|(!-?[0-9][0-9]*)|(![a-zA-Z][^ ]*))");
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1806
3939
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
1807 public void executeCommand(String ln, boolean putInHistory) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1808 if (ln.indexOf('!') != -1) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1809 int size = history.size();
a61af66fc99e Initial load
duke
parents:
diff changeset
1810 if (size == 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1811 ln = "";
a61af66fc99e Initial load
duke
parents:
diff changeset
1812 err.println("History is empty");
a61af66fc99e Initial load
duke
parents:
diff changeset
1813 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1814 StringBuffer result = new StringBuffer();
a61af66fc99e Initial load
duke
parents:
diff changeset
1815 Matcher m = historyPattern.matcher(ln);
a61af66fc99e Initial load
duke
parents:
diff changeset
1816 int start = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
1817 while (m.find()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1818 if (m.start() > start) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1819 result.append(ln.substring(start, m.start() - start));
a61af66fc99e Initial load
duke
parents:
diff changeset
1820 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1821 start = m.end();
a61af66fc99e Initial load
duke
parents:
diff changeset
1822
a61af66fc99e Initial load
duke
parents:
diff changeset
1823 String cmd = m.group();
a61af66fc99e Initial load
duke
parents:
diff changeset
1824 if (cmd.equals("!!")) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1825 result.append((String)history.get(history.size() - 1));
a61af66fc99e Initial load
duke
parents:
diff changeset
1826 } else if (cmd.equals("!!-")) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1827 Tokens item = new Tokens((String)history.get(history.size() - 1));
a61af66fc99e Initial load
duke
parents:
diff changeset
1828 item.trim(1);
a61af66fc99e Initial load
duke
parents:
diff changeset
1829 result.append(item.join(" "));
a61af66fc99e Initial load
duke
parents:
diff changeset
1830 } else if (cmd.equals("!*")) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1831 Tokens item = new Tokens((String)history.get(history.size() - 1));
a61af66fc99e Initial load
duke
parents:
diff changeset
1832 item.nextToken();
a61af66fc99e Initial load
duke
parents:
diff changeset
1833 result.append(item.join(" "));
a61af66fc99e Initial load
duke
parents:
diff changeset
1834 } else if (cmd.equals("!$")) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1835 Tokens item = new Tokens((String)history.get(history.size() - 1));
a61af66fc99e Initial load
duke
parents:
diff changeset
1836 result.append(item.at(item.countTokens() - 1));
a61af66fc99e Initial load
duke
parents:
diff changeset
1837 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1838 String tail = cmd.substring(1);
1385
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
1839 switch (tail.charAt(0)) {
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
1840 case '0':
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
1841 case '1':
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
1842 case '2':
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
1843 case '3':
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
1844 case '4':
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
1845 case '5':
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
1846 case '6':
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
1847 case '7':
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
1848 case '8':
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
1849 case '9':
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
1850 case '-': {
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
1851 int index = Integer.parseInt(tail);
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
1852 if (index < 0) {
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
1853 index = history.size() + index;
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
1854 }
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
1855 if (index > size) {
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
1856 err.println("No such history item");
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
1857 } else {
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
1858 result.append((String)history.get(index));
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
1859 }
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
1860 break;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1861 }
1385
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
1862 default: {
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
1863 for (int i = history.size() - 1; i >= 0; i--) {
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
1864 String s = (String)history.get(i);
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
1865 if (s.startsWith(tail)) {
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
1866 result.append(s);
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
1867 }
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
1868 }
bc32f286fae0 6945219: minor SA fixes
never
parents: 1040
diff changeset
1869 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1870 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1871 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1872 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1873 if (result.length() == 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1874 err.println("malformed history reference");
a61af66fc99e Initial load
duke
parents:
diff changeset
1875 ln = "";
a61af66fc99e Initial load
duke
parents:
diff changeset
1876 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1877 if (start < ln.length()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1878 result.append(ln.substring(start));
a61af66fc99e Initial load
duke
parents:
diff changeset
1879 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1880 ln = result.toString();
a61af66fc99e Initial load
duke
parents:
diff changeset
1881 if (!doEcho) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1882 out.println(ln);
a61af66fc99e Initial load
duke
parents:
diff changeset
1883 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1884 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1885 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1886 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1887
a61af66fc99e Initial load
duke
parents:
diff changeset
1888 if (doEcho) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1889 out.println("+ " + ln);
a61af66fc99e Initial load
duke
parents:
diff changeset
1890 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1891
a61af66fc99e Initial load
duke
parents:
diff changeset
1892 PrintStream redirect = null;
a61af66fc99e Initial load
duke
parents:
diff changeset
1893 Tokens t = new Tokens(ln);
a61af66fc99e Initial load
duke
parents:
diff changeset
1894 if (t.hasMoreTokens()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1895 boolean error = false;
3939
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3388
diff changeset
1896 if (putInHistory) history.add(ln);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1897 int len = t.countTokens();
a61af66fc99e Initial load
duke
parents:
diff changeset
1898 if (len > 2) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1899 String r = t.at(len - 2);
a61af66fc99e Initial load
duke
parents:
diff changeset
1900 if (r.equals(">") || r.equals(">>")) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1901 boolean append = r.length() == 2;
a61af66fc99e Initial load
duke
parents:
diff changeset
1902 String file = t.at(len - 1);
a61af66fc99e Initial load
duke
parents:
diff changeset
1903 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
1904 redirect = new PrintStream(new BufferedOutputStream(new FileOutputStream(file, append)));
a61af66fc99e Initial load
duke
parents:
diff changeset
1905 t.trim(2);
a61af66fc99e Initial load
duke
parents:
diff changeset
1906 } catch (Exception e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1907 out.println("Error: " + e);
a61af66fc99e Initial load
duke
parents:
diff changeset
1908 if (verboseExceptions) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1909 e.printStackTrace(out);
a61af66fc99e Initial load
duke
parents:
diff changeset
1910 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1911 error = true;
a61af66fc99e Initial load
duke
parents:
diff changeset
1912 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1913 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1914 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1915 if (!error) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1916 PrintStream savedout = out;
a61af66fc99e Initial load
duke
parents:
diff changeset
1917 if (redirect != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1918 out = redirect;
a61af66fc99e Initial load
duke
parents:
diff changeset
1919 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1920 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
1921 executeCommand(t);
a61af66fc99e Initial load
duke
parents:
diff changeset
1922 } catch (Exception e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1923 err.println("Error: " + e);
a61af66fc99e Initial load
duke
parents:
diff changeset
1924 if (verboseExceptions) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1925 e.printStackTrace(err);
a61af66fc99e Initial load
duke
parents:
diff changeset
1926 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1927 } finally {
a61af66fc99e Initial load
duke
parents:
diff changeset
1928 if (redirect != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1929 out = savedout;
a61af66fc99e Initial load
duke
parents:
diff changeset
1930 redirect.close();
a61af66fc99e Initial load
duke
parents:
diff changeset
1931 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1932 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1933 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1934 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1935 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1936
a61af66fc99e Initial load
duke
parents:
diff changeset
1937 void executeCommand(Tokens args) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1938 String cmd = args.nextToken();
a61af66fc99e Initial load
duke
parents:
diff changeset
1939
a61af66fc99e Initial load
duke
parents:
diff changeset
1940 Command doit = findCommand(cmd);
a61af66fc99e Initial load
duke
parents:
diff changeset
1941
a61af66fc99e Initial load
duke
parents:
diff changeset
1942 /*
a61af66fc99e Initial load
duke
parents:
diff changeset
1943 * Check for an unknown command
a61af66fc99e Initial load
duke
parents:
diff changeset
1944 */
a61af66fc99e Initial load
duke
parents:
diff changeset
1945 if (doit == null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1946 out.println("Unrecognized command. Try help...");
a61af66fc99e Initial load
duke
parents:
diff changeset
1947 } else if (!debugger.isAttached() && !doit.okIfDisconnected) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1948 out.println("Command not valid until the attached to a VM");
a61af66fc99e Initial load
duke
parents:
diff changeset
1949 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1950 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
1951 doit.doit(args);
a61af66fc99e Initial load
duke
parents:
diff changeset
1952 } catch (Exception e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1953 out.println("Error: " + e);
a61af66fc99e Initial load
duke
parents:
diff changeset
1954 if (verboseExceptions) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1955 e.printStackTrace(out);
a61af66fc99e Initial load
duke
parents:
diff changeset
1956 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1957 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1958 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1959 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1960 }