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

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

Print this page
8003348: SA can not read core file on OS X
   1 /*
   2  * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
   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  *
  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  *


 294             // server, but not client attaching to server)
 295             //
 296 
 297             try {
 298                 os  = PlatformInfo.getOS();
 299                 cpu = PlatformInfo.getCPU();
 300             }
 301             catch (UnsupportedPlatformException e) {
 302                 throw new DebuggerException(e);
 303             }
 304             fileSep = System.getProperty("file.separator");
 305 
 306             if (os.equals("solaris")) {
 307                 setupDebuggerSolaris();
 308             } else if (os.equals("win32")) {
 309                 setupDebuggerWin32();
 310             } else if (os.equals("linux")) {
 311                 setupDebuggerLinux();
 312             } else if (os.equals("bsd")) {
 313                 setupDebuggerBsd();


 314             } else {
 315                 // Add support for more operating systems here
 316                 throw new DebuggerException("Operating system " + os + " not yet supported");
 317             }
 318 
 319             if (isServer) {
 320                 RemoteDebuggerServer remote = null;
 321                 try {
 322                     remote = new RemoteDebuggerServer(debugger);
 323                 }
 324                 catch (RemoteException rem) {
 325                     throw new DebuggerException(rem);
 326                 }
 327                 RMIHelper.rebind(serverID, remote);
 328             }
 329         } else {
 330             //
 331             // Remote mode (client attaching to server)
 332             //
 333 


 353         // consider making constant). On the client it is used to
 354         // configure the VM.
 355 
 356         try {
 357             if (os.equals("solaris")) {
 358                 db = new HotSpotTypeDataBase(machDesc,
 359                 new HotSpotSolarisVtblAccess(debugger, jvmLibNames),
 360                 debugger, jvmLibNames);
 361             } else if (os.equals("win32")) {
 362                 db = new HotSpotTypeDataBase(machDesc,
 363                 new Win32VtblAccess(debugger, jvmLibNames),
 364                 debugger, jvmLibNames);
 365             } else if (os.equals("linux")) {
 366                 db = new HotSpotTypeDataBase(machDesc,
 367                 new LinuxVtblAccess(debugger, jvmLibNames),
 368                 debugger, jvmLibNames);
 369             } else if (os.equals("bsd")) {
 370                 db = new HotSpotTypeDataBase(machDesc,
 371                 new BsdVtblAccess(debugger, jvmLibNames),
 372                 debugger, jvmLibNames);




 373             } else {
 374                 throw new DebuggerException("OS \"" + os + "\" not yet supported (no VtblAccess yet)");
 375             }
 376         }
 377         catch (NoSuchSymbolException e) {
 378             throw new DebuggerException("Doesn't appear to be a HotSpot VM (could not find symbol \"" +
 379             e.getSymbol() + "\" in remote process)");
 380         }
 381 
 382         if (startupMode != REMOTE_MODE) {
 383             // Configure the debugger with the primitive type sizes just obtained from the VM
 384             debugger.configureJavaPrimitiveTypeSizes(db.getJBooleanType().getSize(),
 385             db.getJByteType().getSize(),
 386             db.getJCharType().getSize(),
 387             db.getJDoubleType().getSize(),
 388             db.getJFloatType().getSize(),
 389             db.getJIntType().getSize(),
 390             db.getJLongType().getSize(),
 391             db.getJShortType().getSize());
 392         }


 442         }
 443 
 444         dbg.setMachineDescription(machDesc);
 445         return;
 446     }
 447 
 448     private void connectRemoteDebugger() throws DebuggerException {
 449         RemoteDebugger remote =
 450         (RemoteDebugger) RMIHelper.lookup(debugServerID);
 451         debugger = new RemoteDebuggerClient(remote);
 452         machDesc = ((RemoteDebuggerClient) debugger).getMachineDescription();
 453         os = debugger.getOS();
 454         if (os.equals("solaris")) {
 455             setupJVMLibNamesSolaris();
 456         } else if (os.equals("win32")) {
 457             setupJVMLibNamesWin32();
 458         } else if (os.equals("linux")) {
 459             setupJVMLibNamesLinux();
 460         } else if (os.equals("bsd")) {
 461             setupJVMLibNamesBsd();


 462         } else {
 463             throw new RuntimeException("Unknown OS type");
 464         }
 465 
 466         cpu = debugger.getCPU();
 467     }
 468 
 469     private void setupJVMLibNamesSolaris() {
 470         jvmLibNames = new String[] { "libjvm.so", "libjvm_g.so", "gamma_g" };
 471     }
 472 
 473     //
 474     // Win32
 475     //
 476 
 477     private void setupDebuggerWin32() {
 478         setupJVMLibNamesWin32();
 479 
 480         if (cpu.equals("x86")) {
 481             machDesc = new MachineDescriptionIntelX86();


 550         setupJVMLibNamesBsd();
 551 
 552         if (cpu.equals("x86")) {
 553             machDesc = new MachineDescriptionIntelX86();
 554         } else if (cpu.equals("amd64") || cpu.equals("x86_64")) {
 555             machDesc = new MachineDescriptionAMD64();
 556         } else {
 557             throw new DebuggerException("BSD only supported on x86/x86_64. Current arch: " + cpu);
 558         }
 559 
 560         BsdDebuggerLocal dbg = new BsdDebuggerLocal(machDesc, !isServer);
 561         debugger = dbg;
 562 
 563         attachDebugger();
 564     }
 565 
 566     private void setupJVMLibNamesBsd() {
 567         jvmLibNames = new String[] { "libjvm.so", "libjvm_g.so" };
 568     }
 569 























 570     /** Convenience routine which should be called by per-platform
 571       debugger setup. Should not be called when startupMode is
 572       REMOTE_MODE. */
 573     private void attachDebugger() {
 574         if (startupMode == PROCESS_MODE) {
 575             debugger.attach(pid);
 576         } else if (startupMode == CORE_FILE_MODE) {
 577             debugger.attach(javaExecutableName, coreFileName);
 578         } else {
 579             throw new DebuggerException("Should not call attach() for startupMode == " + startupMode);
 580         }
 581     }
 582 }
   1 /*
   2  * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
   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  *
  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  *


 294             // server, but not client attaching to server)
 295             //
 296 
 297             try {
 298                 os  = PlatformInfo.getOS();
 299                 cpu = PlatformInfo.getCPU();
 300             }
 301             catch (UnsupportedPlatformException e) {
 302                 throw new DebuggerException(e);
 303             }
 304             fileSep = System.getProperty("file.separator");
 305 
 306             if (os.equals("solaris")) {
 307                 setupDebuggerSolaris();
 308             } else if (os.equals("win32")) {
 309                 setupDebuggerWin32();
 310             } else if (os.equals("linux")) {
 311                 setupDebuggerLinux();
 312             } else if (os.equals("bsd")) {
 313                 setupDebuggerBsd();
 314             } else if (os.equals("darwin")) {
 315                 setupDebuggerDarwin();
 316             } else {
 317                 // Add support for more operating systems here
 318                 throw new DebuggerException("Operating system " + os + " not yet supported");
 319             }
 320 
 321             if (isServer) {
 322                 RemoteDebuggerServer remote = null;
 323                 try {
 324                     remote = new RemoteDebuggerServer(debugger);
 325                 }
 326                 catch (RemoteException rem) {
 327                     throw new DebuggerException(rem);
 328                 }
 329                 RMIHelper.rebind(serverID, remote);
 330             }
 331         } else {
 332             //
 333             // Remote mode (client attaching to server)
 334             //
 335 


 355         // consider making constant). On the client it is used to
 356         // configure the VM.
 357 
 358         try {
 359             if (os.equals("solaris")) {
 360                 db = new HotSpotTypeDataBase(machDesc,
 361                 new HotSpotSolarisVtblAccess(debugger, jvmLibNames),
 362                 debugger, jvmLibNames);
 363             } else if (os.equals("win32")) {
 364                 db = new HotSpotTypeDataBase(machDesc,
 365                 new Win32VtblAccess(debugger, jvmLibNames),
 366                 debugger, jvmLibNames);
 367             } else if (os.equals("linux")) {
 368                 db = new HotSpotTypeDataBase(machDesc,
 369                 new LinuxVtblAccess(debugger, jvmLibNames),
 370                 debugger, jvmLibNames);
 371             } else if (os.equals("bsd")) {
 372                 db = new HotSpotTypeDataBase(machDesc,
 373                 new BsdVtblAccess(debugger, jvmLibNames),
 374                 debugger, jvmLibNames);
 375             } else if (os.equals("darwin")) {
 376                 db = new HotSpotTypeDataBase(machDesc,
 377                 new BsdVtblAccess(debugger, jvmLibNames),
 378                 debugger, jvmLibNames);
 379             } else {
 380                 throw new DebuggerException("OS \"" + os + "\" not yet supported (no VtblAccess yet)");
 381             }
 382         }
 383         catch (NoSuchSymbolException e) {
 384             throw new DebuggerException("Doesn't appear to be a HotSpot VM (could not find symbol \"" +
 385             e.getSymbol() + "\" in remote process)");
 386         }
 387 
 388         if (startupMode != REMOTE_MODE) {
 389             // Configure the debugger with the primitive type sizes just obtained from the VM
 390             debugger.configureJavaPrimitiveTypeSizes(db.getJBooleanType().getSize(),
 391             db.getJByteType().getSize(),
 392             db.getJCharType().getSize(),
 393             db.getJDoubleType().getSize(),
 394             db.getJFloatType().getSize(),
 395             db.getJIntType().getSize(),
 396             db.getJLongType().getSize(),
 397             db.getJShortType().getSize());
 398         }


 448         }
 449 
 450         dbg.setMachineDescription(machDesc);
 451         return;
 452     }
 453 
 454     private void connectRemoteDebugger() throws DebuggerException {
 455         RemoteDebugger remote =
 456         (RemoteDebugger) RMIHelper.lookup(debugServerID);
 457         debugger = new RemoteDebuggerClient(remote);
 458         machDesc = ((RemoteDebuggerClient) debugger).getMachineDescription();
 459         os = debugger.getOS();
 460         if (os.equals("solaris")) {
 461             setupJVMLibNamesSolaris();
 462         } else if (os.equals("win32")) {
 463             setupJVMLibNamesWin32();
 464         } else if (os.equals("linux")) {
 465             setupJVMLibNamesLinux();
 466         } else if (os.equals("bsd")) {
 467             setupJVMLibNamesBsd();
 468         } else if (os.equals("darwin")) {
 469             setupJVMLibNamesDarwin();
 470         } else {
 471             throw new RuntimeException("Unknown OS type");
 472         }
 473 
 474         cpu = debugger.getCPU();
 475     }
 476 
 477     private void setupJVMLibNamesSolaris() {
 478         jvmLibNames = new String[] { "libjvm.so", "libjvm_g.so", "gamma_g" };
 479     }
 480 
 481     //
 482     // Win32
 483     //
 484 
 485     private void setupDebuggerWin32() {
 486         setupJVMLibNamesWin32();
 487 
 488         if (cpu.equals("x86")) {
 489             machDesc = new MachineDescriptionIntelX86();


 558         setupJVMLibNamesBsd();
 559 
 560         if (cpu.equals("x86")) {
 561             machDesc = new MachineDescriptionIntelX86();
 562         } else if (cpu.equals("amd64") || cpu.equals("x86_64")) {
 563             machDesc = new MachineDescriptionAMD64();
 564         } else {
 565             throw new DebuggerException("BSD only supported on x86/x86_64. Current arch: " + cpu);
 566         }
 567 
 568         BsdDebuggerLocal dbg = new BsdDebuggerLocal(machDesc, !isServer);
 569         debugger = dbg;
 570 
 571         attachDebugger();
 572     }
 573 
 574     private void setupJVMLibNamesBsd() {
 575         jvmLibNames = new String[] { "libjvm.so", "libjvm_g.so" };
 576     }
 577 
 578     //
 579     // Darwin
 580     //
 581 
 582     private void setupDebuggerDarwin() {
 583         setupJVMLibNamesDarwin();
 584 
 585         if (cpu.equals("amd64") || cpu.equals("x86_64")) {
 586             machDesc = new MachineDescriptionAMD64();
 587         } else {
 588             throw new DebuggerException("Darwin only supported on x86_64. Current arch: " + cpu);
 589         }
 590 
 591         BsdDebuggerLocal dbg = new BsdDebuggerLocal(machDesc, !isServer);
 592         debugger = dbg;
 593 
 594         attachDebugger();
 595     }
 596 
 597     private void setupJVMLibNamesDarwin() {
 598         jvmLibNames = new String[] { "libjvm.dylib", "libjvm_g.dylib" };
 599     }
 600 
 601     /** Convenience routine which should be called by per-platform
 602       debugger setup. Should not be called when startupMode is
 603       REMOTE_MODE. */
 604     private void attachDebugger() {
 605         if (startupMode == PROCESS_MODE) {
 606             debugger.attach(pid);
 607         } else if (startupMode == CORE_FILE_MODE) {
 608             debugger.attach(javaExecutableName, coreFileName);
 609         } else {
 610             throw new DebuggerException("Should not call attach() for startupMode == " + startupMode);
 611         }
 612     }
 613 }
agent/src/share/classes/sun/jvm/hotspot/HotSpotAgent.java
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File