# HG changeset patch # User kvn # Date 1337909984 25200 # Node ID 7089278210e2f766147b09086d4b287076cc5d7a # Parent cee14a6fc5ac283388f880b155afe0f36ce012c0# Parent e2961d14584bef6989d30641f73f93bfc950a1f6 Merge diff -r e2961d14584b -r 7089278210e2 .hgtags --- a/.hgtags Mon May 21 09:46:02 2012 +0200 +++ b/.hgtags Thu May 24 18:39:44 2012 -0700 @@ -246,3 +246,5 @@ 7d5ec8bf38d1b12e0e09ec381f10976b8beede3b hs24-b09 637c3f5f068f88fb9ec9c5867341cf59fd5ebedc jdk8-b38 73147e6c48813b5fee904aa33f79a77103250ff4 hs24-b10 +96a403721094ecdaf6a1f4f52ebd0a82e07df199 jdk8-b39 +14b0e07ab9a6fa1662414496b7e07ac8450cf517 hs24-b11 diff -r e2961d14584b -r 7089278210e2 agent/src/share/classes/sun/jvm/hotspot/HotSpotAgent.java --- a/agent/src/share/classes/sun/jvm/hotspot/HotSpotAgent.java Mon May 21 09:46:02 2012 +0200 +++ b/agent/src/share/classes/sun/jvm/hotspot/HotSpotAgent.java Thu May 24 18:39:44 2012 -0700 @@ -572,10 +572,10 @@ if (cpu.equals("x86")) { machDesc = new MachineDescriptionIntelX86(); - } else if (cpu.equals("amd64")) { + } else if (cpu.equals("amd64") || cpu.equals("x86_64")) { machDesc = new MachineDescriptionAMD64(); } else { - throw new DebuggerException("BSD only supported on x86/amd64"); + throw new DebuggerException("BSD only supported on x86/x86_64. Current arch: " + cpu); } BsdDebuggerLocal dbg = new BsdDebuggerLocal(machDesc, !isServer); diff -r e2961d14584b -r 7089278210e2 agent/src/share/classes/sun/jvm/hotspot/bugspot/BugSpotAgent.java --- a/agent/src/share/classes/sun/jvm/hotspot/bugspot/BugSpotAgent.java Mon May 21 09:46:02 2012 +0200 +++ b/agent/src/share/classes/sun/jvm/hotspot/bugspot/BugSpotAgent.java Thu May 24 18:39:44 2012 -0700 @@ -762,10 +762,10 @@ if (cpu.equals("x86")) { machDesc = new MachineDescriptionIntelX86(); - } else if (cpu.equals("amd64")) { + } else if (cpu.equals("amd64") || (cpu.equals("x86_64"))) { machDesc = new MachineDescriptionAMD64(); } else { - throw new DebuggerException("Bsd only supported on x86/amd64"); + throw new DebuggerException("Bsd only supported on x86/x86_64. Current arch: " + cpu); } // Note we do not use a cache for the local debugger in server diff -r e2961d14584b -r 7089278210e2 agent/src/share/classes/sun/jvm/hotspot/debugger/bsd/BsdCDebugger.java --- a/agent/src/share/classes/sun/jvm/hotspot/debugger/bsd/BsdCDebugger.java Mon May 21 09:46:02 2012 +0200 +++ b/agent/src/share/classes/sun/jvm/hotspot/debugger/bsd/BsdCDebugger.java Thu May 24 18:39:44 2012 -0700 @@ -90,7 +90,7 @@ Address pc = context.getRegisterAsAddress(X86ThreadContext.EIP); if (pc == null) return null; return new BsdX86CFrame(dbg, ebp, pc); - } else if (cpu.equals("amd64")) { + } else if (cpu.equals("amd64") || cpu.equals("x86_64")) { AMD64ThreadContext context = (AMD64ThreadContext) thread.getContext(); Address rbp = context.getRegisterAsAddress(AMD64ThreadContext.RBP); if (rbp == null) return null; diff -r e2961d14584b -r 7089278210e2 agent/src/share/classes/sun/jvm/hotspot/debugger/bsd/BsdThreadContextFactory.java --- a/agent/src/share/classes/sun/jvm/hotspot/debugger/bsd/BsdThreadContextFactory.java Mon May 21 09:46:02 2012 +0200 +++ b/agent/src/share/classes/sun/jvm/hotspot/debugger/bsd/BsdThreadContextFactory.java Thu May 24 18:39:44 2012 -0700 @@ -33,7 +33,7 @@ String cpu = dbg.getCPU(); if (cpu.equals("x86")) { return new BsdX86ThreadContext(dbg); - } else if (cpu.equals("amd64")) { + } else if (cpu.equals("amd64") || cpu.equals("x86_64")) { return new BsdAMD64ThreadContext(dbg); } else { throw new RuntimeException("cpu " + cpu + " is not yet supported"); diff -r e2961d14584b -r 7089278210e2 agent/src/share/classes/sun/jvm/hotspot/debugger/proc/ProcDebuggerLocal.java --- a/agent/src/share/classes/sun/jvm/hotspot/debugger/proc/ProcDebuggerLocal.java Mon May 21 09:46:02 2012 +0200 +++ b/agent/src/share/classes/sun/jvm/hotspot/debugger/proc/ProcDebuggerLocal.java Thu May 24 18:39:44 2012 -0700 @@ -81,7 +81,7 @@ pcRegIndex = X86ThreadContext.EIP; fpRegIndex = X86ThreadContext.EBP; unalignedAccessesOkay = true; - } else if (cpu.equals("amd64")) { + } else if (cpu.equals("amd64") || cpu.equals("x86_64")) { threadFactory = new ProcAMD64ThreadFactory(this); pcRegIndex = AMD64ThreadContext.RIP; fpRegIndex = AMD64ThreadContext.RBP; diff -r e2961d14584b -r 7089278210e2 agent/src/share/classes/sun/jvm/hotspot/debugger/remote/RemoteDebuggerClient.java --- a/agent/src/share/classes/sun/jvm/hotspot/debugger/remote/RemoteDebuggerClient.java Mon May 21 09:46:02 2012 +0200 +++ b/agent/src/share/classes/sun/jvm/hotspot/debugger/remote/RemoteDebuggerClient.java Thu May 24 18:39:44 2012 -0700 @@ -64,7 +64,7 @@ cachePageSize = 4096; cacheNumPages = parseCacheNumPagesProperty(cacheSize / cachePageSize); unalignedAccessesOkay = true; - } else if (cpu.equals("amd64")) { + } else if (cpu.equals("amd64") || cpu.equals("x86_64")) { threadFactory = new RemoteAMD64ThreadFactory(this); cachePageSize = 4096; cacheNumPages = parseCacheNumPagesProperty(cacheSize / cachePageSize); diff -r e2961d14584b -r 7089278210e2 agent/src/share/classes/sun/jvm/hotspot/runtime/Threads.java --- a/agent/src/share/classes/sun/jvm/hotspot/runtime/Threads.java Mon May 21 09:46:02 2012 +0200 +++ b/agent/src/share/classes/sun/jvm/hotspot/runtime/Threads.java Thu May 24 18:39:44 2012 -0700 @@ -95,7 +95,7 @@ } else if (os.equals("bsd")) { if (cpu.equals("x86")) { access = new BsdX86JavaThreadPDAccess(); - } else if (cpu.equals("amd64")) { + } else if (cpu.equals("amd64") || cpu.equals("x86_64")) { access = new BsdAMD64JavaThreadPDAccess(); } } diff -r e2961d14584b -r 7089278210e2 agent/src/share/classes/sun/jvm/hotspot/ui/classbrowser/HTMLGenerator.java --- a/agent/src/share/classes/sun/jvm/hotspot/ui/classbrowser/HTMLGenerator.java Mon May 21 09:46:02 2012 +0200 +++ b/agent/src/share/classes/sun/jvm/hotspot/ui/classbrowser/HTMLGenerator.java Thu May 24 18:39:44 2012 -0700 @@ -199,7 +199,7 @@ cpuHelper = new SPARCHelper(); } else if (cpu.equals("x86")) { cpuHelper = new X86Helper(); - } else if (cpu.equals("amd64")) { + } else if (cpu.equals("amd64") || cpu.equals("x86_64")) { cpuHelper = new AMD64Helper(); } else if (cpu.equals("ia64")) { cpuHelper = new IA64Helper(); diff -r e2961d14584b -r 7089278210e2 agent/src/share/classes/sun/jvm/hotspot/utilities/soql/JSJavaFrame.java --- a/agent/src/share/classes/sun/jvm/hotspot/utilities/soql/JSJavaFrame.java Mon May 21 09:46:02 2012 +0200 +++ b/agent/src/share/classes/sun/jvm/hotspot/utilities/soql/JSJavaFrame.java Thu May 24 18:39:44 2012 -0700 @@ -153,7 +153,8 @@ List visibleVars = new ArrayList(0); for (int i = 0; i < localVars.length; i++) { LocalVariableTableElement cur = localVars[i]; - if (cur.getStartBCI() >= bci && cur.getLength() > 0) { + int startBCI = cur.getStartBCI(); + if (startBCI <= bci && bci < startBCI + cur.getLength()) { visibleVars.add(cur); } } diff -r e2961d14584b -r 7089278210e2 make/hotspot_version --- a/make/hotspot_version Mon May 21 09:46:02 2012 +0200 +++ b/make/hotspot_version Thu May 24 18:39:44 2012 -0700 @@ -35,7 +35,7 @@ HS_MAJOR_VER=24 HS_MINOR_VER=0 -HS_BUILD_NUMBER=11 +HS_BUILD_NUMBER=12 JDK_MAJOR_VER=1 JDK_MINOR_VER=8 diff -r e2961d14584b -r 7089278210e2 make/linux/makefiles/vm.make --- a/make/linux/makefiles/vm.make Mon May 21 09:46:02 2012 +0200 +++ b/make/linux/makefiles/vm.make Thu May 24 18:39:44 2012 -0700 @@ -102,9 +102,11 @@ # a time and date. vm_version.o: CXXFLAGS += ${JRE_VERSION} -ifndef JAVASE_EMBEDDED +ifndef JAVASE_EMBEDDED +ifneq (${ARCH},arm) CFLAGS += -DINCLUDE_TRACE endif +endif # CFLAGS_WARN holds compiler options to suppress/enable warnings. CFLAGS += $(CFLAGS_WARN/BYFILE) @@ -153,11 +155,13 @@ SOURCE_PATHS+=$(HS_COMMON_SRC)/cpu/$(Platform_arch)/vm SOURCE_PATHS+=$(HS_COMMON_SRC)/os_cpu/$(Platform_os_arch)/vm -ifndef JAVASE_EMBEDDED +ifndef JAVASE_EMBEDDED +ifneq (${ARCH},arm) SOURCE_PATHS+=$(shell if [ -d $(HS_ALT_SRC)/share/vm/jfr ]; then \ find $(HS_ALT_SRC)/share/vm/jfr -type d; \ fi) endif +endif CORE_PATHS=$(foreach path,$(SOURCE_PATHS),$(call altsrc,$(path)) $(path)) CORE_PATHS+=$(GENERATED)/jvmtifiles diff -r e2961d14584b -r 7089278210e2 make/solaris/makefiles/add_gnu_debuglink.make --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/make/solaris/makefiles/add_gnu_debuglink.make Thu May 24 18:39:44 2012 -0700 @@ -0,0 +1,51 @@ +# +# 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. +# +# 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. +# +# + +# Rules to build add_gnu_debuglink, used by vm.make on Solaris + +GENERATED = ../generated +ADD_GNU_DEBUGLINK = $(GENERATED)/add_gnu_debuglink + +ADD_GNU_DEBUGLINK_DIR = $(GAMMADIR)/src/os/solaris/add_gnu_debuglink +ADD_GNU_DEBUGLINK_SRC = $(ADD_GNU_DEBUGLINK_DIR)/add_gnu_debuglink.c +ADD_GNU_DEBUGLINK_FLAGS = +LIBS_ADD_GNU_DEBUGLINK += -lelf + +ifeq ("${Platform_compiler}", "sparcWorks") +# Enable the following ADD_GNU_DEBUGLINK_FLAGS addition if you need to +# compare the built ELF objects. +# +# The -g option makes static data global and the "-W0,-noglobal" +# option tells the compiler to not globalize static data using a unique +# globalization prefix. Instead force the use of a static globalization +# prefix based on the source filepath so the objects from two identical +# compilations are the same. +# +# Note: The blog says to use "-W0,-xglobalstatic", but that doesn't +# seem to work. I got "-W0,-noglobal" from Kelly and that works. +#ADD_GNU_DEBUGLINK_FLAGS += -W0,-noglobal +endif # Platform_compiler == sparcWorks + +$(ADD_GNU_DEBUGLINK): $(ADD_GNU_DEBUGLINK_SRC) + $(CC) -g -o $@ $< $(ADD_GNU_DEBUGLINK_FLAGS) $(LIBS_ADD_GNU_DEBUGLINK) diff -r e2961d14584b -r 7089278210e2 make/solaris/makefiles/defs.make --- a/make/solaris/makefiles/defs.make Mon May 21 09:46:02 2012 +0200 +++ b/make/solaris/makefiles/defs.make Thu May 24 18:39:44 2012 -0700 @@ -109,18 +109,12 @@ # overridden in some situations, e.g., a BUILD_FLAVOR != product # build. - # Disable FULL_DEBUG_SYMBOLS by default because dtrace tests are - # failing in nightly when the debug info files are ZIP'ed. On - # Solaris debug info files need to be ZIP'ed to reduce the impact - # on disk space footprint. - FULL_DEBUG_SYMBOLS ?= 0 ifeq ($(BUILD_FLAVOR), product) - # FULL_DEBUG_SYMBOLS ?= 1 + FULL_DEBUG_SYMBOLS ?= 1 ENABLE_FULL_DEBUG_SYMBOLS = $(FULL_DEBUG_SYMBOLS) else # debug variants always get Full Debug Symbols (if available) - # ENABLE_FULL_DEBUG_SYMBOLS = 1 - ENABLE_FULL_DEBUG_SYMBOLS = $(FULL_DEBUG_SYMBOLS) + ENABLE_FULL_DEBUG_SYMBOLS = 1 endif _JUNK_ := $(shell \ echo >&2 "INFO: ENABLE_FULL_DEBUG_SYMBOLS=$(ENABLE_FULL_DEBUG_SYMBOLS)") @@ -178,9 +172,7 @@ _JUNK_ := $(shell \ echo >&2 "INFO: STRIP_POLICY=$(STRIP_POLICY)") - # Disable ZIP_DEBUGINFO_FILES by default because dtrace tests are - # failing in nightly when the debug info files are ZIP'ed. - ZIP_DEBUGINFO_FILES ?= 0 + ZIP_DEBUGINFO_FILES ?= 1 _JUNK_ := $(shell \ echo >&2 "INFO: ZIP_DEBUGINFO_FILES=$(ZIP_DEBUGINFO_FILES)") diff -r e2961d14584b -r 7089278210e2 make/solaris/makefiles/vm.make --- a/make/solaris/makefiles/vm.make Mon May 21 09:46:02 2012 +0200 +++ b/make/solaris/makefiles/vm.make Thu May 24 18:39:44 2012 -0700 @@ -145,6 +145,10 @@ include $(MAKEFILES_DIR)/dtrace.make #---------------------------------------------------------------------- +# add_gnu_debuglink tool +include $(MAKEFILES_DIR)/add_gnu_debuglink.make + +#---------------------------------------------------------------------- # JVM JVM = jvm @@ -276,7 +280,7 @@ LINK_VM = $(LINK_LIB.CXX) endif # making the library: -$(LIBJVM): $(LIBJVM.o) $(LIBJVM_MAPFILE) +$(LIBJVM): $(ADD_GNU_DEBUGLINK) $(LIBJVM.o) $(LIBJVM_MAPFILE) ifeq ($(filter -sbfast -xsbfast, $(CFLAGS_BROWSE)),) @echo Linking vm... $(QUIETLY) $(LINK_LIB.CXX/PRE_HOOK) @@ -287,7 +291,11 @@ $(QUIETLY) [ -f $(LIBJVM_G).1 ] || ln -s $@.1 $(LIBJVM_G).1 ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1) $(QUIETLY) $(OBJCOPY) --only-keep-debug $@ $(LIBJVM_DEBUGINFO) - $(QUIETLY) $(OBJCOPY) --add-gnu-debuglink=$(LIBJVM_DEBUGINFO) $@ +# $(OBJCOPY) --add-gnu-debuglink=... corrupts the SUNW_dof section +# in libjvm.so. Use $(ADD_GNU_DEBUGLINK) until a fixed $(OBJCOPY) +# is available. +# $(QUIETLY) $(OBJCOPY) --add-gnu-debuglink=$(LIBJVM_DEBUGINFO) $@ + $(QUIETLY) $(ADD_GNU_DEBUGLINK) $(LIBJVM_DEBUGINFO) $@ ifeq ($(STRIP_POLICY),all_strip) $(QUIETLY) $(STRIP) $@ else diff -r e2961d14584b -r 7089278210e2 make/windows/makefiles/defs.make --- a/make/windows/makefiles/defs.make Mon May 21 09:46:02 2012 +0200 +++ b/make/windows/makefiles/defs.make Thu May 24 18:39:44 2012 -0700 @@ -145,7 +145,12 @@ ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1) # Disable ZIP_DEBUGINFO_FILES by default because various tests are # failing in nightly when the debug info files are ZIP'ed. - ZIP_DEBUGINFO_FILES ?= 0 + #ZIP_DEBUGINFO_FILES ?= 0 + # The above conditional setting logic is unreliable on Windows for + # unknown reasons. We force ZIP_DEBUGINFO_FILES to be disabled on + # Windows until we figure out why the various tests are failing + # AND why the conditional setting logic is unreliable. + ZIP_DEBUGINFO_FILES=0 else ZIP_DEBUGINFO_FILES=0 endif diff -r e2961d14584b -r 7089278210e2 src/cpu/zero/vm/cppInterpreter_zero.cpp --- a/src/cpu/zero/vm/cppInterpreter_zero.cpp Mon May 21 09:46:02 2012 +0200 +++ b/src/cpu/zero/vm/cppInterpreter_zero.cpp Thu May 24 18:39:44 2012 -0700 @@ -1026,6 +1026,16 @@ java_lang_invoke_AdapterMethodHandle::vmargslot(method_handle); oop arg = VMSLOTS_OBJECT(arg_slot); jvalue arg_value; + if (arg == NULL) { + // queue a nullpointer exception for the caller + stack->set_sp(calculate_unwind_sp(stack, method_handle)); + CALL_VM_NOCHECK_NOFIX( + throw_exception( + thread, vmSymbols::java_lang_NullPointerException())); + // NB all oops trashed! + assert(HAS_PENDING_EXCEPTION, "should do"); + return; + } BasicType arg_type = java_lang_boxing_object::get_value(arg, &arg_value); if (arg_type == T_LONG || arg_type == T_DOUBLE) { intptr_t *unwind_sp = calculate_unwind_sp(stack, method_handle); @@ -1112,6 +1122,15 @@ case T_SHORT: return; } + // INT results sometimes need narrowing + case T_BOOLEAN: + case T_CHAR: + case T_BYTE: + case T_SHORT: + switch (src_rtype) { + case T_INT: + return; + } } tty->print_cr("unhandled conversion:"); diff -r e2961d14584b -r 7089278210e2 src/os/bsd/vm/os_bsd.cpp --- a/src/os/bsd/vm/os_bsd.cpp Mon May 21 09:46:02 2012 +0200 +++ b/src/os/bsd/vm/os_bsd.cpp Thu May 24 18:39:44 2012 -0700 @@ -2340,93 +2340,21 @@ #endif } +void os::print_os_info_brief(outputStream* st) { + st->print("Bsd"); + + os::Posix::print_uname_info(st); +} void os::print_os_info(outputStream* st) { st->print("OS:"); - - // Try to identify popular distros. - // Most Bsd distributions have /etc/XXX-release file, which contains - // the OS version string. Some have more than one /etc/XXX-release file - // (e.g. Mandrake has both /etc/mandrake-release and /etc/redhat-release.), - // so the order is important. - if (!_print_ascii_file("/etc/mandrake-release", st) && - !_print_ascii_file("/etc/sun-release", st) && - !_print_ascii_file("/etc/redhat-release", st) && - !_print_ascii_file("/etc/SuSE-release", st) && - !_print_ascii_file("/etc/turbobsd-release", st) && - !_print_ascii_file("/etc/gentoo-release", st) && - !_print_ascii_file("/etc/debian_version", st) && - !_print_ascii_file("/etc/ltib-release", st) && - !_print_ascii_file("/etc/angstrom-version", st)) { - st->print("Bsd"); - } - st->cr(); - - // kernel - st->print("uname:"); - struct utsname name; - uname(&name); - st->print(name.sysname); st->print(" "); - st->print(name.release); st->print(" "); - st->print(name.version); st->print(" "); - st->print(name.machine); - st->cr(); - -#ifndef _ALLBSD_SOURCE - // Print warning if unsafe chroot environment detected - if (unsafe_chroot_detected) { - st->print("WARNING!! "); - st->print_cr(unstable_chroot_error); - } - - // libc, pthread - st->print("libc:"); - st->print(os::Bsd::glibc_version()); st->print(" "); - st->print(os::Bsd::libpthread_version()); st->print(" "); - if (os::Bsd::is_BsdThreads()) { - st->print("(%s stack)", os::Bsd::is_floating_stack() ? "floating" : "fixed"); - } - st->cr(); -#endif - - // rlimit - st->print("rlimit:"); - struct rlimit rlim; - - st->print(" STACK "); - getrlimit(RLIMIT_STACK, &rlim); - if (rlim.rlim_cur == RLIM_INFINITY) st->print("infinity"); - else st->print("%uk", rlim.rlim_cur >> 10); - - st->print(", CORE "); - getrlimit(RLIMIT_CORE, &rlim); - if (rlim.rlim_cur == RLIM_INFINITY) st->print("infinity"); - else st->print("%uk", rlim.rlim_cur >> 10); - - st->print(", NPROC "); - getrlimit(RLIMIT_NPROC, &rlim); - if (rlim.rlim_cur == RLIM_INFINITY) st->print("infinity"); - else st->print("%d", rlim.rlim_cur); - - st->print(", NOFILE "); - getrlimit(RLIMIT_NOFILE, &rlim); - if (rlim.rlim_cur == RLIM_INFINITY) st->print("infinity"); - else st->print("%d", rlim.rlim_cur); - -#ifndef _ALLBSD_SOURCE - st->print(", AS "); - getrlimit(RLIMIT_AS, &rlim); - if (rlim.rlim_cur == RLIM_INFINITY) st->print("infinity"); - else st->print("%uk", rlim.rlim_cur >> 10); - st->cr(); - - // load average - st->print("load average:"); - double loadavg[3]; - os::loadavg(loadavg, 3); - st->print("%0.02f %0.02f %0.02f", loadavg[0], loadavg[1], loadavg[2]); - st->cr(); -#endif + st->print("Bsd"); + + os::Posix::print_uname_info(st); + + os::Posix::print_rlimit_info(st); + + os::Posix::print_load_average(st); } void os::pd_print_cpu_info(outputStream* st) { diff -r e2961d14584b -r 7089278210e2 src/os/linux/vm/os_linux.cpp --- a/src/os/linux/vm/os_linux.cpp Mon May 21 09:46:02 2012 +0200 +++ b/src/os/linux/vm/os_linux.cpp Thu May 24 18:39:44 2012 -0700 @@ -2020,15 +2020,43 @@ } } +void os::print_os_info_brief(outputStream* st) { + os::Linux::print_distro_info(st); + + os::Posix::print_uname_info(st); + + os::Linux::print_libversion_info(st); + +} void os::print_os_info(outputStream* st) { st->print("OS:"); - // Try to identify popular distros. - // Most Linux distributions have /etc/XXX-release file, which contains - // the OS version string. Some have more than one /etc/XXX-release file - // (e.g. Mandrake has both /etc/mandrake-release and /etc/redhat-release.), - // so the order is important. + os::Linux::print_distro_info(st); + + os::Posix::print_uname_info(st); + + // Print warning if unsafe chroot environment detected + if (unsafe_chroot_detected) { + st->print("WARNING!! "); + st->print_cr(unstable_chroot_error); + } + + os::Linux::print_libversion_info(st); + + os::Posix::print_rlimit_info(st); + + os::Posix::print_load_average(st); + + os::Linux::print_full_memory_info(st); +} + +// Try to identify popular distros. +// Most Linux distributions have /etc/XXX-release file, which contains +// the OS version string. Some have more than one /etc/XXX-release file +// (e.g. Mandrake has both /etc/mandrake-release and /etc/redhat-release.), +// so the order is important. +void os::Linux::print_distro_info(outputStream* st) { if (!_print_ascii_file("/etc/mandrake-release", st) && !_print_ascii_file("/etc/sun-release", st) && !_print_ascii_file("/etc/redhat-release", st) && @@ -2041,23 +2069,9 @@ st->print("Linux"); } st->cr(); - - // kernel - st->print("uname:"); - struct utsname name; - uname(&name); - st->print(name.sysname); st->print(" "); - st->print(name.release); st->print(" "); - st->print(name.version); st->print(" "); - st->print(name.machine); - st->cr(); - - // Print warning if unsafe chroot environment detected - if (unsafe_chroot_detected) { - st->print("WARNING!! "); - st->print_cr(unstable_chroot_error); - } - +} + +void os::Linux::print_libversion_info(outputStream* st) { // libc, pthread st->print("libc:"); st->print(os::Linux::glibc_version()); st->print(" "); @@ -2066,56 +2080,12 @@ st->print("(%s stack)", os::Linux::is_floating_stack() ? "floating" : "fixed"); } st->cr(); - - // rlimit - st->print("rlimit:"); - struct rlimit rlim; - - st->print(" STACK "); - getrlimit(RLIMIT_STACK, &rlim); - if (rlim.rlim_cur == RLIM_INFINITY) st->print("infinity"); - else st->print("%uk", rlim.rlim_cur >> 10); - - st->print(", CORE "); - getrlimit(RLIMIT_CORE, &rlim); - if (rlim.rlim_cur == RLIM_INFINITY) st->print("infinity"); - else st->print("%uk", rlim.rlim_cur >> 10); - - st->print(", NPROC "); - getrlimit(RLIMIT_NPROC, &rlim); - if (rlim.rlim_cur == RLIM_INFINITY) st->print("infinity"); - else st->print("%d", rlim.rlim_cur); - - st->print(", NOFILE "); - getrlimit(RLIMIT_NOFILE, &rlim); - if (rlim.rlim_cur == RLIM_INFINITY) st->print("infinity"); - else st->print("%d", rlim.rlim_cur); - - st->print(", AS "); - getrlimit(RLIMIT_AS, &rlim); - if (rlim.rlim_cur == RLIM_INFINITY) st->print("infinity"); - else st->print("%uk", rlim.rlim_cur >> 10); - st->cr(); - - // load average - st->print("load average:"); - double loadavg[3]; - os::loadavg(loadavg, 3); - st->print("%0.02f %0.02f %0.02f", loadavg[0], loadavg[1], loadavg[2]); - st->cr(); - - // meminfo - st->print("\n/proc/meminfo:\n"); - _print_ascii_file("/proc/meminfo", st); - st->cr(); -} - -void os::pd_print_cpu_info(outputStream* st) { - st->print("\n/proc/cpuinfo:\n"); - if (!_print_ascii_file("/proc/cpuinfo", st)) { - st->print(" "); - } - st->cr(); +} + +void os::Linux::print_full_memory_info(outputStream* st) { + st->print("\n/proc/meminfo:\n"); + _print_ascii_file("/proc/meminfo", st); + st->cr(); } void os::print_memory_info(outputStream* st) { @@ -2138,6 +2108,14 @@ st->cr(); } +void os::pd_print_cpu_info(outputStream* st) { + st->print("\n/proc/cpuinfo:\n"); + if (!_print_ascii_file("/proc/cpuinfo", st)) { + st->print(" "); + } + st->cr(); +} + // Taken from /usr/include/bits/siginfo.h Supposed to be architecture specific // but they're the same for all the linux arch that we support // and they're the same for solaris but there's no common place to put this. diff -r e2961d14584b -r 7089278210e2 src/os/linux/vm/os_linux.hpp --- a/src/os/linux/vm/os_linux.hpp Mon May 21 09:46:02 2012 +0200 +++ b/src/os/linux/vm/os_linux.hpp Thu May 24 18:39:44 2012 -0700 @@ -89,6 +89,10 @@ static bool hugetlbfs_sanity_check(bool warn, size_t page_size); + static void print_full_memory_info(outputStream* st); + static void print_distro_info(outputStream* st); + static void print_libversion_info(outputStream* st); + public: static void init_thread_fpu_state(); static int get_fpu_control_word(); diff -r e2961d14584b -r 7089278210e2 src/os/posix/vm/os_posix.cpp --- a/src/os/posix/vm/os_posix.cpp Mon May 21 09:46:02 2012 +0200 +++ b/src/os/posix/vm/os_posix.cpp Thu May 24 18:39:44 2012 -0700 @@ -28,6 +28,8 @@ #include #include +#include + // Check core dump limit and report possible place where core can be found void os::check_or_create_dump(void* exceptionRecord, void* contextRecord, char* buffer, size_t bufferSize) { @@ -72,3 +74,59 @@ // don't do anything on posix platforms return; } + +void os::Posix::print_load_average(outputStream* st) { + st->print("load average:"); + double loadavg[3]; + os::loadavg(loadavg, 3); + st->print("%0.02f %0.02f %0.02f", loadavg[0], loadavg[1], loadavg[2]); + st->cr(); +} + +void os::Posix::print_rlimit_info(outputStream* st) { + st->print("rlimit:"); + struct rlimit rlim; + + st->print(" STACK "); + getrlimit(RLIMIT_STACK, &rlim); + if (rlim.rlim_cur == RLIM_INFINITY) st->print("infinity"); + else st->print("%uk", rlim.rlim_cur >> 10); + + st->print(", CORE "); + getrlimit(RLIMIT_CORE, &rlim); + if (rlim.rlim_cur == RLIM_INFINITY) st->print("infinity"); + else st->print("%uk", rlim.rlim_cur >> 10); + + //Isn't there on solaris +#ifndef TARGET_OS_FAMILY_solaris + st->print(", NPROC "); + getrlimit(RLIMIT_NPROC, &rlim); + if (rlim.rlim_cur == RLIM_INFINITY) st->print("infinity"); + else st->print("%d", rlim.rlim_cur); +#endif + + st->print(", NOFILE "); + getrlimit(RLIMIT_NOFILE, &rlim); + if (rlim.rlim_cur == RLIM_INFINITY) st->print("infinity"); + else st->print("%d", rlim.rlim_cur); + + st->print(", AS "); + getrlimit(RLIMIT_AS, &rlim); + if (rlim.rlim_cur == RLIM_INFINITY) st->print("infinity"); + else st->print("%uk", rlim.rlim_cur >> 10); + st->cr(); +} + +void os::Posix::print_uname_info(outputStream* st) { + // kernel + st->print("uname:"); + struct utsname name; + uname(&name); + st->print(name.sysname); st->print(" "); + st->print(name.release); st->print(" "); + st->print(name.version); st->print(" "); + st->print(name.machine); + st->cr(); +} + + diff -r e2961d14584b -r 7089278210e2 src/os/posix/vm/os_posix.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/os/posix/vm/os_posix.hpp Thu May 24 18:39:44 2012 -0700 @@ -0,0 +1,41 @@ +/* + * Copyright (c) 1999, 2010, 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. + * + */ + +#ifndef OS_POSIX_VM_OS_POSIX_HPP +#define OS_POSIX_VM_OS_POSIX_HPP +class Posix { + friend class os; + +protected: + static void print_distro_info(outputStream* st); + static void print_rlimit_info(outputStream* st); + static void print_uname_info(outputStream* st); + static void print_libversion_info(outputStream* st); + static void print_load_average(outputStream* st); + + +}; + + +#endif diff -r e2961d14584b -r 7089278210e2 src/os/solaris/add_gnu_debuglink/add_gnu_debuglink.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/os/solaris/add_gnu_debuglink/add_gnu_debuglink.c Thu May 24 18:39:44 2012 -0700 @@ -0,0 +1,285 @@ +/* + * 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. + * + * 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. + * + */ + +/* + * Name: add_gnu_debuglink.c + * + * Description: Add a ".gnu_debuglink" section that refers to the specified + * debug_info_path to the specified ELF object. + * + * This program is adapted from the example program shown on the + * elf(3elf) man page and from code from the Solaris compiler + * driver. + */ + +/* + * needed to define SHF_EXCLUDE + */ +#define ELF_TARGET_ALL + +#include +#include +#include +#include +#include +#include + +static void failure(void); +static unsigned int gnu_debuglink_crc32(unsigned int crc, unsigned char *buf, + size_t len); + +void +main(int argc, char ** argv) { + /* new ELF section name */ + static char SEC_NAME[] = ".gnu_debuglink"; + + unsigned char buffer[8 * 1024]; /* I/O buffer */ + int buffer_len; /* buffer length */ + char * debug_info_path; /* debug info path */ + void * ehdr; /* ELF header */ + Elf * elf; /* ELF descriptor */ + char * elf_ident; /* ELF identity string */ + char * elf_obj; /* elf_obj file */ + int fd; /* descriptor for files */ + unsigned int file_crc = 0; /* CRC for debug info file */ + int is_elfclass64; /* is an ELFCLASS64 file? */ + Elf_Data * link_dat; /* ELF data for new debug info link */ + Elf_Data * name_dat; /* ELF data for new section name */ + Elf_Scn * new_scn; /* new ELF section descriptor */ + void * new_shdr; /* new ELF section header */ + Elf_Scn * scn; /* ELF section descriptor */ + void * shdr; /* ELF section header */ + + if (argc != 3) { + (void) fprintf(stderr, "Usage: %s debug_info_path elf_obj\n", argv[0]); + exit(2); + } + + debug_info_path = argv[1]; /* save for later */ + if ((fd = open(debug_info_path, O_RDONLY)) == -1) { + (void) fprintf(stderr, "%s: cannot open file.\n", debug_info_path); + exit(3); + } + + (void) printf("Computing CRC for '%s'\n", debug_info_path); + (void) fflush(stdout); + /* compute CRC for the debug info file */ + for (;;) { + int len = read(fd, buffer, sizeof buffer); + if (len <= 0) { + break; + } + file_crc = gnu_debuglink_crc32(file_crc, buffer, len); + } + (void) close(fd); + + /* open the elf_obj */ + elf_obj = argv[2]; + if ((fd = open(elf_obj, O_RDWR)) == -1) { + (void) fprintf(stderr, "%s: cannot open file.\n", elf_obj); + exit(4); + } + + (void) printf("Opening '%s' for update\n", elf_obj); + (void) fflush(stdout); + (void) elf_version(EV_CURRENT); /* coordinate ELF versions */ + + /* obtain the ELF descriptors from the input file */ + if ((elf = elf_begin(fd, ELF_C_RDWR, NULL)) == NULL) { + failure(); + } + + /* determine if ELFCLASS64 or not? */ + elf_ident = elf_getident(elf, NULL); + is_elfclass64 = (elf_ident[EI_CLASS] == ELFCLASS64); + + /* get the ELF header */ + if (is_elfclass64) { + ehdr = elf64_getehdr(elf); + } else { + ehdr = elf32_getehdr(elf); + } + if (ehdr == NULL) { + failure(); + } + + /* get the ELF section descriptor */ + if (is_elfclass64) { + scn = elf_getscn(elf, ((Elf64_Ehdr *) ehdr)->e_shstrndx); + } else { + scn = elf_getscn(elf, ((Elf32_Ehdr *) ehdr)->e_shstrndx); + } + if (scn == NULL) { + failure(); + } + + /* get the section header */ + if (is_elfclass64) { + shdr = elf64_getshdr(scn); + } else { + shdr = elf32_getshdr(scn); + } + if (shdr == NULL) { + failure(); + } + + (void) printf("Adding ELF data for new section name\n"); + (void) fflush(stdout); + name_dat = elf_newdata(scn); + name_dat->d_buf = (void *) SEC_NAME; + if (is_elfclass64) { + name_dat->d_off = ((Elf64_Shdr *) shdr)->sh_size + 1; + } else { + name_dat->d_off = ((Elf32_Shdr *) shdr)->sh_size + 1; + } + name_dat->d_align = 1; + name_dat->d_size = strlen(SEC_NAME) + 1; + + new_scn = elf_newscn(elf); + + if (is_elfclass64) { + new_shdr = elf64_getshdr(new_scn); + ((Elf64_Shdr *) new_shdr)->sh_flags = SHF_EXCLUDE; + ((Elf64_Shdr *) new_shdr)->sh_type = SHT_PROGBITS; + ((Elf64_Shdr *) new_shdr)->sh_name = ((Elf64_Shdr *) shdr)->sh_size; + ((Elf64_Shdr *) new_shdr)->sh_addralign = 1; + ((Elf64_Shdr *) shdr)->sh_size += (strlen(SEC_NAME) + 1); + } else { + new_shdr = elf32_getshdr(new_scn); + ((Elf32_Shdr *) new_shdr)->sh_flags = SHF_EXCLUDE; + ((Elf32_Shdr *) new_shdr)->sh_type = SHT_PROGBITS; + ((Elf32_Shdr *) new_shdr)->sh_name = ((Elf32_Shdr *) shdr)->sh_size; + ((Elf32_Shdr *) new_shdr)->sh_addralign = 1; + ((Elf32_Shdr *) shdr)->sh_size += (strlen(SEC_NAME) + 1); + } + + (void) printf("Adding ELF data for debug_info_path value\n"); + (void) fflush(stdout); + (void) memset(buffer, 0, sizeof buffer); + buffer_len = strlen(debug_info_path) + 1; /* +1 for NUL */ + (void) strncpy((char *) buffer, debug_info_path, buffer_len); + if (buffer_len % 4 != 0) { + /* not on a 4 byte boundary so pad to the next one */ + buffer_len += (4 - buffer_len % 4); + } + /* save the CRC */ + (void) memcpy(&buffer[buffer_len], &file_crc, sizeof file_crc); + buffer_len += sizeof file_crc; + + link_dat = elf_newdata(new_scn); + link_dat->d_type = ELF_T_BYTE; + link_dat->d_size = buffer_len; + link_dat->d_buf = buffer; + link_dat->d_align = 1; + + (void) printf("Saving updates to '%s'\n", elf_obj); + (void) fflush(stdout); + (void) elf_update(elf, ELF_C_NULL); /* recalc ELF memory structures */ + (void) elf_update(elf, ELF_C_WRITE); /* write out changes to ELF obj */ + (void) elf_end(elf); /* done with ELF obj */ + (void) close(fd); + + (void) printf("Done updating '%s'\n", elf_obj); + (void) fflush(stdout); + exit(0); +} /* end main */ + + +static void +failure() { + (void) fprintf(stderr, "%s\n", elf_errmsg(elf_errno())); + exit(5); +} + + +/* + * The CRC used in gnu_debuglink, retrieved from + * http://sourceware.org/gdb/current/onlinedocs/gdb/Separate-Debug-Files.html#Separate-Debug-Files. + */ + +static unsigned int +gnu_debuglink_crc32(unsigned int crc, unsigned char *buf, size_t len) { + static const unsigned int crc32_table[256] = { + 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, + 0x706af48f, 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, + 0xe0d5e91e, 0x97d2d988, 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, + 0x90bf1d91, 0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de, + 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7, 0x136c9856, + 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9, + 0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4, + 0xa2677172, 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, + 0x35b5a8fa, 0x42b2986c, 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, + 0x45df5c75, 0xdcd60dcf, 0xabd13d59, 0x26d930ac, 0x51de003a, + 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423, 0xcfba9599, + 0xb8bda50f, 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924, + 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, 0x76dc4190, + 0x01db7106, 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f, + 0x9fbfe4a5, 0xe8b8d433, 0x7807c9a2, 0x0f00f934, 0x9609a88e, + 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d, 0x91646c97, 0xe6635c01, + 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e, 0x6c0695ed, + 0x1b01a57b, 0x8208f4c1, 0xf50fc457, 0x65b0d9c6, 0x12b7e950, + 0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, + 0xfbd44c65, 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, + 0x4adfa541, 0x3dd895d7, 0xa4d1c46d, 0xd3d6f4fb, 0x4369e96a, + 0x346ed9fc, 0xad678846, 0xda60b8d0, 0x44042d73, 0x33031de5, + 0xaa0a4c5f, 0xdd0d7cc9, 0x5005713c, 0x270241aa, 0xbe0b1010, + 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f, + 0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17, + 0x2eb40d81, 0xb7bd5c3b, 0xc0ba6cad, 0xedb88320, 0x9abfb3b6, + 0x03b6e20c, 0x74b1d29a, 0xead54739, 0x9dd277af, 0x04db2615, + 0x73dc1683, 0xe3630b12, 0x94643b84, 0x0d6d6a3e, 0x7a6a5aa8, + 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1, 0xf00f9344, + 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb, + 0x196c3671, 0x6e6b06e7, 0xfed41b76, 0x89d32be0, 0x10da7a5a, + 0x67dd4acc, 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5, + 0xd6d6a3e8, 0xa1d1937e, 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1, + 0xa6bc5767, 0x3fb506dd, 0x48b2364b, 0xd80d2bda, 0xaf0a1b4c, + 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55, 0x316e8eef, + 0x4669be79, 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236, + 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, 0xc5ba3bbe, + 0xb2bd0b28, 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31, + 0x2cd99e8b, 0x5bdeae1d, 0x9b64c2b0, 0xec63f226, 0x756aa39c, + 0x026d930a, 0x9c0906a9, 0xeb0e363f, 0x72076785, 0x05005713, + 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38, 0x92d28e9b, + 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, 0x86d3d2d4, 0xf1d4e242, + 0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, + 0x18b74777, 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, + 0x8f659eff, 0xf862ae69, 0x616bffd3, 0x166ccf45, 0xa00ae278, + 0xd70dd2ee, 0x4e048354, 0x3903b3c2, 0xa7672661, 0xd06016f7, + 0x4969474d, 0x3e6e77db, 0xaed16a4a, 0xd9d65adc, 0x40df0b66, + 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9, + 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, + 0xcdd70693, 0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8, + 0x5d681b02, 0x2a6f2b94, 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, + 0x2d02ef8d + }; + + unsigned char *end; + + crc = ~crc & 0xffffffff; + for (end = buf + len; buf < end; ++buf) { + crc = crc32_table[(crc ^ *buf) & 0xff] ^ (crc >> 8); + } + return ~crc & 0xffffffff; +} diff -r e2961d14584b -r 7089278210e2 src/os/solaris/vm/os_solaris.cpp --- a/src/os/solaris/vm/os_solaris.cpp Mon May 21 09:46:02 2012 +0200 +++ b/src/os/solaris/vm/os_solaris.cpp Thu May 24 18:39:44 2012 -0700 @@ -2242,61 +2242,44 @@ return true; } +void os::print_os_info_brief(outputStream* st) { + os::Solaris::print_distro_info(st); + + os::Posix::print_uname_info(st); + + os::Solaris::print_libversion_info(st); +} + void os::print_os_info(outputStream* st) { st->print("OS:"); + os::Solaris::print_distro_info(st); + + os::Posix::print_uname_info(st); + + os::Solaris::print_libversion_info(st); + + os::Posix::print_rlimit_info(st); + + os::Posix::print_load_average(st); +} + +void os::Solaris::print_distro_info(outputStream* st) { if (!_print_ascii_file("/etc/release", st)) { - st->print("Solaris"); + st->print("Solaris"); + } + st->cr(); +} + +void os::Solaris::print_libversion_info(outputStream* st) { + if (os::Solaris::T2_libthread()) { + st->print(" (T2 libthread)"); + } + else { + st->print(" (T1 libthread)"); } st->cr(); - - // kernel - st->print("uname:"); - struct utsname name; - uname(&name); - st->print(name.sysname); st->print(" "); - st->print(name.release); st->print(" "); - st->print(name.version); st->print(" "); - st->print(name.machine); - - // libthread - if (os::Solaris::T2_libthread()) st->print(" (T2 libthread)"); - else st->print(" (T1 libthread)"); - st->cr(); - - // rlimit - st->print("rlimit:"); - struct rlimit rlim; - - st->print(" STACK "); - getrlimit(RLIMIT_STACK, &rlim); - if (rlim.rlim_cur == RLIM_INFINITY) st->print("infinity"); - else st->print("%uk", rlim.rlim_cur >> 10); - - st->print(", CORE "); - getrlimit(RLIMIT_CORE, &rlim); - if (rlim.rlim_cur == RLIM_INFINITY) st->print("infinity"); - else st->print("%uk", rlim.rlim_cur >> 10); - - st->print(", NOFILE "); - getrlimit(RLIMIT_NOFILE, &rlim); - if (rlim.rlim_cur == RLIM_INFINITY) st->print("infinity"); - else st->print("%d", rlim.rlim_cur); - - st->print(", AS "); - getrlimit(RLIMIT_AS, &rlim); - if (rlim.rlim_cur == RLIM_INFINITY) st->print("infinity"); - else st->print("%uk", rlim.rlim_cur >> 10); - st->cr(); - - // load average - st->print("load average:"); - double loadavg[3]; - os::loadavg(loadavg, 3); - st->print("%0.02f %0.02f %0.02f", loadavg[0], loadavg[1], loadavg[2]); - st->cr(); -} - +} static bool check_addr0(outputStream* st) { jboolean status = false; diff -r e2961d14584b -r 7089278210e2 src/os/solaris/vm/os_solaris.hpp --- a/src/os/solaris/vm/os_solaris.hpp Mon May 21 09:46:02 2012 +0200 +++ b/src/os/solaris/vm/os_solaris.hpp Thu May 24 18:39:44 2012 -0700 @@ -180,6 +180,9 @@ // proc_t structure (note that this is a system struct). static address _main_stack_base; + static void print_distro_info(outputStream* st); + static void print_libversion_info(outputStream* st); + public: static void libthread_init(); static void synchronization_init(); diff -r e2961d14584b -r 7089278210e2 src/os/windows/vm/os_windows.cpp --- a/src/os/windows/vm/os_windows.cpp Mon May 21 09:46:02 2012 +0200 +++ b/src/os/windows/vm/os_windows.cpp Thu May 24 18:39:44 2012 -0700 @@ -1562,9 +1562,17 @@ enumerate_modules(pid, _print_module, (void *)st); } +void os::print_os_info_brief(outputStream* st) { + os::print_os_info(st); +} + void os::print_os_info(outputStream* st) { st->print("OS:"); + os::win32::print_windows_version(st); +} + +void os::win32::print_windows_version(outputStream* st) { OSVERSIONINFOEX osvi; ZeroMemory(&osvi, sizeof(OSVERSIONINFOEX)); osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX); diff -r e2961d14584b -r 7089278210e2 src/os/windows/vm/os_windows.hpp --- a/src/os/windows/vm/os_windows.hpp Mon May 21 09:46:02 2012 +0200 +++ b/src/os/windows/vm/os_windows.hpp Thu May 24 18:39:44 2012 -0700 @@ -27,6 +27,7 @@ // Win32_OS defines the interface to windows operating systems class win32 { + friend class os; protected: static int _vm_page_size; @@ -39,6 +40,8 @@ static bool _is_windows_2003; static bool _is_windows_server; + static void print_windows_version(outputStream* st); + public: // Windows-specific interface: static void initialize_system_info(); diff -r e2961d14584b -r 7089278210e2 src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.cpp --- a/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.cpp Mon May 21 09:46:02 2012 +0200 +++ b/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.cpp Thu May 24 18:39:44 2012 -0700 @@ -6332,10 +6332,10 @@ ) } -void CMSCollector::do_CMS_operation(CMS_op_type op) { +void CMSCollector::do_CMS_operation(CMS_op_type op, GCCause::Cause gc_cause) { gclog_or_tty->date_stamp(PrintGC && PrintGCDateStamps); TraceCPUTime tcpu(PrintGCDetails, true, gclog_or_tty); - TraceTime t("GC", PrintGC, !PrintGCDetails, gclog_or_tty); + TraceTime t(GCCauseString("GC", gc_cause), PrintGC, !PrintGCDetails, gclog_or_tty); TraceCollectorStats tcs(counters()); switch (op) { diff -r e2961d14584b -r 7089278210e2 src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.hpp --- a/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.hpp Mon May 21 09:46:02 2012 +0200 +++ b/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.hpp Thu May 24 18:39:44 2012 -0700 @@ -717,7 +717,7 @@ CMS_op_checkpointRootsFinal }; - void do_CMS_operation(CMS_op_type op); + void do_CMS_operation(CMS_op_type op, GCCause::Cause gc_cause); bool stop_world_and_do(CMS_op_type op); OopTaskQueueSet* task_queues() { return _task_queues; } diff -r e2961d14584b -r 7089278210e2 src/share/vm/gc_implementation/concurrentMarkSweep/vmCMSOperations.cpp --- a/src/share/vm/gc_implementation/concurrentMarkSweep/vmCMSOperations.cpp Mon May 21 09:46:02 2012 +0200 +++ b/src/share/vm/gc_implementation/concurrentMarkSweep/vmCMSOperations.cpp Thu May 24 18:39:44 2012 -0700 @@ -146,7 +146,7 @@ VM_CMS_Operation::verify_before_gc(); IsGCActiveMark x; // stop-world GC active - _collector->do_CMS_operation(CMSCollector::CMS_op_checkpointRootsInitial); + _collector->do_CMS_operation(CMSCollector::CMS_op_checkpointRootsInitial, gch->gc_cause()); VM_CMS_Operation::verify_after_gc(); #ifndef USDT2 @@ -178,7 +178,7 @@ VM_CMS_Operation::verify_before_gc(); IsGCActiveMark x; // stop-world GC active - _collector->do_CMS_operation(CMSCollector::CMS_op_checkpointRootsFinal); + _collector->do_CMS_operation(CMSCollector::CMS_op_checkpointRootsFinal, gch->gc_cause()); VM_CMS_Operation::verify_after_gc(); #ifndef USDT2 diff -r e2961d14584b -r 7089278210e2 src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp --- a/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp Mon May 21 09:46:02 2012 +0200 +++ b/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp Thu May 24 18:39:44 2012 -0700 @@ -1252,10 +1252,7 @@ gclog_or_tty->date_stamp(G1Log::fine() && PrintGCDateStamps); TraceCPUTime tcpu(G1Log::finer(), true, gclog_or_tty); - char verbose_str[128]; - sprintf(verbose_str, "Full GC (%s)", GCCause::to_string(gc_cause())); - TraceTime t(verbose_str, G1Log::fine(), true, gclog_or_tty); - + TraceTime t(GCCauseString("Full GC", gc_cause()), G1Log::fine(), true, gclog_or_tty); TraceCollectorStats tcs(g1mm()->full_collection_counters()); TraceMemoryManagerStats tms(true /* fullGC */, gc_cause()); @@ -3600,12 +3597,10 @@ gclog_or_tty->date_stamp(G1Log::fine() && PrintGCDateStamps); TraceCPUTime tcpu(G1Log::finer(), true, gclog_or_tty); - char verbose_str[128]; - sprintf(verbose_str, "GC pause (%s) (%s)%s", - GCCause::to_string(gc_cause()), - g1_policy()->gcs_are_young() ? "young" : "mixed", - g1_policy()->during_initial_mark_pause() ? " (initial-mark)" : ""); - TraceTime t(verbose_str, G1Log::fine() && !G1Log::finer(), true, gclog_or_tty); + GCCauseString gc_cause_str = GCCauseString("GC pause", gc_cause()) + .append(g1_policy()->gcs_are_young() ? " (young)" : " (mixed)") + .append(g1_policy()->during_initial_mark_pause() ? " (initial-mark)" : ""); + TraceTime t(gc_cause_str, G1Log::fine() && !G1Log::finer(), true, gclog_or_tty); TraceCollectorStats tcs(g1mm()->incremental_collection_counters()); TraceMemoryManagerStats tms(false /* fullGC */, gc_cause()); @@ -5502,7 +5497,7 @@ if (evacuation_failed()) { remove_self_forwarding_pointers(); if (G1Log::finer()) { - gclog_or_tty->print(" (to-space overflow)"); + gclog_or_tty->print(" (to-space exhausted)"); } else if (G1Log::fine()) { gclog_or_tty->print("--"); } diff -r e2961d14584b -r 7089278210e2 src/share/vm/gc_implementation/g1/g1CollectorPolicy.cpp --- a/src/share/vm/gc_implementation/g1/g1CollectorPolicy.cpp Mon May 21 09:46:02 2012 +0200 +++ b/src/share/vm/gc_implementation/g1/g1CollectorPolicy.cpp Thu May 24 18:39:44 2012 -0700 @@ -886,9 +886,8 @@ size_t start_used) { if (G1Log::finer()) { gclog_or_tty->stamp(PrintGCTimeStamps); - gclog_or_tty->print("[GC pause (%s) (%s)", - GCCause::to_string(_g1->gc_cause()), - gcs_are_young() ? "young" : "mixed"); + gclog_or_tty->print("[%s", (const char*)GCCauseString("GC pause", _g1->gc_cause()) + .append(gcs_are_young() ? " (young)" : " (mixed)")); } // We only need to do this here as the policy will only be applied @@ -1010,7 +1009,8 @@ void G1CollectorPolicy::print_par_stats(int level, const char* str, - double* data) { + double* data, + bool showDecimals) { double min = data[0], max = data[0]; double total = 0.0; LineBuffer buf(level); @@ -1023,7 +1023,11 @@ max = val; total += val; if (G1Log::finest()) { - buf.append(" %.1lf", val); + if (showDecimals) { + buf.append(" %.1lf", val); + } else { + buf.append(" %d", (int)val); + } } } @@ -1031,36 +1035,26 @@ buf.append_and_print_cr(""); } double avg = total / (double) no_of_gc_threads(); - buf.append_and_print_cr(" Avg: %.1lf Min: %.1lf Max: %.1lf Diff: %.1lf]", - avg, min, max, max - min); -} - -void G1CollectorPolicy::print_par_sizes(int level, - const char* str, - double* data) { - double min = data[0], max = data[0]; - double total = 0.0; - LineBuffer buf(level); - buf.append("[%s :", str); - for (uint i = 0; i < no_of_gc_threads(); ++i) { - double val = data[i]; - if (val < min) - min = val; - if (val > max) - max = val; - total += val; - buf.append(" %d", (int) val); + if (showDecimals) { + buf.append_and_print_cr(" Min: %.1lf, Avg: %.1lf, Max: %.1lf, Diff: %.1lf, Sum: %.1lf]", + min, avg, max, max - min, total); + } else { + buf.append_and_print_cr(" Min: %d, Avg: %d, Max: %d, Diff: %d, Sum: %d]", + (int)min, (int)avg, (int)max, (int)max - (int)min, (int)total); } - buf.append_and_print_cr(""); - double avg = total / (double) no_of_gc_threads(); - buf.append_and_print_cr(" Sum: %d, Avg: %d, Min: %d, Max: %d, Diff: %d]", - (int)total, (int)avg, (int)min, (int)max, (int)max - (int)min); } void G1CollectorPolicy::print_stats(int level, const char* str, double value) { - LineBuffer(level).append_and_print_cr("[%s: %5.1lf ms]", str, value); + LineBuffer(level).append_and_print_cr("[%s: %.1lf ms]", str, value); +} + +void G1CollectorPolicy::print_stats(int level, + const char* str, + double value, + int workers) { + LineBuffer(level).append_and_print_cr("[%s: %.1lf ms, GC Workers: %d]", str, value, workers); } void G1CollectorPolicy::print_stats(int level, @@ -1373,7 +1367,7 @@ print_stats(1, "Root Region Scan Waiting", _root_region_scan_wait_time_ms); } if (parallel) { - print_stats(1, "Parallel Time", _cur_collection_par_time_ms); + print_stats(1, "Parallel Time", _cur_collection_par_time_ms, no_of_gc_threads); print_par_stats(2, "GC Worker Start", _par_last_gc_worker_start_times_ms); print_par_stats(2, "Ext Root Scanning", _par_last_ext_root_scan_times_ms); if (print_marking_info) { @@ -1381,13 +1375,15 @@ } print_par_stats(2, "Update RS", _par_last_update_rs_times_ms); if (G1Log::finest()) { - print_par_sizes(3, "Processed Buffers", _par_last_update_rs_processed_buffers); + print_par_stats(3, "Processed Buffers", _par_last_update_rs_processed_buffers, + false /* showDecimals */); } print_par_stats(2, "Scan RS", _par_last_scan_rs_times_ms); print_par_stats(2, "Object Copy", _par_last_obj_copy_times_ms); print_par_stats(2, "Termination", _par_last_termination_times_ms); if (G1Log::finest()) { - print_par_sizes(3, "Termination Attempts", _par_last_termination_attempts); + print_par_stats(3, "Termination Attempts", _par_last_termination_attempts, + false /* showDecimals */); } for (int i = 0; i < _parallel_gc_threads; i++) { @@ -1601,9 +1597,9 @@ _collectionSetChooser->verify(); } -#define EXT_SIZE_FORMAT "%d%s" +#define EXT_SIZE_FORMAT "%.1f%s" #define EXT_SIZE_PARAMS(bytes) \ - byte_size_in_proper_unit((bytes)), \ + byte_size_in_proper_unit((double)(bytes)), \ proper_unit_for_byte_size((bytes)) void G1CollectorPolicy::print_heap_transition() { diff -r e2961d14584b -r 7089278210e2 src/share/vm/gc_implementation/g1/g1CollectorPolicy.hpp --- a/src/share/vm/gc_implementation/g1/g1CollectorPolicy.hpp Mon May 21 09:46:02 2012 +0200 +++ b/src/share/vm/gc_implementation/g1/g1CollectorPolicy.hpp Thu May 24 18:39:44 2012 -0700 @@ -552,10 +552,10 @@ private: void print_stats(int level, const char* str, double value); + void print_stats(int level, const char* str, double value, int workers); void print_stats(int level, const char* str, int value); - void print_par_stats(int level, const char* str, double* data); - void print_par_sizes(int level, const char* str, double* data); + void print_par_stats(int level, const char* str, double* data, bool showDecimals = true); void check_other_times(int level, NumberSeq* other_times_ms, diff -r e2961d14584b -r 7089278210e2 src/share/vm/gc_implementation/g1/vm_operations_g1.cpp --- a/src/share/vm/gc_implementation/g1/vm_operations_g1.cpp Mon May 21 09:46:02 2012 +0200 +++ b/src/share/vm/gc_implementation/g1/vm_operations_g1.cpp Thu May 24 18:39:44 2012 -0700 @@ -42,6 +42,7 @@ void VM_G1CollectForAllocation::doit() { G1CollectedHeap* g1h = G1CollectedHeap::heap(); + GCCauseSetter x(g1h, _gc_cause); _result = g1h->satisfy_failed_allocation(_word_size, &_pause_succeeded); assert(_result == NULL || _pause_succeeded, "if we get back a result, the pause should have succeeded"); diff -r e2961d14584b -r 7089278210e2 src/share/vm/gc_implementation/parNew/parNewGeneration.cpp --- a/src/share/vm/gc_implementation/parNew/parNewGeneration.cpp Mon May 21 09:46:02 2012 +0200 +++ b/src/share/vm/gc_implementation/parNew/parNewGeneration.cpp Thu May 24 18:39:44 2012 -0700 @@ -916,7 +916,7 @@ size_policy->minor_collection_begin(); } - TraceTime t1("GC", PrintGC && !PrintGCDetails, true, gclog_or_tty); + TraceTime t1(GCCauseString("GC", gch->gc_cause()), PrintGC && !PrintGCDetails, true, gclog_or_tty); // Capture heap used before collection (for printing). size_t gch_prev_used = gch->used(); diff -r e2961d14584b -r 7089278210e2 src/share/vm/gc_implementation/parallelScavenge/psMarkSweep.cpp --- a/src/share/vm/gc_implementation/parallelScavenge/psMarkSweep.cpp Mon May 21 09:46:02 2012 +0200 +++ b/src/share/vm/gc_implementation/parallelScavenge/psMarkSweep.cpp Thu May 24 18:39:44 2012 -0700 @@ -160,16 +160,10 @@ { HandleMark hm; - const bool is_system_gc = gc_cause == GCCause::_java_lang_system_gc; - // This is useful for debugging but don't change the output the - // the customer sees. - const char* gc_cause_str = "Full GC"; - if (is_system_gc && PrintGCDetails) { - gc_cause_str = "Full GC (System)"; - } + gclog_or_tty->date_stamp(PrintGC && PrintGCDateStamps); TraceCPUTime tcpu(PrintGCDetails, true, gclog_or_tty); - TraceTime t1(gc_cause_str, PrintGC, !PrintGCDetails, gclog_or_tty); + TraceTime t1(GCCauseString("Full GC", gc_cause), PrintGC, !PrintGCDetails, gclog_or_tty); TraceCollectorStats tcs(counters()); TraceMemoryManagerStats tms(true /* Full GC */,gc_cause); diff -r e2961d14584b -r 7089278210e2 src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.cpp --- a/src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.cpp Mon May 21 09:46:02 2012 +0200 +++ b/src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.cpp Thu May 24 18:39:44 2012 -0700 @@ -2047,17 +2047,9 @@ gc_task_manager()->task_idle_workers(); heap->set_par_threads(gc_task_manager()->active_workers()); - const bool is_system_gc = gc_cause == GCCause::_java_lang_system_gc; - - // This is useful for debugging but don't change the output the - // the customer sees. - const char* gc_cause_str = "Full GC"; - if (is_system_gc && PrintGCDetails) { - gc_cause_str = "Full GC (System)"; - } gclog_or_tty->date_stamp(PrintGC && PrintGCDateStamps); TraceCPUTime tcpu(PrintGCDetails, true, gclog_or_tty); - TraceTime t1(gc_cause_str, PrintGC, !PrintGCDetails, gclog_or_tty); + TraceTime t1(GCCauseString("Full GC", gc_cause), PrintGC, !PrintGCDetails, gclog_or_tty); TraceCollectorStats tcs(counters()); TraceMemoryManagerStats tms(true /* Full GC */,gc_cause); @@ -2090,7 +2082,8 @@ } #endif // #ifndef PRODUCT - bool max_on_system_gc = UseMaximumCompactionOnSystemGC && is_system_gc; + bool max_on_system_gc = UseMaximumCompactionOnSystemGC + && gc_cause == GCCause::_java_lang_system_gc; summary_phase(vmthread_cm, maximum_heap_compaction || max_on_system_gc); COMPILER2_PRESENT(assert(DerivedPointerTable::is_active(), "Sanity")); diff -r e2961d14584b -r 7089278210e2 src/share/vm/gc_implementation/parallelScavenge/psScavenge.cpp --- a/src/share/vm/gc_implementation/parallelScavenge/psScavenge.cpp Mon May 21 09:46:02 2012 +0200 +++ b/src/share/vm/gc_implementation/parallelScavenge/psScavenge.cpp Thu May 24 18:39:44 2012 -0700 @@ -325,7 +325,7 @@ gclog_or_tty->date_stamp(PrintGC && PrintGCDateStamps); TraceCPUTime tcpu(PrintGCDetails, true, gclog_or_tty); - TraceTime t1("GC", PrintGC, !PrintGCDetails, gclog_or_tty); + TraceTime t1(GCCauseString("GC", gc_cause), PrintGC, !PrintGCDetails, gclog_or_tty); TraceCollectorStats tcs(counters()); TraceMemoryManagerStats tms(false /* not full GC */,gc_cause); diff -r e2961d14584b -r 7089278210e2 src/share/vm/gc_implementation/shared/gcUtil.cpp --- a/src/share/vm/gc_implementation/shared/gcUtil.cpp Mon May 21 09:46:02 2012 +0200 +++ b/src/share/vm/gc_implementation/shared/gcUtil.cpp Thu May 24 18:39:44 2012 -0700 @@ -31,9 +31,15 @@ float average) { // We smooth the samples by not using weight() directly until we've // had enough data to make it meaningful. We'd like the first weight - // used to be 1, the second to be 1/2, etc until we have 100/weight - // samples. - unsigned count_weight = 100/count(); + // used to be 1, the second to be 1/2, etc until we have + // OLD_THRESHOLD/weight samples. + unsigned count_weight = 0; + + // Avoid division by zero if the counter wraps (7158457) + if (!is_old()) { + count_weight = OLD_THRESHOLD/count(); + } + unsigned adaptive_weight = (MAX2(weight(), count_weight)); float new_avg = exp_avg(average, new_sample, adaptive_weight); @@ -43,8 +49,6 @@ void AdaptiveWeightedAverage::sample(float new_sample) { increment_count(); - assert(count() != 0, - "Wraparound -- history would be incorrectly discarded"); // Compute the new weighted average float new_avg = compute_adaptive_average(new_sample, average()); diff -r e2961d14584b -r 7089278210e2 src/share/vm/gc_implementation/shared/gcUtil.hpp --- a/src/share/vm/gc_implementation/shared/gcUtil.hpp Mon May 21 09:46:02 2012 +0200 +++ b/src/share/vm/gc_implementation/shared/gcUtil.hpp Thu May 24 18:39:44 2012 -0700 @@ -50,11 +50,20 @@ unsigned _weight; // The weight used to smooth the averages // A higher weight favors the most // recent data. + bool _is_old; // Has enough historical data + + const static unsigned OLD_THRESHOLD = 100; protected: float _last_sample; // The last value sampled. - void increment_count() { _sample_count++; } + void increment_count() { + _sample_count++; + if (!_is_old && _sample_count > OLD_THRESHOLD) { + _is_old = true; + } + } + void set_average(float avg) { _average = avg; } // Helper function, computes an adaptive weighted average @@ -64,13 +73,15 @@ public: // Input weight must be between 0 and 100 AdaptiveWeightedAverage(unsigned weight, float avg = 0.0) : - _average(avg), _sample_count(0), _weight(weight), _last_sample(0.0) { + _average(avg), _sample_count(0), _weight(weight), _last_sample(0.0), + _is_old(false) { } void clear() { _average = 0; _sample_count = 0; _last_sample = 0; + _is_old = false; } // Useful for modifying static structures after startup. @@ -84,7 +95,8 @@ float average() const { return _average; } unsigned weight() const { return _weight; } unsigned count() const { return _sample_count; } - float last_sample() const { return _last_sample; } + float last_sample() const { return _last_sample; } + bool is_old() const { return _is_old; } // Update data with a new sample. void sample(float new_sample); diff -r e2961d14584b -r 7089278210e2 src/share/vm/gc_interface/gcCause.hpp --- a/src/share/vm/gc_interface/gcCause.hpp Mon May 21 09:46:02 2012 +0200 +++ b/src/share/vm/gc_interface/gcCause.hpp Thu May 24 18:39:44 2012 -0700 @@ -88,4 +88,36 @@ static const char* to_string(GCCause::Cause cause); }; +// Helper class for doing logging that includes the GC Cause +// as a string. +class GCCauseString : StackObj { + private: + static const int _length = 128; + char _buffer[_length]; + int _position; + + public: + GCCauseString(const char* prefix, GCCause::Cause cause) { + if (PrintGCCause) { + _position = jio_snprintf(_buffer, _length, "%s (%s)", prefix, GCCause::to_string(cause)); + } else { + _position = jio_snprintf(_buffer, _length, "%s", prefix); + } + assert(_position >= 0 && _position <= _length, + err_msg("Need to increase the buffer size in GCCauseString? %d", _position)); + } + + GCCauseString& append(const char* str) { + int res = jio_snprintf(_buffer + _position, _length - _position, "%s", str); + _position += res; + assert(res >= 0 && _position <= _length, + err_msg("Need to increase the buffer size in GCCauseString? %d", res)); + return *this; + } + + operator const char*() { + return _buffer; + } +}; + #endif // SHARE_VM_GC_INTERFACE_GCCAUSE_HPP diff -r e2961d14584b -r 7089278210e2 src/share/vm/memory/defNewGeneration.cpp --- a/src/share/vm/memory/defNewGeneration.cpp Mon May 21 09:46:02 2012 +0200 +++ b/src/share/vm/memory/defNewGeneration.cpp Thu May 24 18:39:44 2012 -0700 @@ -548,7 +548,7 @@ init_assuming_no_promotion_failure(); - TraceTime t1("GC", PrintGC && !PrintGCDetails, true, gclog_or_tty); + TraceTime t1(GCCauseString("GC", gch->gc_cause()), PrintGC && !PrintGCDetails, true, gclog_or_tty); // Capture heap used before collection (for printing). size_t gch_prev_used = gch->used(); diff -r e2961d14584b -r 7089278210e2 src/share/vm/memory/genCollectedHeap.cpp --- a/src/share/vm/memory/genCollectedHeap.cpp Mon May 21 09:46:02 2012 +0200 +++ b/src/share/vm/memory/genCollectedHeap.cpp Thu May 24 18:39:44 2012 -0700 @@ -480,26 +480,15 @@ const size_t perm_prev_used = perm_gen()->used(); print_heap_before_gc(); - if (Verbose) { - gclog_or_tty->print_cr("GC Cause: %s", GCCause::to_string(gc_cause())); - } { FlagSetting fl(_is_gc_active, true); bool complete = full && (max_level == (n_gens()-1)); - const char* gc_cause_str = "GC "; - if (complete) { - GCCause::Cause cause = gc_cause(); - if (cause == GCCause::_java_lang_system_gc) { - gc_cause_str = "Full GC (System) "; - } else { - gc_cause_str = "Full GC "; - } - } + const char* gc_cause_prefix = complete ? "Full GC" : "GC"; gclog_or_tty->date_stamp(PrintGC && PrintGCDateStamps); TraceCPUTime tcpu(PrintGCDetails, true, gclog_or_tty); - TraceTime t(gc_cause_str, PrintGCDetails, false, gclog_or_tty); + TraceTime t(GCCauseString(gc_cause_prefix, gc_cause()), PrintGCDetails, false, gclog_or_tty); gc_prologue(complete); increment_total_collections(complete); diff -r e2961d14584b -r 7089278210e2 src/share/vm/memory/genMarkSweep.cpp --- a/src/share/vm/memory/genMarkSweep.cpp Mon May 21 09:46:02 2012 +0200 +++ b/src/share/vm/memory/genMarkSweep.cpp Thu May 24 18:39:44 2012 -0700 @@ -76,7 +76,7 @@ _ref_processor = rp; rp->setup_policy(clear_all_softrefs); - TraceTime t1("Full GC", PrintGC && !PrintGCDetails, true, gclog_or_tty); + TraceTime t1(GCCauseString("Full GC", gch->gc_cause()), PrintGC && !PrintGCDetails, true, gclog_or_tty); // When collecting the permanent generation methodOops may be moving, // so we either have to flush all bcp data or convert it into bci. diff -r e2961d14584b -r 7089278210e2 src/share/vm/runtime/arguments.cpp --- a/src/share/vm/runtime/arguments.cpp Mon May 21 09:46:02 2012 +0200 +++ b/src/share/vm/runtime/arguments.cpp Thu May 24 18:39:44 2012 -0700 @@ -3039,7 +3039,7 @@ return result; } -#ifdef JAVASE_EMBEDDED +#if (defined JAVASE_EMBEDDED || defined ARM) UNSUPPORTED_OPTION(UseG1GC, "G1 GC"); #endif @@ -3092,6 +3092,14 @@ PrintGC = true; } + if (!JDK_Version::is_gte_jdk18x_version()) { + // To avoid changing the log format for 7 updates this flag is only + // true by default in JDK8 and above. + if (FLAG_IS_DEFAULT(PrintGCCause)) { + FLAG_SET_DEFAULT(PrintGCCause, false); + } + } + // Set object alignment values. set_object_alignment(); diff -r e2961d14584b -r 7089278210e2 src/share/vm/runtime/globals.hpp --- a/src/share/vm/runtime/globals.hpp Mon May 21 09:46:02 2012 +0200 +++ b/src/share/vm/runtime/globals.hpp Thu May 24 18:39:44 2012 -0700 @@ -3902,7 +3902,10 @@ " of this flag is true for JDK 6 and earlier") \ \ diagnostic(bool, WhiteBoxAPI, false, \ - "Enable internal testing APIs") + "Enable internal testing APIs") \ + \ + product(bool, PrintGCCause, true, \ + "Include GC cause in GC logging") /* * Macros for factoring of globals diff -r e2961d14584b -r 7089278210e2 src/share/vm/runtime/java.hpp --- a/src/share/vm/runtime/java.hpp Mon May 21 09:46:02 2012 +0200 +++ b/src/share/vm/runtime/java.hpp Thu May 24 18:39:44 2012 -0700 @@ -206,6 +206,10 @@ return current().compare_major(7) == 0; } + static bool is_jdk18x_version() { + return current().compare_major(8) == 0; + } + static bool is_gte_jdk13x_version() { return current().compare_major(3) >= 0; } @@ -225,6 +229,10 @@ static bool is_gte_jdk17x_version() { return current().compare_major(7) >= 0; } + + static bool is_gte_jdk18x_version() { + return current().compare_major(8) >= 0; + } }; #endif // SHARE_VM_RUNTIME_JAVA_HPP diff -r e2961d14584b -r 7089278210e2 src/share/vm/runtime/os.hpp --- a/src/share/vm/runtime/os.hpp Mon May 21 09:46:02 2012 +0200 +++ b/src/share/vm/runtime/os.hpp Thu May 24 18:39:44 2012 -0700 @@ -492,6 +492,7 @@ // Print out system information; they are called by fatal error handler. // Output format may be different on different platforms. static void print_os_info(outputStream* st); + static void print_os_info_brief(outputStream* st); static void print_cpu_info(outputStream* st); static void pd_print_cpu_info(outputStream* st); static void print_memory_info(outputStream* st); @@ -685,14 +686,17 @@ // Platform dependent stuff #ifdef TARGET_OS_FAMILY_linux # include "os_linux.hpp" +# include "os_posix.hpp" #endif #ifdef TARGET_OS_FAMILY_solaris # include "os_solaris.hpp" +# include "os_posix.hpp" #endif #ifdef TARGET_OS_FAMILY_windows # include "os_windows.hpp" #endif #ifdef TARGET_OS_FAMILY_bsd +# include "os_posix.hpp" # include "os_bsd.hpp" #endif #ifdef TARGET_OS_ARCH_linux_x86 diff -r e2961d14584b -r 7089278210e2 src/share/vm/utilities/globalDefinitions.hpp --- a/src/share/vm/utilities/globalDefinitions.hpp Mon May 21 09:46:02 2012 +0200 +++ b/src/share/vm/utilities/globalDefinitions.hpp Thu May 24 18:39:44 2012 -0700 @@ -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 @@ -179,6 +179,11 @@ const jint NANOSECS_PER_MILLISEC = 1000000; inline const char* proper_unit_for_byte_size(size_t s) { +#ifdef _LP64 + if (s >= 10*G) { + return "G"; + } +#endif if (s >= 10*M) { return "M"; } else if (s >= 10*K) { @@ -188,17 +193,22 @@ } } -inline size_t byte_size_in_proper_unit(size_t s) { +template +inline T byte_size_in_proper_unit(T s) { +#ifdef _LP64 + if (s >= 10*G) { + return (T)(s/G); + } +#endif if (s >= 10*M) { - return s/M; + return (T)(s/M); } else if (s >= 10*K) { - return s/K; + return (T)(s/K); } else { return s; } } - //---------------------------------------------------------------------------------------------------- // VM type definitions diff -r e2961d14584b -r 7089278210e2 test/compiler/6894807/Test6894807.sh --- a/test/compiler/6894807/Test6894807.sh Mon May 21 09:46:02 2012 +0200 +++ b/test/compiler/6894807/Test6894807.sh Thu May 24 18:39:44 2012 -0700 @@ -18,8 +18,6 @@ exit 1 fi -BIT_FLAG="" - # set platform-dependent variables OS=`uname -s` case "$OS" in @@ -27,12 +25,6 @@ NULL=/dev/null PS=":" FS="/" - ## for solaris, linux it's HOME - FILE_LOCATION=$HOME - if [ -f ${FILE_LOCATION}${FS}JDK64BIT -a ${OS} = "SunOS" ] - then - BIT_FLAG=`cat ${FILE_LOCATION}${FS}JDK64BIT | grep -v '^#'` - fi ;; Windows_* ) NULL=NUL @@ -50,9 +42,9 @@ THIS_DIR=`pwd` -${TESTJAVA}${FS}bin${FS}java ${BIT_FLAG} -version +${TESTJAVA}${FS}bin${FS}java ${TESTVMOPTS} -version -${TESTJAVA}${FS}bin${FS}java ${BIT_FLAG} -server IsInstanceTest > test.out 2>&1 +${TESTJAVA}${FS}bin${FS}java ${TESTVMOPTS} IsInstanceTest > test.out 2>&1 cat test.out diff -r e2961d14584b -r 7089278210e2 test/gc/6941923/test6941923.sh --- a/test/gc/6941923/test6941923.sh Mon May 21 09:46:02 2012 +0200 +++ b/test/gc/6941923/test6941923.sh Thu May 24 18:39:44 2012 -0700 @@ -30,7 +30,7 @@ exit 0 fi -$JAVA_HOME/bin/java -version > $NULL 2>&1 +$JAVA_HOME/bin/java ${TESTVMOPTS} -version > $NULL 2>&1 if [ $? != 0 ]; then echo "Wrong JAVA_HOME? JAVA_HOME: $JAVA_HOME" @@ -119,7 +119,7 @@ options="-Xloggc:$logfile -XX:+UseConcMarkSweepGC -XX:+PrintGC -XX:+PrintGCDetails -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=1 -XX:GCLogFileSize=$gclogsize" echo "Test gc log rotation in same file, wait for $tts minutes ...." -$JAVA_HOME/bin/java $options $testname $tts +$JAVA_HOME/bin/java ${TESTVMOPTS} $options $testname $tts if [ $? != 0 ]; then echo "$msgfail" exit -1 @@ -148,7 +148,7 @@ numoffiles=3 options="-Xloggc:$logfile -XX:+UseConcMarkSweepGC -XX:+PrintGC -XX:+PrintGCDetails -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=$numoffiles -XX:GCLogFileSize=$gclogsize" echo "Test gc log rotation in $numoffiles files, wait for $tts minutes ...." -$JAVA_HOME/bin/java $options $testname $tts +$JAVA_HOME/bin/java ${TESTVMOPTS} $options $testname $tts if [ $? != 0 ]; then echo "$msgfail" exit -1 diff -r e2961d14584b -r 7089278210e2 test/runtime/6626217/Test6626217.sh --- a/test/runtime/6626217/Test6626217.sh Mon May 21 09:46:02 2012 +0200 +++ b/test/runtime/6626217/Test6626217.sh Thu May 24 18:39:44 2012 -0700 @@ -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 @@ -46,8 +46,6 @@ exit 1 fi -BIT_FLAG="" - # set platform-dependent variables OS=`uname -s` case "$OS" in @@ -58,12 +56,6 @@ RM=/bin/rm CP=/bin/cp MV=/bin/mv - ## for solaris, linux it's HOME - FILE_LOCATION=$HOME - if [ -f ${FILE_LOCATION}${FS}JDK64BIT -a ${OS} = "SunOS" ] - then - BIT_FLAG=`cat ${FILE_LOCATION}${FS}JDK64BIT` - fi ;; Windows_* ) NULL=NUL @@ -87,7 +79,7 @@ JAVA=${TESTJAVA}${FS}bin${FS}java JAVAC=${TESTJAVA}${FS}bin${FS}javac -${JAVA} ${BIT_FLAG} -version +${JAVA} ${TESTVMOPTS} -version # Current directory is scratch directory, copy all the test source there # (for the subsequent moves to work). @@ -113,7 +105,7 @@ ${MV} many_loader.impl1 many_loader.class ${RM} many_loader.java -${JAVA} ${BIT_FLAG} -Xverify -Xint -cp . bug_21227 >test.out 2>&1 +${JAVA} ${TESTVMOPTS} -Xverify -Xint -cp . bug_21227 >test.out 2>&1 grep "loader constraint" test.out exit $? diff -r e2961d14584b -r 7089278210e2 test/runtime/6878713/Test6878713.sh --- a/test/runtime/6878713/Test6878713.sh Mon May 21 09:46:02 2012 +0200 +++ b/test/runtime/6878713/Test6878713.sh Thu May 24 18:39:44 2012 -0700 @@ -25,8 +25,6 @@ exit 1 fi -BIT_FLAG="" - # set platform-dependent variables OS=`uname -s` case "$OS" in @@ -34,12 +32,6 @@ NULL=/dev/null PS=":" FS="/" - ## for solaris, linux it's HOME - FILE_LOCATION=$HOME - if [ -f ${FILE_LOCATION}${FS}JDK64BIT -a ${OS} = "SunOS" ] - then - BIT_FLAG=`cat ${FILE_LOCATION}${FS}JDK64BIT | grep -v '^#'` - fi ;; Windows_* ) NULL=NUL @@ -57,11 +49,11 @@ THIS_DIR=`pwd` -${TESTJAVA}${FS}bin${FS}java ${BIT_FLAG} -version +${TESTJAVA}${FS}bin${FS}java ${TESTVMOPTS} -version ${TESTJAVA}${FS}bin${FS}jar xvf ${TESTSRC}${FS}testcase.jar -${TESTJAVA}${FS}bin${FS}java ${BIT_FLAG} OOMCrashClass1960_2 > test.out 2>&1 +${TESTJAVA}${FS}bin${FS}java ${TESTVMOPTS} OOMCrashClass1960_2 > test.out 2>&1 if [ -s core -o -s "hs_*.log" ] then diff -r e2961d14584b -r 7089278210e2 test/runtime/6929067/Test6929067.sh --- a/test/runtime/6929067/Test6929067.sh Mon May 21 09:46:02 2012 +0200 +++ b/test/runtime/6929067/Test6929067.sh Thu May 24 18:39:44 2012 -0700 @@ -19,8 +19,6 @@ echo "If this is incorrect, try setting the variable manually." fi -BIT_FLAG="" - # set platform-dependent variables OS=`uname -s` case "$OS" in @@ -42,7 +40,19 @@ ;; esac -LD_LIBRARY_PATH=.:${TESTJAVA}/jre/lib/i386/client:/usr/openwin/lib:/usr/dt/lib:/usr/lib:$LD_LIBRARY_PATH +# Choose arch: i386 or amd64 (test is Linux-specific) +# Cannot simply look at TESTVMOPTS as -d64 is not +# passed if there is only a 64-bit JVM available. + +${TESTJAVA}/bin/java ${TESTVMOPTS} -version 2>1 | grep "64-Bit" >/dev/null +if [ "$?" = "0" ] +then + ARCH=amd64 +else + ARCH=i386 +fi + +LD_LIBRARY_PATH=.:${TESTJAVA}/jre/lib/${ARCH}/client:/usr/openwin/lib:/usr/dt/lib:/usr/lib:$LD_LIBRARY_PATH export LD_LIBRARY_PATH THIS_DIR=`pwd` @@ -51,10 +61,10 @@ cp ${TESTSRC}${FS}T.java ${THIS_DIR} -${TESTJAVA}${FS}bin${FS}java ${BIT_FLAG} -fullversion +${TESTJAVA}${FS}bin${FS}java ${TESTVMOPTS} -fullversion ${TESTJAVA}${FS}bin${FS}javac T.java -gcc -o invoke -I${TESTJAVA}/include -I${TESTJAVA}/include/linux invoke.c ${TESTJAVA}/jre/lib/i386/client/libjvm.so +gcc -o invoke -I${TESTJAVA}/include -I${TESTJAVA}/include/linux invoke.c ${TESTJAVA}/jre/lib/${ARCH}/client/libjvm.so ./invoke exit $? diff -r e2961d14584b -r 7089278210e2 test/runtime/7020373/Test7020373.sh --- a/test/runtime/7020373/Test7020373.sh Mon May 21 09:46:02 2012 +0200 +++ b/test/runtime/7020373/Test7020373.sh Thu May 24 18:39:44 2012 -0700 @@ -27,8 +27,6 @@ exit 1 fi -BIT_FLAG="" - # set platform-dependent variables OS=`uname -s` case "$OS" in @@ -36,12 +34,6 @@ NULL=/dev/null PS=":" FS="/" - ## for solaris, linux it's HOME - FILE_LOCATION=$HOME - if [ -f ${FILE_LOCATION}${FS}JDK64BIT -a ${OS} = "SunOS" ] - then - BIT_FLAG=`cat ${FILE_LOCATION}${FS}JDK64BIT | grep -v '^#'` - fi ;; Windows_* ) NULL=NUL @@ -59,11 +51,11 @@ THIS_DIR=`pwd` -${TESTJAVA}${FS}bin${FS}java ${BIT_FLAG} -version +${TESTJAVA}${FS}bin${FS}java ${TESTVMOPTS} -version ${TESTJAVA}${FS}bin${FS}jar xvf ${TESTSRC}${FS}testcase.jar -${TESTJAVA}${FS}bin${FS}java ${BIT_FLAG} OOMCrashClass4000_1 > test.out 2>&1 +${TESTJAVA}${FS}bin${FS}java ${TESTVMOPTS} OOMCrashClass4000_1 > test.out 2>&1 cat test.out diff -r e2961d14584b -r 7089278210e2 test/runtime/7051189/Xchecksig.sh --- a/test/runtime/7051189/Xchecksig.sh Mon May 21 09:46:02 2012 +0200 +++ b/test/runtime/7051189/Xchecksig.sh Thu May 24 18:39:44 2012 -0700 @@ -1,5 +1,5 @@ # -# Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2011, 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 @@ -41,18 +41,10 @@ fi -BIT_FLAG="" - OS=`uname -s` case "$OS" in SunOS | Linux ) FS="/" - ## for solaris, linux it's HOME - FILE_LOCATION=$HOME - if [ -f ${FILE_LOCATION}${FS}JDK64BIT -a ${OS} = "SunOS" ] - then - BIT_FLAG=`cat ${FILE_LOCATION}${FS}JDK64BIT` - fi ;; Windows_* ) printf "Not testing libjsig.so on Windows. PASSED.\n " @@ -69,20 +61,16 @@ # LD_PRELOAD arch needs to match the binary we run, so run the java # 64-bit binary directly if we are testing 64-bit (bin/ARCH/java). - -# However JPRT runs: .../solaris_x64_5.10-debug/bin/java -# ..which is 32-bit, when it has built the 64-bit version to test. -# -# How does this script know we are meant to run the 64-bit version? -# Can check for the path of the binary containing "x64" on Solaris. +# Check if TESTVMOPS contains -d64, but cannot use +# java ${TESTVMOPS} to run "java -d64" with LD_PRELOAD. if [ ${OS} -eq "SunOS" ] then - printf "SunOS test JAVA=${JAVA}" - printf ${JAVA} | grep x64 > /dev/null + printf "SunOS test TESTVMOPTS = ${TESTVMOPTS}" + printf ${TESTVMOPTS} | grep d64 > /dev/null if [ $? -eq 0 ] then - printf "SunOS x64 test, forcing -d64\n" + printf "SunOS 64-bit test\n" BIT_FLAG=-d64 fi fi @@ -127,20 +115,19 @@ printf "Skipping test: libjsig missing for given architecture: ${LIBJSIG}\n" exit 0 fi -# Use java -version to test, java version info appeas on stderr, +# Use java -version to test, java version info appears on stderr, # the libjsig message we are removing appears on stdout. # grep returns zero meaning found, non-zero means not found: -LD_PRELOAD=${LIBJSIG} ${JAVA} ${BIT_FLAG} -Xcheck:jni -version 2>&1 | grep "libjsig is activated" - +LD_PRELOAD=${LIBJSIG} ${JAVA} ${TESTVMOPTS} -Xcheck:jni -version 2>&1 | grep "libjsig is activated" if [ $? -eq 0 ]; then printf "Failed: -Xcheck:jni prints message when libjsig.so is loaded.\n" exit 1 fi -LD_PRELOAD=${LIBJSIG} ${JAVA} ${BIT_FLAG} -Xcheck:jni -verbose:jni -version 2>&1 | grep "libjsig is activated" +LD_PRELOAD=${LIBJSIG} ${JAVA} ${TESTVMOPTS} -Xcheck:jni -verbose:jni -version 2>&1 | grep "libjsig is activated" if [ $? != 0 ]; then printf "Failed: -Xcheck:jni does not print message when libjsig.so is loaded and -verbose:jni is set.\n" exit 1 diff -r e2961d14584b -r 7089278210e2 test/runtime/7158988/TestFieldMonitor.sh --- a/test/runtime/7158988/TestFieldMonitor.sh Mon May 21 09:46:02 2012 +0200 +++ b/test/runtime/7158988/TestFieldMonitor.sh Thu May 24 18:39:44 2012 -0700 @@ -18,8 +18,6 @@ exit 1 fi -BIT_FLAG="" - # set platform-dependent variables OS=`uname -s` case "$OS" in @@ -27,12 +25,6 @@ NULL=/dev/null PS=":" FS="/" - ## for solaris, linux it's HOME - FILE_LOCATION=$HOME - if [ -f ${FILE_LOCATION}${FS}JDK64BIT -a ${OS} = "SunOS" -a `uname -p`='sparc' ] - then - BIT_FLAG="-d64" - fi ;; Windows_95 | Windows_98 | Windows_ME ) NULL=NUL @@ -56,11 +48,11 @@ cp ${TESTSRC}${FS}*.java . -${TESTJAVA}${FS}bin${FS}java ${BIT_FLAG} -fullversion +${TESTJAVA}${FS}bin${FS}java ${TESTVMOPTS} -fullversion ${TESTJAVA}${FS}bin${FS}javac -classpath .${PS}$TESTJAVA${FS}lib${FS}tools.jar *.java -${TESTJAVA}${FS}bin${FS}java ${BIT_FLAG} -classpath .${PS}$TESTJAVA${FS}lib${FS}tools.jar FieldMonitor > test.out 2>&1 & +${TESTJAVA}${FS}bin${FS}java ${TESTVMOPTS} -classpath .${PS}$TESTJAVA${FS}lib${FS}tools.jar FieldMonitor > test.out 2>&1 & P_PID=$!