hotspot/src/share/tools/hsdis/README
changeset 347 df859fcca515
child 2564 85c3ae53ca1c
equal deleted inserted replaced
346:e13ccc474a28 347:df859fcca515
       
     1 Copyright (c) 2008 Sun Microsystems, Inc.  All Rights Reserved.
       
     2 DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       
     3   
       
     4 This code is free software; you can redistribute it and/or modify it
       
     5 under the terms of the GNU General Public License version 2 only, as
       
     6 published by the Free Software Foundation.
       
     7   
       
     8 This code is distributed in the hope that it will be useful, but WITHOUT
       
     9 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
       
    10 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
       
    11 version 2 for more details (a copy is included in the LICENSE file that
       
    12 accompanied this code).
       
    13  
       
    14 You should have received a copy of the GNU General Public License version
       
    15 2 along with this work; if not, write to the Free Software Foundation,
       
    16 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
       
    17   
       
    18 Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
       
    19 CA 95054 USA or visit www.sun.com if you need additional information or
       
    20 have any questions.
       
    21 
       
    22 ________________________________________________________________________
       
    23 
       
    24 'hsdis':  A HotSpot plugin for disassembling dynamically generated code.
       
    25 
       
    26 The files in this directory (Makefile, hsdis.[ch], hsdis-demo.c)
       
    27 are built independently of the HotSpot JVM.
       
    28 
       
    29 To use the plugin with a JVM, you need a new version that can load it.
       
    30 If the product mode of your JVM does not accept -XX:+PrintAssembly,
       
    31 you do not have a version that is new enough.
       
    32 
       
    33 * Building
       
    34 
       
    35 To build this project you need a build of Gnu binutils to link against.
       
    36 It is known to work with binutils 2.17.
       
    37 
       
    38 The makefile looks for this build in $BINUTILS, or (if that is not set),
       
    39 in  .../binutils-2.17-$LIBARCH, where LIBARCH (as in HotSpot) is one of
       
    40 the jre subdirectory keywords i386, amd64, sparc, sparcv9, etc.
       
    41 
       
    42 To build Gnu binutils, first download a copy of the software:
       
    43   http://directory.fsf.org/project/binutils/
       
    44 
       
    45 Unpack the binutils tarball into an empty directory:
       
    46   chdir ../../../../..
       
    47   tar -xzf - < ../binutils-2.17.tar.gz
       
    48   mv binutils-2.17 binutils-2.17-i386  #or binutils-2.17-sparc
       
    49   cd binutils-2.17-i386
       
    50 
       
    51 From inside that directory, run configure and make:
       
    52   ( export CFLAGS='-fPIC'
       
    53     ./configure i386-pc-elf )
       
    54   gnumake
       
    55 
       
    56 (Leave out or change the argument to configure if not on an i386 system.)
       
    57 
       
    58 Next, untar again into another empty directory for the LP64 version:
       
    59   chdir ..
       
    60   tar -xzf - < ../binutils-2.17.tar.gz
       
    61   mv binutils-2.17 binutils-2.17-amd64  #or binutils-2.17-sparcv9
       
    62   cd binutils-2.17-amd64
       
    63 
       
    64 From inside that directory, run configure for LP64 and make:
       
    65   ( export ac_cv_c_bigendian=no CFLAGS='-m64 -fPIC' LDFLAGS=-m64
       
    66     ./configure amd64-pc-elf )
       
    67   gnumake
       
    68 
       
    69 The -fPIC option is needed because the generated code will be
       
    70 linked into the hsdid-$LIBARCH.so binary.  If you miss the
       
    71 option, the JVM will fail to load the disassembler.
       
    72 
       
    73 You probably want two builds, one for 32 and one for 64 bits.
       
    74 To build the 64-bit variation of a platforn, add LP64=1 to
       
    75 the make command line for hsdis.
       
    76 
       
    77 So, go back to the hsdis project and build:
       
    78   chdir .../hsdis
       
    79   gnumake
       
    80   gnumake LP64=1
       
    81 
       
    82 * Installing
       
    83 
       
    84 Products are named like bin/$OS/hsdis-$LIBARCH.so.
       
    85 You can install them on your LD_LIBRARY_PATH,
       
    86 or inside of your JRE next to $LIBARCH/libjvm.so.
       
    87 
       
    88 Now test:
       
    89   export LD_LIBRARY_PATH .../hsdis/bin/solaris:$LD_LIBRARY_PATH
       
    90   dargs='-XX:+UnlockDiagnosticVMOptions -XX:+PrintAssembly'
       
    91   dargs=$dargs' -XX:PrintAssemblyOptions=hsdis-print-bytes'
       
    92   java $dargs -Xbatch CompileCommand=print,*String.hashCode HelloWorld
       
    93 
       
    94 If the product mode of the JVM does not accept -XX:+PrintAssembly,
       
    95 you do not have a version new enough to use the hsdis plugin.