src/share/vm/utilities/events.hpp
Index
Unified diffs
Context diffs
Sdiffs
Patch
New
Old
Previous File
Next File
*** old/src/share/vm/utilities/events.hpp Tue Feb 14 12:24:14 2012
--- new/src/share/vm/utilities/events.hpp Tue Feb 14 12:24:13 2012
*** 33,56 ****
--- 33,48 ----
// Events and EventMark provide interfaces to log events taking place in the vm.
// This facility is extremly useful for post-mortem debugging. The eventlog
// often provides crucial information about events leading up to the crash.
//
! // All arguments past the format string must be passed as an intptr_t.
//
// To log a single event use:
// Events::log("New nmethod has been created " INTPTR_FORMAT, nm);
//
// To log a block of events use:
// EventMark m("GarbageCollecting %d", (intptr_t)gc_number);
//
// The constructor to eventlog indents the eventlog until the
// destructor has been executed.
//
// IMPLEMENTATION RESTRICTION:
// Max 3 arguments are saved for each logged event.
//
! // Abstractly the logs can record whatever they way but normally they
+ // would record at least a timestamp and the current Thread, along
+ // with whatever data they need in a ring buffer. Commonly fixed
+ // length text messages are recorded for simplicity but other
+ // strategies could be used. Several logs are provided by default but
+ // new instances can be created as needed.
// The base event log dumping class that is registered for dumping at
// crash time. This is a very generic interface that is mainly here
// for completeness. Normally the templated EventLogBase would be
// subclassed to provide different log types.
*** 77,87 ****
--- 69,79 ----
// semantics aren't appropriate. The name is used as the label of the
// log when it is dumped during a crash.
template <class T> class EventLogBase : public EventLog {
template <class X> class EventRecord {
public:
! jlong timestamp;
! double timestamp;
Thread* thread;
X data;
};
protected:
*** 100,109 ****
--- 92,105 ----
_index(0),
_mutex(Mutex::event, name) {
_records = new EventRecord<T>[length];
}
+ double fetch_timestamp() {
+ return tty->time_stamp().seconds();
+ }
+
// move the ring buffer to next open slot and return the index of
// the slot to use for the current message. Should only be called
// while mutex is held.
int compute_log_index() {
int index = _index;
*** 128,138 ****
--- 124,134 ----
// Print a single element. A templated implementation might need to
// be declared by subclasses.
void print(outputStream* out, T& e);
void print(outputStream* out, EventRecord<T>& e) {
! out->print("Event: " INT64_FORMAT " ", e.timestamp);
! out->print("Event: %.3f ", e.timestamp);
if (e.thread != NULL) {
out->print("Thread " INTPTR_FORMAT " ", e.thread);
}
print(out, e.data);
}
*** 153,163 ****
--- 149,159 ----
StringEventLog(const char* name, int count = LogEventsBufferEntries) : EventLogBase<StringLogMessage>(name, count) {}
void logv(Thread* thread, const char* format, va_list ap) {
if (!should_log()) return;
! jlong timestamp = os::javaTimeNanos() / NANOSECS_PER_MILLISEC;
! 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);
*** 191,203 ****
--- 187,198 ----
static StringEventLog* _deopt_messages;
public:
static void print_all(outputStream* out);
static void print() {
! print_all(tty);
}
+ // Dump all events to the tty
! static void print();
// Logs a generic message with timestamp and format as printf.
static void log(Thread* thread, const char* format, ...);
// Log exception related message
*** 253,262 ****
--- 248,258 ----
template <class T>
inline void EventLogBase<T>::print_log_impl(outputStream* out) {
out->print_cr("%s (%d events):", _name, _count);
if (_count == 0) {
out->print_cr("No events");
+ out->cr();
return;
}
if (_count < _length) {
for (int i = 0; i < _count; i++) {
src/share/vm/utilities/events.hpp
Index
Unified diffs
Context diffs
Sdiffs
Patch
New
Old
Previous File
Next File