annotate agent/src/share/classes/sun/jvm/hotspot/debugger/windbg/WindbgDebuggerLocal.java @ 2072:d6cd0d55d0b5

6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process" Summary: Change ExportDirectoryTableImpl to return the 'Export RVA' field without modification. Read 'Base Of Data' field in optional header when PE32 format COFF file is read. Refine search for dbgeng.dll and dbghelp.dll. Other cleanups. Reviewed-by: swamyv, poonam
author dcubed
date Thu, 23 Dec 2010 07:58:35 -0800
parents c18cbe5936b8
children 8e47bac5643a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
2072
d6cd0d55d0b5 6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents: 1552
diff changeset
2 * Copyright (c) 2002, 2010, 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: 196
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 196
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: 196
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.debugger.windbg;
a61af66fc99e Initial load
duke
parents:
diff changeset
26
a61af66fc99e Initial load
duke
parents:
diff changeset
27 import java.io.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
28 import java.net.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
29 import java.util.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
30 import sun.jvm.hotspot.debugger.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
31 import sun.jvm.hotspot.debugger.amd64.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
32 import sun.jvm.hotspot.debugger.x86.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
33 import sun.jvm.hotspot.debugger.ia64.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
34 import sun.jvm.hotspot.debugger.windbg.amd64.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
35 import sun.jvm.hotspot.debugger.windbg.x86.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
36 import sun.jvm.hotspot.debugger.windbg.ia64.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
37 import sun.jvm.hotspot.debugger.win32.coff.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
38 import sun.jvm.hotspot.debugger.cdbg.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
39 import sun.jvm.hotspot.debugger.cdbg.basic.BasicDebugEvent;
a61af66fc99e Initial load
duke
parents:
diff changeset
40 import sun.jvm.hotspot.utilities.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
41 import sun.jvm.hotspot.utilities.memo.*;
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
42 import sun.jvm.hotspot.runtime.*;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
43
a61af66fc99e Initial load
duke
parents:
diff changeset
44 /** <P> An implementation of the JVMDebugger interface which talks to
a61af66fc99e Initial load
duke
parents:
diff changeset
45 windbg and symbol table management is done in Java. </P>
a61af66fc99e Initial load
duke
parents:
diff changeset
46
a61af66fc99e Initial load
duke
parents:
diff changeset
47 <P> <B>NOTE</B> that since we have the notion of fetching "Java
a61af66fc99e Initial load
duke
parents:
diff changeset
48 primitive types" from the remote process (which might have
a61af66fc99e Initial load
duke
parents:
diff changeset
49 different sizes than we expect) we have a bootstrapping
a61af66fc99e Initial load
duke
parents:
diff changeset
50 problem. We need to know the sizes of these types before we can
a61af66fc99e Initial load
duke
parents:
diff changeset
51 fetch them. The current implementation solves this problem by
a61af66fc99e Initial load
duke
parents:
diff changeset
52 requiring that it be configured with these type sizes before they
a61af66fc99e Initial load
duke
parents:
diff changeset
53 can be fetched. The readJ(Type) routines here will throw a
a61af66fc99e Initial load
duke
parents:
diff changeset
54 RuntimeException if they are called before the debugger is
a61af66fc99e Initial load
duke
parents:
diff changeset
55 configured with the Java primitive type sizes. </P> */
a61af66fc99e Initial load
duke
parents:
diff changeset
56
a61af66fc99e Initial load
duke
parents:
diff changeset
57 public class WindbgDebuggerLocal extends DebuggerBase implements WindbgDebugger {
a61af66fc99e Initial load
duke
parents:
diff changeset
58 private PageCache cache;
a61af66fc99e Initial load
duke
parents:
diff changeset
59 private boolean attached;
a61af66fc99e Initial load
duke
parents:
diff changeset
60 private boolean isCore;
a61af66fc99e Initial load
duke
parents:
diff changeset
61
a61af66fc99e Initial load
duke
parents:
diff changeset
62 // Symbol lookup support
a61af66fc99e Initial load
duke
parents:
diff changeset
63 // This is a map of library names to DLLs
a61af66fc99e Initial load
duke
parents:
diff changeset
64 private Map nameToDllMap;
a61af66fc99e Initial load
duke
parents:
diff changeset
65
a61af66fc99e Initial load
duke
parents:
diff changeset
66 // C/C++ debugging support
a61af66fc99e Initial load
duke
parents:
diff changeset
67 private List/*<LoadObject>*/ loadObjects;
a61af66fc99e Initial load
duke
parents:
diff changeset
68 private CDebugger cdbg;
a61af66fc99e Initial load
duke
parents:
diff changeset
69
a61af66fc99e Initial load
duke
parents:
diff changeset
70 // thread access
a61af66fc99e Initial load
duke
parents:
diff changeset
71 private Map threadIntegerRegisterSet;
a61af66fc99e Initial load
duke
parents:
diff changeset
72 private List threadList;
a61af66fc99e Initial load
duke
parents:
diff changeset
73
a61af66fc99e Initial load
duke
parents:
diff changeset
74 // windbg native interface pointers
a61af66fc99e Initial load
duke
parents:
diff changeset
75
a61af66fc99e Initial load
duke
parents:
diff changeset
76 private long ptrIDebugClient;
a61af66fc99e Initial load
duke
parents:
diff changeset
77 private long ptrIDebugControl;
a61af66fc99e Initial load
duke
parents:
diff changeset
78 private long ptrIDebugDataSpaces;
a61af66fc99e Initial load
duke
parents:
diff changeset
79 private long ptrIDebugOutputCallbacks;
a61af66fc99e Initial load
duke
parents:
diff changeset
80 private long ptrIDebugAdvanced;
a61af66fc99e Initial load
duke
parents:
diff changeset
81 private long ptrIDebugSymbols;
a61af66fc99e Initial load
duke
parents:
diff changeset
82 private long ptrIDebugSystemObjects;
a61af66fc99e Initial load
duke
parents:
diff changeset
83
a61af66fc99e Initial load
duke
parents:
diff changeset
84 private WindbgThreadFactory threadFactory;
a61af66fc99e Initial load
duke
parents:
diff changeset
85
a61af66fc99e Initial load
duke
parents:
diff changeset
86 //--------------------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
87 // Implementation of Debugger interface
a61af66fc99e Initial load
duke
parents:
diff changeset
88 //
a61af66fc99e Initial load
duke
parents:
diff changeset
89
a61af66fc99e Initial load
duke
parents:
diff changeset
90 /** <P> machDesc may not be null. </P>
a61af66fc99e Initial load
duke
parents:
diff changeset
91
a61af66fc99e Initial load
duke
parents:
diff changeset
92 <P> useCache should be set to true if debugging is being done
a61af66fc99e Initial load
duke
parents:
diff changeset
93 locally, and to false if the debugger is being created for the
a61af66fc99e Initial load
duke
parents:
diff changeset
94 purpose of supporting remote debugging. </P> */
a61af66fc99e Initial load
duke
parents:
diff changeset
95 public WindbgDebuggerLocal(MachineDescription machDesc,
a61af66fc99e Initial load
duke
parents:
diff changeset
96 boolean useCache) throws DebuggerException {
a61af66fc99e Initial load
duke
parents:
diff changeset
97 this.machDesc = machDesc;
a61af66fc99e Initial load
duke
parents:
diff changeset
98 utils = new DebuggerUtilities(machDesc.getAddressSize(), machDesc.isBigEndian()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
99 public void checkAlignment(long address, long alignment) {
a61af66fc99e Initial load
duke
parents:
diff changeset
100 // Need to override default checkAlignment because we need to
a61af66fc99e Initial load
duke
parents:
diff changeset
101 // relax alignment constraints on Windows/x86
a61af66fc99e Initial load
duke
parents:
diff changeset
102 if ( (address % alignment != 0)
a61af66fc99e Initial load
duke
parents:
diff changeset
103 &&(alignment != 8 || address % 4 != 0)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
104 throw new UnalignedAddressException(
a61af66fc99e Initial load
duke
parents:
diff changeset
105 "Trying to read at address: "
a61af66fc99e Initial load
duke
parents:
diff changeset
106 + addressValueToString(address)
a61af66fc99e Initial load
duke
parents:
diff changeset
107 + " with alignment: " + alignment,
a61af66fc99e Initial load
duke
parents:
diff changeset
108 address);
a61af66fc99e Initial load
duke
parents:
diff changeset
109 }
a61af66fc99e Initial load
duke
parents:
diff changeset
110 }
a61af66fc99e Initial load
duke
parents:
diff changeset
111 };
a61af66fc99e Initial load
duke
parents:
diff changeset
112
a61af66fc99e Initial load
duke
parents:
diff changeset
113 String cpu = PlatformInfo.getCPU();
a61af66fc99e Initial load
duke
parents:
diff changeset
114 if (cpu.equals("x86")) {
a61af66fc99e Initial load
duke
parents:
diff changeset
115 threadFactory = new WindbgX86ThreadFactory(this);
a61af66fc99e Initial load
duke
parents:
diff changeset
116 } else if (cpu.equals("amd64")) {
a61af66fc99e Initial load
duke
parents:
diff changeset
117 threadFactory = new WindbgAMD64ThreadFactory(this);
a61af66fc99e Initial load
duke
parents:
diff changeset
118 } else if (cpu.equals("ia64")) {
a61af66fc99e Initial load
duke
parents:
diff changeset
119 threadFactory = new WindbgIA64ThreadFactory(this);
a61af66fc99e Initial load
duke
parents:
diff changeset
120 }
a61af66fc99e Initial load
duke
parents:
diff changeset
121
a61af66fc99e Initial load
duke
parents:
diff changeset
122 if (useCache) {
a61af66fc99e Initial load
duke
parents:
diff changeset
123 // Cache portion of the remote process's address space.
a61af66fc99e Initial load
duke
parents:
diff changeset
124 // Fetching data over the socket connection to dbx is slow.
a61af66fc99e Initial load
duke
parents:
diff changeset
125 // Might be faster if we were using a binary protocol to talk to
a61af66fc99e Initial load
duke
parents:
diff changeset
126 // dbx, but would have to test. For now, this cache works best
a61af66fc99e Initial load
duke
parents:
diff changeset
127 // if it covers the entire heap of the remote process. FIXME: at
a61af66fc99e Initial load
duke
parents:
diff changeset
128 // least should make this tunable from the outside, i.e., via
a61af66fc99e Initial load
duke
parents:
diff changeset
129 // the UI. This is a cache of 4096 4K pages, or 16 MB. The page
a61af66fc99e Initial load
duke
parents:
diff changeset
130 // size must be adjusted to be the hardware's page size.
a61af66fc99e Initial load
duke
parents:
diff changeset
131 // (FIXME: should pick this up from the debugger.)
a61af66fc99e Initial load
duke
parents:
diff changeset
132 initCache(4096, 4096);
a61af66fc99e Initial load
duke
parents:
diff changeset
133 }
a61af66fc99e Initial load
duke
parents:
diff changeset
134 // FIXME: add instantiation of thread factory
a61af66fc99e Initial load
duke
parents:
diff changeset
135
a61af66fc99e Initial load
duke
parents:
diff changeset
136 }
a61af66fc99e Initial load
duke
parents:
diff changeset
137
a61af66fc99e Initial load
duke
parents:
diff changeset
138 /** From the Debugger interface via JVMDebugger */
a61af66fc99e Initial load
duke
parents:
diff changeset
139 public boolean hasProcessList() throws DebuggerException {
a61af66fc99e Initial load
duke
parents:
diff changeset
140 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
141 }
a61af66fc99e Initial load
duke
parents:
diff changeset
142
a61af66fc99e Initial load
duke
parents:
diff changeset
143 /** From the Debugger interface via JVMDebugger */
a61af66fc99e Initial load
duke
parents:
diff changeset
144 public List getProcessList() throws DebuggerException {
a61af66fc99e Initial load
duke
parents:
diff changeset
145 return null;
a61af66fc99e Initial load
duke
parents:
diff changeset
146 }
a61af66fc99e Initial load
duke
parents:
diff changeset
147
a61af66fc99e Initial load
duke
parents:
diff changeset
148
a61af66fc99e Initial load
duke
parents:
diff changeset
149 /** From the Debugger interface via JVMDebugger */
a61af66fc99e Initial load
duke
parents:
diff changeset
150 public synchronized void attach(int processID) throws DebuggerException {
a61af66fc99e Initial load
duke
parents:
diff changeset
151 attachInit();
a61af66fc99e Initial load
duke
parents:
diff changeset
152 attach0(processID);
a61af66fc99e Initial load
duke
parents:
diff changeset
153 attached = true;
a61af66fc99e Initial load
duke
parents:
diff changeset
154 isCore = false;
a61af66fc99e Initial load
duke
parents:
diff changeset
155 }
a61af66fc99e Initial load
duke
parents:
diff changeset
156
a61af66fc99e Initial load
duke
parents:
diff changeset
157 /** From the Debugger interface via JVMDebugger */
a61af66fc99e Initial load
duke
parents:
diff changeset
158 public synchronized void attach(String executableName, String coreFileName) throws DebuggerException {
a61af66fc99e Initial load
duke
parents:
diff changeset
159 attachInit();
a61af66fc99e Initial load
duke
parents:
diff changeset
160 attach0(executableName, coreFileName);
a61af66fc99e Initial load
duke
parents:
diff changeset
161 attached = true;
a61af66fc99e Initial load
duke
parents:
diff changeset
162 isCore = true;
a61af66fc99e Initial load
duke
parents:
diff changeset
163 }
a61af66fc99e Initial load
duke
parents:
diff changeset
164
a61af66fc99e Initial load
duke
parents:
diff changeset
165 public List getLoadObjectList() {
a61af66fc99e Initial load
duke
parents:
diff changeset
166 requireAttach();
a61af66fc99e Initial load
duke
parents:
diff changeset
167 return loadObjects;
a61af66fc99e Initial load
duke
parents:
diff changeset
168 }
a61af66fc99e Initial load
duke
parents:
diff changeset
169
a61af66fc99e Initial load
duke
parents:
diff changeset
170 /** From the Debugger interface via JVMDebugger */
a61af66fc99e Initial load
duke
parents:
diff changeset
171 public synchronized boolean detach() {
a61af66fc99e Initial load
duke
parents:
diff changeset
172 if ( ! attached)
a61af66fc99e Initial load
duke
parents:
diff changeset
173 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
174
a61af66fc99e Initial load
duke
parents:
diff changeset
175 // Close all open DLLs
a61af66fc99e Initial load
duke
parents:
diff changeset
176 if (nameToDllMap != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
177 for (Iterator iter = nameToDllMap.values().iterator(); iter.hasNext(); ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
178 DLL dll = (DLL) iter.next();
a61af66fc99e Initial load
duke
parents:
diff changeset
179 dll.close();
a61af66fc99e Initial load
duke
parents:
diff changeset
180 }
a61af66fc99e Initial load
duke
parents:
diff changeset
181 nameToDllMap = null;
a61af66fc99e Initial load
duke
parents:
diff changeset
182 loadObjects = null;
a61af66fc99e Initial load
duke
parents:
diff changeset
183 }
a61af66fc99e Initial load
duke
parents:
diff changeset
184
a61af66fc99e Initial load
duke
parents:
diff changeset
185 cdbg = null;
a61af66fc99e Initial load
duke
parents:
diff changeset
186 clearCache();
a61af66fc99e Initial load
duke
parents:
diff changeset
187
a61af66fc99e Initial load
duke
parents:
diff changeset
188 threadIntegerRegisterSet = null;
a61af66fc99e Initial load
duke
parents:
diff changeset
189 threadList = null;
a61af66fc99e Initial load
duke
parents:
diff changeset
190 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
191 detach0();
a61af66fc99e Initial load
duke
parents:
diff changeset
192 } finally {
a61af66fc99e Initial load
duke
parents:
diff changeset
193 attached = false;
a61af66fc99e Initial load
duke
parents:
diff changeset
194 resetNativePointers();
a61af66fc99e Initial load
duke
parents:
diff changeset
195 }
a61af66fc99e Initial load
duke
parents:
diff changeset
196 return true;
a61af66fc99e Initial load
duke
parents:
diff changeset
197 }
a61af66fc99e Initial load
duke
parents:
diff changeset
198
a61af66fc99e Initial load
duke
parents:
diff changeset
199
a61af66fc99e Initial load
duke
parents:
diff changeset
200 /** From the Debugger interface via JVMDebugger */
a61af66fc99e Initial load
duke
parents:
diff changeset
201 public Address parseAddress(String addressString) throws NumberFormatException {
a61af66fc99e Initial load
duke
parents:
diff changeset
202 return newAddress(utils.scanAddress(addressString));
a61af66fc99e Initial load
duke
parents:
diff changeset
203 }
a61af66fc99e Initial load
duke
parents:
diff changeset
204
a61af66fc99e Initial load
duke
parents:
diff changeset
205 /** From the Debugger interface via JVMDebugger */
a61af66fc99e Initial load
duke
parents:
diff changeset
206 public String getOS() {
a61af66fc99e Initial load
duke
parents:
diff changeset
207 return PlatformInfo.getOS();
a61af66fc99e Initial load
duke
parents:
diff changeset
208 }
a61af66fc99e Initial load
duke
parents:
diff changeset
209
a61af66fc99e Initial load
duke
parents:
diff changeset
210 /** From the Debugger interface via JVMDebugger */
a61af66fc99e Initial load
duke
parents:
diff changeset
211 public String getCPU() {
a61af66fc99e Initial load
duke
parents:
diff changeset
212 return PlatformInfo.getCPU();
a61af66fc99e Initial load
duke
parents:
diff changeset
213 }
a61af66fc99e Initial load
duke
parents:
diff changeset
214
a61af66fc99e Initial load
duke
parents:
diff changeset
215 public boolean hasConsole() throws DebuggerException {
a61af66fc99e Initial load
duke
parents:
diff changeset
216 return true;
a61af66fc99e Initial load
duke
parents:
diff changeset
217 }
a61af66fc99e Initial load
duke
parents:
diff changeset
218
a61af66fc99e Initial load
duke
parents:
diff changeset
219 public synchronized String consoleExecuteCommand(String cmd) throws DebuggerException {
a61af66fc99e Initial load
duke
parents:
diff changeset
220 requireAttach();
a61af66fc99e Initial load
duke
parents:
diff changeset
221 if (! attached) {
a61af66fc99e Initial load
duke
parents:
diff changeset
222 throw new DebuggerException("debugger not yet attached to a Dr. Watson dump!");
a61af66fc99e Initial load
duke
parents:
diff changeset
223 }
a61af66fc99e Initial load
duke
parents:
diff changeset
224
a61af66fc99e Initial load
duke
parents:
diff changeset
225 return consoleExecuteCommand0(cmd);
a61af66fc99e Initial load
duke
parents:
diff changeset
226 }
a61af66fc99e Initial load
duke
parents:
diff changeset
227
a61af66fc99e Initial load
duke
parents:
diff changeset
228 public String getConsolePrompt() throws DebuggerException {
a61af66fc99e Initial load
duke
parents:
diff changeset
229 return "(windbg)";
a61af66fc99e Initial load
duke
parents:
diff changeset
230 }
a61af66fc99e Initial load
duke
parents:
diff changeset
231
a61af66fc99e Initial load
duke
parents:
diff changeset
232 public CDebugger getCDebugger() throws DebuggerException {
a61af66fc99e Initial load
duke
parents:
diff changeset
233 if (cdbg == null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
234 // FIXME: CDebugger is not yet supported for IA64 because
a61af66fc99e Initial load
duke
parents:
diff changeset
235 // of native stack walking issues.
a61af66fc99e Initial load
duke
parents:
diff changeset
236 if (! getCPU().equals("ia64")) {
a61af66fc99e Initial load
duke
parents:
diff changeset
237 cdbg = new WindbgCDebugger(this);
a61af66fc99e Initial load
duke
parents:
diff changeset
238 }
a61af66fc99e Initial load
duke
parents:
diff changeset
239 }
a61af66fc99e Initial load
duke
parents:
diff changeset
240 return cdbg;
a61af66fc99e Initial load
duke
parents:
diff changeset
241 }
a61af66fc99e Initial load
duke
parents:
diff changeset
242
a61af66fc99e Initial load
duke
parents:
diff changeset
243 /** From the SymbolLookup interface via Debugger and JVMDebugger */
a61af66fc99e Initial load
duke
parents:
diff changeset
244 public synchronized Address lookup(String objectName, String symbol) {
a61af66fc99e Initial load
duke
parents:
diff changeset
245 requireAttach();
a61af66fc99e Initial load
duke
parents:
diff changeset
246 return newAddress(lookupByName(objectName, symbol));
a61af66fc99e Initial load
duke
parents:
diff changeset
247 }
a61af66fc99e Initial load
duke
parents:
diff changeset
248
a61af66fc99e Initial load
duke
parents:
diff changeset
249 /** From the SymbolLookup interface via Debugger and JVMDebugger */
a61af66fc99e Initial load
duke
parents:
diff changeset
250 public synchronized OopHandle lookupOop(String objectName, String symbol) {
a61af66fc99e Initial load
duke
parents:
diff changeset
251 Address addr = lookup(objectName, symbol);
a61af66fc99e Initial load
duke
parents:
diff changeset
252 if (addr == null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
253 return null;
a61af66fc99e Initial load
duke
parents:
diff changeset
254 }
a61af66fc99e Initial load
duke
parents:
diff changeset
255 return addr.addOffsetToAsOopHandle(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
256 }
a61af66fc99e Initial load
duke
parents:
diff changeset
257
a61af66fc99e Initial load
duke
parents:
diff changeset
258 public synchronized ClosestSymbol lookup(long address) {
a61af66fc99e Initial load
duke
parents:
diff changeset
259 return lookupByAddress0(address);
a61af66fc99e Initial load
duke
parents:
diff changeset
260 }
a61af66fc99e Initial load
duke
parents:
diff changeset
261
a61af66fc99e Initial load
duke
parents:
diff changeset
262 /** From the Debugger interface */
a61af66fc99e Initial load
duke
parents:
diff changeset
263 public MachineDescription getMachineDescription() {
a61af66fc99e Initial load
duke
parents:
diff changeset
264 return machDesc;
a61af66fc99e Initial load
duke
parents:
diff changeset
265 }
a61af66fc99e Initial load
duke
parents:
diff changeset
266
a61af66fc99e Initial load
duke
parents:
diff changeset
267 //--------------------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
268 // Implementation of ThreadAccess interface
a61af66fc99e Initial load
duke
parents:
diff changeset
269 //
a61af66fc99e Initial load
duke
parents:
diff changeset
270
a61af66fc99e Initial load
duke
parents:
diff changeset
271
a61af66fc99e Initial load
duke
parents:
diff changeset
272 /** From the ThreadAccess interface via Debugger and JVMDebugger */
a61af66fc99e Initial load
duke
parents:
diff changeset
273 public ThreadProxy getThreadForIdentifierAddress(Address addr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
274 return threadFactory.createThreadWrapper(addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
275 }
a61af66fc99e Initial load
duke
parents:
diff changeset
276
a61af66fc99e Initial load
duke
parents:
diff changeset
277 public ThreadProxy getThreadForThreadId(long handle) {
a61af66fc99e Initial load
duke
parents:
diff changeset
278 // with windbg we can't make out using handle
a61af66fc99e Initial load
duke
parents:
diff changeset
279 throw new DebuggerException("Unimplemented!");
a61af66fc99e Initial load
duke
parents:
diff changeset
280 }
a61af66fc99e Initial load
duke
parents:
diff changeset
281
a61af66fc99e Initial load
duke
parents:
diff changeset
282 public long getThreadIdFromSysId(long sysId) throws DebuggerException {
a61af66fc99e Initial load
duke
parents:
diff changeset
283 requireAttach();
a61af66fc99e Initial load
duke
parents:
diff changeset
284 return getThreadIdFromSysId0(sysId);
a61af66fc99e Initial load
duke
parents:
diff changeset
285 }
a61af66fc99e Initial load
duke
parents:
diff changeset
286
a61af66fc99e Initial load
duke
parents:
diff changeset
287 //----------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
288 // Overridden from DebuggerBase because we need to relax alignment
a61af66fc99e Initial load
duke
parents:
diff changeset
289 // constraints on x86
a61af66fc99e Initial load
duke
parents:
diff changeset
290
a61af66fc99e Initial load
duke
parents:
diff changeset
291 public long readJLong(long address)
a61af66fc99e Initial load
duke
parents:
diff changeset
292 throws UnmappedAddressException, UnalignedAddressException {
a61af66fc99e Initial load
duke
parents:
diff changeset
293 checkJavaConfigured();
a61af66fc99e Initial load
duke
parents:
diff changeset
294 // FIXME: allow this to be configurable. Undesirable to add a
a61af66fc99e Initial load
duke
parents:
diff changeset
295 // dependency on the runtime package here, though, since this
a61af66fc99e Initial load
duke
parents:
diff changeset
296 // package should be strictly underneath it.
a61af66fc99e Initial load
duke
parents:
diff changeset
297 // utils.checkAlignment(address, jlongSize);
a61af66fc99e Initial load
duke
parents:
diff changeset
298 utils.checkAlignment(address, jintSize);
a61af66fc99e Initial load
duke
parents:
diff changeset
299 byte[] data = readBytes(address, jlongSize);
a61af66fc99e Initial load
duke
parents:
diff changeset
300 return utils.dataToJLong(data, jlongSize);
a61af66fc99e Initial load
duke
parents:
diff changeset
301 }
a61af66fc99e Initial load
duke
parents:
diff changeset
302
a61af66fc99e Initial load
duke
parents:
diff changeset
303 //--------------------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
304 // Internal routines (for implementation of WindbgAddress).
a61af66fc99e Initial load
duke
parents:
diff changeset
305 // These must not be called until the MachineDescription has been set up.
a61af66fc99e Initial load
duke
parents:
diff changeset
306 //
a61af66fc99e Initial load
duke
parents:
diff changeset
307
a61af66fc99e Initial load
duke
parents:
diff changeset
308 /** From the WindbgDebugger interface */
a61af66fc99e Initial load
duke
parents:
diff changeset
309 public String addressValueToString(long address) {
a61af66fc99e Initial load
duke
parents:
diff changeset
310 return utils.addressValueToString(address);
a61af66fc99e Initial load
duke
parents:
diff changeset
311 }
a61af66fc99e Initial load
duke
parents:
diff changeset
312
a61af66fc99e Initial load
duke
parents:
diff changeset
313 /** From the WindbgDebugger interface */
a61af66fc99e Initial load
duke
parents:
diff changeset
314 public WindbgAddress readAddress(long address)
a61af66fc99e Initial load
duke
parents:
diff changeset
315 throws UnmappedAddressException, UnalignedAddressException {
a61af66fc99e Initial load
duke
parents:
diff changeset
316 return (WindbgAddress) newAddress(readAddressValue(address));
a61af66fc99e Initial load
duke
parents:
diff changeset
317 }
a61af66fc99e Initial load
duke
parents:
diff changeset
318
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
319 public WindbgAddress readCompOopAddress(long address)
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
320 throws UnmappedAddressException, UnalignedAddressException {
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
321 return (WindbgAddress) newAddress(readCompOopAddressValue(address));
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
322 }
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
323
0
a61af66fc99e Initial load
duke
parents:
diff changeset
324 /** From the WindbgDebugger interface */
a61af66fc99e Initial load
duke
parents:
diff changeset
325 public WindbgOopHandle readOopHandle(long address)
a61af66fc99e Initial load
duke
parents:
diff changeset
326 throws UnmappedAddressException, UnalignedAddressException, NotInHeapException {
a61af66fc99e Initial load
duke
parents:
diff changeset
327 long value = readAddressValue(address);
a61af66fc99e Initial load
duke
parents:
diff changeset
328 return (value == 0 ? null : new WindbgOopHandle(this, value));
a61af66fc99e Initial load
duke
parents:
diff changeset
329 }
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
330 public WindbgOopHandle readCompOopHandle(long address)
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
331 throws UnmappedAddressException, UnalignedAddressException, NotInHeapException {
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
332 long value = readCompOopAddressValue(address);
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
333 return (value == 0 ? null : new WindbgOopHandle(this, value));
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
334 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
335
a61af66fc99e Initial load
duke
parents:
diff changeset
336 /** From the WindbgDebugger interface */
a61af66fc99e Initial load
duke
parents:
diff changeset
337 public int getAddressSize() {
a61af66fc99e Initial load
duke
parents:
diff changeset
338 return (int) machDesc.getAddressSize();
a61af66fc99e Initial load
duke
parents:
diff changeset
339 }
a61af66fc99e Initial load
duke
parents:
diff changeset
340
a61af66fc99e Initial load
duke
parents:
diff changeset
341 //--------------------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
342 // Thread context access
a61af66fc99e Initial load
duke
parents:
diff changeset
343 //
a61af66fc99e Initial load
duke
parents:
diff changeset
344
a61af66fc99e Initial load
duke
parents:
diff changeset
345 private synchronized void setThreadIntegerRegisterSet(long threadId,
a61af66fc99e Initial load
duke
parents:
diff changeset
346 long[] regs) {
a61af66fc99e Initial load
duke
parents:
diff changeset
347 threadIntegerRegisterSet.put(new Long(threadId), regs);
a61af66fc99e Initial load
duke
parents:
diff changeset
348 }
a61af66fc99e Initial load
duke
parents:
diff changeset
349
a61af66fc99e Initial load
duke
parents:
diff changeset
350 private synchronized void addThread(long sysId) {
a61af66fc99e Initial load
duke
parents:
diff changeset
351 threadList.add(threadFactory.createThreadWrapper(sysId));
a61af66fc99e Initial load
duke
parents:
diff changeset
352 }
a61af66fc99e Initial load
duke
parents:
diff changeset
353
a61af66fc99e Initial load
duke
parents:
diff changeset
354 public synchronized long[] getThreadIntegerRegisterSet(long threadId)
a61af66fc99e Initial load
duke
parents:
diff changeset
355 throws DebuggerException {
a61af66fc99e Initial load
duke
parents:
diff changeset
356 requireAttach();
a61af66fc99e Initial load
duke
parents:
diff changeset
357 return (long[]) threadIntegerRegisterSet.get(new Long(threadId));
a61af66fc99e Initial load
duke
parents:
diff changeset
358 }
a61af66fc99e Initial load
duke
parents:
diff changeset
359
a61af66fc99e Initial load
duke
parents:
diff changeset
360 public synchronized List getThreadList() throws DebuggerException {
a61af66fc99e Initial load
duke
parents:
diff changeset
361 requireAttach();
a61af66fc99e Initial load
duke
parents:
diff changeset
362 return threadList;
a61af66fc99e Initial load
duke
parents:
diff changeset
363 }
a61af66fc99e Initial load
duke
parents:
diff changeset
364
a61af66fc99e Initial load
duke
parents:
diff changeset
365 private String findFullPath(String file) {
a61af66fc99e Initial load
duke
parents:
diff changeset
366 File f = new File(file);
a61af66fc99e Initial load
duke
parents:
diff changeset
367 if (f.exists()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
368 return file;
a61af66fc99e Initial load
duke
parents:
diff changeset
369 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
370 // remove path part, if any.
a61af66fc99e Initial load
duke
parents:
diff changeset
371 file = f.getName();
a61af66fc99e Initial load
duke
parents:
diff changeset
372 StringTokenizer st = new StringTokenizer(imagePath, File.pathSeparator);
a61af66fc99e Initial load
duke
parents:
diff changeset
373 while (st.hasMoreTokens()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
374 f = new File(st.nextToken(), file);
a61af66fc99e Initial load
duke
parents:
diff changeset
375 if (f.exists()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
376 return f.getPath();
a61af66fc99e Initial load
duke
parents:
diff changeset
377 }
a61af66fc99e Initial load
duke
parents:
diff changeset
378 }
a61af66fc99e Initial load
duke
parents:
diff changeset
379 }
a61af66fc99e Initial load
duke
parents:
diff changeset
380 return null;
a61af66fc99e Initial load
duke
parents:
diff changeset
381 }
a61af66fc99e Initial load
duke
parents:
diff changeset
382
a61af66fc99e Initial load
duke
parents:
diff changeset
383 private synchronized void addLoadObject(String file, long size, long base) {
a61af66fc99e Initial load
duke
parents:
diff changeset
384 String path = findFullPath(file);
a61af66fc99e Initial load
duke
parents:
diff changeset
385 if (path != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
386 DLL dll = null;
a61af66fc99e Initial load
duke
parents:
diff changeset
387 if (useNativeLookup) {
a61af66fc99e Initial load
duke
parents:
diff changeset
388 dll = new DLL(this, path, size,newAddress(base)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
389 public ClosestSymbol closestSymbolToPC(Address pcAsAddr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
390 long pc = getAddressValue(pcAsAddr);
a61af66fc99e Initial load
duke
parents:
diff changeset
391 ClosestSymbol sym = lookupByAddress0(pc);
a61af66fc99e Initial load
duke
parents:
diff changeset
392 if (sym == null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
393 return super.closestSymbolToPC(pcAsAddr);
a61af66fc99e Initial load
duke
parents:
diff changeset
394 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
395 return sym;
a61af66fc99e Initial load
duke
parents:
diff changeset
396 }
a61af66fc99e Initial load
duke
parents:
diff changeset
397 }
a61af66fc99e Initial load
duke
parents:
diff changeset
398 };
a61af66fc99e Initial load
duke
parents:
diff changeset
399 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
400 dll = new DLL(this, path, size, newAddress(base));
a61af66fc99e Initial load
duke
parents:
diff changeset
401 }
a61af66fc99e Initial load
duke
parents:
diff changeset
402 loadObjects.add(dll);
a61af66fc99e Initial load
duke
parents:
diff changeset
403 nameToDllMap.put(new File(file).getName(), dll);
a61af66fc99e Initial load
duke
parents:
diff changeset
404 }
a61af66fc99e Initial load
duke
parents:
diff changeset
405 }
a61af66fc99e Initial load
duke
parents:
diff changeset
406
a61af66fc99e Initial load
duke
parents:
diff changeset
407 //--------------------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
408 // Address access
a61af66fc99e Initial load
duke
parents:
diff changeset
409 //
a61af66fc99e Initial load
duke
parents:
diff changeset
410
a61af66fc99e Initial load
duke
parents:
diff changeset
411 /** From the Debugger interface */
a61af66fc99e Initial load
duke
parents:
diff changeset
412 public long getAddressValue(Address addr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
413 if (addr == null) return 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
414 return ((WindbgAddress) addr).getValue();
a61af66fc99e Initial load
duke
parents:
diff changeset
415 }
a61af66fc99e Initial load
duke
parents:
diff changeset
416
a61af66fc99e Initial load
duke
parents:
diff changeset
417 /** From the WindbgDebugger interface */
a61af66fc99e Initial load
duke
parents:
diff changeset
418 public Address newAddress(long value) {
a61af66fc99e Initial load
duke
parents:
diff changeset
419 if (value == 0) return null;
a61af66fc99e Initial load
duke
parents:
diff changeset
420 return new WindbgAddress(this, value);
a61af66fc99e Initial load
duke
parents:
diff changeset
421 }
a61af66fc99e Initial load
duke
parents:
diff changeset
422
a61af66fc99e Initial load
duke
parents:
diff changeset
423 //--------------------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
424 // Internals only below this point
a61af66fc99e Initial load
duke
parents:
diff changeset
425 //
a61af66fc99e Initial load
duke
parents:
diff changeset
426
a61af66fc99e Initial load
duke
parents:
diff changeset
427 // attach/detach helpers
a61af66fc99e Initial load
duke
parents:
diff changeset
428 private void checkAttached() {
a61af66fc99e Initial load
duke
parents:
diff changeset
429 if (attached) {
a61af66fc99e Initial load
duke
parents:
diff changeset
430 String msg = (isCore)? "already attached to a Dr. Watson dump!" :
a61af66fc99e Initial load
duke
parents:
diff changeset
431 "already attached to a process!";
a61af66fc99e Initial load
duke
parents:
diff changeset
432 throw new DebuggerException(msg);
a61af66fc99e Initial load
duke
parents:
diff changeset
433 }
a61af66fc99e Initial load
duke
parents:
diff changeset
434 }
a61af66fc99e Initial load
duke
parents:
diff changeset
435
a61af66fc99e Initial load
duke
parents:
diff changeset
436 private void requireAttach() {
a61af66fc99e Initial load
duke
parents:
diff changeset
437 if (!attached) {
a61af66fc99e Initial load
duke
parents:
diff changeset
438 throw new RuntimeException("not attached to a process or Dr Watson dump");
a61af66fc99e Initial load
duke
parents:
diff changeset
439 }
a61af66fc99e Initial load
duke
parents:
diff changeset
440 }
a61af66fc99e Initial load
duke
parents:
diff changeset
441
a61af66fc99e Initial load
duke
parents:
diff changeset
442 private void attachInit() {
a61af66fc99e Initial load
duke
parents:
diff changeset
443 checkAttached();
a61af66fc99e Initial load
duke
parents:
diff changeset
444 loadObjects = new ArrayList();
a61af66fc99e Initial load
duke
parents:
diff changeset
445 nameToDllMap = new HashMap();
a61af66fc99e Initial load
duke
parents:
diff changeset
446 threadIntegerRegisterSet = new HashMap();
a61af66fc99e Initial load
duke
parents:
diff changeset
447 threadList = new ArrayList();
a61af66fc99e Initial load
duke
parents:
diff changeset
448 }
a61af66fc99e Initial load
duke
parents:
diff changeset
449
a61af66fc99e Initial load
duke
parents:
diff changeset
450 private void resetNativePointers() {
a61af66fc99e Initial load
duke
parents:
diff changeset
451 ptrIDebugClient = 0L;
a61af66fc99e Initial load
duke
parents:
diff changeset
452 ptrIDebugControl = 0L;
a61af66fc99e Initial load
duke
parents:
diff changeset
453 ptrIDebugDataSpaces = 0L;
a61af66fc99e Initial load
duke
parents:
diff changeset
454 ptrIDebugOutputCallbacks = 0L;
a61af66fc99e Initial load
duke
parents:
diff changeset
455 ptrIDebugAdvanced = 0L;
a61af66fc99e Initial load
duke
parents:
diff changeset
456 ptrIDebugSymbols = 0L;
a61af66fc99e Initial load
duke
parents:
diff changeset
457 ptrIDebugSystemObjects = 0L;
a61af66fc99e Initial load
duke
parents:
diff changeset
458 }
a61af66fc99e Initial load
duke
parents:
diff changeset
459
a61af66fc99e Initial load
duke
parents:
diff changeset
460 synchronized long lookupByName(String objectName, String symbol) {
a61af66fc99e Initial load
duke
parents:
diff changeset
461 long res = 0L;
a61af66fc99e Initial load
duke
parents:
diff changeset
462 if (useNativeLookup) {
a61af66fc99e Initial load
duke
parents:
diff changeset
463 res = lookupByName0(objectName, symbol);
a61af66fc99e Initial load
duke
parents:
diff changeset
464 if (res != 0L) {
a61af66fc99e Initial load
duke
parents:
diff changeset
465 return res;
a61af66fc99e Initial load
duke
parents:
diff changeset
466 } // else fallthru...
a61af66fc99e Initial load
duke
parents:
diff changeset
467 }
a61af66fc99e Initial load
duke
parents:
diff changeset
468
a61af66fc99e Initial load
duke
parents:
diff changeset
469 DLL dll = (DLL) nameToDllMap.get(objectName);
a61af66fc99e Initial load
duke
parents:
diff changeset
470 // The DLL can be null because we use this to search through known
a61af66fc99e Initial load
duke
parents:
diff changeset
471 // DLLs in HotSpotTypeDataBase (for example)
a61af66fc99e Initial load
duke
parents:
diff changeset
472 if (dll != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
473 WindbgAddress addr = (WindbgAddress) dll.lookupSymbol(symbol);
a61af66fc99e Initial load
duke
parents:
diff changeset
474 if (addr != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
475 return addr.getValue();
a61af66fc99e Initial load
duke
parents:
diff changeset
476 }
a61af66fc99e Initial load
duke
parents:
diff changeset
477 }
a61af66fc99e Initial load
duke
parents:
diff changeset
478 return 0L;
a61af66fc99e Initial load
duke
parents:
diff changeset
479 }
a61af66fc99e Initial load
duke
parents:
diff changeset
480
a61af66fc99e Initial load
duke
parents:
diff changeset
481 /** This reads bytes from the remote process. */
a61af66fc99e Initial load
duke
parents:
diff changeset
482 public synchronized ReadResult readBytesFromProcess(long address, long numBytes)
a61af66fc99e Initial load
duke
parents:
diff changeset
483 throws UnmappedAddressException, DebuggerException {
a61af66fc99e Initial load
duke
parents:
diff changeset
484 requireAttach();
a61af66fc99e Initial load
duke
parents:
diff changeset
485 byte[] res = readBytesFromProcess0(address, numBytes);
a61af66fc99e Initial load
duke
parents:
diff changeset
486 if(res != null)
a61af66fc99e Initial load
duke
parents:
diff changeset
487 return new ReadResult(res);
a61af66fc99e Initial load
duke
parents:
diff changeset
488 else
a61af66fc99e Initial load
duke
parents:
diff changeset
489 return new ReadResult(address);
a61af66fc99e Initial load
duke
parents:
diff changeset
490 }
a61af66fc99e Initial load
duke
parents:
diff changeset
491
a61af66fc99e Initial load
duke
parents:
diff changeset
492
a61af66fc99e Initial load
duke
parents:
diff changeset
493 private DLL findDLLByName(String fullPathName) {
a61af66fc99e Initial load
duke
parents:
diff changeset
494 for (Iterator iter = loadObjects.iterator(); iter.hasNext(); ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
495 DLL dll = (DLL) iter.next();
a61af66fc99e Initial load
duke
parents:
diff changeset
496 if (dll.getName().equals(fullPathName)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
497 return dll;
a61af66fc99e Initial load
duke
parents:
diff changeset
498 }
a61af66fc99e Initial load
duke
parents:
diff changeset
499 }
a61af66fc99e Initial load
duke
parents:
diff changeset
500 return null;
a61af66fc99e Initial load
duke
parents:
diff changeset
501 }
a61af66fc99e Initial load
duke
parents:
diff changeset
502
a61af66fc99e Initial load
duke
parents:
diff changeset
503 public void writeBytesToProcess(long address, long numBytes, byte[] data)
a61af66fc99e Initial load
duke
parents:
diff changeset
504 throws UnmappedAddressException, DebuggerException {
a61af66fc99e Initial load
duke
parents:
diff changeset
505 // FIXME
a61af66fc99e Initial load
duke
parents:
diff changeset
506 throw new DebuggerException("Unimplemented");
a61af66fc99e Initial load
duke
parents:
diff changeset
507 }
a61af66fc99e Initial load
duke
parents:
diff changeset
508
a61af66fc99e Initial load
duke
parents:
diff changeset
509 private static String imagePath;
a61af66fc99e Initial load
duke
parents:
diff changeset
510 private static String symbolPath;
a61af66fc99e Initial load
duke
parents:
diff changeset
511 private static boolean useNativeLookup;
a61af66fc99e Initial load
duke
parents:
diff changeset
512
a61af66fc99e Initial load
duke
parents:
diff changeset
513 static {
a61af66fc99e Initial load
duke
parents:
diff changeset
514
a61af66fc99e Initial load
duke
parents:
diff changeset
515 /*
2072
d6cd0d55d0b5 6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents: 1552
diff changeset
516 * sawindbg.dll depends on dbgeng.dll which itself depends on
d6cd0d55d0b5 6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents: 1552
diff changeset
517 * dbghelp.dll. We have to make sure that the dbgeng.dll and
d6cd0d55d0b5 6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents: 1552
diff changeset
518 * dbghelp.dll that we load are compatible with each other. We
d6cd0d55d0b5 6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents: 1552
diff changeset
519 * load both of those libraries from the same directory based
d6cd0d55d0b5 6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents: 1552
diff changeset
520 * on the theory that co-located libraries are compatible.
d6cd0d55d0b5 6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents: 1552
diff changeset
521 *
d6cd0d55d0b5 6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents: 1552
diff changeset
522 * On Windows 2000 and earlier, dbgeng.dll and dbghelp.dll were
d6cd0d55d0b5 6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents: 1552
diff changeset
523 * not included as part of the standard system directory. On
d6cd0d55d0b5 6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents: 1552
diff changeset
524 * systems newer than Windows 2000, dbgeng.dll and dbghelp.dll
d6cd0d55d0b5 6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents: 1552
diff changeset
525 * are included in the standard system directory. However, the
d6cd0d55d0b5 6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents: 1552
diff changeset
526 * versions included in the standard system directory may not
d6cd0d55d0b5 6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents: 1552
diff changeset
527 * be able to handle symbol information for the newer compilers.
d6cd0d55d0b5 6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents: 1552
diff changeset
528 *
d6cd0d55d0b5 6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents: 1552
diff changeset
529 * We search for and explicitly load the libraries using the
d6cd0d55d0b5 6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents: 1552
diff changeset
530 * following directory search order:
0
a61af66fc99e Initial load
duke
parents:
diff changeset
531 *
2072
d6cd0d55d0b5 6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents: 1552
diff changeset
532 * - java.home/bin (same as $JAVA_HOME/jre/bin)
d6cd0d55d0b5 6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents: 1552
diff changeset
533 * - dir named by DEBUGGINGTOOLSFORWINDOWS environment variable
d6cd0d55d0b5 6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents: 1552
diff changeset
534 * - various "Debugging Tools For Windows" program directories
d6cd0d55d0b5 6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents: 1552
diff changeset
535 * - the system directory ($SYSROOT/system32)
d6cd0d55d0b5 6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents: 1552
diff changeset
536 *
d6cd0d55d0b5 6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents: 1552
diff changeset
537 * If SA is invoked with -Dsun.jvm.hotspot.loadLibrary.DEBUG=1,
d6cd0d55d0b5 6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents: 1552
diff changeset
538 * then debug messages about library loading are printed to
d6cd0d55d0b5 6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents: 1552
diff changeset
539 * System.err.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
540 */
a61af66fc99e Initial load
duke
parents:
diff changeset
541
2072
d6cd0d55d0b5 6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents: 1552
diff changeset
542 String dbgengPath = null;
d6cd0d55d0b5 6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents: 1552
diff changeset
543 String dbghelpPath = null;
d6cd0d55d0b5 6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents: 1552
diff changeset
544 String sawindbgPath = null;
d6cd0d55d0b5 6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents: 1552
diff changeset
545 List searchList = new ArrayList();
d6cd0d55d0b5 6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents: 1552
diff changeset
546
d6cd0d55d0b5 6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents: 1552
diff changeset
547 boolean loadLibraryDEBUG =
d6cd0d55d0b5 6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents: 1552
diff changeset
548 System.getProperty("sun.jvm.hotspot.loadLibrary.DEBUG") != null;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
549
a61af66fc99e Initial load
duke
parents:
diff changeset
550 {
2072
d6cd0d55d0b5 6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents: 1552
diff changeset
551 // First place to search is co-located with sawindbg.dll in
d6cd0d55d0b5 6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents: 1552
diff changeset
552 // $JAVA_HOME/jre/bin (java.home property is set to $JAVA_HOME/jre):
d6cd0d55d0b5 6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents: 1552
diff changeset
553 searchList.add(System.getProperty("java.home") + File.separator + "bin");
d6cd0d55d0b5 6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents: 1552
diff changeset
554 sawindbgPath = (String) searchList.get(0) + File.separator +
d6cd0d55d0b5 6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents: 1552
diff changeset
555 "sawindbg.dll";
d6cd0d55d0b5 6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents: 1552
diff changeset
556
d6cd0d55d0b5 6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents: 1552
diff changeset
557 // second place to search is specified by an environment variable:
d6cd0d55d0b5 6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents: 1552
diff changeset
558 String DTFWHome = System.getenv("DEBUGGINGTOOLSFORWINDOWS");
d6cd0d55d0b5 6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents: 1552
diff changeset
559 if (DTFWHome != null) {
d6cd0d55d0b5 6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents: 1552
diff changeset
560 searchList.add(DTFWHome);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
561 }
a61af66fc99e Initial load
duke
parents:
diff changeset
562
2072
d6cd0d55d0b5 6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents: 1552
diff changeset
563 // The third place to search is the install directory for the
d6cd0d55d0b5 6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents: 1552
diff changeset
564 // "Debugging Tools For Windows" package; so far there are three
d6cd0d55d0b5 6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents: 1552
diff changeset
565 // name variations that we know of:
d6cd0d55d0b5 6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents: 1552
diff changeset
566 String sysRoot = System.getenv("SYSTEMROOT");
d6cd0d55d0b5 6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents: 1552
diff changeset
567 DTFWHome = sysRoot + File.separator + ".." + File.separator +
d6cd0d55d0b5 6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents: 1552
diff changeset
568 "Program Files" + File.separator + "Debugging Tools For Windows";
d6cd0d55d0b5 6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents: 1552
diff changeset
569 searchList.add(DTFWHome);
d6cd0d55d0b5 6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents: 1552
diff changeset
570 searchList.add(DTFWHome + " (x86)");
d6cd0d55d0b5 6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents: 1552
diff changeset
571 searchList.add(DTFWHome + " (x64)");
d6cd0d55d0b5 6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents: 1552
diff changeset
572
d6cd0d55d0b5 6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents: 1552
diff changeset
573 // The last place to search is the system directory:
d6cd0d55d0b5 6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents: 1552
diff changeset
574 searchList.add(sysRoot + File.separator + "system32");
0
a61af66fc99e Initial load
duke
parents:
diff changeset
575 }
a61af66fc99e Initial load
duke
parents:
diff changeset
576
2072
d6cd0d55d0b5 6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents: 1552
diff changeset
577 for (int i = 0; i < searchList.size(); i++) {
d6cd0d55d0b5 6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents: 1552
diff changeset
578 File dir = new File((String) searchList.get(i));
d6cd0d55d0b5 6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents: 1552
diff changeset
579 if (!dir.exists()) {
d6cd0d55d0b5 6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents: 1552
diff changeset
580 if (loadLibraryDEBUG) {
d6cd0d55d0b5 6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents: 1552
diff changeset
581 System.err.println("DEBUG: '" + searchList.get(i) +
d6cd0d55d0b5 6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents: 1552
diff changeset
582 "': directory does not exist.");
d6cd0d55d0b5 6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents: 1552
diff changeset
583 }
d6cd0d55d0b5 6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents: 1552
diff changeset
584 // this search directory doesn't exist so skip it
d6cd0d55d0b5 6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents: 1552
diff changeset
585 continue;
d6cd0d55d0b5 6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents: 1552
diff changeset
586 }
d6cd0d55d0b5 6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents: 1552
diff changeset
587
d6cd0d55d0b5 6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents: 1552
diff changeset
588 dbgengPath = (String) searchList.get(i) + File.separator + "dbgeng.dll";
d6cd0d55d0b5 6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents: 1552
diff changeset
589 dbghelpPath = (String) searchList.get(i) + File.separator + "dbghelp.dll";
d6cd0d55d0b5 6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents: 1552
diff changeset
590
d6cd0d55d0b5 6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents: 1552
diff changeset
591 File feng = new File(dbgengPath);
d6cd0d55d0b5 6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents: 1552
diff changeset
592 File fhelp = new File(dbghelpPath);
d6cd0d55d0b5 6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents: 1552
diff changeset
593 if (feng.exists() && fhelp.exists()) {
d6cd0d55d0b5 6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents: 1552
diff changeset
594 // both files exist so we have a match
d6cd0d55d0b5 6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents: 1552
diff changeset
595 break;
d6cd0d55d0b5 6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents: 1552
diff changeset
596 }
d6cd0d55d0b5 6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents: 1552
diff changeset
597
d6cd0d55d0b5 6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents: 1552
diff changeset
598 // At least one of the files does not exist; no warning if both
d6cd0d55d0b5 6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents: 1552
diff changeset
599 // don't exist. If just one doesn't exist then we don't check
d6cd0d55d0b5 6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents: 1552
diff changeset
600 // loadLibraryDEBUG because we have a mis-configured system.
d6cd0d55d0b5 6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents: 1552
diff changeset
601 if (feng.exists()) {
d6cd0d55d0b5 6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents: 1552
diff changeset
602 System.err.println("WARNING: found '" + dbgengPath +
d6cd0d55d0b5 6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents: 1552
diff changeset
603 "' but did not find '" + dbghelpPath + "'; ignoring '" +
d6cd0d55d0b5 6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents: 1552
diff changeset
604 dbgengPath + "'.");
d6cd0d55d0b5 6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents: 1552
diff changeset
605 } else if (fhelp.exists()) {
d6cd0d55d0b5 6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents: 1552
diff changeset
606 System.err.println("WARNING: found '" + dbghelpPath +
d6cd0d55d0b5 6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents: 1552
diff changeset
607 "' but did not find '" + dbgengPath + "'; ignoring '" +
d6cd0d55d0b5 6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents: 1552
diff changeset
608 dbghelpPath + "'.");
d6cd0d55d0b5 6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents: 1552
diff changeset
609 } else if (loadLibraryDEBUG) {
d6cd0d55d0b5 6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents: 1552
diff changeset
610 System.err.println("DEBUG: searched '" + searchList.get(i) +
d6cd0d55d0b5 6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents: 1552
diff changeset
611 "': dbgeng.dll and dbghelp.dll were not found.");
d6cd0d55d0b5 6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents: 1552
diff changeset
612 }
d6cd0d55d0b5 6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents: 1552
diff changeset
613 dbgengPath = null;
d6cd0d55d0b5 6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents: 1552
diff changeset
614 dbghelpPath = null;
d6cd0d55d0b5 6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents: 1552
diff changeset
615 }
d6cd0d55d0b5 6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents: 1552
diff changeset
616
d6cd0d55d0b5 6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents: 1552
diff changeset
617 if (dbgengPath == null || dbghelpPath == null) {
d6cd0d55d0b5 6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents: 1552
diff changeset
618 // at least one of the files wasn't found anywhere we searched
d6cd0d55d0b5 6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents: 1552
diff changeset
619 String mesg = null;
d6cd0d55d0b5 6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents: 1552
diff changeset
620
d6cd0d55d0b5 6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents: 1552
diff changeset
621 if (dbgengPath == null && dbghelpPath == null) {
d6cd0d55d0b5 6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents: 1552
diff changeset
622 mesg = "dbgeng.dll and dbghelp.dll cannot be found. ";
d6cd0d55d0b5 6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents: 1552
diff changeset
623 } else if (dbgengPath == null) {
d6cd0d55d0b5 6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents: 1552
diff changeset
624 mesg = "dbgeng.dll cannot be found (dbghelp.dll was found). ";
d6cd0d55d0b5 6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents: 1552
diff changeset
625 } else {
d6cd0d55d0b5 6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents: 1552
diff changeset
626 mesg = "dbghelp.dll cannot be found (dbgeng.dll was found). ";
d6cd0d55d0b5 6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents: 1552
diff changeset
627 }
d6cd0d55d0b5 6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents: 1552
diff changeset
628 throw new UnsatisfiedLinkError(mesg +
d6cd0d55d0b5 6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents: 1552
diff changeset
629 "Please search microsoft.com for 'Debugging Tools For Windows', " +
d6cd0d55d0b5 6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents: 1552
diff changeset
630 "and either download it to the default location, or download it " +
d6cd0d55d0b5 6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents: 1552
diff changeset
631 "to a custom location and set environment variable " +
d6cd0d55d0b5 6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents: 1552
diff changeset
632 "'DEBUGGINGTOOLSFORWINDOWS' to the pathname of that location.");
d6cd0d55d0b5 6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents: 1552
diff changeset
633 }
d6cd0d55d0b5 6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents: 1552
diff changeset
634
d6cd0d55d0b5 6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents: 1552
diff changeset
635 // NOTE: The order of loads is important! If we load dbgeng.dll
d6cd0d55d0b5 6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents: 1552
diff changeset
636 // first, then the dependency - dbghelp.dll - will be loaded
d6cd0d55d0b5 6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents: 1552
diff changeset
637 // from usual DLL search thereby defeating the purpose!
d6cd0d55d0b5 6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents: 1552
diff changeset
638 if (loadLibraryDEBUG) {
d6cd0d55d0b5 6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents: 1552
diff changeset
639 System.err.println("DEBUG: loading '" + dbghelpPath + "'.");
d6cd0d55d0b5 6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents: 1552
diff changeset
640 }
d6cd0d55d0b5 6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents: 1552
diff changeset
641 System.load(dbghelpPath);
d6cd0d55d0b5 6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents: 1552
diff changeset
642 if (loadLibraryDEBUG) {
d6cd0d55d0b5 6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents: 1552
diff changeset
643 System.err.println("DEBUG: loading '" + dbgengPath + "'.");
d6cd0d55d0b5 6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents: 1552
diff changeset
644 }
d6cd0d55d0b5 6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents: 1552
diff changeset
645 System.load(dbgengPath);
d6cd0d55d0b5 6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents: 1552
diff changeset
646
0
a61af66fc99e Initial load
duke
parents:
diff changeset
647 // Now, load sawindbg.dll
2072
d6cd0d55d0b5 6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents: 1552
diff changeset
648 if (loadLibraryDEBUG) {
d6cd0d55d0b5 6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents: 1552
diff changeset
649 System.err.println("DEBUG: loading '" + sawindbgPath + "'.");
d6cd0d55d0b5 6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents: 1552
diff changeset
650 }
d6cd0d55d0b5 6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents: 1552
diff changeset
651 System.load(sawindbgPath);
d6cd0d55d0b5 6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents: 1552
diff changeset
652
0
a61af66fc99e Initial load
duke
parents:
diff changeset
653 // where do I find '.exe', '.dll' files?
a61af66fc99e Initial load
duke
parents:
diff changeset
654 imagePath = System.getProperty("sun.jvm.hotspot.debugger.windbg.imagePath");
a61af66fc99e Initial load
duke
parents:
diff changeset
655 if (imagePath == null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
656 imagePath = System.getenv("PATH");
a61af66fc99e Initial load
duke
parents:
diff changeset
657 }
a61af66fc99e Initial load
duke
parents:
diff changeset
658
a61af66fc99e Initial load
duke
parents:
diff changeset
659 // where do I find '.pdb', '.dbg' files?
a61af66fc99e Initial load
duke
parents:
diff changeset
660 symbolPath = System.getProperty("sun.jvm.hotspot.debugger.windbg.symbolPath");
a61af66fc99e Initial load
duke
parents:
diff changeset
661
a61af66fc99e Initial load
duke
parents:
diff changeset
662 // mostly, debug files would be find where .dll's, .exe's are found.
a61af66fc99e Initial load
duke
parents:
diff changeset
663 if (symbolPath == null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
664 symbolPath = imagePath;
a61af66fc99e Initial load
duke
parents:
diff changeset
665 }
a61af66fc99e Initial load
duke
parents:
diff changeset
666
a61af66fc99e Initial load
duke
parents:
diff changeset
667 // should we parse DLL symbol table in Java code or use
a61af66fc99e Initial load
duke
parents:
diff changeset
668 // Windbg's native lookup facility? By default, we use
a61af66fc99e Initial load
duke
parents:
diff changeset
669 // native lookup so that we can take advantage of '.pdb'
a61af66fc99e Initial load
duke
parents:
diff changeset
670 // files, if available.
a61af66fc99e Initial load
duke
parents:
diff changeset
671 useNativeLookup = true;
a61af66fc99e Initial load
duke
parents:
diff changeset
672 String str = System.getProperty("sun.jvm.hotspot.debugger.windbg.disableNativeLookup");
a61af66fc99e Initial load
duke
parents:
diff changeset
673 if (str != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
674 useNativeLookup = false;
a61af66fc99e Initial load
duke
parents:
diff changeset
675 }
a61af66fc99e Initial load
duke
parents:
diff changeset
676
a61af66fc99e Initial load
duke
parents:
diff changeset
677 initIDs();
a61af66fc99e Initial load
duke
parents:
diff changeset
678 }
a61af66fc99e Initial load
duke
parents:
diff changeset
679
a61af66fc99e Initial load
duke
parents:
diff changeset
680 // native methods
a61af66fc99e Initial load
duke
parents:
diff changeset
681 private static native void initIDs();
a61af66fc99e Initial load
duke
parents:
diff changeset
682 private native void attach0(String executableName, String coreFileName);
a61af66fc99e Initial load
duke
parents:
diff changeset
683 private native void attach0(int processID);
a61af66fc99e Initial load
duke
parents:
diff changeset
684 private native void detach0();
a61af66fc99e Initial load
duke
parents:
diff changeset
685 private native byte[] readBytesFromProcess0(long address, long numBytes)
a61af66fc99e Initial load
duke
parents:
diff changeset
686 throws UnmappedAddressException, DebuggerException;
a61af66fc99e Initial load
duke
parents:
diff changeset
687 private native long getThreadIdFromSysId0(long sysId);
a61af66fc99e Initial load
duke
parents:
diff changeset
688 private native String consoleExecuteCommand0(String cmd);
a61af66fc99e Initial load
duke
parents:
diff changeset
689 private native long lookupByName0(String objName, String symName);
a61af66fc99e Initial load
duke
parents:
diff changeset
690 private native ClosestSymbol lookupByAddress0(long address);
a61af66fc99e Initial load
duke
parents:
diff changeset
691
a61af66fc99e Initial load
duke
parents:
diff changeset
692 // helper called lookupByAddress0
a61af66fc99e Initial load
duke
parents:
diff changeset
693 private ClosestSymbol createClosestSymbol(String symbol, long diff) {
a61af66fc99e Initial load
duke
parents:
diff changeset
694 return new ClosestSymbol(symbol, diff);
a61af66fc99e Initial load
duke
parents:
diff changeset
695 }
a61af66fc99e Initial load
duke
parents:
diff changeset
696 }