Thu, 22 May 2014 15:52:41 -0400
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
1 /*
2 * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved.
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 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
25 #ifndef SHARE_VM_TRACE_TRACESTREAM_HPP
26 #define SHARE_VM_TRACE_TRACESTREAM_HPP
28 #include "utilities/macros.hpp"
30 #if INCLUDE_TRACE
32 #include "oops/klass.hpp"
33 #include "oops/method.hpp"
34 #include "oops/symbol.hpp"
35 #include "utilities/ostream.hpp"
37 class TraceStream : public StackObj {
38 private:
39 outputStream& _st;
41 public:
42 TraceStream(outputStream& stream): _st(stream) {}
44 void print_val(const char* label, u1 val) {
45 _st.print("%s = "UINT32_FORMAT, label, val);
46 }
48 void print_val(const char* label, u2 val) {
49 _st.print("%s = "UINT32_FORMAT, label, val);
50 }
52 void print_val(const char* label, s2 val) {
53 _st.print("%s = "INT32_FORMAT, label, val);
54 }
56 void print_val(const char* label, u4 val) {
57 _st.print("%s = "UINT32_FORMAT, label, val);
58 }
60 void print_val(const char* label, s4 val) {
61 _st.print("%s = "INT32_FORMAT, label, val);
62 }
64 void print_val(const char* label, u8 val) {
65 _st.print("%s = "UINT64_FORMAT, label, val);
66 }
68 void print_val(const char* label, s8 val) {
69 _st.print("%s = "INT64_FORMAT, label, (int64_t) val);
70 }
72 void print_val(const char* label, bool val) {
73 _st.print("%s = %s", label, val ? "true" : "false");
74 }
76 void print_val(const char* label, float val) {
77 _st.print("%s = %f", label, val);
78 }
80 void print_val(const char* label, double val) {
81 _st.print("%s = %f", label, val);
82 }
84 // Caller is machine generated code located in traceEventClasses.hpp
85 // Event<TraceId>::writeEvent() (pseudocode) contains the
86 // necessary ResourceMark for the resource allocations below.
87 // See traceEventClasses.xsl for details.
88 void print_val(const char* label, const Klass* const val) {
89 const char* description = "NULL";
90 if (val != NULL) {
91 Symbol* name = val->name();
92 if (name != NULL) {
93 description = name->as_C_string();
94 }
95 }
96 _st.print("%s = %s", label, description);
97 }
99 // Caller is machine generated code located in traceEventClasses.hpp
100 // Event<TraceId>::writeEvent() (pseudocode) contains the
101 // necessary ResourceMark for the resource allocations below.
102 // See traceEventClasses.xsl for details.
103 void print_val(const char* label, const Method* const val) {
104 const char* description = "NULL";
105 if (val != NULL) {
106 description = val->name_and_sig_as_C_string();
107 }
108 _st.print("%s = %s", label, description);
109 }
111 void print_val(const char* label, const char* val) {
112 _st.print("%s = '%s'", label, val);
113 }
115 void print(const char* val) {
116 _st.print("%s", val);
117 }
118 };
120 #endif /* INCLUDE_TRACE */
121 #endif /* SHARE_VM_TRACE_TRACESTREAM_HPP */