提交 d1725233 编写于 作者: N never

6684007: PrintAssembly plugin not available for linux or windows

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