# HG changeset patch # User ehelin # Date 1395236138 -3600 # Wed Mar 19 14:35:38 2014 +0100 # Node ID 09d060ff4739362b40830926b9f92491da619b12 # Parent 6bd5c687f11af402307c27fbdec064d980f56a05 8033580: Old debug information in IMPORT_JDK is not removed diff --git a/make/Makefile b/make/Makefile --- a/make/Makefile +++ b/make/Makefile @@ -282,18 +282,53 @@ ifeq ($(JVM_VARIANT_MINIMAL1),true) endif else @$(ECHO) "No ($(VM_TARGET)) for $(OSNAME) ARCH_DATA_MODEL=$(ARCH_DATA_MODEL)" endif else @$(ECHO) "Error: trying to build a minimal target but JVM_VARIANT_MINIMAL1 is not true." endif +remove_old_debuginfo: +ifeq ($(JVM_VARIANT_CLIENT), true) + ifeq ($(ZIP_DEBUGINFO_FILES),1) + ifeq ($(OSNAME), windows) + $(RM) -f $(EXPORT_CLIENT_DIR)/jvm.map $(EXPORT_CLIENT_DIR)/jvm.pdb + else + $(RM) -f $(EXPORT_CLIENT_DIR)/libjvm.debuginfo + endif + else + $(RM) -f $(EXPORT_CLIENT_DIR)/libjvm.diz + endif +endif +ifeq ($(findstring true, $(JVM_VARIANT_SERVER) $(JVM_VARIANT_ZERO) $(JVM_VARIANT_ZEROSHARK)), true) + ifeq ($(ZIP_DEBUGINFO_FILES),1) + ifeq ($(OSNAME), windows) + $(RM) -f $(EXPORT_SERVER_DIR)/jvm.map $(EXPORT_SERVER_DIR)/jvm.pdb + else + ifeq ($(OS_VENDOR), Darwin) + $(RM) -rf $(EXPORT_SERVER_DIR)/libjvm.dylib.dSYM + else + $(RM) -f $(EXPORT_SERVER_DIR)/libjvm.debuginfo + endif + endif + else + $(RM) -f $(EXPORT_SERVER_DIR)/libjvm.diz + endif +endif +ifeq ($(JVM_VARIANT_MINIMAL1),true) + ifeq ($(ZIP_DEBUGINFO_FILES),1) + $(RM) -f $(EXPORT_MINIMAL_DIR)/libjvm.debuginfo + else + $(RM) -f $(EXPORT_MINIMAL_DIR)/libjvm.diz + endif +endif + # Export file rule -generic_export: $(EXPORT_LIST) +generic_export: $(EXPORT_LIST) remove_old_debuginfo export_product: $(MAKE) BUILD_FLAVOR=$(@:export_%=%) generic_export export_fastdebug: $(MAKE) BUILD_FLAVOR=$(@:export_%=%) EXPORT_SUBDIR=/$(@:export_%=%) generic_export export_debug: $(MAKE) BUILD_FLAVOR=$(@:export_%=%) EXPORT_SUBDIR=/$(@:export_%=%) generic_export export_optimized: @@ -836,9 +871,9 @@ include $(GAMMADIR)/make/jprt.gmk .PHONY: all world clobber clean help $(C1_VM_TARGETS) $(C2_VM_TARGETS) \ $(MINIMAL1_VM_TARGETS) \ generic_build1 generic_build2 generic_buildminimal1 generic_export \ export_product export_fastdebug export_debug export_optimized \ export_jdk_product export_jdk_fastdebug export_jdk_debug \ create_jdk copy_jdk update_jdk test_jdk \ copy_product_jdk copy_fastdebug_jdk copy_debug_jdk \ - $(HS_ALT_MAKE)/Makefile.make + $(HS_ALT_MAKE)/Makefile.make remove_old_debuginfo # HG changeset patch # User ehelin # Date 1395236195 -3600 # Wed Mar 19 14:36:35 2014 +0100 # Node ID 7ec8e6f8b25eef01d907b72f60e2eedb0782a0a7 # Parent 09d060ff4739362b40830926b9f92491da619b12 8033251: Use DWARF debug symbols for Linux 32-bit diff --git a/make/linux/makefiles/gcc.make b/make/linux/makefiles/gcc.make --- a/make/linux/makefiles/gcc.make +++ b/make/linux/makefiles/gcc.make @@ -339,47 +339,50 @@ ifeq ($(DEBUG_BINARIES), true) else # Use the stabs format for debugging information (this is the default # on gcc-2.91). It's good enough, has all the information about line # numbers and local variables, and libjvm.so is only about 16M. # Change this back to "-g" if you want the most expressive format. # (warning: that could easily inflate libjvm.so to 150M!) # Note: The Itanium gcc compiler crashes when using -gstabs. DEBUG_CFLAGS/ia64 = -g + DEBUG_CFLAGS/i486 = -g DEBUG_CFLAGS/amd64 = -g DEBUG_CFLAGS/arm = -g DEBUG_CFLAGS/ppc = -g DEBUG_CFLAGS/ppc64 = -g DEBUG_CFLAGS += $(DEBUG_CFLAGS/$(BUILDARCH)) ifeq ($(DEBUG_CFLAGS/$(BUILDARCH)),) ifeq ($(USE_CLANG), true) # Clang doesn't understand -gstabs DEBUG_CFLAGS += -g else DEBUG_CFLAGS += -gstabs endif endif ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1) FASTDEBUG_CFLAGS/ia64 = -g + FASTDEBUG_CFLAGS/i486 = -g FASTDEBUG_CFLAGS/amd64 = -g FASTDEBUG_CFLAGS/arm = -g FASTDEBUG_CFLAGS/ppc = -g FASTDEBUG_CFLAGS/ppc64 = -g FASTDEBUG_CFLAGS += $(DEBUG_CFLAGS/$(BUILDARCH)) ifeq ($(FASTDEBUG_CFLAGS/$(BUILDARCH)),) ifeq ($(USE_CLANG), true) # Clang doesn't understand -gstabs FASTDEBUG_CFLAGS += -g else FASTDEBUG_CFLAGS += -gstabs endif endif OPT_CFLAGS/ia64 = -g + OPT_CFLAGS/i486 = -g OPT_CFLAGS/amd64 = -g OPT_CFLAGS/arm = -g OPT_CFLAGS/ppc = -g OPT_CFLAGS/ppc64 = -g OPT_CFLAGS += $(OPT_CFLAGS/$(BUILDARCH)) ifeq ($(OPT_CFLAGS/$(BUILDARCH)),) ifeq ($(USE_CLANG), true) # Clang doesn't understand -gstabs # HG changeset patch # User ehelin # Date 1395239382 -3600 # Wed Mar 19 15:29:42 2014 +0100 # Node ID d1e90449066693b29663726b68d2bc9f9e4b84dc # Parent 6bd5c687f11af402307c27fbdec064d980f56a05 8027915: TestParallelHeapSizeFlags fails with unexpected heap size on sparcv9 diff --git a/src/share/vm/runtime/os.cpp b/src/share/vm/runtime/os.cpp --- a/src/share/vm/runtime/os.cpp +++ b/src/share/vm/runtime/os.cpp @@ -1392,22 +1392,16 @@ size_t os::page_size_for_region(size_t r uint min_pages) { assert(min_pages > 0, "sanity"); if (UseLargePages) { const size_t max_page_size = region_max_size / min_pages; for (unsigned int i = 0; _page_sizes[i] != 0; ++i) { const size_t sz = _page_sizes[i]; - const size_t mask = sz - 1; - if ((region_min_size & mask) == 0 && (region_max_size & mask) == 0) { - // The largest page size with no fragmentation. - return sz; - } - if (sz <= max_page_size) { // The largest page size that satisfies the min_pages requirement. return sz; } } } return vm_page_size(); # HG changeset patch # User ehelin # Date 1395243948 -3600 # Wed Mar 19 16:45:48 2014 +0100 # Node ID aaffbb4d883c3582254c89d50a079e9f78c050fb # Parent 6bd5c687f11af402307c27fbdec064d980f56a05 fix solaris large pages off by one error diff --git a/src/os/solaris/vm/os_solaris.cpp b/src/os/solaris/vm/os_solaris.cpp --- a/src/os/solaris/vm/os_solaris.cpp +++ b/src/os/solaris/vm/os_solaris.cpp @@ -3292,17 +3292,17 @@ bool os::Solaris::mpss_sanity_check(bool // // A better policy could get rid of the 4M limit by taking the sizes of the // important VM memory regions (java heap and possibly the code cache) into // account. insertion_sort_descending(_page_sizes, n); const size_t size_limit = FLAG_IS_DEFAULT(LargePageSizeInBytes) ? 4 * M : LargePageSizeInBytes; int beg; - for (beg = 0; beg < n && _page_sizes[beg] > size_limit; ++beg) /* empty */ ; + for (beg = 0; beg < n && _page_sizes[beg] >= size_limit; ++beg) /* empty */ ; const int end = MIN2((int)usable_count, n) - 1; for (int cur = 0; cur < end; ++cur, ++beg) { _page_sizes[cur] = _page_sizes[beg]; } _page_sizes[end] = vm_page_size(); _page_sizes[end + 1] = 0; if (_page_sizes[end] > _page_sizes[end - 1]) { # HG changeset patch # User ehelin # Date 1395244969 -3600 # Wed Mar 19 17:02:49 2014 +0100 # Node ID c63f59bea9d4932fac34ab79d3d9094122fce3bb # Parent 6bd5c687f11af402307c27fbdec064d980f56a05 8034094: SA agent can't compile when jni_x86.h is used diff --git a/make/bsd/makefiles/saproc.make b/make/bsd/makefiles/saproc.make --- a/make/bsd/makefiles/saproc.make +++ b/make/bsd/makefiles/saproc.make @@ -110,17 +110,17 @@ else endif $(LIBSAPROC): $(SASRCFILES) $(SAMAPFILE) $(QUIETLY) if [ "$(BOOT_JAVA_HOME)" = "" ]; then \ echo "ALT_BOOTDIR, BOOTDIR or JAVA_HOME needs to be defined to build SA"; \ exit 1; \ fi @echo Making SA debugger back-end... - $(QUIETLY) $(CC) -D$(BUILDARCH) -D_GNU_SOURCE \ + $(QUIETLY) $(CC) -D$(BUILDARCH) -D_GNU_SOURCE -D_ALLBSD_SOURCE \ $(SYMFLAG) $(SAARCH) $(SHARED_FLAG) $(PICFLAG) \ -I$(SASRCDIR) \ -I$(GENERATED) \ $(BOOT_JAVA_INCLUDES) \ $(SASRCFILES) \ $(SA_LFLAGS) \ $(SA_DEBUG_CFLAGS) \ -o $@ \ diff --git a/make/linux/makefiles/saproc.make b/make/linux/makefiles/saproc.make --- a/make/linux/makefiles/saproc.make +++ b/make/linux/makefiles/saproc.make @@ -76,17 +76,17 @@ endif SA_LFLAGS = $(MAPFLAG:FILENAME=$(SAMAPFILE)) $(LDFLAGS_HASH_STYLE) $(LIBSAPROC): $(SASRCFILES) $(SAMAPFILE) $(QUIETLY) if [ "$(BOOT_JAVA_HOME)" = "" ]; then \ echo "ALT_BOOTDIR, BOOTDIR or JAVA_HOME needs to be defined to build SA"; \ exit 1; \ fi @echo Making SA debugger back-end... - $(QUIETLY) $(CC) -D$(BUILDARCH) -D_GNU_SOURCE \ + $(QUIETLY) $(CC) -D$(BUILDARCH) -D_GNU_SOURCE -DLINUX \ -D_FILE_OFFSET_BITS=64 \ $(SYMFLAG) $(ARCHFLAG) $(SHARED_FLAG) $(PICFLAG) \ -I$(SASRCDIR) \ -I$(GENERATED) \ -I$(BOOT_JAVA_HOME)/include \ -I$(BOOT_JAVA_HOME)/include/$(Platform_os_family) \ $(ALT_SAINCDIR) \ $(SASRCFILES) \ diff --git a/make/solaris/makefiles/saproc.make b/make/solaris/makefiles/saproc.make --- a/make/solaris/makefiles/saproc.make +++ b/make/solaris/makefiles/saproc.make @@ -93,30 +93,32 @@ SOLARIS_11_B159_OR_LATER := \ $(LIBSAPROC): $(ADD_GNU_DEBUGLINK) $(FIX_EMPTY_SEC_HDR_FLAGS) $(SASRCFILES) $(SADISOBJ) $(SAMAPFILE) $(QUIETLY) if [ "$(BOOT_JAVA_HOME)" = "" ]; then \ echo "ALT_BOOTDIR, BOOTDIR or JAVA_HOME needs to be defined to build SA"; \ exit 1; \ fi @echo Making SA debugger back-end... $(QUIETLY) $(CXX) \ $(SYMFLAG) $(ARCHFLAG) $(SHARED_FLAG) $(PICFLAG) \ + -DSOLARIS \ -I$(SASRCDIR) \ -I$(GENERATED) \ -I$(BOOT_JAVA_HOME)/include \ -I$(BOOT_JAVA_HOME)/include/$(Platform_os_family) \ $(SOLARIS_11_B159_OR_LATER) \ $(SASRCFILES) \ $(SADISOBJ) \ $(SA_LFLAGS) \ -o $@ \ -ldl -ldemangle -lthread -lc $(SADISOBJ): $(SADISSRCFILES) $(QUIETLY) $(CC) \ $(SYMFLAG) $(ARCHFLAG) $(SHARED_FLAG) $(PICFLAG) \ + -DSOLARIS \ -I$(SASRCDIR) \ -I$(GENERATED) \ -I$(BOOT_JAVA_HOME)/include \ -I$(BOOT_JAVA_HOME)/include/$(Platform_os_family) \ $(SOLARIS_11_B159_OR_LATER) \ $(SADISSRCFILES) \ -c -o $(SADISOBJ) # HG changeset patch # User ehelin # Date 1395245068 -3600 # Wed Mar 19 17:04:28 2014 +0100 # Node ID b507edf14f79a756f2ecc62ba9f19f74ae526974 # Parent 6bd5c687f11af402307c27fbdec064d980f56a05 8034094: SA agent can't compile when jni_x86.h is used diff --git a/src/cpu/x86/vm/jni_x86.h b/src/cpu/x86/vm/jni_x86.h --- a/src/cpu/x86/vm/jni_x86.h +++ b/src/cpu/x86/vm/jni_x86.h @@ -21,18 +21,24 @@ * 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 _JAVASOFT_JNI_MD_H_ #define _JAVASOFT_JNI_MD_H_ -#if defined(SOLARIS) || defined(LINUX) || defined(_ALLBSD_SOURCE) +#if defined(_WIN32) + #define JNIEXPORT __declspec(dllexport) + #define JNIIMPORT __declspec(dllimport) + #define JNICALL __stdcall + typedef int jint; + typedef __int64 jlong; +#else // Note: please do not change these without also changing jni_md.h in the JDK // repository #ifndef __has_attribute #define __has_attribute(x) 0 #endif #if (defined(__GNUC__) && ((__GNUC__ > 4) || (__GNUC__ == 4) && (__GNUC_MINOR__ > 2))) || __has_attribute(visibility) #define JNIEXPORT __attribute__((visibility("default"))) @@ -45,20 +51,13 @@ #define JNICALL typedef int jint; #if defined(_LP64) typedef long jlong; #else typedef long long jlong; #endif -#else - #define JNIEXPORT __declspec(dllexport) - #define JNIIMPORT __declspec(dllimport) - #define JNICALL __stdcall - - typedef int jint; - typedef __int64 jlong; #endif typedef signed char jbyte; #endif /* !_JAVASOFT_JNI_MD_H_ */ # HG changeset patch # User ehelin # Date 1395245179 -3600 # Wed Mar 19 17:06:19 2014 +0100 # Node ID ee58daed16302674d2a31c24069e634ac4a3247d # Parent 6bd5c687f11af402307c27fbdec064d980f56a05 8036702: Refactor os::safe_for_sender to work with non-Java threads diff --git a/src/cpu/ppc/vm/frame_ppc.cpp b/src/cpu/ppc/vm/frame_ppc.cpp --- a/src/cpu/ppc/vm/frame_ppc.cpp +++ b/src/cpu/ppc/vm/frame_ppc.cpp @@ -42,17 +42,17 @@ #include "runtime/vframeArray.hpp" #endif #ifdef ASSERT void RegisterMap::check_location_valid() { } #endif // ASSERT -bool frame::safe_for_sender(JavaThread *thread) { +bool frame::safe_for_sender(Thread *thread) { bool safe = false; address cursp = (address)sp(); address curfp = (address)fp(); if ((cursp != NULL && curfp != NULL && (cursp <= thread->stack_base() && cursp >= thread->stack_base() - thread->stack_size())) && (curfp <= thread->stack_base() && curfp >= thread->stack_base() - thread->stack_size())) { safe = true; } @@ -159,17 +159,17 @@ void frame::pd_gc_epilog() { if (is_interpreted_frame()) { // Set constant pool cache entry for interpreter. Method* m = interpreter_frame_method(); *interpreter_frame_cpoolcache_addr() = m->constants()->cache(); } } -bool frame::is_interpreted_frame_valid(JavaThread* thread) const { +bool frame::is_interpreted_frame_valid(Thread* thread) const { // Is there anything to do? assert(is_interpreted_frame(), "Not an interpreted frame"); return true; } BasicType frame::interpreter_frame_result(oop* oop_result, jvalue* value_result) { assert(is_interpreted_frame(), "interpreted frame expected"); Method* method = interpreter_frame_method(); diff --git a/src/cpu/sparc/vm/frame_sparc.cpp b/src/cpu/sparc/vm/frame_sparc.cpp --- a/src/cpu/sparc/vm/frame_sparc.cpp +++ b/src/cpu/sparc/vm/frame_sparc.cpp @@ -169,17 +169,17 @@ void RegisterMap::shift_individual_regis } } } _location_valid[0] = lv; check_location_valid(); } -bool frame::safe_for_sender(JavaThread *thread) { +bool frame::safe_for_sender(Thread *thread) { address _SP = (address) sp(); address _FP = (address) fp(); address _UNEXTENDED_SP = (address) unextended_sp(); // sp must be within the stack bool sp_safe = (_SP <= thread->stack_base()) && (_SP >= thread->stack_base() - thread->stack_size()); @@ -624,17 +624,17 @@ void frame::pd_gc_epilog() { // set constant pool cache entry for interpreter Method* m = interpreter_frame_method(); *interpreter_frame_cpoolcache_addr() = m->constants()->cache(); } } -bool frame::is_interpreted_frame_valid(JavaThread* thread) const { +bool frame::is_interpreted_frame_valid(Thread* thread) const { #ifdef CC_INTERP // Is there anything to do? #else assert(is_interpreted_frame(), "Not an interpreted frame"); // These are reasonable sanity checks if (fp() == 0 || (intptr_t(fp()) & (2*wordSize-1)) != 0) { return false; } diff --git a/src/cpu/x86/vm/frame_x86.cpp b/src/cpu/x86/vm/frame_x86.cpp --- a/src/cpu/x86/vm/frame_x86.cpp +++ b/src/cpu/x86/vm/frame_x86.cpp @@ -46,17 +46,17 @@ #ifdef ASSERT void RegisterMap::check_location_valid() { } #endif // Profiling/safepoint support -bool frame::safe_for_sender(JavaThread *thread) { +bool frame::safe_for_sender(Thread *thread) { address sp = (address)_sp; address fp = (address)_fp; address unextended_sp = (address)_unextended_sp; // consider stack guards when trying to determine "safe" stack pointers static size_t stack_guard_size = os::uses_stack_guard_pages() ? (StackYellowPages + StackRedPages) * os::vm_page_size() : 0; size_t usable_stack_size = thread->stack_size() - stack_guard_size; @@ -535,17 +535,17 @@ bool frame::interpreter_frame_equals_unp Interpreter::stackElementWords; return _fp == (fp - diff); } void frame::pd_gc_epilog() { // nothing done here now } -bool frame::is_interpreted_frame_valid(JavaThread* thread) const { +bool frame::is_interpreted_frame_valid(Thread* thread) const { // QQQ #ifdef CC_INTERP #else assert(is_interpreted_frame(), "Not an interpreted frame"); // These are reasonable sanity checks if (fp() == 0 || (intptr_t(fp()) & (wordSize-1)) != 0) { return false; } diff --git a/src/cpu/zero/vm/frame_zero.cpp b/src/cpu/zero/vm/frame_zero.cpp --- a/src/cpu/zero/vm/frame_zero.cpp +++ b/src/cpu/zero/vm/frame_zero.cpp @@ -109,25 +109,25 @@ void frame::patch_pc(Thread* thread, add } else { // We borrow this call to set the thread pointer in the interpreter // state; the hook to set up deoptimized frames isn't supplied it. assert(pc == NULL, "should be"); get_interpreterState()->set_thread((JavaThread *) thread); } } -bool frame::safe_for_sender(JavaThread *thread) { +bool frame::safe_for_sender(Thread *thread) { ShouldNotCallThis(); return false; } void frame::pd_gc_epilog() { } -bool frame::is_interpreted_frame_valid(JavaThread *thread) const { +bool frame::is_interpreted_frame_valid(Thread *thread) const { ShouldNotCallThis(); return false; } BasicType frame::interpreter_frame_result(oop* oop_result, jvalue* value_result) { assert(is_interpreted_frame(), "interpreted frame expected"); Method* method = interpreter_frame_method(); diff --git a/src/share/vm/runtime/frame.hpp b/src/share/vm/runtime/frame.hpp --- a/src/share/vm/runtime/frame.hpp +++ b/src/share/vm/runtime/frame.hpp @@ -144,34 +144,34 @@ class frame VALUE_OBJ_CLASS_SPEC { bool is_compiled_frame() const; bool is_safepoint_blob_frame() const; bool is_deoptimized_frame() const; // testers bool is_first_frame() const; // oldest frame? (has no sender) bool is_first_java_frame() const; // same for Java frame - bool is_interpreted_frame_valid(JavaThread* thread) const; // performs sanity checks on interpreted frames. + bool is_interpreted_frame_valid(Thread* thread) const; // performs sanity checks on interpreted frames. // tells whether this frame is marked for deoptimization bool should_be_deoptimized() const; // tells whether this frame can be deoptimized bool can_be_deoptimized() const; // returns the frame size in stack slots int frame_size(RegisterMap* map) const; // returns the sending frame frame sender(RegisterMap* map) const; // for Profiling - acting on another frame. walks sender frames // if valid. frame profile_find_Java_sender_frame(JavaThread *thread); - bool safe_for_sender(JavaThread *thread); + bool safe_for_sender(Thread *thread); // returns the sender, but skips conversion frames frame real_sender(RegisterMap* map) const; // returns the the sending Java frame, skipping any intermediate C frames // NB: receiver must not be first frame frame java_sender() const; # HG changeset patch # User ehelin # Date 1395245528 -3600 # Wed Mar 19 17:12:08 2014 +0100 # Node ID b908ca62664b9f46b36d5d2f46d32c1947a77873 # Parent ee58daed16302674d2a31c24069e634ac4a3247d XXX: Add native stack trace to metaspace events diff --git a/src/share/vm/memory/metaspaceTracer.cpp b/src/share/vm/memory/metaspaceTracer.cpp --- a/src/share/vm/memory/metaspaceTracer.cpp +++ b/src/share/vm/memory/metaspaceTracer.cpp @@ -20,31 +20,75 @@ * or visit www.oracle.com if you need additional information or have any * questions. * */ #include "precompiled.hpp" #include "classfile/classLoaderData.hpp" #include "memory/metaspaceTracer.hpp" +#include "runtime/frame.hpp" +#include "runtime/os.hpp" +#include "runtime/thread.inline.hpp" #include "trace/tracing.hpp" #include "trace/traceBackend.hpp" +#include "utilities/decoder.hpp" +#include "utilities/ostream.hpp" void MetaspaceTracer::report_gc_threshold(size_t old_val, size_t new_val, MetaspaceGCThresholdUpdater::Type updater) const { EventMetaspaceGCThreshold event; if (event.should_commit()) { event.set_oldValue(old_val); event.set_newValue(new_val); event.set_updater((u1)updater); event.commit(); } } +static bool get_method_name(address pc, char *buf, size_t buflen) { + if (os::address_is_in_vm(pc) && Decoder::can_decode_C_frame_in_vm()) { + return os::dll_address_to_function_name(pc, buf, (int) buflen, 0); + } + return false; +} + +static bool is_valid_frame_in_vm(const frame* f) { + return f->pc() && os::address_is_in_vm(f->pc()) && !f->is_java_frame(); +} + +static void write_vm_stack_trace(outputStream *stream) { + const size_t max_num_frames = 64; + size_t num_frames = 0; + + const size_t buflen = 256; + char *buf = NEW_RESOURCE_ARRAY(char, buflen); + + Thread* current_thread = Thread::current(); + frame fr = os::current_frame(); + while (is_valid_frame_in_vm(&fr) && num_frames < max_num_frames) { + if (get_method_name(fr.pc(), buf, buflen)) { + stream->print_cr("%s", buf); + } else { + stream->print_cr(PTR_FORMAT, fr.pc()); + } + + // Check if it safe to get the caller's stack frame. + if (fr.safe_for_sender(current_thread)) { + fr = os::get_sender_for_C_frame(&fr); + } else { + // Not safe to traverse the stack any further. + return; + } + + num_frames++; + } +} + void MetaspaceTracer::report_metaspace_allocation_failure(ClassLoaderData *cld, size_t word_size, MetaspaceObj::Type objtype, Metaspace::MetadataType mdtype) const { send_allocation_failure_event(cld, word_size, objtype, mdtype); } void MetaspaceTracer::report_metadata_oom(ClassLoaderData *cld, @@ -68,14 +112,24 @@ void MetaspaceTracer::send_allocation_fa if (cld->is_the_null_class_loader_data()) { event.set_classLoader((Klass*) NULL); } else { event.set_classLoader(cld->class_loader()->klass()); } event.set_anonymousClassLoader(false); } +#ifdef _WINDOWS + // Can not walk the stack on Windows using the frame pointer. + event.set_nativeStackTrace(NULL); +#else + ResourceMark rm; + stringStream stack_trace; + write_vm_stack_trace(&stack_trace); + event.set_nativeStackTrace(stack_trace.as_string()); +#endif + event.set_size(word_size * BytesPerWord); event.set_metadataType((u1) mdtype); event.set_metaspaceObjectType((u1) objtype); event.commit(); } } diff --git a/src/share/vm/trace/trace.xml b/src/share/vm/trace/trace.xml --- a/src/share/vm/trace/trace.xml +++ b/src/share/vm/trace/trace.xml @@ -204,24 +204,26 @@ Declares a structure type that can be us + + # HG changeset patch # User ehelin # Date 1395327197 -3600 # Thu Mar 20 15:53:17 2014 +0100 # Node ID ebcbd40ddcd3d62399c94df601ce03eecac29ff0 # Parent 6bd5c687f11af402307c27fbdec064d980f56a05 8037962: metaspaceTracer.cpp misses a symbol diff --git a/src/share/vm/memory/metaspaceTracer.cpp b/src/share/vm/memory/metaspaceTracer.cpp --- a/src/share/vm/memory/metaspaceTracer.cpp +++ b/src/share/vm/memory/metaspaceTracer.cpp @@ -20,16 +20,17 @@ * or visit www.oracle.com if you need additional information or have any * questions. * */ #include "precompiled.hpp" #include "classfile/classLoaderData.hpp" #include "memory/metaspaceTracer.hpp" +#include "oops/oop.inline.hpp" #include "trace/tracing.hpp" #include "trace/traceBackend.hpp" void MetaspaceTracer::report_gc_threshold(size_t old_val, size_t new_val, MetaspaceGCThresholdUpdater::Type updater) const { EventMetaspaceGCThreshold event; if (event.should_commit()) {