src/share/vm/utilities/events.cpp

Print this page


   1 /*
   2  * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "memory/allocation.inline.hpp"
  27 #include "runtime/mutexLocker.hpp"
  28 #include "runtime/osThread.hpp"
  29 #include "runtime/thread.inline.hpp"
  30 #include "runtime/threadCritical.hpp"
  31 #include "runtime/threadLocalStorage.hpp"
  32 #include "runtime/timer.hpp"
  33 #include "utilities/events.hpp"
  34 
  35 
  36 EventLog* Events::_logs = NULL;
  37 StringEventLog* Events::_messages = NULL;
  38 StringEventLog* Events::_exceptions = NULL;

  39 StringEventLog* Events::_deopt_messages = NULL;
  40 
  41 EventLog::EventLog() {
  42   // This normally done during bootstrap when we're only single
  43   // threaded but use a ThreadCritical to ensure inclusion in case
  44   // some are created slightly late.
  45   ThreadCritical tc;
  46   _next = Events::_logs;
  47   Events::_logs = this;
  48 }
  49 
  50 // For each registered event logger, print out the current contents of
  51 // the buffer.  This is normally called when the JVM is crashing.
  52 void Events::print_all(outputStream* out) {
  53   EventLog* log = _logs;
  54   while (log != NULL) {
  55     log->print_log_on(out);
  56     log = log->next();
  57   }
  58 }
  59 
  60 void Events::print() {
  61   print_all(tty);
  62 }
  63 
  64 void Events::init() {
  65   if (LogEvents) {
  66     _messages = new StringEventLog("Events");
  67     _exceptions = new StringEventLog("Internal exceptions");

  68     _deopt_messages = new StringEventLog("Deoptimization events");
  69   }
  70 }
  71 
  72 void eventlog_init() {
  73   Events::init();
  74 }
  75 
  76 ///////////////////////////////////////////////////////////////////////////
  77 // EventMark
  78 
  79 EventMark::EventMark(const char* format, ...) {
  80   if (LogEvents) {
  81     va_list ap;
  82     va_start(ap, format);
  83     // Save a copy of begin message and log it.
  84     _buffer.printv(format, ap);
  85     Events::log(NULL, "%s", _buffer.buffer());
  86     va_end(ap);
  87   }
   1 /*
   2  * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "memory/allocation.inline.hpp"
  27 #include "runtime/mutexLocker.hpp"
  28 #include "runtime/osThread.hpp"
  29 #include "runtime/thread.inline.hpp"
  30 #include "runtime/threadCritical.hpp"
  31 #include "runtime/threadLocalStorage.hpp"
  32 #include "runtime/timer.hpp"
  33 #include "utilities/events.hpp"
  34 
  35 
  36 EventLog* Events::_logs = NULL;
  37 StringEventLog* Events::_messages = NULL;
  38 StringEventLog* Events::_exceptions = NULL;
  39 StringEventLog* Events::_redefinitions = NULL;
  40 StringEventLog* Events::_deopt_messages = NULL;
  41 
  42 EventLog::EventLog() {
  43   // This normally done during bootstrap when we're only single
  44   // threaded but use a ThreadCritical to ensure inclusion in case
  45   // some are created slightly late.
  46   ThreadCritical tc;
  47   _next = Events::_logs;
  48   Events::_logs = this;
  49 }
  50 
  51 // For each registered event logger, print out the current contents of
  52 // the buffer.  This is normally called when the JVM is crashing.
  53 void Events::print_all(outputStream* out) {
  54   EventLog* log = _logs;
  55   while (log != NULL) {
  56     log->print_log_on(out);
  57     log = log->next();
  58   }
  59 }
  60 
  61 void Events::print() {
  62   print_all(tty);
  63 }
  64 
  65 void Events::init() {
  66   if (LogEvents) {
  67     _messages = new StringEventLog("Events");
  68     _exceptions = new StringEventLog("Internal exceptions");
  69     _redefinitions = new StringEventLog("Classes redefined");
  70     _deopt_messages = new StringEventLog("Deoptimization events");
  71   }
  72 }
  73 
  74 void eventlog_init() {
  75   Events::init();
  76 }
  77 
  78 ///////////////////////////////////////////////////////////////////////////
  79 // EventMark
  80 
  81 EventMark::EventMark(const char* format, ...) {
  82   if (LogEvents) {
  83     va_list ap;
  84     va_start(ap, format);
  85     // Save a copy of begin message and log it.
  86     _buffer.printv(format, ap);
  87     Events::log(NULL, "%s", _buffer.buffer());
  88     va_end(ap);
  89   }