README revision 100
100N/ACopyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved.
100N/ADO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
100N/A
100N/AThis code is free software; you can redistribute it and/or modify it
100N/Aunder the terms of the GNU General Public License version 2 only, as
100N/Apublished by the Free Software Foundation.
100N/A
100N/AThis code is distributed in the hope that it will be useful, but WITHOUT
100N/AANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
100N/AFITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
100N/Aversion 2 for more details (a copy is included in the LICENSE file that
100N/Aaccompanied this code).
100N/A
100N/AYou should have received a copy of the GNU General Public License version
100N/A2 along with this work; if not, write to the Free Software Foundation,
100N/AInc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
100N/A
100N/APlease contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
100N/ACA 95054 USA or visit www.sun.com if you need additional information or
100N/Ahave any questions.
100N/A
100N/A________________________________________________________________________
100N/A
100N/A'hsdis': A HotSpot plugin for disassembling dynamically generated code.
100N/A
100N/AThe files in this directory (Makefile, hsdis.[ch], hsdis-demo.c)
100N/Aare built independently of the HotSpot JVM.
100N/A
100N/ATo use the plugin with a JVM, you need a new version that can load it.
100N/AIf the product mode of your JVM does not accept -XX:+PrintAssembly,
100N/Ayou do not have a version that is new enough.
100N/A
100N/A* Building
100N/A
100N/ATo build this project you need a build of Gnu binutils to link against.
100N/AIt is known to work with binutils 2.17.
100N/A
100N/AThe makefile looks for this build in $BINUTILS, or (if that is not set),
100N/Ain .../binutils-2.17-$LIBARCH, where LIBARCH (as in HotSpot) is one of
100N/Athe jre subdirectory keywords i386, amd64, sparc, sparcv9, etc.
100N/A
100N/ATo build Gnu binutils, first download a copy of the software:
100N/A http://directory.fsf.org/project/binutils/
100N/A
100N/AUnpack the binutils tarball into an empty directory:
100N/A chdir ../../../../..
100N/A tar -xzf - < ../binutils-2.17.tar.gz
100N/A mv binutils-2.17 binutils-2.17-i386 #or binutils-2.17-sparc
100N/A cd binutils-2.17-i386
100N/A
100N/AFrom inside that directory, run configure and make:
100N/A ( export CFLAGS='-fPIC'
100N/A ./configure i386-pc-elf )
100N/A gnumake
100N/A
100N/A(Leave out or change the argument to configure if not on an i386 system.)
100N/A
100N/ANext, untar again into another empty directory for the LP64 version:
100N/A chdir ..
100N/A tar -xzf - < ../binutils-2.17.tar.gz
100N/A mv binutils-2.17 binutils-2.17-amd64 #or binutils-2.17-sparcv9
100N/A cd binutils-2.17-amd64
100N/A
100N/AFrom inside that directory, run configure for LP64 and make:
100N/A ( export ac_cv_c_bigendian=no CFLAGS='-m64 -fPIC' LDFLAGS=-m64
100N/A ./configure amd64-pc-elf )
100N/A gnumake
100N/A
100N/AThe -fPIC option is needed because the generated code will be
100N/Alinked into the hsdid-$LIBARCH.so binary. If you miss the
100N/Aoption, the JVM will fail to load the disassembler.
100N/A
100N/AYou probably want two builds, one for 32 and one for 64 bits.
100N/ATo build the 64-bit variation of a platforn, add LP64=1 to
100N/Athe make command line for hsdis.
100N/A
100N/ASo, go back to the hsdis project and build:
100N/A chdir .../hsdis
100N/A gnumake
100N/A gnumake LP64=1
100N/A
100N/A* Installing
100N/A
100N/AProducts are named like bin/$OS/hsdis-$LIBARCH.so.
100N/AYou can install them on your LD_LIBRARY_PATH,
100N/Aor inside of your JRE next to $LIBARCH/libjvm.so.
100N/A
100N/ANow test:
100N/A export LD_LIBRARY_PATH .../hsdis/bin/solaris:$LD_LIBRARY_PATH
100N/A dargs='-XX:+UnlockDiagnosticVMOptions -XX:+PrintAssembly'
100N/A dargs=$dargs' -XX:PrintAssemblyOptions=hsdis-print-bytes'
100N/A java $dargs -Xbatch CompileCommand=print,*String.hashCode HelloWorld
100N/A
100N/AIf the product mode of the JVM does not accept -XX:+PrintAssembly,
100N/Ayou do not have a version new enough to use the hsdis plugin.