Merge
This commit is contained in:
commit
5c390e7094
2
.hgtags
2
.hgtags
@ -202,3 +202,5 @@ d17eb2e13e362085e866d46235314c50cc4661cc jdk8-b77
|
||||
6d3dcd34b5b962ea1ef9eed0dafdee9e812401bc jdk8-b78
|
||||
a1313a8d90d17d363a3b2a645dc4030ec204b168 jdk8-b79
|
||||
3fa21fbf9be7e6b482af43aacb6a09acfa30bdb6 jdk8-b80
|
||||
e41d716405b209d3eddef8bd4240cec2bd34dcca jdk8-b81
|
||||
5e8c55025644730385a6f8fa029ecdb2d2c98a07 jdk8-b82
|
||||
|
@ -202,3 +202,5 @@ b43aa5bd8ca5c8121336495382d35ecfa7a71536 jdk8-b74
|
||||
fd1a5574cf68af24bfd52decc37ac6361afb278a jdk8-b78
|
||||
91d35211e74464dca5edf9b66ab01d0d0d8cded7 jdk8-b79
|
||||
907a926d3c96472f357617b48b6b968ea855c23c jdk8-b80
|
||||
145dbc56f931c134e837b675b9e6e7bf08902e93 jdk8-b81
|
||||
29153d0df68f84162ffe8c2cf4f402a3f2245e85 jdk8-b82
|
||||
|
7
Makefile
7
Makefile
@ -90,6 +90,7 @@ include ./make/corba-rules.gmk
|
||||
include ./make/jaxp-rules.gmk
|
||||
include ./make/jaxws-rules.gmk
|
||||
include ./make/jdk-rules.gmk
|
||||
include ./make/nashorn-rules.gmk
|
||||
include ./make/install-rules.gmk
|
||||
include ./make/sponsors-rules.gmk
|
||||
include ./make/deploy-rules.gmk
|
||||
@ -174,6 +175,11 @@ ifeq ($(BUILD_JDK), true)
|
||||
clobber:: jdk-clobber
|
||||
endif
|
||||
|
||||
ifeq ($(BUILD_NASHORN), true)
|
||||
generic_build_repo_series:: $(NASHORN)
|
||||
clobber:: nashorn-clobber
|
||||
endif
|
||||
|
||||
ifeq ($(BUILD_DEPLOY), true)
|
||||
generic_build_repo_series:: $(DEPLOY)
|
||||
clobber:: deploy-clobber
|
||||
@ -336,6 +342,7 @@ deploy_fastdebug_only:
|
||||
BUILD_HOTSPOT=false \
|
||||
BUILD_JDK=false \
|
||||
BUILD_LANGTOOLS=false \
|
||||
BUILD_NASHORN=false \
|
||||
BUILD_CORBA=false \
|
||||
BUILD_JAXP=false \
|
||||
BUILD_JAXWS=false \
|
||||
|
@ -194,6 +194,7 @@ BASIC_COMPILE_FIXPATH
|
||||
###############################################################################
|
||||
|
||||
JDKOPT_SETUP_BUILD_TWEAKS
|
||||
JDKOPT_DETECT_INTREE_EC
|
||||
|
||||
###############################################################################
|
||||
#
|
||||
|
@ -612,6 +612,7 @@ SJAVAC_SERVER_JAVA
|
||||
JOBS
|
||||
MEMORY_SIZE
|
||||
NUM_CORES
|
||||
ENABLE_INTREE_EC
|
||||
SALIB_NAME
|
||||
HOTSPOT_MAKE_ARGS
|
||||
FIXPATH
|
||||
@ -749,6 +750,7 @@ BUILD_OUTPUT
|
||||
OVERRIDE_SRC_ROOT
|
||||
ADD_SRC_ROOT
|
||||
JDK_TOPDIR
|
||||
NASHORN_TOPDIR
|
||||
HOTSPOT_TOPDIR
|
||||
JAXWS_TOPDIR
|
||||
JAXP_TOPDIR
|
||||
@ -3751,7 +3753,7 @@ fi
|
||||
#CUSTOM_AUTOCONF_INCLUDE
|
||||
|
||||
# Do not change or remove the following line, it is needed for consistency checks:
|
||||
DATE_WHEN_GENERATED=1363150186
|
||||
DATE_WHEN_GENERATED=1363706268
|
||||
|
||||
###############################################################################
|
||||
#
|
||||
@ -10783,6 +10785,12 @@ else
|
||||
fi
|
||||
|
||||
|
||||
###############################################################################
|
||||
#
|
||||
# Enable or disable the elliptic curve crypto implementation
|
||||
#
|
||||
|
||||
|
||||
###############################################################################
|
||||
#
|
||||
# Compress jars
|
||||
@ -15682,6 +15690,7 @@ CORBA_TOPDIR="$SRC_ROOT/corba"
|
||||
JAXP_TOPDIR="$SRC_ROOT/jaxp"
|
||||
JAXWS_TOPDIR="$SRC_ROOT/jaxws"
|
||||
HOTSPOT_TOPDIR="$SRC_ROOT/hotspot"
|
||||
NASHORN_TOPDIR="$SRC_ROOT/nashorn"
|
||||
JDK_TOPDIR="$SRC_ROOT/jdk"
|
||||
|
||||
|
||||
@ -15692,6 +15701,7 @@ JDK_TOPDIR="$SRC_ROOT/jdk"
|
||||
|
||||
|
||||
|
||||
|
||||
###############################################################################
|
||||
#
|
||||
# Pickup additional source for a component from outside of the source root
|
||||
@ -15922,6 +15932,19 @@ $as_echo_n "checking if hotspot should be overridden... " >&6; }
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes with $HOTSPOT_TOPDIR" >&5
|
||||
$as_echo "yes with $HOTSPOT_TOPDIR" >&6; }
|
||||
fi
|
||||
if test "x$with_override_nashorn" != x; then
|
||||
CURDIR="$PWD"
|
||||
cd "$with_override_nashorn"
|
||||
NASHORN_TOPDIR="`pwd`"
|
||||
cd "$CURDIR"
|
||||
if ! test -f $NASHORN_TOPDIR/makefiles/BuildNashorn.gmk; then
|
||||
as_fn_error $? "You have to override nashorn with a full nashorn repo!" "$LINENO" 5
|
||||
fi
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if nashorn should be overridden" >&5
|
||||
$as_echo_n "checking if nashorn should be overridden... " >&6; }
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes with $NASHORN_TOPDIR" >&5
|
||||
$as_echo "yes with $NASHORN_TOPDIR" >&6; }
|
||||
fi
|
||||
if test "x$with_override_jdk" != x; then
|
||||
CURDIR="$PWD"
|
||||
cd "$with_override_jdk"
|
||||
@ -18534,14 +18557,18 @@ fi
|
||||
|
||||
### Locate C compiler (CC)
|
||||
|
||||
# gcc is almost always present, but on Windows we
|
||||
# prefer cl.exe and on Solaris we prefer CC.
|
||||
# Thus test for them in this order.
|
||||
if test "x$OPENJDK_TARGET_OS" = xmacosx; then
|
||||
# Do not probe for cc on MacOSX.
|
||||
COMPILER_CHECK_LIST="cl gcc"
|
||||
# On windows, only cl.exe is supported.
|
||||
# On Solaris, cc is preferred to gcc.
|
||||
# Elsewhere, gcc is preferred to cc.
|
||||
|
||||
if test "x$CC" != x; then
|
||||
COMPILER_CHECK_LIST="$CC"
|
||||
elif test "x$OPENJDK_TARGET_OS" = "xwindows"; then
|
||||
COMPILER_CHECK_LIST="cl"
|
||||
elif test "x$OPENJDK_TARGET_OS" = "xsolaris"; then
|
||||
COMPILER_CHECK_LIST="cc gcc"
|
||||
else
|
||||
COMPILER_CHECK_LIST="cl cc gcc"
|
||||
COMPILER_CHECK_LIST="gcc cc"
|
||||
fi
|
||||
|
||||
|
||||
@ -19505,7 +19532,7 @@ $as_echo "$as_me: The result from running with --version was: \"$COMPILER_VERSIO
|
||||
$as_echo "$as_me: Using $COMPILER_VENDOR $COMPILER_NAME compiler version $COMPILER_VERSION (located at $COMPILER)" >&6;}
|
||||
|
||||
|
||||
# Now that we have resolved CC ourself, let autoconf have it's go at it
|
||||
# Now that we have resolved CC ourself, let autoconf have its go at it
|
||||
ac_ext=c
|
||||
ac_cpp='$CPP $CPPFLAGS'
|
||||
ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
|
||||
@ -20107,13 +20134,17 @@ ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
|
||||
|
||||
### Locate C++ compiler (CXX)
|
||||
|
||||
if test "x$OPENJDK_TARGET_OS" = xmacosx; then
|
||||
# Do not probe for CC on MacOSX.
|
||||
COMPILER_CHECK_LIST="cl g++"
|
||||
if test "x$CXX" != x; then
|
||||
COMPILER_CHECK_LIST="$CXX"
|
||||
elif test "x$OPENJDK_TARGET_OS" = "xwindows"; then
|
||||
COMPILER_CHECK_LIST="cl"
|
||||
elif test "x$OPENJDK_TARGET_OS" = "xsolaris"; then
|
||||
COMPILER_CHECK_LIST="CC g++"
|
||||
else
|
||||
COMPILER_CHECK_LIST="cl CC g++"
|
||||
COMPILER_CHECK_LIST="g++ CC"
|
||||
fi
|
||||
|
||||
|
||||
COMPILER_NAME=C++
|
||||
|
||||
CXX=
|
||||
@ -21074,7 +21105,7 @@ $as_echo "$as_me: The result from running with --version was: \"$COMPILER_VERSIO
|
||||
$as_echo "$as_me: Using $COMPILER_VENDOR $COMPILER_NAME compiler version $COMPILER_VERSION (located at $COMPILER)" >&6;}
|
||||
|
||||
|
||||
# Now that we have resolved CXX ourself, let autoconf have it's go at it
|
||||
# Now that we have resolved CXX ourself, let autoconf have its go at it
|
||||
ac_ext=cpp
|
||||
ac_cpp='$CXXCPP $CPPFLAGS'
|
||||
ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
|
||||
@ -29799,7 +29830,7 @@ if eval test \"x\$"$as_ac_Header"\" = x"yes"; then :
|
||||
_ACEOF
|
||||
X11_A_OK=yes
|
||||
else
|
||||
X11_A_OK=no
|
||||
X11_A_OK=no; break
|
||||
fi
|
||||
|
||||
done
|
||||
@ -31670,6 +31701,22 @@ fi
|
||||
|
||||
|
||||
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if elliptic curve crypto implementation is present" >&5
|
||||
$as_echo_n "checking if elliptic curve crypto implementation is present... " >&6; }
|
||||
|
||||
if test -d "${SRC_ROOT}/jdk/src/share/native/sun/security/ec/impl"; then
|
||||
ENABLE_INTREE_EC=yes
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
|
||||
$as_echo "yes" >&6; }
|
||||
else
|
||||
ENABLE_INTREE_EC=no
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
|
||||
$as_echo "no" >&6; }
|
||||
fi
|
||||
|
||||
|
||||
|
||||
|
||||
###############################################################################
|
||||
#
|
||||
# Configure parts of the build that only affect the build performance,
|
||||
|
@ -364,6 +364,25 @@ else
|
||||
fi
|
||||
AC_SUBST(UNLIMITED_CRYPTO)
|
||||
|
||||
###############################################################################
|
||||
#
|
||||
# Enable or disable the elliptic curve crypto implementation
|
||||
#
|
||||
AC_DEFUN_ONCE([JDKOPT_DETECT_INTREE_EC],
|
||||
[
|
||||
AC_MSG_CHECKING([if elliptic curve crypto implementation is present])
|
||||
|
||||
if test -d "${SRC_ROOT}/jdk/src/share/native/sun/security/ec/impl"; then
|
||||
ENABLE_INTREE_EC=yes
|
||||
AC_MSG_RESULT([yes])
|
||||
else
|
||||
ENABLE_INTREE_EC=no
|
||||
AC_MSG_RESULT([no])
|
||||
fi
|
||||
|
||||
AC_SUBST(ENABLE_INTREE_EC)
|
||||
])
|
||||
|
||||
###############################################################################
|
||||
#
|
||||
# Compress jars
|
||||
|
@ -182,7 +182,7 @@ CFLAGS="$CFLAGS $X_CFLAGS"
|
||||
# Need to include Xlib.h and Xutil.h to avoid "present but cannot be compiled" warnings on Solaris 10
|
||||
AC_CHECK_HEADERS([X11/extensions/shape.h X11/extensions/Xrender.h X11/extensions/XTest.h],
|
||||
[X11_A_OK=yes],
|
||||
[X11_A_OK=no],
|
||||
[X11_A_OK=no; break],
|
||||
[ # include <X11/Xlib.h>
|
||||
# include <X11/Xutil.h>
|
||||
])
|
||||
|
@ -33,12 +33,14 @@ CORBA_TOPDIR="$SRC_ROOT/corba"
|
||||
JAXP_TOPDIR="$SRC_ROOT/jaxp"
|
||||
JAXWS_TOPDIR="$SRC_ROOT/jaxws"
|
||||
HOTSPOT_TOPDIR="$SRC_ROOT/hotspot"
|
||||
NASHORN_TOPDIR="$SRC_ROOT/nashorn"
|
||||
JDK_TOPDIR="$SRC_ROOT/jdk"
|
||||
AC_SUBST(LANGTOOLS_TOPDIR)
|
||||
AC_SUBST(CORBA_TOPDIR)
|
||||
AC_SUBST(JAXP_TOPDIR)
|
||||
AC_SUBST(JAXWS_TOPDIR)
|
||||
AC_SUBST(HOTSPOT_TOPDIR)
|
||||
AC_SUBST(NASHORN_TOPDIR)
|
||||
AC_SUBST(JDK_TOPDIR)
|
||||
])
|
||||
|
||||
@ -234,6 +236,17 @@ if test "x$with_override_hotspot" != x; then
|
||||
AC_MSG_CHECKING([if hotspot should be overridden])
|
||||
AC_MSG_RESULT([yes with $HOTSPOT_TOPDIR])
|
||||
fi
|
||||
if test "x$with_override_nashorn" != x; then
|
||||
CURDIR="$PWD"
|
||||
cd "$with_override_nashorn"
|
||||
NASHORN_TOPDIR="`pwd`"
|
||||
cd "$CURDIR"
|
||||
if ! test -f $NASHORN_TOPDIR/makefiles/BuildNashorn.gmk; then
|
||||
AC_MSG_ERROR([You have to override nashorn with a full nashorn repo!])
|
||||
fi
|
||||
AC_MSG_CHECKING([if nashorn should be overridden])
|
||||
AC_MSG_RESULT([yes with $NASHORN_TOPDIR])
|
||||
fi
|
||||
if test "x$with_override_jdk" != x; then
|
||||
CURDIR="$PWD"
|
||||
cd "$with_override_jdk"
|
||||
|
@ -141,6 +141,7 @@ CORBA_TOPDIR:=@CORBA_TOPDIR@
|
||||
JAXP_TOPDIR:=@JAXP_TOPDIR@
|
||||
JAXWS_TOPDIR:=@JAXWS_TOPDIR@
|
||||
HOTSPOT_TOPDIR:=@HOTSPOT_TOPDIR@
|
||||
NASHORN_TOPDIR:=@NASHORN_TOPDIR@
|
||||
COPYRIGHT_YEAR:=@COPYRIGHT_YEAR@
|
||||
|
||||
# Location where build customization files may be found
|
||||
@ -230,6 +231,7 @@ JAXP_OUTPUTDIR=$(BUILD_OUTPUT)/jaxp
|
||||
JAXWS_OUTPUTDIR=$(BUILD_OUTPUT)/jaxws
|
||||
HOTSPOT_OUTPUTDIR=$(BUILD_OUTPUT)/hotspot
|
||||
JDK_OUTPUTDIR=$(BUILD_OUTPUT)/jdk
|
||||
NASHORN_OUTPUTDIR=$(BUILD_OUTPUT)/nashorn
|
||||
IMAGES_OUTPUTDIR=$(BUILD_OUTPUT)/images
|
||||
JCE_OUTPUTDIR=$(BUILD_OUTPUT)/jce-release
|
||||
|
||||
@ -238,6 +240,7 @@ CORBA_DIST=$(CORBA_OUTPUTDIR)/dist
|
||||
JAXP_DIST=$(JAXP_OUTPUTDIR)/dist
|
||||
JAXWS_DIST=$(JAXWS_OUTPUTDIR)/dist
|
||||
HOTSPOT_DIST=@HOTSPOT_DIST@
|
||||
NASHORN_DIST=$(NASHORN_OUTPUTDIR)/dist
|
||||
|
||||
BUILD_HOTSPOT=@BUILD_HOTSPOT@
|
||||
|
||||
@ -536,6 +539,7 @@ endif
|
||||
|
||||
# Build setup
|
||||
ENABLE_JFR=@ENABLE_JFR@
|
||||
ENABLE_INTREE_EC=@ENABLE_INTREE_EC@
|
||||
USE_EXTERNAL_LIBJPEG:=@USE_EXTERNAL_LIBJPEG@
|
||||
USE_EXTERNAL_LIBGIF:=@USE_EXTERNAL_LIBGIF@
|
||||
USE_EXTERNAL_LIBZ:=@USE_EXTERNAL_LIBZ@
|
||||
|
@ -249,30 +249,38 @@ fi
|
||||
|
||||
### Locate C compiler (CC)
|
||||
|
||||
# gcc is almost always present, but on Windows we
|
||||
# prefer cl.exe and on Solaris we prefer CC.
|
||||
# Thus test for them in this order.
|
||||
if test "x$OPENJDK_TARGET_OS" = xmacosx; then
|
||||
# Do not probe for cc on MacOSX.
|
||||
COMPILER_CHECK_LIST="cl gcc"
|
||||
# On windows, only cl.exe is supported.
|
||||
# On Solaris, cc is preferred to gcc.
|
||||
# Elsewhere, gcc is preferred to cc.
|
||||
|
||||
if test "x$CC" != x; then
|
||||
COMPILER_CHECK_LIST="$CC"
|
||||
elif test "x$OPENJDK_TARGET_OS" = "xwindows"; then
|
||||
COMPILER_CHECK_LIST="cl"
|
||||
elif test "x$OPENJDK_TARGET_OS" = "xsolaris"; then
|
||||
COMPILER_CHECK_LIST="cc gcc"
|
||||
else
|
||||
COMPILER_CHECK_LIST="cl cc gcc"
|
||||
COMPILER_CHECK_LIST="gcc cc"
|
||||
fi
|
||||
|
||||
TOOLCHAIN_FIND_COMPILER([CC],[C],[$COMPILER_CHECK_LIST])
|
||||
# Now that we have resolved CC ourself, let autoconf have it's go at it
|
||||
# Now that we have resolved CC ourself, let autoconf have its go at it
|
||||
AC_PROG_CC([$CC])
|
||||
|
||||
### Locate C++ compiler (CXX)
|
||||
|
||||
if test "x$OPENJDK_TARGET_OS" = xmacosx; then
|
||||
# Do not probe for CC on MacOSX.
|
||||
COMPILER_CHECK_LIST="cl g++"
|
||||
if test "x$CXX" != x; then
|
||||
COMPILER_CHECK_LIST="$CXX"
|
||||
elif test "x$OPENJDK_TARGET_OS" = "xwindows"; then
|
||||
COMPILER_CHECK_LIST="cl"
|
||||
elif test "x$OPENJDK_TARGET_OS" = "xsolaris"; then
|
||||
COMPILER_CHECK_LIST="CC g++"
|
||||
else
|
||||
COMPILER_CHECK_LIST="cl CC g++"
|
||||
COMPILER_CHECK_LIST="g++ CC"
|
||||
fi
|
||||
|
||||
TOOLCHAIN_FIND_COMPILER([CXX],[C++],[$COMPILER_CHECK_LIST])
|
||||
# Now that we have resolved CXX ourself, let autoconf have it's go at it
|
||||
# Now that we have resolved CXX ourself, let autoconf have its go at it
|
||||
AC_PROG_CXX([$CXX])
|
||||
|
||||
### Locate other tools
|
||||
|
@ -96,7 +96,7 @@ pull_default=""
|
||||
repos=""
|
||||
repos_extra=""
|
||||
if [ "${command}" = "clone" -o "${command}" = "fclone" ] ; then
|
||||
subrepos="corba jaxp jaxws langtools jdk hotspot"
|
||||
subrepos="corba jaxp jaxws langtools jdk hotspot nashorn"
|
||||
if [ -f .hg/hgrc ] ; then
|
||||
pull_default=`hg paths default`
|
||||
if [ "${pull_default}" = "" ] ; then
|
||||
|
@ -120,6 +120,12 @@ jdk-only: start-make
|
||||
@($(CD) $(JDK_TOPDIR)/makefiles && $(BUILD_LOG_WRAPPER) $(MAKE) $(MAKE_ARGS) -f BuildJdk.gmk $(JDK_TARGET))
|
||||
@$(call TargetExit)
|
||||
|
||||
nashorn: jdk nashorn-only
|
||||
nashorn-only: start-make
|
||||
@$(call TargetEnter)
|
||||
@($(CD) $(NASHORN_TOPDIR)/makefiles && $(BUILD_LOG_WRAPPER) $(MAKE) $(MAKE_ARGS) -f BuildNashorn.gmk)
|
||||
@$(call TargetExit)
|
||||
|
||||
demos: jdk demos-only
|
||||
demos-only: start-make
|
||||
@$(call TargetEnter)
|
||||
@ -128,7 +134,7 @@ demos-only: start-make
|
||||
|
||||
# Note: This double-colon rule is intentional, to support
|
||||
# custom make file integration.
|
||||
images:: source-tips demos images-only
|
||||
images:: source-tips demos nashorn images-only
|
||||
images-only: start-make
|
||||
@$(call TargetEnter)
|
||||
@($(CD) $(JDK_TOPDIR)/makefiles && $(BUILD_LOG_WRAPPER) $(MAKE) $(MAKE_ARGS) -f BuildJdk.gmk images)
|
||||
@ -175,9 +181,10 @@ bootcycle-images:
|
||||
@$(ECHO) Boot cycle build step 2: Building a new JDK image using previously built image
|
||||
@($(CD) $(SRC_ROOT)/common/makefiles && $(BUILD_LOG_WRAPPER) $(MAKE) SPEC=$(dir $(SPEC))bootcycle-spec.gmk images)
|
||||
|
||||
test: start-make
|
||||
test: images test-only
|
||||
test-only: start-make
|
||||
@$(call TargetEnter)
|
||||
@($(CD) $(SRC_ROOT)/test && $(BUILD_LOG_WRAPPER) $(MAKE) -j1 -k MAKEFLAGS= PRODUCT_HOME=$(OUTPUT_ROOT)/jdk JPRT_JAVA_HOME=$(OUTPUT_ROOT)/jdk ALT_OUTPUTDIR=$(OUTPUT_ROOT) $(TEST)) || true
|
||||
@($(CD) $(SRC_ROOT)/test && $(BUILD_LOG_WRAPPER) $(MAKE) -j1 -k MAKEFLAGS= PRODUCT_HOME=$(JDK_IMAGE_DIR) JPRT_JAVA_HOME=$(JDK_IMAGE_DIR) ALT_OUTPUTDIR=$(OUTPUT_ROOT) $(TEST)) || true
|
||||
@$(call TargetExit)
|
||||
|
||||
# Stores the tips for each repository. This file is be used when constructing the jdk image and can be
|
||||
@ -190,7 +197,7 @@ $(OUTPUT_ROOT)/source_tips: FRC
|
||||
|
||||
|
||||
# Remove everything, except the output from configure.
|
||||
clean: clean-langtools clean-corba clean-jaxp clean-jaxws clean-hotspot clean-jdk clean-images clean-overlay-images clean-bootcycle-build clean-docs
|
||||
clean: clean-langtools clean-corba clean-jaxp clean-jaxws clean-hotspot clean-jdk clean-nashorn clean-images clean-overlay-images clean-bootcycle-build clean-docs
|
||||
@($(CD) $(OUTPUT_ROOT) && $(RM) -r tmp source_tips build.log* build-trace*.log*)
|
||||
@$(ECHO) Cleaned all build artifacts.
|
||||
|
||||
@ -220,6 +227,8 @@ clean-hotspot:
|
||||
$(call CleanComponent,hotspot)
|
||||
clean-jdk:
|
||||
$(call CleanComponent,jdk)
|
||||
clean-nashorn:
|
||||
$(call CleanComponent,nashorn)
|
||||
clean-images:
|
||||
$(call CleanComponent,images)
|
||||
clean-overlay-images:
|
||||
@ -230,10 +239,10 @@ clean-docs:
|
||||
$(call CleanComponent,docs)
|
||||
$(call CleanComponent,docstemp)
|
||||
|
||||
.PHONY: langtools corba jaxp jaxws hotspot jdk images overlay-images install
|
||||
.PHONY: langtools-only corba-only jaxp-only jaxws-only hotspot-only jdk-only images-only overlay-images-only install-only
|
||||
.PHONY: langtools corba jaxp jaxws hotspot jdk nashorn images overlay-images install
|
||||
.PHONY: langtools-only corba-only jaxp-only jaxws-only hotspot-only jdk-only nashorn-only images-only overlay-images-only install-only
|
||||
.PHONY: all test clean dist-clean bootcycle-images start-make
|
||||
.PHONY: clean-langtools clean-corba clean-jaxp clean-jaxws clean-hotspot clean-jdk clean-images clean-overlay-images clean-bootcycle-build
|
||||
.PHONY: clean-langtools clean-corba clean-jaxp clean-jaxws clean-hotspot clean-jdk clean-nashorn clean-images clean-overlay-images clean-bootcycle-build
|
||||
.PHONY: profiles profiles-only profiles-oscheck
|
||||
|
||||
FRC: # Force target
|
||||
|
@ -51,8 +51,9 @@ decompress_paths=$(SED) -f $(SRC_ROOT)/common/makefiles/support/ListPathsSafely-
|
||||
-e 's|X98|$(OUTPUT_ROOT)|g' -e 's|X97|$(SRC_ROOT)|g' \
|
||||
-e 's|X00|X|g' | tr '\n' '$2'
|
||||
|
||||
# Subst in an extra $ to prevent it from disappearing.
|
||||
define ListPathsSafely_If
|
||||
$(if $(word $3,$($1)),$(eval $1_LPS$3:=$(call compress_paths,$(wordlist $3,$4,$($1)))))
|
||||
$(if $(word $3,$($1)),$(eval $1_LPS$3:=$(call compress_paths,$(subst $$,$$$$,$(wordlist $3,$4,$($1))))))
|
||||
endef
|
||||
|
||||
define ListPathsSafely_Printf
|
||||
|
@ -80,7 +80,8 @@ JCONSOLE_PKGS = com.sun.tools.jconsole
|
||||
|
||||
TREEAPI_PKGS = com.sun.source.doctree \
|
||||
com.sun.source.tree \
|
||||
com.sun.source.util
|
||||
com.sun.source.util \
|
||||
jdk
|
||||
|
||||
SMARTCARDIO_PKGS = javax.smartcardio
|
||||
|
||||
@ -93,6 +94,8 @@ APPLE_EXT_PKGS = com.apple.concurrent \
|
||||
com.apple.eio
|
||||
endif
|
||||
|
||||
JDK_PKGS = jdk
|
||||
|
||||
# non-core packages in rt.jar
|
||||
NON_CORE_PKGS = $(DOMAPI_PKGS) \
|
||||
$(MGMT_PKGS) \
|
||||
@ -103,5 +106,5 @@ NON_CORE_PKGS = $(DOMAPI_PKGS) \
|
||||
$(HTTPSERVER_PKGS) \
|
||||
$(SMARTCARDIO_PKGS) \
|
||||
$(SCTPAPI_PKGS) \
|
||||
$(APPLE_EXT_PKGS)
|
||||
|
||||
$(APPLE_EXT_PKGS) \
|
||||
$(JDK_PKGS)
|
||||
|
@ -202,3 +202,5 @@ d4e68ce17795601017ac2f952baad7272942c36e jdk8-b75
|
||||
27d6368ae8ba570c31c2f0e696d39c99fa2f4538 jdk8-b78
|
||||
e41fb1aa0329767b2737303c994e38bede1baa07 jdk8-b79
|
||||
5f3d4a6bdd027a1631d97e2dfff63fd5e46987a4 jdk8-b80
|
||||
2a00aeeb466b9dee22508f6261f63b70f9c696fe jdk8-b81
|
||||
48e1bc77004d9af575b733c04637b98fd17603c2 jdk8-b82
|
||||
|
@ -1,5 +1,5 @@
|
||||
#
|
||||
# Copyright (c) 2000, 2009, Oracle and/or its affiliates. All rights reserved.
|
||||
# Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
#
|
||||
# This code is free software; you can redistribute it and/or modify it
|
||||
@ -29,10 +29,6 @@ com_sun_corba_se_impl_orbutil_java = \
|
||||
com/sun/corba/se/impl/orbutil/DenseIntMapImpl.java \
|
||||
com/sun/corba/se/impl/orbutil/GetPropertyAction.java \
|
||||
com/sun/corba/se/impl/orbutil/HexOutputStream.java \
|
||||
com/sun/corba/se/impl/orbutil/IIOPInputStream_1_3.java \
|
||||
com/sun/corba/se/impl/orbutil/IIOPInputStream_1_3_1.java \
|
||||
com/sun/corba/se/impl/orbutil/IIOPOutputStream_1_3.java \
|
||||
com/sun/corba/se/impl/orbutil/IIOPOutputStream_1_3_1.java \
|
||||
com/sun/corba/se/impl/orbutil/LegacyHookGetFields.java \
|
||||
com/sun/corba/se/impl/orbutil/LegacyHookPutFields.java \
|
||||
com/sun/corba/se/impl/orbutil/LogKeywords.java \
|
||||
@ -45,19 +41,11 @@ com_sun_corba_se_impl_orbutil_java = \
|
||||
com/sun/corba/se/impl/orbutil/ORBUtility.java \
|
||||
com/sun/corba/se/impl/orbutil/ORBClassLoader.java \
|
||||
com/sun/corba/se/impl/orbutil/RepIdDelegator.java \
|
||||
com/sun/corba/se/impl/orbutil/RepIdDelegator_1_3.java \
|
||||
com/sun/corba/se/impl/orbutil/RepIdDelegator_1_3_1.java \
|
||||
com/sun/corba/se/impl/orbutil/RepositoryIdCache_1_3.java \
|
||||
com/sun/corba/se/impl/orbutil/RepositoryId_1_3.java \
|
||||
com/sun/corba/se/impl/orbutil/RepositoryIdFactory.java \
|
||||
com/sun/corba/se/impl/orbutil/RepositoryIdStrings.java \
|
||||
com/sun/corba/se/impl/orbutil/RepositoryIdUtility.java \
|
||||
com/sun/corba/se/impl/orbutil/RepositoryIdInterface.java \
|
||||
com/sun/corba/se/impl/orbutil/RepositoryIdCache_1_3_1.java \
|
||||
com/sun/corba/se/impl/orbutil/RepositoryId_1_3_1.java \
|
||||
com/sun/corba/se/impl/orbutil/StackImpl.java \
|
||||
com/sun/corba/se/impl/orbutil/ValueHandlerImpl_1_3_1.java \
|
||||
com/sun/corba/se/impl/orbutil/ValueHandlerImpl_1_3.java \
|
||||
com/sun/corba/se/impl/orbutil/closure/Future.java \
|
||||
com/sun/corba/se/impl/orbutil/closure/Constant.java \
|
||||
com/sun/corba/se/impl/orbutil/concurrent/Sync.java \
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2002, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -322,9 +322,9 @@ class ServerCallback extends
|
||||
com.sun.corba.se.spi.activation._ServerImplBase
|
||||
{
|
||||
private ORB orb;
|
||||
private Method installMethod ;
|
||||
private Method uninstallMethod ;
|
||||
private Method shutdownMethod ;
|
||||
private transient Method installMethod ;
|
||||
private transient Method uninstallMethod ;
|
||||
private transient Method shutdownMethod ;
|
||||
private Object methodArgs[] ;
|
||||
|
||||
ServerCallback(ORB orb, Method installMethod, Method uninstallMethod,
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2004, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -1218,7 +1218,7 @@ public class AnyImpl extends Any
|
||||
// See bug 4391648 for more info about the tcORB in this
|
||||
// case.
|
||||
RepositoryIdStrings repStrs
|
||||
= RepositoryIdFactory.getRepIdStringsFactory(tcORB);
|
||||
= RepositoryIdFactory.getRepIdStringsFactory();
|
||||
|
||||
|
||||
// Assertion: c instanceof Serializable?
|
||||
@ -1251,7 +1251,7 @@ public class AnyImpl extends Any
|
||||
// Anything else
|
||||
// We know that this is a TypeCodeImpl since it is our ORB
|
||||
classTC = (TypeCodeImpl)ValueUtility.createTypeCodeForClass(
|
||||
tcORB, c, ORBUtility.createValueHandler(tcORB));
|
||||
tcORB, c, ORBUtility.createValueHandler());
|
||||
// Intruct classTC to store its buffer
|
||||
classTC.setCaching(true);
|
||||
// Update the cache
|
||||
|
@ -2189,10 +2189,7 @@ public final class TypeCodeImpl extends TypeCode
|
||||
|
||||
if (labelIndex == _unionLabels.length) {
|
||||
// check if label has not been found
|
||||
if (_defaultIndex == -1)
|
||||
// throw exception if default was not expected
|
||||
throw wrapper.unexpectedUnionDefault() ;
|
||||
else
|
||||
if (_defaultIndex != -1)
|
||||
// must be of the default branch type
|
||||
_memberTypes[_defaultIndex].copy(src, dst);
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -269,8 +269,8 @@ public class CDRInputStream_1_0 extends CDRInputStreamBase
|
||||
|
||||
private final void createRepositoryIdHandlers()
|
||||
{
|
||||
repIdUtil = RepositoryIdFactory.getRepIdUtility(orb);
|
||||
repIdStrs = RepositoryIdFactory.getRepIdStringsFactory(orb);
|
||||
repIdUtil = RepositoryIdFactory.getRepIdUtility();
|
||||
repIdStrs = RepositoryIdFactory.getRepIdStringsFactory();
|
||||
}
|
||||
|
||||
public GIOPVersion getGIOPVersion() {
|
||||
@ -564,9 +564,6 @@ public class CDRInputStream_1_0 extends CDRInputStreamBase
|
||||
|
||||
checkForNegativeLength(len);
|
||||
|
||||
if (orb != null && ORBUtility.isLegacyORB((ORB)orb))
|
||||
return legacyReadString(len);
|
||||
else
|
||||
return internalReadString(len);
|
||||
}
|
||||
|
||||
@ -588,54 +585,6 @@ public class CDRInputStream_1_0 extends CDRInputStreamBase
|
||||
return new String(result, 0, getCharConverter().getNumChars());
|
||||
}
|
||||
|
||||
private final String legacyReadString(int len) {
|
||||
|
||||
//
|
||||
// Workaround for ORBs which send string lengths of
|
||||
// zero to mean empty string.
|
||||
//
|
||||
//
|
||||
// IMPORTANT: Do not replace 'new String("")' with "", it may result
|
||||
// in a Serialization bug (See serialization.zerolengthstring) and
|
||||
// bug id: 4728756 for details
|
||||
if (len == 0)
|
||||
return new String("");
|
||||
|
||||
len--;
|
||||
char[] c = new char[len];
|
||||
|
||||
int n = 0;
|
||||
while (n < len) {
|
||||
int avail;
|
||||
int bytes;
|
||||
int wanted;
|
||||
|
||||
avail = bbwi.buflen - bbwi.position();
|
||||
if (avail <= 0) {
|
||||
grow(1, 1);
|
||||
avail = bbwi.buflen - bbwi.position();
|
||||
}
|
||||
wanted = len - n;
|
||||
bytes = (wanted < avail) ? wanted : avail;
|
||||
// Microbenchmarks are showing a loop of ByteBuffer.get(int) being
|
||||
// faster than ByteBuffer.get(byte[], int, int).
|
||||
for (int i=0; i<bytes; i++) {
|
||||
c[n+i] = (char) (bbwi.byteBuffer.get(bbwi.position()+i) & 0xFF);
|
||||
}
|
||||
bbwi.position(bbwi.position() + bytes);
|
||||
n += bytes;
|
||||
}
|
||||
|
||||
//
|
||||
// Skip past terminating null byte
|
||||
//
|
||||
if (bbwi.position() + 1 > bbwi.buflen)
|
||||
alignAndCheck(1, 1);
|
||||
bbwi.position(bbwi.position() + 1);
|
||||
|
||||
return new String(c);
|
||||
}
|
||||
|
||||
public final String read_string() {
|
||||
return readStringOrIndirection(false);
|
||||
}
|
||||
@ -1045,7 +994,7 @@ public class CDRInputStream_1_0 extends CDRInputStreamBase
|
||||
|
||||
try {
|
||||
if (valueHandler == null)
|
||||
valueHandler = ORBUtility.createValueHandler(orb);
|
||||
valueHandler = ORBUtility.createValueHandler();
|
||||
|
||||
value = valueHandler.readValue(parent,
|
||||
indirection,
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -189,19 +189,9 @@ public class CDROutputStream_1_0 extends CDROutputStreamBase
|
||||
|
||||
private final void createRepositoryIdHandlers()
|
||||
{
|
||||
if (orb != null) {
|
||||
// Get the appropriate versions based on the ORB version. The
|
||||
// ORB versioning info is only in the core ORB.
|
||||
repIdUtil
|
||||
= RepositoryIdFactory.getRepIdUtility(orb);
|
||||
repIdStrs
|
||||
= RepositoryIdFactory.getRepIdStringsFactory(orb);
|
||||
} else {
|
||||
// Get the latest versions
|
||||
repIdUtil = RepositoryIdFactory.getRepIdUtility();
|
||||
repIdStrs = RepositoryIdFactory.getRepIdStringsFactory();
|
||||
}
|
||||
}
|
||||
|
||||
public BufferManagerWrite getBufferManager()
|
||||
{
|
||||
@ -705,7 +695,7 @@ public class CDROutputStream_1_0 extends CDROutputStreamBase
|
||||
private void writeArray(Serializable array, Class clazz) {
|
||||
|
||||
if (valueHandler == null)
|
||||
valueHandler = ORBUtility.createValueHandler(orb); //d11638
|
||||
valueHandler = ORBUtility.createValueHandler(); //d11638
|
||||
|
||||
// Write value_tag
|
||||
int indirection = writeValueTag(mustChunk, true,
|
||||
@ -768,7 +758,7 @@ public class CDROutputStream_1_0 extends CDROutputStreamBase
|
||||
|
||||
private void writeRMIIIOPValueType(Serializable object, Class clazz) {
|
||||
if (valueHandler == null)
|
||||
valueHandler = ORBUtility.createValueHandler(orb); //d11638
|
||||
valueHandler = ORBUtility.createValueHandler(); //d11638
|
||||
|
||||
Serializable key = object;
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1999, 2003, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -86,7 +86,7 @@ public class FVDCodeBaseImpl extends _CodeBaseImplBase
|
||||
// default to using the current ORB version in case the
|
||||
// vhandler is not set
|
||||
if (vhandler == null) {
|
||||
vhandler = new ValueHandlerImpl(false);
|
||||
vhandler = ValueHandlerImpl.getInstance(false);
|
||||
}
|
||||
|
||||
// Util.getCodebase may return null which would
|
||||
@ -120,7 +120,7 @@ public class FVDCodeBaseImpl extends _CodeBaseImplBase
|
||||
// default to using the current ORB version in case the
|
||||
// vhandler is not set
|
||||
if (vhandler == null) {
|
||||
vhandler = new ValueHandlerImpl(false);
|
||||
vhandler = ValueHandlerImpl.getInstance(false);
|
||||
}
|
||||
|
||||
try{
|
||||
@ -161,7 +161,7 @@ public class FVDCodeBaseImpl extends _CodeBaseImplBase
|
||||
// default to using the current ORB version in case the
|
||||
// vhandler is not set
|
||||
if (vhandler == null) {
|
||||
vhandler = new ValueHandlerImpl(false);
|
||||
vhandler = ValueHandlerImpl.getInstance(false);
|
||||
}
|
||||
|
||||
Stack repIds = new Stack();
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -25,7 +25,7 @@
|
||||
/*
|
||||
* Licensed Materials - Property of IBM
|
||||
* RMI-IIOP v1.0
|
||||
* Copyright IBM Corp. 1998 1999 All Rights Reserved
|
||||
* Copyright IBM Corp. 1998 2012 All Rights Reserved
|
||||
*
|
||||
*/
|
||||
|
||||
@ -56,7 +56,6 @@ import java.io.Serializable;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
import java.util.Hashtable;
|
||||
|
||||
import com.sun.corba.se.impl.util.RepositoryId;
|
||||
|
||||
@ -83,8 +82,6 @@ public class ObjectStreamClass implements java.io.Serializable {
|
||||
private static Object noArgsList[] = {};
|
||||
private static Class noTypesList[] = {};
|
||||
|
||||
private static Hashtable translatedFields;
|
||||
|
||||
/** true if represents enum type */
|
||||
private boolean isEnum;
|
||||
|
||||
@ -384,6 +381,42 @@ public class ObjectStreamClass implements java.io.Serializable {
|
||||
*/
|
||||
}
|
||||
|
||||
private static final class PersistentFieldsValue
|
||||
extends ClassValue<ObjectStreamField[]> {
|
||||
PersistentFieldsValue() { }
|
||||
|
||||
protected ObjectStreamField[] computeValue(Class<?> type) {
|
||||
try {
|
||||
Field pf = type.getDeclaredField("serialPersistentFields");
|
||||
int mods = pf.getModifiers();
|
||||
if (Modifier.isPrivate(mods) && Modifier.isStatic(mods) &&
|
||||
Modifier.isFinal(mods)) {
|
||||
pf.setAccessible(true);
|
||||
java.io.ObjectStreamField[] fields =
|
||||
(java.io.ObjectStreamField[])pf.get(type);
|
||||
return translateFields(fields);
|
||||
}
|
||||
} catch (NoSuchFieldException | IllegalAccessException |
|
||||
IllegalArgumentException | ClassCastException e) {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static ObjectStreamField[] translateFields(
|
||||
java.io.ObjectStreamField[] fields) {
|
||||
ObjectStreamField[] translation =
|
||||
new ObjectStreamField[fields.length];
|
||||
for (int i = 0; i < fields.length; i++) {
|
||||
translation[i] = new ObjectStreamField(fields[i].getName(),
|
||||
fields[i].getType());
|
||||
}
|
||||
return translation;
|
||||
}
|
||||
}
|
||||
|
||||
private static final PersistentFieldsValue persistentFieldsValue =
|
||||
new PersistentFieldsValue();
|
||||
|
||||
/*
|
||||
* Initialize class descriptor. This method is only invoked on class
|
||||
* descriptors created via calls to lookupInternal(). This method is kept
|
||||
@ -416,35 +449,7 @@ public class ObjectStreamClass implements java.io.Serializable {
|
||||
* If it is declared, use the declared serialPersistentFields.
|
||||
* Otherwise, extract the fields from the class itself.
|
||||
*/
|
||||
try {
|
||||
Field pf = cl.getDeclaredField("serialPersistentFields");
|
||||
// serial bug 7; the serialPersistentFields were not
|
||||
// being read and stored as Accessible bit was not set
|
||||
pf.setAccessible(true);
|
||||
// serial bug 7; need to find if the field is of type
|
||||
// java.io.ObjectStreamField
|
||||
java.io.ObjectStreamField[] f =
|
||||
(java.io.ObjectStreamField[])pf.get(cl);
|
||||
int mods = pf.getModifiers();
|
||||
if ((Modifier.isPrivate(mods)) &&
|
||||
(Modifier.isStatic(mods)) &&
|
||||
(Modifier.isFinal(mods)))
|
||||
{
|
||||
fields = (ObjectStreamField[])translateFields((Object[])pf.get(cl));
|
||||
}
|
||||
} catch (NoSuchFieldException e) {
|
||||
fields = null;
|
||||
} catch (IllegalAccessException e) {
|
||||
fields = null;
|
||||
} catch (IllegalArgumentException e) {
|
||||
fields = null;
|
||||
} catch (ClassCastException e) {
|
||||
/* Thrown if a field serialPersistentField exists
|
||||
* but it is not of type ObjectStreamField.
|
||||
*/
|
||||
fields = null;
|
||||
}
|
||||
|
||||
fields = persistentFieldsValue.get(cl);
|
||||
|
||||
if (fields == null) {
|
||||
/* Get all of the declared fields for this
|
||||
@ -641,43 +646,6 @@ public class ObjectStreamClass implements java.io.Serializable {
|
||||
superclass = null;
|
||||
}
|
||||
|
||||
private static Object[] translateFields(Object objs[])
|
||||
throws NoSuchFieldException {
|
||||
try{
|
||||
java.io.ObjectStreamField fields[] = (java.io.ObjectStreamField[])objs;
|
||||
Object translation[] = null;
|
||||
|
||||
if (translatedFields == null)
|
||||
translatedFields = new Hashtable();
|
||||
|
||||
translation = (Object[])translatedFields.get(fields);
|
||||
|
||||
if (translation != null)
|
||||
return translation;
|
||||
else {
|
||||
Class osfClass = Class.forName("com.sun.corba.se.impl.io.ObjectStreamField");
|
||||
translation = (Object[])java.lang.reflect.Array.newInstance(osfClass, objs.length);
|
||||
Object arg[] = new Object[2];
|
||||
Class types[] = {String.class, Class.class};
|
||||
Constructor constructor = osfClass.getDeclaredConstructor(types);
|
||||
for (int i = fields.length -1; i >= 0; i--){
|
||||
arg[0] = fields[i].getName();
|
||||
arg[1] = fields[i].getType();
|
||||
|
||||
translation[i] = constructor.newInstance(arg);
|
||||
}
|
||||
translatedFields.put(fields, translation);
|
||||
|
||||
}
|
||||
|
||||
return (Object[])translation;
|
||||
}
|
||||
catch(Throwable t){
|
||||
NoSuchFieldException nsfe = new NoSuchFieldException();
|
||||
nsfe.initCause( t ) ;
|
||||
throw nsfe ;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Set the class this version descriptor matches.
|
||||
@ -1555,8 +1523,8 @@ public class ObjectStreamClass implements java.io.Serializable {
|
||||
private boolean hasExternalizableBlockData;
|
||||
Method writeObjectMethod;
|
||||
Method readObjectMethod;
|
||||
private Method writeReplaceObjectMethod;
|
||||
private Method readResolveObjectMethod;
|
||||
private transient Method writeReplaceObjectMethod;
|
||||
private transient Method readResolveObjectMethod;
|
||||
private Constructor cons ;
|
||||
|
||||
/**
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -53,7 +53,7 @@ import com.sun.corba.se.spi.logging.CORBALogDomains;
|
||||
import com.sun.corba.se.impl.logging.OMGSystemException;
|
||||
import com.sun.corba.se.impl.logging.UtilSystemException;
|
||||
|
||||
public class ValueHandlerImpl implements javax.rmi.CORBA.ValueHandlerMultiFormat {
|
||||
public final class ValueHandlerImpl implements javax.rmi.CORBA.ValueHandlerMultiFormat {
|
||||
|
||||
// Property to override our maximum stream format version
|
||||
public static final String FORMAT_VERSION_PROPERTY
|
||||
@ -150,14 +150,22 @@ public class ValueHandlerImpl implements javax.rmi.CORBA.ValueHandlerMultiFormat
|
||||
writeValueWithVersion(out, value, streamFormatVersion);
|
||||
}
|
||||
|
||||
public ValueHandlerImpl(){}
|
||||
private ValueHandlerImpl(){}
|
||||
|
||||
public ValueHandlerImpl(boolean isInputStream) {
|
||||
private ValueHandlerImpl(boolean isInputStream) {
|
||||
this();
|
||||
useHashtables = false;
|
||||
this.isInputStream = isInputStream;
|
||||
}
|
||||
|
||||
static ValueHandlerImpl getInstance() {
|
||||
return new ValueHandlerImpl();
|
||||
}
|
||||
|
||||
static ValueHandlerImpl getInstance(boolean isInputStream) {
|
||||
return new ValueHandlerImpl(isInputStream);
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes the value to the stream using java semantics.
|
||||
* @param out The stream to write the value to
|
||||
@ -458,12 +466,7 @@ public class ValueHandlerImpl implements javax.rmi.CORBA.ValueHandlerMultiFormat
|
||||
return ObjectStreamClass.lookup(value.getClass()).writeReplace(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Encapsulates writing of Java char arrays so that the 1.3 subclass
|
||||
* can override it without exposing internals across packages. This
|
||||
* is a fix for bug 4367783.
|
||||
*/
|
||||
protected void writeCharArray(org.omg.CORBA_2_3.portable.OutputStream out,
|
||||
private void writeCharArray(org.omg.CORBA_2_3.portable.OutputStream out,
|
||||
char[] array,
|
||||
int offset,
|
||||
int length)
|
||||
@ -576,12 +579,7 @@ public class ValueHandlerImpl implements javax.rmi.CORBA.ValueHandlerMultiFormat
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Encapsulates reading of Java char arrays so that the 1.3 subclass
|
||||
* can override it without exposing internals across packages. This
|
||||
* is a fix for bug 4367783.
|
||||
*/
|
||||
protected void readCharArray(org.omg.CORBA_2_3.portable.InputStream in,
|
||||
private void readCharArray(org.omg.CORBA_2_3.portable.InputStream in,
|
||||
char[] array,
|
||||
int offset,
|
||||
int length)
|
||||
@ -795,7 +793,7 @@ public class ValueHandlerImpl implements javax.rmi.CORBA.ValueHandlerMultiFormat
|
||||
return RepositoryId.cache.getId(repId).isSequence();
|
||||
}
|
||||
|
||||
protected String getOutputStreamClassName() {
|
||||
private String getOutputStreamClassName() {
|
||||
return "com.sun.corba.se.impl.io.IIOPOutputStream";
|
||||
}
|
||||
|
||||
@ -843,29 +841,11 @@ public class ValueHandlerImpl implements javax.rmi.CORBA.ValueHandlerMultiFormat
|
||||
private IIOPOutputStream createOutputStreamBuiltInNoPriv(
|
||||
final String name
|
||||
) throws IOException {
|
||||
return
|
||||
name.equals(
|
||||
IIOPOutputStream
|
||||
.class.getName()
|
||||
) ?
|
||||
new IIOPOutputStream() :
|
||||
|
||||
name.equals(
|
||||
com.sun.corba.se.impl.orbutil.IIOPOutputStream_1_3
|
||||
.class.getName()
|
||||
) ?
|
||||
new com.sun.corba.se.impl.orbutil.IIOPOutputStream_1_3() :
|
||||
|
||||
name.equals(
|
||||
com.sun.corba.se.impl.orbutil.IIOPOutputStream_1_3_1
|
||||
.class.getName()
|
||||
) ?
|
||||
new com.sun.corba.se.impl.orbutil.IIOPOutputStream_1_3_1() :
|
||||
|
||||
null;
|
||||
return name.equals(IIOPOutputStream.class.getName()) ?
|
||||
new IIOPOutputStream() : null;
|
||||
}
|
||||
|
||||
protected String getInputStreamClassName() {
|
||||
private String getInputStreamClassName() {
|
||||
return "com.sun.corba.se.impl.io.IIOPInputStream";
|
||||
}
|
||||
|
||||
@ -913,26 +893,8 @@ public class ValueHandlerImpl implements javax.rmi.CORBA.ValueHandlerMultiFormat
|
||||
private IIOPInputStream createInputStreamBuiltInNoPriv(
|
||||
final String name
|
||||
) throws IOException {
|
||||
return
|
||||
name.equals(
|
||||
IIOPInputStream
|
||||
.class.getName()
|
||||
) ?
|
||||
new IIOPInputStream() :
|
||||
|
||||
name.equals(
|
||||
com.sun.corba.se.impl.orbutil.IIOPInputStream_1_3
|
||||
.class.getName()
|
||||
) ?
|
||||
new com.sun.corba.se.impl.orbutil.IIOPInputStream_1_3() :
|
||||
|
||||
name.equals(
|
||||
com.sun.corba.se.impl.orbutil.IIOPInputStream_1_3_1
|
||||
.class.getName()
|
||||
) ?
|
||||
new com.sun.corba.se.impl.orbutil.IIOPInputStream_1_3_1() :
|
||||
|
||||
null;
|
||||
return name.equals(IIOPInputStream.class.getName()) ?
|
||||
new IIOPInputStream() : null;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -958,12 +920,7 @@ public class ValueHandlerImpl implements javax.rmi.CORBA.ValueHandlerMultiFormat
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Our JDK 1.3 and JDK 1.3.1 behavior subclasses override this.
|
||||
* The correct behavior is for a Java char to map to a CORBA wchar,
|
||||
* but our older code mapped it to a CORBA char.
|
||||
*/
|
||||
protected TCKind getJavaCharTCKind() {
|
||||
TCKind getJavaCharTCKind() {
|
||||
return TCKind.tk_wchar;
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1999, 2002, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -93,6 +93,14 @@ public class ValueUtility {
|
||||
null, // tk_abstract_interface 32
|
||||
};
|
||||
|
||||
static {
|
||||
sun.corba.SharedSecrets.setJavaCorbaAccess(new sun.corba.JavaCorbaAccess() {
|
||||
public ValueHandlerImpl newValueHandlerImpl() {
|
||||
return ValueHandlerImpl.getInstance();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static String getSignature(ValueMember member)
|
||||
throws ClassNotFoundException {
|
||||
|
||||
|
@ -112,6 +112,9 @@ import com.sun.corba.se.impl.util.JDKBridge;
|
||||
import com.sun.corba.se.impl.orbutil.ORBClassLoader;
|
||||
import com.sun.corba.se.impl.logging.UtilSystemException;
|
||||
import com.sun.corba.se.spi.logging.CORBALogDomains;
|
||||
import sun.corba.SharedSecrets;
|
||||
import sun.corba.JavaCorbaAccess;
|
||||
|
||||
|
||||
/**
|
||||
* Provides utility methods that can be used by stubs and ties to
|
||||
@ -125,7 +128,8 @@ public class Util implements javax.rmi.CORBA.UtilDelegate
|
||||
// Maps targets to ties.
|
||||
private static IdentityHashtable exportedServants = new IdentityHashtable();
|
||||
|
||||
private static ValueHandlerImpl valueHandlerSingleton = new ValueHandlerImpl();
|
||||
private static final ValueHandlerImpl valueHandlerSingleton =
|
||||
SharedSecrets.getJavaCorbaAccess().newValueHandlerImpl();
|
||||
|
||||
private UtilSystemException utilWrapper = UtilSystemException.get(
|
||||
CORBALogDomains.RPC_ENCODING);
|
||||
|
@ -840,7 +840,7 @@ public class ORBImpl extends com.sun.corba.se.spi.orb.ORB
|
||||
// backward compatability 4365188
|
||||
CodeBase cb;
|
||||
|
||||
ValueHandler vh = ORBUtility.createValueHandler(this);
|
||||
ValueHandler vh = ORBUtility.createValueHandler();
|
||||
|
||||
cb = (CodeBase)vh.getRunTimeCodeBase();
|
||||
return ORBUtility.connectAndGetIOR( this, cb ) ;
|
||||
|
@ -1,68 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2002, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package com.sun.corba.se.impl.orbutil;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
/**
|
||||
* Implements legacy behavior from before Ladybird to maintain
|
||||
* backwards compatibility.
|
||||
*/
|
||||
public class IIOPOutputStream_1_3 extends com.sun.corba.se.impl.io.IIOPOutputStream
|
||||
{
|
||||
// We can't assume that the superclass's putFields
|
||||
// member will be non-private. We must allow
|
||||
// the RI to run on JDK 1.3.1 FCS as well as
|
||||
// the JDK 1.3.1_01 patch.
|
||||
private ObjectOutputStream.PutField putFields_1_3;
|
||||
|
||||
// The newer version in the io package correctly writes a wstring instead.
|
||||
// This concerns bug 4379597.
|
||||
protected void internalWriteUTF(org.omg.CORBA.portable.OutputStream stream,
|
||||
String data)
|
||||
{
|
||||
stream.write_string(data);
|
||||
}
|
||||
|
||||
public IIOPOutputStream_1_3()
|
||||
throws java.io.IOException {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* Before JDK 1.3.1_01, the PutField/GetField implementation
|
||||
* actually sent a Hashtable.
|
||||
*/
|
||||
public ObjectOutputStream.PutField putFields()
|
||||
throws IOException {
|
||||
putFields_1_3 = new LegacyHookPutFields();
|
||||
return putFields_1_3;
|
||||
}
|
||||
|
||||
public void writeFields()
|
||||
throws IOException {
|
||||
putFields_1_3.write(this);
|
||||
}
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2009, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -160,42 +160,10 @@ public final class ORBUtility {
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the correct ValueHandler for the given ORB,
|
||||
* querying ORBVersion information. If the ORB or
|
||||
* ORBVersion is null, gets the ValueHandler from
|
||||
* Util.createValueHandler.
|
||||
* Return default ValueHandler
|
||||
*/
|
||||
public static ValueHandler createValueHandler(ORB orb) {
|
||||
|
||||
if (orb == null)
|
||||
public static ValueHandler createValueHandler() {
|
||||
return Util.createValueHandler();
|
||||
|
||||
ORBVersion version = orb.getORBVersion();
|
||||
|
||||
if (version == null)
|
||||
return Util.createValueHandler();
|
||||
|
||||
if (version.equals(ORBVersionFactory.getOLD()))
|
||||
return new ValueHandlerImpl_1_3();
|
||||
if (version.equals(ORBVersionFactory.getNEW()))
|
||||
return new ValueHandlerImpl_1_3_1();
|
||||
|
||||
return Util.createValueHandler();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the given ORB could accurately be determined to be a
|
||||
* Kestrel or earlier ORB. Note: If passed the ORBSingleton, this will return
|
||||
* false.
|
||||
*/
|
||||
public static boolean isLegacyORB(ORB orb)
|
||||
{
|
||||
try {
|
||||
ORBVersion currentORB = orb.getORBVersion();
|
||||
return currentORB.equals( ORBVersionFactory.getOLD() ) ;
|
||||
} catch (SecurityException se) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2001, 2003, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -1119,8 +1119,8 @@ public class ObjectStreamClass_1_3_1 implements java.io.Serializable {
|
||||
private boolean hasExternalizableBlockData;
|
||||
Method writeObjectMethod;
|
||||
Method readObjectMethod;
|
||||
private Method writeReplaceObjectMethod;
|
||||
private Method readResolveObjectMethod;
|
||||
private transient Method writeReplaceObjectMethod;
|
||||
private transient Method readResolveObjectMethod;
|
||||
|
||||
/*
|
||||
* ObjectStreamClass_1_3_1 that this one was built from.
|
||||
|
@ -1,177 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2004, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.corba.se.impl.orbutil;
|
||||
|
||||
import org.omg.CORBA.ORB;
|
||||
import java.io.Serializable;
|
||||
import java.util.Hashtable;
|
||||
import java.net.MalformedURLException;
|
||||
import com.sun.corba.se.impl.io.TypeMismatchException;
|
||||
import com.sun.corba.se.impl.util.RepositoryId;
|
||||
|
||||
/**
|
||||
* Delegates to the RepositoryId_1_3 implementation in
|
||||
* com.sun.corba.se.impl.orbutil. This is necessary to
|
||||
* overcome the fact that many of RepositoryId's methods
|
||||
* are static.
|
||||
*/
|
||||
public final class RepIdDelegator_1_3
|
||||
implements RepositoryIdStrings,
|
||||
RepositoryIdUtility,
|
||||
RepositoryIdInterface
|
||||
{
|
||||
// RepositoryIdFactory methods
|
||||
|
||||
public String createForAnyType(Class type) {
|
||||
return RepositoryId_1_3.createForAnyType(type);
|
||||
}
|
||||
|
||||
public String createForJavaType(Serializable ser)
|
||||
throws TypeMismatchException
|
||||
{
|
||||
return RepositoryId_1_3.createForJavaType(ser);
|
||||
}
|
||||
|
||||
public String createForJavaType(Class clz)
|
||||
throws TypeMismatchException
|
||||
{
|
||||
return RepositoryId_1_3.createForJavaType(clz);
|
||||
}
|
||||
|
||||
public String createSequenceRepID(java.lang.Object ser) {
|
||||
return RepositoryId_1_3.createSequenceRepID(ser);
|
||||
}
|
||||
|
||||
public String createSequenceRepID(Class clazz) {
|
||||
return RepositoryId_1_3.createSequenceRepID(clazz);
|
||||
}
|
||||
|
||||
public RepositoryIdInterface getFromString(String repIdString) {
|
||||
return new RepIdDelegator_1_3(RepositoryId_1_3.cache.getId(repIdString));
|
||||
}
|
||||
|
||||
// RepositoryIdUtility methods
|
||||
|
||||
public boolean isChunkedEncoding(int valueTag) {
|
||||
return RepositoryId.isChunkedEncoding(valueTag);
|
||||
}
|
||||
|
||||
public boolean isCodeBasePresent(int valueTag) {
|
||||
return RepositoryId.isCodeBasePresent(valueTag);
|
||||
}
|
||||
|
||||
public String getClassDescValueRepId() {
|
||||
return RepositoryId_1_3.kClassDescValueRepID;
|
||||
}
|
||||
|
||||
public String getWStringValueRepId() {
|
||||
return RepositoryId_1_3.kWStringValueRepID;
|
||||
}
|
||||
|
||||
public int getTypeInfo(int valueTag) {
|
||||
return RepositoryId.getTypeInfo(valueTag);
|
||||
}
|
||||
|
||||
public int getStandardRMIChunkedNoRepStrId() {
|
||||
return RepositoryId.kPreComputed_StandardRMIChunked_NoRep;
|
||||
}
|
||||
|
||||
public int getCodeBaseRMIChunkedNoRepStrId() {
|
||||
return RepositoryId.kPreComputed_CodeBaseRMIChunked_NoRep;
|
||||
}
|
||||
|
||||
public int getStandardRMIChunkedId() {
|
||||
return RepositoryId.kPreComputed_StandardRMIChunked;
|
||||
}
|
||||
|
||||
public int getCodeBaseRMIChunkedId() {
|
||||
return RepositoryId.kPreComputed_CodeBaseRMIChunked;
|
||||
}
|
||||
|
||||
public int getStandardRMIUnchunkedId() {
|
||||
return RepositoryId.kPreComputed_StandardRMIUnchunked;
|
||||
}
|
||||
|
||||
public int getCodeBaseRMIUnchunkedId() {
|
||||
return RepositoryId.kPreComputed_CodeBaseRMIUnchunked;
|
||||
}
|
||||
|
||||
public int getStandardRMIUnchunkedNoRepStrId() {
|
||||
return RepositoryId.kPreComputed_StandardRMIUnchunked_NoRep;
|
||||
}
|
||||
|
||||
public int getCodeBaseRMIUnchunkedNoRepStrId() {
|
||||
return RepositoryId.kPreComputed_CodeBaseRMIUnchunked_NoRep;
|
||||
}
|
||||
|
||||
// RepositoryIdInterface methods
|
||||
|
||||
public Class getClassFromType() throws ClassNotFoundException {
|
||||
return delegate.getClassFromType();
|
||||
}
|
||||
|
||||
public Class getClassFromType(String codebaseURL)
|
||||
throws ClassNotFoundException, MalformedURLException
|
||||
{
|
||||
return delegate.getClassFromType(codebaseURL);
|
||||
}
|
||||
|
||||
public Class getClassFromType(Class expectedType,
|
||||
String codebaseURL)
|
||||
throws ClassNotFoundException, MalformedURLException
|
||||
{
|
||||
return delegate.getClassFromType(expectedType, codebaseURL);
|
||||
}
|
||||
|
||||
public String getClassName() {
|
||||
return delegate.getClassName();
|
||||
}
|
||||
|
||||
// Constructor used for factory/utility cases
|
||||
public RepIdDelegator_1_3() {}
|
||||
|
||||
// Constructor used by getIdFromString. All non-static
|
||||
// RepositoryId methods will use the provided delegate.
|
||||
private RepIdDelegator_1_3(RepositoryId_1_3 _delegate) {
|
||||
this.delegate = _delegate;
|
||||
}
|
||||
|
||||
private RepositoryId_1_3 delegate = null;
|
||||
|
||||
public String toString() {
|
||||
if (delegate != null)
|
||||
return delegate.toString();
|
||||
else
|
||||
return this.getClass().getName();
|
||||
}
|
||||
|
||||
public boolean equals(Object obj) {
|
||||
if (delegate != null)
|
||||
return delegate.equals(obj);
|
||||
else
|
||||
return super.equals(obj);
|
||||
}
|
||||
}
|
@ -1,177 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001, 2004, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.corba.se.impl.orbutil;
|
||||
|
||||
import org.omg.CORBA.ORB;
|
||||
import java.io.Serializable;
|
||||
import java.util.Hashtable;
|
||||
import java.net.MalformedURLException;
|
||||
import com.sun.corba.se.impl.io.TypeMismatchException;
|
||||
import com.sun.corba.se.impl.util.RepositoryId;
|
||||
|
||||
/**
|
||||
* Delegates to the RepositoryId_1_3_1 implementation in
|
||||
* com.sun.corba.se.impl.orbutil. This is necessary to
|
||||
* overcome the fact that many of RepositoryId's methods
|
||||
* are static.
|
||||
*/
|
||||
public final class RepIdDelegator_1_3_1
|
||||
implements RepositoryIdStrings,
|
||||
RepositoryIdUtility,
|
||||
RepositoryIdInterface
|
||||
{
|
||||
// RepositoryIdFactory methods
|
||||
|
||||
public String createForAnyType(Class type) {
|
||||
return RepositoryId_1_3_1.createForAnyType(type);
|
||||
}
|
||||
|
||||
public String createForJavaType(Serializable ser)
|
||||
throws TypeMismatchException
|
||||
{
|
||||
return RepositoryId_1_3_1.createForJavaType(ser);
|
||||
}
|
||||
|
||||
public String createForJavaType(Class clz)
|
||||
throws TypeMismatchException
|
||||
{
|
||||
return RepositoryId_1_3_1.createForJavaType(clz);
|
||||
}
|
||||
|
||||
public String createSequenceRepID(java.lang.Object ser) {
|
||||
return RepositoryId_1_3_1.createSequenceRepID(ser);
|
||||
}
|
||||
|
||||
public String createSequenceRepID(Class clazz) {
|
||||
return RepositoryId_1_3_1.createSequenceRepID(clazz);
|
||||
}
|
||||
|
||||
public RepositoryIdInterface getFromString(String repIdString) {
|
||||
return new RepIdDelegator_1_3_1(RepositoryId_1_3_1.cache.getId(repIdString));
|
||||
}
|
||||
|
||||
// RepositoryIdUtility methods
|
||||
|
||||
public boolean isChunkedEncoding(int valueTag) {
|
||||
return RepositoryId.isChunkedEncoding(valueTag);
|
||||
}
|
||||
|
||||
public boolean isCodeBasePresent(int valueTag) {
|
||||
return RepositoryId.isCodeBasePresent(valueTag);
|
||||
}
|
||||
|
||||
public String getClassDescValueRepId() {
|
||||
return RepositoryId_1_3_1.kClassDescValueRepID;
|
||||
}
|
||||
|
||||
public String getWStringValueRepId() {
|
||||
return RepositoryId_1_3_1.kWStringValueRepID;
|
||||
}
|
||||
|
||||
public int getTypeInfo(int valueTag) {
|
||||
return RepositoryId.getTypeInfo(valueTag);
|
||||
}
|
||||
|
||||
public int getStandardRMIChunkedNoRepStrId() {
|
||||
return RepositoryId.kPreComputed_StandardRMIChunked_NoRep;
|
||||
}
|
||||
|
||||
public int getCodeBaseRMIChunkedNoRepStrId() {
|
||||
return RepositoryId.kPreComputed_CodeBaseRMIChunked_NoRep;
|
||||
}
|
||||
|
||||
public int getStandardRMIChunkedId() {
|
||||
return RepositoryId.kPreComputed_StandardRMIChunked;
|
||||
}
|
||||
|
||||
public int getCodeBaseRMIChunkedId() {
|
||||
return RepositoryId.kPreComputed_CodeBaseRMIChunked;
|
||||
}
|
||||
|
||||
public int getStandardRMIUnchunkedId() {
|
||||
return RepositoryId.kPreComputed_StandardRMIUnchunked;
|
||||
}
|
||||
|
||||
public int getCodeBaseRMIUnchunkedId() {
|
||||
return RepositoryId.kPreComputed_CodeBaseRMIUnchunked;
|
||||
}
|
||||
|
||||
public int getStandardRMIUnchunkedNoRepStrId() {
|
||||
return RepositoryId.kPreComputed_StandardRMIUnchunked_NoRep;
|
||||
}
|
||||
|
||||
public int getCodeBaseRMIUnchunkedNoRepStrId() {
|
||||
return RepositoryId.kPreComputed_CodeBaseRMIUnchunked_NoRep;
|
||||
}
|
||||
|
||||
// RepositoryIdInterface methods
|
||||
|
||||
public Class getClassFromType() throws ClassNotFoundException {
|
||||
return delegate.getClassFromType();
|
||||
}
|
||||
|
||||
public Class getClassFromType(String codebaseURL)
|
||||
throws ClassNotFoundException, MalformedURLException
|
||||
{
|
||||
return delegate.getClassFromType(codebaseURL);
|
||||
}
|
||||
|
||||
public Class getClassFromType(Class expectedType,
|
||||
String codebaseURL)
|
||||
throws ClassNotFoundException, MalformedURLException
|
||||
{
|
||||
return delegate.getClassFromType(expectedType, codebaseURL);
|
||||
}
|
||||
|
||||
public String getClassName() {
|
||||
return delegate.getClassName();
|
||||
}
|
||||
|
||||
// Constructor used for factory/utility cases
|
||||
public RepIdDelegator_1_3_1() {}
|
||||
|
||||
// Constructor used by getIdFromString. All non-static
|
||||
// RepositoryId methods will use the provided delegate.
|
||||
private RepIdDelegator_1_3_1(RepositoryId_1_3_1 _delegate) {
|
||||
this.delegate = _delegate;
|
||||
}
|
||||
|
||||
private RepositoryId_1_3_1 delegate = null;
|
||||
|
||||
public String toString() {
|
||||
if (delegate != null)
|
||||
return delegate.toString();
|
||||
else
|
||||
return this.getClass().getName();
|
||||
}
|
||||
|
||||
public boolean equals(Object obj) {
|
||||
if (delegate != null)
|
||||
return delegate.equals(obj);
|
||||
else
|
||||
return super.equals(obj);
|
||||
}
|
||||
}
|
@ -1,108 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2002, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
/*
|
||||
* Licensed Materials - Property of IBM
|
||||
* RMI-IIOP v1.0
|
||||
* Copyright IBM Corp. 1998 1999 All Rights Reserved
|
||||
*
|
||||
*/
|
||||
|
||||
package com.sun.corba.se.impl.orbutil;
|
||||
|
||||
import java.util.Stack;
|
||||
import java.util.Hashtable;
|
||||
import java.util.EmptyStackException;
|
||||
import java.util.Enumeration;
|
||||
|
||||
// Really limited pool - in this case just creating several at a time...
|
||||
class RepositoryIdPool_1_3 extends Stack {
|
||||
|
||||
private static int MAX_CACHE_SIZE = 4;
|
||||
private RepositoryIdCache_1_3 cache;
|
||||
|
||||
public final synchronized RepositoryId_1_3 popId() {
|
||||
|
||||
try {
|
||||
return (RepositoryId_1_3)super.pop();
|
||||
}
|
||||
catch(EmptyStackException e) {
|
||||
increasePool(5);
|
||||
return (RepositoryId_1_3)super.pop();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Pool management
|
||||
final void increasePool(int size) {
|
||||
//if (cache.size() <= MAX_CACHE_SIZE)
|
||||
for (int i = size; i > 0; i--)
|
||||
push(new RepositoryId_1_3());
|
||||
/*
|
||||
// _REVISIT_ This will not work w/out either thread tracing or weak references. I am
|
||||
// betting that thread tracing almost completely negates benefit of reuse. Until either
|
||||
// 1.2 only inclusion or proof to the contrary, I'll leave it this way...
|
||||
else {
|
||||
int numToReclaim = cache.size() / 2;
|
||||
Enumeration keys = cache.keys();
|
||||
Enumeration elements = cache.elements();
|
||||
for (int i = numToReclaim; i > 0; i--) {
|
||||
Object key = keys.nextElement();
|
||||
Object element = elements.nextElement();
|
||||
|
||||
push(element);
|
||||
cache.remove(key);
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
final void setCaches(RepositoryIdCache_1_3 cache) {
|
||||
this.cache = cache;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public class RepositoryIdCache_1_3 extends Hashtable {
|
||||
|
||||
private RepositoryIdPool_1_3 pool = new RepositoryIdPool_1_3();
|
||||
|
||||
public RepositoryIdCache_1_3() {
|
||||
pool.setCaches(this);
|
||||
}
|
||||
|
||||
public final synchronized RepositoryId_1_3 getId(String key) {
|
||||
RepositoryId_1_3 repId = (RepositoryId_1_3)super.get(key);
|
||||
|
||||
if (repId != null)
|
||||
return repId;
|
||||
else {
|
||||
//repId = pool.popId().init(key);
|
||||
repId = new RepositoryId_1_3(key);
|
||||
put(key, repId);
|
||||
return repId;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -1,102 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001, 2002, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.corba.se.impl.orbutil;
|
||||
|
||||
import java.util.Stack;
|
||||
import java.util.Hashtable;
|
||||
import java.util.EmptyStackException;
|
||||
import java.util.Enumeration;
|
||||
|
||||
// Really limited pool - in this case just creating several at a time...
|
||||
class RepositoryIdPool_1_3_1 extends Stack {
|
||||
|
||||
private static int MAX_CACHE_SIZE = 4;
|
||||
private RepositoryIdCache_1_3_1 cache;
|
||||
|
||||
public final synchronized RepositoryId_1_3_1 popId() {
|
||||
|
||||
try {
|
||||
return (RepositoryId_1_3_1)super.pop();
|
||||
}
|
||||
catch(EmptyStackException e) {
|
||||
increasePool(5);
|
||||
return (RepositoryId_1_3_1)super.pop();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Pool management
|
||||
final void increasePool(int size) {
|
||||
//if (cache.size() <= MAX_CACHE_SIZE)
|
||||
for (int i = size; i > 0; i--)
|
||||
push(new RepositoryId_1_3_1());
|
||||
/*
|
||||
// _REVISIT_ This will not work w/out either thread tracing or weak references. I am
|
||||
// betting that thread tracing almost completely negates benefit of reuse. Until either
|
||||
// 1.2 only inclusion or proof to the contrary, I'll leave it this way...
|
||||
else {
|
||||
int numToReclaim = cache.size() / 2;
|
||||
Enumeration keys = cache.keys();
|
||||
Enumeration elements = cache.elements();
|
||||
for (int i = numToReclaim; i > 0; i--) {
|
||||
Object key = keys.nextElement();
|
||||
Object element = elements.nextElement();
|
||||
|
||||
push(element);
|
||||
cache.remove(key);
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
final void setCaches(RepositoryIdCache_1_3_1 cache) {
|
||||
this.cache = cache;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public class RepositoryIdCache_1_3_1 extends Hashtable {
|
||||
|
||||
private RepositoryIdPool_1_3_1 pool = new RepositoryIdPool_1_3_1();
|
||||
|
||||
public RepositoryIdCache_1_3_1() {
|
||||
pool.setCaches(this);
|
||||
}
|
||||
|
||||
public final synchronized RepositoryId_1_3_1 getId(String key) {
|
||||
RepositoryId_1_3_1 repId = (RepositoryId_1_3_1)super.get(key);
|
||||
|
||||
if (repId != null)
|
||||
return repId;
|
||||
else {
|
||||
//repId = pool.popId().init(key);
|
||||
repId = new RepositoryId_1_3_1(key);
|
||||
put(key, repId);
|
||||
return repId;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2003, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -30,12 +30,6 @@ import com.sun.corba.se.spi.orb.ORB;
|
||||
|
||||
public abstract class RepositoryIdFactory
|
||||
{
|
||||
private static final RepIdDelegator_1_3 legacyDelegator
|
||||
= new RepIdDelegator_1_3();
|
||||
|
||||
private static final RepIdDelegator_1_3_1 ladybirdDelegator
|
||||
= new RepIdDelegator_1_3_1();
|
||||
|
||||
private static final RepIdDelegator currentDelegator
|
||||
= new RepIdDelegator();
|
||||
|
||||
@ -47,29 +41,6 @@ public abstract class RepositoryIdFactory
|
||||
return currentDelegator;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks the version of the ORB and returns the appropriate
|
||||
* RepositoryIdStrings instance.
|
||||
*/
|
||||
public static RepositoryIdStrings getRepIdStringsFactory(ORB orb)
|
||||
{
|
||||
if (orb != null) {
|
||||
switch (orb.getORBVersion().getORBType()) {
|
||||
case ORBVersion.NEWER:
|
||||
case ORBVersion.FOREIGN:
|
||||
case ORBVersion.JDK1_3_1_01:
|
||||
return currentDelegator;
|
||||
case ORBVersion.OLD:
|
||||
return legacyDelegator;
|
||||
case ORBVersion.NEW:
|
||||
return ladybirdDelegator;
|
||||
default:
|
||||
return currentDelegator;
|
||||
}
|
||||
} else
|
||||
return currentDelegator;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the latest version RepositoryIdUtility instance
|
||||
*/
|
||||
@ -78,26 +49,4 @@ public abstract class RepositoryIdFactory
|
||||
return currentDelegator;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks the version of the ORB and returns the appropriate
|
||||
* RepositoryIdUtility instance.
|
||||
*/
|
||||
public static RepositoryIdUtility getRepIdUtility(ORB orb)
|
||||
{
|
||||
if (orb != null) {
|
||||
switch (orb.getORBVersion().getORBType()) {
|
||||
case ORBVersion.NEWER:
|
||||
case ORBVersion.FOREIGN:
|
||||
case ORBVersion.JDK1_3_1_01:
|
||||
return currentDelegator;
|
||||
case ORBVersion.OLD:
|
||||
return legacyDelegator;
|
||||
case ORBVersion.NEW:
|
||||
return ladybirdDelegator;
|
||||
default:
|
||||
return currentDelegator;
|
||||
}
|
||||
} else
|
||||
return currentDelegator;
|
||||
}
|
||||
}
|
||||
|
@ -1,990 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
/*
|
||||
* Licensed Materials - Property of IBM
|
||||
* RMI-IIOP v1.0
|
||||
* Copyright IBM Corp. 1998 1999 All Rights Reserved
|
||||
*
|
||||
*/
|
||||
|
||||
package com.sun.corba.se.impl.orbutil;
|
||||
|
||||
import java.util.StringTokenizer;
|
||||
import java.util.Hashtable;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
// Imports for using codebase URL to load class
|
||||
import java.net.MalformedURLException;
|
||||
import org.omg.CORBA.portable.ValueBase;
|
||||
import org.omg.CORBA.portable.IDLEntity;
|
||||
|
||||
import com.sun.corba.se.impl.util.JDKBridge;
|
||||
import com.sun.corba.se.impl.util.Utility;
|
||||
import com.sun.corba.se.impl.util.PackagePrefixChecker;
|
||||
import com.sun.corba.se.impl.util.IdentityHashtable;
|
||||
import com.sun.corba.se.impl.io.ObjectStreamClass;
|
||||
|
||||
import javax.rmi.CORBA.Util;
|
||||
|
||||
// keeping the original RepositoryId class that was shipped in
|
||||
// JDK 1.3. It has interoperability bugs
|
||||
|
||||
public class RepositoryId_1_3 {
|
||||
|
||||
// Legal IDL Identifier characters (1 = legal). Note
|
||||
// that '.' (2E) is marked as legal even though it is
|
||||
// not legal in IDL. This allows us to treat a fully
|
||||
// qualified Java name with '.' package separators
|
||||
// uniformly, and is safe because that is the only
|
||||
// legal use of '.' in a Java name.
|
||||
|
||||
public static final RepositoryIdCache_1_3 cache = new RepositoryIdCache_1_3();
|
||||
private static final byte[] IDL_IDENTIFIER_CHARS = {
|
||||
|
||||
// 0 1 2 3 4 5 6 7 8 9 a b c d e f
|
||||
0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, // 00-0f
|
||||
0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, // 10-1f
|
||||
0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,1,0, // 20-2f
|
||||
1,1,1,1, 1,1,1,1, 1,1,0,0, 0,0,0,0, // 30-3f
|
||||
0,1,1,1, 1,1,1,1, 1,1,1,1, 1,1,1,1, // 40-4f
|
||||
1,1,1,1, 1,1,1,1, 1,1,1,0, 0,0,0,1, // 50-5f
|
||||
0,1,1,1, 1,1,1,1, 1,1,1,1, 1,1,1,1, // 60-6f
|
||||
1,1,1,1, 1,1,1,1, 1,1,1,0, 0,0,0,0, // 70-7f
|
||||
0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, // 80-8f
|
||||
0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, // 90-9f
|
||||
0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, // a0-af
|
||||
0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, // b0-bf
|
||||
1,1,1,1, 1,1,1,1, 1,1,1,1, 1,1,1,1, // c0-cf
|
||||
0,1,1,1, 1,1,1,0, 1,1,1,1, 1,0,0,1, // d0-df
|
||||
1,1,1,1, 1,1,1,1, 1,1,1,1, 1,1,1,1, // e0-ef
|
||||
0,1,1,1, 1,1,1,0, 1,1,1,1, 1,0,0,1, // f0-ff
|
||||
};
|
||||
|
||||
private static String defaultServerURL = null;
|
||||
private static boolean useCodebaseOnly = false;
|
||||
|
||||
static {
|
||||
if (defaultServerURL == null)
|
||||
defaultServerURL = (String)JDKBridge.getLocalCodebase();
|
||||
useCodebaseOnly = JDKBridge.useCodebaseOnly();
|
||||
|
||||
}
|
||||
|
||||
private static IdentityHashtable classToRepStr = new IdentityHashtable();
|
||||
private static IdentityHashtable classIDLToRepStr = new IdentityHashtable();
|
||||
private static IdentityHashtable classSeqToRepStr = new IdentityHashtable();
|
||||
|
||||
private static IdentityHashtable repStrToByteArray = new IdentityHashtable();
|
||||
private static Hashtable repStrToClass = new Hashtable();
|
||||
|
||||
private String repId = null;
|
||||
private boolean isSupportedFormat = true;
|
||||
private String typeString = null;
|
||||
private String versionString = null;
|
||||
private boolean isSequence = false;
|
||||
private boolean isRMIValueType = false;
|
||||
private boolean isIDLType = false;
|
||||
private String completeClassName = null;
|
||||
private String unqualifiedName = null;
|
||||
private String definedInId = null;
|
||||
private Class clazz = null;
|
||||
private String suid = null, actualSuid = null;
|
||||
private long suidLong = ObjectStreamClass.kDefaultUID, actualSuidLong = ObjectStreamClass.kDefaultUID;
|
||||
|
||||
// Repository ID fragments
|
||||
private static final String kValuePrefix = "RMI:";
|
||||
private static final String kIDLPrefix = "IDL:";
|
||||
private static final String kIDLNamePrefix = "omg.org/";
|
||||
private static final String kIDLClassnamePrefix = "org.omg.";
|
||||
private static final String kSequencePrefix = "[";
|
||||
private static final String kCORBAPrefix = "CORBA/";
|
||||
private static final String kArrayPrefix = kValuePrefix + kSequencePrefix + kCORBAPrefix;
|
||||
private static final int kValuePrefixLength = kValuePrefix.length();
|
||||
private static final int kIDLPrefixLength = kIDLPrefix.length();
|
||||
private static final int kSequencePrefixLength = kSequencePrefix.length();
|
||||
private static final String kInterfaceHashCode = ":0000000000000000";
|
||||
private static final String kInterfaceOnlyHashStr = "0000000000000000";
|
||||
private static final String kExternalizableHashStr = "0000000000000001";
|
||||
|
||||
// Value tag utility methods and constants
|
||||
public static final int kInitialValueTag= 0x7fffff00;
|
||||
public static final int kNoTypeInfo = 0;
|
||||
public static final int kSingleRepTypeInfo = 0x02;
|
||||
public static final int kPartialListTypeInfo = 0x06;
|
||||
public static final int kChunkedMask = 0x08;
|
||||
|
||||
// Public, well known repository IDs
|
||||
|
||||
// _REVISIT_ : A table structure with a good search routine for all of this
|
||||
// would be more efficient and easier to maintain...
|
||||
|
||||
// String
|
||||
public static final String kWStringValueVersion = "1.0";
|
||||
public static final String kWStringValueHash = ":"+kWStringValueVersion;
|
||||
public static final String kWStringStubValue = "WStringValue";
|
||||
public static final String kWStringTypeStr = "omg.org/CORBA/"+kWStringStubValue;
|
||||
public static final String kWStringValueRepID = kIDLPrefix + kWStringTypeStr + kWStringValueHash;
|
||||
|
||||
// Any
|
||||
public static final String kAnyRepID = kIDLPrefix + "omg.org/CORBA/Any";
|
||||
|
||||
// Class
|
||||
public static final String kClassDescValueHash = ":" + Long.toHexString(
|
||||
ObjectStreamClass.getSerialVersionUID(javax.rmi.CORBA.ClassDesc.class));
|
||||
public static final String kClassDescStubValue = "ClassDesc";
|
||||
public static final String kClassDescTypeStr = "javax.rmi.CORBA."+kClassDescStubValue;
|
||||
public static final String kClassDescValueRepID = kValuePrefix + kClassDescTypeStr + kClassDescValueHash;
|
||||
|
||||
// Object
|
||||
public static final String kObjectValueHash = ":1.0";
|
||||
public static final String kObjectStubValue = "Object";
|
||||
|
||||
// Sequence
|
||||
public static final String kSequenceValueHash = ":1.0";
|
||||
public static final String kPrimitiveSequenceValueHash = ":0000000000000000";
|
||||
|
||||
// Serializable
|
||||
public static final String kSerializableValueHash = ":1.0";
|
||||
public static final String kSerializableStubValue = "Serializable";
|
||||
|
||||
// Externalizable
|
||||
public static final String kExternalizableValueHash = ":1.0";
|
||||
public static final String kExternalizableStubValue = "Externalizable";
|
||||
|
||||
// Remote (The empty string is used for java.rmi.Remote)
|
||||
public static final String kRemoteValueHash = "";
|
||||
public static final String kRemoteStubValue = "";
|
||||
public static final String kRemoteTypeStr = "";
|
||||
public static final String kRemoteValueRepID = "";
|
||||
|
||||
private static final Hashtable kSpecialArrayTypeStrings = new Hashtable();
|
||||
|
||||
static {
|
||||
kSpecialArrayTypeStrings.put("CORBA.WStringValue", new StringBuffer(java.lang.String.class.getName()));
|
||||
kSpecialArrayTypeStrings.put("javax.rmi.CORBA.ClassDesc", new StringBuffer(java.lang.Class.class.getName()));
|
||||
kSpecialArrayTypeStrings.put("CORBA.Object", new StringBuffer(java.rmi.Remote.class.getName()));
|
||||
|
||||
}
|
||||
|
||||
private static final Hashtable kSpecialCasesRepIDs = new Hashtable();
|
||||
|
||||
static {
|
||||
kSpecialCasesRepIDs.put(java.lang.String.class, kWStringValueRepID);
|
||||
kSpecialCasesRepIDs.put(java.lang.Class.class, kClassDescValueRepID);
|
||||
kSpecialCasesRepIDs.put(java.rmi.Remote.class, kRemoteValueRepID);
|
||||
}
|
||||
|
||||
private static final Hashtable kSpecialCasesStubValues = new Hashtable();
|
||||
|
||||
static {
|
||||
kSpecialCasesStubValues.put(java.lang.String.class, kWStringStubValue);
|
||||
kSpecialCasesStubValues.put(java.lang.Class.class, kClassDescStubValue);
|
||||
kSpecialCasesStubValues.put(java.lang.Object.class, kObjectStubValue);
|
||||
kSpecialCasesStubValues.put(java.io.Serializable.class, kSerializableStubValue);
|
||||
kSpecialCasesStubValues.put(java.io.Externalizable.class, kExternalizableStubValue);
|
||||
kSpecialCasesStubValues.put(java.rmi.Remote.class, kRemoteStubValue);
|
||||
}
|
||||
|
||||
|
||||
private static final Hashtable kSpecialCasesVersions = new Hashtable();
|
||||
|
||||
static {
|
||||
kSpecialCasesVersions.put(java.lang.String.class, kWStringValueHash);
|
||||
kSpecialCasesVersions.put(java.lang.Class.class, kClassDescValueHash);
|
||||
kSpecialCasesVersions.put(java.lang.Object.class, kObjectValueHash);
|
||||
kSpecialCasesVersions.put(java.io.Serializable.class, kSerializableValueHash);
|
||||
kSpecialCasesVersions.put(java.io.Externalizable.class, kExternalizableValueHash);
|
||||
kSpecialCasesVersions.put(java.rmi.Remote.class, kRemoteValueHash);
|
||||
}
|
||||
|
||||
private static final Hashtable kSpecialCasesClasses = new Hashtable();
|
||||
|
||||
static {
|
||||
kSpecialCasesClasses.put(kWStringTypeStr, java.lang.String.class);
|
||||
kSpecialCasesClasses.put(kClassDescTypeStr, java.lang.Class.class);
|
||||
kSpecialCasesClasses.put(kRemoteTypeStr, java.rmi.Remote.class);
|
||||
|
||||
kSpecialCasesClasses.put("org.omg.CORBA.WStringValue", java.lang.String.class);
|
||||
kSpecialCasesClasses.put("javax.rmi.CORBA.ClassDesc", java.lang.Class.class);
|
||||
//kSpecialCasesClasses.put(kRemoteTypeStr, java.rmi.Remote.class);
|
||||
}
|
||||
|
||||
private static final Hashtable kSpecialCasesArrayPrefix = new Hashtable();
|
||||
|
||||
static {
|
||||
kSpecialCasesArrayPrefix.put(java.lang.String.class, kValuePrefix + kSequencePrefix + kCORBAPrefix);
|
||||
kSpecialCasesArrayPrefix.put(java.lang.Class.class, kValuePrefix + kSequencePrefix + "javax/rmi/CORBA/");
|
||||
kSpecialCasesArrayPrefix.put(java.lang.Object.class, kValuePrefix + kSequencePrefix + "java/lang/");
|
||||
kSpecialCasesArrayPrefix.put(java.io.Serializable.class, kValuePrefix + kSequencePrefix + "java/io/");
|
||||
kSpecialCasesArrayPrefix.put(java.io.Externalizable.class, kValuePrefix + kSequencePrefix + "java/io/");
|
||||
kSpecialCasesArrayPrefix.put(java.rmi.Remote.class, kValuePrefix + kSequencePrefix + kCORBAPrefix);
|
||||
}
|
||||
|
||||
private static final Hashtable kSpecialPrimitives = new Hashtable();
|
||||
|
||||
static {
|
||||
kSpecialPrimitives.put("int","long");
|
||||
kSpecialPrimitives.put("long","longlong");
|
||||
kSpecialPrimitives.put("byte","octet");
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to convert ascii to hex.
|
||||
*/
|
||||
private static final byte ASCII_HEX[] = {
|
||||
(byte)'0',
|
||||
(byte)'1',
|
||||
(byte)'2',
|
||||
(byte)'3',
|
||||
(byte)'4',
|
||||
(byte)'5',
|
||||
(byte)'6',
|
||||
(byte)'7',
|
||||
(byte)'8',
|
||||
(byte)'9',
|
||||
(byte)'A',
|
||||
(byte)'B',
|
||||
(byte)'C',
|
||||
(byte)'D',
|
||||
(byte)'E',
|
||||
(byte)'F',
|
||||
};
|
||||
|
||||
|
||||
// Interface Rep ID Strings
|
||||
public static final String kjava_rmi_Remote = createForAnyType(java.rmi.Remote.class);
|
||||
public static final String korg_omg_CORBA_Object = createForAnyType(org.omg.CORBA.Object.class);
|
||||
|
||||
// Dummy arguments for getIdFromHelper method
|
||||
public static final Class kNoParamTypes[] ={};
|
||||
public static final Object kNoArgs[] = {};
|
||||
|
||||
|
||||
RepositoryId_1_3(){}
|
||||
|
||||
RepositoryId_1_3(String aRepId){
|
||||
init(aRepId);
|
||||
}
|
||||
|
||||
RepositoryId_1_3 init(String aRepId){
|
||||
|
||||
this.repId = aRepId;
|
||||
|
||||
// Special case for remote
|
||||
if (aRepId.length() == 0) {
|
||||
clazz = java.rmi.Remote.class;
|
||||
typeString = "";
|
||||
isRMIValueType = true;
|
||||
suid = kInterfaceOnlyHashStr;
|
||||
return this;
|
||||
}
|
||||
else if (aRepId.equals(kWStringValueRepID)) {
|
||||
clazz = java.lang.String.class;
|
||||
typeString = kWStringTypeStr;
|
||||
isIDLType = true;
|
||||
versionString = kWStringValueVersion;
|
||||
return this;
|
||||
}
|
||||
else {
|
||||
|
||||
String repId = convertFromISOLatin1(aRepId);
|
||||
|
||||
versionString = repId.substring(repId.indexOf(':', repId.indexOf(':')+1));
|
||||
if (repId.startsWith(kIDLPrefix)) {
|
||||
typeString =
|
||||
repId.substring(kIDLPrefixLength, repId.indexOf(':', kIDLPrefixLength));
|
||||
isIDLType = true;
|
||||
if (typeString.startsWith(kIDLNamePrefix))
|
||||
completeClassName = kIDLClassnamePrefix +
|
||||
typeString.substring(kIDLNamePrefix.length()).replace('/','.');
|
||||
else completeClassName = typeString.replace('/','.');
|
||||
|
||||
}
|
||||
else if (repId.startsWith(kValuePrefix)) {
|
||||
typeString =
|
||||
repId.substring(kValuePrefixLength, repId.indexOf(':', kValuePrefixLength));
|
||||
isRMIValueType = true;
|
||||
|
||||
if (versionString.indexOf('.') == -1) {
|
||||
actualSuid = versionString.substring(1);
|
||||
suid = actualSuid; // default if not explicitly specified
|
||||
|
||||
if (actualSuid.indexOf(':') != -1){
|
||||
// we have a declared hash also
|
||||
int pos = actualSuid.indexOf(':')+1;
|
||||
// actualSuid = suid.substring(pos);
|
||||
// suid = suid.substring(0, pos-1);
|
||||
suid = actualSuid.substring(pos);
|
||||
actualSuid = actualSuid.substring(0, pos-1);
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
// _REVISIT_ : Special case version failure ?
|
||||
}
|
||||
}
|
||||
else isSupportedFormat = false;
|
||||
|
||||
if (typeString.startsWith(kSequencePrefix)) {
|
||||
isSequence = true;
|
||||
}
|
||||
|
||||
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
public final String getUnqualifiedName() {
|
||||
if (unqualifiedName == null){
|
||||
String className = getClassName();
|
||||
int index = (className != null) ? className.lastIndexOf('.') : -1;
|
||||
if (index == -1){
|
||||
unqualifiedName = className;
|
||||
definedInId = "IDL::1.0";
|
||||
}
|
||||
else {
|
||||
unqualifiedName = className.substring(index);
|
||||
definedInId = "IDL:" + className.substring(0, index).replace('.','/') + ":1.0";
|
||||
}
|
||||
}
|
||||
|
||||
return unqualifiedName;
|
||||
}
|
||||
|
||||
public final String getDefinedInId() {
|
||||
if (definedInId == null){
|
||||
getUnqualifiedName();
|
||||
}
|
||||
|
||||
return definedInId;
|
||||
}
|
||||
|
||||
public final String getTypeString() {
|
||||
return typeString;
|
||||
}
|
||||
|
||||
public final String getVersionString() {
|
||||
return versionString;
|
||||
}
|
||||
|
||||
public final String getSerialVersionUID() {
|
||||
return suid;
|
||||
}
|
||||
|
||||
public final String getActualSerialVersionUID() {
|
||||
return actualSuid;
|
||||
}
|
||||
public final long getSerialVersionUIDAsLong() {
|
||||
return suidLong;
|
||||
}
|
||||
|
||||
public final long getActualSerialVersionUIDAsLong() {
|
||||
return actualSuidLong;
|
||||
}
|
||||
|
||||
public final boolean isRMIValueType() {
|
||||
return isRMIValueType;
|
||||
}
|
||||
|
||||
public final boolean isIDLType() {
|
||||
return isIDLType;
|
||||
}
|
||||
|
||||
public final String getRepositoryId() {
|
||||
return repId;
|
||||
}
|
||||
|
||||
public static byte[] getByteArray(String repStr) {
|
||||
synchronized (repStrToByteArray){
|
||||
return (byte[]) repStrToByteArray.get(repStr);
|
||||
}
|
||||
}
|
||||
|
||||
public static void setByteArray(String repStr, byte[] repStrBytes) {
|
||||
synchronized (repStrToByteArray){
|
||||
repStrToByteArray.put(repStr, repStrBytes);
|
||||
}
|
||||
}
|
||||
|
||||
public final boolean isSequence() {
|
||||
return isSequence;
|
||||
}
|
||||
|
||||
public final boolean isSupportedFormat() {
|
||||
return isSupportedFormat;
|
||||
}
|
||||
|
||||
|
||||
// This method will return the classname from the typestring OR if the classname turns out to be
|
||||
// a special class "pseudo" name, then the matching real classname is returned.
|
||||
public final String getClassName() {
|
||||
|
||||
if (isRMIValueType)
|
||||
return typeString;
|
||||
else if (isIDLType)
|
||||
return completeClassName;
|
||||
else return null;
|
||||
|
||||
}
|
||||
|
||||
// This method calls getClazzFromType() and falls back to the repStrToClass
|
||||
// cache if no class was found. It's used where any class matching the
|
||||
// given repid is an acceptable result.
|
||||
public final Class getAnyClassFromType() throws ClassNotFoundException {
|
||||
try {
|
||||
return getClassFromType();
|
||||
} catch (ClassNotFoundException cnfe) {
|
||||
Class clz = (Class)repStrToClass.get(repId);
|
||||
if (clz != null)
|
||||
return clz;
|
||||
else
|
||||
throw cnfe;
|
||||
}
|
||||
}
|
||||
|
||||
public final Class getClassFromType()
|
||||
throws ClassNotFoundException {
|
||||
if (clazz != null)
|
||||
return clazz;
|
||||
|
||||
Class specialCase = (Class)kSpecialCasesClasses.get(getClassName());
|
||||
|
||||
if (specialCase != null){
|
||||
clazz = specialCase;
|
||||
return specialCase;
|
||||
}
|
||||
else
|
||||
{
|
||||
try{
|
||||
return Util.loadClass(getClassName(), null, null);
|
||||
}
|
||||
catch(ClassNotFoundException cnfe){
|
||||
if (defaultServerURL != null) {
|
||||
try{
|
||||
return getClassFromType(defaultServerURL);
|
||||
}
|
||||
catch(MalformedURLException mue){
|
||||
throw cnfe;
|
||||
}
|
||||
}
|
||||
else throw cnfe;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public final Class getClassFromType(Class expectedType, String codebase)
|
||||
throws ClassNotFoundException {
|
||||
if (clazz != null)
|
||||
return clazz;
|
||||
|
||||
Class specialCase = (Class)kSpecialCasesClasses.get(getClassName());
|
||||
|
||||
if (specialCase != null){
|
||||
clazz = specialCase;
|
||||
return specialCase;
|
||||
} else {
|
||||
ClassLoader expectedTypeClassLoader = (expectedType == null ? null : expectedType.getClassLoader());
|
||||
return loadClassOfType(getClassName(),
|
||||
codebase,
|
||||
expectedTypeClassLoader,
|
||||
expectedType,
|
||||
expectedTypeClassLoader);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public final Class getClassFromType(String url)
|
||||
throws ClassNotFoundException, MalformedURLException {
|
||||
return Util.loadClass(getClassName(), url, null);
|
||||
}
|
||||
|
||||
public final String toString() {
|
||||
return repId;
|
||||
}
|
||||
|
||||
private static String createHashString(java.io.Serializable ser) {
|
||||
|
||||
return createHashString(ser.getClass());
|
||||
}
|
||||
|
||||
private static String createHashString(java.lang.Class clazz) {
|
||||
|
||||
if (clazz.isInterface() || !java.io.Serializable.class.isAssignableFrom(clazz))
|
||||
return kInterfaceHashCode;
|
||||
|
||||
|
||||
long actualLong = ObjectStreamClassUtil_1_3.computeStructuralUID(false, clazz);
|
||||
String hash = null;
|
||||
if (actualLong == 0)
|
||||
hash = kInterfaceOnlyHashStr;
|
||||
else if (actualLong == 1)
|
||||
hash = kExternalizableHashStr;
|
||||
else
|
||||
hash = Long.toHexString(actualLong).toUpperCase();
|
||||
while(hash.length() < 16){
|
||||
hash = "0" + hash;
|
||||
}
|
||||
|
||||
long declaredLong = ObjectStreamClassUtil_1_3.computeSerialVersionUID(clazz);
|
||||
String declared = null;
|
||||
if (declaredLong == 0)
|
||||
declared = kInterfaceOnlyHashStr;
|
||||
else if (declaredLong == 1)
|
||||
declared = kExternalizableHashStr;
|
||||
else
|
||||
declared = Long.toHexString(declaredLong).toUpperCase();
|
||||
while (declared.length() < 16){
|
||||
declared = "0" + declared;
|
||||
}
|
||||
hash = hash + ":" + declared;
|
||||
|
||||
return ":" + hash;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a repository ID for a sequence. This is for expert users only as
|
||||
* this method assumes the object passed is an array. If passed an object
|
||||
* that is not an array, it will produce a rep id for a sequence of zero
|
||||
* length. This would be an error.
|
||||
* @param ser The Java object to create a repository ID for
|
||||
**/
|
||||
public static String createSequenceRepID(java.lang.Object ser){
|
||||
return createSequenceRepID(ser.getClass());
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a repository ID for a sequence. This is for expert users only as
|
||||
* this method assumes the object passed is an array. If passed an object
|
||||
* that is not an array, it will produce a malformed rep id.
|
||||
* @param clazz The Java class to create a repository ID for
|
||||
**/
|
||||
public static String createSequenceRepID(java.lang.Class clazz){
|
||||
synchronized (classSeqToRepStr){
|
||||
|
||||
String repid = (String)classSeqToRepStr.get(clazz);
|
||||
if (repid != null)
|
||||
return repid;
|
||||
|
||||
Class originalClazz = clazz;
|
||||
|
||||
Class type = null;
|
||||
int numOfDims = 0;
|
||||
|
||||
while ((type = clazz.getComponentType()) != null) {
|
||||
numOfDims++;
|
||||
clazz = type;
|
||||
}
|
||||
|
||||
if (clazz.isPrimitive())
|
||||
repid = kValuePrefix + originalClazz.getName() + kPrimitiveSequenceValueHash;
|
||||
else {
|
||||
StringBuffer buf = new StringBuffer();
|
||||
buf.append(kValuePrefix);
|
||||
while(numOfDims-- > 0) {
|
||||
buf.append("[");
|
||||
}
|
||||
buf.append("L");
|
||||
buf.append(convertToISOLatin1(clazz.getName()));
|
||||
buf.append(";");
|
||||
buf.append(createHashString(clazz));
|
||||
repid = buf.toString();
|
||||
}
|
||||
classSeqToRepStr.put(originalClazz,repid);
|
||||
return repid;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static String createForSpecialCase(java.lang.Class clazz){
|
||||
if (clazz.isArray()){
|
||||
return createSequenceRepID(clazz);
|
||||
}
|
||||
else {
|
||||
return (String)kSpecialCasesRepIDs.get(clazz);
|
||||
}
|
||||
}
|
||||
|
||||
public static String createForSpecialCase(java.io.Serializable ser){
|
||||
Class clazz = ser.getClass();
|
||||
if (clazz.isArray()){
|
||||
return createSequenceRepID(ser);
|
||||
}
|
||||
else
|
||||
return createForSpecialCase(clazz);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a repository ID for a normal Java Type.
|
||||
* @param ser The Java object to create a repository ID for
|
||||
* @exception com.sun.corba.se.impl.io.TypeMismatchException if ser implements the
|
||||
* org.omg.CORBA.portable.IDLEntity interface which indicates it is an IDL Value type.
|
||||
**/
|
||||
public static String createForJavaType(java.io.Serializable ser)
|
||||
throws com.sun.corba.se.impl.io.TypeMismatchException
|
||||
{
|
||||
synchronized (classToRepStr) {
|
||||
String repid = createForSpecialCase(ser);
|
||||
if (repid != null)
|
||||
return repid;
|
||||
Class clazz = ser.getClass();
|
||||
repid = (String)classToRepStr.get(clazz);
|
||||
|
||||
if (repid != null)
|
||||
return repid;
|
||||
|
||||
repid = kValuePrefix + convertToISOLatin1(clazz.getName()) +
|
||||
createHashString(clazz);
|
||||
|
||||
classToRepStr.put(clazz, repid);
|
||||
repStrToClass.put(repid, clazz);
|
||||
return repid;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a repository ID for a normal Java Type.
|
||||
* @param clz The Java class to create a repository ID for
|
||||
* @exception com.sun.corba.se.impl.io.TypeMismatchException if ser implements the
|
||||
* org.omg.CORBA.portable.IDLEntity interface which indicates it is an IDL Value type.
|
||||
**/
|
||||
public static String createForJavaType(Class clz)
|
||||
throws com.sun.corba.se.impl.io.TypeMismatchException
|
||||
{
|
||||
synchronized (classToRepStr){
|
||||
String repid = createForSpecialCase(clz);
|
||||
if (repid != null)
|
||||
return repid;
|
||||
|
||||
repid = (String)classToRepStr.get(clz);
|
||||
if (repid != null)
|
||||
return repid;
|
||||
|
||||
repid = kValuePrefix + convertToISOLatin1(clz.getName()) +
|
||||
createHashString(clz);
|
||||
|
||||
classToRepStr.put(clz, repid);
|
||||
repStrToClass.put(repid, clz);
|
||||
return repid;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a repository ID for an IDL Java Type.
|
||||
* @param ser The IDL Value object to create a repository ID for
|
||||
* @param major The major version number
|
||||
* @param minor The minor version number
|
||||
* @exception com.sun.corba.se.impl.io.TypeMismatchException if ser does not implement the
|
||||
* org.omg.CORBA.portable.IDLEntity interface which indicates it is an IDL Value type.
|
||||
**/
|
||||
public static String createForIDLType(Class ser, int major, int minor)
|
||||
throws com.sun.corba.se.impl.io.TypeMismatchException
|
||||
{
|
||||
synchronized (classIDLToRepStr){
|
||||
String repid = (String)classIDLToRepStr.get(ser);
|
||||
if (repid != null)
|
||||
return repid;
|
||||
|
||||
repid = kIDLPrefix + convertToISOLatin1(ser.getName()).replace('.','/') +
|
||||
":" + major + "." + minor;
|
||||
classIDLToRepStr.put(ser, repid);
|
||||
return repid;
|
||||
}
|
||||
}
|
||||
|
||||
private static String getIdFromHelper(Class clazz){
|
||||
try {
|
||||
Class helperClazz = Utility.loadClassForClass(clazz.getName()+"Helper", null,
|
||||
clazz.getClassLoader(), clazz, clazz.getClassLoader());
|
||||
Method idMethod = helperClazz.getDeclaredMethod("id", kNoParamTypes);
|
||||
return (String)idMethod.invoke(null, kNoArgs);
|
||||
}
|
||||
catch(java.lang.ClassNotFoundException cnfe)
|
||||
{
|
||||
throw new org.omg.CORBA.MARSHAL(cnfe.toString());
|
||||
}
|
||||
catch(java.lang.NoSuchMethodException nsme)
|
||||
{
|
||||
throw new org.omg.CORBA.MARSHAL(nsme.toString());
|
||||
}
|
||||
catch(java.lang.reflect.InvocationTargetException ite)
|
||||
{
|
||||
throw new org.omg.CORBA.MARSHAL(ite.toString());
|
||||
}
|
||||
catch(java.lang.IllegalAccessException iae)
|
||||
{
|
||||
throw new org.omg.CORBA.MARSHAL(iae.toString());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Createa a repository ID for the type if it is either a java type
|
||||
* or an IDL type.
|
||||
* @param type The type to create rep. id for
|
||||
* @return The rep. id.
|
||||
**/
|
||||
public static String createForAnyType(Class type) {
|
||||
try{
|
||||
if (type.isArray())
|
||||
return createSequenceRepID(type);
|
||||
else if (IDLEntity.class.isAssignableFrom(type))
|
||||
{
|
||||
try{
|
||||
return getIdFromHelper(type);
|
||||
}
|
||||
catch(Throwable t) {
|
||||
return createForIDLType(type, 1, 0);
|
||||
}
|
||||
}
|
||||
else return createForJavaType(type);
|
||||
}
|
||||
catch(com.sun.corba.se.impl.io.TypeMismatchException e){
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static boolean isAbstractBase(Class clazz) {
|
||||
return (clazz.isInterface() &&
|
||||
IDLEntity.class.isAssignableFrom(clazz) &&
|
||||
(!ValueBase.class.isAssignableFrom(clazz)) &&
|
||||
(!org.omg.CORBA.Object.class.isAssignableFrom(clazz)));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert strings with illegal IDL identifier characters.
|
||||
* <p>
|
||||
* Section 5.5.7 of OBV spec.
|
||||
*/
|
||||
private static String convertToISOLatin1 (String name) {
|
||||
|
||||
int length = name.length();
|
||||
if (length == 0) {
|
||||
return name;
|
||||
}
|
||||
StringBuffer buffer = null;
|
||||
|
||||
for (int i = 0; i < length; i++) {
|
||||
|
||||
char c = name.charAt(i);
|
||||
|
||||
if (c > 255 || IDL_IDENTIFIER_CHARS[c] == 0) {
|
||||
|
||||
// We gotta convert. Have we already started?
|
||||
|
||||
if (buffer == null) {
|
||||
|
||||
// No, so get set up...
|
||||
|
||||
buffer = new StringBuffer(name.substring(0,i));
|
||||
}
|
||||
|
||||
// Convert the character into the IDL escape syntax...
|
||||
buffer.append(
|
||||
"\\U" +
|
||||
(char)ASCII_HEX[(c & 0xF000) >>> 12] +
|
||||
(char)ASCII_HEX[(c & 0x0F00) >>> 8] +
|
||||
(char)ASCII_HEX[(c & 0x00F0) >>> 4] +
|
||||
(char)ASCII_HEX[(c & 0x000F)]);
|
||||
|
||||
} else {
|
||||
if (buffer != null) {
|
||||
buffer.append(c);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (buffer != null) {
|
||||
name = buffer.toString();
|
||||
}
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert strings with ISO Latin 1 escape sequences back to original strings.
|
||||
* <p>
|
||||
* Section 5.5.7 of OBV spec.
|
||||
*/
|
||||
private static String convertFromISOLatin1 (String name) {
|
||||
|
||||
int index = -1;
|
||||
StringBuffer buf = new StringBuffer(name);
|
||||
|
||||
while ((index = buf.toString().indexOf("\\U")) != -1){
|
||||
String str = "0000" + buf.toString().substring(index+2, index+6);
|
||||
|
||||
// Convert Hexadecimal
|
||||
byte[] buffer = new byte[(str.length() - 4) / 2];
|
||||
for (int i=4, j=0; i < str.length(); i +=2, j++) {
|
||||
buffer[j] = (byte)((ORBUtility.hexOf(str.charAt(i)) << 4) & 0xF0);
|
||||
buffer[j] |= (byte)((ORBUtility.hexOf(str.charAt(i+1)) << 0) & 0x0F);
|
||||
}
|
||||
buf = new StringBuffer(delete(buf.toString(), index, index+6));
|
||||
buf.insert(index, (char)buffer[1]);
|
||||
}
|
||||
|
||||
return buf.toString();
|
||||
|
||||
|
||||
}
|
||||
|
||||
private static String delete(String str, int from, int to)
|
||||
{
|
||||
return str.substring(0, from) + str.substring(to, str.length());
|
||||
}
|
||||
|
||||
private static String replace(String target, String arg, String source)
|
||||
{
|
||||
int i = 0;
|
||||
i = target.indexOf(arg);
|
||||
|
||||
while(i != -1)
|
||||
{
|
||||
String left = target.substring(0, i);
|
||||
String right = target.substring(i+arg.length());
|
||||
target = new String(left+source+right);
|
||||
i = target.indexOf(arg);
|
||||
}
|
||||
return target;
|
||||
}
|
||||
|
||||
/*
|
||||
* Load a class and check that it is assignable to a given type.
|
||||
* @param className the class name.
|
||||
* @param remoteCodebase the codebase to use. May be null.
|
||||
* @param loader the class loader of last resort. May be null.
|
||||
* @param expectedType the expected type. May be null.
|
||||
* @return the loaded class.
|
||||
*/
|
||||
private Class loadClassOfType (String className,
|
||||
String remoteCodebase,
|
||||
ClassLoader loader,
|
||||
Class expectedType,
|
||||
ClassLoader expectedTypeClassLoader)
|
||||
throws ClassNotFoundException {
|
||||
|
||||
Class loadedClass = null;
|
||||
|
||||
try {
|
||||
//Sequence finding of the stubs according to spec
|
||||
try{
|
||||
//If-else is put here for speed up of J2EE.
|
||||
//According to the OMG spec, the if clause is not dead code.
|
||||
//It can occur if some compiler has allowed generation
|
||||
//into org.omg.stub hierarchy for non-offending
|
||||
//classes. This will encourage people to
|
||||
//produce non-offending class stubs in their own hierarchy.
|
||||
if(!PackagePrefixChecker
|
||||
.hasOffendingPrefix(PackagePrefixChecker
|
||||
.withoutPackagePrefix(className))){
|
||||
loadedClass = Util.loadClass
|
||||
(PackagePrefixChecker.withoutPackagePrefix(className),
|
||||
remoteCodebase,
|
||||
loader);
|
||||
} else {
|
||||
loadedClass = Util.loadClass
|
||||
(className,
|
||||
remoteCodebase,
|
||||
loader);
|
||||
}
|
||||
} catch (ClassNotFoundException cnfe) {
|
||||
loadedClass = Util.loadClass
|
||||
(className,
|
||||
remoteCodebase,
|
||||
loader);
|
||||
}
|
||||
if (expectedType == null)
|
||||
return loadedClass;
|
||||
} catch (ClassNotFoundException cnfe) {
|
||||
if (expectedType == null)
|
||||
throw cnfe;
|
||||
}
|
||||
|
||||
// If no class was not loaded, or if the loaded class is not of the
|
||||
// correct type, make a further attempt to load the correct class
|
||||
// using the classloader of the expected type.
|
||||
// _REVISIT_ Is this step necessary, or should the Util,loadClass
|
||||
// algorithm always produce a valid class if the setup is correct?
|
||||
// Does the OMG standard algorithm need to be changed to include
|
||||
// this step?
|
||||
if (loadedClass == null || !expectedType.isAssignableFrom(loadedClass)) {
|
||||
if (expectedType.getClassLoader() != expectedTypeClassLoader)
|
||||
throw new IllegalArgumentException("expectedTypeClassLoader not class loader of expectedType.");
|
||||
|
||||
if (expectedTypeClassLoader != null)
|
||||
loadedClass = expectedTypeClassLoader.loadClass(className);
|
||||
else
|
||||
loadedClass = ORBClassLoader.loadClass(className);
|
||||
}
|
||||
|
||||
return loadedClass;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks to see if the FullValueDescription should be retrieved.
|
||||
* @exception Throws IOException if suids do not match or if the repositoryID
|
||||
* is not an RMIValueType
|
||||
*/
|
||||
public static boolean useFullValueDescription(Class clazz, String repositoryID)
|
||||
throws IOException{
|
||||
|
||||
String clazzRepIDStr = createForAnyType(clazz);
|
||||
|
||||
if (clazzRepIDStr.equals(repositoryID))
|
||||
return false;
|
||||
|
||||
RepositoryId_1_3 targetRepid;
|
||||
RepositoryId_1_3 clazzRepid;
|
||||
|
||||
synchronized(cache) {
|
||||
// to avoid race condition where multiple threads could be
|
||||
// accessing this method, and their access to the cache may
|
||||
// be interleaved giving unexpected results
|
||||
|
||||
targetRepid = cache.getId(repositoryID);
|
||||
clazzRepid = cache.getId(clazzRepIDStr);
|
||||
}
|
||||
|
||||
if ((targetRepid.isRMIValueType()) && (clazzRepid.isRMIValueType())){
|
||||
if (!targetRepid.getSerialVersionUID().equals(clazzRepid.getSerialVersionUID())) {
|
||||
|
||||
String mssg = "Mismatched serialization UIDs : Source (Rep. ID" +
|
||||
clazzRepid + ") = " +
|
||||
clazzRepid.getSerialVersionUID() + " whereas Target (Rep. ID " + repositoryID +
|
||||
") = " + targetRepid.getSerialVersionUID();
|
||||
throw new IOException(mssg);
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
|
||||
throw new IOException("The repository ID is not of an RMI value type (Expected ID = " + clazzRepIDStr + "; Received ID = " + repositoryID +")");
|
||||
}
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -1,251 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2003, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
/*
|
||||
* Licensed Materials - Property of IBM
|
||||
* RMI-IIOP v1.0
|
||||
* Copyright IBM Corp. 1998 1999 All Rights Reserved
|
||||
*
|
||||
*/
|
||||
|
||||
package com.sun.corba.se.impl.orbutil;
|
||||
|
||||
import javax.rmi.CORBA.Util;
|
||||
import javax.rmi.PortableRemoteObject;
|
||||
|
||||
import java.util.Hashtable;
|
||||
import java.util.Stack;
|
||||
import java.io.IOException;
|
||||
import java.util.EmptyStackException;
|
||||
|
||||
import com.sun.corba.se.impl.util.Utility;
|
||||
import com.sun.corba.se.impl.io.IIOPInputStream;
|
||||
import com.sun.corba.se.impl.io.IIOPOutputStream;
|
||||
import com.sun.corba.se.impl.util.RepositoryId;
|
||||
import com.sun.corba.se.impl.util.Utility;
|
||||
|
||||
import org.omg.CORBA.TCKind;
|
||||
import org.omg.CORBA.MARSHAL;
|
||||
import org.omg.CORBA.CompletionStatus;
|
||||
import org.omg.CORBA.portable.IndirectionException;
|
||||
import com.sun.org.omg.SendingContext.CodeBase;
|
||||
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivilegedAction;
|
||||
|
||||
/**
|
||||
* This class overrides behavior of our current ValueHandlerImpl to
|
||||
* provide backwards compatibility with JDK 1.3.0.
|
||||
*/
|
||||
public class ValueHandlerImpl_1_3 extends com.sun.corba.se.impl.io.ValueHandlerImpl {
|
||||
|
||||
public ValueHandlerImpl_1_3(){
|
||||
super();
|
||||
}
|
||||
|
||||
public ValueHandlerImpl_1_3(boolean isInputStream) {
|
||||
super(isInputStream);
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes the value to the stream using java semantics.
|
||||
* @param out The stream to write the value to
|
||||
* @param value The value to be written to the stream
|
||||
**/
|
||||
public void writeValue(org.omg.CORBA.portable.OutputStream _out, java.io.Serializable value) {
|
||||
super.writeValue(_out, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads a value from the stream using java semantics.
|
||||
* @param in The stream to read the value from
|
||||
* @param clazz The type of the value to be read in
|
||||
* @param sender The sending context runtime
|
||||
**/
|
||||
public java.io.Serializable readValue(org.omg.CORBA.portable.InputStream _in,
|
||||
int offset,
|
||||
java.lang.Class clazz,
|
||||
String repositoryID,
|
||||
org.omg.SendingContext.RunTime _sender)
|
||||
{
|
||||
return super.readValue(_in, offset, clazz, repositoryID, _sender);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the repository ID for the given RMI value Class.
|
||||
* @param clz The class to return a repository ID for.
|
||||
* @return the repository ID of the Class.
|
||||
**/
|
||||
public java.lang.String getRMIRepositoryID(java.lang.Class clz) {
|
||||
return RepositoryId_1_3.createForJavaType(clz);
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates whether the given Class performs custom or
|
||||
* default marshaling.
|
||||
* @param clz The class to test for custom marshaling.
|
||||
* @return True if the class performs custom marshaling, false
|
||||
* if it does not.
|
||||
**/
|
||||
public boolean isCustomMarshaled(java.lang.Class clz) {
|
||||
return super.isCustomMarshaled(clz);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the CodeBase for this ValueHandler. This is used by
|
||||
* the ORB runtime. The server sends the service context containing
|
||||
* the IOR for this CodeBase on the first GIOP reply. The clients
|
||||
* do the same on the first GIOP request.
|
||||
* @return the SendingContext.CodeBase of this ValueHandler.
|
||||
**/
|
||||
public org.omg.SendingContext.RunTime getRunTimeCodeBase() {
|
||||
return super.getRunTimeCodeBase();
|
||||
}
|
||||
|
||||
/**
|
||||
* If the value contains a writeReplace method then the result
|
||||
* is returned. Otherwise, the value itself is returned.
|
||||
* @return the true value to marshal on the wire.
|
||||
**/
|
||||
public java.io.Serializable writeReplace(java.io.Serializable value) {
|
||||
return super.writeReplace(value);
|
||||
}
|
||||
|
||||
// methods supported for backward compatability so that the appropriate
|
||||
// Rep-id calculations take place based on the ORB version
|
||||
|
||||
/**
|
||||
* Returns a boolean of whether or not RepositoryId indicates
|
||||
* FullValueDescriptor.
|
||||
* used for backward compatability
|
||||
*/
|
||||
|
||||
public boolean useFullValueDescription(Class clazz, String repositoryID)
|
||||
throws IOException
|
||||
|
||||
{
|
||||
return RepositoryId_1_3.useFullValueDescription(clazz, repositoryID);
|
||||
}
|
||||
|
||||
public String getClassName(String id)
|
||||
{
|
||||
RepositoryId_1_3 repID = RepositoryId_1_3.cache.getId(id);
|
||||
return repID.getClassName();
|
||||
}
|
||||
|
||||
public Class getClassFromType(String id)
|
||||
throws ClassNotFoundException
|
||||
{
|
||||
RepositoryId_1_3 repId = RepositoryId_1_3.cache.getId(id);
|
||||
return repId.getClassFromType();
|
||||
}
|
||||
|
||||
public Class getAnyClassFromType(String id)
|
||||
throws ClassNotFoundException
|
||||
{
|
||||
RepositoryId_1_3 repId = RepositoryId_1_3.cache.getId(id);
|
||||
return repId.getAnyClassFromType();
|
||||
}
|
||||
|
||||
public String createForAnyType(Class cl)
|
||||
{
|
||||
return RepositoryId_1_3.createForAnyType(cl);
|
||||
}
|
||||
|
||||
public String getDefinedInId(String id)
|
||||
{
|
||||
RepositoryId_1_3 repId = RepositoryId_1_3.cache.getId(id);
|
||||
return repId.getDefinedInId();
|
||||
}
|
||||
|
||||
public String getUnqualifiedName(String id)
|
||||
{
|
||||
RepositoryId_1_3 repId = RepositoryId_1_3.cache.getId(id);
|
||||
return repId.getUnqualifiedName();
|
||||
}
|
||||
|
||||
public String getSerialVersionUID(String id)
|
||||
{
|
||||
RepositoryId_1_3 repId = RepositoryId_1_3.cache.getId(id);
|
||||
return repId.getSerialVersionUID();
|
||||
}
|
||||
|
||||
public boolean isAbstractBase(Class clazz)
|
||||
{
|
||||
return RepositoryId_1_3.isAbstractBase(clazz);
|
||||
}
|
||||
|
||||
public boolean isSequence(String id)
|
||||
{
|
||||
RepositoryId_1_3 repId = RepositoryId_1_3.cache.getId(id);
|
||||
return repId.isSequence();
|
||||
}
|
||||
|
||||
/**
|
||||
* Preserves the incorrect 1.3 behavior which truncates Java chars in
|
||||
* arrays to 8-bit CORBA chars. Bug 4367783. This enables us to
|
||||
* continue interoperating with our legacy ORBs. If this goes into
|
||||
* Ladybird, then Ladybird and Kestrel will interoperate as long as
|
||||
* people don't use chars greater than 8-bits.
|
||||
*/
|
||||
protected void writeCharArray(org.omg.CORBA_2_3.portable.OutputStream out,
|
||||
char[] array,
|
||||
int offset,
|
||||
int length)
|
||||
{
|
||||
out.write_char_array(array, offset, length);
|
||||
}
|
||||
|
||||
/**
|
||||
* Preserves the incorrect 1.3 behavior which truncates Java chars in
|
||||
* arrays to 8-bit CORBA chars. Bug 4367783. This enables us to
|
||||
* continue interoperating with our legacy ORBs. If this goes into
|
||||
* Ladybird, then Ladybird and Kestrel will interoperate as long as
|
||||
* people don't use chars greater than 8-bits.
|
||||
*/
|
||||
protected void readCharArray(org.omg.CORBA_2_3.portable.InputStream in,
|
||||
char[] array,
|
||||
int offset,
|
||||
int length)
|
||||
{
|
||||
in.read_char_array(array, offset, length);
|
||||
}
|
||||
|
||||
protected final String getOutputStreamClassName() {
|
||||
return "com.sun.corba.se.impl.orbutil.IIOPOutputStream_1_3";
|
||||
}
|
||||
|
||||
protected final String getInputStreamClassName() {
|
||||
return "com.sun.corba.se.impl.orbutil.IIOPInputStream_1_3";
|
||||
}
|
||||
|
||||
/**
|
||||
* Our JDK 1.3 and JDK 1.3.1 behavior subclasses override this.
|
||||
* The correct behavior is for a Java char to map to a CORBA wchar,
|
||||
* but our older code mapped it to a CORBA char.
|
||||
*/
|
||||
protected TCKind getJavaCharTCKind() {
|
||||
return TCKind.tk_char;
|
||||
}
|
||||
}
|
@ -1,77 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001, 2002, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package com.sun.corba.se.impl.orbutil;
|
||||
|
||||
import org.omg.CORBA.TCKind;
|
||||
|
||||
/**
|
||||
* This class overrides behavior of our current ValueHandlerImpl to
|
||||
* provide backwards compatibility with JDK 1.3.1.
|
||||
*/
|
||||
public class ValueHandlerImpl_1_3_1
|
||||
extends com.sun.corba.se.impl.io.ValueHandlerImpl
|
||||
{
|
||||
public ValueHandlerImpl_1_3_1() {}
|
||||
|
||||
public ValueHandlerImpl_1_3_1(boolean isInputStream) {
|
||||
super(isInputStream);
|
||||
}
|
||||
|
||||
/**
|
||||
* Our JDK 1.3 and JDK 1.3.1 behavior subclasses override this.
|
||||
* The correct behavior is for a Java char to map to a CORBA wchar,
|
||||
* but our older code mapped it to a CORBA char.
|
||||
*/
|
||||
protected TCKind getJavaCharTCKind() {
|
||||
return TCKind.tk_char;
|
||||
}
|
||||
|
||||
/**
|
||||
* RepositoryId_1_3_1 performs an incorrect repId calculation
|
||||
* when using serialPersistentFields and one of the fields no longer
|
||||
* exists on the class itself.
|
||||
*/
|
||||
public boolean useFullValueDescription(Class clazz, String repositoryID)
|
||||
throws java.io.IOException
|
||||
{
|
||||
return RepositoryId_1_3_1.useFullValueDescription(clazz, repositoryID);
|
||||
}
|
||||
|
||||
/**
|
||||
* Installs the legacy IIOPOutputStream_1_3_1 which does
|
||||
* PutFields/GetFields incorrectly. Bug 4407244.
|
||||
*/
|
||||
protected final String getOutputStreamClassName() {
|
||||
return "com.sun.corba.se.impl.orbutil.IIOPOutputStream_1_3_1";
|
||||
}
|
||||
|
||||
/**
|
||||
* Installs the legacy IIOPInputStream_1_3_1 which does
|
||||
* PutFields/GetFields incorrectly. Bug 4407244.
|
||||
*/
|
||||
protected final String getInputStreamClassName() {
|
||||
return "com.sun.corba.se.impl.orbutil.IIOPInputStream_1_3_1";
|
||||
}
|
||||
}
|
@ -98,6 +98,7 @@ import com.sun.corba.se.impl.logging.OMGSystemException ;
|
||||
import com.sun.corba.se.impl.presentation.rmi.PresentationManagerImpl ;
|
||||
|
||||
import com.sun.corba.se.impl.orbutil.ORBClassLoader ;
|
||||
import sun.awt.AppContext;
|
||||
|
||||
public abstract class ORB extends com.sun.corba.se.org.omg.CORBA.ORB
|
||||
implements Broker, TypeCodeFactory
|
||||
@ -173,14 +174,7 @@ public abstract class ORB extends com.sun.corba.se.org.omg.CORBA.ORB
|
||||
|
||||
protected MonitoringManager monitoringManager;
|
||||
|
||||
// There is only one instance of the PresentationManager
|
||||
// that is shared between all ORBs. This is necessary
|
||||
// because RMI-IIOP requires the PresentationManager in
|
||||
// places where no ORB is available, so the PresentationManager
|
||||
// must be global. It is initialized here as well.
|
||||
protected static PresentationManager globalPM = null ;
|
||||
|
||||
static {
|
||||
private static PresentationManager setupPresentationManager() {
|
||||
staticWrapper = ORBUtilSystemException.get(
|
||||
CORBALogDomains.RPC_PRESENTATION ) ;
|
||||
|
||||
@ -220,10 +214,11 @@ public abstract class ORB extends com.sun.corba.se.org.omg.CORBA.ORB
|
||||
}
|
||||
) ;
|
||||
|
||||
globalPM = new PresentationManagerImpl( useDynamicStub ) ;
|
||||
globalPM.setStubFactoryFactory( false,
|
||||
PresentationManager pm = new PresentationManagerImpl( useDynamicStub ) ;
|
||||
pm.setStubFactoryFactory( false,
|
||||
PresentationDefaults.getStaticStubFactoryFactory() ) ;
|
||||
globalPM.setStubFactoryFactory( true, dynamicStubFactoryFactory ) ;
|
||||
pm.setStubFactoryFactory( true, dynamicStubFactoryFactory ) ;
|
||||
return pm;
|
||||
}
|
||||
|
||||
public void destroy() {
|
||||
@ -234,11 +229,19 @@ public abstract class ORB extends com.sun.corba.se.org.omg.CORBA.ORB
|
||||
byteBufferPool = null;
|
||||
}
|
||||
|
||||
/** Get the single instance of the PresentationManager
|
||||
/**
|
||||
* Returns the Presentation Manager for the current thread group, using the ThreadGroup-specific
|
||||
* AppContext to hold it. Creates and records one if needed.
|
||||
*/
|
||||
public static PresentationManager getPresentationManager()
|
||||
{
|
||||
return globalPM ;
|
||||
AppContext ac = AppContext.getAppContext();
|
||||
PresentationManager pm = (PresentationManager) ac.get(PresentationManager.class);
|
||||
if (pm == null) {
|
||||
pm = setupPresentationManager();
|
||||
ac.put(PresentationManager.class, pm);
|
||||
}
|
||||
return pm;
|
||||
}
|
||||
|
||||
/** Get the appropriate StubFactoryFactory. This
|
||||
@ -248,8 +251,9 @@ public abstract class ORB extends com.sun.corba.se.org.omg.CORBA.ORB
|
||||
public static PresentationManager.StubFactoryFactory
|
||||
getStubFactoryFactory()
|
||||
{
|
||||
boolean useDynamicStubs = globalPM.useDynamicStubs() ;
|
||||
return globalPM.getStubFactoryFactory( useDynamicStubs ) ;
|
||||
PresentationManager gPM = getPresentationManager();
|
||||
boolean useDynamicStubs = gPM.useDynamicStubs() ;
|
||||
return gPM.getStubFactoryFactory( useDynamicStubs ) ;
|
||||
}
|
||||
|
||||
protected ORB()
|
||||
|
32
corba/src/share/classes/sun/corba/JavaCorbaAccess.java
Normal file
32
corba/src/share/classes/sun/corba/JavaCorbaAccess.java
Normal file
@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package sun.corba;
|
||||
|
||||
import com.sun.corba.se.impl.io.ValueHandlerImpl;
|
||||
|
||||
public interface JavaCorbaAccess {
|
||||
public ValueHandlerImpl newValueHandlerImpl();
|
||||
}
|
60
corba/src/share/classes/sun/corba/SharedSecrets.java
Normal file
60
corba/src/share/classes/sun/corba/SharedSecrets.java
Normal file
@ -0,0 +1,60 @@
|
||||
/*
|
||||
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package sun.corba;
|
||||
|
||||
import com.sun.corba.se.impl.io.ValueUtility;
|
||||
import sun.misc.Unsafe;
|
||||
|
||||
import java.security.AccessController;
|
||||
|
||||
/** A repository of "shared secrets", which are a mechanism for
|
||||
calling implementation-private methods in another package without
|
||||
using reflection. A package-private class implements a public
|
||||
interface and provides the ability to call package-private methods
|
||||
within that package; the object implementing that interface is
|
||||
provided through a third package to which access is restricted.
|
||||
This framework avoids the primary disadvantage of using reflection
|
||||
for this purpose, namely the loss of compile-time checking. */
|
||||
|
||||
// SharedSecrets cloned in corba repo to avoid build issues
|
||||
public class SharedSecrets {
|
||||
private static final Unsafe unsafe = Unsafe.getUnsafe();
|
||||
private static JavaCorbaAccess javaCorbaAccess;
|
||||
|
||||
public static JavaCorbaAccess getJavaCorbaAccess() {
|
||||
if (javaCorbaAccess == null) {
|
||||
// Ensure ValueUtility is initialized; we know that that class
|
||||
// provides the shared secret
|
||||
unsafe.ensureClassInitialized(ValueUtility.class);
|
||||
}
|
||||
return javaCorbaAccess;
|
||||
}
|
||||
|
||||
public static void setJavaCorbaAccess(JavaCorbaAccess access) {
|
||||
javaCorbaAccess = access;
|
||||
}
|
||||
|
||||
}
|
@ -322,3 +322,7 @@ d5e12e7d2f719144d84903d9151455661c47b476 jdk8-b78
|
||||
df5396524152118535c36da5801d828b560d19a2 hs25-b21
|
||||
4a198b201f3ce84433fa94a3ca65d061473e7c4c jdk8-b80
|
||||
dd6350b4abc4a6c19c89dd982cc0e4f3d119885c hs25-b22
|
||||
65b797426a3bec6e91b64085a0cfb94adadb634a jdk8-b81
|
||||
0631ebcc45f05c73b09a56c2586685af1f781c1d hs25-b23
|
||||
3db4ab0e12f437fe374817de346b2b0c6b4a5b31 jdk8-b82
|
||||
e3a41fc0234895eba4f272b984f7dacff495f8eb hs25-b24
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -40,12 +40,34 @@
|
||||
#import <errno.h>
|
||||
#import <sys/types.h>
|
||||
#import <sys/ptrace.h>
|
||||
#include "libproc_impl.h"
|
||||
|
||||
jboolean debug = JNI_FALSE;
|
||||
#define UNSUPPORTED_ARCH "Unsupported architecture!"
|
||||
|
||||
#if defined(x86_64) && !defined(amd64)
|
||||
#define amd64 1
|
||||
#endif
|
||||
|
||||
#if amd64
|
||||
#include "sun_jvm_hotspot_debugger_amd64_AMD64ThreadContext.h"
|
||||
#else
|
||||
#error UNSUPPORTED_ARCH
|
||||
#endif
|
||||
|
||||
static jfieldID symbolicatorID = 0; // set in _init0
|
||||
static jfieldID taskID = 0; // set in _init0
|
||||
|
||||
static jfieldID p_ps_prochandle_ID = 0;
|
||||
static jfieldID loadObjectList_ID = 0;
|
||||
static jmethodID listAdd_ID = 0;
|
||||
|
||||
static jmethodID createClosestSymbol_ID = 0;
|
||||
static jmethodID createLoadObject_ID = 0;
|
||||
static jmethodID getJavaThreadsInfo_ID = 0;
|
||||
|
||||
// indicator if thread id (lwpid_t) was set
|
||||
static bool _threads_filled = false;
|
||||
|
||||
static void putSymbolicator(JNIEnv *env, jobject this_obj, id symbolicator) {
|
||||
(*env)->SetLongField(env, this_obj, symbolicatorID, (jlong)(intptr_t)symbolicator);
|
||||
}
|
||||
@ -76,6 +98,11 @@ static void throw_new_debugger_exception(JNIEnv* env, const char* errMsg) {
|
||||
(*env)->ThrowNew(env, (*env)->FindClass(env, "sun/jvm/hotspot/debugger/DebuggerException"), errMsg);
|
||||
}
|
||||
|
||||
static struct ps_prochandle* get_proc_handle(JNIEnv* env, jobject this_obj) {
|
||||
jlong ptr = (*env)->GetLongField(env, this_obj, p_ps_prochandle_ID);
|
||||
return (struct ps_prochandle*)(intptr_t)ptr;
|
||||
}
|
||||
|
||||
#if defined(__i386__)
|
||||
#define hsdb_thread_state_t x86_thread_state32_t
|
||||
#define hsdb_float_state_t x86_float_state32_t
|
||||
@ -91,7 +118,7 @@ static void throw_new_debugger_exception(JNIEnv* env, const char* errMsg) {
|
||||
#define HSDB_THREAD_STATE_COUNT x86_THREAD_STATE64_COUNT
|
||||
#define HSDB_FLOAT_STATE_COUNT x86_FLOAT_STATE64_COUNT
|
||||
#else
|
||||
#error "Unsupported architecture"
|
||||
#error UNSUPPORTED_ARCH
|
||||
#endif
|
||||
|
||||
/*
|
||||
@ -104,6 +131,66 @@ Java_sun_jvm_hotspot_debugger_bsd_BsdDebuggerLocal_init0(JNIEnv *env, jclass cls
|
||||
symbolicatorID = (*env)->GetFieldID(env, cls, "symbolicator", "J");
|
||||
taskID = (*env)->GetFieldID(env, cls, "task", "J");
|
||||
CHECK_EXCEPTION;
|
||||
|
||||
// for core file
|
||||
p_ps_prochandle_ID = (*env)->GetFieldID(env, cls, "p_ps_prochandle", "J");
|
||||
CHECK_EXCEPTION;
|
||||
loadObjectList_ID = (*env)->GetFieldID(env, cls, "loadObjectList", "Ljava/util/List;");
|
||||
CHECK_EXCEPTION;
|
||||
|
||||
// methods we use
|
||||
createClosestSymbol_ID = (*env)->GetMethodID(env, cls, "createClosestSymbol",
|
||||
"(Ljava/lang/String;J)Lsun/jvm/hotspot/debugger/cdbg/ClosestSymbol;");
|
||||
CHECK_EXCEPTION;
|
||||
createLoadObject_ID = (*env)->GetMethodID(env, cls, "createLoadObject",
|
||||
"(Ljava/lang/String;JJ)Lsun/jvm/hotspot/debugger/cdbg/LoadObject;");
|
||||
CHECK_EXCEPTION;
|
||||
|
||||
// java.util.List method we call
|
||||
jclass listClass = (*env)->FindClass(env, "java/util/List");
|
||||
CHECK_EXCEPTION;
|
||||
listAdd_ID = (*env)->GetMethodID(env, listClass, "add", "(Ljava/lang/Object;)Z");
|
||||
CHECK_EXCEPTION;
|
||||
getJavaThreadsInfo_ID = (*env)->GetMethodID(env, cls, "getJavaThreadsInfo",
|
||||
"()[J");
|
||||
CHECK_EXCEPTION;
|
||||
|
||||
init_libproc(getenv("LIBSAPROC_DEBUG") != NULL);
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL Java_sun_jvm_hotspot_debugger_bsd_BsdDebuggerLocal_getAddressSize
|
||||
(JNIEnv *env, jclass cls)
|
||||
{
|
||||
#ifdef _LP64
|
||||
return 8;
|
||||
#else
|
||||
#error UNSUPPORTED_ARCH
|
||||
#endif
|
||||
}
|
||||
|
||||
/** called by Java_sun_jvm_hotspot_debugger_bsd_BsdDebuggerLocal_lookupByName0 */
|
||||
jlong lookupByNameIncore(
|
||||
JNIEnv *env, struct ps_prochandle *ph, jobject this_obj, jstring objectName, jstring symbolName)
|
||||
{
|
||||
const char *objectName_cstr, *symbolName_cstr;
|
||||
jlong addr;
|
||||
jboolean isCopy;
|
||||
objectName_cstr = NULL;
|
||||
if (objectName != NULL) {
|
||||
objectName_cstr = (*env)->GetStringUTFChars(env, objectName, &isCopy);
|
||||
CHECK_EXCEPTION_(0);
|
||||
}
|
||||
symbolName_cstr = (*env)->GetStringUTFChars(env, symbolName, &isCopy);
|
||||
CHECK_EXCEPTION_(0);
|
||||
|
||||
print_debug("look for %s \n", symbolName_cstr);
|
||||
addr = (jlong) lookup_symbol(ph, objectName_cstr, symbolName_cstr);
|
||||
|
||||
if (objectName_cstr != NULL) {
|
||||
(*env)->ReleaseStringUTFChars(env, objectName, objectName_cstr);
|
||||
}
|
||||
(*env)->ReleaseStringUTFChars(env, symbolName, symbolName_cstr);
|
||||
return addr;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -116,14 +203,17 @@ Java_sun_jvm_hotspot_debugger_bsd_BsdDebuggerLocal_lookupByName0(
|
||||
JNIEnv *env, jobject this_obj,
|
||||
jstring objectName, jstring symbolName)
|
||||
{
|
||||
struct ps_prochandle* ph = get_proc_handle(env, this_obj);
|
||||
if (ph->core != NULL) {
|
||||
return lookupByNameIncore(env, ph, this_obj, objectName, symbolName);
|
||||
}
|
||||
|
||||
jlong address = 0;
|
||||
|
||||
JNF_COCOA_ENTER(env);
|
||||
NSString *symbolNameString = JNFJavaToNSString(env, symbolName);
|
||||
|
||||
if (debug) {
|
||||
printf("lookupInProcess called for %s\n", [symbolNameString UTF8String]);
|
||||
}
|
||||
print_debug("lookupInProcess called for %s\n", [symbolNameString UTF8String]);
|
||||
|
||||
id symbolicator = getSymbolicator(env, this_obj);
|
||||
if (symbolicator != nil) {
|
||||
@ -131,14 +221,48 @@ JNF_COCOA_ENTER(env);
|
||||
address = (jlong) dynamicCall(symbolicator, @selector(addressForSymbol:), symbolNameString);
|
||||
}
|
||||
|
||||
if (debug) {
|
||||
printf("address of symbol %s = %llx\n", [symbolNameString UTF8String], address);
|
||||
}
|
||||
print_debug("address of symbol %s = %llx\n", [symbolNameString UTF8String], address);
|
||||
JNF_COCOA_EXIT(env);
|
||||
|
||||
return address;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: sun_jvm_hotspot_debugger_bsd_BsdDebuggerLocal
|
||||
* Method: lookupByAddress0
|
||||
* Signature: (J)Lsun/jvm/hotspot/debugger/cdbg/ClosestSymbol;
|
||||
*/
|
||||
JNIEXPORT jobject JNICALL Java_sun_jvm_hotspot_debugger_bsd_BsdDebuggerLocal_lookupByAddress0
|
||||
(JNIEnv *env, jobject this_obj, jlong addr) {
|
||||
uintptr_t offset;
|
||||
const char* sym = NULL;
|
||||
|
||||
struct ps_prochandle* ph = get_proc_handle(env, this_obj);
|
||||
sym = symbol_for_pc(ph, (uintptr_t) addr, &offset);
|
||||
if (sym == NULL) return 0;
|
||||
return (*env)->CallObjectMethod(env, this_obj, createClosestSymbol_ID,
|
||||
(*env)->NewStringUTF(env, sym), (jlong)offset);
|
||||
}
|
||||
|
||||
/** called from Java_sun_jvm_hotspot_debugger_bsd_BsdDebuggerLocal_readBytesFromProcess0 */
|
||||
jbyteArray readBytesFromCore(
|
||||
JNIEnv *env, struct ps_prochandle *ph, jobject this_obj, jlong addr, jlong numBytes)
|
||||
{
|
||||
jboolean isCopy;
|
||||
jbyteArray array;
|
||||
jbyte *bufPtr;
|
||||
ps_err_e err;
|
||||
|
||||
array = (*env)->NewByteArray(env, numBytes);
|
||||
CHECK_EXCEPTION_(0);
|
||||
bufPtr = (*env)->GetByteArrayElements(env, array, &isCopy);
|
||||
CHECK_EXCEPTION_(0);
|
||||
|
||||
err = ps_pread(ph, (psaddr_t) (uintptr_t)addr, bufPtr, numBytes);
|
||||
(*env)->ReleaseByteArrayElements(env, array, bufPtr, 0);
|
||||
return (err == PS_OK)? array : 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: sun_jvm_hotspot_debugger_bsd_BsdDebuggerLocal
|
||||
* Method: readBytesFromProcess0
|
||||
@ -149,12 +273,15 @@ Java_sun_jvm_hotspot_debugger_bsd_BsdDebuggerLocal_readBytesFromProcess0(
|
||||
JNIEnv *env, jobject this_obj,
|
||||
jlong addr, jlong numBytes)
|
||||
{
|
||||
if (debug) printf("readBytesFromProcess called. addr = %llx numBytes = %lld\n", addr, numBytes);
|
||||
print_debug("readBytesFromProcess called. addr = %llx numBytes = %lld\n", addr, numBytes);
|
||||
|
||||
// must allocate storage instead of using former parameter buf
|
||||
jboolean isCopy;
|
||||
jbyteArray array;
|
||||
jbyte *bufPtr;
|
||||
|
||||
struct ps_prochandle* ph = get_proc_handle(env, this_obj);
|
||||
if (ph->core != NULL) {
|
||||
return readBytesFromCore(env, ph, this_obj, addr, numBytes);
|
||||
}
|
||||
|
||||
array = (*env)->NewByteArray(env, numBytes);
|
||||
CHECK_EXCEPTION_(0);
|
||||
@ -189,7 +316,7 @@ Java_sun_jvm_hotspot_debugger_bsd_BsdDebuggerLocal_readBytesFromProcess0(
|
||||
// assume all failures are unmapped pages
|
||||
}
|
||||
|
||||
if (debug) fprintf(stderr, "%ld pages\n", pageCount);
|
||||
print_debug("%ld pages\n", pageCount);
|
||||
|
||||
remaining = numBytes;
|
||||
|
||||
@ -207,7 +334,7 @@ Java_sun_jvm_hotspot_debugger_bsd_BsdDebuggerLocal_readBytesFromProcess0(
|
||||
}
|
||||
|
||||
if (mapped[i]) {
|
||||
if (debug) fprintf(stderr, "page %d mapped (len %ld start %ld)\n", i, len, start);
|
||||
print_debug("page %d mapped (len %ld start %ld)\n", i, len, start);
|
||||
(*env)->SetByteArrayRegion(env, array, 0, len, ((jbyte *) pages[i] + start));
|
||||
vm_deallocate(mach_task_self(), pages[i], vm_page_size);
|
||||
}
|
||||
@ -220,6 +347,115 @@ Java_sun_jvm_hotspot_debugger_bsd_BsdDebuggerLocal_readBytesFromProcess0(
|
||||
return array;
|
||||
}
|
||||
|
||||
/** Only used for core file reading, set thread_id for threads which is got after core file parsed.
|
||||
* Thread context is available in Mach-O core file but thread id is not. We can get thread id
|
||||
* from Threads which store all java threads information when they are created. Here we can identify
|
||||
* them as java threads by checking if a thread's rsp or rbp within a java thread's stack.
|
||||
* Note Macosx uses unique_thread_id which is different from other platforms though printed ids
|
||||
* are still pthread id. Function BsdDebuggerLocal.getJavaThreadsInfo returns an array of long
|
||||
* integers to host all java threads' id, stack_start, stack_end as:
|
||||
* [uid0, stack_start0, stack_end0, uid1, stack_start1, stack_end1, ...]
|
||||
*
|
||||
* The work cannot be done at init0 since Threads is not available yet(VM not initialized yet).
|
||||
* This function should be called only once if succeeded
|
||||
*/
|
||||
bool fill_java_threads(JNIEnv* env, jobject this_obj, struct ps_prochandle* ph) {
|
||||
int n = 0, i = 0, j;
|
||||
struct reg regs;
|
||||
|
||||
jlongArray thrinfos = (*env)->CallObjectMethod(env, this_obj, getJavaThreadsInfo_ID);
|
||||
CHECK_EXCEPTION_(false);
|
||||
int len = (int)(*env)->GetArrayLength(env, thrinfos);
|
||||
uint64_t* cinfos = (uint64_t *)(*env)->GetLongArrayElements(env, thrinfos, NULL);
|
||||
CHECK_EXCEPTION_(false);
|
||||
n = get_num_threads(ph);
|
||||
print_debug("fill_java_threads called, num_of_thread = %d\n", n);
|
||||
for (i = 0; i < n; i++) {
|
||||
if (!get_nth_lwp_regs(ph, i, ®s)) {
|
||||
print_debug("Could not get regs of thread %d, already set!\n", i);
|
||||
return false;
|
||||
}
|
||||
for (j = 0; j < len; j += 3) {
|
||||
lwpid_t uid = cinfos[j];
|
||||
uint64_t beg = cinfos[j + 1];
|
||||
uint64_t end = cinfos[j + 2];
|
||||
if ((regs.r_rsp < end && regs.r_rsp >= beg) ||
|
||||
(regs.r_rbp < end && regs.r_rbp >= beg)) {
|
||||
set_lwp_id(ph, i, uid);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
(*env)->ReleaseLongArrayElements(env, thrinfos, (jlong*)cinfos, 0);
|
||||
CHECK_EXCEPTION_(false);
|
||||
return true;
|
||||
}
|
||||
|
||||
/* For core file only, called from
|
||||
* Java_sun_jvm_hotspot_debugger_bsd_BsdDebuggerLocal_getThreadIntegerRegisterSet0
|
||||
*/
|
||||
jlongArray getThreadIntegerRegisterSetFromCore(JNIEnv *env, jobject this_obj, long lwp_id) {
|
||||
if (!_threads_filled) {
|
||||
if (!fill_java_threads(env, this_obj, get_proc_handle(env, this_obj))) {
|
||||
throw_new_debugger_exception(env, "Failed to fill in threads");
|
||||
return 0;
|
||||
} else {
|
||||
_threads_filled = true;
|
||||
}
|
||||
}
|
||||
|
||||
struct reg gregs;
|
||||
jboolean isCopy;
|
||||
jlongArray array;
|
||||
jlong *regs;
|
||||
|
||||
struct ps_prochandle* ph = get_proc_handle(env, this_obj);
|
||||
if (get_lwp_regs(ph, lwp_id, &gregs) != true) {
|
||||
THROW_NEW_DEBUGGER_EXCEPTION_("get_thread_regs failed for a lwp", 0);
|
||||
}
|
||||
|
||||
#undef NPRGREG
|
||||
#undef REG_INDEX
|
||||
#if amd64
|
||||
#define NPRGREG sun_jvm_hotspot_debugger_amd64_AMD64ThreadContext_NPRGREG
|
||||
#define REG_INDEX(reg) sun_jvm_hotspot_debugger_amd64_AMD64ThreadContext_##reg
|
||||
|
||||
array = (*env)->NewLongArray(env, NPRGREG);
|
||||
CHECK_EXCEPTION_(0);
|
||||
regs = (*env)->GetLongArrayElements(env, array, &isCopy);
|
||||
|
||||
regs[REG_INDEX(R15)] = gregs.r_r15;
|
||||
regs[REG_INDEX(R14)] = gregs.r_r14;
|
||||
regs[REG_INDEX(R13)] = gregs.r_r13;
|
||||
regs[REG_INDEX(R12)] = gregs.r_r12;
|
||||
regs[REG_INDEX(RBP)] = gregs.r_rbp;
|
||||
regs[REG_INDEX(RBX)] = gregs.r_rbx;
|
||||
regs[REG_INDEX(R11)] = gregs.r_r11;
|
||||
regs[REG_INDEX(R10)] = gregs.r_r10;
|
||||
regs[REG_INDEX(R9)] = gregs.r_r9;
|
||||
regs[REG_INDEX(R8)] = gregs.r_r8;
|
||||
regs[REG_INDEX(RAX)] = gregs.r_rax;
|
||||
regs[REG_INDEX(RCX)] = gregs.r_rcx;
|
||||
regs[REG_INDEX(RDX)] = gregs.r_rdx;
|
||||
regs[REG_INDEX(RSI)] = gregs.r_rsi;
|
||||
regs[REG_INDEX(RDI)] = gregs.r_rdi;
|
||||
regs[REG_INDEX(RIP)] = gregs.r_rip;
|
||||
regs[REG_INDEX(CS)] = gregs.r_cs;
|
||||
regs[REG_INDEX(RSP)] = gregs.r_rsp;
|
||||
regs[REG_INDEX(SS)] = gregs.r_ss;
|
||||
regs[REG_INDEX(FSBASE)] = 0;
|
||||
regs[REG_INDEX(GSBASE)] = 0;
|
||||
regs[REG_INDEX(DS)] = gregs.r_ds;
|
||||
regs[REG_INDEX(ES)] = gregs.r_es;
|
||||
regs[REG_INDEX(FS)] = gregs.r_fs;
|
||||
regs[REG_INDEX(GS)] = gregs.r_gs;
|
||||
regs[REG_INDEX(TRAPNO)] = gregs.r_trapno;
|
||||
regs[REG_INDEX(RFL)] = gregs.r_rflags;
|
||||
|
||||
#endif /* amd64 */
|
||||
(*env)->ReleaseLongArrayElements(env, array, regs, JNI_COMMIT);
|
||||
return array;
|
||||
}
|
||||
|
||||
/*
|
||||
* Lookup the thread_t that corresponds to the given thread_id.
|
||||
@ -232,9 +468,7 @@ Java_sun_jvm_hotspot_debugger_bsd_BsdDebuggerLocal_readBytesFromProcess0(
|
||||
*/
|
||||
thread_t
|
||||
lookupThreadFromThreadId(task_t task, jlong thread_id) {
|
||||
if (debug) {
|
||||
printf("lookupThreadFromThreadId thread_id=0x%llx\n", thread_id);
|
||||
}
|
||||
print_debug("lookupThreadFromThreadId thread_id=0x%llx\n", thread_id);
|
||||
|
||||
thread_array_t thread_list = NULL;
|
||||
mach_msg_type_number_t thread_list_count = 0;
|
||||
@ -244,9 +478,7 @@ lookupThreadFromThreadId(task_t task, jlong thread_id) {
|
||||
// get the list of all the send rights
|
||||
kern_return_t result = task_threads(task, &thread_list, &thread_list_count);
|
||||
if (result != KERN_SUCCESS) {
|
||||
if (debug) {
|
||||
printf("task_threads returned 0x%x\n", result);
|
||||
}
|
||||
print_debug("task_threads returned 0x%x\n", result);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -257,9 +489,7 @@ lookupThreadFromThreadId(task_t task, jlong thread_id) {
|
||||
// get the THREAD_IDENTIFIER_INFO for the send right
|
||||
result = thread_info(thread_list[i], THREAD_IDENTIFIER_INFO, (thread_info_t) &m_ident_info, &count);
|
||||
if (result != KERN_SUCCESS) {
|
||||
if (debug) {
|
||||
printf("thread_info returned 0x%x\n", result);
|
||||
}
|
||||
print_debug("thread_info returned 0x%x\n", result);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -288,15 +518,17 @@ Java_sun_jvm_hotspot_debugger_bsd_BsdDebuggerLocal_getThreadIntegerRegisterSet0(
|
||||
JNIEnv *env, jobject this_obj,
|
||||
jlong thread_id)
|
||||
{
|
||||
if (debug)
|
||||
printf("getThreadRegisterSet0 called\n");
|
||||
print_debug("getThreadRegisterSet0 called\n");
|
||||
|
||||
struct ps_prochandle* ph = get_proc_handle(env, this_obj);
|
||||
if (ph->core != NULL) {
|
||||
return getThreadIntegerRegisterSetFromCore(env, this_obj, thread_id);
|
||||
}
|
||||
|
||||
kern_return_t result;
|
||||
thread_t tid;
|
||||
mach_msg_type_number_t count = HSDB_THREAD_STATE_COUNT;
|
||||
hsdb_thread_state_t state;
|
||||
unsigned int *r;
|
||||
int i;
|
||||
jlongArray registerArray;
|
||||
jlong *primitiveArray;
|
||||
task_t gTask = getTask(env, this_obj);
|
||||
@ -306,97 +538,56 @@ Java_sun_jvm_hotspot_debugger_bsd_BsdDebuggerLocal_getThreadIntegerRegisterSet0(
|
||||
result = thread_get_state(tid, HSDB_THREAD_STATE, (thread_state_t)&state, &count);
|
||||
|
||||
if (result != KERN_SUCCESS) {
|
||||
if (debug)
|
||||
printf("getregs: thread_get_state(%d) failed (%d)\n", tid, result);
|
||||
print_error("getregs: thread_get_state(%d) failed (%d)\n", tid, result);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// 40 32-bit registers on ppc, 16 on x86.
|
||||
// Output order is the same as the order in the ppc_thread_state/i386_thread_state struct.
|
||||
#if defined(__i386__)
|
||||
r = (unsigned int *)&state;
|
||||
registerArray = (*env)->NewLongArray(env, 8);
|
||||
primitiveArray = (*env)->GetLongArrayElements(env, registerArray, NULL);
|
||||
primitiveArray[0] = r[0]; // eax
|
||||
primitiveArray[1] = r[2]; // ecx
|
||||
primitiveArray[2] = r[3]; // edx
|
||||
primitiveArray[3] = r[1]; // ebx
|
||||
primitiveArray[4] = r[7]; // esp
|
||||
primitiveArray[5] = r[6]; // ebp
|
||||
primitiveArray[6] = r[5]; // esi
|
||||
primitiveArray[7] = r[4]; // edi
|
||||
(*env)->ReleaseLongArrayElements(env, registerArray, primitiveArray, 0);
|
||||
#elif defined(__x86_64__)
|
||||
/* From AMD64ThreadContext.java
|
||||
public static final int R15 = 0;
|
||||
public static final int R14 = 1;
|
||||
public static final int R13 = 2;
|
||||
public static final int R12 = 3;
|
||||
public static final int R11 = 4;
|
||||
public static final int R10 = 5;
|
||||
public static final int R9 = 6;
|
||||
public static final int R8 = 7;
|
||||
public static final int RDI = 8;
|
||||
public static final int RSI = 9;
|
||||
public static final int RBP = 10;
|
||||
public static final int RBX = 11;
|
||||
public static final int RDX = 12;
|
||||
public static final int RCX = 13;
|
||||
public static final int RAX = 14;
|
||||
public static final int TRAPNO = 15;
|
||||
public static final int ERR = 16;
|
||||
public static final int RIP = 17;
|
||||
public static final int CS = 18;
|
||||
public static final int RFL = 19;
|
||||
public static final int RSP = 20;
|
||||
public static final int SS = 21;
|
||||
public static final int FS = 22;
|
||||
public static final int GS = 23;
|
||||
public static final int ES = 24;
|
||||
public static final int DS = 25;
|
||||
public static final int FSBASE = 26;
|
||||
public static final int GSBASE = 27;
|
||||
*/
|
||||
#if amd64
|
||||
#define NPRGREG sun_jvm_hotspot_debugger_amd64_AMD64ThreadContext_NPRGREG
|
||||
#undef REG_INDEX
|
||||
#define REG_INDEX(reg) sun_jvm_hotspot_debugger_amd64_AMD64ThreadContext_##reg
|
||||
|
||||
// 64 bit
|
||||
if (debug) printf("Getting threads for a 64-bit process\n");
|
||||
registerArray = (*env)->NewLongArray(env, 28);
|
||||
print_debug("Getting threads for a 64-bit process\n");
|
||||
registerArray = (*env)->NewLongArray(env, NPRGREG);
|
||||
CHECK_EXCEPTION_(0);
|
||||
primitiveArray = (*env)->GetLongArrayElements(env, registerArray, NULL);
|
||||
|
||||
primitiveArray[0] = state.__r15;
|
||||
primitiveArray[1] = state.__r14;
|
||||
primitiveArray[2] = state.__r13;
|
||||
primitiveArray[3] = state.__r12;
|
||||
primitiveArray[4] = state.__r11;
|
||||
primitiveArray[5] = state.__r10;
|
||||
primitiveArray[6] = state.__r9;
|
||||
primitiveArray[7] = state.__r8;
|
||||
primitiveArray[8] = state.__rdi;
|
||||
primitiveArray[9] = state.__rsi;
|
||||
primitiveArray[10] = state.__rbp;
|
||||
primitiveArray[11] = state.__rbx;
|
||||
primitiveArray[12] = state.__rdx;
|
||||
primitiveArray[13] = state.__rcx;
|
||||
primitiveArray[14] = state.__rax;
|
||||
primitiveArray[15] = 0; // trapno ?
|
||||
primitiveArray[16] = 0; // err ?
|
||||
primitiveArray[17] = state.__rip;
|
||||
primitiveArray[18] = state.__cs;
|
||||
primitiveArray[19] = state.__rflags;
|
||||
primitiveArray[20] = state.__rsp;
|
||||
primitiveArray[21] = 0; // We don't have SS
|
||||
primitiveArray[22] = state.__fs;
|
||||
primitiveArray[23] = state.__gs;
|
||||
primitiveArray[24] = 0;
|
||||
primitiveArray[25] = 0;
|
||||
primitiveArray[26] = 0;
|
||||
primitiveArray[27] = 0;
|
||||
|
||||
if (debug) printf("set registers\n");
|
||||
primitiveArray[REG_INDEX(R15)] = state.__r15;
|
||||
primitiveArray[REG_INDEX(R14)] = state.__r14;
|
||||
primitiveArray[REG_INDEX(R13)] = state.__r13;
|
||||
primitiveArray[REG_INDEX(R12)] = state.__r12;
|
||||
primitiveArray[REG_INDEX(R11)] = state.__r11;
|
||||
primitiveArray[REG_INDEX(R10)] = state.__r10;
|
||||
primitiveArray[REG_INDEX(R9)] = state.__r9;
|
||||
primitiveArray[REG_INDEX(R8)] = state.__r8;
|
||||
primitiveArray[REG_INDEX(RDI)] = state.__rdi;
|
||||
primitiveArray[REG_INDEX(RSI)] = state.__rsi;
|
||||
primitiveArray[REG_INDEX(RBP)] = state.__rbp;
|
||||
primitiveArray[REG_INDEX(RBX)] = state.__rbx;
|
||||
primitiveArray[REG_INDEX(RDX)] = state.__rdx;
|
||||
primitiveArray[REG_INDEX(RCX)] = state.__rcx;
|
||||
primitiveArray[REG_INDEX(RAX)] = state.__rax;
|
||||
primitiveArray[REG_INDEX(TRAPNO)] = 0; // trapno, not used
|
||||
primitiveArray[REG_INDEX(ERR)] = 0; // err, not used
|
||||
primitiveArray[REG_INDEX(RIP)] = state.__rip;
|
||||
primitiveArray[REG_INDEX(CS)] = state.__cs;
|
||||
primitiveArray[REG_INDEX(RFL)] = state.__rflags;
|
||||
primitiveArray[REG_INDEX(RSP)] = state.__rsp;
|
||||
primitiveArray[REG_INDEX(SS)] = 0; // We don't have SS
|
||||
primitiveArray[REG_INDEX(FS)] = state.__fs;
|
||||
primitiveArray[REG_INDEX(GS)] = state.__gs;
|
||||
primitiveArray[REG_INDEX(ES)] = 0;
|
||||
primitiveArray[REG_INDEX(DS)] = 0;
|
||||
primitiveArray[REG_INDEX(FSBASE)] = 0;
|
||||
primitiveArray[REG_INDEX(GSBASE)] = 0;
|
||||
print_debug("set registers\n");
|
||||
|
||||
(*env)->ReleaseLongArrayElements(env, registerArray, primitiveArray, 0);
|
||||
|
||||
#else
|
||||
#error Unsupported architecture
|
||||
#endif
|
||||
#error UNSUPPORTED_ARCH
|
||||
#endif /* amd64 */
|
||||
|
||||
return registerArray;
|
||||
}
|
||||
@ -410,8 +601,7 @@ JNIEXPORT jint JNICALL
|
||||
Java_sun_jvm_hotspot_debugger_macosx_MacOSXDebuggerLocal_translateTID0(
|
||||
JNIEnv *env, jobject this_obj, jint tid)
|
||||
{
|
||||
if (debug)
|
||||
printf("translateTID0 called on tid = 0x%x\n", (int)tid);
|
||||
print_debug("translateTID0 called on tid = 0x%x\n", (int)tid);
|
||||
|
||||
kern_return_t result;
|
||||
thread_t foreign_tid, usable_tid;
|
||||
@ -426,8 +616,7 @@ Java_sun_jvm_hotspot_debugger_macosx_MacOSXDebuggerLocal_translateTID0(
|
||||
if (result != KERN_SUCCESS)
|
||||
return -1;
|
||||
|
||||
if (debug)
|
||||
printf("translateTID0: 0x%x -> 0x%x\n", foreign_tid, usable_tid);
|
||||
print_debug("translateTID0: 0x%x -> 0x%x\n", foreign_tid, usable_tid);
|
||||
|
||||
return (jint) usable_tid;
|
||||
}
|
||||
@ -437,7 +626,7 @@ static bool ptrace_continue(pid_t pid, int signal) {
|
||||
// pass the signal to the process so we don't swallow it
|
||||
int res;
|
||||
if ((res = ptrace(PT_CONTINUE, pid, (caddr_t)1, signal)) < 0) {
|
||||
fprintf(stderr, "attach: ptrace(PT_CONTINUE, %d) failed with %d\n", pid, res);
|
||||
print_error("attach: ptrace(PT_CONTINUE, %d) failed with %d\n", pid, res);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@ -461,11 +650,11 @@ static bool ptrace_waitpid(pid_t pid) {
|
||||
return true;
|
||||
}
|
||||
if (!ptrace_continue(pid, WSTOPSIG(status))) {
|
||||
fprintf(stderr, "attach: Failed to correctly attach to VM. VM might HANG! [PTRACE_CONT failed, stopped by %d]\n", WSTOPSIG(status));
|
||||
print_error("attach: Failed to correctly attach to VM. VM might HANG! [PTRACE_CONT failed, stopped by %d]\n", WSTOPSIG(status));
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
fprintf(stderr, "attach: waitpid(): Child process exited/terminated (status = 0x%x)\n", status);
|
||||
print_error("attach: waitpid(): Child process exited/terminated (status = 0x%x)\n", status);
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
@ -474,13 +663,13 @@ static bool ptrace_waitpid(pid_t pid) {
|
||||
continue;
|
||||
break;
|
||||
case ECHILD:
|
||||
fprintf(stderr, "attach: waitpid() failed. Child process pid (%d) does not exist \n", pid);
|
||||
print_error("attach: waitpid() failed. Child process pid (%d) does not exist \n", pid);
|
||||
break;
|
||||
case EINVAL:
|
||||
fprintf(stderr, "attach: waitpid() failed. Invalid options argument.\n");
|
||||
print_error("attach: waitpid() failed. Invalid options argument.\n");
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr, "attach: waitpid() failed. Unexpected error %d\n",errno);
|
||||
print_error("attach: waitpid() failed. Unexpected error %d\n",errno);
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
@ -492,7 +681,7 @@ static bool ptrace_waitpid(pid_t pid) {
|
||||
static bool ptrace_attach(pid_t pid) {
|
||||
int res;
|
||||
if ((res = ptrace(PT_ATTACH, pid, 0, 0)) < 0) {
|
||||
fprintf(stderr, "ptrace(PT_ATTACH, %d) failed with %d\n", pid, res);
|
||||
print_error("ptrace(PT_ATTACH, %d) failed with %d\n", pid, res);
|
||||
return false;
|
||||
} else {
|
||||
return ptrace_waitpid(pid);
|
||||
@ -508,19 +697,15 @@ JNIEXPORT void JNICALL
|
||||
Java_sun_jvm_hotspot_debugger_bsd_BsdDebuggerLocal_attach0__I(
|
||||
JNIEnv *env, jobject this_obj, jint jpid)
|
||||
{
|
||||
JNF_COCOA_ENTER(env);
|
||||
if (getenv("JAVA_SAPROC_DEBUG") != NULL)
|
||||
debug = JNI_TRUE;
|
||||
else
|
||||
debug = JNI_FALSE;
|
||||
if (debug) printf("attach0 called for jpid=%d\n", (int)jpid);
|
||||
print_debug("attach0 called for jpid=%d\n", (int)jpid);
|
||||
|
||||
JNF_COCOA_ENTER(env);
|
||||
|
||||
// get the task from the pid
|
||||
kern_return_t result;
|
||||
task_t gTask = 0;
|
||||
result = task_for_pid(mach_task_self(), jpid, &gTask);
|
||||
if (result != KERN_SUCCESS) {
|
||||
fprintf(stderr, "attach: task_for_pid(%d) failed (%d)\n", (int)jpid, result);
|
||||
print_error("attach: task_for_pid(%d) failed (%d)\n", (int)jpid, result);
|
||||
THROW_NEW_DEBUGGER_EXCEPTION("Can't attach to the process");
|
||||
}
|
||||
putTask(env, this_obj, gTask);
|
||||
@ -550,6 +735,63 @@ JNF_COCOA_ENTER(env);
|
||||
JNF_COCOA_EXIT(env);
|
||||
}
|
||||
|
||||
/** For core file,
|
||||
called from Java_sun_jvm_hotspot_debugger_bsd_BsdDebuggerLocal_attach0__Ljava_lang_String_2Ljava_lang_String_2 */
|
||||
static void fillLoadObjects(JNIEnv* env, jobject this_obj, struct ps_prochandle* ph) {
|
||||
int n = 0, i = 0;
|
||||
|
||||
// add load objects
|
||||
n = get_num_libs(ph);
|
||||
for (i = 0; i < n; i++) {
|
||||
uintptr_t base;
|
||||
const char* name;
|
||||
jobject loadObject;
|
||||
jobject loadObjectList;
|
||||
|
||||
base = get_lib_base(ph, i);
|
||||
name = get_lib_name(ph, i);
|
||||
loadObject = (*env)->CallObjectMethod(env, this_obj, createLoadObject_ID,
|
||||
(*env)->NewStringUTF(env, name), (jlong)0, (jlong)base);
|
||||
CHECK_EXCEPTION;
|
||||
loadObjectList = (*env)->GetObjectField(env, this_obj, loadObjectList_ID);
|
||||
CHECK_EXCEPTION;
|
||||
(*env)->CallBooleanMethod(env, loadObjectList, listAdd_ID, loadObject);
|
||||
CHECK_EXCEPTION;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: sun_jvm_hotspot_debugger_bsd_BsdDebuggerLocal
|
||||
* Method: attach0
|
||||
* Signature: (Ljava/lang/String;Ljava/lang/String;)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_sun_jvm_hotspot_debugger_bsd_BsdDebuggerLocal_attach0__Ljava_lang_String_2Ljava_lang_String_2(
|
||||
JNIEnv *env, jobject this_obj, jstring execName, jstring coreName)
|
||||
{
|
||||
const char *execName_cstr;
|
||||
const char *coreName_cstr;
|
||||
jboolean isCopy;
|
||||
struct ps_prochandle* ph;
|
||||
|
||||
execName_cstr = (*env)->GetStringUTFChars(env, execName, &isCopy);
|
||||
CHECK_EXCEPTION;
|
||||
coreName_cstr = (*env)->GetStringUTFChars(env, coreName, &isCopy);
|
||||
CHECK_EXCEPTION;
|
||||
|
||||
print_debug("attach: %s %s\n", execName_cstr, coreName_cstr);
|
||||
|
||||
if ( (ph = Pgrab_core(execName_cstr, coreName_cstr)) == NULL) {
|
||||
(*env)->ReleaseStringUTFChars(env, execName, execName_cstr);
|
||||
(*env)->ReleaseStringUTFChars(env, coreName, coreName_cstr);
|
||||
THROW_NEW_DEBUGGER_EXCEPTION("Can't attach to the core file");
|
||||
}
|
||||
(*env)->SetLongField(env, this_obj, p_ps_prochandle_ID, (jlong)(intptr_t)ph);
|
||||
(*env)->ReleaseStringUTFChars(env, execName, execName_cstr);
|
||||
(*env)->ReleaseStringUTFChars(env, coreName, coreName_cstr);
|
||||
fillLoadObjects(env, this_obj, ph);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: sun_jvm_hotspot_debugger_bsd_BsdDebuggerLocal
|
||||
* Method: detach0
|
||||
@ -559,9 +801,13 @@ JNIEXPORT void JNICALL
|
||||
Java_sun_jvm_hotspot_debugger_bsd_BsdDebuggerLocal_detach0(
|
||||
JNIEnv *env, jobject this_obj)
|
||||
{
|
||||
print_debug("detach0 called\n");
|
||||
struct ps_prochandle* ph = get_proc_handle(env, this_obj);
|
||||
if (ph != NULL && ph->core != NULL) {
|
||||
Prelease(ph);
|
||||
return;
|
||||
}
|
||||
JNF_COCOA_ENTER(env);
|
||||
if (debug) printf("detach0 called\n");
|
||||
|
||||
task_t gTask = getTask(env, this_obj);
|
||||
|
||||
// detach from the ptraced process causing it to resume execution
|
||||
@ -569,12 +815,12 @@ JNF_COCOA_ENTER(env);
|
||||
kern_return_t k_res;
|
||||
k_res = pid_for_task(gTask, &pid);
|
||||
if (k_res != KERN_SUCCESS) {
|
||||
fprintf(stderr, "detach: pid_for_task(%d) failed (%d)\n", pid, k_res);
|
||||
print_error("detach: pid_for_task(%d) failed (%d)\n", pid, k_res);
|
||||
}
|
||||
else {
|
||||
int res = ptrace(PT_DETACH, pid, 0, 0);
|
||||
if (res < 0) {
|
||||
fprintf(stderr, "detach: ptrace(PT_DETACH, %d) failed (%d)\n", pid, res);
|
||||
print_error("detach: ptrace(PT_DETACH, %d) failed (%d)\n", pid, res);
|
||||
}
|
||||
}
|
||||
|
||||
@ -585,170 +831,3 @@ JNF_COCOA_ENTER(env);
|
||||
}
|
||||
JNF_COCOA_EXIT(env);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: sun_jvm_hotspot_asm_Disassembler
|
||||
* Method: load_library
|
||||
* Signature: (Ljava/lang/String;)L
|
||||
*/
|
||||
JNIEXPORT jlong JNICALL
|
||||
Java_sun_jvm_hotspot_asm_Disassembler_load_1library(
|
||||
JNIEnv * env,
|
||||
jclass disclass,
|
||||
jstring jrepath_s,
|
||||
jstring libname_s)
|
||||
{
|
||||
uintptr_t func = 0;
|
||||
const char* error_message = NULL;
|
||||
const char* java_home;
|
||||
jboolean isCopy;
|
||||
uintptr_t *handle = NULL;
|
||||
|
||||
const char * jrepath = (*env)->GetStringUTFChars(env, jrepath_s, &isCopy); // like $JAVA_HOME/jre/lib/sparc/
|
||||
const char * libname = (*env)->GetStringUTFChars(env, libname_s, &isCopy);
|
||||
char buffer[128];
|
||||
|
||||
/* Load the hsdis library */
|
||||
void* hsdis_handle;
|
||||
hsdis_handle = dlopen(libname, RTLD_LAZY | RTLD_GLOBAL);
|
||||
if (hsdis_handle == NULL) {
|
||||
snprintf(buffer, sizeof(buffer), "%s%s", jrepath, libname);
|
||||
hsdis_handle = dlopen(buffer, RTLD_LAZY | RTLD_GLOBAL);
|
||||
}
|
||||
if (hsdis_handle != NULL) {
|
||||
func = (uintptr_t)dlsym(hsdis_handle, "decode_instructions_virtual");
|
||||
}
|
||||
if (func == 0) {
|
||||
error_message = dlerror();
|
||||
fprintf(stderr, "%s\n", error_message);
|
||||
}
|
||||
|
||||
(*env)->ReleaseStringUTFChars(env, libname_s, libname);
|
||||
(*env)->ReleaseStringUTFChars(env, jrepath_s, jrepath);
|
||||
|
||||
if (func == 0) {
|
||||
/* Couldn't find entry point. error_message should contain some
|
||||
* platform dependent error message.
|
||||
*/
|
||||
THROW_NEW_DEBUGGER_EXCEPTION_(error_message, (jlong)func);
|
||||
}
|
||||
return (jlong)func;
|
||||
}
|
||||
|
||||
/* signature of decode_instructions_virtual from hsdis.h */
|
||||
typedef void* (*decode_func)(uintptr_t start_va, uintptr_t end_va,
|
||||
unsigned char* start, uintptr_t length,
|
||||
void* (*event_callback)(void*, const char*, void*),
|
||||
void* event_stream,
|
||||
int (*printf_callback)(void*, const char*, ...),
|
||||
void* printf_stream,
|
||||
const char* options);
|
||||
|
||||
/* container for call back state when decoding instructions */
|
||||
typedef struct {
|
||||
JNIEnv* env;
|
||||
jobject dis;
|
||||
jobject visitor;
|
||||
jmethodID handle_event;
|
||||
jmethodID raw_print;
|
||||
char buffer[4096];
|
||||
} decode_env;
|
||||
|
||||
|
||||
/* event callback binding to Disassembler.handleEvent */
|
||||
static void* event_to_env(void* env_pv, const char* event, void* arg) {
|
||||
decode_env* denv = (decode_env*)env_pv;
|
||||
JNIEnv* env = denv->env;
|
||||
jstring event_string = (*env)->NewStringUTF(env, event);
|
||||
jlong result = (*env)->CallLongMethod(env, denv->dis, denv->handle_event, denv->visitor,
|
||||
event_string, (jlong) (uintptr_t)arg);
|
||||
/* ignore exceptions for now */
|
||||
CHECK_EXCEPTION_CLEAR_((void *)0);
|
||||
return (void*)(uintptr_t)result;
|
||||
}
|
||||
|
||||
/* printing callback binding to Disassembler.rawPrint */
|
||||
static int printf_to_env(void* env_pv, const char* format, ...) {
|
||||
jstring output;
|
||||
va_list ap;
|
||||
int cnt;
|
||||
decode_env* denv = (decode_env*)env_pv;
|
||||
JNIEnv* env = denv->env;
|
||||
size_t flen = strlen(format);
|
||||
const char* raw = NULL;
|
||||
|
||||
if (flen == 0) return 0;
|
||||
if (flen < 2 ||
|
||||
strchr(format, '%') == NULL) {
|
||||
raw = format;
|
||||
} else if (format[0] == '%' && format[1] == '%' &&
|
||||
strchr(format+2, '%') == NULL) {
|
||||
// happens a lot on machines with names like %foo
|
||||
flen--;
|
||||
raw = format+1;
|
||||
}
|
||||
if (raw != NULL) {
|
||||
jstring output = (*env)->NewStringUTF(env, raw);
|
||||
(*env)->CallVoidMethod(env, denv->dis, denv->raw_print, denv->visitor, output);
|
||||
CHECK_EXCEPTION_CLEAR;
|
||||
return (int) flen;
|
||||
}
|
||||
va_start(ap, format);
|
||||
cnt = vsnprintf(denv->buffer, sizeof(denv->buffer), format, ap);
|
||||
va_end(ap);
|
||||
|
||||
output = (*env)->NewStringUTF(env, denv->buffer);
|
||||
(*env)->CallVoidMethod(env, denv->dis, denv->raw_print, denv->visitor, output);
|
||||
CHECK_EXCEPTION_CLEAR;
|
||||
return cnt;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: sun_jvm_hotspot_asm_Disassembler
|
||||
* Method: decode
|
||||
* Signature: (Lsun/jvm/hotspot/asm/InstructionVisitor;J[BLjava/lang/String;J)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_sun_jvm_hotspot_asm_Disassembler_decode(
|
||||
JNIEnv * env,
|
||||
jobject dis,
|
||||
jobject visitor,
|
||||
jlong startPc,
|
||||
jbyteArray code,
|
||||
jstring options_s,
|
||||
jlong decode_instructions_virtual)
|
||||
{
|
||||
jboolean isCopy;
|
||||
jbyte* start = (*env)->GetByteArrayElements(env, code, &isCopy);
|
||||
jbyte* end = start + (*env)->GetArrayLength(env, code);
|
||||
const char * options = (*env)->GetStringUTFChars(env, options_s, &isCopy);
|
||||
jclass disclass = (*env)->GetObjectClass(env, dis);
|
||||
|
||||
decode_env denv;
|
||||
denv.env = env;
|
||||
denv.dis = dis;
|
||||
denv.visitor = visitor;
|
||||
|
||||
/* find Disassembler.handleEvent callback */
|
||||
denv.handle_event = (*env)->GetMethodID(env, disclass, "handleEvent",
|
||||
"(Lsun/jvm/hotspot/asm/InstructionVisitor;Ljava/lang/String;J)J");
|
||||
CHECK_EXCEPTION_CLEAR_VOID
|
||||
|
||||
/* find Disassembler.rawPrint callback */
|
||||
denv.raw_print = (*env)->GetMethodID(env, disclass, "rawPrint",
|
||||
"(Lsun/jvm/hotspot/asm/InstructionVisitor;Ljava/lang/String;)V");
|
||||
CHECK_EXCEPTION_CLEAR_VOID
|
||||
|
||||
/* decode the buffer */
|
||||
(*(decode_func)(uintptr_t)decode_instructions_virtual)(startPc,
|
||||
startPc + end - start,
|
||||
(unsigned char*)start,
|
||||
end - start,
|
||||
&event_to_env, (void*) &denv,
|
||||
&printf_to_env, (void*) &denv,
|
||||
options);
|
||||
|
||||
/* cleanup */
|
||||
(*env)->ReleaseByteArrayElements(env, code, start, JNI_ABORT);
|
||||
(*env)->ReleaseStringUTFChars(env, options_s, options);
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
#
|
||||
# Copyright (c) 2002, 2009, Oracle and/or its affiliates. All rights reserved.
|
||||
# Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
#
|
||||
# This code is free software; you can redistribute it and/or modify it
|
||||
@ -22,34 +22,60 @@
|
||||
#
|
||||
#
|
||||
|
||||
ARCH := $(shell if ([ `uname -m` = "ia64" ]) ; then echo ia64 ; elif ([ `uname -m` = "amd64" ]) ; then echo amd64; elif ([ `uname -m` = "sparc64" ]) ; then echo sparc; else echo i386 ; fi )
|
||||
ARCH := $(shell if ([ `uname -m` = "ia64" ]) ; then echo ia64 ; elif ([ `uname -m` = "amd64" ]) ; then echo amd64; elif ([ `uname -m` = "x86_64" ]) ; then echo amd64; elif ([ `uname -m` = "sparc64" ]) ; then echo sparc; else echo i386 ; fi )
|
||||
|
||||
OS := $(shell uname -s)
|
||||
|
||||
GCC = gcc
|
||||
|
||||
JAVAH = ${JAVA_HOME}/bin/javah
|
||||
|
||||
ifneq ($(OS), Darwin)
|
||||
SOURCES = salibelf.c \
|
||||
symtab.c \
|
||||
libproc_impl.c \
|
||||
ps_proc.c \
|
||||
ps_core.c \
|
||||
BsdDebuggerLocal.c
|
||||
|
||||
INCLUDES = -I${JAVA_HOME}/include -I${JAVA_HOME}/include/$(shell uname -s | tr "[:upper:]" "[:lower:]")
|
||||
|
||||
OBJS = $(SOURCES:.c=.o)
|
||||
OBJSPLUS = $(OBJS) sadis.o
|
||||
LIBSA = $(ARCH)/libsaproc.so
|
||||
|
||||
LIBS = -lutil -lthread_db
|
||||
|
||||
CFLAGS = -c -fPIC -g -Wall -D_ALLBSD_SOURCE -D_GNU_SOURCE -D$(ARCH) $(INCLUDES)
|
||||
else
|
||||
|
||||
SOURCES = symtab.c \
|
||||
libproc_impl.c \
|
||||
ps_core.c
|
||||
OBJS = $(SOURCES:.c=.o)
|
||||
OBJSPLUS = MacosxDebuggerLocal.o sadis.o $(OBJS)
|
||||
EXTINCLUDE = -I/System/Library/Frameworks/JavaVM.framework/Headers -I.
|
||||
EXTCFLAGS = -m64 -D__APPLE__ -framework JavaNativeFoundation
|
||||
FOUNDATIONFLAGS = -framework Foundation -F/System/Library/Frameworks/JavaVM.framework/Frameworks -framework JavaNativeFoundation -framework Security -framework CoreFoundation
|
||||
LIBSA = $(ARCH)/libsaproc.dylib
|
||||
endif # Darwin
|
||||
|
||||
INCLUDES = -I${JAVA_HOME}/include -I${JAVA_HOME}/include/$(shell uname -s | tr "[:upper:]" "[:lower:]") $(EXTINCLUDE)
|
||||
|
||||
|
||||
|
||||
CFLAGS = -c -fPIC -g -Wall -D_ALLBSD_SOURCE -D_GNU_SOURCE -D$(ARCH) $(INCLUDES) $(EXTCFLAGS)
|
||||
|
||||
|
||||
LIBSA = $(ARCH)/libsaproc.so
|
||||
|
||||
all: $(LIBSA)
|
||||
|
||||
BsdDebuggerLocal.o: BsdDebuggerLocal.c
|
||||
$(JAVAH) -jni -classpath ../../../../../build/bsd-i586/hotspot/outputdir/bsd_i486_compiler2/generated/saclasses \
|
||||
MacosxDebuggerLocal.o: MacosxDebuggerLocal.m
|
||||
echo "OS="$(OS)
|
||||
$(JAVAH) -jni -classpath ../../../build/classes \
|
||||
sun.jvm.hotspot.debugger.x86.X86ThreadContext \
|
||||
sun.jvm.hotspot.debugger.amd64.AMD64ThreadContext
|
||||
$(GCC) $(CFLAGS) $(FOUNDATIONFLAGS) $<
|
||||
|
||||
sadis.o: ../../share/native/sadis.c
|
||||
$(JAVAH) -jni -classpath ../../../build/classes \
|
||||
sun.jvm.hotspot.asm.Disassembler
|
||||
$(GCC) $(CFLAGS) $<
|
||||
|
||||
.c.obj:
|
||||
@ -59,9 +85,9 @@ ifndef LDNOMAP
|
||||
LFLAGS_LIBSA = -Xlinker --version-script=mapfile
|
||||
endif
|
||||
|
||||
$(LIBSA): $(OBJS) mapfile
|
||||
$(LIBSA): $(OBJSPLUS) mapfile
|
||||
if [ ! -d $(ARCH) ] ; then mkdir $(ARCH) ; fi
|
||||
$(GCC) -shared $(LFLAGS_LIBSA) -o $(LIBSA) $(OBJS) $(LIBS)
|
||||
$(GCC) -shared $(LFLAGS_LIBSA) -o $(LIBSA) $(FOUNDATIONFLAGS) $(OBJSPLUS) $(LIBS) $(SALIBS)
|
||||
|
||||
test.o: $(LIBSA) test.c
|
||||
$(GCC) -c -o test.o -g -D_GNU_SOURCE -D$(ARCH) $(INCLUDES) test.c
|
||||
@ -71,7 +97,6 @@ test: test.o
|
||||
|
||||
clean:
|
||||
rm -f $(LIBSA)
|
||||
rm -f $(OBJS)
|
||||
rm -f *.o
|
||||
rm -f test.o
|
||||
-rmdir $(ARCH)
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2007, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -27,9 +27,38 @@
|
||||
|
||||
#include <unistd.h>
|
||||
#include <stdint.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#ifdef __APPLE__
|
||||
typedef enum ps_err_e {
|
||||
PS_OK, PS_ERR, PS_BADPID, PS_BADLID,
|
||||
PS_BADADDR, PS_NOSYM, PS_NOFREGS
|
||||
} ps_err_e;
|
||||
|
||||
#ifndef psaddr_t
|
||||
#define psaddr_t uintptr_t
|
||||
#endif
|
||||
|
||||
#ifndef bool
|
||||
typedef int bool;
|
||||
#define true 1
|
||||
#define false 0
|
||||
#endif // bool
|
||||
|
||||
#ifndef lwpid_t
|
||||
#define lwpid_t uintptr_t
|
||||
#endif
|
||||
|
||||
#include <mach/thread_status.h>
|
||||
#else // __APPLE__
|
||||
#include <elf.h>
|
||||
#include <link.h>
|
||||
#include <machine/reg.h>
|
||||
#include <proc_service.h>
|
||||
|
||||
#if defined(sparc) || defined(sparcv9)
|
||||
/*
|
||||
If _LP64 is defined ptrace.h should be taken from /usr/include/asm-sparc64
|
||||
@ -44,6 +73,14 @@
|
||||
|
||||
#endif //sparc or sparcv9
|
||||
|
||||
// This C bool type must be int for compatibility with BSD calls and
|
||||
// it would be a mistake to equivalence it to C++ bool on many platforms
|
||||
typedef int bool;
|
||||
#define true 1
|
||||
#define false 0
|
||||
|
||||
#endif // __APPLE__
|
||||
|
||||
/************************************************************************************
|
||||
|
||||
0. This is very minimal subset of Solaris libproc just enough for current application.
|
||||
@ -72,13 +109,7 @@ combination of ptrace and /proc calls.
|
||||
|
||||
*************************************************************************************/
|
||||
|
||||
// This C bool type must be int for compatibility with BSD calls and
|
||||
// it would be a mistake to equivalence it to C++ bool on many platforms
|
||||
|
||||
typedef int bool;
|
||||
#define true 1
|
||||
#define false 0
|
||||
|
||||
struct reg;
|
||||
struct ps_prochandle;
|
||||
|
||||
// attach to a process
|
||||
|
@ -21,12 +21,6 @@
|
||||
* questions.
|
||||
*
|
||||
*/
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <fcntl.h>
|
||||
#include <thread_db.h>
|
||||
#include "libproc_impl.h"
|
||||
|
||||
static const char* alt_root = NULL;
|
||||
@ -34,6 +28,10 @@ static int alt_root_len = -1;
|
||||
|
||||
#define SA_ALTROOT "SA_ALTROOT"
|
||||
|
||||
off_t ltell(int fd) {
|
||||
return lseek(fd, 0, SEEK_CUR);
|
||||
}
|
||||
|
||||
static void init_alt_root() {
|
||||
if (alt_root_len == -1) {
|
||||
alt_root = getenv(SA_ALTROOT);
|
||||
@ -50,10 +48,6 @@ int pathmap_open(const char* name) {
|
||||
char alt_path[PATH_MAX + 1];
|
||||
|
||||
init_alt_root();
|
||||
fd = open(name, O_RDONLY);
|
||||
if (fd >= 0) {
|
||||
return fd;
|
||||
}
|
||||
|
||||
if (alt_root_len > 0) {
|
||||
strcpy(alt_path, alt_root);
|
||||
@ -73,8 +67,12 @@ int pathmap_open(const char* name) {
|
||||
return fd;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
fd = open(name, O_RDONLY);
|
||||
if (fd >= 0) {
|
||||
return fd;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -103,21 +101,78 @@ bool is_debug() {
|
||||
return _libsaproc_debug;
|
||||
}
|
||||
|
||||
#ifdef __APPLE__
|
||||
// get arch offset in file
|
||||
bool get_arch_off(int fd, cpu_type_t cputype, off_t *offset) {
|
||||
struct fat_header fatheader;
|
||||
struct fat_arch fatarch;
|
||||
off_t img_start = 0;
|
||||
|
||||
off_t pos = ltell(fd);
|
||||
if (read(fd, (void *)&fatheader, sizeof(struct fat_header)) != sizeof(struct fat_header)) {
|
||||
return false;
|
||||
}
|
||||
if (fatheader.magic == FAT_CIGAM) {
|
||||
int i;
|
||||
for (i = 0; i < ntohl(fatheader.nfat_arch); i++) {
|
||||
if (read(fd, (void *)&fatarch, sizeof(struct fat_arch)) != sizeof(struct fat_arch)) {
|
||||
return false;
|
||||
}
|
||||
if (ntohl(fatarch.cputype) == cputype) {
|
||||
print_debug("fat offset=%x\n", ntohl(fatarch.offset));
|
||||
img_start = ntohl(fatarch.offset);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (img_start == 0) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
lseek(fd, pos, SEEK_SET);
|
||||
*offset = img_start;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool is_macho_file(int fd) {
|
||||
mach_header_64 fhdr;
|
||||
off_t x86_64_off;
|
||||
|
||||
if (fd < 0) {
|
||||
print_debug("Invalid file handle passed to is_macho_file\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
off_t pos = ltell(fd);
|
||||
// check fat header
|
||||
if (!get_arch_off(fd, CPU_TYPE_X86_64, &x86_64_off)) {
|
||||
print_debug("failed to get fat header\n");
|
||||
return false;
|
||||
}
|
||||
lseek(fd, x86_64_off, SEEK_SET);
|
||||
if (read(fd, (void *)&fhdr, sizeof(mach_header_64)) != sizeof(mach_header_64)) {
|
||||
return false;
|
||||
}
|
||||
lseek(fd, pos, SEEK_SET); // restore
|
||||
print_debug("fhdr.magic %x\n", fhdr.magic);
|
||||
return (fhdr.magic == MH_MAGIC_64 || fhdr.magic == MH_CIGAM_64);
|
||||
}
|
||||
|
||||
#endif //__APPLE__
|
||||
|
||||
// initialize libproc
|
||||
bool init_libproc(bool debug) {
|
||||
// init debug mode
|
||||
_libsaproc_debug = debug;
|
||||
|
||||
#ifndef __APPLE__
|
||||
// initialize the thread_db library
|
||||
if (td_init() != TD_OK) {
|
||||
print_debug("libthread_db's td_init failed\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
#endif // __APPLE__
|
||||
return true;
|
||||
}
|
||||
|
||||
static void destroy_lib_info(struct ps_prochandle* ph) {
|
||||
void destroy_lib_info(struct ps_prochandle* ph) {
|
||||
lib_info* lib = ph->libs;
|
||||
while (lib) {
|
||||
lib_info* next = lib->next;
|
||||
@ -129,17 +184,15 @@ static void destroy_lib_info(struct ps_prochandle* ph) {
|
||||
}
|
||||
}
|
||||
|
||||
static void destroy_thread_info(struct ps_prochandle* ph) {
|
||||
thread_info* thr = ph->threads;
|
||||
void destroy_thread_info(struct ps_prochandle* ph) {
|
||||
sa_thread_info* thr = ph->threads;
|
||||
while (thr) {
|
||||
thread_info *next = thr->next;
|
||||
sa_thread_info* n = thr->next;
|
||||
free(thr);
|
||||
thr = next;
|
||||
thr = n;
|
||||
}
|
||||
}
|
||||
|
||||
// ps_prochandle cleanup
|
||||
|
||||
// ps_prochandle cleanup
|
||||
void Prelease(struct ps_prochandle* ph) {
|
||||
// do the "derived class" clean-up first
|
||||
@ -155,6 +208,7 @@ lib_info* add_lib_info(struct ps_prochandle* ph, const char* libname, uintptr_t
|
||||
|
||||
lib_info* add_lib_info_fd(struct ps_prochandle* ph, const char* libname, int fd, uintptr_t base) {
|
||||
lib_info* newlib;
|
||||
print_debug("add_lib_info_fd %s\n", libname);
|
||||
|
||||
if ( (newlib = (lib_info*) calloc(1, sizeof(struct lib_info))) == NULL) {
|
||||
print_debug("can't allocate memory for lib_info\n");
|
||||
@ -174,6 +228,15 @@ lib_info* add_lib_info_fd(struct ps_prochandle* ph, const char* libname, int fd,
|
||||
newlib->fd = fd;
|
||||
}
|
||||
|
||||
#ifdef __APPLE__
|
||||
// check whether we have got an Macho file.
|
||||
if (is_macho_file(newlib->fd) == false) {
|
||||
close(newlib->fd);
|
||||
free(newlib);
|
||||
print_debug("not a mach-o file\n");
|
||||
return NULL;
|
||||
}
|
||||
#else
|
||||
// check whether we have got an ELF file. /proc/<pid>/map
|
||||
// gives out all file mappings and not just shared objects
|
||||
if (is_elf_file(newlib->fd) == false) {
|
||||
@ -181,17 +244,17 @@ lib_info* add_lib_info_fd(struct ps_prochandle* ph, const char* libname, int fd,
|
||||
free(newlib);
|
||||
return NULL;
|
||||
}
|
||||
#endif // __APPLE__
|
||||
|
||||
newlib->symtab = build_symtab(newlib->fd);
|
||||
if (newlib->symtab == NULL) {
|
||||
print_debug("symbol table build failed for %s\n", newlib->name);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
print_debug("built symbol table for %s\n", newlib->name);
|
||||
}
|
||||
|
||||
// even if symbol table building fails, we add the lib_info.
|
||||
// This is because we may need to read from the ELF file for core file
|
||||
// This is because we may need to read from the ELF file or MachO file for core file
|
||||
// address read functionality. lookup_symbol checks for NULL symtab.
|
||||
if (ph->libs) {
|
||||
ph->lib_tail->next = newlib;
|
||||
@ -200,7 +263,6 @@ lib_info* add_lib_info_fd(struct ps_prochandle* ph, const char* libname, int fd,
|
||||
ph->libs = ph->lib_tail = newlib;
|
||||
}
|
||||
ph->num_libs++;
|
||||
|
||||
return newlib;
|
||||
}
|
||||
|
||||
@ -228,7 +290,6 @@ uintptr_t lookup_symbol(struct ps_prochandle* ph, const char* object_name,
|
||||
return (uintptr_t) NULL;
|
||||
}
|
||||
|
||||
|
||||
const char* symbol_for_pc(struct ps_prochandle* ph, uintptr_t addr, uintptr_t* poffset) {
|
||||
const char* res = NULL;
|
||||
lib_info* lib = ph->libs;
|
||||
@ -243,9 +304,9 @@ const char* symbol_for_pc(struct ps_prochandle* ph, uintptr_t addr, uintptr_t* p
|
||||
}
|
||||
|
||||
// add a thread to ps_prochandle
|
||||
thread_info* add_thread_info(struct ps_prochandle* ph, pthread_t pthread_id, lwpid_t lwp_id) {
|
||||
thread_info* newthr;
|
||||
if ( (newthr = (thread_info*) calloc(1, sizeof(thread_info))) == NULL) {
|
||||
sa_thread_info* add_thread_info(struct ps_prochandle* ph, pthread_t pthread_id, lwpid_t lwp_id) {
|
||||
sa_thread_info* newthr;
|
||||
if ( (newthr = (sa_thread_info*) calloc(1, sizeof(sa_thread_info))) == NULL) {
|
||||
print_debug("can't allocate memory for thread_info\n");
|
||||
return NULL;
|
||||
}
|
||||
@ -261,7 +322,7 @@ thread_info* add_thread_info(struct ps_prochandle* ph, pthread_t pthread_id, lwp
|
||||
return newthr;
|
||||
}
|
||||
|
||||
|
||||
#ifndef __APPLE__
|
||||
// struct used for client data from thread_db callback
|
||||
struct thread_db_client_data {
|
||||
struct ps_prochandle* ph;
|
||||
@ -314,6 +375,7 @@ bool read_thread_info(struct ps_prochandle* ph, thread_info_callback cb) {
|
||||
return true;
|
||||
}
|
||||
|
||||
#endif // __APPLE__
|
||||
|
||||
// get number of threads
|
||||
int get_num_threads(struct ps_prochandle* ph) {
|
||||
@ -323,7 +385,7 @@ int get_num_threads(struct ps_prochandle* ph) {
|
||||
// get lwp_id of n'th thread
|
||||
lwpid_t get_lwp_id(struct ps_prochandle* ph, int index) {
|
||||
int count = 0;
|
||||
thread_info* thr = ph->threads;
|
||||
sa_thread_info* thr = ph->threads;
|
||||
while (thr) {
|
||||
if (count == index) {
|
||||
return thr->lwp_id;
|
||||
@ -331,9 +393,45 @@ lwpid_t get_lwp_id(struct ps_prochandle* ph, int index) {
|
||||
count++;
|
||||
thr = thr->next;
|
||||
}
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef __APPLE__
|
||||
// set lwp_id of n'th thread
|
||||
bool set_lwp_id(struct ps_prochandle* ph, int index, lwpid_t lwpid) {
|
||||
int count = 0;
|
||||
sa_thread_info* thr = ph->threads;
|
||||
while (thr) {
|
||||
if (count == index) {
|
||||
thr->lwp_id = lwpid;
|
||||
return true;
|
||||
}
|
||||
count++;
|
||||
thr = thr->next;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// get regs of n-th thread, only used in fillThreads the first time called
|
||||
bool get_nth_lwp_regs(struct ps_prochandle* ph, int index, struct reg* regs) {
|
||||
int count = 0;
|
||||
sa_thread_info* thr = ph->threads;
|
||||
while (thr) {
|
||||
if (count == index) {
|
||||
break;
|
||||
}
|
||||
count++;
|
||||
thr = thr->next;
|
||||
}
|
||||
if (thr != NULL) {
|
||||
memcpy(regs, &thr->regs, sizeof(struct reg));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
#endif // __APPLE__
|
||||
|
||||
// get regs for a given lwp
|
||||
bool get_lwp_regs(struct ps_prochandle* ph, lwpid_t lwp_id, struct reg* regs) {
|
||||
return ph->ops->get_lwp_regs(ph, lwp_id, regs);
|
||||
@ -425,6 +523,7 @@ ps_plog (const char *format, ...)
|
||||
va_end(alist);
|
||||
}
|
||||
|
||||
#ifndef __APPLE__
|
||||
// ------------------------------------------------------------------------
|
||||
// Functions below this point are not yet implemented. They are here only
|
||||
// to make the linker happy.
|
||||
@ -458,3 +557,4 @@ ps_err_e ps_pcontinue(struct ps_prochandle *ph) {
|
||||
print_debug("ps_pcontinue not implemented\n");
|
||||
return PS_OK;
|
||||
}
|
||||
#endif // __APPLE__
|
||||
|
@ -30,6 +30,60 @@
|
||||
#include "libproc.h"
|
||||
#include "symtab.h"
|
||||
|
||||
#ifdef __APPLE__
|
||||
#include <inttypes.h> // for PRIx64, 32, ...
|
||||
#include <pthread.h>
|
||||
#include <mach-o/loader.h>
|
||||
#include <mach-o/nlist.h>
|
||||
#include <mach-o/fat.h>
|
||||
|
||||
#ifndef register_t
|
||||
#define register_t uint64_t
|
||||
#endif
|
||||
|
||||
/*** registers copied from bsd/amd64 */
|
||||
typedef struct reg {
|
||||
register_t r_r15;
|
||||
register_t r_r14;
|
||||
register_t r_r13;
|
||||
register_t r_r12;
|
||||
register_t r_r11;
|
||||
register_t r_r10;
|
||||
register_t r_r9;
|
||||
register_t r_r8;
|
||||
register_t r_rdi;
|
||||
register_t r_rsi;
|
||||
register_t r_rbp;
|
||||
register_t r_rbx;
|
||||
register_t r_rdx;
|
||||
register_t r_rcx;
|
||||
register_t r_rax;
|
||||
uint32_t r_trapno; // not used
|
||||
uint16_t r_fs;
|
||||
uint16_t r_gs;
|
||||
uint32_t r_err; // not used
|
||||
uint16_t r_es; // not used
|
||||
uint16_t r_ds; // not used
|
||||
register_t r_rip;
|
||||
register_t r_cs;
|
||||
register_t r_rflags;
|
||||
register_t r_rsp;
|
||||
register_t r_ss; // not used
|
||||
} reg;
|
||||
|
||||
// convenient defs
|
||||
typedef struct mach_header_64 mach_header_64;
|
||||
typedef struct load_command load_command;
|
||||
typedef struct segment_command_64 segment_command_64;
|
||||
typedef struct thread_command thread_command;
|
||||
typedef struct dylib_command dylib_command;
|
||||
typedef struct symtab_command symtab_command;
|
||||
typedef struct nlist_64 nlist_64;
|
||||
#else
|
||||
#include <thread_db.h>
|
||||
#include "salibelf.h"
|
||||
#endif // __APPLE__
|
||||
|
||||
// data structures in this file mimic those of Solaris 8.0 - libproc's Pcontrol.h
|
||||
|
||||
#define BUF_SIZE (PATH_MAX + NAME_MAX + 1)
|
||||
@ -44,12 +98,12 @@ typedef struct lib_info {
|
||||
} lib_info;
|
||||
|
||||
// list of threads
|
||||
typedef struct thread_info {
|
||||
lwpid_t lwp_id;
|
||||
pthread_t pthread_id; // not used cores, always -1
|
||||
typedef struct sa_thread_info {
|
||||
lwpid_t lwp_id; // same as pthread_t
|
||||
pthread_t pthread_id; //
|
||||
struct reg regs; // not for process, core uses for caching regset
|
||||
struct thread_info* next;
|
||||
} thread_info;
|
||||
struct sa_thread_info* next;
|
||||
} sa_thread_info;
|
||||
|
||||
// list of virtual memory maps
|
||||
typedef struct map_info {
|
||||
@ -91,6 +145,7 @@ struct core_data {
|
||||
// part of the class sharing workaround
|
||||
map_info* class_share_maps;// class share maps in a linked list
|
||||
map_info** map_array; // sorted (by vaddr) array of map_info pointers
|
||||
char exec_path[4096]; // file name java
|
||||
};
|
||||
|
||||
struct ps_prochandle {
|
||||
@ -100,12 +155,11 @@ struct ps_prochandle {
|
||||
lib_info* libs; // head of lib list
|
||||
lib_info* lib_tail; // tail of lib list - to append at the end
|
||||
int num_threads;
|
||||
thread_info* threads; // head of thread list
|
||||
sa_thread_info* threads; // head of thread list
|
||||
struct core_data* core; // data only used for core dumps, NULL for process
|
||||
};
|
||||
|
||||
int pathmap_open(const char* name);
|
||||
|
||||
void print_debug(const char* format,...);
|
||||
void print_error(const char* format,...);
|
||||
bool is_debug();
|
||||
@ -122,10 +176,45 @@ lib_info* add_lib_info(struct ps_prochandle* ph, const char* libname, uintptr_t
|
||||
lib_info* add_lib_info_fd(struct ps_prochandle* ph, const char* libname, int fd,
|
||||
uintptr_t base);
|
||||
|
||||
// adds a new thread to threads list, returns NULL on failure
|
||||
thread_info* add_thread_info(struct ps_prochandle* ph, pthread_t pthread_id, lwpid_t lwp_id);
|
||||
|
||||
sa_thread_info* add_thread_info(struct ps_prochandle* ph, pthread_t pthread_id, lwpid_t lwp_id);
|
||||
// a test for ELF signature without using libelf
|
||||
bool is_elf_file(int fd);
|
||||
|
||||
#ifdef __APPLE__
|
||||
// a test for Mach-O signature
|
||||
bool is_macho_file(int fd);
|
||||
// skip fat head to get image start offset of cpu_type_t
|
||||
// return false if any error happens, else value in offset.
|
||||
bool get_arch_off(int fd, cpu_type_t cputype, off_t *offset);
|
||||
#else
|
||||
bool is_elf_file(int fd);
|
||||
#endif // __APPLE__
|
||||
|
||||
lwpid_t get_lwp_id(struct ps_prochandle* ph, int index);
|
||||
bool set_lwp_id(struct ps_prochandle* ph, int index, lwpid_t lwpid);
|
||||
bool get_nth_lwp_regs(struct ps_prochandle* ph, int index, struct reg* regs);
|
||||
|
||||
// ps_pglobal_lookup() looks up the symbol sym_name in the symbol table
|
||||
// of the load object object_name in the target process identified by ph.
|
||||
// It returns the symbol's value as an address in the target process in
|
||||
// *sym_addr.
|
||||
|
||||
ps_err_e ps_pglobal_lookup(struct ps_prochandle *ph, const char *object_name,
|
||||
const char *sym_name, psaddr_t *sym_addr);
|
||||
|
||||
// read "size" bytes info "buf" from address "addr"
|
||||
ps_err_e ps_pread(struct ps_prochandle *ph, psaddr_t addr,
|
||||
void *buf, size_t size);
|
||||
|
||||
// write "size" bytes of data to debuggee at address "addr"
|
||||
ps_err_e ps_pwrite(struct ps_prochandle *ph, psaddr_t addr,
|
||||
const void *buf, size_t size);
|
||||
|
||||
// fill in ptrace_lwpinfo for lid
|
||||
ps_err_e ps_linfo(struct ps_prochandle *ph, lwpid_t lwp_id, void *linfo);
|
||||
|
||||
// needed for when libthread_db is compiled with TD_DEBUG defined
|
||||
void ps_plog (const char *format, ...);
|
||||
|
||||
// untility, tells the position in file
|
||||
off_t ltell(int fd);
|
||||
#endif //_LIBPROC_IMPL_H_
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -28,10 +28,11 @@
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <stddef.h>
|
||||
#include <elf.h>
|
||||
#include <link.h>
|
||||
#include "libproc_impl.h"
|
||||
#include "salibelf.h"
|
||||
|
||||
#ifdef __APPLE__
|
||||
#include "sun_jvm_hotspot_debugger_amd64_AMD64ThreadContext.h"
|
||||
#endif
|
||||
|
||||
// This file has the libproc implementation to read core files.
|
||||
// For live processes, refer to ps_proc.c. Portions of this is adapted
|
||||
@ -41,9 +42,8 @@
|
||||
// ps_prochandle cleanup helper functions
|
||||
|
||||
// close all file descriptors
|
||||
static void close_elf_files(struct ps_prochandle* ph) {
|
||||
static void close_files(struct ps_prochandle* ph) {
|
||||
lib_info* lib = NULL;
|
||||
|
||||
// close core file descriptor
|
||||
if (ph->core->core_fd >= 0)
|
||||
close(ph->core->core_fd);
|
||||
@ -64,7 +64,9 @@ static void close_elf_files(struct ps_prochandle* ph) {
|
||||
lib = ph->libs;
|
||||
while (lib) {
|
||||
int fd = lib->fd;
|
||||
if (fd >= 0 && fd != ph->core->exec_fd) close(fd);
|
||||
if (fd >= 0 && fd != ph->core->exec_fd) {
|
||||
close(fd);
|
||||
}
|
||||
lib = lib->next;
|
||||
}
|
||||
}
|
||||
@ -94,7 +96,7 @@ static void destroy_map_info(struct ps_prochandle* ph) {
|
||||
// ps_prochandle operations
|
||||
static void core_release(struct ps_prochandle* ph) {
|
||||
if (ph->core) {
|
||||
close_elf_files(ph);
|
||||
close_files(ph);
|
||||
destroy_map_info(ph);
|
||||
free(ph->core);
|
||||
}
|
||||
@ -154,19 +156,22 @@ static map_info* core_lookup(struct ps_prochandle *ph, uintptr_t addr)
|
||||
|
||||
while (hi - lo > 1) {
|
||||
mid = (lo + hi) / 2;
|
||||
if (addr >= ph->core->map_array[mid]->vaddr)
|
||||
if (addr >= ph->core->map_array[mid]->vaddr) {
|
||||
lo = mid;
|
||||
else
|
||||
} else {
|
||||
hi = mid;
|
||||
}
|
||||
}
|
||||
|
||||
if (addr < ph->core->map_array[hi]->vaddr)
|
||||
if (addr < ph->core->map_array[hi]->vaddr) {
|
||||
mp = ph->core->map_array[lo];
|
||||
else
|
||||
} else {
|
||||
mp = ph->core->map_array[hi];
|
||||
}
|
||||
|
||||
if (addr >= mp->vaddr && addr < mp->vaddr + mp->memsz)
|
||||
if (addr >= mp->vaddr && addr < mp->vaddr + mp->memsz) {
|
||||
return (mp);
|
||||
}
|
||||
|
||||
|
||||
// Part of the class sharing workaround
|
||||
@ -177,13 +182,11 @@ static map_info* core_lookup(struct ps_prochandle *ph, uintptr_t addr)
|
||||
// want to prefer class sharing data to data from core.
|
||||
mp = ph->core->class_share_maps;
|
||||
if (mp) {
|
||||
print_debug("can't locate map_info at 0x%lx, trying class share maps\n",
|
||||
addr);
|
||||
print_debug("can't locate map_info at 0x%lx, trying class share maps\n", addr);
|
||||
}
|
||||
while (mp) {
|
||||
if (addr >= mp->vaddr && addr < mp->vaddr + mp->memsz) {
|
||||
print_debug("located map_info at 0x%lx from class share maps\n",
|
||||
addr);
|
||||
print_debug("located map_info at 0x%lx from class share maps\n", addr);
|
||||
return (mp);
|
||||
}
|
||||
mp = mp->next;
|
||||
@ -250,7 +253,7 @@ static bool read_jboolean(struct ps_prochandle* ph, uintptr_t addr, jboolean* pv
|
||||
|
||||
static bool read_pointer(struct ps_prochandle* ph, uintptr_t addr, uintptr_t* pvalue) {
|
||||
uintptr_t uip;
|
||||
if (ps_pread(ph, (psaddr_t) addr, &uip, sizeof(uip)) == PS_OK) {
|
||||
if (ps_pread(ph, (psaddr_t) addr, (char *)&uip, sizeof(uip)) == PS_OK) {
|
||||
*pvalue = uip;
|
||||
return true;
|
||||
} else {
|
||||
@ -264,35 +267,50 @@ static bool read_string(struct ps_prochandle* ph, uintptr_t addr, char* buf, siz
|
||||
char c = ' ';
|
||||
|
||||
while (c != '\0') {
|
||||
if (ps_pread(ph, (psaddr_t) addr, &c, sizeof(char)) != PS_OK)
|
||||
if (ps_pread(ph, (psaddr_t) addr, &c, sizeof(char)) != PS_OK) {
|
||||
return false;
|
||||
if (i < size - 1)
|
||||
}
|
||||
if (i < size - 1) {
|
||||
buf[i] = c;
|
||||
else // smaller buffer
|
||||
} else {
|
||||
// smaller buffer
|
||||
return false;
|
||||
}
|
||||
i++; addr++;
|
||||
}
|
||||
|
||||
buf[i] = '\0';
|
||||
return true;
|
||||
}
|
||||
|
||||
#define USE_SHARED_SPACES_SYM "UseSharedSpaces"
|
||||
#ifdef __APPLE__
|
||||
#define USE_SHARED_SPACES_SYM "_UseSharedSpaces"
|
||||
// mangled name of Arguments::SharedArchivePath
|
||||
#define SHARED_ARCHIVE_PATH_SYM "_ZN9Arguments17SharedArchivePathE"
|
||||
#else
|
||||
#define USE_SHARED_SPACES_SYM "UseSharedSpaces"
|
||||
// mangled name of Arguments::SharedArchivePath
|
||||
#define SHARED_ARCHIVE_PATH_SYM "__ZN9Arguments17SharedArchivePathE"
|
||||
#endif // __APPLE_
|
||||
|
||||
static bool init_classsharing_workaround(struct ps_prochandle* ph) {
|
||||
int m;
|
||||
size_t n;
|
||||
lib_info* lib = ph->libs;
|
||||
while (lib != NULL) {
|
||||
// we are iterating over shared objects from the core dump. look for
|
||||
// libjvm[_g].so.
|
||||
const char *jvm_name = 0;
|
||||
#ifdef __APPLE__
|
||||
if ((jvm_name = strstr(lib->name, "/libjvm.dylib")) != 0 ||
|
||||
(jvm_name = strstr(lib->name, "/libjvm_g.dylib")) != 0)
|
||||
#else
|
||||
if ((jvm_name = strstr(lib->name, "/libjvm.so")) != 0 ||
|
||||
(jvm_name = strstr(lib->name, "/libjvm_g.so")) != 0) {
|
||||
(jvm_name = strstr(lib->name, "/libjvm_g.so")) != 0)
|
||||
#endif // __APPLE__
|
||||
{
|
||||
char classes_jsa[PATH_MAX];
|
||||
struct FileMapHeader header;
|
||||
size_t n = 0;
|
||||
int fd = -1, m = 0;
|
||||
int fd = -1;
|
||||
uintptr_t base = 0, useSharedSpacesAddr = 0;
|
||||
uintptr_t sharedArchivePathAddrAddr = 0, sharedArchivePathAddr = 0;
|
||||
jboolean useSharedSpaces = 0;
|
||||
@ -389,7 +407,6 @@ static bool init_classsharing_workaround(struct ps_prochandle* ph) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// functions to handle map_info
|
||||
|
||||
@ -400,8 +417,9 @@ static int core_cmp_mapping(const void *lhsp, const void *rhsp)
|
||||
const map_info *lhs = *((const map_info **)lhsp);
|
||||
const map_info *rhs = *((const map_info **)rhsp);
|
||||
|
||||
if (lhs->vaddr == rhs->vaddr)
|
||||
if (lhs->vaddr == rhs->vaddr) {
|
||||
return (0);
|
||||
}
|
||||
|
||||
return (lhs->vaddr < rhs->vaddr ? -1 : 1);
|
||||
}
|
||||
@ -428,7 +446,9 @@ static bool sort_map_array(struct ps_prochandle* ph) {
|
||||
}
|
||||
|
||||
// sort is called twice. If this is second time, clear map array
|
||||
if (ph->core->map_array) free(ph->core->map_array);
|
||||
if (ph->core->map_array) {
|
||||
free(ph->core->map_array);
|
||||
}
|
||||
ph->core->map_array = array;
|
||||
// sort the map_info array by base virtual address.
|
||||
qsort(ph->core->map_array, ph->core->num_maps, sizeof (map_info*),
|
||||
@ -461,16 +481,18 @@ static bool core_read_data(struct ps_prochandle* ph, uintptr_t addr, char *buf,
|
||||
off_t off;
|
||||
int fd;
|
||||
|
||||
if (mp == NULL)
|
||||
if (mp == NULL) {
|
||||
break; /* No mapping for this address */
|
||||
}
|
||||
|
||||
fd = mp->fd;
|
||||
mapoff = addr - mp->vaddr;
|
||||
len = MIN(resid, mp->memsz - mapoff);
|
||||
off = mp->offset + mapoff;
|
||||
|
||||
if ((len = pread(fd, buf, len, off)) <= 0)
|
||||
if ((len = pread(fd, buf, len, off)) <= 0) {
|
||||
break;
|
||||
}
|
||||
|
||||
resid -= len;
|
||||
addr += len;
|
||||
@ -507,8 +529,8 @@ static bool core_write_data(struct ps_prochandle* ph,
|
||||
|
||||
static bool core_get_lwp_regs(struct ps_prochandle* ph, lwpid_t lwp_id,
|
||||
struct reg* regs) {
|
||||
// for core we have cached the lwp regs from NOTE section
|
||||
thread_info* thr = ph->threads;
|
||||
// for core we have cached the lwp regs after segment parsed
|
||||
sa_thread_info* thr = ph->threads;
|
||||
while (thr) {
|
||||
if (thr->lwp_id == lwp_id) {
|
||||
memcpy(regs, &thr->regs, sizeof(struct reg));
|
||||
@ -519,7 +541,7 @@ static bool core_get_lwp_regs(struct ps_prochandle* ph, lwpid_t lwp_id,
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool core_get_lwp_info(struct ps_prochandle *ph, lwpid_t lwp_id, void *linfo) {
|
||||
static bool core_get_lwp_info(struct ps_prochandle *ph, lwpid_t id, void *info) {
|
||||
print_debug("core_get_lwp_info not implemented\n");
|
||||
return false;
|
||||
}
|
||||
@ -532,12 +554,451 @@ static ps_prochandle_ops core_ops = {
|
||||
.get_lwp_info= core_get_lwp_info
|
||||
};
|
||||
|
||||
// read regs and create thread from NT_PRSTATUS entries from core file
|
||||
// from this point, mainly two blocks divided by def __APPLE__
|
||||
// one for Macosx, the other for regular Bsd
|
||||
|
||||
#ifdef __APPLE__
|
||||
|
||||
void print_thread(sa_thread_info *threadinfo) {
|
||||
print_debug("thread added: %d\n", threadinfo->lwp_id);
|
||||
print_debug("registers:\n");
|
||||
print_debug(" r_r15: 0x%" PRIx64 "\n", threadinfo->regs.r_r15);
|
||||
print_debug(" r_r14: 0x%" PRIx64 "\n", threadinfo->regs.r_r14);
|
||||
print_debug(" r_r13: 0x%" PRIx64 "\n", threadinfo->regs.r_r13);
|
||||
print_debug(" r_r12: 0x%" PRIx64 "\n", threadinfo->regs.r_r12);
|
||||
print_debug(" r_r11: 0x%" PRIx64 "\n", threadinfo->regs.r_r11);
|
||||
print_debug(" r_r10: 0x%" PRIx64 "\n", threadinfo->regs.r_r10);
|
||||
print_debug(" r_r9: 0x%" PRIx64 "\n", threadinfo->regs.r_r9);
|
||||
print_debug(" r_r8: 0x%" PRIx64 "\n", threadinfo->regs.r_r8);
|
||||
print_debug(" r_rdi: 0x%" PRIx64 "\n", threadinfo->regs.r_rdi);
|
||||
print_debug(" r_rsi: 0x%" PRIx64 "\n", threadinfo->regs.r_rsi);
|
||||
print_debug(" r_rbp: 0x%" PRIx64 "\n", threadinfo->regs.r_rbp);
|
||||
print_debug(" r_rbx: 0x%" PRIx64 "\n", threadinfo->regs.r_rbx);
|
||||
print_debug(" r_rdx: 0x%" PRIx64 "\n", threadinfo->regs.r_rdx);
|
||||
print_debug(" r_rcx: 0x%" PRIx64 "\n", threadinfo->regs.r_rcx);
|
||||
print_debug(" r_rax: 0x%" PRIx64 "\n", threadinfo->regs.r_rax);
|
||||
print_debug(" r_fs: 0x%" PRIx32 "\n", threadinfo->regs.r_fs);
|
||||
print_debug(" r_gs: 0x%" PRIx32 "\n", threadinfo->regs.r_gs);
|
||||
print_debug(" r_rip 0x%" PRIx64 "\n", threadinfo->regs.r_rip);
|
||||
print_debug(" r_cs: 0x%" PRIx64 "\n", threadinfo->regs.r_cs);
|
||||
print_debug(" r_rsp: 0x%" PRIx64 "\n", threadinfo->regs.r_rsp);
|
||||
print_debug(" r_rflags: 0x%" PRIx64 "\n", threadinfo->regs.r_rflags);
|
||||
}
|
||||
|
||||
// read all segments64 commands from core file
|
||||
// read all thread commands from core file
|
||||
static bool read_core_segments(struct ps_prochandle* ph) {
|
||||
int i = 0;
|
||||
int num_threads = 0;
|
||||
int fd = ph->core->core_fd;
|
||||
off_t offset = 0;
|
||||
mach_header_64 fhead;
|
||||
load_command lcmd;
|
||||
segment_command_64 segcmd;
|
||||
// thread_command thrcmd;
|
||||
|
||||
lseek(fd, offset, SEEK_SET);
|
||||
if(read(fd, (void *)&fhead, sizeof(mach_header_64)) != sizeof(mach_header_64)) {
|
||||
goto err;
|
||||
}
|
||||
print_debug("total commands: %d\n", fhead.ncmds);
|
||||
offset += sizeof(mach_header_64);
|
||||
for (i = 0; i < fhead.ncmds; i++) {
|
||||
lseek(fd, offset, SEEK_SET);
|
||||
if (read(fd, (void *)&lcmd, sizeof(load_command)) != sizeof(load_command)) {
|
||||
goto err;
|
||||
}
|
||||
offset += lcmd.cmdsize; // next command position
|
||||
if (lcmd.cmd == LC_SEGMENT_64) {
|
||||
lseek(fd, -sizeof(load_command), SEEK_CUR);
|
||||
if (read(fd, (void *)&segcmd, sizeof(segment_command_64)) != sizeof(segment_command_64)) {
|
||||
print_debug("failed to read LC_SEGMENT_64 i = %d!\n", i);
|
||||
goto err;
|
||||
}
|
||||
if (add_map_info(ph, fd, segcmd.fileoff, segcmd.vmaddr, segcmd.vmsize) == NULL) {
|
||||
print_debug("Failed to add map_info at i = %d\n", i);
|
||||
goto err;
|
||||
}
|
||||
print_debug("segment added: %" PRIu64 " 0x%" PRIx64 " %d\n",
|
||||
segcmd.fileoff, segcmd.vmaddr, segcmd.vmsize);
|
||||
} else if (lcmd.cmd == LC_THREAD || lcmd.cmd == LC_UNIXTHREAD) {
|
||||
typedef struct thread_fc {
|
||||
uint32_t flavor;
|
||||
uint32_t count;
|
||||
} thread_fc;
|
||||
thread_fc fc;
|
||||
uint32_t size = sizeof(load_command);
|
||||
while (size < lcmd.cmdsize) {
|
||||
if (read(fd, (void *)&fc, sizeof(thread_fc)) != sizeof(thread_fc)) {
|
||||
printf("Reading flavor, count failed.\n");
|
||||
goto err;
|
||||
}
|
||||
size += sizeof(thread_fc);
|
||||
if (fc.flavor == x86_THREAD_STATE) {
|
||||
x86_thread_state_t thrstate;
|
||||
if (read(fd, (void *)&thrstate, sizeof(x86_thread_state_t)) != sizeof(x86_thread_state_t)) {
|
||||
printf("Reading flavor, count failed.\n");
|
||||
goto err;
|
||||
}
|
||||
size += sizeof(x86_thread_state_t);
|
||||
// create thread info list, update lwp_id later
|
||||
sa_thread_info* newthr = add_thread_info(ph, (pthread_t) -1, (lwpid_t) num_threads++);
|
||||
if (newthr == NULL) {
|
||||
printf("create thread_info failed\n");
|
||||
goto err;
|
||||
}
|
||||
|
||||
// note __DARWIN_UNIX03 depengs on other definitions
|
||||
#if __DARWIN_UNIX03
|
||||
#define get_register_v(regst, regname) \
|
||||
regst.uts.ts64.__##regname
|
||||
#else
|
||||
#define get_register_v(regst, regname) \
|
||||
regst.uts.ts64.##regname
|
||||
#endif // __DARWIN_UNIX03
|
||||
newthr->regs.r_rax = get_register_v(thrstate, rax);
|
||||
newthr->regs.r_rbx = get_register_v(thrstate, rbx);
|
||||
newthr->regs.r_rcx = get_register_v(thrstate, rcx);
|
||||
newthr->regs.r_rdx = get_register_v(thrstate, rdx);
|
||||
newthr->regs.r_rdi = get_register_v(thrstate, rdi);
|
||||
newthr->regs.r_rsi = get_register_v(thrstate, rsi);
|
||||
newthr->regs.r_rbp = get_register_v(thrstate, rbp);
|
||||
newthr->regs.r_rsp = get_register_v(thrstate, rsp);
|
||||
newthr->regs.r_r8 = get_register_v(thrstate, r8);
|
||||
newthr->regs.r_r9 = get_register_v(thrstate, r9);
|
||||
newthr->regs.r_r10 = get_register_v(thrstate, r10);
|
||||
newthr->regs.r_r11 = get_register_v(thrstate, r11);
|
||||
newthr->regs.r_r12 = get_register_v(thrstate, r12);
|
||||
newthr->regs.r_r13 = get_register_v(thrstate, r13);
|
||||
newthr->regs.r_r14 = get_register_v(thrstate, r14);
|
||||
newthr->regs.r_r15 = get_register_v(thrstate, r15);
|
||||
newthr->regs.r_rip = get_register_v(thrstate, rip);
|
||||
newthr->regs.r_rflags = get_register_v(thrstate, rflags);
|
||||
newthr->regs.r_cs = get_register_v(thrstate, cs);
|
||||
newthr->regs.r_fs = get_register_v(thrstate, fs);
|
||||
newthr->regs.r_gs = get_register_v(thrstate, gs);
|
||||
print_thread(newthr);
|
||||
} else if (fc.flavor == x86_FLOAT_STATE) {
|
||||
x86_float_state_t flstate;
|
||||
if (read(fd, (void *)&flstate, sizeof(x86_float_state_t)) != sizeof(x86_float_state_t)) {
|
||||
print_debug("Reading flavor, count failed.\n");
|
||||
goto err;
|
||||
}
|
||||
size += sizeof(x86_float_state_t);
|
||||
} else if (fc.flavor == x86_EXCEPTION_STATE) {
|
||||
x86_exception_state_t excpstate;
|
||||
if (read(fd, (void *)&excpstate, sizeof(x86_exception_state_t)) != sizeof(x86_exception_state_t)) {
|
||||
printf("Reading flavor, count failed.\n");
|
||||
goto err;
|
||||
}
|
||||
size += sizeof(x86_exception_state_t);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
err:
|
||||
return false;
|
||||
}
|
||||
|
||||
/**local function **/
|
||||
bool exists(const char *fname)
|
||||
{
|
||||
int fd;
|
||||
if ((fd = open(fname, O_RDONLY)) > 0) {
|
||||
close(fd);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// we check: 1. lib
|
||||
// 2. lib/server
|
||||
// 3. jre/lib
|
||||
// 4. jre/lib/server
|
||||
// from: 1. exe path
|
||||
// 2. JAVA_HOME
|
||||
// 3. DYLD_LIBRARY_PATH
|
||||
static bool get_real_path(struct ps_prochandle* ph, char *rpath) {
|
||||
/** check if they exist in JAVA ***/
|
||||
char* execname = ph->core->exec_path;
|
||||
char filepath[4096];
|
||||
char* filename = strrchr(rpath, '/'); // like /libjvm.dylib
|
||||
if (filename == NULL) {
|
||||
return false;
|
||||
}
|
||||
|
||||
char* posbin = strstr(execname, "/bin/java");
|
||||
if (posbin != NULL) {
|
||||
memcpy(filepath, execname, posbin - execname); // not include trailing '/'
|
||||
filepath[posbin - execname] = '\0';
|
||||
} else {
|
||||
char* java_home = getenv("JAVA_HOME");
|
||||
if (java_home != NULL) {
|
||||
strcpy(filepath, java_home);
|
||||
} else {
|
||||
char* dyldpath = getenv("DYLD_LIBRARY_PATH");
|
||||
char* dypath = strtok(dyldpath, ":");
|
||||
while (dypath != NULL) {
|
||||
strcpy(filepath, dypath);
|
||||
strcat(filepath, filename);
|
||||
if (exists(filepath)) {
|
||||
strcpy(rpath, filepath);
|
||||
return true;
|
||||
}
|
||||
dypath = strtok(dyldpath, ":");
|
||||
}
|
||||
// not found
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// for exec and java_home, jdkpath now is filepath
|
||||
size_t filepath_base_size = strlen(filepath);
|
||||
|
||||
// first try /lib/ and /lib/server
|
||||
strcat(filepath, "/lib");
|
||||
strcat(filepath, filename);
|
||||
if (exists(filepath)) {
|
||||
strcpy(rpath, filepath);
|
||||
return true;
|
||||
}
|
||||
char* pos = strstr(filepath, filename); // like /libjvm.dylib
|
||||
*pos = '\0';
|
||||
strcat(filepath, "/server");
|
||||
strcat(filepath, filename);
|
||||
if (exists(filepath)) {
|
||||
strcpy(rpath, filepath);
|
||||
return true;
|
||||
}
|
||||
|
||||
// then try /jre/lib/ and /jre/lib/server
|
||||
filepath[filepath_base_size] = '\0';
|
||||
strcat(filepath, "/jre/lib");
|
||||
strcat(filepath, filename);
|
||||
if (exists(filepath)) {
|
||||
strcpy(rpath, filepath);
|
||||
return true;
|
||||
}
|
||||
pos = strstr(filepath, filename);
|
||||
*pos = '\0';
|
||||
strcat(filepath, "/server");
|
||||
strcat(filepath, filename);
|
||||
if (exists(filepath)) {
|
||||
strcpy(rpath, filepath);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool read_shared_lib_info(struct ps_prochandle* ph) {
|
||||
static int pagesize = 0;
|
||||
int fd = ph->core->core_fd;
|
||||
int i = 0, j;
|
||||
uint32_t v;
|
||||
mach_header_64 header; // used to check if a file header in segment
|
||||
load_command lcmd;
|
||||
dylib_command dylibcmd;
|
||||
|
||||
char name[BUF_SIZE]; // use to store name
|
||||
|
||||
if (pagesize == 0) {
|
||||
pagesize = getpagesize();
|
||||
print_debug("page size is %d\n", pagesize);
|
||||
}
|
||||
for (j = 0; j < ph->core->num_maps; j++) {
|
||||
map_info *iter = ph->core->map_array[j]; // head
|
||||
off_t fpos = iter->offset;
|
||||
if (iter->fd != fd) {
|
||||
// only search core file!
|
||||
continue;
|
||||
}
|
||||
print_debug("map_info %d: vmaddr = 0x%016" PRIx64 " fileoff = %" PRIu64 " vmsize = %" PRIu64 "\n",
|
||||
j, iter->vaddr, iter->offset, iter->memsz);
|
||||
lseek(fd, fpos, SEEK_SET);
|
||||
// we assume .dylib loaded at segment address --- which is true for JVM libraries
|
||||
// multiple files may be loaded in one segment.
|
||||
// if first word is not a magic word, means this segment does not contain lib file.
|
||||
if (read(fd, (void *)&v, sizeof(uint32_t)) == sizeof(uint32_t)) {
|
||||
if (v != MH_MAGIC_64) {
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
// may be encountered last map, which is not readable
|
||||
continue;
|
||||
}
|
||||
while (ltell(fd) - iter->offset < iter->memsz) {
|
||||
lseek(fd, fpos, SEEK_SET);
|
||||
if (read(fd, (void *)&v, sizeof(uint32_t)) != sizeof(uint32_t)) {
|
||||
break;
|
||||
}
|
||||
if (v != MH_MAGIC_64) {
|
||||
fpos = (ltell(fd) + pagesize -1)/pagesize * pagesize;
|
||||
continue;
|
||||
}
|
||||
lseek(fd, -sizeof(uint32_t), SEEK_CUR);
|
||||
// this is the file begining to core file.
|
||||
if (read(fd, (void *)&header, sizeof(mach_header_64)) != sizeof(mach_header_64)) {
|
||||
goto err;
|
||||
}
|
||||
fpos = ltell(fd);
|
||||
|
||||
// found a mach-o file in this segment
|
||||
for (i = 0; i < header.ncmds; i++) {
|
||||
// read commands in this "file"
|
||||
// LC_ID_DYLIB is the file itself for a .dylib
|
||||
lseek(fd, fpos, SEEK_SET);
|
||||
if (read(fd, (void *)&lcmd, sizeof(load_command)) != sizeof(load_command)) {
|
||||
return false; // error
|
||||
}
|
||||
fpos += lcmd.cmdsize; // next command position
|
||||
// make sure still within seg size.
|
||||
if (fpos - lcmd.cmdsize - iter->offset > iter->memsz) {
|
||||
print_debug("Warning: out of segement limit: %ld \n", fpos - lcmd.cmdsize - iter->offset);
|
||||
break; // no need to iterate all commands
|
||||
}
|
||||
if (lcmd.cmd == LC_ID_DYLIB) {
|
||||
lseek(fd, -sizeof(load_command), SEEK_CUR);
|
||||
if (read(fd, (void *)&dylibcmd, sizeof(dylib_command)) != sizeof(dylib_command)) {
|
||||
return false;
|
||||
}
|
||||
/**** name stored at dylib_command.dylib.name.offset, is a C string */
|
||||
lseek(fd, dylibcmd.dylib.name.offset - sizeof(dylib_command), SEEK_CUR);
|
||||
int j = 0;
|
||||
while (j < BUF_SIZE) {
|
||||
read(fd, (void *)(name + j), sizeof(char));
|
||||
if (name[j] == '\0') break;
|
||||
j++;
|
||||
}
|
||||
print_debug("%s\n", name);
|
||||
// changed name from @rpath/xxxx.dylib to real path
|
||||
if (strrchr(name, '@')) {
|
||||
get_real_path(ph, name);
|
||||
print_debug("get_real_path returned: %s\n", name);
|
||||
}
|
||||
add_lib_info(ph, name, iter->vaddr);
|
||||
break;
|
||||
}
|
||||
}
|
||||
// done with the file, advanced to next page to search more files
|
||||
fpos = (ltell(fd) + pagesize - 1) / pagesize * pagesize;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
err:
|
||||
return false;
|
||||
}
|
||||
|
||||
bool read_macho64_header(int fd, mach_header_64* core_header) {
|
||||
bool is_macho = false;
|
||||
if (fd < 0) return false;
|
||||
off_t pos = ltell(fd);
|
||||
lseek(fd, 0, SEEK_SET);
|
||||
if (read(fd, (void *)core_header, sizeof(mach_header_64)) != sizeof(mach_header_64)) {
|
||||
is_macho = false;
|
||||
} else {
|
||||
is_macho = (core_header->magic == MH_MAGIC_64 || core_header->magic == MH_CIGAM_64);
|
||||
}
|
||||
lseek(fd, pos, SEEK_SET);
|
||||
return is_macho;
|
||||
}
|
||||
|
||||
// the one and only one exposed stuff from this file
|
||||
struct ps_prochandle* Pgrab_core(const char* exec_file, const char* core_file) {
|
||||
mach_header_64 core_header;
|
||||
mach_header_64 exec_header;
|
||||
|
||||
struct ps_prochandle* ph = (struct ps_prochandle*) calloc(1, sizeof(struct ps_prochandle));
|
||||
if (ph == NULL) {
|
||||
print_debug("cant allocate ps_prochandle\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if ((ph->core = (struct core_data*) calloc(1, sizeof(struct core_data))) == NULL) {
|
||||
free(ph);
|
||||
print_debug("can't allocate ps_prochandle\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// initialize ph
|
||||
ph->ops = &core_ops;
|
||||
ph->core->core_fd = -1;
|
||||
ph->core->exec_fd = -1;
|
||||
ph->core->interp_fd = -1;
|
||||
|
||||
print_debug("exec: %s core: %s", exec_file, core_file);
|
||||
|
||||
strncpy(ph->core->exec_path, exec_file, sizeof(ph->core->exec_path));
|
||||
|
||||
// open the core file
|
||||
if ((ph->core->core_fd = open(core_file, O_RDONLY)) < 0) {
|
||||
print_error("can't open core file\n");
|
||||
goto err;
|
||||
}
|
||||
|
||||
// read core file header
|
||||
if (read_macho64_header(ph->core->core_fd, &core_header) != true || core_header.filetype != MH_CORE) {
|
||||
print_debug("core file is not a valid Mach-O file\n");
|
||||
goto err;
|
||||
}
|
||||
|
||||
if ((ph->core->exec_fd = open(exec_file, O_RDONLY)) < 0) {
|
||||
print_error("can't open executable file\n");
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (read_macho64_header(ph->core->exec_fd, &exec_header) != true ||
|
||||
exec_header.filetype != MH_EXECUTE) {
|
||||
print_error("executable file is not a valid Mach-O file\n");
|
||||
goto err;
|
||||
}
|
||||
|
||||
// process core file segments
|
||||
if (read_core_segments(ph) != true) {
|
||||
print_error("failed to read core segments\n");
|
||||
goto err;
|
||||
}
|
||||
|
||||
// allocate and sort maps into map_array, we need to do this
|
||||
// here because read_shared_lib_info needs to read from debuggee
|
||||
// address space
|
||||
if (sort_map_array(ph) != true) {
|
||||
print_error("failed to sort segment map array\n");
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (read_shared_lib_info(ph) != true) {
|
||||
print_error("failed to read libraries\n");
|
||||
goto err;
|
||||
}
|
||||
|
||||
// sort again because we have added more mappings from shared objects
|
||||
if (sort_map_array(ph) != true) {
|
||||
print_error("failed to sort segment map array\n");
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (init_classsharing_workaround(ph) != true) {
|
||||
print_error("failed to workaround classshareing\n");
|
||||
goto err;
|
||||
}
|
||||
|
||||
print_debug("Leave Pgrab_core\n");
|
||||
return ph;
|
||||
|
||||
err:
|
||||
Prelease(ph);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#else // __APPLE__ (none macosx)
|
||||
|
||||
// read regs and create thread from core file
|
||||
static bool core_handle_prstatus(struct ps_prochandle* ph, const char* buf, size_t nbytes) {
|
||||
// we have to read prstatus_t from buf
|
||||
// assert(nbytes == sizeof(prstaus_t), "size mismatch on prstatus_t");
|
||||
prstatus_t* prstat = (prstatus_t*) buf;
|
||||
thread_info* newthr;
|
||||
sa_thread_info* newthr;
|
||||
print_debug("got integer regset for lwp %d\n", prstat->pr_pid);
|
||||
// we set pthread_t to -1 for core dump
|
||||
if((newthr = add_thread_info(ph, (pthread_t) -1, prstat->pr_pid)) == NULL)
|
||||
@ -632,9 +1093,10 @@ static bool core_handle_note(struct ps_prochandle* ph, ELF_PHDR* note_phdr) {
|
||||
notep->n_type, notep->n_descsz);
|
||||
|
||||
if (notep->n_type == NT_PRSTATUS) {
|
||||
if (core_handle_prstatus(ph, descdata, notep->n_descsz) != true)
|
||||
if (core_handle_prstatus(ph, descdata, notep->n_descsz) != true) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
p = descdata + ROUNDUP(notep->n_descsz, 4);
|
||||
}
|
||||
|
||||
@ -681,7 +1143,9 @@ static bool read_core_segments(struct ps_prochandle* ph, ELF_EHDR* core_ehdr) {
|
||||
for (core_php = phbuf, i = 0; i < core_ehdr->e_phnum; i++) {
|
||||
switch (core_php->p_type) {
|
||||
case PT_NOTE:
|
||||
if (core_handle_note(ph, core_php) != true) goto err;
|
||||
if (core_handle_note(ph, core_php) != true) {
|
||||
goto err;
|
||||
}
|
||||
break;
|
||||
|
||||
case PT_LOAD: {
|
||||
@ -800,7 +1264,6 @@ err:
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
#define FIRST_LINK_MAP_OFFSET offsetof(struct r_debug, r_map)
|
||||
#define LD_BASE_OFFSET offsetof(struct r_debug, r_ldbase)
|
||||
#define LINK_MAP_ADDR_OFFSET offsetof(struct link_map, l_addr)
|
||||
@ -947,7 +1410,7 @@ struct ps_prochandle* Pgrab_core(const char* exec_file, const char* core_file) {
|
||||
|
||||
struct ps_prochandle* ph = (struct ps_prochandle*) calloc(1, sizeof(struct ps_prochandle));
|
||||
if (ph == NULL) {
|
||||
print_debug("can't allocate ps_prochandle\n");
|
||||
print_debug("cant allocate ps_prochandle\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -963,6 +1426,8 @@ struct ps_prochandle* Pgrab_core(const char* exec_file, const char* core_file) {
|
||||
ph->core->exec_fd = -1;
|
||||
ph->core->interp_fd = -1;
|
||||
|
||||
print_debug("exec: %s core: %s", exec_file, core_file);
|
||||
|
||||
// open the core file
|
||||
if ((ph->core->core_fd = open(core_file, O_RDONLY)) < 0) {
|
||||
print_debug("can't open core file\n");
|
||||
@ -1014,9 +1479,12 @@ struct ps_prochandle* Pgrab_core(const char* exec_file, const char* core_file) {
|
||||
if (init_classsharing_workaround(ph) != true)
|
||||
goto err;
|
||||
|
||||
print_debug("Leave Pgrab_core\n");
|
||||
return ph;
|
||||
|
||||
err:
|
||||
Prelease(ph);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#endif // __APPLE__
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -28,32 +28,182 @@
|
||||
#include <string.h>
|
||||
#include <db.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#include "libproc_impl.h"
|
||||
#include "symtab.h"
|
||||
#ifndef __APPLE__
|
||||
#include "salibelf.h"
|
||||
#endif // __APPLE__
|
||||
|
||||
|
||||
// ----------------------------------------------------
|
||||
// functions for symbol lookups
|
||||
// ----------------------------------------------------
|
||||
|
||||
typedef struct symtab_symbol {
|
||||
char *name; // name like __ZThread_...
|
||||
uintptr_t offset; // to loaded address
|
||||
uintptr_t size; // size strlen
|
||||
} symtab_symbol;
|
||||
|
||||
typedef struct symtab {
|
||||
char *strs; // all symbols "__symbol1__'\0'__symbol2__...."
|
||||
size_t num_symbols;
|
||||
DB* hash_table;
|
||||
symtab_symbol* symbols;
|
||||
} symtab_t;
|
||||
|
||||
#ifdef __APPLE__
|
||||
|
||||
void build_search_table(symtab_t *symtab) {
|
||||
int i;
|
||||
for (i = 0; i < symtab->num_symbols; i++) {
|
||||
DBT key, value;
|
||||
key.data = symtab->symbols[i].name;
|
||||
key.size = strlen(key.data) + 1;
|
||||
value.data = &(symtab->symbols[i]);
|
||||
value.size = sizeof(symtab_symbol);
|
||||
(*symtab->hash_table->put)(symtab->hash_table, &key, &value, 0);
|
||||
|
||||
// check result
|
||||
if (is_debug()) {
|
||||
DBT rkey, rvalue;
|
||||
char* tmp = (char *)malloc(strlen(symtab->symbols[i].name) + 1);
|
||||
strcpy(tmp, symtab->symbols[i].name);
|
||||
rkey.data = tmp;
|
||||
rkey.size = strlen(tmp) + 1;
|
||||
(*symtab->hash_table->get)(symtab->hash_table, &rkey, &rvalue, 0);
|
||||
// we may get a copy back so compare contents
|
||||
symtab_symbol *res = (symtab_symbol *)rvalue.data;
|
||||
if (strcmp(res->name, symtab->symbols[i].name) ||
|
||||
res->offset != symtab->symbols[i].offset ||
|
||||
res->size != symtab->symbols[i].size) {
|
||||
print_debug("error to get hash_table value!\n");
|
||||
}
|
||||
free(tmp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// read symbol table from given fd.
|
||||
struct symtab* build_symtab(int fd) {
|
||||
symtab_t* symtab = NULL;
|
||||
int i;
|
||||
mach_header_64 header;
|
||||
off_t image_start;
|
||||
|
||||
if (!get_arch_off(fd, CPU_TYPE_X86_64, &image_start)) {
|
||||
print_debug("failed in get fat header\n");
|
||||
return NULL;
|
||||
}
|
||||
lseek(fd, image_start, SEEK_SET);
|
||||
if (read(fd, (void *)&header, sizeof(mach_header_64)) != sizeof(mach_header_64)) {
|
||||
print_debug("reading header failed!\n");
|
||||
return NULL;
|
||||
}
|
||||
// header
|
||||
if (header.magic != MH_MAGIC_64) {
|
||||
print_debug("not a valid .dylib file\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
load_command lcmd;
|
||||
symtab_command symtabcmd;
|
||||
nlist_64 lentry;
|
||||
|
||||
bool lcsymtab_exist = false;
|
||||
|
||||
long filepos = ltell(fd);
|
||||
for (i = 0; i < header.ncmds; i++) {
|
||||
lseek(fd, filepos, SEEK_SET);
|
||||
if (read(fd, (void *)&lcmd, sizeof(load_command)) != sizeof(load_command)) {
|
||||
print_debug("read load_command failed for file\n");
|
||||
return NULL;
|
||||
}
|
||||
filepos += lcmd.cmdsize; // next command position
|
||||
if (lcmd.cmd == LC_SYMTAB) {
|
||||
lseek(fd, -sizeof(load_command), SEEK_CUR);
|
||||
lcsymtab_exist = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!lcsymtab_exist) {
|
||||
print_debug("No symtab command found!\n");
|
||||
return NULL;
|
||||
}
|
||||
if (read(fd, (void *)&symtabcmd, sizeof(symtab_command)) != sizeof(symtab_command)) {
|
||||
print_debug("read symtab_command failed for file");
|
||||
return NULL;
|
||||
}
|
||||
symtab = (symtab_t *)malloc(sizeof(symtab_t));
|
||||
if (symtab == NULL) {
|
||||
print_debug("out of memory: allocating symtab\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// create hash table, we use berkeley db to
|
||||
// manipulate the hash table.
|
||||
symtab->hash_table = dbopen(NULL, O_CREAT | O_RDWR, 0600, DB_HASH, NULL);
|
||||
if (symtab->hash_table == NULL)
|
||||
goto quit;
|
||||
|
||||
symtab->num_symbols = symtabcmd.nsyms;
|
||||
symtab->symbols = (symtab_symbol *)malloc(sizeof(symtab_symbol) * symtab->num_symbols);
|
||||
symtab->strs = (char *)malloc(sizeof(char) * symtabcmd.strsize);
|
||||
if (symtab->symbols == NULL || symtab->strs == NULL) {
|
||||
print_debug("out of memory: allocating symtab.symbol or symtab.strs\n");
|
||||
goto quit;
|
||||
}
|
||||
lseek(fd, image_start + symtabcmd.symoff, SEEK_SET);
|
||||
for (i = 0; i < symtab->num_symbols; i++) {
|
||||
if (read(fd, (void *)&lentry, sizeof(nlist_64)) != sizeof(nlist_64)) {
|
||||
print_debug("read nlist_64 failed at %i\n", i);
|
||||
goto quit;
|
||||
}
|
||||
symtab->symbols[i].offset = lentry.n_value;
|
||||
symtab->symbols[i].size = lentry.n_un.n_strx; // index
|
||||
}
|
||||
|
||||
// string table
|
||||
lseek(fd, image_start + symtabcmd.stroff, SEEK_SET);
|
||||
int size = read(fd, (void *)(symtab->strs), symtabcmd.strsize * sizeof(char));
|
||||
if (size != symtabcmd.strsize * sizeof(char)) {
|
||||
print_debug("reading string table failed\n");
|
||||
goto quit;
|
||||
}
|
||||
|
||||
for (i = 0; i < symtab->num_symbols; i++) {
|
||||
symtab->symbols[i].name = symtab->strs + symtab->symbols[i].size;
|
||||
if (i > 0) {
|
||||
// fix size
|
||||
symtab->symbols[i - 1].size = symtab->symbols[i].size - symtab->symbols[i - 1].size;
|
||||
print_debug("%s size = %d\n", symtab->symbols[i - 1].name, symtab->symbols[i - 1].size);
|
||||
|
||||
}
|
||||
|
||||
if (i == symtab->num_symbols - 1) {
|
||||
// last index
|
||||
symtab->symbols[i].size =
|
||||
symtabcmd.strsize - symtab->symbols[i].size;
|
||||
print_debug("%s size = %d\n", symtab->symbols[i].name, symtab->symbols[i].size);
|
||||
}
|
||||
}
|
||||
|
||||
// build a hashtable for fast query
|
||||
build_search_table(symtab);
|
||||
return symtab;
|
||||
quit:
|
||||
if (symtab) destroy_symtab(symtab);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#else // __APPLE__
|
||||
|
||||
struct elf_section {
|
||||
ELF_SHDR *c_shdr;
|
||||
void *c_data;
|
||||
};
|
||||
|
||||
struct elf_symbol {
|
||||
char *name;
|
||||
uintptr_t offset;
|
||||
uintptr_t size;
|
||||
};
|
||||
|
||||
typedef struct symtab {
|
||||
char *strs;
|
||||
size_t num_symbols;
|
||||
struct elf_symbol *symbols;
|
||||
DB* hash_table;
|
||||
} symtab_t;
|
||||
|
||||
// read symbol table from given fd.
|
||||
struct symtab* build_symtab(int fd) {
|
||||
ELF_EHDR ehdr;
|
||||
@ -176,7 +326,7 @@ struct symtab* build_symtab(int fd) {
|
||||
key.data = sym_name;
|
||||
key.size = strlen(sym_name) + 1;
|
||||
value.data = &(symtab->symbols[j]);
|
||||
value.size = sizeof(void *);
|
||||
value.size = sizeof(symtab_symbol);
|
||||
(*symtab->hash_table->put)(symtab->hash_table, &key, &value, 0);
|
||||
}
|
||||
}
|
||||
@ -201,30 +351,29 @@ quit:
|
||||
return symtab;
|
||||
}
|
||||
|
||||
void destroy_symtab(struct symtab* symtab) {
|
||||
#endif // __APPLE__
|
||||
|
||||
void destroy_symtab(symtab_t* symtab) {
|
||||
if (!symtab) return;
|
||||
if (symtab->strs) free(symtab->strs);
|
||||
if (symtab->symbols) free(symtab->symbols);
|
||||
if (symtab->hash_table) {
|
||||
(*symtab->hash_table->close)(symtab->hash_table);
|
||||
}
|
||||
free(symtab->strs);
|
||||
free(symtab->symbols);
|
||||
free(symtab);
|
||||
}
|
||||
|
||||
uintptr_t search_symbol(struct symtab* symtab, uintptr_t base,
|
||||
const char *sym_name, int *sym_size) {
|
||||
uintptr_t search_symbol(struct symtab* symtab, uintptr_t base, const char *sym_name, int *sym_size) {
|
||||
DBT key, value;
|
||||
int ret;
|
||||
|
||||
// library does not have symbol table
|
||||
if (!symtab || !symtab->hash_table)
|
||||
if (!symtab || !symtab->hash_table) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
key.data = (char*)(uintptr_t)sym_name;
|
||||
key.size = strlen(sym_name) + 1;
|
||||
ret = (*symtab->hash_table->get)(symtab->hash_table, &key, &value, 0);
|
||||
if (ret == 0) {
|
||||
struct elf_symbol *sym = value.data;
|
||||
symtab_symbol *sym = value.data;
|
||||
uintptr_t rslt = (uintptr_t) ((char*)base + sym->offset);
|
||||
if (sym_size) *sym_size = sym->size;
|
||||
return rslt;
|
||||
@ -238,7 +387,7 @@ const char* nearest_symbol(struct symtab* symtab, uintptr_t offset,
|
||||
int n = 0;
|
||||
if (!symtab) return NULL;
|
||||
for (; n < symtab->num_symbols; n++) {
|
||||
struct elf_symbol* sym = &(symtab->symbols[n]);
|
||||
symtab_symbol* sym = &(symtab->symbols[n]);
|
||||
if (sym->name != NULL &&
|
||||
offset >= sym->offset && offset < sym->offset + sym->size) {
|
||||
if (poffset) *poffset = (offset - sym->offset);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -27,11 +27,11 @@
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
// interface to manage ELF symbol tables
|
||||
// interface to manage ELF or MachO symbol tables
|
||||
|
||||
struct symtab;
|
||||
|
||||
// build symbol table for a given ELF file descriptor
|
||||
// build symbol table for a given ELF or MachO file escriptor
|
||||
struct symtab* build_symtab(int fd);
|
||||
|
||||
// destroy the symbol table
|
||||
|
@ -132,12 +132,12 @@ static map_info* add_map_info(struct ps_prochandle* ph, int fd, off_t offset,
|
||||
}
|
||||
|
||||
// Part of the class sharing workaround
|
||||
static map_info* add_class_share_map_info(struct ps_prochandle* ph, off_t offset,
|
||||
static void add_class_share_map_info(struct ps_prochandle* ph, off_t offset,
|
||||
uintptr_t vaddr, size_t memsz) {
|
||||
map_info* map;
|
||||
if ((map = allocate_init_map(ph->core->classes_jsa_fd,
|
||||
offset, vaddr, memsz)) == NULL) {
|
||||
return NULL;
|
||||
return;
|
||||
}
|
||||
|
||||
map->next = ph->core->class_share_maps;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 2003, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -34,11 +34,18 @@ public class BsdVtblAccess extends BasicVtblAccess {
|
||||
public BsdVtblAccess(SymbolLookup symbolLookup,
|
||||
String[] dllNames) {
|
||||
super(symbolLookup, dllNames);
|
||||
|
||||
if (symbolLookup.lookup("libjvm.so", "__vt_10JavaThread") != null ||
|
||||
symbolLookup.lookup("libjvm_g.so", "__vt_10JavaThread") != null) {
|
||||
boolean oldVT = false;
|
||||
boolean isDarwin = dllNames[0].lastIndexOf(".dylib") != -1;
|
||||
String vtJavaThread = isDarwin ? "_vt_10JavaThread" : "__vt_10JavaThread";
|
||||
for (String dllName : dllNames) {
|
||||
if (symbolLookup.lookup(dllName, vtJavaThread) != null) {
|
||||
oldVT = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (oldVT) {
|
||||
// old C++ ABI
|
||||
vt = "__vt_";
|
||||
vt = isDarwin ? "_vt_" : "__vt_";
|
||||
} else {
|
||||
// new C++ ABI
|
||||
vt = "_ZTV";
|
||||
|
@ -24,36 +24,81 @@
|
||||
|
||||
package sun.jvm.hotspot;
|
||||
|
||||
import java.io.*;
|
||||
import java.math.*;
|
||||
import java.util.*;
|
||||
import java.util.regex.*;
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.PrintStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.Stack;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import sun.jvm.hotspot.types.Type;
|
||||
import sun.jvm.hotspot.types.Field;
|
||||
import sun.jvm.hotspot.HotSpotTypeDataBase;
|
||||
import sun.jvm.hotspot.types.basic.BasicType;
|
||||
import sun.jvm.hotspot.types.basic.BasicTypeDataBase;
|
||||
import sun.jvm.hotspot.types.CIntegerType;
|
||||
import sun.jvm.hotspot.code.*;
|
||||
import sun.jvm.hotspot.compiler.*;
|
||||
import sun.jvm.hotspot.debugger.*;
|
||||
import sun.jvm.hotspot.interpreter.*;
|
||||
import sun.jvm.hotspot.memory.*;
|
||||
import sun.jvm.hotspot.oops.*;
|
||||
import sun.jvm.hotspot.opto.*;
|
||||
import sun.jvm.hotspot.ci.*;
|
||||
import sun.jvm.hotspot.asm.*;
|
||||
import sun.jvm.hotspot.runtime.*;
|
||||
import sun.jvm.hotspot.utilities.*;
|
||||
import sun.jvm.hotspot.utilities.soql.*;
|
||||
import sun.jvm.hotspot.ui.classbrowser.*;
|
||||
import sun.jvm.hotspot.ui.tree.*;
|
||||
import sun.jvm.hotspot.tools.*;
|
||||
import sun.jvm.hotspot.ci.ciEnv;
|
||||
import sun.jvm.hotspot.code.CodeBlob;
|
||||
import sun.jvm.hotspot.code.CodeCacheVisitor;
|
||||
import sun.jvm.hotspot.code.NMethod;
|
||||
import sun.jvm.hotspot.debugger.Address;
|
||||
import sun.jvm.hotspot.debugger.OopHandle;
|
||||
import sun.jvm.hotspot.memory.SymbolTable;
|
||||
import sun.jvm.hotspot.memory.SystemDictionary;
|
||||
import sun.jvm.hotspot.memory.Universe;
|
||||
import sun.jvm.hotspot.oops.DefaultHeapVisitor;
|
||||
import sun.jvm.hotspot.oops.HeapVisitor;
|
||||
import sun.jvm.hotspot.oops.InstanceKlass;
|
||||
import sun.jvm.hotspot.oops.Klass;
|
||||
import sun.jvm.hotspot.oops.Metadata;
|
||||
import sun.jvm.hotspot.oops.Method;
|
||||
import sun.jvm.hotspot.oops.MethodData;
|
||||
import sun.jvm.hotspot.oops.Oop;
|
||||
import sun.jvm.hotspot.oops.RawHeapVisitor;
|
||||
import sun.jvm.hotspot.oops.Symbol;
|
||||
import sun.jvm.hotspot.oops.UnknownOopException;
|
||||
import sun.jvm.hotspot.opto.Compile;
|
||||
import sun.jvm.hotspot.opto.InlineTree;
|
||||
import sun.jvm.hotspot.runtime.CompiledVFrame;
|
||||
import sun.jvm.hotspot.runtime.CompilerThread;
|
||||
import sun.jvm.hotspot.runtime.JavaThread;
|
||||
import sun.jvm.hotspot.runtime.JavaVFrame;
|
||||
import sun.jvm.hotspot.runtime.Threads;
|
||||
import sun.jvm.hotspot.runtime.VM;
|
||||
import sun.jvm.hotspot.tools.ObjectHistogram;
|
||||
import sun.jvm.hotspot.tools.PMap;
|
||||
import sun.jvm.hotspot.tools.PStack;
|
||||
import sun.jvm.hotspot.tools.StackTrace;
|
||||
import sun.jvm.hotspot.tools.jcore.ClassDump;
|
||||
import sun.jvm.hotspot.tools.jcore.ClassFilter;
|
||||
import sun.jvm.hotspot.types.CIntegerType;
|
||||
import sun.jvm.hotspot.types.Field;
|
||||
import sun.jvm.hotspot.types.Type;
|
||||
import sun.jvm.hotspot.types.basic.BasicType;
|
||||
import sun.jvm.hotspot.ui.classbrowser.HTMLGenerator;
|
||||
import sun.jvm.hotspot.ui.tree.CTypeTreeNodeAdapter;
|
||||
import sun.jvm.hotspot.ui.tree.OopTreeNodeAdapter;
|
||||
import sun.jvm.hotspot.ui.tree.SimpleTreeNode;
|
||||
import sun.jvm.hotspot.utilities.AddressOps;
|
||||
import sun.jvm.hotspot.utilities.Assert;
|
||||
import sun.jvm.hotspot.utilities.HeapProgressThunk;
|
||||
import sun.jvm.hotspot.utilities.LivenessPathElement;
|
||||
import sun.jvm.hotspot.utilities.MethodArray;
|
||||
import sun.jvm.hotspot.utilities.ObjectReader;
|
||||
import sun.jvm.hotspot.utilities.PointerFinder;
|
||||
import sun.jvm.hotspot.utilities.PointerLocation;
|
||||
import sun.jvm.hotspot.utilities.ReversePtrs;
|
||||
import sun.jvm.hotspot.utilities.ReversePtrsAnalysis;
|
||||
import sun.jvm.hotspot.utilities.RobustOopDeterminator;
|
||||
import sun.jvm.hotspot.utilities.SystemDictionaryHelper;
|
||||
import sun.jvm.hotspot.utilities.soql.JSJavaFactory;
|
||||
import sun.jvm.hotspot.utilities.soql.JSJavaFactoryImpl;
|
||||
import sun.jvm.hotspot.utilities.soql.JSJavaScriptEngine;
|
||||
|
||||
public class CommandProcessor {
|
||||
public abstract static class DebuggerInterface {
|
||||
@ -1132,6 +1177,10 @@ public class CommandProcessor {
|
||||
Klass klass = null;
|
||||
if (t.countTokens() == 1) {
|
||||
klass = SystemDictionaryHelper.findInstanceKlass(t.nextToken());
|
||||
if (klass == null) {
|
||||
out.println("No such type.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
while (base != null && base.lessThan(end)) {
|
||||
long step = stride;
|
||||
@ -1517,7 +1566,7 @@ public class CommandProcessor {
|
||||
ByteArrayOutputStream bos = new ByteArrayOutputStream();
|
||||
thread.printThreadIDOn(new PrintStream(bos));
|
||||
if (all || bos.toString().equals(name)) {
|
||||
out.println(bos.toString() + " = " + thread.getAddress());
|
||||
out.println("Thread " + bos.toString() + " Address: " + thread.getAddress());
|
||||
HTMLGenerator gen = new HTMLGenerator(false);
|
||||
try {
|
||||
out.println(gen.genHTMLForJavaStackTrace(thread));
|
||||
@ -1546,7 +1595,7 @@ public class CommandProcessor {
|
||||
ByteArrayOutputStream bos = new ByteArrayOutputStream();
|
||||
thread.printThreadIDOn(new PrintStream(bos));
|
||||
if (all || bos.toString().equals(name)) {
|
||||
out.println(bos.toString() + " = " + thread.getAddress());
|
||||
out.println("Thread " + bos.toString() + " Address " + thread.getAddress());
|
||||
if (!all) return;
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -311,6 +311,8 @@ public class HotSpotAgent {
|
||||
setupDebuggerLinux();
|
||||
} else if (os.equals("bsd")) {
|
||||
setupDebuggerBsd();
|
||||
} else if (os.equals("darwin")) {
|
||||
setupDebuggerDarwin();
|
||||
} else {
|
||||
// Add support for more operating systems here
|
||||
throw new DebuggerException("Operating system " + os + " not yet supported");
|
||||
@ -370,6 +372,10 @@ public class HotSpotAgent {
|
||||
db = new HotSpotTypeDataBase(machDesc,
|
||||
new BsdVtblAccess(debugger, jvmLibNames),
|
||||
debugger, jvmLibNames);
|
||||
} else if (os.equals("darwin")) {
|
||||
db = new HotSpotTypeDataBase(machDesc,
|
||||
new BsdVtblAccess(debugger, jvmLibNames),
|
||||
debugger, jvmLibNames);
|
||||
} else {
|
||||
throw new DebuggerException("OS \"" + os + "\" not yet supported (no VtblAccess yet)");
|
||||
}
|
||||
@ -459,6 +465,8 @@ public class HotSpotAgent {
|
||||
setupJVMLibNamesLinux();
|
||||
} else if (os.equals("bsd")) {
|
||||
setupJVMLibNamesBsd();
|
||||
} else if (os.equals("darwin")) {
|
||||
setupJVMLibNamesDarwin();
|
||||
} else {
|
||||
throw new RuntimeException("Unknown OS type");
|
||||
}
|
||||
@ -567,6 +575,29 @@ public class HotSpotAgent {
|
||||
jvmLibNames = new String[] { "libjvm.so", "libjvm_g.so" };
|
||||
}
|
||||
|
||||
//
|
||||
// Darwin
|
||||
//
|
||||
|
||||
private void setupDebuggerDarwin() {
|
||||
setupJVMLibNamesDarwin();
|
||||
|
||||
if (cpu.equals("amd64") || cpu.equals("x86_64")) {
|
||||
machDesc = new MachineDescriptionAMD64();
|
||||
} else {
|
||||
throw new DebuggerException("Darwin only supported on x86_64. Current arch: " + cpu);
|
||||
}
|
||||
|
||||
BsdDebuggerLocal dbg = new BsdDebuggerLocal(machDesc, !isServer);
|
||||
debugger = dbg;
|
||||
|
||||
attachDebugger();
|
||||
}
|
||||
|
||||
private void setupJVMLibNamesDarwin() {
|
||||
jvmLibNames = new String[] { "libjvm.dylib", "libjvm_g.dylib" };
|
||||
}
|
||||
|
||||
/** Convenience routine which should be called by per-platform
|
||||
debugger setup. Should not be called when startupMode is
|
||||
REMOTE_MODE. */
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 2008, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -31,6 +31,9 @@ import sun.jvm.hotspot.debugger.*;
|
||||
import sun.jvm.hotspot.debugger.x86.*;
|
||||
import sun.jvm.hotspot.debugger.cdbg.*;
|
||||
import sun.jvm.hotspot.utilities.*;
|
||||
import sun.jvm.hotspot.runtime.VM;
|
||||
import sun.jvm.hotspot.runtime.Threads;
|
||||
import sun.jvm.hotspot.runtime.JavaThread;
|
||||
import java.lang.reflect.*;
|
||||
|
||||
/** <P> An implementation of the JVMDebugger interface. The basic debug
|
||||
@ -55,6 +58,7 @@ public class BsdDebuggerLocal extends DebuggerBase implements BsdDebugger {
|
||||
private long symbolicator; // macosx symbolicator handle
|
||||
private long task; // macosx task handle
|
||||
private boolean isCore;
|
||||
private boolean isDarwin; // variant for bsd
|
||||
|
||||
// CDebugger support
|
||||
private BsdCDebugger cdbg;
|
||||
@ -208,6 +212,7 @@ public class BsdDebuggerLocal extends DebuggerBase implements BsdDebugger {
|
||||
}
|
||||
}
|
||||
|
||||
isDarwin = getOS().equals("darwin");
|
||||
workerThread = new BsdDebuggerLocalWorkerThread(this);
|
||||
workerThread.start();
|
||||
}
|
||||
@ -240,8 +245,11 @@ public class BsdDebuggerLocal extends DebuggerBase implements BsdDebugger {
|
||||
|
||||
/* called from attach methods */
|
||||
private void findABIVersion() throws DebuggerException {
|
||||
if (lookupByName0("libjvm.so", "__vt_10JavaThread") != 0 ||
|
||||
lookupByName0("libjvm_g.so", "__vt_10JavaThread") != 0) {
|
||||
String libjvmName = isDarwin ? "libjvm.dylib" : "libjvm.so";
|
||||
String libjvm_gName = isDarwin? "libjvm_g.dylib" : "libjvm_g.so";
|
||||
String javaThreadVt = isDarwin ? "_vt_10JavaThread" : "__vt_10JavaThread";
|
||||
if (lookupByName0(libjvmName, javaThreadVt) != 0 ||
|
||||
lookupByName0(libjvm_gName, javaThreadVt) != 0) {
|
||||
// old C++ ABI
|
||||
useGCC32ABI = false;
|
||||
} else {
|
||||
@ -360,7 +368,8 @@ public class BsdDebuggerLocal extends DebuggerBase implements BsdDebugger {
|
||||
}
|
||||
|
||||
if (isCore) {
|
||||
long addr = lookupByName0(objectName, symbol);
|
||||
// MacOSX symbol with "_" as leading
|
||||
long addr = lookupByName0(objectName, isDarwin ? "_" + symbol : symbol);
|
||||
return (addr == 0)? null : new BsdAddress(this, handleGCC32ABI(addr, symbol));
|
||||
} else {
|
||||
class LookupByNameTask implements WorkerThreadTask {
|
||||
@ -403,12 +412,12 @@ public class BsdDebuggerLocal extends DebuggerBase implements BsdDebugger {
|
||||
public ThreadProxy getThreadForIdentifierAddress(Address threadIdAddr, Address uniqueThreadIdAddr) {
|
||||
return new BsdThread(this, threadIdAddr, uniqueThreadIdAddr);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ThreadProxy getThreadForIdentifierAddress(Address addr) {
|
||||
throw new RuntimeException("unimplemented");
|
||||
}
|
||||
|
||||
|
||||
/** From the ThreadAccess interface via Debugger and JVMDebugger */
|
||||
public ThreadProxy getThreadForThreadId(long id) {
|
||||
return new BsdThread(this, id);
|
||||
@ -601,6 +610,33 @@ public class BsdDebuggerLocal extends DebuggerBase implements BsdDebugger {
|
||||
throw new DebuggerException("Unimplemented");
|
||||
}
|
||||
|
||||
/** this functions used for core file reading and called from native attach0,
|
||||
it returns an array of long integers as
|
||||
[thread_id, stack_start, stack_end, thread_id, stack_start, stack_end, ....] for
|
||||
all java threads recorded in Threads. Also adds the ThreadProxy to threadList */
|
||||
public long[] getJavaThreadsInfo() {
|
||||
requireAttach();
|
||||
Threads threads = VM.getVM().getThreads();
|
||||
int len = threads.getNumberOfThreads();
|
||||
long[] result = new long[len * 3]; // triple
|
||||
JavaThread t = threads.first();
|
||||
long beg, end;
|
||||
int i = 0;
|
||||
while (t != null) {
|
||||
end = t.getStackBaseValue();
|
||||
beg = end - t.getStackSize();
|
||||
BsdThread bsdt = (BsdThread)t.getThreadProxy();
|
||||
long uid = bsdt.getUniqueThreadId();
|
||||
if (threadList != null) threadList.add(bsdt);
|
||||
result[i] = uid;
|
||||
result[i + 1] = beg;
|
||||
result[i + 2] = end;
|
||||
t = t.next();
|
||||
i += 3;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
static {
|
||||
System.loadLibrary("saproc");
|
||||
init0();
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 2003, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -44,7 +44,8 @@ class BsdThread implements ThreadProxy {
|
||||
|
||||
BsdThread(BsdDebugger debugger, long id) {
|
||||
this.debugger = debugger;
|
||||
this.thread_id = (int) id;
|
||||
// use unique_thread_id to identify thread
|
||||
this.unique_thread_id = id;
|
||||
}
|
||||
|
||||
public boolean equals(Object obj) {
|
||||
@ -52,7 +53,7 @@ class BsdThread implements ThreadProxy {
|
||||
return false;
|
||||
}
|
||||
|
||||
return (((BsdThread) obj).thread_id == thread_id);
|
||||
return (((BsdThread) obj).unique_thread_id == unique_thread_id);
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
@ -80,4 +81,9 @@ class BsdThread implements ThreadProxy {
|
||||
throws IllegalThreadStateException, DebuggerException {
|
||||
throw new DebuggerException("Unimplemented");
|
||||
}
|
||||
|
||||
/** this is not interface function, used in core file to get unique thread id on Macosx*/
|
||||
public long getUniqueThreadId() {
|
||||
return unique_thread_id;
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -148,7 +148,7 @@ public class Oop {
|
||||
if (doVMFields) {
|
||||
visitor.doCInt(mark, true);
|
||||
if (VM.getVM().isCompressedKlassPointersEnabled()) {
|
||||
throw new InternalError("unimplemented");
|
||||
visitor.doMetadata(compressedKlass, true);
|
||||
} else {
|
||||
visitor.doMetadata(klass, true);
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -320,6 +320,10 @@ public class JavaThread extends Thread {
|
||||
return stackBaseField.getValue(addr);
|
||||
}
|
||||
|
||||
public long getStackBaseValue() {
|
||||
return VM.getVM().getAddressValue(getStackBase());
|
||||
}
|
||||
|
||||
public long getStackSize() {
|
||||
return stackSizeField.getValue(addr);
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -42,6 +42,7 @@ import sun.jvm.hotspot.utilities.*;
|
||||
public class Threads {
|
||||
private static JavaThreadFactory threadFactory;
|
||||
private static AddressField threadListField;
|
||||
private static CIntegerField numOfThreadsField;
|
||||
private static VirtualConstructor virtualConstructor;
|
||||
private static JavaThreadPDAccess access;
|
||||
|
||||
@ -57,6 +58,7 @@ public class Threads {
|
||||
Type type = db.lookupType("Threads");
|
||||
|
||||
threadListField = type.getAddressField("_thread_list");
|
||||
numOfThreadsField = type.getCIntegerField("_number_of_threads");
|
||||
|
||||
// Instantiate appropriate platform-specific JavaThreadFactory
|
||||
String os = VM.getVM().getOS();
|
||||
@ -102,6 +104,10 @@ public class Threads {
|
||||
} else if (cpu.equals("amd64") || cpu.equals("x86_64")) {
|
||||
access = new BsdAMD64JavaThreadPDAccess();
|
||||
}
|
||||
} else if (os.equals("darwin")) {
|
||||
if (cpu.equals("amd64") || cpu.equals("x86_64")) {
|
||||
access = new BsdAMD64JavaThreadPDAccess();
|
||||
}
|
||||
}
|
||||
|
||||
if (access == null) {
|
||||
@ -144,6 +150,10 @@ public class Threads {
|
||||
return createJavaThreadWrapper(threadAddr);
|
||||
}
|
||||
|
||||
public int getNumberOfThreads() {
|
||||
return (int) numOfThreadsField.getValue();
|
||||
}
|
||||
|
||||
/** Routine for instantiating appropriately-typed wrapper for a
|
||||
JavaThread. Currently needs to be public for OopUtilities to
|
||||
access it. */
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -32,6 +32,7 @@ import sun.jvm.hotspot.debugger.*;
|
||||
import sun.jvm.hotspot.debugger.cdbg.*;
|
||||
import sun.jvm.hotspot.oops.*;
|
||||
import sun.jvm.hotspot.runtime.*;
|
||||
import sun.jvm.hotspot.utilities.PlatformInfo;
|
||||
|
||||
public class PStack extends Tool {
|
||||
// in non-verbose mode, Method*s are not printed in java frames
|
||||
@ -54,6 +55,11 @@ public class PStack extends Tool {
|
||||
}
|
||||
|
||||
public void run(PrintStream out, Debugger dbg) {
|
||||
if (PlatformInfo.getOS().equals("darwin")) {
|
||||
out.println("Not available on Darwin");
|
||||
return;
|
||||
}
|
||||
|
||||
CDebugger cdbg = dbg.getCDebugger();
|
||||
if (cdbg != null) {
|
||||
ConcurrentLocksPrinter concLocksPrinter = null;
|
||||
|
@ -24,10 +24,15 @@
|
||||
|
||||
package sun.jvm.hotspot.types.basic;
|
||||
|
||||
import java.util.*;
|
||||
import sun.jvm.hotspot.debugger.*;
|
||||
import sun.jvm.hotspot.types.*;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
|
||||
import sun.jvm.hotspot.debugger.Address;
|
||||
import sun.jvm.hotspot.debugger.MachineDescription;
|
||||
import sun.jvm.hotspot.runtime.VM;
|
||||
import sun.jvm.hotspot.types.Type;
|
||||
import sun.jvm.hotspot.types.TypeDataBase;
|
||||
|
||||
/** <P> This is a basic implementation of the TypeDataBase interface.
|
||||
It allows an external type database builder to add types to be
|
||||
@ -150,7 +155,7 @@ public class BasicTypeDataBase implements TypeDataBase {
|
||||
return VM.getVM().getOopSize();
|
||||
}
|
||||
|
||||
static HashMap typeToVtbl = new HashMap();
|
||||
HashMap typeToVtbl = new HashMap();
|
||||
|
||||
private Address vtblForType(Type type) {
|
||||
Address vtblAddr = (Address)typeToVtbl.get(type);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -43,8 +43,8 @@ public class PlatformInfo {
|
||||
return "bsd";
|
||||
} else if (os.equals("OpenBSD")) {
|
||||
return "bsd";
|
||||
} else if (os.equals("Darwin") || os.contains("OS X")) {
|
||||
return "bsd";
|
||||
} else if (os.contains("Darwin") || os.contains("OS X")) {
|
||||
return "darwin";
|
||||
} else if (os.startsWith("Windows")) {
|
||||
return "win32";
|
||||
} else {
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -48,7 +48,10 @@
|
||||
|
||||
#include <string.h>
|
||||
#include <dlfcn.h>
|
||||
|
||||
#ifndef __APPLE__
|
||||
#include <link.h>
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@ -109,9 +112,7 @@ JNIEXPORT jlong JNICALL Java_sun_jvm_hotspot_asm_Disassembler_load_1library(JNIE
|
||||
jstring libname_s) {
|
||||
uintptr_t func = 0;
|
||||
const char* error_message = NULL;
|
||||
const char* java_home;
|
||||
jboolean isCopy;
|
||||
uintptr_t *handle = NULL;
|
||||
|
||||
const char * jrepath = (*env)->GetStringUTFChars(env, jrepath_s, &isCopy); // like $JAVA_HOME/jre/lib/sparc/
|
||||
const char * libname = (*env)->GetStringUTFChars(env, libname_s, &isCopy);
|
||||
@ -167,7 +168,8 @@ typedef void* (*decode_func)(uintptr_t start_va, uintptr_t end_va,
|
||||
void* event_stream,
|
||||
int (*printf_callback)(void*, const char*, ...),
|
||||
void* printf_stream,
|
||||
const char* options);
|
||||
const char* options,
|
||||
int newline);
|
||||
|
||||
/* container for call back state when decoding instructions */
|
||||
typedef struct {
|
||||
@ -281,7 +283,7 @@ JNIEXPORT void JNICALL Java_sun_jvm_hotspot_asm_Disassembler_decode(JNIEnv * env
|
||||
end - start,
|
||||
&event_to_env, (void*) &denv,
|
||||
&printf_to_env, (void*) &denv,
|
||||
options);
|
||||
options, 0 /* newline */);
|
||||
|
||||
/* cleanup */
|
||||
(*env)->ReleaseByteArrayElements(env, code, start, JNI_ABORT);
|
||||
|
@ -532,6 +532,39 @@ $(JDK_IMAGE_DIR)/jre/lib/rt.jar:
|
||||
$(TAR) -cf - *) | \
|
||||
($(CD) $(JDK_IMAGE_DIR) && $(TAR) -xf -)
|
||||
|
||||
|
||||
# Testing the built JVM
|
||||
RUN_JVM=JAVA_HOME=$(JDK_IMPORT_PATH) $(JDK_IMPORT_PATH)/bin/java -d$(ARCH_DATA_MODEL) -Dsun.java.launcher=gamma
|
||||
generic_test:
|
||||
@$(ECHO) "Running with: $(ALTJVM_DIR)"
|
||||
@$(RUN_JVM) -XXaltjvm=$(ALTJVM_DIR) -Xinternalversion
|
||||
@$(RUN_JVM) -XXaltjvm=$(ALTJVM_DIR) -showversion -help
|
||||
|
||||
# C2 test targets
|
||||
test_product test_optimized test_fastdebug test_jvmg:
|
||||
@$(MAKE) generic_test ALTJVM_DIR="$(C2_DIR)/$(@:test_%=%)"
|
||||
|
||||
# C1 test targets
|
||||
test_product1 test_optimized1 test_fastdebug1 test_jvmg1:
|
||||
ifeq ($(ARCH_DATA_MODEL), 32)
|
||||
@$(MAKE) generic_test ALTJVM_DIR="$(C1_DIR)/$(@:test_%1=%)"
|
||||
else
|
||||
@$(ECHO) "No compiler1 ($(@:test_%=%)) for ARCH_DATA_MODEL=$(ARCH_DATA_MODEL)"
|
||||
endif
|
||||
|
||||
# Zero test targets
|
||||
test_productzero test_optimizedzero test_fastdebugzero test_jvmgzero:
|
||||
@$(MAKE) generic_test ALTJVM_DIR="$(ZERO_DIR)/$(@:test_%zero=%)"
|
||||
|
||||
# Shark test targets
|
||||
test_productshark test_optimizedshark test_fastdebugshark test_jvmgshark:
|
||||
@$(MAKE) generic_test ALTJVM_DIR="$(SHARK_DIR)/$(@:test_%shark=%)"
|
||||
|
||||
# Minimal1 test targets
|
||||
test_productminimal1 test_optimizedminimal1 test_fastdebugminimal1 test_jvmgminimal1:
|
||||
@$(MAKE) generic_test ALTJVM_DIR="$(MINIMAL1_DIR)/$(@:test_%minimal1=%)"
|
||||
|
||||
|
||||
test_jdk:
|
||||
ifeq ($(JVM_VARIANT_CLIENT), true)
|
||||
$(JDK_IMAGE_DIR)/bin/java -d$(ARCH_DATA_MODEL) -client -Xinternalversion
|
||||
|
@ -299,63 +299,42 @@ platform_zero: $(GAMMADIR)/make/$(OSNAME)/platform_zero.in
|
||||
|
||||
$(TARGETS_C2): $(SUBDIRS_C2)
|
||||
cd $(OSNAME)_$(BUILDARCH)_compiler2/$@ && $(MAKE) $(MFLAGS)
|
||||
ifeq ($(TEST_IN_BUILD),true)
|
||||
cd $(OSNAME)_$(BUILDARCH)_compiler2/$@ && ./test_gamma
|
||||
endif
|
||||
ifdef INSTALL
|
||||
cd $(OSNAME)_$(BUILDARCH)_compiler2/$@ && $(MAKE) $(MFLAGS) install
|
||||
endif
|
||||
|
||||
$(TARGETS_TIERED): $(SUBDIRS_TIERED)
|
||||
cd $(OSNAME)_$(BUILDARCH)_tiered/$(patsubst %tiered,%,$@) && $(MAKE) $(MFLAGS)
|
||||
ifeq ($(TEST_IN_BUILD),true)
|
||||
cd $(OSNAME)_$(BUILDARCH)_tiered/$(patsubst %tiered,%,$@) && ./test_gamma
|
||||
endif
|
||||
ifdef INSTALL
|
||||
cd $(OSNAME)_$(BUILDARCH)_tiered/$(patsubst %tiered,%,$@) && $(MAKE) $(MFLAGS) install
|
||||
endif
|
||||
|
||||
$(TARGETS_C1): $(SUBDIRS_C1)
|
||||
cd $(OSNAME)_$(BUILDARCH)_compiler1/$(patsubst %1,%,$@) && $(MAKE) $(MFLAGS)
|
||||
ifeq ($(TEST_IN_BUILD),true)
|
||||
cd $(OSNAME)_$(BUILDARCH)_compiler1/$(patsubst %1,%,$@) && ./test_gamma
|
||||
endif
|
||||
ifdef INSTALL
|
||||
cd $(OSNAME)_$(BUILDARCH)_compiler1/$(patsubst %1,%,$@) && $(MAKE) $(MFLAGS) install
|
||||
endif
|
||||
|
||||
$(TARGETS_CORE): $(SUBDIRS_CORE)
|
||||
cd $(OSNAME)_$(BUILDARCH)_core/$(patsubst %core,%,$@) && $(MAKE) $(MFLAGS)
|
||||
ifeq ($(TEST_IN_BUILD),true)
|
||||
cd $(OSNAME)_$(BUILDARCH)_core/$(patsubst %core,%,$@) && ./test_gamma
|
||||
endif
|
||||
ifdef INSTALL
|
||||
cd $(OSNAME)_$(BUILDARCH)_core/$(patsubst %core,%,$@) && $(MAKE) $(MFLAGS) install
|
||||
endif
|
||||
|
||||
$(TARGETS_ZERO): $(SUBDIRS_ZERO)
|
||||
cd $(OSNAME)_$(VARIANTARCH)_zero/$(patsubst %zero,%,$@) && $(MAKE) $(MFLAGS)
|
||||
ifeq ($(TEST_IN_BUILD),true)
|
||||
cd $(OSNAME)_$(VARIANTARCH)_zero/$(patsubst %zero,%,$@) && ./test_gamma
|
||||
endif
|
||||
ifdef INSTALL
|
||||
cd $(OSNAME)_$(VARIANTARCH)_zero/$(patsubst %zero,%,$@) && $(MAKE) $(MFLAGS) install
|
||||
endif
|
||||
|
||||
$(TARGETS_SHARK): $(SUBDIRS_SHARK)
|
||||
cd $(OSNAME)_$(VARIANTARCH)_shark/$(patsubst %shark,%,$@) && $(MAKE) $(MFLAGS)
|
||||
ifeq ($(TEST_IN_BUILD),true)
|
||||
cd $(OSNAME)_$(VARIANTARCH)_shark/$(patsubst %shark,%,$@) && ./test_gamma
|
||||
endif
|
||||
ifdef INSTALL
|
||||
cd $(OSNAME)_$(VARIANTARCH)_shark/$(patsubst %shark,%,$@) && $(MAKE) $(MFLAGS) install
|
||||
endif
|
||||
|
||||
$(TARGETS_MINIMAL1): $(SUBDIRS_MINIMAL1)
|
||||
cd $(OSNAME)_$(BUILDARCH)_minimal1/$(patsubst %minimal1,%,$@) && $(MAKE) $(MFLAGS)
|
||||
ifeq ($(TEST_IN_BUILD),true)
|
||||
cd $(OSNAME)_$(BUILDARCH)_minimal1/$(patsubst %minimal1,%,$@) && ./test_gamma
|
||||
endif
|
||||
ifdef INSTALL
|
||||
cd $(OSNAME)_$(BUILDARCH)_minimal1/$(patsubst %minimal1,%,$@) && $(MAKE) $(MFLAGS) install
|
||||
endif
|
||||
|
@ -50,7 +50,6 @@
|
||||
# jvmti.make - generate JVMTI bindings from the spec (JSR-163)
|
||||
# sa.make - generate SA jar file and natives
|
||||
# env.[ck]sh - environment settings
|
||||
# test_gamma - script to run the Queens program
|
||||
#
|
||||
# The makefiles are split this way so that "make foo" will run faster by not
|
||||
# having to read the dependency files for the vm.
|
||||
@ -67,9 +66,6 @@ include $(GAMMADIR)/make/altsrc.make
|
||||
# 'gmake MAKE_VERBOSE=y' or 'gmake QUIETLY=' gives all the gory details.
|
||||
QUIETLY$(MAKE_VERBOSE) = @
|
||||
|
||||
# For now, until the compiler is less wobbly:
|
||||
TESTFLAGS = -Xbatch -showversion
|
||||
|
||||
ifeq ($(findstring true, $(JVM_VARIANT_ZERO) $(JVM_VARIANT_ZEROSHARK)), true)
|
||||
PLATFORM_FILE = $(shell dirname $(shell dirname $(shell pwd)))/platform_zero
|
||||
else
|
||||
@ -135,7 +131,7 @@ BUILDTREE_MAKE = $(GAMMADIR)/make/$(OS_FAMILY)/makefiles/buildtree.make
|
||||
# dtrace.make is used on BSD versions that implement Dtrace (like MacOS X)
|
||||
BUILDTREE_TARGETS = Makefile flags.make flags_vm.make vm.make adlc.make \
|
||||
jvmti.make sa.make dtrace.make \
|
||||
env.sh env.csh jdkpath.sh .dbxrc test_gamma
|
||||
env.sh env.csh jdkpath.sh
|
||||
|
||||
BUILDTREE_VARS = GAMMADIR=$(GAMMADIR) OS_FAMILY=$(OS_FAMILY) \
|
||||
SRCARCH=$(SRCARCH) BUILDARCH=$(BUILDARCH) LIBARCH=$(LIBARCH) VARIANT=$(VARIANT)
|
||||
@ -352,7 +348,7 @@ env.sh: $(BUILDTREE_MAKE)
|
||||
@echo Creating $@ ...
|
||||
$(QUIETLY) ( \
|
||||
$(BUILDTREE_COMMENT); \
|
||||
[ -n "$$JAVA_HOME" ] && { echo ": \$${JAVA_HOME:=$${JAVA_HOME}}"; }; \
|
||||
{ echo "JAVA_HOME=$(JDK_IMPORT_PATH)"; }; \
|
||||
{ \
|
||||
echo "CLASSPATH=$${CLASSPATH:+$$CLASSPATH:}.:\$${JAVA_HOME}/jre/lib/rt.jar:\$${JAVA_HOME}/jre/lib/i18n.jar"; \
|
||||
} | sed s:$${JAVA_HOME:--------}:\$${JAVA_HOME}:g; \
|
||||
@ -364,8 +360,7 @@ env.csh: env.sh
|
||||
@echo Creating $@ ...
|
||||
$(QUIETLY) ( \
|
||||
$(BUILDTREE_COMMENT); \
|
||||
[ -n "$$JAVA_HOME" ] && \
|
||||
{ echo "if (! \$$?JAVA_HOME) setenv JAVA_HOME \"$$JAVA_HOME\""; }; \
|
||||
{ echo "setenv JAVA_HOME \"$(JDK_IMPORT_PATH)\""; }; \
|
||||
sed -n 's/^\([A-Za-z_][A-Za-z0-9_]*\)=/setenv \1 /p' $?; \
|
||||
) > $@
|
||||
|
||||
@ -376,119 +371,6 @@ jdkpath.sh: $(BUILDTREE_MAKE)
|
||||
echo "JDK=${JAVA_HOME}"; \
|
||||
) > $@
|
||||
|
||||
.dbxrc: $(BUILDTREE_MAKE)
|
||||
@echo Creating $@ ...
|
||||
$(QUIETLY) ( \
|
||||
echo "echo '# Loading $(PLATFORM_DIR)/$(TARGET)/.dbxrc'"; \
|
||||
echo "if [ -f \"\$${HOTSPOT_DBXWARE}\" ]"; \
|
||||
echo "then"; \
|
||||
echo " source \"\$${HOTSPOT_DBXWARE}\""; \
|
||||
echo "elif [ -f \"\$$HOME/.dbxrc\" ]"; \
|
||||
echo "then"; \
|
||||
echo " source \"\$$HOME/.dbxrc\""; \
|
||||
echo "fi"; \
|
||||
) > $@
|
||||
|
||||
# Skip the test for product builds (which only work when installed in a JDK), to
|
||||
# avoid exiting with an error and causing make to halt.
|
||||
NO_TEST_MSG = \
|
||||
echo "$@: skipping the test--this build must be tested in a JDK."
|
||||
|
||||
NO_JAVA_HOME_MSG = \
|
||||
echo "JAVA_HOME must be set to run this test."
|
||||
|
||||
DATA_MODE = $(DATA_MODE/$(BUILDARCH))
|
||||
JAVA_FLAG = $(JAVA_FLAG/$(DATA_MODE))
|
||||
|
||||
DATA_MODE/i486 = 32
|
||||
DATA_MODE/sparc = 32
|
||||
DATA_MODE/sparcv9 = 64
|
||||
DATA_MODE/amd64 = 64
|
||||
DATA_MODE/ia64 = 64
|
||||
DATA_MODE/zero = $(ARCH_DATA_MODEL)
|
||||
|
||||
JAVA_FLAG/32 = -d32
|
||||
JAVA_FLAG/64 = -d64
|
||||
|
||||
WRONG_DATA_MODE_MSG = \
|
||||
echo "JAVA_HOME must point to a $(DATA_MODE)-bit OpenJDK."
|
||||
|
||||
CROSS_COMPILING_MSG = \
|
||||
echo "Cross compiling for ARCH $(CROSS_COMPILE_ARCH), skipping gamma run."
|
||||
|
||||
test_gamma: $(BUILDTREE_MAKE) $(GAMMADIR)/make/test/Queens.java
|
||||
@echo Creating $@ ...
|
||||
$(QUIETLY) ( \
|
||||
echo "#!/bin/sh"; \
|
||||
echo ""; \
|
||||
$(BUILDTREE_COMMENT); \
|
||||
echo ""; \
|
||||
echo "# Include environment settings for gamma run"; \
|
||||
echo ""; \
|
||||
echo ". ./env.sh"; \
|
||||
echo ""; \
|
||||
echo "# Do not run gamma test for cross compiles"; \
|
||||
echo ""; \
|
||||
echo "if [ -n \"$(CROSS_COMPILE_ARCH)\" ]; then "; \
|
||||
echo " $(CROSS_COMPILING_MSG)"; \
|
||||
echo " exit 0"; \
|
||||
echo "fi"; \
|
||||
echo ""; \
|
||||
echo "# Make sure JAVA_HOME is set as it is required for gamma"; \
|
||||
echo ""; \
|
||||
echo "if [ -z \"\$${JAVA_HOME}\" ]; then "; \
|
||||
echo " $(NO_JAVA_HOME_MSG)"; \
|
||||
echo " exit 0"; \
|
||||
echo "fi"; \
|
||||
echo ""; \
|
||||
echo "# Check JAVA_HOME version to be used for the test"; \
|
||||
echo ""; \
|
||||
echo "\$${JAVA_HOME}/bin/java $(JAVA_FLAG) -fullversion > /dev/null 2>&1"; \
|
||||
echo "if [ \$$? -ne 0 ]; then "; \
|
||||
echo " $(WRONG_DATA_MODE_MSG)"; \
|
||||
echo " exit 0"; \
|
||||
echo "fi"; \
|
||||
echo ""; \
|
||||
echo "GAMMA_PROG=gamma"; \
|
||||
echo ""; \
|
||||
echo "if [ \"$(OS_VENDOR)\" = \"Darwin\" ]; then "; \
|
||||
echo " # Ensure architecture for gamma and JAVA_HOME is the same."; \
|
||||
echo " # NOTE: gamma assumes the OpenJDK directory layout."; \
|
||||
echo ""; \
|
||||
echo " GAMMA_ARCH=\"\`file \$${GAMMA_PROG} | awk '{print \$$NF}'\`\""; \
|
||||
echo " JVM_LIB=\"\$${JAVA_HOME}/jre/lib/libjava.$(LIBRARY_SUFFIX)\""; \
|
||||
echo " if [ ! -f \$${JVM_LIB} ]; then"; \
|
||||
echo " JVM_LIB=\"\$${JAVA_HOME}/jre/lib/$${LIBARCH}/libjava.$(LIBRARY_SUFFIX)\""; \
|
||||
echo " fi"; \
|
||||
echo " if [ ! -f \$${JVM_LIB} ] || [ -z \"\`file \$${JVM_LIB} | grep \$${GAMMA_ARCH}\`\" ]; then "; \
|
||||
echo " $(WRONG_DATA_MODE_MSG)"; \
|
||||
echo " exit 0"; \
|
||||
echo " fi"; \
|
||||
echo "fi"; \
|
||||
echo ""; \
|
||||
echo "# Compile Queens program for test"; \
|
||||
echo ""; \
|
||||
echo "rm -f Queens.class"; \
|
||||
echo "\$${JAVA_HOME}/bin/javac -d . $(GAMMADIR)/make/test/Queens.java"; \
|
||||
echo ""; \
|
||||
echo "# Set library path solely for gamma launcher test run"; \
|
||||
echo ""; \
|
||||
echo "LD_LIBRARY_PATH=.:$${LD_LIBRARY_PATH:+$$LD_LIBRARY_PATH:}\$${JAVA_HOME}/jre/lib/${LIBARCH}/native_threads:\$${JAVA_HOME}/jre/lib/${LIBARCH}:${GCC_LIB}"; \
|
||||
echo "export LD_LIBRARY_PATH"; \
|
||||
echo "unset LD_LIBRARY_PATH_32"; \
|
||||
echo "unset LD_LIBRARY_PATH_64"; \
|
||||
echo ""; \
|
||||
echo "if [ \"$(OS_VENDOR)\" = \"Darwin\" ]; then "; \
|
||||
echo " DYLD_LIBRARY_PATH=.:$${DYLD_LIBRARY_PATH:+$$DYLD_LIBRARY_PATH:}\$${JAVA_HOME}/jre/lib/native_threads:\$${JAVA_HOME}/jre/lib:$${DYLD_LIBRARY_PATH:+$$DYLD_LIBRARY_PATH:}\$${JAVA_HOME}/jre/lib/${LIBARCH}/native_threads:\$${JAVA_HOME}/jre/lib/${LIBARCH}:${GCC_LIB}"; \
|
||||
echo " export DYLD_LIBRARY_PATH"; \
|
||||
echo "fi"; \
|
||||
echo ""; \
|
||||
echo "# Use the gamma launcher and JAVA_HOME to run the test"; \
|
||||
echo ""; \
|
||||
echo "./\$${GAMMA_PROG} $(TESTFLAGS) Queens < /dev/null"; \
|
||||
) > $@
|
||||
$(QUIETLY) chmod +x $@
|
||||
|
||||
FORCE:
|
||||
|
||||
.PHONY: all FORCE
|
||||
|
@ -168,12 +168,12 @@ endif
|
||||
# conversions which might affect the values. To avoid that, we need to turn
|
||||
# it off explicitly.
|
||||
ifneq "$(shell expr \( $(CC_VER_MAJOR) \> 4 \) \| \( \( $(CC_VER_MAJOR) = 4 \) \& \( $(CC_VER_MINOR) \>= 3 \) \))" "0"
|
||||
ACCEPTABLE_WARNINGS = -Wpointer-arith -Wsign-compare
|
||||
WARNING_FLAGS = -Wpointer-arith -Wsign-compare -Wundef
|
||||
else
|
||||
ACCEPTABLE_WARNINGS = -Wpointer-arith -Wconversion -Wsign-compare
|
||||
WARNING_FLAGS = -Wpointer-arith -Wconversion -Wsign-compare -Wundef
|
||||
endif
|
||||
|
||||
CFLAGS_WARN/DEFAULT = $(WARNINGS_ARE_ERRORS) $(ACCEPTABLE_WARNINGS)
|
||||
CFLAGS_WARN/DEFAULT = $(WARNINGS_ARE_ERRORS) $(WARNING_FLAGS)
|
||||
# Special cases
|
||||
CFLAGS_WARN/BYFILE = $(CFLAGS_WARN/$@)$(CFLAGS_WARN/DEFAULT$(CFLAGS_WARN/$@))
|
||||
# XXXDARWIN: for _dyld_bind_fully_image_containing_address
|
||||
|
@ -1,5 +1,5 @@
|
||||
#
|
||||
# Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
# Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
#
|
||||
# This code is free software; you can redistribute it and/or modify it
|
||||
@ -24,7 +24,7 @@
|
||||
|
||||
# Rules to build serviceability agent library, used by vm.make
|
||||
|
||||
# libsaproc.so: serviceability agent
|
||||
# libsaproc.so(dylib): serviceability agent
|
||||
SAPROC = saproc
|
||||
|
||||
ifeq ($(OS_VENDOR), Darwin)
|
||||
@ -37,7 +37,7 @@ AGENT_DIR = $(GAMMADIR)/agent
|
||||
|
||||
SASRCDIR = $(AGENT_DIR)/src/os/$(Platform_os_family)
|
||||
|
||||
NON_STUB_SASRCFILES = $(SASRCDIR)/salibelf.c \
|
||||
BSD_NON_STUB_SASRCFILES = $(SASRCDIR)/salibelf.c \
|
||||
$(SASRCDIR)/symtab.c \
|
||||
$(SASRCDIR)/libproc_impl.c \
|
||||
$(SASRCDIR)/ps_proc.c \
|
||||
@ -45,13 +45,19 @@ NON_STUB_SASRCFILES = $(SASRCDIR)/salibelf.c \
|
||||
$(SASRCDIR)/BsdDebuggerLocal.c \
|
||||
$(AGENT_DIR)/src/share/native/sadis.c
|
||||
|
||||
DARWIN_NON_STUB_SASRCFILES = $(SASRCDIR)/symtab.c \
|
||||
$(SASRCDIR)/libproc_impl.c \
|
||||
$(SASRCDIR)/ps_core.c \
|
||||
$(SASRCDIR)/MacosxDebuggerLocal.m \
|
||||
$(AGENT_DIR)/src/share/native/sadis.c
|
||||
|
||||
ifeq ($(OS_VENDOR), FreeBSD)
|
||||
SASRCFILES = $(NON_STUB_SASRCFILES)
|
||||
SASRCFILES = $(BSD_NON_STUB_SASRCFILES)
|
||||
SALIBS = -lutil -lthread_db
|
||||
SAARCH = $(ARCHFLAG)
|
||||
else
|
||||
ifeq ($(OS_VENDOR), Darwin)
|
||||
SASRCFILES = $(SASRCDIR)/MacosxDebuggerLocal.m
|
||||
SASRCFILES = $(DARWIN_NON_STUB_SASRCFILES)
|
||||
SALIBS = -g -framework Foundation -F/System/Library/Frameworks/JavaVM.framework/Frameworks -framework JavaNativeFoundation -framework Security -framework CoreFoundation
|
||||
#objc compiler blows up on -march=i586, perhaps it should not be included in the macosx intel 32-bit C++ compiles?
|
||||
SAARCH = $(subst -march=i586,,$(ARCHFLAG))
|
||||
|
@ -302,7 +302,7 @@ ifneq ($(OSNAME),windows)
|
||||
endif
|
||||
|
||||
# Required make macro settings for all platforms
|
||||
MAKE_ARGS += JAVA_HOME=$(ABS_BOOTDIR)
|
||||
MAKE_ARGS += BOOTDIR=$(ABS_BOOTDIR)
|
||||
MAKE_ARGS += OUTPUTDIR=$(ABS_OUTPUTDIR)
|
||||
MAKE_ARGS += GAMMADIR=$(ABS_GAMMADIR)
|
||||
MAKE_ARGS += MAKE_VERBOSE=$(MAKE_VERBOSE)
|
||||
@ -337,9 +337,6 @@ EXPORT_LIST += $(EXPORT_INCLUDE_DIR)/jni.h
|
||||
EXPORT_LIST += $(EXPORT_INCLUDE_DIR)/$(JDK_INCLUDE_SUBDIR)/jni_md.h
|
||||
EXPORT_LIST += $(EXPORT_INCLUDE_DIR)/jmm.h
|
||||
|
||||
# By default, run Queens test after building
|
||||
TEST_IN_BUILD ?= true
|
||||
|
||||
ifndef JAVASE_EMBEDDED
|
||||
EXPORT_LIST += $(EXPORT_INCLUDE_DIR)/jfr.h
|
||||
endif
|
||||
|
@ -69,7 +69,7 @@ ifeq ($(INCLUDE_CDS), false)
|
||||
CXXFLAGS += -DINCLUDE_CDS=0
|
||||
CFLAGS += -DINCLUDE_CDS=0
|
||||
|
||||
Src_Files_EXCLUDE += metaspaceShared.cpp
|
||||
Src_Files_EXCLUDE += filemap.cpp metaspaceShared.cpp
|
||||
endif
|
||||
|
||||
ifeq ($(INCLUDE_ALL_GCS), false)
|
||||
|
@ -35,7 +35,7 @@ HOTSPOT_VM_COPYRIGHT=Copyright 2013
|
||||
|
||||
HS_MAJOR_VER=25
|
||||
HS_MINOR_VER=0
|
||||
HS_BUILD_NUMBER=22
|
||||
HS_BUILD_NUMBER=24
|
||||
|
||||
JDK_MAJOR_VER=1
|
||||
JDK_MINOR_VER=8
|
||||
|
@ -1,5 +1,5 @@
|
||||
#
|
||||
# Copyright (c) 2006, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
# Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
#
|
||||
# This code is free software; you can redistribute it and/or modify it
|
||||
@ -97,15 +97,18 @@ jprt.my.linux.ppcsflt.jdk7=linux_ppcsflt_2.6
|
||||
jprt.my.linux.ppcsflt.jdk7u8=${jprt.my.linux.ppcsflt.jdk7}
|
||||
jprt.my.linux.ppcsflt=${jprt.my.linux.ppcsflt.${jprt.tools.default.release}}
|
||||
|
||||
jprt.my.linux.armvfp.jdk8=linux_armvfp_2.6
|
||||
jprt.my.linux.armvfp.jdk7=linux_armvfp_2.6
|
||||
jprt.my.linux.armvfp.jdk7u8=${jprt.my.linux.armvfp.jdk7}
|
||||
jprt.my.linux.armvfp=${jprt.my.linux.armvfp.${jprt.tools.default.release}}
|
||||
jprt.my.linux.armvfpsflt.jdk8=linux_armvfpsflt_2.6
|
||||
jprt.my.linux.armvfpsflt=${jprt.my.linux.armvfpsflt.${jprt.tools.default.release}}
|
||||
|
||||
jprt.my.linux.armv6.jdk8=linux_armv6_2.6
|
||||
jprt.my.linux.armv6.jdk7=linux_armv6_2.6
|
||||
jprt.my.linux.armv6.jdk7u8=${jprt.my.linux.armv6.jdk7}
|
||||
jprt.my.linux.armv6=${jprt.my.linux.armv6.${jprt.tools.default.release}}
|
||||
jprt.my.linux.armvfphflt.jdk8=linux_armvfphflt_2.6
|
||||
jprt.my.linux.armvfphflt=${jprt.my.linux.armvfphflt.${jprt.tools.default.release}}
|
||||
|
||||
# The ARM GP vfp-sflt build is not currently supported
|
||||
#jprt.my.linux.armvs.jdk8=linux_armvs_2.6
|
||||
#jprt.my.linux.armvs=${jprt.my.linux.armvs.${jprt.tools.default.release}}
|
||||
|
||||
jprt.my.linux.armvh.jdk8=linux_armvh_2.6
|
||||
jprt.my.linux.armvh=${jprt.my.linux.armvh.${jprt.tools.default.release}}
|
||||
|
||||
jprt.my.linux.armsflt.jdk8=linux_armsflt_2.6
|
||||
jprt.my.linux.armsflt.jdk7=linux_armsflt_2.6
|
||||
@ -139,7 +142,7 @@ jprt.build.targets.standard= \
|
||||
${jprt.my.macosx.x64}-{product|fastdebug|debug}, \
|
||||
${jprt.my.windows.i586}-{product|fastdebug|debug}, \
|
||||
${jprt.my.windows.x64}-{product|fastdebug|debug}, \
|
||||
${jprt.my.linux.armv6}-{product|fastdebug}
|
||||
${jprt.my.linux.armvh}-{product|fastdebug}
|
||||
|
||||
jprt.build.targets.open= \
|
||||
${jprt.my.solaris.i586}-{productOpen}, \
|
||||
@ -151,7 +154,8 @@ jprt.build.targets.embedded= \
|
||||
${jprt.my.linux.ppc}-{productEmb|fastdebugEmb}, \
|
||||
${jprt.my.linux.ppcv2}-{productEmb|fastdebugEmb}, \
|
||||
${jprt.my.linux.ppcsflt}-{productEmb|fastdebugEmb}, \
|
||||
${jprt.my.linux.armvfp}-{productEmb|fastdebugEmb}, \
|
||||
${jprt.my.linux.armvfpsflt}-{productEmb|fastdebugEmb}, \
|
||||
${jprt.my.linux.armvfphflt}-{productEmb|fastdebugEmb}, \
|
||||
${jprt.my.linux.armsflt}-{productEmb|fastdebugEmb}
|
||||
|
||||
jprt.build.targets.all=${jprt.build.targets.standard}, \
|
||||
|
@ -300,63 +300,42 @@ platform_zero: $(GAMMADIR)/make/$(OSNAME)/platform_zero.in
|
||||
|
||||
$(TARGETS_C2): $(SUBDIRS_C2)
|
||||
cd $(OSNAME)_$(BUILDARCH)_compiler2/$@ && $(MAKE) $(MFLAGS)
|
||||
ifeq ($(TEST_IN_BUILD),true)
|
||||
cd $(OSNAME)_$(BUILDARCH)_compiler2/$@ && ./test_gamma
|
||||
endif
|
||||
ifdef INSTALL
|
||||
cd $(OSNAME)_$(BUILDARCH)_compiler2/$@ && $(MAKE) $(MFLAGS) install
|
||||
endif
|
||||
|
||||
$(TARGETS_TIERED): $(SUBDIRS_TIERED)
|
||||
cd $(OSNAME)_$(BUILDARCH)_tiered/$(patsubst %tiered,%,$@) && $(MAKE) $(MFLAGS)
|
||||
ifeq ($(TEST_IN_BUILD),true)
|
||||
cd $(OSNAME)_$(BUILDARCH)_tiered/$(patsubst %tiered,%,$@) && ./test_gamma
|
||||
endif
|
||||
ifdef INSTALL
|
||||
cd $(OSNAME)_$(BUILDARCH)_tiered/$(patsubst %tiered,%,$@) && $(MAKE) $(MFLAGS) install
|
||||
endif
|
||||
|
||||
$(TARGETS_C1): $(SUBDIRS_C1)
|
||||
cd $(OSNAME)_$(BUILDARCH)_compiler1/$(patsubst %1,%,$@) && $(MAKE) $(MFLAGS)
|
||||
ifeq ($(TEST_IN_BUILD),true)
|
||||
cd $(OSNAME)_$(BUILDARCH)_compiler1/$(patsubst %1,%,$@) && ./test_gamma
|
||||
endif
|
||||
ifdef INSTALL
|
||||
cd $(OSNAME)_$(BUILDARCH)_compiler1/$(patsubst %1,%,$@) && $(MAKE) $(MFLAGS) install
|
||||
endif
|
||||
|
||||
$(TARGETS_CORE): $(SUBDIRS_CORE)
|
||||
cd $(OSNAME)_$(BUILDARCH)_core/$(patsubst %core,%,$@) && $(MAKE) $(MFLAGS)
|
||||
ifeq ($(TEST_IN_BUILD),true)
|
||||
cd $(OSNAME)_$(BUILDARCH)_core/$(patsubst %core,%,$@) && ./test_gamma
|
||||
endif
|
||||
ifdef INSTALL
|
||||
cd $(OSNAME)_$(BUILDARCH)_core/$(patsubst %core,%,$@) && $(MAKE) $(MFLAGS) install
|
||||
endif
|
||||
|
||||
$(TARGETS_ZERO): $(SUBDIRS_ZERO)
|
||||
cd $(OSNAME)_$(VARIANTARCH)_zero/$(patsubst %zero,%,$@) && $(MAKE) $(MFLAGS)
|
||||
ifeq ($(TEST_IN_BUILD),true)
|
||||
cd $(OSNAME)_$(VARIANTARCH)_zero/$(patsubst %zero,%,$@) && ./test_gamma
|
||||
endif
|
||||
ifdef INSTALL
|
||||
cd $(OSNAME)_$(VARIANTARCH)_zero/$(patsubst %zero,%,$@) && $(MAKE) $(MFLAGS) install
|
||||
endif
|
||||
|
||||
$(TARGETS_SHARK): $(SUBDIRS_SHARK)
|
||||
cd $(OSNAME)_$(VARIANTARCH)_shark/$(patsubst %shark,%,$@) && $(MAKE) $(MFLAGS)
|
||||
ifeq ($(TEST_IN_BUILD),true)
|
||||
cd $(OSNAME)_$(VARIANTARCH)_shark/$(patsubst %shark,%,$@) && ./test_gamma
|
||||
endif
|
||||
ifdef INSTALL
|
||||
cd $(OSNAME)_$(VARIANTARCH)_shark/$(patsubst %shark,%,$@) && $(MAKE) $(MFLAGS) install
|
||||
endif
|
||||
|
||||
$(TARGETS_MINIMAL1): $(SUBDIRS_MINIMAL1)
|
||||
cd $(OSNAME)_$(BUILDARCH)_minimal1/$(patsubst %minimal1,%,$@) && $(MAKE) $(MFLAGS)
|
||||
ifeq ($(TEST_IN_BUILD),true)
|
||||
cd $(OSNAME)_$(BUILDARCH)_minimal1/$(patsubst %minimal1,%,$@) && ./test_gamma
|
||||
endif
|
||||
ifdef INSTALL
|
||||
cd $(OSNAME)_$(BUILDARCH)_minimal1/$(patsubst %minimal1,%,$@) && $(MAKE) $(MFLAGS) install
|
||||
endif
|
||||
|
@ -50,7 +50,6 @@
|
||||
# jvmti.make - generate JVMTI bindings from the spec (JSR-163)
|
||||
# sa.make - generate SA jar file and natives
|
||||
# env.[ck]sh - environment settings
|
||||
# test_gamma - script to run the Queens program
|
||||
#
|
||||
# The makefiles are split this way so that "make foo" will run faster by not
|
||||
# having to read the dependency files for the vm.
|
||||
@ -64,9 +63,6 @@ include $(GAMMADIR)/make/altsrc.make
|
||||
# 'gmake MAKE_VERBOSE=y' or 'gmake QUIETLY=' gives all the gory details.
|
||||
QUIETLY$(MAKE_VERBOSE) = @
|
||||
|
||||
# For now, until the compiler is less wobbly:
|
||||
TESTFLAGS = -Xbatch -showversion
|
||||
|
||||
ifeq ($(findstring true, $(JVM_VARIANT_ZERO) $(JVM_VARIANT_ZEROSHARK)), true)
|
||||
PLATFORM_FILE = $(shell dirname $(shell dirname $(shell pwd)))/platform_zero
|
||||
else
|
||||
@ -128,7 +124,7 @@ SUBMAKE_DIRS = $(addprefix $(PLATFORM_DIR)/,$(TARGETS))
|
||||
BUILDTREE_MAKE = $(GAMMADIR)/make/$(OS_FAMILY)/makefiles/buildtree.make
|
||||
|
||||
BUILDTREE_TARGETS = Makefile flags.make flags_vm.make vm.make adlc.make jvmti.make sa.make \
|
||||
env.sh env.csh jdkpath.sh .dbxrc test_gamma
|
||||
env.sh env.csh jdkpath.sh
|
||||
|
||||
BUILDTREE_VARS = GAMMADIR=$(GAMMADIR) OS_FAMILY=$(OS_FAMILY) \
|
||||
SRCARCH=$(SRCARCH) BUILDARCH=$(BUILDARCH) LIBARCH=$(LIBARCH) VARIANT=$(VARIANT)
|
||||
@ -345,7 +341,7 @@ env.sh: $(BUILDTREE_MAKE)
|
||||
@echo Creating $@ ...
|
||||
$(QUIETLY) ( \
|
||||
$(BUILDTREE_COMMENT); \
|
||||
[ -n "$$JAVA_HOME" ] && { echo ": \$${JAVA_HOME:=$${JAVA_HOME}}"; }; \
|
||||
{ echo "JAVA_HOME=$(JDK_IMPORT_PATH)"; }; \
|
||||
{ \
|
||||
echo "CLASSPATH=$${CLASSPATH:+$$CLASSPATH:}.:\$${JAVA_HOME}/jre/lib/rt.jar:\$${JAVA_HOME}/jre/lib/i18n.jar"; \
|
||||
} | sed s:$${JAVA_HOME:--------}:\$${JAVA_HOME}:g; \
|
||||
@ -357,8 +353,7 @@ env.csh: env.sh
|
||||
@echo Creating $@ ...
|
||||
$(QUIETLY) ( \
|
||||
$(BUILDTREE_COMMENT); \
|
||||
[ -n "$$JAVA_HOME" ] && \
|
||||
{ echo "if (! \$$?JAVA_HOME) setenv JAVA_HOME \"$$JAVA_HOME\""; }; \
|
||||
{ echo "setenv JAVA_HOME \"$(JDK_IMPORT_PATH)\""; }; \
|
||||
sed -n 's/^\([A-Za-z_][A-Za-z0-9_]*\)=/setenv \1 /p' $?; \
|
||||
) > $@
|
||||
|
||||
@ -369,119 +364,6 @@ jdkpath.sh: $(BUILDTREE_MAKE)
|
||||
echo "JDK=${JAVA_HOME}"; \
|
||||
) > $@
|
||||
|
||||
.dbxrc: $(BUILDTREE_MAKE)
|
||||
@echo Creating $@ ...
|
||||
$(QUIETLY) ( \
|
||||
echo "echo '# Loading $(PLATFORM_DIR)/$(TARGET)/.dbxrc'"; \
|
||||
echo "if [ -f \"\$${HOTSPOT_DBXWARE}\" ]"; \
|
||||
echo "then"; \
|
||||
echo " source \"\$${HOTSPOT_DBXWARE}\""; \
|
||||
echo "elif [ -f \"\$$HOME/.dbxrc\" ]"; \
|
||||
echo "then"; \
|
||||
echo " source \"\$$HOME/.dbxrc\""; \
|
||||
echo "fi"; \
|
||||
) > $@
|
||||
|
||||
# Skip the test for product builds (which only work when installed in a JDK), to
|
||||
# avoid exiting with an error and causing make to halt.
|
||||
NO_TEST_MSG = \
|
||||
echo "$@: skipping the test--this build must be tested in a JDK."
|
||||
|
||||
NO_JAVA_HOME_MSG = \
|
||||
echo "JAVA_HOME must be set to run this test."
|
||||
|
||||
DATA_MODE = $(DATA_MODE/$(BUILDARCH))
|
||||
JAVA_FLAG = $(JAVA_FLAG/$(DATA_MODE))
|
||||
|
||||
DATA_MODE/i486 = 32
|
||||
DATA_MODE/sparc = 32
|
||||
DATA_MODE/sparcv9 = 64
|
||||
DATA_MODE/amd64 = 64
|
||||
DATA_MODE/ia64 = 64
|
||||
DATA_MODE/zero = $(ARCH_DATA_MODEL)
|
||||
|
||||
JAVA_FLAG/32 = -d32
|
||||
JAVA_FLAG/64 = -d64
|
||||
|
||||
WRONG_DATA_MODE_MSG = \
|
||||
echo "JAVA_HOME must point to a $(DATA_MODE)-bit OpenJDK."
|
||||
|
||||
CROSS_COMPILING_MSG = \
|
||||
echo "Cross compiling for ARCH $(CROSS_COMPILE_ARCH), skipping gamma run."
|
||||
|
||||
test_gamma: $(BUILDTREE_MAKE) $(GAMMADIR)/make/test/Queens.java
|
||||
@echo Creating $@ ...
|
||||
$(QUIETLY) ( \
|
||||
echo "#!/bin/sh"; \
|
||||
echo ""; \
|
||||
$(BUILDTREE_COMMENT); \
|
||||
echo ""; \
|
||||
echo "# Include environment settings for gamma run"; \
|
||||
echo ""; \
|
||||
echo ". ./env.sh"; \
|
||||
echo ""; \
|
||||
echo "# Do not run gamma test for cross compiles"; \
|
||||
echo ""; \
|
||||
echo "if [ -n \"$(CROSS_COMPILE_ARCH)\" ]; then "; \
|
||||
echo " $(CROSS_COMPILING_MSG)"; \
|
||||
echo " exit 0"; \
|
||||
echo "fi"; \
|
||||
echo ""; \
|
||||
echo "# Make sure JAVA_HOME is set as it is required for gamma"; \
|
||||
echo ""; \
|
||||
echo "if [ -z \"\$${JAVA_HOME}\" ]; then "; \
|
||||
echo " $(NO_JAVA_HOME_MSG)"; \
|
||||
echo " exit 0"; \
|
||||
echo "fi"; \
|
||||
echo ""; \
|
||||
echo "# Check JAVA_HOME version to be used for the test"; \
|
||||
echo ""; \
|
||||
echo "\$${JAVA_HOME}/bin/java $(JAVA_FLAG) -fullversion > /dev/null 2>&1"; \
|
||||
echo "if [ \$$? -ne 0 ]; then "; \
|
||||
echo " $(WRONG_DATA_MODE_MSG)"; \
|
||||
echo " exit 0"; \
|
||||
echo "fi"; \
|
||||
echo ""; \
|
||||
echo "GAMMA_PROG=gamma"; \
|
||||
echo ""; \
|
||||
echo "if [ \"$(OS_VENDOR)\" = \"Darwin\" ]; then "; \
|
||||
echo " # Ensure architecture for gamma and JAVA_HOME is the same."; \
|
||||
echo " # NOTE: gamma assumes the OpenJDK directory layout."; \
|
||||
echo ""; \
|
||||
echo " GAMMA_ARCH=\"\`file \$${GAMMA_PROG} | awk '{print \$$NF}'\`\""; \
|
||||
echo " JVM_LIB=\"\$${JAVA_HOME}/jre/lib/libjava.$(LIBRARY_SUFFIX)\""; \
|
||||
echo " if [ ! -f \$${JVM_LIB} ]; then"; \
|
||||
echo " JVM_LIB=\"\$${JAVA_HOME}/jre/lib/$${LIBARCH}/libjava.$(LIBRARY_SUFFIX)\""; \
|
||||
echo " fi"; \
|
||||
echo " if [ ! -f \$${JVM_LIB} ] || [ -z \"\`file \$${JVM_LIB} | grep \$${GAMMA_ARCH}\`\" ]; then "; \
|
||||
echo " $(WRONG_DATA_MODE_MSG)"; \
|
||||
echo " exit 0"; \
|
||||
echo " fi"; \
|
||||
echo "fi"; \
|
||||
echo ""; \
|
||||
echo "# Compile Queens program for test"; \
|
||||
echo ""; \
|
||||
echo "rm -f Queens.class"; \
|
||||
echo "\$${JAVA_HOME}/bin/javac -d . $(GAMMADIR)/make/test/Queens.java"; \
|
||||
echo ""; \
|
||||
echo "# Set library path solely for gamma launcher test run"; \
|
||||
echo ""; \
|
||||
echo "LD_LIBRARY_PATH=.:$${LD_LIBRARY_PATH:+$$LD_LIBRARY_PATH:}\$${JAVA_HOME}/jre/lib/${LIBARCH}/native_threads:\$${JAVA_HOME}/jre/lib/${LIBARCH}:${GCC_LIB}"; \
|
||||
echo "export LD_LIBRARY_PATH"; \
|
||||
echo "unset LD_LIBRARY_PATH_32"; \
|
||||
echo "unset LD_LIBRARY_PATH_64"; \
|
||||
echo ""; \
|
||||
echo "if [ \"$(OS_VENDOR)\" = \"Darwin\" ]; then "; \
|
||||
echo " DYLD_LIBRARY_PATH=.:$${DYLD_LIBRARY_PATH:+$$DYLD_LIBRARY_PATH:}\$${JAVA_HOME}/jre/lib/native_threads:\$${JAVA_HOME}/jre/lib:$${DYLD_LIBRARY_PATH:+$$DYLD_LIBRARY_PATH:}\$${JAVA_HOME}/jre/lib/${LIBARCH}/native_threads:\$${JAVA_HOME}/jre/lib/${LIBARCH}:${GCC_LIB}"; \
|
||||
echo " export DYLD_LIBRARY_PATH"; \
|
||||
echo "fi"; \
|
||||
echo ""; \
|
||||
echo "# Use the gamma launcher and JAVA_HOME to run the test"; \
|
||||
echo ""; \
|
||||
echo "./\$${GAMMA_PROG} $(TESTFLAGS) Queens < /dev/null"; \
|
||||
) > $@
|
||||
$(QUIETLY) chmod +x $@
|
||||
|
||||
FORCE:
|
||||
|
||||
.PHONY: all FORCE
|
||||
|
@ -131,12 +131,12 @@ WARNINGS_ARE_ERRORS = -Werror
|
||||
# conversions which might affect the values. To avoid that, we need to turn
|
||||
# it off explicitly.
|
||||
ifneq "$(shell expr \( $(CC_VER_MAJOR) \> 4 \) \| \( \( $(CC_VER_MAJOR) = 4 \) \& \( $(CC_VER_MINOR) \>= 3 \) \))" "0"
|
||||
ACCEPTABLE_WARNINGS = -Wpointer-arith -Wsign-compare
|
||||
WARNING_FLAGS = -Wpointer-arith -Wsign-compare -Wundef
|
||||
else
|
||||
ACCEPTABLE_WARNINGS = -Wpointer-arith -Wconversion -Wsign-compare
|
||||
WARNING_FLAGS = -Wpointer-arith -Wconversion -Wsign-compare -Wundef
|
||||
endif
|
||||
|
||||
CFLAGS_WARN/DEFAULT = $(WARNINGS_ARE_ERRORS) $(ACCEPTABLE_WARNINGS)
|
||||
CFLAGS_WARN/DEFAULT = $(WARNINGS_ARE_ERRORS) $(WARNING_FLAGS)
|
||||
# Special cases
|
||||
CFLAGS_WARN/BYFILE = $(CFLAGS_WARN/$@)$(CFLAGS_WARN/DEFAULT$(CFLAGS_WARN/$@))
|
||||
|
||||
|
@ -231,36 +231,24 @@ $(SUBDIRS_CORE): $(BUILDTREE_MAKE)
|
||||
|
||||
$(TARGETS_C2): $(SUBDIRS_C2)
|
||||
cd $(OSNAME)_$(BUILDARCH)_compiler2/$@ && $(MAKE) $(MFLAGS)
|
||||
ifeq ($(TEST_IN_BUILD),true)
|
||||
cd $(OSNAME)_$(BUILDARCH)_compiler2/$@ && ./test_gamma
|
||||
endif
|
||||
ifdef INSTALL
|
||||
cd $(OSNAME)_$(BUILDARCH)_compiler2/$@ && $(MAKE) $(MFLAGS) install
|
||||
endif
|
||||
|
||||
$(TARGETS_TIERED): $(SUBDIRS_TIERED)
|
||||
cd $(OSNAME)_$(BUILDARCH)_tiered/$(patsubst %tiered,%,$@) && $(MAKE) $(MFLAGS)
|
||||
ifeq ($(TEST_IN_BUILD),true)
|
||||
cd $(OSNAME)_$(BUILDARCH)_tiered/$(patsubst %tiered,%,$@) && ./test_gamma
|
||||
endif
|
||||
ifdef INSTALL
|
||||
cd $(OSNAME)_$(BUILDARCH)_tiered/$(patsubst %tiered,%,$@) && $(MAKE) $(MFLAGS) install
|
||||
endif
|
||||
|
||||
$(TARGETS_C1): $(SUBDIRS_C1)
|
||||
cd $(OSNAME)_$(BUILDARCH)_compiler1/$(patsubst %1,%,$@) && $(MAKE) $(MFLAGS)
|
||||
ifeq ($(TEST_IN_BUILD),true)
|
||||
cd $(OSNAME)_$(BUILDARCH)_compiler1/$(patsubst %1,%,$@) && ./test_gamma
|
||||
endif
|
||||
ifdef INSTALL
|
||||
cd $(OSNAME)_$(BUILDARCH)_compiler1/$(patsubst %1,%,$@) && $(MAKE) $(MFLAGS) install
|
||||
endif
|
||||
|
||||
$(TARGETS_CORE): $(SUBDIRS_CORE)
|
||||
cd $(OSNAME)_$(BUILDARCH)_core/$(patsubst %core,%,$@) && $(MAKE) $(MFLAGS)
|
||||
ifeq ($(TEST_IN_BUILD),true)
|
||||
cd $(OSNAME)_$(BUILDARCH)_core/$(patsubst %core,%,$@) && ./test_gamma
|
||||
endif
|
||||
ifdef INSTALL
|
||||
cd $(OSNAME)_$(BUILDARCH)_core/$(patsubst %core,%,$@) && $(MAKE) $(MFLAGS) install
|
||||
endif
|
||||
|
@ -50,21 +50,19 @@
|
||||
# jvmti.make - generate JVMTI bindings from the spec (JSR-163)
|
||||
# sa.make - generate SA jar file and natives
|
||||
# env.[ck]sh - environment settings
|
||||
# test_gamma - script to run the Queens program
|
||||
#
|
||||
# The makefiles are split this way so that "make foo" will run faster by not
|
||||
# having to read the dependency files for the vm.
|
||||
|
||||
-include $(SPEC)
|
||||
include $(GAMMADIR)/make/scm.make
|
||||
include $(GAMMADIR)/make/defs.make
|
||||
include $(GAMMADIR)/make/altsrc.make
|
||||
|
||||
|
||||
# 'gmake MAKE_VERBOSE=y' or 'gmake QUIETLY=' gives all the gory details.
|
||||
QUIETLY$(MAKE_VERBOSE) = @
|
||||
|
||||
# For now, until the compiler is less wobbly:
|
||||
TESTFLAGS = -Xbatch -Xmx32m -showversion
|
||||
|
||||
### maye ARCH_XXX instead?
|
||||
ifdef USE_GCC
|
||||
PLATFORM_FILE = $(GAMMADIR)/make/$(OS_FAMILY)/platform_$(BUILDARCH).gcc
|
||||
@ -119,7 +117,7 @@ SUBMAKE_DIRS = $(addprefix $(PLATFORM_DIR)/,$(TARGETS))
|
||||
BUILDTREE_MAKE = $(GAMMADIR)/make/$(OS_FAMILY)/makefiles/buildtree.make
|
||||
|
||||
BUILDTREE_TARGETS = Makefile flags.make flags_vm.make vm.make adlc.make jvmti.make sa.make \
|
||||
env.sh env.csh jdkpath.sh .dbxrc test_gamma
|
||||
env.sh env.csh jdkpath.sh
|
||||
|
||||
BUILDTREE_VARS = GAMMADIR=$(GAMMADIR) OS_FAMILY=$(OS_FAMILY) \
|
||||
ARCH=$(ARCH) BUILDARCH=$(BUILDARCH) LIBARCH=$(LIBARCH) VARIANT=$(VARIANT)
|
||||
@ -334,7 +332,7 @@ env.sh: $(BUILDTREE_MAKE)
|
||||
@echo Creating $@ ...
|
||||
$(QUIETLY) ( \
|
||||
$(BUILDTREE_COMMENT); \
|
||||
[ -n "$$JAVA_HOME" ] && { echo ": \$${JAVA_HOME:=$${JAVA_HOME}}"; }; \
|
||||
{ echo "JAVA_HOME=$(JDK_IMPORT_PATH)"; }; \
|
||||
{ \
|
||||
echo "CLASSPATH=$${CLASSPATH:+$$CLASSPATH:}.:\$${JAVA_HOME}/jre/lib/rt.jar:\$${JAVA_HOME}/jre/lib/i18n.jar"; \
|
||||
} | sed s:$${JAVA_HOME:--------}:\$${JAVA_HOME}:g; \
|
||||
@ -346,8 +344,7 @@ env.csh: env.sh
|
||||
@echo Creating $@ ...
|
||||
$(QUIETLY) ( \
|
||||
$(BUILDTREE_COMMENT); \
|
||||
[ -n "$$JAVA_HOME" ] && \
|
||||
{ echo "if (! \$$?JAVA_HOME) setenv JAVA_HOME \"$$JAVA_HOME\""; }; \
|
||||
{ echo "setenv JAVA_HOME \"$(JDK_IMPORT_PATH)\""; }; \
|
||||
sed -n 's/^\([A-Za-z_][A-Za-z0-9_]*\)=/setenv \1 /p' $?; \
|
||||
) > $@
|
||||
|
||||
@ -358,124 +355,6 @@ jdkpath.sh: $(BUILDTREE_MAKE)
|
||||
echo "JDK=${JAVA_HOME}"; \
|
||||
) > $@
|
||||
|
||||
.dbxrc: $(BUILDTREE_MAKE)
|
||||
@echo Creating $@ ...
|
||||
$(QUIETLY) ( \
|
||||
echo "echo '# Loading $(PLATFORM_DIR)/$(TARGET)/.dbxrc'"; \
|
||||
echo "if [ -f \"\$${HOTSPOT_DBXWARE}\" ]"; \
|
||||
echo "then"; \
|
||||
echo " source \"\$${HOTSPOT_DBXWARE}\""; \
|
||||
echo "elif [ -f \"\$$HOME/.dbxrc\" ]"; \
|
||||
echo "then"; \
|
||||
echo " source \"\$$HOME/.dbxrc\""; \
|
||||
echo "fi"; \
|
||||
) > $@
|
||||
|
||||
# Skip the test for product builds (which only work when installed in a JDK), to
|
||||
# avoid exiting with an error and causing make to halt.
|
||||
NO_TEST_MSG = \
|
||||
echo "$@: skipping the test--this build must be tested in a JDK."
|
||||
|
||||
NO_JAVA_HOME_MSG = \
|
||||
echo "JAVA_HOME must be set to run this test."
|
||||
|
||||
DATA_MODE = $(DATA_MODE/$(BUILDARCH))
|
||||
JAVA_FLAG = $(JAVA_FLAG/$(DATA_MODE))
|
||||
|
||||
DATA_MODE/i486 = 32
|
||||
DATA_MODE/sparc = 32
|
||||
DATA_MODE/sparcv9 = 64
|
||||
DATA_MODE/amd64 = 64
|
||||
DATA_MODE/ia64 = 64
|
||||
|
||||
# This bit is needed to enable local rebuilds.
|
||||
# Unless the makefile itself sets LP64, any environmental
|
||||
# setting of LP64 will interfere with the build.
|
||||
LP64_SETTING/32 = LP64 = \#empty
|
||||
LP64_SETTING/64 = LP64 = 1
|
||||
|
||||
JAVA_FLAG/32 = -d32
|
||||
JAVA_FLAG/64 = -d64
|
||||
|
||||
WRONG_DATA_MODE_MSG = \
|
||||
echo "JAVA_HOME must point to a $(DATA_MODE)-bit OpenJDK."
|
||||
|
||||
CROSS_COMPILING_MSG = \
|
||||
echo "Cross compiling for ARCH $(CROSS_COMPILE_ARCH), skipping gamma run."
|
||||
|
||||
test_gamma: $(BUILDTREE_MAKE) $(GAMMADIR)/make/test/Queens.java
|
||||
@echo Creating $@ ...
|
||||
$(QUIETLY) ( \
|
||||
echo "#!/bin/sh"; \
|
||||
echo ""; \
|
||||
$(BUILDTREE_COMMENT); \
|
||||
echo ""; \
|
||||
echo "# Include environment settings for gamma run"; \
|
||||
echo ""; \
|
||||
echo ". ./env.sh"; \
|
||||
echo ""; \
|
||||
echo "# Do not run gamma test for cross compiles"; \
|
||||
echo ""; \
|
||||
echo "if [ -n \"$(CROSS_COMPILE_ARCH)\" ]; then "; \
|
||||
echo " $(CROSS_COMPILING_MSG)"; \
|
||||
echo " exit 0"; \
|
||||
echo "fi"; \
|
||||
echo ""; \
|
||||
echo "# Make sure JAVA_HOME is set as it is required for gamma"; \
|
||||
echo ""; \
|
||||
echo "if [ -z \"\$${JAVA_HOME}\" ]; then "; \
|
||||
echo " $(NO_JAVA_HOME_MSG)"; \
|
||||
echo " exit 0"; \
|
||||
echo "fi"; \
|
||||
echo ""; \
|
||||
echo "# Check JAVA_HOME version to be used for the test"; \
|
||||
echo ""; \
|
||||
echo "\$${JAVA_HOME}/bin/java $(JAVA_FLAG) -fullversion > /dev/null 2>&1"; \
|
||||
echo "if [ \$$? -ne 0 ]; then "; \
|
||||
echo " $(WRONG_DATA_MODE_MSG)"; \
|
||||
echo " exit 0"; \
|
||||
echo "fi"; \
|
||||
echo ""; \
|
||||
echo "GAMMA_PROG=gamma"; \
|
||||
echo ""; \
|
||||
echo "if [ \"$(OS_VENDOR)\" = \"Darwin\" ]; then "; \
|
||||
echo " # Ensure architecture for gamma and JAVA_HOME is the same."; \
|
||||
echo " # NOTE: gamma assumes the OpenJDK directory layout."; \
|
||||
echo ""; \
|
||||
echo " GAMMA_ARCH=\"\`file \$${GAMMA_PROG} | awk '{print \$$NF}'\`\""; \
|
||||
echo " JVM_LIB=\"\$${JAVA_HOME}/jre/lib/libjava.$(LIBRARY_SUFFIX)\""; \
|
||||
echo " if [ ! -f \$${JVM_LIB} ]; then"; \
|
||||
echo " JVM_LIB=\"\$${JAVA_HOME}/jre/lib/$${LIBARCH}/libjava.$(LIBRARY_SUFFIX)\""; \
|
||||
echo " fi"; \
|
||||
echo " if [ ! -f \$${JVM_LIB} ] || [ -z \"\`file \$${JVM_LIB} | grep \$${GAMMA_ARCH}\`\" ]; then "; \
|
||||
echo " $(WRONG_DATA_MODE_MSG)"; \
|
||||
echo " exit 0"; \
|
||||
echo " fi"; \
|
||||
echo "fi"; \
|
||||
echo ""; \
|
||||
echo "# Compile Queens program for test"; \
|
||||
echo ""; \
|
||||
echo "rm -f Queens.class"; \
|
||||
echo "\$${JAVA_HOME}/bin/javac -d . $(GAMMADIR)/make/test/Queens.java"; \
|
||||
echo ""; \
|
||||
echo "# Set library path solely for gamma launcher test run"; \
|
||||
echo ""; \
|
||||
echo "LD_LIBRARY_PATH=.:$${LD_LIBRARY_PATH:+$$LD_LIBRARY_PATH:}\$${JAVA_HOME}/jre/lib/${LIBARCH}/native_threads:\$${JAVA_HOME}/jre/lib/${LIBARCH}:${GCC_LIB}"; \
|
||||
echo "export LD_LIBRARY_PATH"; \
|
||||
echo "unset LD_LIBRARY_PATH_32"; \
|
||||
echo "unset LD_LIBRARY_PATH_64"; \
|
||||
echo ""; \
|
||||
echo "if [ \"$(OS_VENDOR)\" = \"Darwin\" ]; then "; \
|
||||
echo " DYLD_LIBRARY_PATH=.:$${DYLD_LIBRARY_PATH:+$$DYLD_LIBRARY_PATH:}\$${JAVA_HOME}/jre/lib/native_threads:\$${JAVA_HOME}/jre/lib:$${DYLD_LIBRARY_PATH:+$$DYLD_LIBRARY_PATH:}\$${JAVA_HOME}/jre/lib/${LIBARCH}/native_threads:\$${JAVA_HOME}/jre/lib/${LIBARCH}:${GCC_LIB}"; \
|
||||
echo " export DYLD_LIBRARY_PATH"; \
|
||||
echo "fi"; \
|
||||
echo ""; \
|
||||
echo "# Use the gamma launcher and JAVA_HOME to run the test"; \
|
||||
echo ""; \
|
||||
echo "./\$${GAMMA_PROG} $(TESTFLAGS) Queens < /dev/null"; \
|
||||
) > $@
|
||||
$(QUIETLY) chmod +x $@
|
||||
|
||||
FORCE:
|
||||
|
||||
.PHONY: all FORCE
|
||||
|
@ -118,8 +118,8 @@ endif
|
||||
# Compiler warnings are treated as errors
|
||||
WARNINGS_ARE_ERRORS = -Werror
|
||||
# Enable these warnings. See 'info gcc' about details on these options
|
||||
ADDITIONAL_WARNINGS = -Wpointer-arith -Wconversion -Wsign-compare
|
||||
CFLAGS_WARN/DEFAULT = $(WARNINGS_ARE_ERRORS) $(ADDITIONAL_WARNINGS)
|
||||
WARNING_FLAGS = -Wpointer-arith -Wconversion -Wsign-compare -Wundef
|
||||
CFLAGS_WARN/DEFAULT = $(WARNINGS_ARE_ERRORS) $(WARNING_FLAGS)
|
||||
# Special cases
|
||||
CFLAGS_WARN/BYFILE = $(CFLAGS_WARN/$@)$(CFLAGS_WARN/DEFAULT$(CFLAGS_WARN/$@))
|
||||
|
||||
|
@ -1,86 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2006, 2008, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*
|
||||
*/
|
||||
|
||||
import java.util.*;
|
||||
|
||||
// Copyright 1996, Animorphic Systems
|
||||
// gri 28 Aug 92 / 15 Jan 93 / 8 Dec 95
|
||||
|
||||
class Queens {
|
||||
|
||||
static void try_i(boolean a[], boolean b[], boolean c[], int x[], int i) {
|
||||
int adj = 7;
|
||||
|
||||
for (int j = 1; j <= 8; j++) {
|
||||
if (b[j] && a[i+j] && c[adj+i-j]) {
|
||||
x[i] = j;
|
||||
b[j] = false;
|
||||
a[i+j] = false;
|
||||
c[adj+i-j] = false;
|
||||
if (i < 8) try_i(a, b, c, x, i+1);
|
||||
else print(x);
|
||||
b[j] = true;
|
||||
a[i+j] = true;
|
||||
c[adj+i-j] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String s[]) {
|
||||
boolean a[] = new boolean[16+1];
|
||||
boolean b[] = new boolean[ 8+1];
|
||||
boolean c[] = new boolean[14+1];
|
||||
int x[] = new int[8+1];
|
||||
int adj = 7;
|
||||
|
||||
for (int i = -7; i <= 16; i++) {
|
||||
if (i >= 1 && i <= 8) b[i] = true;
|
||||
if (i >= 2) a[i] = true;
|
||||
if (i <= 7) c[adj+i] = true;
|
||||
}
|
||||
|
||||
x[0] = 0; // solution counter
|
||||
|
||||
try_i(a, b, c, x, 1);
|
||||
}
|
||||
|
||||
static void print(int x[]) {
|
||||
// first correct solution: A1 B5 C8 D6 E3 F7 G2 H4
|
||||
|
||||
char LF = (char)0xA;
|
||||
char CR = (char)0xD;
|
||||
|
||||
x[0]++;
|
||||
if (x[0] < 10)
|
||||
System.out.print(" ");
|
||||
System.out.print(x[0] + ". ");
|
||||
for (int i = 1; i <= 8; i++) {
|
||||
char p = (char)('A' + i - 1);
|
||||
System.out.print(p);
|
||||
System.out.print (x[i] + " ");
|
||||
}
|
||||
System.out.println();
|
||||
}
|
||||
|
||||
};
|
@ -2194,7 +2194,8 @@ int AbstractInterpreter::layout_activation(Method* method,
|
||||
int callee_locals_size,
|
||||
frame* caller,
|
||||
frame* interpreter_frame,
|
||||
bool is_top_frame) {
|
||||
bool is_top_frame,
|
||||
bool is_bottom_frame) {
|
||||
|
||||
assert(popframe_extra_args == 0, "NEED TO FIX");
|
||||
// NOTE this code must exactly mimic what InterpreterGenerator::generate_compute_interpreter_state()
|
||||
|
@ -1385,13 +1385,13 @@ void MacroAssembler::_verify_oop(Register reg, const char* msg, const char * fil
|
||||
}
|
||||
#endif
|
||||
|
||||
int len = strlen(file) + strlen(msg) + 1 + 4;
|
||||
sprintf(buffer, "%d", line);
|
||||
len += strlen(buffer);
|
||||
sprintf(buffer, " at offset %d ", offset());
|
||||
len += strlen(buffer);
|
||||
char * real_msg = new char[len];
|
||||
sprintf(real_msg, "%s%s(%s:%d)", msg, buffer, file, line);
|
||||
const char* real_msg = NULL;
|
||||
{
|
||||
ResourceMark rm;
|
||||
stringStream ss;
|
||||
ss.print("%s at offset %d (%s:%d)", msg, offset(), file, line);
|
||||
real_msg = code_string(ss.as_string());
|
||||
}
|
||||
|
||||
// Call indirectly to solve generation ordering problem
|
||||
AddressLiteral a(StubRoutines::verify_oop_subroutine_entry_address());
|
||||
@ -1423,13 +1423,13 @@ void MacroAssembler::_verify_oop_addr(Address addr, const char* msg, const char
|
||||
// plausibility check for oops
|
||||
if (!VerifyOops) return;
|
||||
|
||||
char buffer[64];
|
||||
sprintf(buffer, "%d", line);
|
||||
int len = strlen(file) + strlen(msg) + 1 + 4 + strlen(buffer);
|
||||
sprintf(buffer, " at SP+%d ", addr.disp());
|
||||
len += strlen(buffer);
|
||||
char * real_msg = new char[len];
|
||||
sprintf(real_msg, "%s at SP+%d (%s:%d)", msg, addr.disp(), file, line);
|
||||
const char* real_msg = NULL;
|
||||
{
|
||||
ResourceMark rm;
|
||||
stringStream ss;
|
||||
ss.print("%s at SP+%d (%s:%d)", msg, addr.disp(), file, line);
|
||||
real_msg = code_string(ss.as_string());
|
||||
}
|
||||
|
||||
// Call indirectly to solve generation ordering problem
|
||||
AddressLiteral a(StubRoutines::verify_oop_subroutine_entry_address());
|
||||
@ -1622,9 +1622,13 @@ void MacroAssembler::untested(const char* what) {
|
||||
// in order to run automated test scripts on the VM
|
||||
// Use the flag ShowMessageBoxOnError
|
||||
|
||||
char* b = new char[1024];
|
||||
sprintf(b, "untested: %s", what);
|
||||
|
||||
const char* b = NULL;
|
||||
{
|
||||
ResourceMark rm;
|
||||
stringStream ss;
|
||||
ss.print("untested: %s", what);
|
||||
b = code_string(ss.as_string());
|
||||
}
|
||||
if (ShowMessageBoxOnError) { STOP(b); }
|
||||
else { warn(b); }
|
||||
}
|
||||
|
@ -1581,7 +1581,8 @@ int AbstractInterpreter::layout_activation(Method* method,
|
||||
int callee_local_count,
|
||||
frame* caller,
|
||||
frame* interpreter_frame,
|
||||
bool is_top_frame) {
|
||||
bool is_top_frame,
|
||||
bool is_bottom_frame) {
|
||||
// Note: This calculation must exactly parallel the frame setup
|
||||
// in InterpreterGenerator::generate_fixed_frame.
|
||||
// If f!=NULL, set up the following variables:
|
||||
@ -1664,6 +1665,15 @@ int AbstractInterpreter::layout_activation(Method* method,
|
||||
int delta = local_words - parm_words;
|
||||
int computed_sp_adjustment = (delta > 0) ? round_to(delta, WordsPerLong) : 0;
|
||||
*interpreter_frame->register_addr(I5_savedSP) = (intptr_t) (fp + computed_sp_adjustment) - STACK_BIAS;
|
||||
if (!is_bottom_frame) {
|
||||
// Llast_SP is set below for the current frame to SP (with the
|
||||
// extra space for the callee's locals). Here we adjust
|
||||
// Llast_SP for the caller's frame, removing the extra space
|
||||
// for the current method's locals.
|
||||
*caller->register_addr(Llast_SP) = *interpreter_frame->register_addr(I5_savedSP);
|
||||
} else {
|
||||
assert(*caller->register_addr(Llast_SP) >= *interpreter_frame->register_addr(I5_savedSP), "strange Llast_SP");
|
||||
}
|
||||
} else {
|
||||
assert(caller->is_compiled_frame() || caller->is_entry_frame(), "only possible cases");
|
||||
// Don't have Lesp available; lay out locals block in the caller
|
||||
|
@ -2361,7 +2361,8 @@ int AbstractInterpreter::layout_activation(Method* method,
|
||||
int callee_locals,
|
||||
frame* caller,
|
||||
frame* interpreter_frame,
|
||||
bool is_top_frame) {
|
||||
bool is_top_frame,
|
||||
bool is_bottom_frame) {
|
||||
|
||||
assert(popframe_extra_args == 0, "FIX ME");
|
||||
// NOTE this code must exactly mimic what InterpreterGenerator::generate_compute_interpreter_state()
|
||||
|
@ -356,7 +356,7 @@ frame frame::sender_for_entry_frame(RegisterMap* map) const {
|
||||
// Verifies the calculated original PC of a deoptimization PC for the
|
||||
// given unextended SP. The unextended SP might also be the saved SP
|
||||
// for MethodHandle call sites.
|
||||
#if ASSERT
|
||||
#ifdef ASSERT
|
||||
void frame::verify_deopt_original_pc(nmethod* nm, intptr_t* unextended_sp, bool is_method_handle_return) {
|
||||
frame fr;
|
||||
|
||||
|
@ -170,7 +170,7 @@
|
||||
return (intptr_t*) addr_at(offset);
|
||||
}
|
||||
|
||||
#if ASSERT
|
||||
#ifdef ASSERT
|
||||
// Used in frame::sender_for_{interpreter,compiled}_frame
|
||||
static void verify_deopt_original_pc( nmethod* nm, intptr_t* unextended_sp, bool is_method_handle_return = false);
|
||||
static void verify_deopt_mh_original_pc(nmethod* nm, intptr_t* unextended_sp) {
|
||||
|
@ -295,14 +295,18 @@ inline bool frame::volatile_across_calls(Register reg) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
inline oop frame::saved_oop_result(RegisterMap* map) const {
|
||||
return *((oop*) map->location(rax->as_VMReg()));
|
||||
oop* result_adr = (oop *)map->location(rax->as_VMReg());
|
||||
guarantee(result_adr != NULL, "bad register save location");
|
||||
|
||||
return (*result_adr);
|
||||
}
|
||||
|
||||
inline void frame::set_saved_oop_result(RegisterMap* map, oop obj) {
|
||||
*((oop*) map->location(rax->as_VMReg())) = obj;
|
||||
oop* result_adr = (oop *)map->location(rax->as_VMReg());
|
||||
guarantee(result_adr != NULL, "bad register save location");
|
||||
|
||||
*result_adr = obj;
|
||||
}
|
||||
|
||||
#endif // CPU_X86_VM_FRAME_X86_INLINE_HPP
|
||||
|
@ -4262,8 +4262,13 @@ void MacroAssembler::verify_oop(Register reg, const char* s) {
|
||||
if (!VerifyOops) return;
|
||||
|
||||
// Pass register number to verify_oop_subroutine
|
||||
char* b = new char[strlen(s) + 50];
|
||||
sprintf(b, "verify_oop: %s: %s", reg->name(), s);
|
||||
const char* b = NULL;
|
||||
{
|
||||
ResourceMark rm;
|
||||
stringStream ss;
|
||||
ss.print("verify_oop: %s: %s", reg->name(), s);
|
||||
b = code_string(ss.as_string());
|
||||
}
|
||||
BLOCK_COMMENT("verify_oop {");
|
||||
#ifdef _LP64
|
||||
push(rscratch1); // save r10, trashed by movptr()
|
||||
@ -4297,9 +4302,14 @@ RegisterOrConstant MacroAssembler::delayed_value_impl(intptr_t* delayed_value_ad
|
||||
{ Label L;
|
||||
testptr(tmp, tmp);
|
||||
if (WizardMode) {
|
||||
const char* buf = NULL;
|
||||
{
|
||||
ResourceMark rm;
|
||||
stringStream ss;
|
||||
ss.print("DelayedValue="INTPTR_FORMAT, delayed_value_addr[1]);
|
||||
buf = code_string(ss.as_string());
|
||||
}
|
||||
jcc(Assembler::notZero, L);
|
||||
char* buf = new char[40];
|
||||
sprintf(buf, "DelayedValue="INTPTR_FORMAT, delayed_value_addr[1]);
|
||||
STOP(buf);
|
||||
} else {
|
||||
jccb(Assembler::notZero, L);
|
||||
@ -4343,9 +4353,13 @@ void MacroAssembler::verify_oop_addr(Address addr, const char* s) {
|
||||
|
||||
// Address adjust(addr.base(), addr.index(), addr.scale(), addr.disp() + BytesPerWord);
|
||||
// Pass register number to verify_oop_subroutine
|
||||
char* b = new char[strlen(s) + 50];
|
||||
sprintf(b, "verify_oop_addr: %s", s);
|
||||
|
||||
const char* b = NULL;
|
||||
{
|
||||
ResourceMark rm;
|
||||
stringStream ss;
|
||||
ss.print("verify_oop_addr: %s", s);
|
||||
b = code_string(ss.as_string());
|
||||
}
|
||||
#ifdef _LP64
|
||||
push(rscratch1); // save r10, trashed by movptr()
|
||||
#endif
|
||||
|
@ -145,12 +145,9 @@ address* Relocation::pd_address_in_code() {
|
||||
assert(which == Assembler::disp32_operand ||
|
||||
which == Assembler::call32_operand ||
|
||||
which == Assembler::imm_operand, "format unpacks ok");
|
||||
if (which != Assembler::imm_operand) {
|
||||
// The "address" in the code is a displacement can't return it as
|
||||
// and address* since it is really a jint*
|
||||
ShouldNotReachHere();
|
||||
return NULL;
|
||||
}
|
||||
guarantee(which == Assembler::imm_operand, "must be immediate operand");
|
||||
#else
|
||||
assert(which == Assembler::disp32_operand || which == Assembler::imm_operand, "format unpacks ok");
|
||||
#endif // AMD64
|
||||
|
@ -1585,7 +1585,8 @@ int AbstractInterpreter::layout_activation(Method* method,
|
||||
int callee_locals,
|
||||
frame* caller,
|
||||
frame* interpreter_frame,
|
||||
bool is_top_frame) {
|
||||
bool is_top_frame,
|
||||
bool is_bottom_frame) {
|
||||
// Note: This calculation must exactly parallel the frame setup
|
||||
// in AbstractInterpreterGenerator::generate_method_entry.
|
||||
// If interpreter_frame!=NULL, set up the method, locals, and monitors.
|
||||
|
@ -1599,7 +1599,8 @@ int AbstractInterpreter::layout_activation(Method* method,
|
||||
int callee_locals,
|
||||
frame* caller,
|
||||
frame* interpreter_frame,
|
||||
bool is_top_frame) {
|
||||
bool is_top_frame,
|
||||
bool is_bottom_frame) {
|
||||
// Note: This calculation must exactly parallel the frame setup
|
||||
// in AbstractInterpreterGenerator::generate_method_entry.
|
||||
// If interpreter_frame!=NULL, set up the method, locals, and monitors.
|
||||
|
@ -919,7 +919,8 @@ int AbstractInterpreter::layout_activation(Method* method,
|
||||
int callee_locals,
|
||||
frame* caller,
|
||||
frame* interpreter_frame,
|
||||
bool is_top_frame) {
|
||||
bool is_top_frame,
|
||||
bool is_bottom_frame) {
|
||||
assert(popframe_extra_args == 0, "what to do?");
|
||||
assert(!is_top_frame || (!callee_locals && !callee_param_count),
|
||||
"top frame should have no caller");
|
||||
|
@ -57,6 +57,7 @@
|
||||
#include "runtime/threadCritical.hpp"
|
||||
#include "runtime/timer.hpp"
|
||||
#include "services/attachListener.hpp"
|
||||
#include "services/memTracker.hpp"
|
||||
#include "services/runtimeService.hpp"
|
||||
#include "utilities/decoder.hpp"
|
||||
#include "utilities/defaultStream.hpp"
|
||||
@ -2275,13 +2276,25 @@ char* os::reserve_memory_special(size_t bytes, char* req_addr, bool exec) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// The memory is committed
|
||||
address pc = CALLER_PC;
|
||||
MemTracker::record_virtual_memory_reserve((address)addr, bytes, pc);
|
||||
MemTracker::record_virtual_memory_commit((address)addr, bytes, pc);
|
||||
|
||||
return addr;
|
||||
}
|
||||
|
||||
bool os::release_memory_special(char* base, size_t bytes) {
|
||||
// detaching the SHM segment will also delete it, see reserve_memory_special()
|
||||
int rslt = shmdt(base);
|
||||
return rslt == 0;
|
||||
if (rslt == 0) {
|
||||
MemTracker::record_virtual_memory_uncommit((address)base, bytes);
|
||||
MemTracker::record_virtual_memory_release((address)base, bytes);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
size_t os::large_page_size() {
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -40,6 +40,9 @@
|
||||
product(bool, UseHugeTLBFS, false, \
|
||||
"Use MAP_HUGETLB for large pages") \
|
||||
\
|
||||
product(bool, LoadExecStackDllInVMThread, true, \
|
||||
"Load DLLs with executable-stack attribute in the VM Thread") \
|
||||
\
|
||||
product(bool, UseSHM, false, \
|
||||
"Use SYSV shared memory for large pages")
|
||||
|
||||
|
@ -44,6 +44,7 @@
|
||||
#include "runtime/extendedPC.hpp"
|
||||
#include "runtime/globals.hpp"
|
||||
#include "runtime/interfaceSupport.hpp"
|
||||
#include "runtime/init.hpp"
|
||||
#include "runtime/java.hpp"
|
||||
#include "runtime/javaCalls.hpp"
|
||||
#include "runtime/mutexLocker.hpp"
|
||||
@ -57,10 +58,12 @@
|
||||
#include "runtime/threadCritical.hpp"
|
||||
#include "runtime/timer.hpp"
|
||||
#include "services/attachListener.hpp"
|
||||
#include "services/memTracker.hpp"
|
||||
#include "services/runtimeService.hpp"
|
||||
#include "utilities/decoder.hpp"
|
||||
#include "utilities/defaultStream.hpp"
|
||||
#include "utilities/events.hpp"
|
||||
#include "utilities/elfFile.hpp"
|
||||
#include "utilities/growableArray.hpp"
|
||||
#include "utilities/vmError.hpp"
|
||||
|
||||
@ -1796,9 +1799,93 @@ bool os::dll_address_to_library_name(address addr, char* buf,
|
||||
// in case of error it checks if .dll/.so was built for the
|
||||
// same architecture as Hotspot is running on
|
||||
|
||||
|
||||
// Remember the stack's state. The Linux dynamic linker will change
|
||||
// the stack to 'executable' at most once, so we must safepoint only once.
|
||||
bool os::Linux::_stack_is_executable = false;
|
||||
|
||||
// VM operation that loads a library. This is necessary if stack protection
|
||||
// of the Java stacks can be lost during loading the library. If we
|
||||
// do not stop the Java threads, they can stack overflow before the stacks
|
||||
// are protected again.
|
||||
class VM_LinuxDllLoad: public VM_Operation {
|
||||
private:
|
||||
const char *_filename;
|
||||
void *_lib;
|
||||
public:
|
||||
VM_LinuxDllLoad(const char *fn) :
|
||||
_filename(fn), _lib(NULL) {}
|
||||
VMOp_Type type() const { return VMOp_LinuxDllLoad; }
|
||||
void doit() {
|
||||
_lib = os::Linux::dll_load_inner(_filename);
|
||||
os::Linux::_stack_is_executable = true;
|
||||
}
|
||||
void* loaded_library() { return _lib; }
|
||||
};
|
||||
|
||||
void * os::dll_load(const char *filename, char *ebuf, int ebuflen)
|
||||
{
|
||||
void * result= ::dlopen(filename, RTLD_LAZY);
|
||||
void * result = NULL;
|
||||
bool load_attempted = false;
|
||||
|
||||
// Check whether the library to load might change execution rights
|
||||
// of the stack. If they are changed, the protection of the stack
|
||||
// guard pages will be lost. We need a safepoint to fix this.
|
||||
//
|
||||
// See Linux man page execstack(8) for more info.
|
||||
if (os::uses_stack_guard_pages() && !os::Linux::_stack_is_executable) {
|
||||
ElfFile ef(filename);
|
||||
if (!ef.specifies_noexecstack()) {
|
||||
if (!is_init_completed()) {
|
||||
os::Linux::_stack_is_executable = true;
|
||||
// This is OK - No Java threads have been created yet, and hence no
|
||||
// stack guard pages to fix.
|
||||
//
|
||||
// This should happen only when you are building JDK7 using a very
|
||||
// old version of JDK6 (e.g., with JPRT) and running test_gamma.
|
||||
//
|
||||
// Dynamic loader will make all stacks executable after
|
||||
// this function returns, and will not do that again.
|
||||
assert(Threads::first() == NULL, "no Java threads should exist yet.");
|
||||
} else {
|
||||
warning("You have loaded library %s which might have disabled stack guard. "
|
||||
"The VM will try to fix the stack guard now.\n"
|
||||
"It's highly recommended that you fix the library with "
|
||||
"'execstack -c <libfile>', or link it with '-z noexecstack'.",
|
||||
filename);
|
||||
|
||||
assert(Thread::current()->is_Java_thread(), "must be Java thread");
|
||||
JavaThread *jt = JavaThread::current();
|
||||
if (jt->thread_state() != _thread_in_native) {
|
||||
// This happens when a compiler thread tries to load a hsdis-<arch>.so file
|
||||
// that requires ExecStack. Cannot enter safe point. Let's give up.
|
||||
warning("Unable to fix stack guard. Giving up.");
|
||||
} else {
|
||||
if (!LoadExecStackDllInVMThread) {
|
||||
// This is for the case where the DLL has an static
|
||||
// constructor function that executes JNI code. We cannot
|
||||
// load such DLLs in the VMThread.
|
||||
result = ::dlopen(filename, RTLD_LAZY);
|
||||
}
|
||||
|
||||
ThreadInVMfromNative tiv(jt);
|
||||
debug_only(VMNativeEntryWrapper vew;)
|
||||
|
||||
VM_LinuxDllLoad op(filename);
|
||||
VMThread::execute(&op);
|
||||
if (LoadExecStackDllInVMThread) {
|
||||
result = op.loaded_library();
|
||||
}
|
||||
load_attempted = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!load_attempted) {
|
||||
result = ::dlopen(filename, RTLD_LAZY);
|
||||
}
|
||||
|
||||
if (result != NULL) {
|
||||
// Successful loading
|
||||
return result;
|
||||
@ -1952,6 +2039,38 @@ void * os::dll_load(const char *filename, char *ebuf, int ebuflen)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void * os::Linux::dll_load_inner(const char *filename) {
|
||||
void * result = NULL;
|
||||
if (LoadExecStackDllInVMThread) {
|
||||
result = ::dlopen(filename, RTLD_LAZY);
|
||||
}
|
||||
|
||||
// Since 7019808, libjvm.so is linked with -noexecstack. If the VM loads a
|
||||
// library that requires an executable stack, or which does not have this
|
||||
// stack attribute set, dlopen changes the stack attribute to executable. The
|
||||
// read protection of the guard pages gets lost.
|
||||
//
|
||||
// Need to check _stack_is_executable again as multiple VM_LinuxDllLoad
|
||||
// may have been queued at the same time.
|
||||
|
||||
if (!_stack_is_executable) {
|
||||
JavaThread *jt = Threads::first();
|
||||
|
||||
while (jt) {
|
||||
if (!jt->stack_guard_zone_unused() && // Stack not yet fully initialized
|
||||
jt->stack_yellow_zone_enabled()) { // No pending stack overflow exceptions
|
||||
if (!os::guard_memory((char *) jt->stack_red_zone_base() - jt->stack_red_zone_size(),
|
||||
jt->stack_yellow_zone_size() + jt->stack_red_zone_size())) {
|
||||
warning("Attempt to reguard stack yellow zone failed.");
|
||||
}
|
||||
}
|
||||
jt = jt->next();
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
* glibc-2.0 libdl is not MT safe. If you are building with any glibc,
|
||||
* chances are you might want to run the generated bits against glibc-2.0
|
||||
@ -3094,13 +3213,24 @@ char* os::reserve_memory_special(size_t bytes, char* req_addr, bool exec) {
|
||||
numa_make_global(addr, bytes);
|
||||
}
|
||||
|
||||
// The memory is committed
|
||||
address pc = CALLER_PC;
|
||||
MemTracker::record_virtual_memory_reserve((address)addr, bytes, pc);
|
||||
MemTracker::record_virtual_memory_commit((address)addr, bytes, pc);
|
||||
|
||||
return addr;
|
||||
}
|
||||
|
||||
bool os::release_memory_special(char* base, size_t bytes) {
|
||||
// detaching the SHM segment will also delete it, see reserve_memory_special()
|
||||
int rslt = shmdt(base);
|
||||
return rslt == 0;
|
||||
if (rslt == 0) {
|
||||
MemTracker::record_virtual_memory_uncommit((address)base, bytes);
|
||||
MemTracker::record_virtual_memory_release((address)base, bytes);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
size_t os::large_page_size() {
|
||||
|
@ -94,6 +94,9 @@ class Linux {
|
||||
static void print_libversion_info(outputStream* st);
|
||||
|
||||
public:
|
||||
static bool _stack_is_executable;
|
||||
static void *dll_load_inner(const char *name);
|
||||
|
||||
static void init_thread_fpu_state();
|
||||
static int get_fpu_control_word();
|
||||
static void set_fpu_control_word(int fpu_control);
|
||||
|
@ -2945,7 +2945,7 @@ char *os::scan_pages(char *start, char* end, page_info* page_expected, page_info
|
||||
while (p < (uint64_t)end) {
|
||||
addrs[0] = p;
|
||||
size_t addrs_count = 1;
|
||||
while (addrs_count < MAX_MEMINFO_CNT && addrs[addrs_count - 1] < (uint64_t)end) {
|
||||
while (addrs_count < MAX_MEMINFO_CNT && addrs[addrs_count - 1] + page_size < (uint64_t)end) {
|
||||
addrs[addrs_count] = addrs[addrs_count - 1] + page_size;
|
||||
addrs_count++;
|
||||
}
|
||||
@ -3420,13 +3420,25 @@ char* os::reserve_memory_special(size_t size, char* addr, bool exec) {
|
||||
if ((retAddr != NULL) && UseNUMAInterleaving) {
|
||||
numa_make_global(retAddr, size);
|
||||
}
|
||||
|
||||
// The memory is committed
|
||||
address pc = CALLER_PC;
|
||||
MemTracker::record_virtual_memory_reserve((address)retAddr, size, pc);
|
||||
MemTracker::record_virtual_memory_commit((address)retAddr, size, pc);
|
||||
|
||||
return retAddr;
|
||||
}
|
||||
|
||||
bool os::release_memory_special(char* base, size_t bytes) {
|
||||
// detaching the SHM segment will also delete it, see reserve_memory_special()
|
||||
int rslt = shmdt(base);
|
||||
return rslt == 0;
|
||||
if (rslt == 0) {
|
||||
MemTracker::record_virtual_memory_uncommit((address)base, bytes);
|
||||
MemTracker::record_virtual_memory_release((address)base, bytes);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
size_t os::large_page_size() {
|
||||
|
@ -60,6 +60,7 @@
|
||||
#include "runtime/threadCritical.hpp"
|
||||
#include "runtime/timer.hpp"
|
||||
#include "services/attachListener.hpp"
|
||||
#include "services/memTracker.hpp"
|
||||
#include "services/runtimeService.hpp"
|
||||
#include "utilities/decoder.hpp"
|
||||
#include "utilities/defaultStream.hpp"
|
||||
@ -2836,7 +2837,7 @@ static char* allocate_pages_individually(size_t bytes, char* addr, DWORD flags,
|
||||
PAGE_READWRITE);
|
||||
// If reservation failed, return NULL
|
||||
if (p_buf == NULL) return NULL;
|
||||
|
||||
MemTracker::record_virtual_memory_reserve((address)p_buf, size_of_reserve, CALLER_PC);
|
||||
os::release_memory(p_buf, bytes + chunk_size);
|
||||
|
||||
// we still need to round up to a page boundary (in case we are using large pages)
|
||||
@ -2898,6 +2899,11 @@ static char* allocate_pages_individually(size_t bytes, char* addr, DWORD flags,
|
||||
if (next_alloc_addr > p_buf) {
|
||||
// Some memory was committed so release it.
|
||||
size_t bytes_to_release = bytes - bytes_remaining;
|
||||
// NMT has yet to record any individual blocks, so it
|
||||
// need to create a dummy 'reserve' record to match
|
||||
// the release.
|
||||
MemTracker::record_virtual_memory_reserve((address)p_buf,
|
||||
bytes_to_release, CALLER_PC);
|
||||
os::release_memory(p_buf, bytes_to_release);
|
||||
}
|
||||
#ifdef ASSERT
|
||||
@ -2909,10 +2915,19 @@ static char* allocate_pages_individually(size_t bytes, char* addr, DWORD flags,
|
||||
#endif
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bytes_remaining -= bytes_to_rq;
|
||||
next_alloc_addr += bytes_to_rq;
|
||||
count++;
|
||||
}
|
||||
// Although the memory is allocated individually, it is returned as one.
|
||||
// NMT records it as one block.
|
||||
address pc = CALLER_PC;
|
||||
MemTracker::record_virtual_memory_reserve((address)p_buf, bytes, pc);
|
||||
if ((flags & MEM_COMMIT) != 0) {
|
||||
MemTracker::record_virtual_memory_commit((address)p_buf, bytes, pc);
|
||||
}
|
||||
|
||||
// made it this far, success
|
||||
return p_buf;
|
||||
}
|
||||
@ -3099,11 +3114,20 @@ char* os::reserve_memory_special(size_t bytes, char* addr, bool exec) {
|
||||
// normal policy just allocate it all at once
|
||||
DWORD flag = MEM_RESERVE | MEM_COMMIT | MEM_LARGE_PAGES;
|
||||
char * res = (char *)VirtualAlloc(NULL, bytes, flag, prot);
|
||||
if (res != NULL) {
|
||||
address pc = CALLER_PC;
|
||||
MemTracker::record_virtual_memory_reserve((address)res, bytes, pc);
|
||||
MemTracker::record_virtual_memory_commit((address)res, bytes, pc);
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
bool os::release_memory_special(char* base, size_t bytes) {
|
||||
assert(base != NULL, "Sanity check");
|
||||
// Memory allocated via reserve_memory_special() is committed
|
||||
MemTracker::record_virtual_memory_uncommit((address)base, bytes);
|
||||
return release_memory(base, bytes);
|
||||
}
|
||||
|
||||
|
@ -516,7 +516,7 @@ JVM_handle_bsd_signal(int sig,
|
||||
// here if the underlying file has been truncated.
|
||||
// Do not crash the VM in such a case.
|
||||
CodeBlob* cb = CodeCache::find_blob_unsafe(pc);
|
||||
nmethod* nm = cb->is_nmethod() ? (nmethod*)cb : NULL;
|
||||
nmethod* nm = (cb != NULL && cb->is_nmethod()) ? (nmethod*)cb : NULL;
|
||||
if (nm != NULL && nm->has_unsafe_access()) {
|
||||
stub = StubRoutines::handler_for_unsafe_access();
|
||||
}
|
||||
|
@ -410,6 +410,11 @@ inline static bool checkOverflow(sigcontext* uc,
|
||||
// to handle_unexpected_exception way down below.
|
||||
thread->disable_stack_red_zone();
|
||||
tty->print_raw_cr("An irrecoverable stack overflow has occurred.");
|
||||
|
||||
// This is a likely cause, but hard to verify. Let's just print
|
||||
// it as a hint.
|
||||
tty->print_raw_cr("Please check if any of your loaded .so files has "
|
||||
"enabled executable stack (see man page execstack(8))");
|
||||
} else {
|
||||
// Accessing stack address below sp may cause SEGV if current
|
||||
// thread has MAP_GROWSDOWN stack. This should only happen when
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user