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 a copy of GNU binutils to build against.  It
  36 is known to work with binutils 2.17 and binutils 2.19.1.  Download a
  37 copy of the software from http://directory.fsf.org/project/binutils or
  38 one of it's mirrors.  Builds targetting windows should use at least
  39 2.19 and currently requires the use of a cross compiler.
  40 
  41 Binutils should be configured with the '--disable-nls' flag to disable
  42 Native Language Support, otherwise you might get an "undefined
  43 reference to `libintl_gettext'" if you try to load hsdis.so on systems
  44 which don't have NLS by default.  It also avoids build problems on
  45 other configurations that don't include the full NLS support.
  46 
  47 The makefile looks for the sources in build/binutils or you can
  48 specify it's location to the makefile using BINTUILS=path.  It will
  49 configure binutils and build it first and then build and link the
  50 disasembly adapter.  Make all will build the default target for your
  51 platform.  If you platform support both 32 and 64 simultaneously then
  52 "make both" will build them both at once.  "make all64" will
  53 explicitly build the 64 bit version.  By default this will build the
  54 disassembler library only.  If you build demo it will build a demo
  55 program that attempts to exercise the library.
  56 
  57 Windows
  58 
  59 In theory this should be buildable on Windows but getting a working
  60 GNU build environment on Windows has proven difficult.  MINGW should
  61 be able to do it but at the time of this writing I was unable to get
  62 this working.  Instead you can use the mingw cross compiler on linux
  63 to produce the windows binaries.  For 32-bit windows you can install
  64 mingw32 using your package manager and it will be added to your path
  65 automatically.  For 64-bit you need to download the 64 bit mingw from
  66 http://sourceforge.net/projects/mingw-w64.  Grab a copy of the
  67 complete toolchain and unpack it somewhere.  Put the bin directory of
  68 the toolchain in your path.  The mingw installs contain cross compile
  69 versions of gcc that are named with a prefix to indicate what they are
  70 targetting and you must tell the Makefile which one to use.  This
  71 should either be i586-mingw32msvc or x86_64-pc-mingw32 depending on
  72 which on you are targetting and there should be a version of gcc in
  73 your path named i586-mingw32msvc-gcc or x86_64-pc-mingw32-gcc.  Tell
  74 the makefile what prefix to use to find the mingw tools by using
  75 MINGW=.  For example:
  76 
  77 make MINGW=i586-mingw32msvc BINTUILS=build/binutils-2.19.1
  78 
  79 will build the Win32 cross compiled version of hsdis based on 2.19.1.
  80 
  81 * Installing
  82 
  83 Products are named like build/$OS-$LIBARCH/hsdis-$LIBARCH.so.  You can
  84 install them on your LD_LIBRARY_PATH, or inside of your JRE next to
  85 $LIBARCH/libjvm.so.
  86 
  87 Now test:
  88 
  89   export LD_LIBRARY_PATH .../hsdis/build/$OS-$LIBARCH:$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.