2007-12-01 00:00:00 +00:00
|
|
|
/*
|
2015-06-04 08:05:47 -04:00
|
|
|
* Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
|
2007-12-01 00:00:00 +00:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
|
|
*
|
|
|
|
* This code is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU General Public License version 2 only, as
|
|
|
|
* published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This code is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
|
|
* version 2 for more details (a copy is included in the LICENSE file that
|
|
|
|
* accompanied this code).
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License version
|
|
|
|
* 2 along with this work; if not, write to the Free Software Foundation,
|
|
|
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*
|
2010-05-27 19:08:38 -07:00
|
|
|
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
|
|
|
* or visit www.oracle.com if you need additional information or have any
|
|
|
|
* questions.
|
2007-12-01 00:00:00 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2010-11-23 13:22:55 -08:00
|
|
|
#include "precompiled.hpp"
|
|
|
|
#include "memory/allocation.inline.hpp"
|
|
|
|
#include "runtime/mutexLocker.hpp"
|
2014-06-26 16:05:15 +02:00
|
|
|
#include "runtime/os.inline.hpp"
|
2010-11-23 13:22:55 -08:00
|
|
|
#include "runtime/osThread.hpp"
|
2012-11-27 14:20:21 +01:00
|
|
|
#include "runtime/thread.inline.hpp"
|
2012-02-01 07:59:01 -08:00
|
|
|
#include "runtime/threadCritical.hpp"
|
2010-11-23 13:22:55 -08:00
|
|
|
#include "runtime/timer.hpp"
|
|
|
|
#include "utilities/events.hpp"
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
|
2012-02-01 07:59:01 -08:00
|
|
|
EventLog* Events::_logs = NULL;
|
|
|
|
StringEventLog* Events::_messages = NULL;
|
|
|
|
StringEventLog* Events::_exceptions = NULL;
|
2015-06-04 08:05:47 -04:00
|
|
|
StringEventLog* Events::_redefinitions = NULL;
|
2012-02-01 07:59:01 -08:00
|
|
|
StringEventLog* Events::_deopt_messages = NULL;
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2012-02-01 07:59:01 -08:00
|
|
|
EventLog::EventLog() {
|
|
|
|
// This normally done during bootstrap when we're only single
|
|
|
|
// threaded but use a ThreadCritical to ensure inclusion in case
|
|
|
|
// some are created slightly late.
|
|
|
|
ThreadCritical tc;
|
|
|
|
_next = Events::_logs;
|
|
|
|
Events::_logs = this;
|
|
|
|
}
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2012-02-01 07:59:01 -08:00
|
|
|
// For each registered event logger, print out the current contents of
|
|
|
|
// the buffer. This is normally called when the JVM is crashing.
|
|
|
|
void Events::print_all(outputStream* out) {
|
|
|
|
EventLog* log = _logs;
|
|
|
|
while (log != NULL) {
|
|
|
|
log->print_log_on(out);
|
|
|
|
log = log->next();
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
2012-02-01 07:59:01 -08:00
|
|
|
}
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2012-02-15 10:12:55 -08:00
|
|
|
void Events::print() {
|
|
|
|
print_all(tty);
|
|
|
|
}
|
|
|
|
|
2012-02-01 07:59:01 -08:00
|
|
|
void Events::init() {
|
2007-12-01 00:00:00 +00:00
|
|
|
if (LogEvents) {
|
2012-02-01 07:59:01 -08:00
|
|
|
_messages = new StringEventLog("Events");
|
|
|
|
_exceptions = new StringEventLog("Internal exceptions");
|
2015-06-04 08:05:47 -04:00
|
|
|
_redefinitions = new StringEventLog("Classes redefined");
|
2012-02-01 07:59:01 -08:00
|
|
|
_deopt_messages = new StringEventLog("Deoptimization events");
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-02-01 07:59:01 -08:00
|
|
|
void eventlog_init() {
|
|
|
|
Events::init();
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////
|
|
|
|
// EventMark
|
|
|
|
|
|
|
|
EventMark::EventMark(const char* format, ...) {
|
|
|
|
if (LogEvents) {
|
|
|
|
va_list ap;
|
|
|
|
va_start(ap, format);
|
2012-02-01 07:59:01 -08:00
|
|
|
// Save a copy of begin message and log it.
|
|
|
|
_buffer.printv(format, ap);
|
2014-05-09 16:50:54 -04:00
|
|
|
Events::log(NULL, "%s", _buffer.buffer());
|
2007-12-01 00:00:00 +00:00
|
|
|
va_end(ap);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
EventMark::~EventMark() {
|
|
|
|
if (LogEvents) {
|
2012-02-01 07:59:01 -08:00
|
|
|
// Append " done" to the begin message and log it
|
|
|
|
_buffer.append(" done");
|
2014-05-09 16:50:54 -04:00
|
|
|
Events::log(NULL, "%s", _buffer.buffer());
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
}
|