2685N/ACopyright (c) 2008, Oracle and/or its affiliates. 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
1472N/APlease contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
1472N/Aor visit www.oracle.com if you need additional information or have any
1472N/Aquestions.
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
720N/ATo build this project you a copy of GNU binutils to build against. It
720N/Ais known to work with binutils 2.17 and binutils 2.19.1. Download a
720N/Acopy of the software from http://directory.fsf.org/project/binutils or
720N/Aone of it's mirrors. Builds targetting windows should use at least
720N/A2.19 and currently requires the use of a cross compiler.
100N/A
720N/AThe makefile looks for the sources in build/binutils or you can
720N/Aspecify it's location to the makefile using BINTUILS=path. It will
720N/Aconfigure binutils and build it first and then build and link the
720N/Adisasembly adapter. Make all will build the default target for your
720N/Aplatform. If you platform support both 32 and 64 simultaneously then
720N/A"make both" will build them both at once. "make all64" will
720N/Aexplicitly build the 64 bit version. By default this will build the
720N/Adisassembler library only. If you build demo it will build a demo
720N/Aprogram that attempts to exercise the library.
100N/A
720N/AWindows
100N/A
720N/AIn theory this should be buildable on Windows but getting a working
720N/AGNU build environment on Windows has proven difficult. MINGW should
720N/Abe able to do it but at the time of this writing I was unable to get
720N/Athis working. Instead you can use the mingw cross compiler on linux
720N/Ato produce the windows binaries. For 32-bit windows you can install
720N/Amingw32 using your package manager and it will be added to your path
720N/Aautomatically. For 64-bit you need to download the 64 bit mingw from
720N/Ahttp://sourceforge.net/projects/mingw-w64. Grab a copy of the
720N/Acomplete toolchain and unpack it somewhere. Put the bin directory of
720N/Athe toolchain in your path. The mingw installs contain cross compile
720N/Aversions of gcc that are named with a prefix to indicate what they are
720N/Atargetting and you must tell the Makefile which one to use. This
720N/Ashould either be i586-mingw32msvc or x86_64-pc-mingw32 depending on
720N/Awhich on you are targetting and there should be a version of gcc in
720N/Ayour path named i586-mingw32msvc-gcc or x86_64-pc-mingw32-gcc. Tell
720N/Athe makefile what prefix to use to find the mingw tools by using
720N/AMINGW=. For example:
100N/A
720N/Amake MINGW=i586-mingw32msvc BINTUILS=build/binutils-2.19.1
100N/A
720N/Awill build the Win32 cross compiled version of hsdis based on 2.19.1.
100N/A
100N/A* Installing
100N/A
720N/AProducts are named like build/$OS-$LIBARCH/hsdis-$LIBARCH.so. You can
2619N/Ainstall them on your LD_LIBRARY_PATH, or inside of your JRE/JDK. The
2619N/Asearch path in the JVM is:
2619N/A
2619N/A1. <home>/jre/lib/<arch>/<vm>/libhsdis-<arch>.so
2619N/A2. <home>/jre/lib/<arch>/<vm>/hsdis-<arch>.so
2619N/A3. <home>/jre/lib/<arch>/hsdis-<arch>.so
2619N/A4. hsdis-<arch>.so (using LD_LIBRARY_PATH)
2619N/A
2619N/ANote that there's a bug in hotspot versions prior to hs22 that causes
2619N/Asteps 2 and 3 to fail when used with JDK7.
100N/A
100N/ANow test:
720N/A
720N/A export LD_LIBRARY_PATH .../hsdis/build/$OS-$LIBARCH:$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.