annotate agent/src/share/classes/sun/jvm/hotspot/debugger/dummy/DummyDebugger.java @ 113:ba764ed4b6f2

6420645: Create a vm that uses compressed oops for up to 32gb heapsizes Summary: Compressed oops in instances, arrays, and headers. Code contributors are coleenp, phh, never, swamyv Reviewed-by: jmasa, kamg, acorn, tbell, kvn, rasbold
author coleenp
date Sun, 13 Apr 2008 17:43:42 -0400
parents a61af66fc99e
children c18cbe5936b8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
a61af66fc99e Initial load
duke
parents:
diff changeset
2 * Copyright 2000-2004 Sun Microsystems, Inc. All Rights Reserved.
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 *
a61af66fc99e Initial load
duke
parents:
diff changeset
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
a61af66fc99e Initial load
duke
parents:
diff changeset
20 * CA 95054 USA or visit www.sun.com if you need additional information or
a61af66fc99e Initial load
duke
parents:
diff changeset
21 * have any questions.
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.debugger.dummy;
a61af66fc99e Initial load
duke
parents:
diff changeset
26
a61af66fc99e Initial load
duke
parents:
diff changeset
27 import java.util.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
28 import sun.jvm.hotspot.debugger.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
29 import sun.jvm.hotspot.debugger.cdbg.CDebugger;
a61af66fc99e Initial load
duke
parents:
diff changeset
30 import sun.jvm.hotspot.utilities.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
31
a61af66fc99e Initial load
duke
parents:
diff changeset
32 /** For testing purposes */
a61af66fc99e Initial load
duke
parents:
diff changeset
33
a61af66fc99e Initial load
duke
parents:
diff changeset
34 public class DummyDebugger extends DebuggerBase {
a61af66fc99e Initial load
duke
parents:
diff changeset
35 private MachineDescription machDesc;
a61af66fc99e Initial load
duke
parents:
diff changeset
36
a61af66fc99e Initial load
duke
parents:
diff changeset
37 public DummyDebugger(MachineDescription machDesc) {
a61af66fc99e Initial load
duke
parents:
diff changeset
38 this.machDesc = machDesc;
a61af66fc99e Initial load
duke
parents:
diff changeset
39 }
a61af66fc99e Initial load
duke
parents:
diff changeset
40
a61af66fc99e Initial load
duke
parents:
diff changeset
41 public boolean hasProcessList() throws DebuggerException {
a61af66fc99e Initial load
duke
parents:
diff changeset
42 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
43 }
a61af66fc99e Initial load
duke
parents:
diff changeset
44
a61af66fc99e Initial load
duke
parents:
diff changeset
45 public List getProcessList() throws DebuggerException {
a61af66fc99e Initial load
duke
parents:
diff changeset
46 return null;
a61af66fc99e Initial load
duke
parents:
diff changeset
47 }
a61af66fc99e Initial load
duke
parents:
diff changeset
48
a61af66fc99e Initial load
duke
parents:
diff changeset
49 public void attach(int processID) throws DebuggerException {
a61af66fc99e Initial load
duke
parents:
diff changeset
50 }
a61af66fc99e Initial load
duke
parents:
diff changeset
51
a61af66fc99e Initial load
duke
parents:
diff changeset
52 public void attach(String executableName, String coreFileName)
a61af66fc99e Initial load
duke
parents:
diff changeset
53 throws DebuggerException {
a61af66fc99e Initial load
duke
parents:
diff changeset
54 }
a61af66fc99e Initial load
duke
parents:
diff changeset
55
a61af66fc99e Initial load
duke
parents:
diff changeset
56 public boolean detach() {
a61af66fc99e Initial load
duke
parents:
diff changeset
57 return true;
a61af66fc99e Initial load
duke
parents:
diff changeset
58 }
a61af66fc99e Initial load
duke
parents:
diff changeset
59
a61af66fc99e Initial load
duke
parents:
diff changeset
60 public Address parseAddress(String addrStr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
61 String s = addrStr.trim();
a61af66fc99e Initial load
duke
parents:
diff changeset
62 if (!s.startsWith("0x")) {
a61af66fc99e Initial load
duke
parents:
diff changeset
63 throw new NumberFormatException(addrStr);
a61af66fc99e Initial load
duke
parents:
diff changeset
64 }
a61af66fc99e Initial load
duke
parents:
diff changeset
65 long l = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
66 for (int i = 2; i < s.length(); ++i) {
a61af66fc99e Initial load
duke
parents:
diff changeset
67 int val = charToNibble(s.charAt(i));
a61af66fc99e Initial load
duke
parents:
diff changeset
68 l <<= 4;
a61af66fc99e Initial load
duke
parents:
diff changeset
69 l |= val;
a61af66fc99e Initial load
duke
parents:
diff changeset
70 }
a61af66fc99e Initial load
duke
parents:
diff changeset
71 return new DummyAddress(this, l);
a61af66fc99e Initial load
duke
parents:
diff changeset
72 }
a61af66fc99e Initial load
duke
parents:
diff changeset
73
a61af66fc99e Initial load
duke
parents:
diff changeset
74 public long getAddressValue(Address addr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
75 if (addr == null) return 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
76 return ((DummyAddress) addr).getValue();
a61af66fc99e Initial load
duke
parents:
diff changeset
77 }
a61af66fc99e Initial load
duke
parents:
diff changeset
78
a61af66fc99e Initial load
duke
parents:
diff changeset
79 public String getOS() {
a61af66fc99e Initial load
duke
parents:
diff changeset
80 return PlatformInfo.getOS();
a61af66fc99e Initial load
duke
parents:
diff changeset
81 }
a61af66fc99e Initial load
duke
parents:
diff changeset
82
a61af66fc99e Initial load
duke
parents:
diff changeset
83 public String getCPU() {
a61af66fc99e Initial load
duke
parents:
diff changeset
84 return PlatformInfo.getCPU();
a61af66fc99e Initial load
duke
parents:
diff changeset
85 }
a61af66fc99e Initial load
duke
parents:
diff changeset
86
a61af66fc99e Initial load
duke
parents:
diff changeset
87 public MachineDescription getMachineDescription() throws DebuggerException {
a61af66fc99e Initial load
duke
parents:
diff changeset
88 return machDesc;
a61af66fc99e Initial load
duke
parents:
diff changeset
89 }
a61af66fc99e Initial load
duke
parents:
diff changeset
90
a61af66fc99e Initial load
duke
parents:
diff changeset
91 public boolean hasConsole() {
a61af66fc99e Initial load
duke
parents:
diff changeset
92 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
93 }
a61af66fc99e Initial load
duke
parents:
diff changeset
94
a61af66fc99e Initial load
duke
parents:
diff changeset
95 public String consoleExecuteCommand(String cmd)
a61af66fc99e Initial load
duke
parents:
diff changeset
96 throws DebuggerException {
a61af66fc99e Initial load
duke
parents:
diff changeset
97 throw new DebuggerException("unimplemented");
a61af66fc99e Initial load
duke
parents:
diff changeset
98 }
a61af66fc99e Initial load
duke
parents:
diff changeset
99
a61af66fc99e Initial load
duke
parents:
diff changeset
100 public String getConsolePrompt() throws DebuggerException {
a61af66fc99e Initial load
duke
parents:
diff changeset
101 throw new DebuggerException("unimplemented");
a61af66fc99e Initial load
duke
parents:
diff changeset
102 }
a61af66fc99e Initial load
duke
parents:
diff changeset
103
a61af66fc99e Initial load
duke
parents:
diff changeset
104 public CDebugger getCDebugger() throws DebuggerException {
a61af66fc99e Initial load
duke
parents:
diff changeset
105 return null;
a61af66fc99e Initial load
duke
parents:
diff changeset
106 }
a61af66fc99e Initial load
duke
parents:
diff changeset
107
a61af66fc99e Initial load
duke
parents:
diff changeset
108 public Address lookup(String objectName, String symbol) {
a61af66fc99e Initial load
duke
parents:
diff changeset
109 return null;
a61af66fc99e Initial load
duke
parents:
diff changeset
110 }
a61af66fc99e Initial load
duke
parents:
diff changeset
111
a61af66fc99e Initial load
duke
parents:
diff changeset
112 public OopHandle lookupOop(String objectName, String symbol) {
a61af66fc99e Initial load
duke
parents:
diff changeset
113 return null;
a61af66fc99e Initial load
duke
parents:
diff changeset
114 }
a61af66fc99e Initial load
duke
parents:
diff changeset
115
a61af66fc99e Initial load
duke
parents:
diff changeset
116 public ThreadProxy getThreadForIdentifierAddress(Address addr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
117 return null;
a61af66fc99e Initial load
duke
parents:
diff changeset
118 }
a61af66fc99e Initial load
duke
parents:
diff changeset
119
a61af66fc99e Initial load
duke
parents:
diff changeset
120 public ThreadProxy getThreadForThreadId(long id) {
a61af66fc99e Initial load
duke
parents:
diff changeset
121 return null;
a61af66fc99e Initial load
duke
parents:
diff changeset
122 }
a61af66fc99e Initial load
duke
parents:
diff changeset
123
a61af66fc99e Initial load
duke
parents:
diff changeset
124 public ReadResult readBytesFromProcess(long address, long numBytes)
a61af66fc99e Initial load
duke
parents:
diff changeset
125 throws DebuggerException {
a61af66fc99e Initial load
duke
parents:
diff changeset
126 throw new DebuggerException("Unimplemented");
a61af66fc99e Initial load
duke
parents:
diff changeset
127 }
a61af66fc99e Initial load
duke
parents:
diff changeset
128
a61af66fc99e Initial load
duke
parents:
diff changeset
129 public void writeBytesToProcess(long a, long b, byte[] buf)
a61af66fc99e Initial load
duke
parents:
diff changeset
130 throws DebuggerException {
a61af66fc99e Initial load
duke
parents:
diff changeset
131 throw new DebuggerException("Unimplemented");
a61af66fc99e Initial load
duke
parents:
diff changeset
132 }
a61af66fc99e Initial load
duke
parents:
diff changeset
133
a61af66fc99e Initial load
duke
parents:
diff changeset
134 //----------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
135 // Package-internal routines
a61af66fc99e Initial load
duke
parents:
diff changeset
136 //
a61af66fc99e Initial load
duke
parents:
diff changeset
137
a61af66fc99e Initial load
duke
parents:
diff changeset
138 String addressToString(DummyAddress addr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
139 StringBuffer buf = new StringBuffer();
a61af66fc99e Initial load
duke
parents:
diff changeset
140 buf.append("0x");
a61af66fc99e Initial load
duke
parents:
diff changeset
141 String val;
a61af66fc99e Initial load
duke
parents:
diff changeset
142 if (addr == null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
143 val = "0";
a61af66fc99e Initial load
duke
parents:
diff changeset
144 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
145 val = Long.toHexString(addr.getValue());
a61af66fc99e Initial load
duke
parents:
diff changeset
146 }
a61af66fc99e Initial load
duke
parents:
diff changeset
147 for (int i = 0; i < ((2 * machDesc.getAddressSize()) - val.length()); i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
148 buf.append('0');
a61af66fc99e Initial load
duke
parents:
diff changeset
149 }
a61af66fc99e Initial load
duke
parents:
diff changeset
150 buf.append(val);
a61af66fc99e Initial load
duke
parents:
diff changeset
151 return buf.toString();
a61af66fc99e Initial load
duke
parents:
diff changeset
152 }
a61af66fc99e Initial load
duke
parents:
diff changeset
153
a61af66fc99e Initial load
duke
parents:
diff changeset
154 //----------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
155 // Internals only below this point
a61af66fc99e Initial load
duke
parents:
diff changeset
156 //
a61af66fc99e Initial load
duke
parents:
diff changeset
157
a61af66fc99e Initial load
duke
parents:
diff changeset
158 private int charToNibble(char ascii) throws NumberFormatException {
a61af66fc99e Initial load
duke
parents:
diff changeset
159 if (ascii >= '0' && ascii <= '9') {
a61af66fc99e Initial load
duke
parents:
diff changeset
160 return ascii - '0';
a61af66fc99e Initial load
duke
parents:
diff changeset
161 } else if (ascii >= 'A' && ascii <= 'F') {
a61af66fc99e Initial load
duke
parents:
diff changeset
162 return 10 + ascii - 'A';
a61af66fc99e Initial load
duke
parents:
diff changeset
163 } else if (ascii >= 'a' && ascii <= 'f') {
a61af66fc99e Initial load
duke
parents:
diff changeset
164 return 10 + ascii - 'a';
a61af66fc99e Initial load
duke
parents:
diff changeset
165 }
a61af66fc99e Initial load
duke
parents:
diff changeset
166 throw new NumberFormatException(new Character(ascii).toString());
a61af66fc99e Initial load
duke
parents:
diff changeset
167 }
a61af66fc99e Initial load
duke
parents:
diff changeset
168 }