Mercurial > hg > truffle
comparison 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 |
comparison
equal
deleted
inserted
replaced
2071:07c62ff47437 | 2072:d6cd0d55d0b5 |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 2002, 2008, Oracle and/or its affiliates. All rights reserved. | 2 * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * | 4 * |
5 * This code is free software; you can redistribute it and/or modify it | 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 | 6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
504 throws UnmappedAddressException, DebuggerException { | 504 throws UnmappedAddressException, DebuggerException { |
505 // FIXME | 505 // FIXME |
506 throw new DebuggerException("Unimplemented"); | 506 throw new DebuggerException("Unimplemented"); |
507 } | 507 } |
508 | 508 |
509 private static String DTFWHome; | |
510 private static String imagePath; | 509 private static String imagePath; |
511 private static String symbolPath; | 510 private static String symbolPath; |
512 private static boolean useNativeLookup; | 511 private static boolean useNativeLookup; |
513 | 512 |
514 static { | 513 static { |
515 | 514 |
516 /* | 515 /* |
517 * sawindbg.dll depends on dbgeng.dll which | 516 * sawindbg.dll depends on dbgeng.dll which itself depends on |
518 * itself depends on dbghelp.dll. dbgeng.dll and dbghelp.dll. | 517 * dbghelp.dll. We have to make sure that the dbgeng.dll and |
519 * On systems newer than Windows 2000, these two .dlls are | 518 * dbghelp.dll that we load are compatible with each other. We |
520 * in the standard system directory so we will find them there. | 519 * load both of those libraries from the same directory based |
521 * On Windows 2000 and earlier, these files do not exist. | 520 * on the theory that co-located libraries are compatible. |
522 * The user must download Debugging Tools For Windows (DTFW) | |
523 * and install it in order to use SA. | |
524 * | 521 * |
525 * We have to make sure we use the two files from the same directory | 522 * On Windows 2000 and earlier, dbgeng.dll and dbghelp.dll were |
526 * in case there are more than one copy on the system because | 523 * not included as part of the standard system directory. On |
527 * one version of dbgeng.dll might not be compatible with a | 524 * systems newer than Windows 2000, dbgeng.dll and dbghelp.dll |
528 * different version of dbghelp.dll. | 525 * are included in the standard system directory. However, the |
529 * We first look for them in the directory pointed at by | 526 * versions included in the standard system directory may not |
530 * env. var. DEBUGGINGTOOLSFORWINDOWS, next in the default | 527 * be able to handle symbol information for the newer compilers. |
531 * installation dir for DTFW, and lastly in the standard | 528 * |
532 * system directory. We expect that that we will find | 529 * We search for and explicitly load the libraries using the |
533 * them in the standard system directory on all systems | 530 * following directory search order: |
534 * newer than Windows 2000. | 531 * |
532 * - java.home/bin (same as $JAVA_HOME/jre/bin) | |
533 * - dir named by DEBUGGINGTOOLSFORWINDOWS environment variable | |
534 * - various "Debugging Tools For Windows" program directories | |
535 * - the system directory ($SYSROOT/system32) | |
536 * | |
537 * If SA is invoked with -Dsun.jvm.hotspot.loadLibrary.DEBUG=1, | |
538 * then debug messages about library loading are printed to | |
539 * System.err. | |
535 */ | 540 */ |
536 String dirName = null; | 541 |
537 DTFWHome = System.getenv("DEBUGGINGTOOLSFORWINDOWS"); | 542 String dbgengPath = null; |
538 | 543 String dbghelpPath = null; |
539 if (DTFWHome == null) { | 544 String sawindbgPath = null; |
540 // See if we have the files in the default location. | 545 List searchList = new ArrayList(); |
546 | |
547 boolean loadLibraryDEBUG = | |
548 System.getProperty("sun.jvm.hotspot.loadLibrary.DEBUG") != null; | |
549 | |
550 { | |
551 // First place to search is co-located with sawindbg.dll in | |
552 // $JAVA_HOME/jre/bin (java.home property is set to $JAVA_HOME/jre): | |
553 searchList.add(System.getProperty("java.home") + File.separator + "bin"); | |
554 sawindbgPath = (String) searchList.get(0) + File.separator + | |
555 "sawindbg.dll"; | |
556 | |
557 // second place to search is specified by an environment variable: | |
558 String DTFWHome = System.getenv("DEBUGGINGTOOLSFORWINDOWS"); | |
559 if (DTFWHome != null) { | |
560 searchList.add(DTFWHome); | |
561 } | |
562 | |
563 // The third place to search is the install directory for the | |
564 // "Debugging Tools For Windows" package; so far there are three | |
565 // name variations that we know of: | |
541 String sysRoot = System.getenv("SYSTEMROOT"); | 566 String sysRoot = System.getenv("SYSTEMROOT"); |
542 DTFWHome = sysRoot + File.separator + | 567 DTFWHome = sysRoot + File.separator + ".." + File.separator + |
543 ".." + File.separator + "Program Files" + | 568 "Program Files" + File.separator + "Debugging Tools For Windows"; |
544 File.separator + "Debugging Tools For Windows"; | 569 searchList.add(DTFWHome); |
545 } | 570 searchList.add(DTFWHome + " (x86)"); |
546 | 571 searchList.add(DTFWHome + " (x64)"); |
547 { | 572 |
548 String dbghelp = DTFWHome + File.separator + "dbghelp.dll"; | 573 // The last place to search is the system directory: |
549 String dbgeng = DTFWHome + File.separator + "dbgeng.dll"; | 574 searchList.add(sysRoot + File.separator + "system32"); |
550 File fhelp = new File(dbghelp); | 575 } |
551 File feng = new File(dbgeng); | 576 |
552 if (fhelp.exists() && feng.exists()) { | 577 for (int i = 0; i < searchList.size(); i++) { |
553 // found both, we are happy. | 578 File dir = new File((String) searchList.get(i)); |
554 // NOTE: The order of loads is important! If we load dbgeng.dll | 579 if (!dir.exists()) { |
555 // first, then the dependency - dbghelp.dll - will be loaded | 580 if (loadLibraryDEBUG) { |
556 // from usual DLL search thereby defeating the purpose! | 581 System.err.println("DEBUG: '" + searchList.get(i) + |
557 System.load(dbghelp); | 582 "': directory does not exist."); |
558 System.load(dbgeng); | 583 } |
559 } else if (! fhelp.exists() && ! feng.exists()) { | 584 // this search directory doesn't exist so skip it |
560 // neither exist. We will ignore this dir and assume | 585 continue; |
561 // they are in the system dir. | 586 } |
562 DTFWHome = null; | 587 |
588 dbgengPath = (String) searchList.get(i) + File.separator + "dbgeng.dll"; | |
589 dbghelpPath = (String) searchList.get(i) + File.separator + "dbghelp.dll"; | |
590 | |
591 File feng = new File(dbgengPath); | |
592 File fhelp = new File(dbghelpPath); | |
593 if (feng.exists() && fhelp.exists()) { | |
594 // both files exist so we have a match | |
595 break; | |
596 } | |
597 | |
598 // At least one of the files does not exist; no warning if both | |
599 // don't exist. If just one doesn't exist then we don't check | |
600 // loadLibraryDEBUG because we have a mis-configured system. | |
601 if (feng.exists()) { | |
602 System.err.println("WARNING: found '" + dbgengPath + | |
603 "' but did not find '" + dbghelpPath + "'; ignoring '" + | |
604 dbgengPath + "'."); | |
605 } else if (fhelp.exists()) { | |
606 System.err.println("WARNING: found '" + dbghelpPath + | |
607 "' but did not find '" + dbgengPath + "'; ignoring '" + | |
608 dbghelpPath + "'."); | |
609 } else if (loadLibraryDEBUG) { | |
610 System.err.println("DEBUG: searched '" + searchList.get(i) + | |
611 "': dbgeng.dll and dbghelp.dll were not found."); | |
612 } | |
613 dbgengPath = null; | |
614 dbghelpPath = null; | |
615 } | |
616 | |
617 if (dbgengPath == null || dbghelpPath == null) { | |
618 // at least one of the files wasn't found anywhere we searched | |
619 String mesg = null; | |
620 | |
621 if (dbgengPath == null && dbghelpPath == null) { | |
622 mesg = "dbgeng.dll and dbghelp.dll cannot be found. "; | |
623 } else if (dbgengPath == null) { | |
624 mesg = "dbgeng.dll cannot be found (dbghelp.dll was found). "; | |
563 } else { | 625 } else { |
564 // one exists but not the other | 626 mesg = "dbghelp.dll cannot be found (dbgeng.dll was found). "; |
565 //System.err.println("Error: Both files dbghelp.dll and dbgeng.dll " | 627 } |
566 // "must exist in directory " + DTFWHome); | 628 throw new UnsatisfiedLinkError(mesg + |
567 throw new UnsatisfiedLinkError("Both files dbghelp.dll and " + | 629 "Please search microsoft.com for 'Debugging Tools For Windows', " + |
568 "dbgeng.dll must exist in " + | 630 "and either download it to the default location, or download it " + |
569 "directory " + DTFWHome); | 631 "to a custom location and set environment variable " + |
570 } | 632 "'DEBUGGINGTOOLSFORWINDOWS' to the pathname of that location."); |
571 } | 633 } |
572 if (DTFWHome == null) { | 634 |
573 // The files better be in the system dir. | 635 // NOTE: The order of loads is important! If we load dbgeng.dll |
574 String sysDir = System.getenv("SYSTEMROOT") + | 636 // first, then the dependency - dbghelp.dll - will be loaded |
575 File.separator + "system32"; | 637 // from usual DLL search thereby defeating the purpose! |
576 | 638 if (loadLibraryDEBUG) { |
577 File feng = new File(sysDir + File.separator + "dbgeng.dll"); | 639 System.err.println("DEBUG: loading '" + dbghelpPath + "'."); |
578 if (!feng.exists()) { | 640 } |
579 throw new UnsatisfiedLinkError("File dbgeng.dll does not exist in " + | 641 System.load(dbghelpPath); |
580 sysDir + ". Please search microsoft.com " + | 642 if (loadLibraryDEBUG) { |
581 "for Debugging Tools For Windows, and " + | 643 System.err.println("DEBUG: loading '" + dbgengPath + "'."); |
582 "either download it to the default " + | 644 } |
583 "location, or download it to a custom " + | 645 System.load(dbgengPath); |
584 "location and set environment variable " + | |
585 " DEBUGGINGTOOLSFORWINDOWS " + | |
586 "to the pathname of that location."); | |
587 } | |
588 } | |
589 | 646 |
590 // Now, load sawindbg.dll | 647 // Now, load sawindbg.dll |
591 System.loadLibrary("sawindbg"); | 648 if (loadLibraryDEBUG) { |
649 System.err.println("DEBUG: loading '" + sawindbgPath + "'."); | |
650 } | |
651 System.load(sawindbgPath); | |
652 | |
592 // where do I find '.exe', '.dll' files? | 653 // where do I find '.exe', '.dll' files? |
593 imagePath = System.getProperty("sun.jvm.hotspot.debugger.windbg.imagePath"); | 654 imagePath = System.getProperty("sun.jvm.hotspot.debugger.windbg.imagePath"); |
594 if (imagePath == null) { | 655 if (imagePath == null) { |
595 imagePath = System.getenv("PATH"); | 656 imagePath = System.getenv("PATH"); |
596 } | 657 } |