Mercurial > hg > graal-compiler
annotate src/share/vm/utilities/events.hpp @ 4911:d903bf750e9f
7129514: time warp warnings after 7117303
Summary: Replace calls to os::javaTimeMillis() that are used to update the milliseconds since the last GC to an equivalent that uses a monotonically non-decreasing time source.
Reviewed-by: ysr, jmasa
author | johnc |
---|---|
date | Wed, 18 Jan 2012 09:50:16 -0800 |
parents | aa3d708d67c4 |
children | 09d00c18e323 |
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 // | |
38 // All arguments past the format string must be passed as an intptr_t. | |
39 // | |
40 // To log a single event use: | |
41 // Events::log("New nmethod has been created " INTPTR_FORMAT, nm); | |
42 // | |
43 // To log a block of events use: | |
44 // EventMark m("GarbageCollecting %d", (intptr_t)gc_number); | |
45 // | |
46 // The constructor to eventlog indents the eventlog until the | |
47 // destructor has been executed. | |
48 // | |
49 // IMPLEMENTATION RESTRICTION: | |
50 // Max 3 arguments are saved for each logged event. | |
51 // | |
52 | |
4872
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
53 // 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
|
54 // 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
|
55 // for completeness. Normally the templated EventLogBase would be |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
56 // subclassed to provide different log types. |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
57 class EventLog : public CHeapObj { |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
58 friend class Events; |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
59 |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
60 private: |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
61 EventLog* _next; |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
62 |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
63 EventLog* next() const { return _next; } |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
64 |
0 | 65 public: |
4872
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
66 // 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
|
67 // crashes. |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
68 EventLog(); |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
69 |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
70 virtual void print_log_on(outputStream* out) = 0; |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
71 }; |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
72 |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
73 |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
74 // 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
|
75 // functionality. Most event loggers should subclass this, possibly |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
76 // 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
|
77 // 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
|
78 // log when it is dumped during a crash. |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
79 template <class T> class EventLogBase : public EventLog { |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
80 template <class X> class EventRecord { |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
81 public: |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
82 jlong timestamp; |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
83 Thread* thread; |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
84 X data; |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
85 }; |
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 protected: |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
88 Mutex _mutex; |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
89 const char* _name; |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
90 int _length; |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
91 int _index; |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
92 int _count; |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
93 EventRecord<T>* _records; |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
94 |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
95 public: |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
96 EventLogBase<T>(const char* name, int length = LogEventsBufferEntries): |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
97 _name(name), |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
98 _length(length), |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
99 _count(0), |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
100 _index(0), |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
101 _mutex(Mutex::event, name) { |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
102 _records = new EventRecord<T>[length]; |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
103 } |
0 | 104 |
4872
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
105 // 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
|
106 // 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
|
107 // while mutex is held. |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
108 int compute_log_index() { |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
109 int index = _index; |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
110 if (_count < _length) _count++; |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
111 _index++; |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
112 if (_index >= _length) _index = 0; |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
113 return index; |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
114 } |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
115 |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
116 bool should_log() { |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
117 // 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
|
118 // 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
|
119 return !VMError::fatal_error_in_progress(); |
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 |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
122 // Print the contents of the log |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
123 void print_log_on(outputStream* out); |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
124 |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
125 private: |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
126 void print_log_impl(outputStream* out); |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
127 |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
128 // 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
|
129 // be declared by subclasses. |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
130 void print(outputStream* out, T& e); |
0 | 131 |
4872
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
132 void print(outputStream* out, EventRecord<T>& e) { |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
133 out->print("Event: " INT64_FORMAT " ", e.timestamp); |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
134 if (e.thread != NULL) { |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
135 out->print("Thread " INTPTR_FORMAT " ", e.thread); |
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 print(out, e.data); |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
138 } |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
139 }; |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
140 |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
141 // 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
|
142 class StringLogMessage : public FormatBuffer<132> { |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
143 public: |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
144 // Wrap this buffer in a stringStream. |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
145 stringStream stream() { |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
146 return stringStream(_buf, sizeof(_buf)); |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
147 } |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
148 }; |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
149 |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
150 // 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
|
151 class StringEventLog : public EventLogBase<StringLogMessage> { |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
152 public: |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
153 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
|
154 |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
155 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
|
156 if (!should_log()) return; |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
157 |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
158 jlong timestamp = os::javaTimeNanos() / NANOSECS_PER_MILLISEC; |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
159 MutexLockerEx ml(&_mutex, Mutex::_no_safepoint_check_flag); |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
160 int index = compute_log_index(); |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
161 _records[index].thread = thread; |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
162 _records[index].timestamp = timestamp; |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
163 _records[index].data.printv(format, ap); |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
164 } |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
165 |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
166 void log(Thread* thread, const char* format, ...) { |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
167 va_list ap; |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
168 va_start(ap, format); |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
169 logv(thread, format, ap); |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
170 va_end(ap); |
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 |
0 | 173 }; |
174 | |
4872
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 |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
177 class Events : AllStatic { |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
178 friend class EventLog; |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
179 |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
180 private: |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
181 static EventLog* _logs; |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
182 |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
183 // 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
|
184 static StringEventLog* _messages; |
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 // 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
|
187 // throws and implicit exceptions. |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
188 static StringEventLog* _exceptions; |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
189 |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
190 // Deoptization related messages |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
191 static StringEventLog* _deopt_messages; |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
192 |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
193 public: |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
194 static void print_all(outputStream* out); |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
195 |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
196 static void print() { |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
197 print_all(tty); |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
198 } |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
199 |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
200 // 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
|
201 static void log(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 // Log exception related message |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
204 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
|
205 |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
206 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
|
207 |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
208 // Register default loggers |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
209 static void init(); |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
210 }; |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
211 |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
212 |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
213 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
|
214 if (LogEvents) { |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
215 va_list ap; |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
216 va_start(ap, format); |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
217 _messages->logv(thread, format, ap); |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
218 va_end(ap); |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
219 } |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
220 } |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
221 |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
222 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
|
223 if (LogEvents) { |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
224 va_list ap; |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
225 va_start(ap, format); |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
226 _exceptions->logv(thread, format, ap); |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
227 va_end(ap); |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
228 } |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
229 } |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
230 |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
231 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
|
232 if (LogEvents) { |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
233 va_list ap; |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
234 va_start(ap, format); |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
235 _deopt_messages->logv(thread, format, ap); |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
236 va_end(ap); |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
237 } |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
238 } |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
239 |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
240 |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
241 template <class T> |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
242 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
|
243 if (ThreadLocalStorage::get_thread_slow() == NULL) { |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
244 // 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
|
245 print_log_impl(out); |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
246 } else { |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
247 MutexLockerEx ml(&_mutex, Mutex::_no_safepoint_check_flag); |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
248 print_log_impl(out); |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
249 } |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
250 } |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
251 |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
252 // 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
|
253 template <class T> |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
254 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
|
255 out->print_cr("%s (%d events):", _name, _count); |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
256 if (_count == 0) { |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
257 out->print_cr("No events"); |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
258 return; |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
259 } |
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 if (_count < _length) { |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
262 for (int i = 0; i < _count; 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 } else { |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
266 for (int i = _index; i < _length; i++) { |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
267 print(out, _records[i]); |
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 for (int i = 0; i < _index; i++) { |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
270 print(out, _records[i]); |
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 } |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
273 out->cr(); |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
274 } |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
275 |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
276 // Implement a printing routine for the StringLogMessage |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
277 template <> |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
278 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
|
279 out->print_raw(lm); |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
280 out->cr(); |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
281 } |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
282 |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
283 // 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
|
284 // These end up in the default log. |
0 | 285 class EventMark : public StackObj { |
4872
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
286 StringLogMessage _buffer; |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
287 |
0 | 288 public: |
289 // log a begin event, format as printf | |
4872
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
290 EventMark(const char* format, ...); |
0 | 291 // log an end event |
4872
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
1972
diff
changeset
|
292 ~EventMark(); |
0 | 293 }; |
294 | |
1972 | 295 #endif // SHARE_VM_UTILITIES_EVENTS_HPP |