< prev index next >

src/hotspot/share/utilities/events.cpp

Print this page




  34 #include "utilities/events.hpp"
  35 
  36 
  37 EventLog* Events::_logs = NULL;
  38 StringEventLog* Events::_messages = NULL;
  39 ExceptionsEventLog* Events::_exceptions = NULL;
  40 StringEventLog* Events::_redefinitions = NULL;
  41 UnloadingEventLog* Events::_class_unloading = NULL;
  42 StringEventLog* Events::_deopt_messages = NULL;
  43 
  44 EventLog::EventLog() {
  45   // This normally done during bootstrap when we're only single
  46   // threaded but use a ThreadCritical to ensure inclusion in case
  47   // some are created slightly late.
  48   ThreadCritical tc;
  49   _next = Events::_logs;
  50   Events::_logs = this;
  51 }
  52 
  53 // For each registered event logger, print out the current contents of
  54 // the buffer.
  55 void Events::print_all(outputStream* out, int max) {
  56   EventLog* log = _logs;
  57   while (log != NULL) {
  58     log->print_log_on(out, max);
  59     log = log->next();
  60   }
  61 }
  62 
  63 // Print a single event log specified by name.
  64 void Events::print_one(outputStream* out, const char* log_name, int max) {
  65   EventLog* log = _logs;
  66   int num_printed = 0;
  67   while (log != NULL) {
  68     if (log->matches_name_or_handle(log_name)) {
  69       log->print_log_on(out, max);
  70       num_printed ++;
  71     }
  72     log = log->next();
  73   }
  74   // Write a short error note if no name matched.
  75   if (num_printed == 0) {
  76     out->print_cr("The name \"%s\" did not match any known event log. "
  77                   "Valid event log names are:", log_name);
  78     EventLog* log = _logs;
  79     while (log != NULL) {
  80       log->print_names(out);
  81       out->cr();
  82       log = log->next();
  83     }
  84   }
  85 }
  86 
  87 
  88 void Events::print() {
  89   print_all(tty);
  90 }
  91 
  92 void Events::init() {
  93   if (LogEvents) {
  94     _messages = new StringEventLog("Events", "events");
  95     _exceptions = new ExceptionsEventLog("Internal exceptions", "exc");
  96     _redefinitions = new StringEventLog("Classes redefined", "redef");
  97     _class_unloading = new UnloadingEventLog("Classes unloaded", "unload");
  98     _deopt_messages = new StringEventLog("Deoptimization events", "deopt");
  99   }
 100 }
 101 
 102 void eventlog_init() {
 103   Events::init();
 104 }
 105 
 106 ///////////////////////////////////////////////////////////////////////////
 107 // EventMark
 108 
 109 EventMark::EventMark(const char* format, ...) {
 110   if (LogEvents) {
 111     va_list ap;
 112     va_start(ap, format);
 113     // Save a copy of begin message and log it.
 114     _buffer.printv(format, ap);
 115     Events::log(NULL, "%s", _buffer.buffer());
 116     va_end(ap);
 117   }
 118 }




  34 #include "utilities/events.hpp"
  35 
  36 
  37 EventLog* Events::_logs = NULL;
  38 StringEventLog* Events::_messages = NULL;
  39 ExceptionsEventLog* Events::_exceptions = NULL;
  40 StringEventLog* Events::_redefinitions = NULL;
  41 UnloadingEventLog* Events::_class_unloading = NULL;
  42 StringEventLog* Events::_deopt_messages = NULL;
  43 
  44 EventLog::EventLog() {
  45   // This normally done during bootstrap when we're only single
  46   // threaded but use a ThreadCritical to ensure inclusion in case
  47   // some are created slightly late.
  48   ThreadCritical tc;
  49   _next = Events::_logs;
  50   Events::_logs = this;
  51 }
  52 
  53 // For each registered event logger, print out the current contents of
  54 // the buffer.  This is normally called when the JVM is crashing.
  55 void Events::print_all(outputStream* out) {
  56   EventLog* log = _logs;
  57   while (log != NULL) {
  58     log->print_log_on(out);
  59     log = log->next();
  60   }
  61 }
  62 

























  63 void Events::print() {
  64   print_all(tty);
  65 }
  66 
  67 void Events::init() {
  68   if (LogEvents) {
  69     _messages = new StringEventLog("Events");
  70     _exceptions = new ExceptionsEventLog("Internal exceptions");
  71     _redefinitions = new StringEventLog("Classes redefined");
  72     _class_unloading = new UnloadingEventLog("Classes unloaded");
  73     _deopt_messages = new StringEventLog("Deoptimization events");
  74   }
  75 }
  76 
  77 void eventlog_init() {
  78   Events::init();
  79 }
  80 
  81 ///////////////////////////////////////////////////////////////////////////
  82 // EventMark
  83 
  84 EventMark::EventMark(const char* format, ...) {
  85   if (LogEvents) {
  86     va_list ap;
  87     va_start(ap, format);
  88     // Save a copy of begin message and log it.
  89     _buffer.printv(format, ap);
  90     Events::log(NULL, "%s", _buffer.buffer());
  91     va_end(ap);
  92   }
  93 }


< prev index next >