Mercurial > hg > truffle
annotate agent/src/share/classes/sun/jvm/hotspot/debugger/windbg/WindbgDebuggerLocal.java @ 10343:6bd680e9ea35
8003421: NPG: Move oops out of InstanceKlass into mirror
Summary: Inject protection_domain, signers, init_lock into java_lang_Class
Reviewed-by: stefank, dholmes, sla
author | coleenp |
---|---|
date | Wed, 22 May 2013 14:37:49 -0400 |
parents | e458120c6e1a |
children | de6a9e811145 |
rev | line source |
---|---|
0 | 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 | 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * | |
5 * This code is free software; you can redistribute it and/or modify it | |
6 * under the terms of the GNU General Public License version 2 only, as | |
7 * published by the Free Software Foundation. | |
8 * | |
9 * This code is distributed in the hope that it will be useful, but WITHOUT | |
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
12 * version 2 for more details (a copy is included in the LICENSE file that | |
13 * accompanied this code). | |
14 * | |
15 * You should have received a copy of the GNU General Public License version | |
16 * 2 along with this work; if not, write to the Free Software Foundation, | |
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
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 | 22 * |
23 */ | |
24 | |
25 package sun.jvm.hotspot.debugger.windbg; | |
26 | |
27 import java.io.*; | |
28 import java.net.*; | |
29 import java.util.*; | |
30 import sun.jvm.hotspot.debugger.*; | |
31 import sun.jvm.hotspot.debugger.amd64.*; | |
32 import sun.jvm.hotspot.debugger.x86.*; | |
33 import sun.jvm.hotspot.debugger.ia64.*; | |
34 import sun.jvm.hotspot.debugger.windbg.amd64.*; | |
35 import sun.jvm.hotspot.debugger.windbg.x86.*; | |
36 import sun.jvm.hotspot.debugger.windbg.ia64.*; | |
37 import sun.jvm.hotspot.debugger.win32.coff.*; | |
38 import sun.jvm.hotspot.debugger.cdbg.*; | |
39 import sun.jvm.hotspot.debugger.cdbg.basic.BasicDebugEvent; | |
40 import sun.jvm.hotspot.utilities.*; | |
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 | 43 |
44 /** <P> An implementation of the JVMDebugger interface which talks to | |
45 windbg and symbol table management is done in Java. </P> | |
46 | |
47 <P> <B>NOTE</B> that since we have the notion of fetching "Java | |
48 primitive types" from the remote process (which might have | |
49 different sizes than we expect) we have a bootstrapping | |
50 problem. We need to know the sizes of these types before we can | |
51 fetch them. The current implementation solves this problem by | |
52 requiring that it be configured with these type sizes before they | |
53 can be fetched. The readJ(Type) routines here will throw a | |
54 RuntimeException if they are called before the debugger is | |
55 configured with the Java primitive type sizes. </P> */ | |
56 | |
57 public class WindbgDebuggerLocal extends DebuggerBase implements WindbgDebugger { | |
58 private PageCache cache; | |
59 private boolean attached; | |
60 private boolean isCore; | |
61 | |
62 // Symbol lookup support | |
63 // This is a map of library names to DLLs | |
64 private Map nameToDllMap; | |
65 | |
66 // C/C++ debugging support | |
67 private List/*<LoadObject>*/ loadObjects; | |
68 private CDebugger cdbg; | |
69 | |
70 // thread access | |
71 private Map threadIntegerRegisterSet; | |
72 private List threadList; | |
73 | |
74 // windbg native interface pointers | |
75 | |
76 private long ptrIDebugClient; | |
77 private long ptrIDebugControl; | |
78 private long ptrIDebugDataSpaces; | |
79 private long ptrIDebugOutputCallbacks; | |
80 private long ptrIDebugAdvanced; | |
81 private long ptrIDebugSymbols; | |
82 private long ptrIDebugSystemObjects; | |
83 | |
84 private WindbgThreadFactory threadFactory; | |
85 | |
86 //-------------------------------------------------------------------------------- | |
87 // Implementation of Debugger interface | |
88 // | |
89 | |
90 /** <P> machDesc may not be null. </P> | |
91 | |
92 <P> useCache should be set to true if debugging is being done | |
93 locally, and to false if the debugger is being created for the | |
94 purpose of supporting remote debugging. </P> */ | |
95 public WindbgDebuggerLocal(MachineDescription machDesc, | |
96 boolean useCache) throws DebuggerException { | |
97 this.machDesc = machDesc; | |
98 utils = new DebuggerUtilities(machDesc.getAddressSize(), machDesc.isBigEndian()) { | |
99 public void checkAlignment(long address, long alignment) { | |
100 // Need to override default checkAlignment because we need to | |
101 // relax alignment constraints on Windows/x86 | |
102 if ( (address % alignment != 0) | |
103 &&(alignment != 8 || address % 4 != 0)) { | |
104 throw new UnalignedAddressException( | |
105 "Trying to read at address: " | |
106 + addressValueToString(address) | |
107 + " with alignment: " + alignment, | |
108 address); | |
109 } | |
110 } | |
111 }; | |
112 | |
113 String cpu = PlatformInfo.getCPU(); | |
114 if (cpu.equals("x86")) { | |
115 threadFactory = new WindbgX86ThreadFactory(this); | |
116 } else if (cpu.equals("amd64")) { | |
117 threadFactory = new WindbgAMD64ThreadFactory(this); | |
118 } else if (cpu.equals("ia64")) { | |
119 threadFactory = new WindbgIA64ThreadFactory(this); | |
120 } | |
121 | |
122 if (useCache) { | |
123 // Cache portion of the remote process's address space. | |
124 // Fetching data over the socket connection to dbx is slow. | |
125 // Might be faster if we were using a binary protocol to talk to | |
126 // dbx, but would have to test. For now, this cache works best | |
127 // if it covers the entire heap of the remote process. FIXME: at | |
128 // least should make this tunable from the outside, i.e., via | |
129 // the UI. This is a cache of 4096 4K pages, or 16 MB. The page | |
130 // size must be adjusted to be the hardware's page size. | |
131 // (FIXME: should pick this up from the debugger.) | |
132 initCache(4096, 4096); | |
133 } | |
134 // FIXME: add instantiation of thread factory | |
135 | |
136 } | |
137 | |
138 /** From the Debugger interface via JVMDebugger */ | |
139 public boolean hasProcessList() throws DebuggerException { | |
140 return false; | |
141 } | |
142 | |
143 /** From the Debugger interface via JVMDebugger */ | |
144 public List getProcessList() throws DebuggerException { | |
145 return null; | |
146 } | |
147 | |
148 | |
149 /** From the Debugger interface via JVMDebugger */ | |
150 public synchronized void attach(int processID) throws DebuggerException { | |
151 attachInit(); | |
152 attach0(processID); | |
153 attached = true; | |
154 isCore = false; | |
155 } | |
156 | |
157 /** From the Debugger interface via JVMDebugger */ | |
158 public synchronized void attach(String executableName, String coreFileName) throws DebuggerException { | |
159 attachInit(); | |
160 attach0(executableName, coreFileName); | |
161 attached = true; | |
162 isCore = true; | |
163 } | |
164 | |
165 public List getLoadObjectList() { | |
166 requireAttach(); | |
167 return loadObjects; | |
168 } | |
169 | |
170 /** From the Debugger interface via JVMDebugger */ | |
171 public synchronized boolean detach() { | |
172 if ( ! attached) | |
173 return false; | |
174 | |
175 // Close all open DLLs | |
176 if (nameToDllMap != null) { | |
177 for (Iterator iter = nameToDllMap.values().iterator(); iter.hasNext(); ) { | |
178 DLL dll = (DLL) iter.next(); | |
179 dll.close(); | |
180 } | |
181 nameToDllMap = null; | |
182 loadObjects = null; | |
183 } | |
184 | |
185 cdbg = null; | |
186 clearCache(); | |
187 | |
188 threadIntegerRegisterSet = null; | |
189 threadList = null; | |
190 try { | |
191 detach0(); | |
192 } finally { | |
193 attached = false; | |
194 resetNativePointers(); | |
195 } | |
196 return true; | |
197 } | |
198 | |
199 | |
200 /** From the Debugger interface via JVMDebugger */ | |
201 public Address parseAddress(String addressString) throws NumberFormatException { | |
202 return newAddress(utils.scanAddress(addressString)); | |
203 } | |
204 | |
205 /** From the Debugger interface via JVMDebugger */ | |
206 public String getOS() { | |
207 return PlatformInfo.getOS(); | |
208 } | |
209 | |
210 /** From the Debugger interface via JVMDebugger */ | |
211 public String getCPU() { | |
212 return PlatformInfo.getCPU(); | |
213 } | |
214 | |
215 public boolean hasConsole() throws DebuggerException { | |
216 return true; | |
217 } | |
218 | |
219 public synchronized String consoleExecuteCommand(String cmd) throws DebuggerException { | |
220 requireAttach(); | |
221 if (! attached) { | |
222 throw new DebuggerException("debugger not yet attached to a Dr. Watson dump!"); | |
223 } | |
224 | |
225 return consoleExecuteCommand0(cmd); | |
226 } | |
227 | |
228 public String getConsolePrompt() throws DebuggerException { | |
229 return "(windbg)"; | |
230 } | |
231 | |
232 public CDebugger getCDebugger() throws DebuggerException { | |
233 if (cdbg == null) { | |
234 // FIXME: CDebugger is not yet supported for IA64 because | |
235 // of native stack walking issues. | |
236 if (! getCPU().equals("ia64")) { | |
237 cdbg = new WindbgCDebugger(this); | |
238 } | |
239 } | |
240 return cdbg; | |
241 } | |
242 | |
243 /** From the SymbolLookup interface via Debugger and JVMDebugger */ | |
244 public synchronized Address lookup(String objectName, String symbol) { | |
245 requireAttach(); | |
246 return newAddress(lookupByName(objectName, symbol)); | |
247 } | |
248 | |
249 /** From the SymbolLookup interface via Debugger and JVMDebugger */ | |
250 public synchronized OopHandle lookupOop(String objectName, String symbol) { | |
251 Address addr = lookup(objectName, symbol); | |
252 if (addr == null) { | |
253 return null; | |
254 } | |
255 return addr.addOffsetToAsOopHandle(0); | |
256 } | |
257 | |
258 public synchronized ClosestSymbol lookup(long address) { | |
259 return lookupByAddress0(address); | |
260 } | |
261 | |
262 /** From the Debugger interface */ | |
263 public MachineDescription getMachineDescription() { | |
264 return machDesc; | |
265 } | |
266 | |
267 //-------------------------------------------------------------------------------- | |
268 // Implementation of ThreadAccess interface | |
269 // | |
270 | |
271 | |
272 /** From the ThreadAccess interface via Debugger and JVMDebugger */ | |
273 public ThreadProxy getThreadForIdentifierAddress(Address addr) { | |
274 return threadFactory.createThreadWrapper(addr); | |
275 } | |
276 | |
277 public ThreadProxy getThreadForThreadId(long handle) { | |
278 // with windbg we can't make out using handle | |
279 throw new DebuggerException("Unimplemented!"); | |
280 } | |
281 | |
282 public long getThreadIdFromSysId(long sysId) throws DebuggerException { | |
283 requireAttach(); | |
284 return getThreadIdFromSysId0(sysId); | |
285 } | |
286 | |
287 //---------------------------------------------------------------------- | |
288 // Overridden from DebuggerBase because we need to relax alignment | |
289 // constraints on x86 | |
290 | |
291 public long readJLong(long address) | |
292 throws UnmappedAddressException, UnalignedAddressException { | |
293 checkJavaConfigured(); | |
294 // FIXME: allow this to be configurable. Undesirable to add a | |
295 // dependency on the runtime package here, though, since this | |
296 // package should be strictly underneath it. | |
297 // utils.checkAlignment(address, jlongSize); | |
298 utils.checkAlignment(address, jintSize); | |
299 byte[] data = readBytes(address, jlongSize); | |
300 return utils.dataToJLong(data, jlongSize); | |
301 } | |
302 | |
303 //-------------------------------------------------------------------------------- | |
304 // Internal routines (for implementation of WindbgAddress). | |
305 // These must not be called until the MachineDescription has been set up. | |
306 // | |
307 | |
308 /** From the WindbgDebugger interface */ | |
309 public String addressValueToString(long address) { | |
310 return utils.addressValueToString(address); | |
311 } | |
312 | |
313 /** From the WindbgDebugger interface */ | |
314 public WindbgAddress readAddress(long address) | |
315 throws UnmappedAddressException, UnalignedAddressException { | |
316 return (WindbgAddress) newAddress(readAddressValue(address)); | |
317 } | |
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 |
6848
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
2072
diff
changeset
|
324 public WindbgAddress readCompKlassAddress(long address) |
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
2072
diff
changeset
|
325 throws UnmappedAddressException, UnalignedAddressException { |
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
2072
diff
changeset
|
326 return (WindbgAddress) newAddress(readCompKlassAddressValue(address)); |
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
2072
diff
changeset
|
327 } |
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
2072
diff
changeset
|
328 |
0 | 329 /** From the WindbgDebugger interface */ |
330 public WindbgOopHandle readOopHandle(long address) | |
331 throws UnmappedAddressException, UnalignedAddressException, NotInHeapException { | |
332 long value = readAddressValue(address); | |
333 return (value == 0 ? null : new WindbgOopHandle(this, value)); | |
334 } | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
335 public WindbgOopHandle readCompOopHandle(long address) |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
336 throws UnmappedAddressException, UnalignedAddressException, NotInHeapException { |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
337 long value = readCompOopAddressValue(address); |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
338 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
|
339 } |
0 | 340 |
341 /** From the WindbgDebugger interface */ | |
342 public int getAddressSize() { | |
343 return (int) machDesc.getAddressSize(); | |
344 } | |
345 | |
346 //-------------------------------------------------------------------------------- | |
347 // Thread context access | |
348 // | |
349 | |
350 private synchronized void setThreadIntegerRegisterSet(long threadId, | |
351 long[] regs) { | |
352 threadIntegerRegisterSet.put(new Long(threadId), regs); | |
353 } | |
354 | |
355 private synchronized void addThread(long sysId) { | |
356 threadList.add(threadFactory.createThreadWrapper(sysId)); | |
357 } | |
358 | |
359 public synchronized long[] getThreadIntegerRegisterSet(long threadId) | |
360 throws DebuggerException { | |
361 requireAttach(); | |
362 return (long[]) threadIntegerRegisterSet.get(new Long(threadId)); | |
363 } | |
364 | |
365 public synchronized List getThreadList() throws DebuggerException { | |
366 requireAttach(); | |
367 return threadList; | |
368 } | |
369 | |
370 private String findFullPath(String file) { | |
371 File f = new File(file); | |
372 if (f.exists()) { | |
373 return file; | |
374 } else { | |
375 // remove path part, if any. | |
376 file = f.getName(); | |
377 StringTokenizer st = new StringTokenizer(imagePath, File.pathSeparator); | |
378 while (st.hasMoreTokens()) { | |
379 f = new File(st.nextToken(), file); | |
380 if (f.exists()) { | |
381 return f.getPath(); | |
382 } | |
383 } | |
384 } | |
385 return null; | |
386 } | |
387 | |
388 private synchronized void addLoadObject(String file, long size, long base) { | |
389 String path = findFullPath(file); | |
390 if (path != null) { | |
391 DLL dll = null; | |
392 if (useNativeLookup) { | |
393 dll = new DLL(this, path, size,newAddress(base)) { | |
394 public ClosestSymbol closestSymbolToPC(Address pcAsAddr) { | |
395 long pc = getAddressValue(pcAsAddr); | |
396 ClosestSymbol sym = lookupByAddress0(pc); | |
397 if (sym == null) { | |
398 return super.closestSymbolToPC(pcAsAddr); | |
399 } else { | |
400 return sym; | |
401 } | |
402 } | |
403 }; | |
404 } else { | |
405 dll = new DLL(this, path, size, newAddress(base)); | |
406 } | |
407 loadObjects.add(dll); | |
408 nameToDllMap.put(new File(file).getName(), dll); | |
409 } | |
410 } | |
411 | |
412 //-------------------------------------------------------------------------------- | |
413 // Address access | |
414 // | |
415 | |
416 /** From the Debugger interface */ | |
417 public long getAddressValue(Address addr) { | |
418 if (addr == null) return 0; | |
419 return ((WindbgAddress) addr).getValue(); | |
420 } | |
421 | |
422 /** From the WindbgDebugger interface */ | |
423 public Address newAddress(long value) { | |
424 if (value == 0) return null; | |
425 return new WindbgAddress(this, value); | |
426 } | |
427 | |
428 //-------------------------------------------------------------------------------- | |
429 // Internals only below this point | |
430 // | |
431 | |
432 // attach/detach helpers | |
433 private void checkAttached() { | |
434 if (attached) { | |
435 String msg = (isCore)? "already attached to a Dr. Watson dump!" : | |
436 "already attached to a process!"; | |
437 throw new DebuggerException(msg); | |
438 } | |
439 } | |
440 | |
441 private void requireAttach() { | |
442 if (!attached) { | |
443 throw new RuntimeException("not attached to a process or Dr Watson dump"); | |
444 } | |
445 } | |
446 | |
447 private void attachInit() { | |
448 checkAttached(); | |
449 loadObjects = new ArrayList(); | |
450 nameToDllMap = new HashMap(); | |
451 threadIntegerRegisterSet = new HashMap(); | |
452 threadList = new ArrayList(); | |
453 } | |
454 | |
455 private void resetNativePointers() { | |
456 ptrIDebugClient = 0L; | |
457 ptrIDebugControl = 0L; | |
458 ptrIDebugDataSpaces = 0L; | |
459 ptrIDebugOutputCallbacks = 0L; | |
460 ptrIDebugAdvanced = 0L; | |
461 ptrIDebugSymbols = 0L; | |
462 ptrIDebugSystemObjects = 0L; | |
463 } | |
464 | |
465 synchronized long lookupByName(String objectName, String symbol) { | |
466 long res = 0L; | |
467 if (useNativeLookup) { | |
468 res = lookupByName0(objectName, symbol); | |
469 if (res != 0L) { | |
470 return res; | |
471 } // else fallthru... | |
472 } | |
473 | |
474 DLL dll = (DLL) nameToDllMap.get(objectName); | |
475 // The DLL can be null because we use this to search through known | |
476 // DLLs in HotSpotTypeDataBase (for example) | |
477 if (dll != null) { | |
478 WindbgAddress addr = (WindbgAddress) dll.lookupSymbol(symbol); | |
479 if (addr != null) { | |
480 return addr.getValue(); | |
481 } | |
482 } | |
483 return 0L; | |
484 } | |
485 | |
486 /** This reads bytes from the remote process. */ | |
487 public synchronized ReadResult readBytesFromProcess(long address, long numBytes) | |
488 throws UnmappedAddressException, DebuggerException { | |
489 requireAttach(); | |
490 byte[] res = readBytesFromProcess0(address, numBytes); | |
491 if(res != null) | |
492 return new ReadResult(res); | |
493 else | |
494 return new ReadResult(address); | |
495 } | |
496 | |
497 | |
498 private DLL findDLLByName(String fullPathName) { | |
499 for (Iterator iter = loadObjects.iterator(); iter.hasNext(); ) { | |
500 DLL dll = (DLL) iter.next(); | |
501 if (dll.getName().equals(fullPathName)) { | |
502 return dll; | |
503 } | |
504 } | |
505 return null; | |
506 } | |
507 | |
508 public void writeBytesToProcess(long address, long numBytes, byte[] data) | |
509 throws UnmappedAddressException, DebuggerException { | |
510 // FIXME | |
511 throw new DebuggerException("Unimplemented"); | |
512 } | |
513 | |
514 private static String imagePath; | |
515 private static String symbolPath; | |
516 private static boolean useNativeLookup; | |
517 | |
518 static { | |
519 | |
520 /* | |
2072
d6cd0d55d0b5
6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents:
1552
diff
changeset
|
521 * 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
|
522 * 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
|
523 * 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
|
524 * 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
|
525 * 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
|
526 * |
d6cd0d55d0b5
6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents:
1552
diff
changeset
|
527 * 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
|
528 * 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
|
529 * 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
|
530 * 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
|
531 * 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
|
532 * 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
|
533 * |
d6cd0d55d0b5
6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents:
1552
diff
changeset
|
534 * 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
|
535 * following directory search order: |
0 | 536 * |
2072
d6cd0d55d0b5
6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents:
1552
diff
changeset
|
537 * - 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
|
538 * - 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
|
539 * - 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
|
540 * - the system directory ($SYSROOT/system32) |
d6cd0d55d0b5
6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents:
1552
diff
changeset
|
541 * |
d6cd0d55d0b5
6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents:
1552
diff
changeset
|
542 * 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
|
543 * 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
|
544 * System.err. |
0 | 545 */ |
546 | |
2072
d6cd0d55d0b5
6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents:
1552
diff
changeset
|
547 String dbgengPath = null; |
d6cd0d55d0b5
6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents:
1552
diff
changeset
|
548 String dbghelpPath = null; |
d6cd0d55d0b5
6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents:
1552
diff
changeset
|
549 String sawindbgPath = null; |
d6cd0d55d0b5
6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents:
1552
diff
changeset
|
550 List searchList = new ArrayList(); |
d6cd0d55d0b5
6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents:
1552
diff
changeset
|
551 |
d6cd0d55d0b5
6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents:
1552
diff
changeset
|
552 boolean loadLibraryDEBUG = |
d6cd0d55d0b5
6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents:
1552
diff
changeset
|
553 System.getProperty("sun.jvm.hotspot.loadLibrary.DEBUG") != null; |
0 | 554 |
555 { | |
2072
d6cd0d55d0b5
6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents:
1552
diff
changeset
|
556 // 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
|
557 // $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
|
558 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
|
559 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
|
560 "sawindbg.dll"; |
d6cd0d55d0b5
6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents:
1552
diff
changeset
|
561 |
d6cd0d55d0b5
6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents:
1552
diff
changeset
|
562 // 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
|
563 String DTFWHome = System.getenv("DEBUGGINGTOOLSFORWINDOWS"); |
d6cd0d55d0b5
6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents:
1552
diff
changeset
|
564 if (DTFWHome != null) { |
d6cd0d55d0b5
6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents:
1552
diff
changeset
|
565 searchList.add(DTFWHome); |
0 | 566 } |
567 | |
2072
d6cd0d55d0b5
6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents:
1552
diff
changeset
|
568 // 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
|
569 // "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
|
570 // 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
|
571 String sysRoot = System.getenv("SYSTEMROOT"); |
d6cd0d55d0b5
6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents:
1552
diff
changeset
|
572 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
|
573 "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
|
574 searchList.add(DTFWHome); |
d6cd0d55d0b5
6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents:
1552
diff
changeset
|
575 |
8849
e458120c6e1a
8002118: WindbgDebuggerLocal should not try to load 64-bit debug libraries for 32-bit JVM
sla
parents:
6848
diff
changeset
|
576 // Only add the search path for the current CPU architecture: |
e458120c6e1a
8002118: WindbgDebuggerLocal should not try to load 64-bit debug libraries for 32-bit JVM
sla
parents:
6848
diff
changeset
|
577 String cpu = PlatformInfo.getCPU(); |
e458120c6e1a
8002118: WindbgDebuggerLocal should not try to load 64-bit debug libraries for 32-bit JVM
sla
parents:
6848
diff
changeset
|
578 if (cpu.equals("x86")) { |
e458120c6e1a
8002118: WindbgDebuggerLocal should not try to load 64-bit debug libraries for 32-bit JVM
sla
parents:
6848
diff
changeset
|
579 searchList.add(DTFWHome + " (x86)"); |
e458120c6e1a
8002118: WindbgDebuggerLocal should not try to load 64-bit debug libraries for 32-bit JVM
sla
parents:
6848
diff
changeset
|
580 } else if (cpu.equals("amd64")) { |
e458120c6e1a
8002118: WindbgDebuggerLocal should not try to load 64-bit debug libraries for 32-bit JVM
sla
parents:
6848
diff
changeset
|
581 searchList.add(DTFWHome + " (x64)"); |
e458120c6e1a
8002118: WindbgDebuggerLocal should not try to load 64-bit debug libraries for 32-bit JVM
sla
parents:
6848
diff
changeset
|
582 } |
2072
d6cd0d55d0b5
6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents:
1552
diff
changeset
|
583 // 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
|
584 searchList.add(sysRoot + File.separator + "system32"); |
0 | 585 } |
586 | |
2072
d6cd0d55d0b5
6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents:
1552
diff
changeset
|
587 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
|
588 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
|
589 if (!dir.exists()) { |
d6cd0d55d0b5
6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents:
1552
diff
changeset
|
590 if (loadLibraryDEBUG) { |
d6cd0d55d0b5
6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents:
1552
diff
changeset
|
591 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
|
592 "': directory does not exist."); |
d6cd0d55d0b5
6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents:
1552
diff
changeset
|
593 } |
d6cd0d55d0b5
6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents:
1552
diff
changeset
|
594 // 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
|
595 continue; |
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 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
|
599 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
|
600 |
d6cd0d55d0b5
6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents:
1552
diff
changeset
|
601 File feng = new File(dbgengPath); |
d6cd0d55d0b5
6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents:
1552
diff
changeset
|
602 File fhelp = new File(dbghelpPath); |
d6cd0d55d0b5
6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents:
1552
diff
changeset
|
603 if (feng.exists() && fhelp.exists()) { |
d6cd0d55d0b5
6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents:
1552
diff
changeset
|
604 // 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
|
605 break; |
d6cd0d55d0b5
6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents:
1552
diff
changeset
|
606 } |
d6cd0d55d0b5
6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents:
1552
diff
changeset
|
607 |
d6cd0d55d0b5
6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents:
1552
diff
changeset
|
608 // 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
|
609 // 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
|
610 // 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
|
611 if (feng.exists()) { |
d6cd0d55d0b5
6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents:
1552
diff
changeset
|
612 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
|
613 "' 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
|
614 dbgengPath + "'."); |
d6cd0d55d0b5
6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents:
1552
diff
changeset
|
615 } else if (fhelp.exists()) { |
d6cd0d55d0b5
6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents:
1552
diff
changeset
|
616 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
|
617 "' 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
|
618 dbghelpPath + "'."); |
d6cd0d55d0b5
6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents:
1552
diff
changeset
|
619 } else if (loadLibraryDEBUG) { |
d6cd0d55d0b5
6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents:
1552
diff
changeset
|
620 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
|
621 "': 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
|
622 } |
d6cd0d55d0b5
6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents:
1552
diff
changeset
|
623 dbgengPath = null; |
d6cd0d55d0b5
6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents:
1552
diff
changeset
|
624 dbghelpPath = null; |
d6cd0d55d0b5
6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents:
1552
diff
changeset
|
625 } |
d6cd0d55d0b5
6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents:
1552
diff
changeset
|
626 |
d6cd0d55d0b5
6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents:
1552
diff
changeset
|
627 if (dbgengPath == null || dbghelpPath == null) { |
d6cd0d55d0b5
6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents:
1552
diff
changeset
|
628 // 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
|
629 String mesg = null; |
d6cd0d55d0b5
6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents:
1552
diff
changeset
|
630 |
d6cd0d55d0b5
6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents:
1552
diff
changeset
|
631 if (dbgengPath == null && dbghelpPath == null) { |
d6cd0d55d0b5
6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents:
1552
diff
changeset
|
632 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
|
633 } else if (dbgengPath == null) { |
d6cd0d55d0b5
6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents:
1552
diff
changeset
|
634 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
|
635 } else { |
d6cd0d55d0b5
6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents:
1552
diff
changeset
|
636 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
|
637 } |
d6cd0d55d0b5
6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents:
1552
diff
changeset
|
638 throw new UnsatisfiedLinkError(mesg + |
d6cd0d55d0b5
6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents:
1552
diff
changeset
|
639 "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
|
640 "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
|
641 "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
|
642 "'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
|
643 } |
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 // 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
|
646 // 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
|
647 // 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
|
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 '" + dbghelpPath + "'."); |
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(dbghelpPath); |
d6cd0d55d0b5
6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents:
1552
diff
changeset
|
652 if (loadLibraryDEBUG) { |
d6cd0d55d0b5
6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents:
1552
diff
changeset
|
653 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
|
654 } |
d6cd0d55d0b5
6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents:
1552
diff
changeset
|
655 System.load(dbgengPath); |
d6cd0d55d0b5
6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents:
1552
diff
changeset
|
656 |
0 | 657 // Now, load sawindbg.dll |
2072
d6cd0d55d0b5
6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents:
1552
diff
changeset
|
658 if (loadLibraryDEBUG) { |
d6cd0d55d0b5
6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents:
1552
diff
changeset
|
659 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
|
660 } |
d6cd0d55d0b5
6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents:
1552
diff
changeset
|
661 System.load(sawindbgPath); |
d6cd0d55d0b5
6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents:
1552
diff
changeset
|
662 |
0 | 663 // where do I find '.exe', '.dll' files? |
664 imagePath = System.getProperty("sun.jvm.hotspot.debugger.windbg.imagePath"); | |
665 if (imagePath == null) { | |
666 imagePath = System.getenv("PATH"); | |
667 } | |
668 | |
669 // where do I find '.pdb', '.dbg' files? | |
670 symbolPath = System.getProperty("sun.jvm.hotspot.debugger.windbg.symbolPath"); | |
671 | |
672 // mostly, debug files would be find where .dll's, .exe's are found. | |
673 if (symbolPath == null) { | |
674 symbolPath = imagePath; | |
675 } | |
676 | |
677 // should we parse DLL symbol table in Java code or use | |
678 // Windbg's native lookup facility? By default, we use | |
679 // native lookup so that we can take advantage of '.pdb' | |
680 // files, if available. | |
681 useNativeLookup = true; | |
682 String str = System.getProperty("sun.jvm.hotspot.debugger.windbg.disableNativeLookup"); | |
683 if (str != null) { | |
684 useNativeLookup = false; | |
685 } | |
686 | |
687 initIDs(); | |
688 } | |
689 | |
690 // native methods | |
691 private static native void initIDs(); | |
692 private native void attach0(String executableName, String coreFileName); | |
693 private native void attach0(int processID); | |
694 private native void detach0(); | |
695 private native byte[] readBytesFromProcess0(long address, long numBytes) | |
696 throws UnmappedAddressException, DebuggerException; | |
697 private native long getThreadIdFromSysId0(long sysId); | |
698 private native String consoleExecuteCommand0(String cmd); | |
699 private native long lookupByName0(String objName, String symName); | |
700 private native ClosestSymbol lookupByAddress0(long address); | |
701 | |
702 // helper called lookupByAddress0 | |
703 private ClosestSymbol createClosestSymbol(String symbol, long diff) { | |
704 return new ClosestSymbol(symbol, diff); | |
705 } | |
706 } |