agent/src/share/classes/sun/jvm/hotspot/HotSpotAgent.java
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File 7089790_full Sdiff agent/src/share/classes/sun/jvm/hotspot

agent/src/share/classes/sun/jvm/hotspot/HotSpotAgent.java

Print this page
rev 2695 : shared changes


  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  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 package sun.jvm.hotspot;
  26 
  27 import java.io.PrintStream;
  28 import java.net.*;
  29 import java.rmi.*;
  30 import sun.jvm.hotspot.debugger.*;

  31 import sun.jvm.hotspot.debugger.proc.*;
  32 import sun.jvm.hotspot.debugger.remote.*;
  33 import sun.jvm.hotspot.debugger.windbg.*;
  34 import sun.jvm.hotspot.debugger.linux.*;
  35 import sun.jvm.hotspot.memory.*;
  36 import sun.jvm.hotspot.oops.*;
  37 import sun.jvm.hotspot.runtime.*;
  38 import sun.jvm.hotspot.types.*;
  39 import sun.jvm.hotspot.utilities.*;
  40 
  41 /** <P> This class wraps much of the basic functionality and is the
  42  * highest-level factory for VM data structures. It makes it simple
  43  * to start up the debugging system. </P>
  44  *
  45  * <P> FIXME: need to add a way to configure the paths to dbx and the
  46  * DSO from the outside. However, this should work for now for
  47  * internal use. </P>
  48  *
  49  * <P> FIXME: especially with the addition of remote debugging, this
  50  * has turned into a mess; needs rethinking. </P>


 318             //
 319             // Local mode (client attaching to local process or setting up
 320             // server, but not client attaching to server)
 321             //
 322 
 323             try {
 324                 os  = PlatformInfo.getOS();
 325                 cpu = PlatformInfo.getCPU();
 326             }
 327             catch (UnsupportedPlatformException e) {
 328                 throw new DebuggerException(e);
 329             }
 330             fileSep = System.getProperty("file.separator");
 331 
 332             if (os.equals("solaris")) {
 333                 setupDebuggerSolaris();
 334             } else if (os.equals("win32")) {
 335                 setupDebuggerWin32();
 336             } else if (os.equals("linux")) {
 337                 setupDebuggerLinux();


 338             } else {
 339                 // Add support for more operating systems here
 340                 throw new DebuggerException("Operating system " + os + " not yet supported");
 341             }
 342 
 343             if (isServer) {
 344                 RemoteDebuggerServer remote = null;
 345                 try {
 346                     remote = new RemoteDebuggerServer(debugger);
 347                 }
 348                 catch (RemoteException rem) {
 349                     throw new DebuggerException(rem);
 350                 }
 351                 RMIHelper.rebind(serverID, remote);
 352             }
 353         } else {
 354             //
 355             // Remote mode (client attaching to server)
 356             //
 357 


 373     private void setupVM() {
 374         // We need to instantiate a HotSpotTypeDataBase on both the client
 375         // and server machine. On the server it is only currently used to
 376         // configure the Java primitive type sizes (which we should
 377         // consider making constant). On the client it is used to
 378         // configure the VM.
 379 
 380         try {
 381             if (os.equals("solaris")) {
 382                 db = new HotSpotTypeDataBase(machDesc,
 383                 new HotSpotSolarisVtblAccess(debugger, jvmLibNames),
 384                 debugger, jvmLibNames);
 385             } else if (os.equals("win32")) {
 386                 db = new HotSpotTypeDataBase(machDesc,
 387                 new Win32VtblAccess(debugger, jvmLibNames),
 388                 debugger, jvmLibNames);
 389             } else if (os.equals("linux")) {
 390                 db = new HotSpotTypeDataBase(machDesc,
 391                 new LinuxVtblAccess(debugger, jvmLibNames),
 392                 debugger, jvmLibNames);




 393             } else {
 394                 throw new DebuggerException("OS \"" + os + "\" not yet supported (no VtblAccess yet)");
 395             }
 396         }
 397         catch (NoSuchSymbolException e) {
 398             throw new DebuggerException("Doesn't appear to be a HotSpot VM (could not find symbol \"" +
 399             e.getSymbol() + "\" in remote process)");
 400         }
 401 
 402         if (startupMode != REMOTE_MODE) {
 403             // Configure the debugger with the primitive type sizes just obtained from the VM
 404             debugger.configureJavaPrimitiveTypeSizes(db.getJBooleanType().getSize(),
 405             db.getJByteType().getSize(),
 406             db.getJCharType().getSize(),
 407             db.getJDoubleType().getSize(),
 408             db.getJFloatType().getSize(),
 409             db.getJIntType().getSize(),
 410             db.getJLongType().getSize(),
 411             db.getJShortType().getSize());
 412         }


 460         } else {
 461             throw new DebuggerException("Solaris only supported on sparc/sparcv9/x86/amd64");
 462         }
 463 
 464         dbg.setMachineDescription(machDesc);
 465         return;
 466     }
 467 
 468     private void connectRemoteDebugger() throws DebuggerException {
 469         RemoteDebugger remote =
 470         (RemoteDebugger) RMIHelper.lookup(debugServerID);
 471         debugger = new RemoteDebuggerClient(remote);
 472         machDesc = ((RemoteDebuggerClient) debugger).getMachineDescription();
 473         os = debugger.getOS();
 474         if (os.equals("solaris")) {
 475             setupJVMLibNamesSolaris();
 476         } else if (os.equals("win32")) {
 477             setupJVMLibNamesWin32();
 478         } else if (os.equals("linux")) {
 479             setupJVMLibNamesLinux();


 480         } else {
 481             throw new RuntimeException("Unknown OS type");
 482         }
 483 
 484         cpu = debugger.getCPU();
 485     }
 486 
 487     private void setupJVMLibNamesSolaris() {
 488         jvmLibNames = new String[] { "libjvm.so", "libjvm_g.so", "gamma_g" };
 489     }
 490 
 491     //
 492     // Win32
 493     //
 494 
 495     private void setupDebuggerWin32() {
 496         setupJVMLibNamesWin32();
 497 
 498         if (cpu.equals("x86")) {
 499             machDesc = new MachineDescriptionIntelX86();


 536         } else if (cpu.equals("sparc")) {
 537             if (LinuxDebuggerLocal.getAddressSize()==8) {
 538                     machDesc = new MachineDescriptionSPARC64Bit();
 539             } else {
 540                     machDesc = new MachineDescriptionSPARC32Bit();
 541             }
 542         } else {
 543             throw new DebuggerException("Linux only supported on x86/ia64/amd64/sparc/sparc64");
 544         }
 545 
 546         LinuxDebuggerLocal dbg =
 547         new LinuxDebuggerLocal(machDesc, !isServer);
 548         debugger = dbg;
 549 
 550         attachDebugger();
 551     }
 552 
 553     private void setupJVMLibNamesLinux() {
 554         jvmLibNames = new String[] { "libjvm.so", "libjvm_g.so" };
 555     }

























 556 
 557     /** Convenience routine which should be called by per-platform
 558       debugger setup. Should not be called when startupMode is
 559       REMOTE_MODE. */
 560     private void attachDebugger() {
 561         if (startupMode == PROCESS_MODE) {
 562             debugger.attach(pid);
 563         } else if (startupMode == CORE_FILE_MODE) {
 564             debugger.attach(javaExecutableName, coreFileName);
 565         } else {
 566             throw new DebuggerException("Should not call attach() for startupMode == " + startupMode);
 567         }
 568     }
 569 }


  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  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 package sun.jvm.hotspot;
  26 
  27 import java.io.PrintStream;
  28 import java.net.*;
  29 import java.rmi.*;
  30 import sun.jvm.hotspot.debugger.*;
  31 import sun.jvm.hotspot.debugger.bsd.*;
  32 import sun.jvm.hotspot.debugger.proc.*;
  33 import sun.jvm.hotspot.debugger.remote.*;
  34 import sun.jvm.hotspot.debugger.windbg.*;
  35 import sun.jvm.hotspot.debugger.linux.*;
  36 import sun.jvm.hotspot.memory.*;
  37 import sun.jvm.hotspot.oops.*;
  38 import sun.jvm.hotspot.runtime.*;
  39 import sun.jvm.hotspot.types.*;
  40 import sun.jvm.hotspot.utilities.*;
  41 
  42 /** <P> This class wraps much of the basic functionality and is the
  43  * highest-level factory for VM data structures. It makes it simple
  44  * to start up the debugging system. </P>
  45  *
  46  * <P> FIXME: need to add a way to configure the paths to dbx and the
  47  * DSO from the outside. However, this should work for now for
  48  * internal use. </P>
  49  *
  50  * <P> FIXME: especially with the addition of remote debugging, this
  51  * has turned into a mess; needs rethinking. </P>


 319             //
 320             // Local mode (client attaching to local process or setting up
 321             // server, but not client attaching to server)
 322             //
 323 
 324             try {
 325                 os  = PlatformInfo.getOS();
 326                 cpu = PlatformInfo.getCPU();
 327             }
 328             catch (UnsupportedPlatformException e) {
 329                 throw new DebuggerException(e);
 330             }
 331             fileSep = System.getProperty("file.separator");
 332 
 333             if (os.equals("solaris")) {
 334                 setupDebuggerSolaris();
 335             } else if (os.equals("win32")) {
 336                 setupDebuggerWin32();
 337             } else if (os.equals("linux")) {
 338                 setupDebuggerLinux();
 339             } else if (os.equals("bsd")) {
 340                 setupDebuggerBsd();
 341             } else {
 342                 // Add support for more operating systems here
 343                 throw new DebuggerException("Operating system " + os + " not yet supported");
 344             }
 345 
 346             if (isServer) {
 347                 RemoteDebuggerServer remote = null;
 348                 try {
 349                     remote = new RemoteDebuggerServer(debugger);
 350                 }
 351                 catch (RemoteException rem) {
 352                     throw new DebuggerException(rem);
 353                 }
 354                 RMIHelper.rebind(serverID, remote);
 355             }
 356         } else {
 357             //
 358             // Remote mode (client attaching to server)
 359             //
 360 


 376     private void setupVM() {
 377         // We need to instantiate a HotSpotTypeDataBase on both the client
 378         // and server machine. On the server it is only currently used to
 379         // configure the Java primitive type sizes (which we should
 380         // consider making constant). On the client it is used to
 381         // configure the VM.
 382 
 383         try {
 384             if (os.equals("solaris")) {
 385                 db = new HotSpotTypeDataBase(machDesc,
 386                 new HotSpotSolarisVtblAccess(debugger, jvmLibNames),
 387                 debugger, jvmLibNames);
 388             } else if (os.equals("win32")) {
 389                 db = new HotSpotTypeDataBase(machDesc,
 390                 new Win32VtblAccess(debugger, jvmLibNames),
 391                 debugger, jvmLibNames);
 392             } else if (os.equals("linux")) {
 393                 db = new HotSpotTypeDataBase(machDesc,
 394                 new LinuxVtblAccess(debugger, jvmLibNames),
 395                 debugger, jvmLibNames);
 396             } else if (os.equals("bsd")) {
 397                 db = new HotSpotTypeDataBase(machDesc,
 398                 new BsdVtblAccess(debugger, jvmLibNames),
 399                 debugger, jvmLibNames);
 400             } else {
 401                 throw new DebuggerException("OS \"" + os + "\" not yet supported (no VtblAccess yet)");
 402             }
 403         }
 404         catch (NoSuchSymbolException e) {
 405             throw new DebuggerException("Doesn't appear to be a HotSpot VM (could not find symbol \"" +
 406             e.getSymbol() + "\" in remote process)");
 407         }
 408 
 409         if (startupMode != REMOTE_MODE) {
 410             // Configure the debugger with the primitive type sizes just obtained from the VM
 411             debugger.configureJavaPrimitiveTypeSizes(db.getJBooleanType().getSize(),
 412             db.getJByteType().getSize(),
 413             db.getJCharType().getSize(),
 414             db.getJDoubleType().getSize(),
 415             db.getJFloatType().getSize(),
 416             db.getJIntType().getSize(),
 417             db.getJLongType().getSize(),
 418             db.getJShortType().getSize());
 419         }


 467         } else {
 468             throw new DebuggerException("Solaris only supported on sparc/sparcv9/x86/amd64");
 469         }
 470 
 471         dbg.setMachineDescription(machDesc);
 472         return;
 473     }
 474 
 475     private void connectRemoteDebugger() throws DebuggerException {
 476         RemoteDebugger remote =
 477         (RemoteDebugger) RMIHelper.lookup(debugServerID);
 478         debugger = new RemoteDebuggerClient(remote);
 479         machDesc = ((RemoteDebuggerClient) debugger).getMachineDescription();
 480         os = debugger.getOS();
 481         if (os.equals("solaris")) {
 482             setupJVMLibNamesSolaris();
 483         } else if (os.equals("win32")) {
 484             setupJVMLibNamesWin32();
 485         } else if (os.equals("linux")) {
 486             setupJVMLibNamesLinux();
 487         } else if (os.equals("bsd")) {
 488             setupJVMLibNamesBsd();
 489         } else {
 490             throw new RuntimeException("Unknown OS type");
 491         }
 492 
 493         cpu = debugger.getCPU();
 494     }
 495 
 496     private void setupJVMLibNamesSolaris() {
 497         jvmLibNames = new String[] { "libjvm.so", "libjvm_g.so", "gamma_g" };
 498     }
 499 
 500     //
 501     // Win32
 502     //
 503 
 504     private void setupDebuggerWin32() {
 505         setupJVMLibNamesWin32();
 506 
 507         if (cpu.equals("x86")) {
 508             machDesc = new MachineDescriptionIntelX86();


 545         } else if (cpu.equals("sparc")) {
 546             if (LinuxDebuggerLocal.getAddressSize()==8) {
 547                     machDesc = new MachineDescriptionSPARC64Bit();
 548             } else {
 549                     machDesc = new MachineDescriptionSPARC32Bit();
 550             }
 551         } else {
 552             throw new DebuggerException("Linux only supported on x86/ia64/amd64/sparc/sparc64");
 553         }
 554 
 555         LinuxDebuggerLocal dbg =
 556         new LinuxDebuggerLocal(machDesc, !isServer);
 557         debugger = dbg;
 558 
 559         attachDebugger();
 560     }
 561 
 562     private void setupJVMLibNamesLinux() {
 563         jvmLibNames = new String[] { "libjvm.so", "libjvm_g.so" };
 564     }
 565 
 566     //
 567     // BSD
 568     //
 569 
 570     private void setupDebuggerBsd() {
 571         setupJVMLibNamesBsd();
 572 
 573         if (cpu.equals("x86")) {
 574             machDesc = new MachineDescriptionIntelX86();
 575         } else if (cpu.equals("amd64")) {
 576             machDesc = new MachineDescriptionAMD64();
 577         } else {
 578             throw new DebuggerException("BSD only supported on x86/amd64");
 579         }
 580 
 581         BsdDebuggerLocal dbg = new BsdDebuggerLocal(machDesc, !isServer);
 582         debugger = dbg;
 583 
 584         attachDebugger();
 585     }
 586 
 587     private void setupJVMLibNamesBsd() {
 588         jvmLibNames = new String[] { "libjvm.so", "libjvm_g.so" };
 589     }
 590 
 591     /** Convenience routine which should be called by per-platform
 592       debugger setup. Should not be called when startupMode is
 593       REMOTE_MODE. */
 594     private void attachDebugger() {
 595         if (startupMode == PROCESS_MODE) {
 596             debugger.attach(pid);
 597         } else if (startupMode == CORE_FILE_MODE) {
 598             debugger.attach(javaExecutableName, coreFileName);
 599         } else {
 600             throw new DebuggerException("Should not call attach() for startupMode == " + startupMode);
 601         }
 602     }
 603 }
agent/src/share/classes/sun/jvm/hotspot/HotSpotAgent.java
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File