comparison agent/src/share/classes/sun/jvm/hotspot/bugspot/BugSpotAgent.java @ 3939:f6f3bb0ee072

7088955: add C2 IR support to the SA Reviewed-by: kvn
author never
date Sun, 11 Sep 2011 14:48:24 -0700
parents c18cbe5936b8
children f08d439fab8c
comparison
equal deleted inserted replaced
3938:e6b1331a51d2 3939:f6f3bb0ee072
1 /* 1 /*
2 * Copyright (c) 2002, 2006, Oracle and/or its affiliates. All rights reserved. 2 * Copyright (c) 2002, 2011, 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.
27 import java.io.PrintStream; 27 import java.io.PrintStream;
28 import java.net.*; 28 import java.net.*;
29 import java.rmi.*; 29 import java.rmi.*;
30 import sun.jvm.hotspot.*; 30 import sun.jvm.hotspot.*;
31 import sun.jvm.hotspot.debugger.*; 31 import sun.jvm.hotspot.debugger.*;
32 import sun.jvm.hotspot.debugger.dbx.*;
33 import sun.jvm.hotspot.debugger.proc.*; 32 import sun.jvm.hotspot.debugger.proc.*;
34 import sun.jvm.hotspot.debugger.cdbg.*; 33 import sun.jvm.hotspot.debugger.cdbg.*;
35 import sun.jvm.hotspot.debugger.win32.*;
36 import sun.jvm.hotspot.debugger.windbg.*; 34 import sun.jvm.hotspot.debugger.windbg.*;
37 import sun.jvm.hotspot.debugger.linux.*; 35 import sun.jvm.hotspot.debugger.linux.*;
38 import sun.jvm.hotspot.debugger.sparc.*; 36 import sun.jvm.hotspot.debugger.sparc.*;
39 import sun.jvm.hotspot.debugger.remote.*; 37 import sun.jvm.hotspot.debugger.remote.*;
40 import sun.jvm.hotspot.livejvm.*; 38 import sun.jvm.hotspot.livejvm.*;
625 // Solaris 623 // Solaris
626 // 624 //
627 625
628 private void setupDebuggerSolaris() { 626 private void setupDebuggerSolaris() {
629 setupJVMLibNamesSolaris(); 627 setupJVMLibNamesSolaris();
630 String prop = System.getProperty("sun.jvm.hotspot.debugger.useProcDebugger"); 628 ProcDebuggerLocal dbg = new ProcDebuggerLocal(null, true);
631 if (prop != null && !prop.equals("false")) { 629 debugger = dbg;
632 ProcDebuggerLocal dbg = new ProcDebuggerLocal(null, true); 630 attachDebugger();
633 debugger = dbg; 631
634 attachDebugger(); 632 // Set up CPU-dependent stuff
635 633 if (cpu.equals("x86")) {
636 // Set up CPU-dependent stuff 634 machDesc = new MachineDescriptionIntelX86();
637 if (cpu.equals("x86")) { 635 } else if (cpu.equals("sparc")) {
638 machDesc = new MachineDescriptionIntelX86(); 636 int addressSize = dbg.getRemoteProcessAddressSize();
639 } else if (cpu.equals("sparc")) { 637 if (addressSize == -1) {
640 int addressSize = dbg.getRemoteProcessAddressSize(); 638 throw new DebuggerException("Error occurred while trying to determine the remote process's address size");
641 if (addressSize == -1) { 639 }
642 throw new DebuggerException("Error occurred while trying to determine the remote process's address size"); 640
643 } 641 if (addressSize == 32) {
644 642 machDesc = new MachineDescriptionSPARC32Bit();
645 if (addressSize == 32) { 643 } else if (addressSize == 64) {
646 machDesc = new MachineDescriptionSPARC32Bit(); 644 machDesc = new MachineDescriptionSPARC64Bit();
647 } else if (addressSize == 64) {
648 machDesc = new MachineDescriptionSPARC64Bit();
649 } else {
650 throw new DebuggerException("Address size " + addressSize + " is not supported on SPARC");
651 }
652 } else if (cpu.equals("amd64")) {
653 machDesc = new MachineDescriptionAMD64();
654 } else { 645 } else {
655 throw new DebuggerException("Solaris only supported on sparc/sparcv9/x86/amd64"); 646 throw new DebuggerException("Address size " + addressSize + " is not supported on SPARC");
656 } 647 }
657 648 } else if (cpu.equals("amd64")) {
658 dbg.setMachineDescription(machDesc); 649 machDesc = new MachineDescriptionAMD64();
659 return;
660 } else { 650 } else {
661 String dbxPathName; 651 throw new DebuggerException("Solaris only supported on sparc/sparcv9/x86/amd64");
662 String dbxPathPrefix; 652 }
663 String dbxSvcAgentDSOPathName; 653
664 String dbxSvcAgentDSOPathPrefix; 654 dbg.setMachineDescription(machDesc);
665 String[] dbxSvcAgentDSOPathNames = null;
666
667 // use path names/prefixes specified on command
668 dbxPathName = System.getProperty("dbxPathName");
669 if (dbxPathName == null) {
670 dbxPathPrefix = System.getProperty("dbxPathPrefix");
671 if (dbxPathPrefix == null) {
672 dbxPathPrefix = defaultDbxPathPrefix;
673 }
674 dbxPathName = dbxPathPrefix + fileSep + os + fileSep + cpu + fileSep + "bin" + fileSep + "dbx";
675 }
676
677 dbxSvcAgentDSOPathName = System.getProperty("dbxSvcAgentDSOPathName");
678 if (dbxSvcAgentDSOPathName != null) {
679 dbxSvcAgentDSOPathNames = new String[] { dbxSvcAgentDSOPathName } ;
680 } else {
681 dbxSvcAgentDSOPathPrefix = System.getProperty("dbxSvcAgentDSOPathPrefix");
682 if (dbxSvcAgentDSOPathPrefix == null) {
683 dbxSvcAgentDSOPathPrefix = defaultDbxSvcAgentDSOPathPrefix;
684 }
685 if (cpu.equals("sparc")) {
686 dbxSvcAgentDSOPathNames = new String[] {
687 // FIXME: bad hack for SPARC v9. This is necessary because
688 // there are two dbx executables on SPARC, one for v8 and one
689 // for v9, and it isn't obvious how to tell the two apart
690 // using the dbx command line. See
691 // DbxDebuggerLocal.importDbxModule().
692 dbxSvcAgentDSOPathPrefix + fileSep + os + fileSep + cpu + "v9" + fileSep + "lib" + fileSep + "libsvc_agent_dbx.so",
693 dbxSvcAgentDSOPathPrefix + fileSep + os + fileSep + cpu + fileSep + "lib" + fileSep + "libsvc_agent_dbx.so",
694 };
695 } else {
696 dbxSvcAgentDSOPathNames = new String[] {
697 dbxSvcAgentDSOPathPrefix + fileSep + os + fileSep + cpu + fileSep + "lib" + fileSep + "libsvc_agent_dbx.so"
698 };
699 }
700 }
701 // Note we do not use a cache for the local debugger in server
702 // mode; it's taken care of on the client side
703 DbxDebuggerLocal dbg = new DbxDebuggerLocal(null, dbxPathName, dbxSvcAgentDSOPathNames, !isServer);
704 debugger = dbg;
705
706 attachDebugger();
707
708 // Set up CPU-dependent stuff
709 if (cpu.equals("x86")) {
710 machDesc = new MachineDescriptionIntelX86();
711 } else if (cpu.equals("sparc")) {
712 int addressSize = dbg.getRemoteProcessAddressSize();
713 if (addressSize == -1) {
714 throw new DebuggerException("Error occurred while trying to determine the remote process's address size. It's possible that the Serviceability Agent's dbx module failed to initialize. Examine the standard output and standard error streams from the dbx process for more information.");
715 }
716
717 if (addressSize == 32) {
718 machDesc = new MachineDescriptionSPARC32Bit();
719 } else if (addressSize == 64) {
720 machDesc = new MachineDescriptionSPARC64Bit();
721 } else {
722 throw new DebuggerException("Address size " + addressSize + " is not supported on SPARC");
723 }
724 }
725
726 dbg.setMachineDescription(machDesc);
727 }
728 } 655 }
729 656
730 private void connectRemoteDebugger() throws DebuggerException { 657 private void connectRemoteDebugger() throws DebuggerException {
731 RemoteDebugger remote = 658 RemoteDebugger remote =
732 (RemoteDebugger) RMIHelper.lookup(debugServerID); 659 (RemoteDebugger) RMIHelper.lookup(debugServerID);
770 697
771 // Note we do not use a cache for the local debugger in server 698 // Note we do not use a cache for the local debugger in server
772 // mode; it will be taken care of on the client side (once remote 699 // mode; it will be taken care of on the client side (once remote
773 // debugging is implemented). 700 // debugging is implemented).
774 701
775 if (System.getProperty("sun.jvm.hotspot.debugger.useWindbgDebugger") != null) { 702 debugger = new WindbgDebuggerLocal(machDesc, !isServer);
776 debugger = new WindbgDebuggerLocal(machDesc, !isServer);
777 } else {
778 debugger = new Win32DebuggerLocal(machDesc, !isServer);
779 }
780 703
781 attachDebugger(); 704 attachDebugger();
782 } 705 }
783 706
784 private void setupJVMLibNamesWin32() { 707 private void setupJVMLibNamesWin32() {