comparison src/share/vm/gc_interface/gcCause.hpp @ 6064:9d679effd28c

7166894: Add gc cause to GC logging for all collectors Reviewed-by: mgerdin, johnc
author brutisso
date Tue, 15 May 2012 10:25:06 +0200
parents 9509c20bba28
children da91efe96a93
comparison
equal deleted inserted replaced
6063:cdfa5139bd58 6064:9d679effd28c
86 86
87 // Return a string describing the GCCause. 87 // Return a string describing the GCCause.
88 static const char* to_string(GCCause::Cause cause); 88 static const char* to_string(GCCause::Cause cause);
89 }; 89 };
90 90
91 // Helper class for doing logging that includes the GC Cause
92 // as a string.
93 class GCCauseString : StackObj {
94 private:
95 static const int _length = 128;
96 char _buffer[_length];
97 int _position;
98
99 public:
100 GCCauseString(const char* prefix, GCCause::Cause cause) {
101 if (PrintGCCause) {
102 _position = jio_snprintf(_buffer, _length, "%s (%s)", prefix, GCCause::to_string(cause));
103 } else {
104 _position = jio_snprintf(_buffer, _length, "%s", prefix);
105 }
106 assert(_position >= 0 && _position <= _length,
107 err_msg("Need to increase the buffer size in GCCauseString? %d", _position));
108 }
109
110 GCCauseString& append(const char* str) {
111 int res = jio_snprintf(_buffer + _position, _length - _position, "%s", str);
112 _position += res;
113 assert(res >= 0 && _position <= _length,
114 err_msg("Need to increase the buffer size in GCCauseString? %d", res));
115 return *this;
116 }
117
118 operator const char*() {
119 return _buffer;
120 }
121 };
122
91 #endif // SHARE_VM_GC_INTERFACE_GCCAUSE_HPP 123 #endif // SHARE_VM_GC_INTERFACE_GCCAUSE_HPP