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