Mercurial > hg > graal-jvmci-8
comparison src/share/vm/utilities/events.hpp @ 17937:78bbf4d43a14
8037816: Fix for 8036122 breaks build with Xcode5/clang
8043029: Change 8037816 breaks HS build with older GCC versions which don't support diagnostic pragmas
8043164: Format warning in traceStream.hpp
Summary: Backport of main fix + two corrections, enables clang compilation, turns on format attributes, corrects/mutes warnings
Reviewed-by: kvn, coleenp, iveresov, twisti
author | drchase |
---|---|
date | Thu, 22 May 2014 15:52:41 -0400 |
parents | f9be75d21404 |
children |
comparison
equal
deleted
inserted
replaced
17935:7384f6a12fc1 | 17937:78bbf4d43a14 |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. | 2 * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * | 4 * |
5 * This code is free software; you can redistribute it and/or modify it | 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 | 6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
126 void print(outputStream* out, T& e); | 126 void print(outputStream* out, T& e); |
127 | 127 |
128 void print(outputStream* out, EventRecord<T>& e) { | 128 void print(outputStream* out, EventRecord<T>& e) { |
129 out->print("Event: %.3f ", e.timestamp); | 129 out->print("Event: %.3f ", e.timestamp); |
130 if (e.thread != NULL) { | 130 if (e.thread != NULL) { |
131 out->print("Thread " INTPTR_FORMAT " ", e.thread); | 131 out->print("Thread " INTPTR_FORMAT " ", p2i(e.thread)); |
132 } | 132 } |
133 print(out, e.data); | 133 print(out, e.data); |
134 } | 134 } |
135 }; | 135 }; |
136 | 136 |
146 // A simple ring buffer of fixed size text messages. | 146 // A simple ring buffer of fixed size text messages. |
147 class StringEventLog : public EventLogBase<StringLogMessage> { | 147 class StringEventLog : public EventLogBase<StringLogMessage> { |
148 public: | 148 public: |
149 StringEventLog(const char* name, int count = LogEventsBufferEntries) : EventLogBase<StringLogMessage>(name, count) {} | 149 StringEventLog(const char* name, int count = LogEventsBufferEntries) : EventLogBase<StringLogMessage>(name, count) {} |
150 | 150 |
151 void logv(Thread* thread, const char* format, va_list ap) { | 151 void logv(Thread* thread, const char* format, va_list ap) ATTRIBUTE_PRINTF(3, 0) { |
152 if (!should_log()) return; | 152 if (!should_log()) return; |
153 | 153 |
154 double timestamp = fetch_timestamp(); | 154 double timestamp = fetch_timestamp(); |
155 MutexLockerEx ml(&_mutex, Mutex::_no_safepoint_check_flag); | 155 MutexLockerEx ml(&_mutex, Mutex::_no_safepoint_check_flag); |
156 int index = compute_log_index(); | 156 int index = compute_log_index(); |
157 _records[index].thread = thread; | 157 _records[index].thread = thread; |
158 _records[index].timestamp = timestamp; | 158 _records[index].timestamp = timestamp; |
159 _records[index].data.printv(format, ap); | 159 _records[index].data.printv(format, ap); |
160 } | 160 } |
161 | 161 |
162 void log(Thread* thread, const char* format, ...) { | 162 void log(Thread* thread, const char* format, ...) ATTRIBUTE_PRINTF(3, 4) { |
163 va_list ap; | 163 va_list ap; |
164 va_start(ap, format); | 164 va_start(ap, format); |
165 logv(thread, format, ap); | 165 logv(thread, format, ap); |
166 va_end(ap); | 166 va_end(ap); |
167 } | 167 } |
191 | 191 |
192 // Dump all events to the tty | 192 // Dump all events to the tty |
193 static void print(); | 193 static void print(); |
194 | 194 |
195 // Logs a generic message with timestamp and format as printf. | 195 // Logs a generic message with timestamp and format as printf. |
196 static void log(Thread* thread, const char* format, ...); | 196 static void log(Thread* thread, const char* format, ...) ATTRIBUTE_PRINTF(2, 3); |
197 | 197 |
198 // Log exception related message | 198 // Log exception related message |
199 static void log_exception(Thread* thread, const char* format, ...); | 199 static void log_exception(Thread* thread, const char* format, ...) ATTRIBUTE_PRINTF(2, 3); |
200 | 200 |
201 static void log_deopt_message(Thread* thread, const char* format, ...); | 201 static void log_deopt_message(Thread* thread, const char* format, ...) ATTRIBUTE_PRINTF(2, 3); |
202 | 202 |
203 // Register default loggers | 203 // Register default loggers |
204 static void init(); | 204 static void init(); |
205 }; | 205 }; |
206 | |
207 | 206 |
208 inline void Events::log(Thread* thread, const char* format, ...) { | 207 inline void Events::log(Thread* thread, const char* format, ...) { |
209 if (LogEvents) { | 208 if (LogEvents) { |
210 va_list ap; | 209 va_list ap; |
211 va_start(ap, format); | 210 va_start(ap, format); |
281 class EventMark : public StackObj { | 280 class EventMark : public StackObj { |
282 StringLogMessage _buffer; | 281 StringLogMessage _buffer; |
283 | 282 |
284 public: | 283 public: |
285 // log a begin event, format as printf | 284 // log a begin event, format as printf |
286 EventMark(const char* format, ...); | 285 EventMark(const char* format, ...) ATTRIBUTE_PRINTF(2, 3); |
287 // log an end event | 286 // log an end event |
288 ~EventMark(); | 287 ~EventMark(); |
289 }; | 288 }; |
290 | 289 |
291 #endif // SHARE_VM_UTILITIES_EVENTS_HPP | 290 #endif // SHARE_VM_UTILITIES_EVENTS_HPP |