src/share/tools/hsdis/README

Fri, 02 Nov 2012 13:30:47 -0700

author
minqi
date
Fri, 02 Nov 2012 13:30:47 -0700
changeset 4244
3d701c802d01
parent 4093
5a98bf7d847b
child 6456
c9f0adfb4a8b
permissions
-rw-r--r--

8000489: older builds of hsdis don't work anymore after 6879063
Summary: The old function not defined properly, need a definition for export in dll. Also changes made to let new jvm work with old hsdis.
Reviewed-by: jrose, sspitsyn, kmo
Contributed-by: yumin.qi@oracle.com

minqi@4093 1 Copyright (c) 2008, 2012, Oracle and/or its affiliates. All rights reserved.
jrose@535 2 DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
jrose@535 3
jrose@535 4 This code is free software; you can redistribute it and/or modify it
jrose@535 5 under the terms of the GNU General Public License version 2 only, as
jrose@535 6 published by the Free Software Foundation.
jrose@535 7
jrose@535 8 This code is distributed in the hope that it will be useful, but WITHOUT
jrose@535 9 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
jrose@535 10 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
jrose@535 11 version 2 for more details (a copy is included in the LICENSE file that
jrose@535 12 accompanied this code).
jrose@535 13
jrose@535 14 You should have received a copy of the GNU General Public License version
jrose@535 15 2 along with this work; if not, write to the Free Software Foundation,
jrose@535 16 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
jrose@535 17
trims@1907 18 Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
trims@1907 19 or visit www.oracle.com if you need additional information or have any
trims@1907 20 questions.
jrose@535 21
jrose@535 22 ________________________________________________________________________
jrose@535 23
jrose@535 24 'hsdis': A HotSpot plugin for disassembling dynamically generated code.
jrose@535 25
jrose@535 26 The files in this directory (Makefile, hsdis.[ch], hsdis-demo.c)
jrose@535 27 are built independently of the HotSpot JVM.
jrose@535 28
jrose@535 29 To use the plugin with a JVM, you need a new version that can load it.
jrose@535 30 If the product mode of your JVM does not accept -XX:+PrintAssembly,
jrose@535 31 you do not have a version that is new enough.
jrose@535 32
jrose@535 33 * Building
jrose@535 34
never@1155 35 To build this project you a copy of GNU binutils to build against. It
never@1155 36 is known to work with binutils 2.17 and binutils 2.19.1. Download a
never@1155 37 copy of the software from http://directory.fsf.org/project/binutils or
never@1155 38 one of it's mirrors. Builds targetting windows should use at least
never@1155 39 2.19 and currently requires the use of a cross compiler.
jrose@535 40
minqi@4093 41 Binutils should be configured with the '--disable-nls' flag to disable
minqi@4093 42 Native Language Support, otherwise you might get an "undefined
minqi@4093 43 reference to `libintl_gettext'" if you try to load hsdis.so on systems
minqi@4093 44 which don't have NLS by default. It also avoids build problems on
minqi@4093 45 other configurations that don't include the full NLS support.
minqi@4093 46
never@1155 47 The makefile looks for the sources in build/binutils or you can
minqi@4093 48 specify it's location to the makefile using BINUTILS=path. It will
never@1155 49 configure binutils and build it first and then build and link the
never@1155 50 disasembly adapter. Make all will build the default target for your
never@1155 51 platform. If you platform support both 32 and 64 simultaneously then
never@1155 52 "make both" will build them both at once. "make all64" will
never@1155 53 explicitly build the 64 bit version. By default this will build the
never@1155 54 disassembler library only. If you build demo it will build a demo
never@1155 55 program that attempts to exercise the library.
jrose@535 56
never@1155 57 Windows
jrose@535 58
never@1155 59 In theory this should be buildable on Windows but getting a working
never@1155 60 GNU build environment on Windows has proven difficult. MINGW should
never@1155 61 be able to do it but at the time of this writing I was unable to get
never@1155 62 this working. Instead you can use the mingw cross compiler on linux
never@1155 63 to produce the windows binaries. For 32-bit windows you can install
never@1155 64 mingw32 using your package manager and it will be added to your path
never@1155 65 automatically. For 64-bit you need to download the 64 bit mingw from
never@1155 66 http://sourceforge.net/projects/mingw-w64. Grab a copy of the
never@1155 67 complete toolchain and unpack it somewhere. Put the bin directory of
never@1155 68 the toolchain in your path. The mingw installs contain cross compile
never@1155 69 versions of gcc that are named with a prefix to indicate what they are
never@1155 70 targetting and you must tell the Makefile which one to use. This
never@1155 71 should either be i586-mingw32msvc or x86_64-pc-mingw32 depending on
never@1155 72 which on you are targetting and there should be a version of gcc in
never@1155 73 your path named i586-mingw32msvc-gcc or x86_64-pc-mingw32-gcc. Tell
never@1155 74 the makefile what prefix to use to find the mingw tools by using
never@1155 75 MINGW=. For example:
jrose@535 76
never@1155 77 make MINGW=i586-mingw32msvc BINTUILS=build/binutils-2.19.1
jrose@535 78
never@1155 79 will build the Win32 cross compiled version of hsdis based on 2.19.1.
jrose@535 80
jrose@535 81 * Installing
jrose@535 82
never@1155 83 Products are named like build/$OS-$LIBARCH/hsdis-$LIBARCH.so. You can
never@2991 84 install them on your LD_LIBRARY_PATH, or inside of your JRE/JDK. The
never@2991 85 search path in the JVM is:
never@2991 86
never@2991 87 1. <home>/jre/lib/<arch>/<vm>/libhsdis-<arch>.so
never@2991 88 2. <home>/jre/lib/<arch>/<vm>/hsdis-<arch>.so
never@2991 89 3. <home>/jre/lib/<arch>/hsdis-<arch>.so
never@2991 90 4. hsdis-<arch>.so (using LD_LIBRARY_PATH)
never@2991 91
never@2991 92 Note that there's a bug in hotspot versions prior to hs22 that causes
never@2991 93 steps 2 and 3 to fail when used with JDK7.
jrose@535 94
jrose@535 95 Now test:
never@1155 96
never@1155 97 export LD_LIBRARY_PATH .../hsdis/build/$OS-$LIBARCH:$LD_LIBRARY_PATH
jrose@535 98 dargs='-XX:+UnlockDiagnosticVMOptions -XX:+PrintAssembly'
jrose@535 99 dargs=$dargs' -XX:PrintAssemblyOptions=hsdis-print-bytes'
jrose@535 100 java $dargs -Xbatch CompileCommand=print,*String.hashCode HelloWorld
jrose@535 101
jrose@535 102 If the product mode of the JVM does not accept -XX:+PrintAssembly,
jrose@535 103 you do not have a version new enough to use the hsdis plugin.

mercurial