Mercurial > hg > graal-jvmci-8
annotate src/share/vm/utilities/events.hpp @ 6972:bd7a7ce2e264
6830717: replay of compilations would help with debugging
Summary: When java process crashed in compiler thread, repeat the compilation process will help finding root cause. This is done with using SA dump application class data and replay data from core dump, then use debug version of jvm to recompile the problematic java method.
Reviewed-by: kvn, twisti, sspitsyn
Contributed-by: yumin.qi@oracle.com
author | minqi |
---|---|
date | Mon, 12 Nov 2012 14:03:53 -0800 |
parents | d2a62e0f25eb |
children | ee32440febeb |
rev | line source |
---|---|
0 | 1 /* |
4872
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
2 * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. |
0 | 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 * | |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
0
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
0
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
0
diff
changeset
|
21 * questions. |
0 | 22 * |
23 */ | |
24 | |
1972 | 25 #ifndef SHARE_VM_UTILITIES_EVENTS_HPP |
26 #define SHARE_VM_UTILITIES_EVENTS_HPP | |
27 | |
28 #include "memory/allocation.hpp" | |
4872
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
29 #include "runtime/mutexLocker.hpp" |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
30 #include "runtime/thread.hpp" |
1972 | 31 #include "utilities/top.hpp" |
4872
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
32 #include "utilities/vmError.hpp" |
1972 | 33 |
0 | 34 // Events and EventMark provide interfaces to log events taking place in the vm. |
35 // This facility is extremly useful for post-mortem debugging. The eventlog | |
36 // often provides crucial information about events leading up to the crash. | |
37 // | |
4944 | 38 // Abstractly the logs can record whatever they way but normally they |
39 // would record at least a timestamp and the current Thread, along | |
40 // with whatever data they need in a ring buffer. Commonly fixed | |
41 // length text messages are recorded for simplicity but other | |
42 // strategies could be used. Several logs are provided by default but | |
43 // new instances can be created as needed. | |
0 | 44 |
4872
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
45 // The base event log dumping class that is registered for dumping at |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
46 // crash time. This is a very generic interface that is mainly here |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
47 // for completeness. Normally the templated EventLogBase would be |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
48 // subclassed to provide different log types. |
6197 | 49 class EventLog : public CHeapObj<mtInternal> { |
4872
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
50 friend class Events; |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
51 |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
52 private: |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
53 EventLog* _next; |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
54 |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
55 EventLog* next() const { return _next; } |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
56 |
0 | 57 public: |
4872
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
58 // Automatically registers the log so that it will be printed during |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
59 // crashes. |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
60 EventLog(); |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
61 |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
62 virtual void print_log_on(outputStream* out) = 0; |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
63 }; |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
64 |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
65 |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
66 // A templated subclass of EventLog that provides basic ring buffer |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
67 // functionality. Most event loggers should subclass this, possibly |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
68 // providing a more featureful log function if the existing copy |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
69 // semantics aren't appropriate. The name is used as the label of the |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
70 // log when it is dumped during a crash. |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
71 template <class T> class EventLogBase : public EventLog { |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
72 template <class X> class EventRecord { |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
73 public: |
4944 | 74 double timestamp; |
4872
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
75 Thread* thread; |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
76 X data; |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
77 }; |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
78 |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
79 protected: |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
80 Mutex _mutex; |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
81 const char* _name; |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
82 int _length; |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
83 int _index; |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
84 int _count; |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
85 EventRecord<T>* _records; |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
86 |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
87 public: |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
88 EventLogBase<T>(const char* name, int length = LogEventsBufferEntries): |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
89 _name(name), |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
90 _length(length), |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
91 _count(0), |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
92 _index(0), |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
93 _mutex(Mutex::event, name) { |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
94 _records = new EventRecord<T>[length]; |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
95 } |
0 | 96 |
4944 | 97 double fetch_timestamp() { |
4951
72c425c46102
7146729: nightly failure after 7141200: tty is sometimes null during shutdown of main thread
never
parents:
4944
diff
changeset
|
98 return os::elapsedTime(); |
4944 | 99 } |
100 | |
4872
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
101 // move the ring buffer to next open slot and return the index of |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
102 // the slot to use for the current message. Should only be called |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
103 // while mutex is held. |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
104 int compute_log_index() { |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
105 int index = _index; |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
106 if (_count < _length) _count++; |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
107 _index++; |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
108 if (_index >= _length) _index = 0; |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
109 return index; |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
110 } |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
111 |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
112 bool should_log() { |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
113 // Don't bother adding new entries when we're crashing. This also |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
114 // avoids mutating the ring buffer when printing the log. |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
115 return !VMError::fatal_error_in_progress(); |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
116 } |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
117 |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
118 // Print the contents of the log |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
119 void print_log_on(outputStream* out); |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
120 |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
121 private: |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
122 void print_log_impl(outputStream* out); |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
123 |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
124 // Print a single element. A templated implementation might need to |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
125 // be declared by subclasses. |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
126 void print(outputStream* out, T& e); |
0 | 127 |
4872
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
128 void print(outputStream* out, EventRecord<T>& e) { |
4944 | 129 out->print("Event: %.3f ", e.timestamp); |
4872
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
130 if (e.thread != NULL) { |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
131 out->print("Thread " INTPTR_FORMAT " ", e.thread); |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
132 } |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
133 print(out, e.data); |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
134 } |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
135 }; |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
136 |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
137 // A simple wrapper class for fixed size text messages. |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
138 class StringLogMessage : public FormatBuffer<132> { |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
139 public: |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
140 // Wrap this buffer in a stringStream. |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
141 stringStream stream() { |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
142 return stringStream(_buf, sizeof(_buf)); |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
143 } |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
144 }; |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
145 |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
146 // A simple ring buffer of fixed size text messages. |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
147 class StringEventLog : public EventLogBase<StringLogMessage> { |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
148 public: |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
149 StringEventLog(const char* name, int count = LogEventsBufferEntries) : EventLogBase<StringLogMessage>(name, count) {} |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
150 |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
151 void logv(Thread* thread, const char* format, va_list ap) { |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
152 if (!should_log()) return; |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
153 |
4944 | 154 double timestamp = fetch_timestamp(); |
4872
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
155 MutexLockerEx ml(&_mutex, Mutex::_no_safepoint_check_flag); |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
156 int index = compute_log_index(); |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
157 _records[index].thread = thread; |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
158 _records[index].timestamp = timestamp; |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
159 _records[index].data.printv(format, ap); |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
160 } |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
161 |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
162 void log(Thread* thread, const char* format, ...) { |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
163 va_list ap; |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
164 va_start(ap, format); |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
165 logv(thread, format, ap); |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
166 va_end(ap); |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
167 } |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
168 |
0 | 169 }; |
170 | |
4872
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
171 |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
172 |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
173 class Events : AllStatic { |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
174 friend class EventLog; |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
175 |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
176 private: |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
177 static EventLog* _logs; |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
178 |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
179 // A log for generic messages that aren't well categorized. |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
180 static StringEventLog* _messages; |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
181 |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
182 // A log for internal exception related messages, like internal |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
183 // throws and implicit exceptions. |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
184 static StringEventLog* _exceptions; |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
185 |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
186 // Deoptization related messages |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
187 static StringEventLog* _deopt_messages; |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
188 |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
189 public: |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
190 static void print_all(outputStream* out); |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
191 |
4944 | 192 // Dump all events to the tty |
193 static void print(); | |
4872
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
194 |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
195 // Logs a generic message with timestamp and format as printf. |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
196 static void log(Thread* thread, const char* format, ...); |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
197 |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
198 // Log exception related message |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
199 static void log_exception(Thread* thread, const char* format, ...); |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
200 |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
201 static void log_deopt_message(Thread* thread, const char* format, ...); |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
202 |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
203 // Register default loggers |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
204 static void init(); |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
205 }; |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
206 |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
207 |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
208 inline void Events::log(Thread* thread, const char* format, ...) { |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
209 if (LogEvents) { |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
210 va_list ap; |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
211 va_start(ap, format); |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
212 _messages->logv(thread, format, ap); |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
213 va_end(ap); |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
214 } |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
215 } |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
216 |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
217 inline void Events::log_exception(Thread* thread, const char* format, ...) { |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
218 if (LogEvents) { |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
219 va_list ap; |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
220 va_start(ap, format); |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
221 _exceptions->logv(thread, format, ap); |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
222 va_end(ap); |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
223 } |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
224 } |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
225 |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
226 inline void Events::log_deopt_message(Thread* thread, const char* format, ...) { |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
227 if (LogEvents) { |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
228 va_list ap; |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
229 va_start(ap, format); |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
230 _deopt_messages->logv(thread, format, ap); |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
231 va_end(ap); |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
232 } |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
233 } |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
234 |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
235 |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
236 template <class T> |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
237 inline void EventLogBase<T>::print_log_on(outputStream* out) { |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
238 if (ThreadLocalStorage::get_thread_slow() == NULL) { |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
239 // Not a regular Java thread so don't bother locking |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
240 print_log_impl(out); |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
241 } else { |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
242 MutexLockerEx ml(&_mutex, Mutex::_no_safepoint_check_flag); |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
243 print_log_impl(out); |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
244 } |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
245 } |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
246 |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
247 // Dump the ring buffer entries that current have entries. |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
248 template <class T> |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
249 inline void EventLogBase<T>::print_log_impl(outputStream* out) { |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
250 out->print_cr("%s (%d events):", _name, _count); |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
251 if (_count == 0) { |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
252 out->print_cr("No events"); |
4944 | 253 out->cr(); |
4872
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
254 return; |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
255 } |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
256 |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
257 if (_count < _length) { |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
258 for (int i = 0; i < _count; i++) { |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
259 print(out, _records[i]); |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
260 } |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
261 } else { |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
262 for (int i = _index; i < _length; i++) { |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
263 print(out, _records[i]); |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
264 } |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
265 for (int i = 0; i < _index; i++) { |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
266 print(out, _records[i]); |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
267 } |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
268 } |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
269 out->cr(); |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
270 } |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
271 |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
272 // Implement a printing routine for the StringLogMessage |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
273 template <> |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
274 inline void EventLogBase<StringLogMessage>::print(outputStream* out, StringLogMessage& lm) { |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
275 out->print_raw(lm); |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
276 out->cr(); |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
277 } |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
278 |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
279 // Place markers for the beginning and end up of a set of events. |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
280 // These end up in the default log. |
0 | 281 class EventMark : public StackObj { |
4872
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
282 StringLogMessage _buffer; |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
283 |
0 | 284 public: |
285 // log a begin event, format as printf | |
4872
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
286 EventMark(const char* format, ...); |
0 | 287 // log an end event |
4872
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
288 ~EventMark(); |
0 | 289 }; |
290 | |
1972 | 291 #endif // SHARE_VM_UTILITIES_EVENTS_HPP |