25
#include "precompiled.hpp"
26
#include "gc/shared/gc_globals.hpp"
27
#include "memory/allocation.inline.hpp"
28
#include "oops/instanceKlass.hpp"
29
#include "oops/symbol.hpp"
30
#include "runtime/javaThread.hpp"
31
#include "runtime/mutexLocker.hpp"
32
#include "runtime/osThread.hpp"
33
#include "runtime/threadCritical.hpp"
34
#include "runtime/timer.hpp"
35
#include "utilities/events.hpp"
38
EventLog* Events::_logs = nullptr;
39
StringEventLog* Events::_messages = nullptr;
40
StringEventLog* Events::_memprotect_messages = nullptr;
41
StringEventLog* Events::_nmethod_flush_messages = nullptr;
42
StringEventLog* Events::_vm_operations = nullptr;
43
StringEventLog* Events::_zgc_phase_switch = nullptr;
44
ExceptionsEventLog* Events::_exceptions = nullptr;
45
StringEventLog* Events::_redefinitions = nullptr;
46
UnloadingEventLog* Events::_class_unloading = nullptr;
47
StringEventLog* Events::_class_loading = nullptr;
48
StringEventLog* Events::_deopt_messages = nullptr;
49
StringEventLog* Events::_dll_messages = nullptr;
56
_next = Events::_logs;
62
void Events::print_all(outputStream* out, int max) {
63
EventLog* log = _logs;
64
while (log != nullptr) {
65
log->print_log_on(out, max);
71
void Events::print_one(outputStream* out, const char* log_name, int max) {
72
EventLog* log = _logs;
74
while (log != nullptr) {
75
if (log->matches_name_or_handle(log_name)) {
76
log->print_log_on(out, max);
82
if (num_printed == 0) {
83
out->print_cr("The name \"%s\" did not match any known event log. "
84
"Valid event log names are:", log_name);
85
EventLog* log = _logs;
86
while (log != nullptr) {
87
log->print_names(out);
101
_messages = new StringEventLog("Events", "events");
102
_nmethod_flush_messages = new StringEventLog("Nmethod flushes", "nmethodflushes");
103
_memprotect_messages = new StringEventLog("Memory protections", "memprotects");
104
_vm_operations = new StringEventLog("VM Operations", "vmops");
106
_zgc_phase_switch = new StringEventLog("ZGC Phase Switch", "zgcps");
108
_exceptions = new ExceptionsEventLog("Internal exceptions", "exc");
109
_redefinitions = new StringEventLog("Classes redefined", "redef");
110
_class_unloading = new UnloadingEventLog("Classes unloaded", "unload");
111
_class_loading = new StringEventLog("Classes loaded", "load");
112
_deopt_messages = new StringEventLog("Deoptimization events", "deopt");
113
_dll_messages = new StringEventLog("Dll operation events", "dll");
117
void eventlog_init() {
124
EventMarkBase::EventMarkBase(EventLogFunction log_function) :
125
_log_function(log_function),
128
void EventMarkBase::log_start(const char* format, va_list argp) {
130
_buffer.printv(format, argp);
131
_log_function(nullptr, "%s", _buffer.buffer());
134
void EventMarkBase::log_end() {
136
_buffer.append(" done");
137
_log_function(nullptr, "%s", _buffer.buffer());
140
void UnloadingEventLog::log(Thread* thread, InstanceKlass* ik) {
141
if (!should_log()) return;
143
double timestamp = fetch_timestamp();
145
int index = compute_log_index();
146
_records[index].thread = thread;
147
_records[index].timestamp = timestamp;
148
stringStream st(_records[index].data.buffer(),
149
_records[index].data.size());
150
st.print("Unloading class " PTR_FORMAT " ", p2i(ik));
151
ik->name()->print_value_on(&st);
154
void ExceptionsEventLog::log(Thread* thread, Handle h_exception, const char* message, const char* file, int line) {
155
if (!should_log()) return;
157
double timestamp = fetch_timestamp();
158
MutexLocker ml(&_mutex, Mutex::_no_safepoint_check_flag);
159
int index = compute_log_index();
160
_records[index].thread = thread;
161
_records[index].timestamp = timestamp;
162
stringStream st(_records[index].data.buffer(),
163
_records[index].data.size());
164
st.print("Exception <");
165
h_exception->print_value_on(&st);
166
st.print("%s%s> (" PTR_FORMAT ") \n"
167
"thrown [%s, line %d]",
168
message ? ": " : "", message ? message : "",
169
p2i(h_exception()), file, line);