提交 d1725233 编写于 作者: N never

6684007: PrintAssembly plugin not available for linux or windows

Reviewed-by: rasbold, jrose, twisti
上级 bb1ed4db
^build/ ^build/
^dist/ ^dist/
^nbproject/private/ ^nbproject/private/
^src/share/tools/hsdis/bin/ ^src/share/tools/hsdis/build/
^src/share/tools/IdealGraphVisualizer/[a-zA-Z0-9]*/build/ ^src/share/tools/IdealGraphVisualizer/[a-zA-Z0-9]*/build/
^src/share/tools/IdealGraphVisualizer/build/ ^src/share/tools/IdealGraphVisualizer/build/
^src/share/tools/IdealGraphVisualizer/dist/ ^src/share/tools/IdealGraphVisualizer/dist/
...@@ -55,10 +55,16 @@ CPP_FLAGS=$(CPP_FLAGS) /D "COMPILER2" ...@@ -55,10 +55,16 @@ CPP_FLAGS=$(CPP_FLAGS) /D "COMPILER2"
CPP_FLAGS=$(CPP_FLAGS) /D "COMPILER1" /D "COMPILER2" CPP_FLAGS=$(CPP_FLAGS) /D "COMPILER1" /D "COMPILER2"
!endif !endif
!if "$(BUILDARCH)" == "i486"
HOTSPOT_LIB_ARCH=i386
!else
HOTSPOT_LIB_ARCH=$(BUILDARCH)
!endif
# The following variables are defined in the generated local.make file. # The following variables are defined in the generated local.make file.
CPP_FLAGS=$(CPP_FLAGS) /D "HOTSPOT_RELEASE_VERSION=\"$(HS_BUILD_VER)\"" CPP_FLAGS=$(CPP_FLAGS) /D "HOTSPOT_RELEASE_VERSION=\"$(HS_BUILD_VER)\""
CPP_FLAGS=$(CPP_FLAGS) /D "JRE_RELEASE_VERSION=\"$(JRE_RELEASE_VER)\"" CPP_FLAGS=$(CPP_FLAGS) /D "JRE_RELEASE_VERSION=\"$(JRE_RELEASE_VER)\""
CPP_FLAGS=$(CPP_FLAGS) /D "HOTSPOT_LIB_ARCH=\"$(BUILDARCH)\"" CPP_FLAGS=$(CPP_FLAGS) /D "HOTSPOT_LIB_ARCH=\"$(HOTSPOT_LIB_ARCH)\""
CPP_FLAGS=$(CPP_FLAGS) /D "HOTSPOT_BUILD_TARGET=\"$(BUILD_FLAVOR)\"" CPP_FLAGS=$(CPP_FLAGS) /D "HOTSPOT_BUILD_TARGET=\"$(BUILD_FLAVOR)\""
CPP_FLAGS=$(CPP_FLAGS) /D "HOTSPOT_BUILD_USER=\"$(BuildUser)\"" CPP_FLAGS=$(CPP_FLAGS) /D "HOTSPOT_BUILD_USER=\"$(BuildUser)\""
CPP_FLAGS=$(CPP_FLAGS) /D "HOTSPOT_VM_DISTRO=\"$(HOTSPOT_VM_DISTRO)\"" CPP_FLAGS=$(CPP_FLAGS) /D "HOTSPOT_VM_DISTRO=\"$(HOTSPOT_VM_DISTRO)\""
......
...@@ -247,7 +247,7 @@ class BuildConfig { ...@@ -247,7 +247,7 @@ class BuildConfig {
sysDefines.add("HOTSPOT_BUILD_USER="+System.getProperty("user.name")); sysDefines.add("HOTSPOT_BUILD_USER="+System.getProperty("user.name"));
sysDefines.add("HOTSPOT_BUILD_TARGET=\\\""+get("Build")+"\\\""); sysDefines.add("HOTSPOT_BUILD_TARGET=\\\""+get("Build")+"\\\"");
sysDefines.add("_JNI_IMPLEMENTATION_"); sysDefines.add("_JNI_IMPLEMENTATION_");
sysDefines.add("HOTSPOT_LIB_ARCH=\\\"i486\\\""); sysDefines.add("HOTSPOT_LIB_ARCH=\\\"i386\\\"");
sysDefines.addAll(defines); sysDefines.addAll(defines);
......
...@@ -22,61 +22,75 @@ ...@@ -22,61 +22,75 @@
# #
# #
# Single gnu makefile for solaris, linux and windows (windows requires mks or # Single gnu makefile for solaris, linux and windows (windows requires cygwin and mingw)
# cygwin).
ifeq ($(BINUTILS),)
# Pop all the way out of the workspace to look for binutils.
# ...You probably want to override this setting.
BINUTILS = $(shell cd ../../../../..;pwd)/binutils-2.17-$(LIBARCH)
endif
# Default arch; it is changed below as needed. # Default arch; it is changed below as needed.
ARCH = i386 ARCH = i386
OS = $(shell uname) OS = $(shell uname)
CPPFLAGS += -I$(BINUTILS)/include -I$(BINUTILS)/bfd
CPPFLAGS += -DHOTSPOT_LIB_ARCH=\"$(LIBARCH)\" -DLIBARCH_$(LIBARCH)
CPPFLAGS += -DHOTSPOT_OS=\"$(OS)\" -DOS_$(OS)
## OS = SunOS ## ## OS = SunOS ##
ifeq ($(OS),SunOS) ifeq ($(OS),SunOS)
ARCH = $(shell uname -p) CPU = $(shell uname -p)
ARCH1=$(CPU:i586=i386)
ARCH=$(ARCH1:i686=i386)
OS = solaris OS = solaris
CC = cc CC = cc
CCFLAGS += -Kpic -g CFLAGS += -KPIC
CCFLAGS/amd64 += -xarch=amd64 ifdef LP64
CCFLAGS/sparcv9 += -xarch=v9 ifeq ($(ARCH),sparc)
CCFLAGS += $(CCFLAGS/$(LIBARCH)) ARCH = sparcv9
endif
ifeq ($(ARCH),i386)
ARCH = amd64
endif
endif
CFLAGS/sparcv9 += -xarch=v9
CFLAGS/amd64 += -m64
CFLAGS += $(CFLAGS/$(ARCH))
DLDFLAGS += -G DLDFLAGS += -G
LDFLAGS += -ldl
OUTFLAGS += -o $@ OUTFLAGS += -o $@
LIB_EXT = .so LIB_EXT = .so
else else
## OS = Linux ## ## OS = Linux ##
ifeq ($(OS),Linux) ifeq ($(OS),Linux)
CPU = $(shell uname -m) ifneq ($(MINGW),)
ifeq ($(CPU),ia64) LIB_EXT = .dll
ARCH = ia64 CPPFLAGS += -I$(TARGET_DIR)/include
LDFLAGS += -L$(TARGET_DIR)/lib
OS=windows
ifneq ($(findstring x86_64-,$(MINGW)),)
ARCH=amd64
else
ARCH=i386
endif
CC = $(MINGW)-gcc
CONFIGURE_ARGS= --host=$(MINGW) --target=$(MINGW)
else else
ifeq ($(CPU),x86_64) CPU = $(shell uname -m)
CCFLAGS += -fPIC ARCH1=$(CPU:x86_64=amd64)
endif # x86_64 ARCH=$(ARCH1:i686=i386)
endif # ia64 CFLAGS/i386 += -m32
CFLAGS/sparc += -m32
CFLAGS/sparcv9 += -m64
CFLAGS/amd64 += -m64
CFLAGS += $(CFLAGS/$(ARCH))
CFLAGS += -fPIC
OS = linux OS = linux
LIB_EXT = .so
CC = gcc CC = gcc
CCFLAGS += -O endif
CFLAGS += -O
DLDFLAGS += -shared DLDFLAGS += -shared
LDFLAGS += -ldl
OUTFLAGS += -o $@ OUTFLAGS += -o $@
LIB_EXT = .so
CPPFLAGS += -Iinclude -Iinclude/$(OS)_$(ARCH)/
## OS = Windows ## ## OS = Windows ##
else # !SunOS, !Linux => Windows else # !SunOS, !Linux => Windows
OS = win OS = windows
CC = cl CC = gcc
#CPPFLAGS += /D"WIN32" /D"_WINDOWS" /D"DEBUG" /D"NDEBUG" #CPPFLAGS += /D"WIN32" /D"_WINDOWS" /D"DEBUG" /D"NDEBUG"
CCFLAGS += /nologo /MD /W3 /WX /O2 /Fo$(@:.dll=.obj) /Gi- CFLAGS += /nologo /MD /W3 /WX /O2 /Fo$(@:.dll=.obj) /Gi-
CCFLAGS += -Iinclude -Iinclude/gnu -Iinclude/$(OS)_$(ARCH) CFLAGS += LIBARCH=\"$(LIBARCH)\""
CCFLAGS += /D"HOTSPOT_LIB_ARCH=\"$(LIBARCH)\""
DLDFLAGS += /dll /subsystem:windows /incremental:no \ DLDFLAGS += /dll /subsystem:windows /incremental:no \
/export:decode_instruction /export:decode_instruction
OUTFLAGS += /link /out:$@ OUTFLAGS += /link /out:$@
...@@ -94,21 +108,34 @@ LIBARCH = $(LIBARCH64) ...@@ -94,21 +108,34 @@ LIBARCH = $(LIBARCH64)
endif # LIBARCH64/$(ARCH) endif # LIBARCH64/$(ARCH)
endif # LP64 endif # LP64
TARGET_DIR = bin/$(OS) JDKARCH=$(LIBARCH:i386=i586)
ifeq ($(BINUTILS),)
# Pop all the way out of the workspace to look for binutils.
# ...You probably want to override this setting.
BINUTILSDIR = $(shell cd build/binutils;pwd)
else
BINUTILSDIR = $(shell cd $(BINUTILS);pwd)
endif
CPPFLAGS += -I$(BINUTILSDIR)/include -I$(BINUTILS)/bfd -I$(TARGET_DIR)/bfd
CPPFLAGS += -DLIBARCH_$(LIBARCH) -DLIBARCH=\"$(LIBARCH)\" -DLIB_EXT=\"$(LIB_EXT)\"
TARGET_DIR = build/$(OS)-$(JDKARCH)
TARGET = $(TARGET_DIR)/hsdis-$(LIBARCH)$(LIB_EXT) TARGET = $(TARGET_DIR)/hsdis-$(LIBARCH)$(LIB_EXT)
SOURCE = hsdis.c SOURCE = hsdis.c
LIBRARIES = $(BINUTILS)/bfd/libbfd.a \ LIBRARIES = $(TARGET_DIR)/bfd/libbfd.a \
$(BINUTILS)/opcodes/libopcodes.a \ $(TARGET_DIR)/opcodes/libopcodes.a \
$(BINUTILS)/libiberty/libiberty.a $(TARGET_DIR)/libiberty/libiberty.a
DEMO_TARGET = $(TARGET_DIR)/hsdis-demo-$(LIBARCH) DEMO_TARGET = $(TARGET_DIR)/hsdis-demo
DEMO_SOURCE = hsdis-demo.c DEMO_SOURCE = hsdis-demo.c
.PHONY: all clean demo both .PHONY: all clean demo both
all: $(TARGET) demo all: $(TARGET)
both: all all64 both: all all64
...@@ -117,16 +144,17 @@ both: all all64 ...@@ -117,16 +144,17 @@ both: all all64
demo: $(TARGET) $(DEMO_TARGET) demo: $(TARGET) $(DEMO_TARGET)
$(LIBRARIES): $(LIBRARIES): $(TARGET_DIR) $(TARGET_DIR)/Makefile
@echo "*** Please build binutils first; see ./README: ***" if [ ! -f $@ ]; then cd $(TARGET_DIR); make all-opcodes; fi
@sed < ./README '1,/__________/d' | head -20
@echo "..."; exit 1 $(TARGET_DIR)/Makefile:
(cd $(TARGET_DIR); CC=$(CC) CFLAGS="$(CFLAGS)" $(BINUTILSDIR)/configure --disable-nls $(CONFIGURE_ARGS))
$(TARGET): $(SOURCE) $(LIBS) $(LIBRARIES) $(TARGET_DIR) $(TARGET): $(SOURCE) $(LIBS) $(LIBRARIES) $(TARGET_DIR)
$(CC) $(OUTFLAGS) $(CPPFLAGS) $(CCFLAGS) $(SOURCE) $(DLDFLAGS) $(LIBRARIES) $(CC) $(OUTFLAGS) $(CPPFLAGS) $(CFLAGS) $(SOURCE) $(DLDFLAGS) $(LIBRARIES)
$(DEMO_TARGET): $(DEMO_SOURCE) $(TARGET) $(TARGET_DIR) $(DEMO_TARGET): $(DEMO_SOURCE) $(TARGET) $(TARGET_DIR)
$(CC) $(OUTFLAGS) $(CPPFLAGS) $(CCFLAGS) $(DEMO_SOURCE) $(LDFLAGS) $(CC) $(OUTFLAGS) -DTARGET_DIR=\"$(TARGET_DIR)\" $(CPPFLAGS) -g $(CFLAGS/$(ARCH)) $(DEMO_SOURCE) $(LDFLAGS)
$(TARGET_DIR): $(TARGET_DIR):
[ -d $@ ] || mkdir -p $@ [ -d $@ ] || mkdir -p $@
......
...@@ -32,61 +32,55 @@ you do not have a version that is new enough. ...@@ -32,61 +32,55 @@ you do not have a version that is new enough.
* Building * Building
To build this project you need a build of Gnu binutils to link against. To build this project you a copy of GNU binutils to build against. It
It is known to work with binutils 2.17. is known to work with binutils 2.17 and binutils 2.19.1. Download a
copy of the software from http://directory.fsf.org/project/binutils or
The makefile looks for this build in $BINUTILS, or (if that is not set), one of it's mirrors. Builds targetting windows should use at least
in .../binutils-2.17-$LIBARCH, where LIBARCH (as in HotSpot) is one of 2.19 and currently requires the use of a cross compiler.
the jre subdirectory keywords i386, amd64, sparc, sparcv9, etc.
The makefile looks for the sources in build/binutils or you can
To build Gnu binutils, first download a copy of the software: specify it's location to the makefile using BINTUILS=path. It will
http://directory.fsf.org/project/binutils/ configure binutils and build it first and then build and link the
disasembly adapter. Make all will build the default target for your
Unpack the binutils tarball into an empty directory: platform. If you platform support both 32 and 64 simultaneously then
chdir ../../../../.. "make both" will build them both at once. "make all64" will
tar -xzf - < ../binutils-2.17.tar.gz explicitly build the 64 bit version. By default this will build the
mv binutils-2.17 binutils-2.17-i386 #or binutils-2.17-sparc disassembler library only. If you build demo it will build a demo
cd binutils-2.17-i386 program that attempts to exercise the library.
From inside that directory, run configure and make: Windows
( export CFLAGS='-fPIC'
./configure i386-pc-elf ) In theory this should be buildable on Windows but getting a working
gnumake GNU build environment on Windows has proven difficult. MINGW should
be able to do it but at the time of this writing I was unable to get
(Leave out or change the argument to configure if not on an i386 system.) this working. Instead you can use the mingw cross compiler on linux
to produce the windows binaries. For 32-bit windows you can install
Next, untar again into another empty directory for the LP64 version: mingw32 using your package manager and it will be added to your path
chdir .. automatically. For 64-bit you need to download the 64 bit mingw from
tar -xzf - < ../binutils-2.17.tar.gz http://sourceforge.net/projects/mingw-w64. Grab a copy of the
mv binutils-2.17 binutils-2.17-amd64 #or binutils-2.17-sparcv9 complete toolchain and unpack it somewhere. Put the bin directory of
cd binutils-2.17-amd64 the toolchain in your path. The mingw installs contain cross compile
versions of gcc that are named with a prefix to indicate what they are
From inside that directory, run configure for LP64 and make: targetting and you must tell the Makefile which one to use. This
( export ac_cv_c_bigendian=no CFLAGS='-m64 -fPIC' LDFLAGS=-m64 should either be i586-mingw32msvc or x86_64-pc-mingw32 depending on
./configure amd64-pc-elf ) which on you are targetting and there should be a version of gcc in
gnumake your path named i586-mingw32msvc-gcc or x86_64-pc-mingw32-gcc. Tell
the makefile what prefix to use to find the mingw tools by using
The -fPIC option is needed because the generated code will be MINGW=. For example:
linked into the hsdid-$LIBARCH.so binary. If you miss the
option, the JVM will fail to load the disassembler. make MINGW=i586-mingw32msvc BINTUILS=build/binutils-2.19.1
You probably want two builds, one for 32 and one for 64 bits. will build the Win32 cross compiled version of hsdis based on 2.19.1.
To build the 64-bit variation of a platforn, add LP64=1 to
the make command line for hsdis.
So, go back to the hsdis project and build:
chdir .../hsdis
gnumake
gnumake LP64=1
* Installing * Installing
Products are named like bin/$OS/hsdis-$LIBARCH.so. Products are named like build/$OS-$LIBARCH/hsdis-$LIBARCH.so. You can
You can install them on your LD_LIBRARY_PATH, install them on your LD_LIBRARY_PATH, or inside of your JRE next to
or inside of your JRE next to $LIBARCH/libjvm.so. $LIBARCH/libjvm.so.
Now test: Now test:
export LD_LIBRARY_PATH .../hsdis/bin/solaris:$LD_LIBRARY_PATH
export LD_LIBRARY_PATH .../hsdis/build/$OS-$LIBARCH:$LD_LIBRARY_PATH
dargs='-XX:+UnlockDiagnosticVMOptions -XX:+PrintAssembly' dargs='-XX:+UnlockDiagnosticVMOptions -XX:+PrintAssembly'
dargs=$dargs' -XX:PrintAssemblyOptions=hsdis-print-bytes' dargs=$dargs' -XX:PrintAssemblyOptions=hsdis-print-bytes'
java $dargs -Xbatch CompileCommand=print,*String.hashCode HelloWorld java $dargs -Xbatch CompileCommand=print,*String.hashCode HelloWorld
......
...@@ -53,7 +53,7 @@ int main(int ac, char** av) { ...@@ -53,7 +53,7 @@ int main(int ac, char** av) {
else if (!strncmp(arg, "-options=", 9)) else if (!strncmp(arg, "-options=", 9))
options = arg+9; options = arg+9;
else else
{ printf("Usage: %s [-xml] [name...]\n"); exit(2); } { printf("Usage: %s [-xml] [name...]\n", av[0]); exit(2); }
continue; continue;
} }
greet(arg); greet(arg);
...@@ -76,26 +76,14 @@ void end_of_file() { } ...@@ -76,26 +76,14 @@ void end_of_file() { }
#include "dlfcn.h" #include "dlfcn.h"
#ifdef HOTSPOT_LIB_ARCH
#define LIBARCH HOTSPOT_LIB_ARCH
#endif
#ifdef HOTSPOT_OS
#define OS HOTSPOT_OS
#endif
#define DECODE_INSTRUCTIONS_NAME "decode_instructions" #define DECODE_INSTRUCTIONS_NAME "decode_instructions"
#define HSDIS_NAME "hsdis" #define HSDIS_NAME "hsdis"
static void* decode_instructions_pv = 0; static void* decode_instructions_pv = 0;
static const char* hsdis_path[] = { static const char* hsdis_path[] = {
HSDIS_NAME".so", HSDIS_NAME"-"LIBARCH LIB_EXT,
#ifdef OS "./" HSDIS_NAME"-"LIBARCH LIB_EXT,
"bin/"OS"/"HSDIS_NAME".so", #ifdef TARGET_DIR
#endif TARGET_DIR"/"HSDIS_NAME"-"LIBARCH LIB_EXT,
#ifdef LIBARCH
HSDIS_NAME"-"LIBARCH".so",
#ifdef OS
"bin/"OS"/"HSDIS_NAME"-"LIBARCH".so",
#endif
#endif #endif
NULL NULL
}; };
...@@ -112,7 +100,7 @@ static const char* load_decode_instructions() { ...@@ -112,7 +100,7 @@ static const char* load_decode_instructions() {
for (dllib = NULL; dllib == NULL; ) { for (dllib = NULL; dllib == NULL; ) {
const char* next_lib = (*next_in_path++); const char* next_lib = (*next_in_path++);
if (next_lib == NULL) if (next_lib == NULL)
return "cannot find plugin "HSDIS_NAME".so"; return "cannot find plugin "HSDIS_NAME LIB_EXT;
dllib = dlopen(next_lib, RTLD_LAZY); dllib = dlopen(next_lib, RTLD_LAZY);
} }
} }
......
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
#include <libiberty.h> #include <libiberty.h>
#include <bfd.h> #include <bfd.h>
#include <dis-asm.h> #include <dis-asm.h>
#include <inttypes.h>
#ifndef bool #ifndef bool
#define bool int #define bool int
...@@ -404,21 +405,21 @@ static const bfd_arch_info_type* find_arch_info(const char* arch_name) { ...@@ -404,21 +405,21 @@ static const bfd_arch_info_type* find_arch_info(const char* arch_name) {
} }
static const char* native_arch_name() { static const char* native_arch_name() {
const char* res = HOTSPOT_LIB_ARCH; const char* res = NULL;
#ifdef LIBARCH_i386
res = "i386";
#endif
#ifdef LIBARCH_amd64 #ifdef LIBARCH_amd64
res = "i386:x86-64"; res = "i386:x86-64";
#endif #endif
#ifdef LIBARCH_sparc #ifdef LIBARCH_sparc
res = "sparc:v8plusb"; res = "sparc:v8plusb";
#endif #endif
#ifdef LIBARCH_sparc
res = "sparc:v8plusb";
#endif
#ifdef LIBARCH_sparcv9 #ifdef LIBARCH_sparcv9
res = "sparc:v9b"; res = "sparc:v9b";
#endif #endif
if (res == NULL) if (res == NULL)
res = "HOTSPOT_LIB_ARCH is not set in Makefile!"; res = "architecture not set in Makefile!";
return res; return res;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册