src/share/vm/gc_interface/gcCause.hpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File
*** old/src/share/vm/gc_interface/gcCause.hpp	Tue May  8 16:12:34 2012
--- new/src/share/vm/gc_interface/gcCause.hpp	Tue May  8 16:12:32 2012

*** 86,91 **** --- 86,122 ---- // Return a string describing the GCCause. 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) { + position += jio_snprintf(buffer + position, length - position, "%", str); + assert(position > 0 && position <= length, + err_msg("Need to increase the buffer size in GCCauseString? %d", position)); + return *this; + } + + operator const char*() { + return buffer; + } + }; + #endif // SHARE_VM_GC_INTERFACE_GCCAUSE_HPP

src/share/vm/gc_interface/gcCause.hpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File