--- old/src/share/vm/prims/stackwalk.cpp 2016-09-27 15:18:45.803175992 -0400 +++ new/src/share/vm/prims/stackwalk.cpp 2016-09-27 15:18:44.951176022 -0400 @@ -26,6 +26,7 @@ #include "classfile/javaClasses.hpp" #include "classfile/javaClasses.inline.hpp" #include "classfile/vmSymbols.hpp" +#include "logging/log.hpp" #include "memory/oopFactory.hpp" #include "oops/oop.inline.hpp" #include "oops/objArrayOop.inline.hpp" @@ -105,10 +106,8 @@ int max_nframes, int start_index, objArrayHandle frames_array, int& end_index, TRAPS) { - if (TraceStackWalk) { - tty->print_cr("fill_in_frames limit=%d start=%d frames length=%d", - max_nframes, start_index, frames_array->length()); - } + log_trace(stackwalk)("fill_in_frames limit=%d start=%d frames length=%d", + max_nframes, start_index, frames_array->length()); assert(max_nframes > 0, "invalid max_nframes"); assert(start_index + max_nframes <= frames_array->length(), "oob"); @@ -122,18 +121,24 @@ // not set) and when StackWalker::getCallerClass is called if (!ShowHiddenFrames && (skip_hidden_frames(mode) || get_caller_class(mode))) { if (method->is_hidden()) { - if (TraceStackWalk) { - tty->print(" hidden method: "); method->print_short_name(); - tty->print("\n"); + { + ResourceMark rm; + outputStream* st = Log(stackwalk)::trace_stream(); + st->print(" hidden method: "); + method->print_short_name(st); + st->cr(); } continue; } } int index = end_index++; - if (TraceStackWalk) { - tty->print(" %d: frame method: ", index); method->print_short_name(); - tty->print_cr(" bci=%d", stream.bci()); + { + ResourceMark rm; + outputStream* st = Log(stackwalk)::trace_stream(); + st->print(" %d: frame method: ", index); + method->print_short_name(st); + st->print_cr(" bci=%d", stream.bci()); } if (!need_method_info(mode) && get_caller_class(mode) && @@ -317,10 +322,8 @@ TRAPS) { ResourceMark rm(THREAD); JavaThread* jt = (JavaThread*)THREAD; - if (TraceStackWalk) { - tty->print_cr("Start walking: mode " JLONG_FORMAT " skip %d frames batch size %d", - mode, skip_frames, frame_count); - } + log_trace(stackwalk)("Start walking: mode " JLONG_FORMAT " skip %d frames batch size %d", + mode, skip_frames, frame_count); if (frames_array.is_null()) { THROW_MSG_(vmSymbols::java_lang_NullPointerException(), "frames_array is NULL", NULL); @@ -355,8 +358,12 @@ break; } - if (TraceStackWalk) { - tty->print(" skip "); stream.method()->print_short_name(); tty->print("\n"); + { + ResourceMark rm; + outputStream* st = Log(stackwalk)::trace_stream(); + st->print(" skip "); + stream.method()->print_short_name(st); + st->cr(); } stream.next(); } @@ -364,9 +371,11 @@ // stack frame has been traversed individually and resume stack walk // from the stack frame at depth == skip_frames. for (int n=0; n < skip_frames && !stream.at_end(); stream.next(), n++) { - if (TraceStackWalk) { - tty->print(" skip "); stream.method()->print_short_name(); tty->cr(); - } + ResourceMark rm; + outputStream* st = Log(stackwalk)::trace_stream(); + st->print(" skip "); + stream.method()->print_short_name(st); + tty->cr(); } } @@ -438,10 +447,12 @@ THROW_MSG_(vmSymbols::java_lang_NullPointerException(), "frames_array is NULL", 0L); } - if (TraceStackWalk) { - tty->print_cr("StackWalk::fetchNextBatch frame_count %d existing_stream " PTR_FORMAT " start %d frames %d", - frame_count, p2i(existing_stream), start_index, frames_array->length()); - } + log_trace(stackwalk)("StackWalk::fetchNextBatch frame_count %d existing_stream " + PTR_FORMAT " start %d frames %d", + frame_count, + p2i(existing_stream), + start_index, + frames_array->length()); int end_index = start_index; if (frame_count <= 0) { return end_index; // No operation.