< prev index next >
src/hotspot/share/utilities/events.hpp
Print this page
*** 133,173 ****
print(out, e.data);
}
};
// A simple wrapper class for fixed size text messages.
! class StringLogMessage : public FormatBuffer<256> {
public:
// Wrap this buffer in a stringStream.
stringStream stream() {
! return stringStream(_buf, size());
}
};
// A simple ring buffer of fixed size text messages.
! class StringEventLog : public EventLogBase<StringLogMessage> {
public:
! StringEventLog(const char* name, int count = LogEventsBufferEntries) : EventLogBase<StringLogMessage>(name, count) {}
void logv(Thread* thread, const char* format, va_list ap) ATTRIBUTE_PRINTF(3, 0) {
! if (!should_log()) return;
! double timestamp = fetch_timestamp();
! MutexLockerEx ml(&_mutex, Mutex::_no_safepoint_check_flag);
! int index = compute_log_index();
! _records[index].thread = thread;
! _records[index].timestamp = timestamp;
! _records[index].data.printv(format, ap);
}
void log(Thread* thread, const char* format, ...) ATTRIBUTE_PRINTF(3, 4) {
va_list ap;
va_start(ap, format);
! logv(thread, format, ap);
va_end(ap);
}
};
class InstanceKlass;
// Event log for class unloading events to materialize the class name in place in the log stream.
class UnloadingEventLog : public EventLogBase<StringLogMessage> {
--- 133,179 ----
print(out, e.data);
}
};
// A simple wrapper class for fixed size text messages.
! template <size_t bufsz>
! class TemplatedStringLogMessage : public FormatBuffer<bufsz> {
public:
// Wrap this buffer in a stringStream.
stringStream stream() {
! return stringStream(this->_buf, this->size());
}
};
+ typedef TemplatedStringLogMessage<256> StringLogMessage;
+ typedef TemplatedStringLogMessage<512> ExtendedStringLogMessage;
// A simple ring buffer of fixed size text messages.
! template <size_t bufsz>
! class TemplatedStringEventLog : public EventLogBase< TemplatedStringLogMessage<bufsz> > {
public:
! TemplatedStringEventLog(const char* name, int count = LogEventsBufferEntries) : EventLogBase< TemplatedStringLogMessage<bufsz> >(name, count) {}
void logv(Thread* thread, const char* format, va_list ap) ATTRIBUTE_PRINTF(3, 0) {
! if (!this->should_log()) return;
! double timestamp = this->fetch_timestamp();
! MutexLockerEx ml(&this->_mutex, Mutex::_no_safepoint_check_flag);
! int index = this->compute_log_index();
! this->_records[index].thread = thread;
! this->_records[index].timestamp = timestamp;
! this->_records[index].data.printv(format, ap);
}
void log(Thread* thread, const char* format, ...) ATTRIBUTE_PRINTF(3, 4) {
va_list ap;
va_start(ap, format);
! this->logv(thread, format, ap);
va_end(ap);
}
};
+ typedef TemplatedStringEventLog<256> StringEventLog;
+ typedef TemplatedStringEventLog<512> ExtendedStringEventLog;
class InstanceKlass;
// Event log for class unloading events to materialize the class name in place in the log stream.
class UnloadingEventLog : public EventLogBase<StringLogMessage> {
*** 187,197 ****
// A log for generic messages that aren't well categorized.
static StringEventLog* _messages;
// A log for internal exception related messages, like internal
// throws and implicit exceptions.
! static StringEventLog* _exceptions;
// Deoptization related messages
static StringEventLog* _deopt_messages;
// Redefinition related messages
--- 193,203 ----
// A log for generic messages that aren't well categorized.
static StringEventLog* _messages;
// A log for internal exception related messages, like internal
// throws and implicit exceptions.
! static ExtendedStringEventLog* _exceptions;
// Deoptization related messages
static StringEventLog* _deopt_messages;
// Redefinition related messages
*** 305,314 ****
--- 311,327 ----
inline void EventLogBase<StringLogMessage>::print(outputStream* out, StringLogMessage& lm) {
out->print_raw(lm);
out->cr();
}
+ // Implement a printing routine for the ExtendedStringLogMessage
+ template <>
+ inline void EventLogBase<ExtendedStringLogMessage>::print(outputStream* out, ExtendedStringLogMessage& lm) {
+ out->print_raw(lm);
+ out->cr();
+ }
+
// Place markers for the beginning and end up of a set of events.
// These end up in the default log.
class EventMark : public StackObj {
StringLogMessage _buffer;
< prev index next >