author | ysuenaga |
Sat, 16 Feb 2019 11:40:34 +0900 | |
changeset 53784 | 31e3aa9c0c71 |
parent 53738 | 7f3b27d9c22d |
child 53874 | b2fb6f782d84 |
permissions | -rw-r--r-- |
1 | 1 |
/* |
53784
31e3aa9c0c71
8204551: Event descriptions are truncated in logs
ysuenaga
parents:
53738
diff
changeset
|
2 |
* Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved. |
1 | 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 |
* |
|
5547
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1
diff
changeset
|
21 |
* questions. |
1 | 22 |
* |
23 |
*/ |
|
24 |
||
7397 | 25 |
#include "precompiled.hpp" |
26 |
#include "memory/allocation.inline.hpp" |
|
53738
7f3b27d9c22d
8212988: add recent class unloading events to the hs_err log
coleenp
parents:
47216
diff
changeset
|
27 |
#include "oops/instanceKlass.hpp" |
7397 | 28 |
#include "runtime/mutexLocker.hpp" |
25468
5331df506290
8048241: Introduce umbrella header os.inline.hpp and clean up includes
goetz
parents:
24424
diff
changeset
|
29 |
#include "runtime/os.inline.hpp" |
7397 | 30 |
#include "runtime/osThread.hpp" |
14583
d70ee55535f4
8003935: Simplify the needed includes for using Thread::current()
stefank
parents:
11788
diff
changeset
|
31 |
#include "runtime/thread.inline.hpp" |
11636
3c07b54482a5
7141200: log some interesting information in ring buffers for crashes
never
parents:
10565
diff
changeset
|
32 |
#include "runtime/threadCritical.hpp" |
7397 | 33 |
#include "runtime/timer.hpp" |
34 |
#include "utilities/events.hpp" |
|
1 | 35 |
|
36 |
||
11636
3c07b54482a5
7141200: log some interesting information in ring buffers for crashes
never
parents:
10565
diff
changeset
|
37 |
EventLog* Events::_logs = NULL; |
3c07b54482a5
7141200: log some interesting information in ring buffers for crashes
never
parents:
10565
diff
changeset
|
38 |
StringEventLog* Events::_messages = NULL; |
53784
31e3aa9c0c71
8204551: Event descriptions are truncated in logs
ysuenaga
parents:
53738
diff
changeset
|
39 |
ExtendedStringEventLog* Events::_exceptions = NULL; |
31234
48000028382c
8081219: hs_err improvement: Add event logging for class redefinition to the hs_err file
coleenp
parents:
25468
diff
changeset
|
40 |
StringEventLog* Events::_redefinitions = NULL; |
53738
7f3b27d9c22d
8212988: add recent class unloading events to the hs_err log
coleenp
parents:
47216
diff
changeset
|
41 |
UnloadingEventLog* Events::_class_unloading = NULL; |
11636
3c07b54482a5
7141200: log some interesting information in ring buffers for crashes
never
parents:
10565
diff
changeset
|
42 |
StringEventLog* Events::_deopt_messages = NULL; |
1 | 43 |
|
11636
3c07b54482a5
7141200: log some interesting information in ring buffers for crashes
never
parents:
10565
diff
changeset
|
44 |
EventLog::EventLog() { |
3c07b54482a5
7141200: log some interesting information in ring buffers for crashes
never
parents:
10565
diff
changeset
|
45 |
// This normally done during bootstrap when we're only single |
3c07b54482a5
7141200: log some interesting information in ring buffers for crashes
never
parents:
10565
diff
changeset
|
46 |
// threaded but use a ThreadCritical to ensure inclusion in case |
3c07b54482a5
7141200: log some interesting information in ring buffers for crashes
never
parents:
10565
diff
changeset
|
47 |
// some are created slightly late. |
3c07b54482a5
7141200: log some interesting information in ring buffers for crashes
never
parents:
10565
diff
changeset
|
48 |
ThreadCritical tc; |
3c07b54482a5
7141200: log some interesting information in ring buffers for crashes
never
parents:
10565
diff
changeset
|
49 |
_next = Events::_logs; |
3c07b54482a5
7141200: log some interesting information in ring buffers for crashes
never
parents:
10565
diff
changeset
|
50 |
Events::_logs = this; |
3c07b54482a5
7141200: log some interesting information in ring buffers for crashes
never
parents:
10565
diff
changeset
|
51 |
} |
1 | 52 |
|
11636
3c07b54482a5
7141200: log some interesting information in ring buffers for crashes
never
parents:
10565
diff
changeset
|
53 |
// For each registered event logger, print out the current contents of |
3c07b54482a5
7141200: log some interesting information in ring buffers for crashes
never
parents:
10565
diff
changeset
|
54 |
// the buffer. This is normally called when the JVM is crashing. |
3c07b54482a5
7141200: log some interesting information in ring buffers for crashes
never
parents:
10565
diff
changeset
|
55 |
void Events::print_all(outputStream* out) { |
3c07b54482a5
7141200: log some interesting information in ring buffers for crashes
never
parents:
10565
diff
changeset
|
56 |
EventLog* log = _logs; |
3c07b54482a5
7141200: log some interesting information in ring buffers for crashes
never
parents:
10565
diff
changeset
|
57 |
while (log != NULL) { |
3c07b54482a5
7141200: log some interesting information in ring buffers for crashes
never
parents:
10565
diff
changeset
|
58 |
log->print_log_on(out); |
3c07b54482a5
7141200: log some interesting information in ring buffers for crashes
never
parents:
10565
diff
changeset
|
59 |
log = log->next(); |
1 | 60 |
} |
61 |
} |
|
62 |
||
11788 | 63 |
void Events::print() { |
64 |
print_all(tty); |
|
65 |
} |
|
66 |
||
11636
3c07b54482a5
7141200: log some interesting information in ring buffers for crashes
never
parents:
10565
diff
changeset
|
67 |
void Events::init() { |
3c07b54482a5
7141200: log some interesting information in ring buffers for crashes
never
parents:
10565
diff
changeset
|
68 |
if (LogEvents) { |
3c07b54482a5
7141200: log some interesting information in ring buffers for crashes
never
parents:
10565
diff
changeset
|
69 |
_messages = new StringEventLog("Events"); |
53784
31e3aa9c0c71
8204551: Event descriptions are truncated in logs
ysuenaga
parents:
53738
diff
changeset
|
70 |
_exceptions = new ExtendedStringEventLog("Internal exceptions"); |
31234
48000028382c
8081219: hs_err improvement: Add event logging for class redefinition to the hs_err file
coleenp
parents:
25468
diff
changeset
|
71 |
_redefinitions = new StringEventLog("Classes redefined"); |
53738
7f3b27d9c22d
8212988: add recent class unloading events to the hs_err log
coleenp
parents:
47216
diff
changeset
|
72 |
_class_unloading = new UnloadingEventLog("Classes unloaded"); |
11636
3c07b54482a5
7141200: log some interesting information in ring buffers for crashes
never
parents:
10565
diff
changeset
|
73 |
_deopt_messages = new StringEventLog("Deoptimization events"); |
3c07b54482a5
7141200: log some interesting information in ring buffers for crashes
never
parents:
10565
diff
changeset
|
74 |
} |
1 | 75 |
} |
76 |
||
11636
3c07b54482a5
7141200: log some interesting information in ring buffers for crashes
never
parents:
10565
diff
changeset
|
77 |
void eventlog_init() { |
3c07b54482a5
7141200: log some interesting information in ring buffers for crashes
never
parents:
10565
diff
changeset
|
78 |
Events::init(); |
1 | 79 |
} |
80 |
||
81 |
/////////////////////////////////////////////////////////////////////////// |
|
82 |
// EventMark |
|
83 |
||
84 |
EventMark::EventMark(const char* format, ...) { |
|
85 |
if (LogEvents) { |
|
86 |
va_list ap; |
|
87 |
va_start(ap, format); |
|
11636
3c07b54482a5
7141200: log some interesting information in ring buffers for crashes
never
parents:
10565
diff
changeset
|
88 |
// Save a copy of begin message and log it. |
3c07b54482a5
7141200: log some interesting information in ring buffers for crashes
never
parents:
10565
diff
changeset
|
89 |
_buffer.printv(format, ap); |
24424
2658d7834c6e
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
14583
diff
changeset
|
90 |
Events::log(NULL, "%s", _buffer.buffer()); |
1 | 91 |
va_end(ap); |
92 |
} |
|
93 |
} |
|
94 |
||
95 |
EventMark::~EventMark() { |
|
96 |
if (LogEvents) { |
|
11636
3c07b54482a5
7141200: log some interesting information in ring buffers for crashes
never
parents:
10565
diff
changeset
|
97 |
// Append " done" to the begin message and log it |
3c07b54482a5
7141200: log some interesting information in ring buffers for crashes
never
parents:
10565
diff
changeset
|
98 |
_buffer.append(" done"); |
24424
2658d7834c6e
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
14583
diff
changeset
|
99 |
Events::log(NULL, "%s", _buffer.buffer()); |
1 | 100 |
} |
101 |
} |
|
53738
7f3b27d9c22d
8212988: add recent class unloading events to the hs_err log
coleenp
parents:
47216
diff
changeset
|
102 |
|
7f3b27d9c22d
8212988: add recent class unloading events to the hs_err log
coleenp
parents:
47216
diff
changeset
|
103 |
void UnloadingEventLog::log(Thread* thread, InstanceKlass* ik) { |
7f3b27d9c22d
8212988: add recent class unloading events to the hs_err log
coleenp
parents:
47216
diff
changeset
|
104 |
if (!should_log()) return; |
7f3b27d9c22d
8212988: add recent class unloading events to the hs_err log
coleenp
parents:
47216
diff
changeset
|
105 |
|
7f3b27d9c22d
8212988: add recent class unloading events to the hs_err log
coleenp
parents:
47216
diff
changeset
|
106 |
double timestamp = fetch_timestamp(); |
7f3b27d9c22d
8212988: add recent class unloading events to the hs_err log
coleenp
parents:
47216
diff
changeset
|
107 |
// Unloading events are single threaded. |
7f3b27d9c22d
8212988: add recent class unloading events to the hs_err log
coleenp
parents:
47216
diff
changeset
|
108 |
int index = compute_log_index(); |
7f3b27d9c22d
8212988: add recent class unloading events to the hs_err log
coleenp
parents:
47216
diff
changeset
|
109 |
_records[index].thread = thread; |
7f3b27d9c22d
8212988: add recent class unloading events to the hs_err log
coleenp
parents:
47216
diff
changeset
|
110 |
_records[index].timestamp = timestamp; |
7f3b27d9c22d
8212988: add recent class unloading events to the hs_err log
coleenp
parents:
47216
diff
changeset
|
111 |
stringStream st = _records[index].data.stream(); |
7f3b27d9c22d
8212988: add recent class unloading events to the hs_err log
coleenp
parents:
47216
diff
changeset
|
112 |
st.print("Unloading class " INTPTR_FORMAT " ", p2i(ik)); |
7f3b27d9c22d
8212988: add recent class unloading events to the hs_err log
coleenp
parents:
47216
diff
changeset
|
113 |
ik->name()->print_value_on(&st); |
7f3b27d9c22d
8212988: add recent class unloading events to the hs_err log
coleenp
parents:
47216
diff
changeset
|
114 |
} |