src/share/vm/utilities/events.cpp

Mon, 02 Jul 2012 13:11:28 -0400

author
coleenp
date
Mon, 02 Jul 2012 13:11:28 -0400
changeset 3901
24b9c7f4cae6
parent 3571
09d00c18e323
child 4299
f34d701e952e
permissions
-rw-r--r--

Merge

     1 /*
     2  * Copyright (c) 1997, 2012, 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  */
    25 #include "precompiled.hpp"
    26 #include "memory/allocation.inline.hpp"
    27 #include "runtime/mutexLocker.hpp"
    28 #include "runtime/osThread.hpp"
    29 #include "runtime/threadCritical.hpp"
    30 #include "runtime/threadLocalStorage.hpp"
    31 #include "runtime/timer.hpp"
    32 #include "utilities/events.hpp"
    33 #ifdef TARGET_OS_FAMILY_linux
    34 # include "thread_linux.inline.hpp"
    35 #endif
    36 #ifdef TARGET_OS_FAMILY_solaris
    37 # include "thread_solaris.inline.hpp"
    38 #endif
    39 #ifdef TARGET_OS_FAMILY_windows
    40 # include "thread_windows.inline.hpp"
    41 #endif
    42 #ifdef TARGET_OS_FAMILY_bsd
    43 # include "thread_bsd.inline.hpp"
    44 #endif
    47 EventLog* Events::_logs = NULL;
    48 StringEventLog* Events::_messages = NULL;
    49 StringEventLog* Events::_exceptions = NULL;
    50 StringEventLog* Events::_deopt_messages = NULL;
    52 EventLog::EventLog() {
    53   // This normally done during bootstrap when we're only single
    54   // threaded but use a ThreadCritical to ensure inclusion in case
    55   // some are created slightly late.
    56   ThreadCritical tc;
    57   _next = Events::_logs;
    58   Events::_logs = this;
    59 }
    61 // For each registered event logger, print out the current contents of
    62 // the buffer.  This is normally called when the JVM is crashing.
    63 void Events::print_all(outputStream* out) {
    64   EventLog* log = _logs;
    65   while (log != NULL) {
    66     log->print_log_on(out);
    67     log = log->next();
    68   }
    69 }
    71 void Events::print() {
    72   print_all(tty);
    73 }
    75 void Events::init() {
    76   if (LogEvents) {
    77     _messages = new StringEventLog("Events");
    78     _exceptions = new StringEventLog("Internal exceptions");
    79     _deopt_messages = new StringEventLog("Deoptimization events");
    80   }
    81 }
    83 void eventlog_init() {
    84   Events::init();
    85 }
    87 ///////////////////////////////////////////////////////////////////////////
    88 // EventMark
    90 EventMark::EventMark(const char* format, ...) {
    91   if (LogEvents) {
    92     va_list ap;
    93     va_start(ap, format);
    94     // Save a copy of begin message and log it.
    95     _buffer.printv(format, ap);
    96     Events::log(NULL, _buffer);
    97     va_end(ap);
    98   }
    99 }
   101 EventMark::~EventMark() {
   102   if (LogEvents) {
   103     // Append " done" to the begin message and log it
   104     _buffer.append(" done");
   105     Events::log(NULL, _buffer);
   106   }
   107 }

mercurial