src/share/vm/trace/traceStream.hpp

Thu, 22 May 2014 15:52:41 -0400

author
drchase
date
Thu, 22 May 2014 15:52:41 -0400
changeset 6680
78bbf4d43a14
parent 5237
f2110083203d
child 6876
710a3c8b516e
child 7367
82d3e7b5277a
permissions
-rw-r--r--

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

sla@5237 1 /*
drchase@6680 2 * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved.
sla@5237 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
sla@5237 4 *
sla@5237 5 * This code is free software; you can redistribute it and/or modify it
sla@5237 6 * under the terms of the GNU General Public License version 2 only, as
sla@5237 7 * published by the Free Software Foundation.
sla@5237 8 *
sla@5237 9 * This code is distributed in the hope that it will be useful, but WITHOUT
sla@5237 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
sla@5237 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
sla@5237 12 * version 2 for more details (a copy is included in the LICENSE file that
sla@5237 13 * accompanied this code).
sla@5237 14 *
sla@5237 15 * You should have received a copy of the GNU General Public License version
sla@5237 16 * 2 along with this work; if not, write to the Free Software Foundation,
sla@5237 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
sla@5237 18 *
sla@5237 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
sla@5237 20 * or visit www.oracle.com if you need additional information or have any
sla@5237 21 * questions.
sla@5237 22 *
sla@5237 23 */
sla@5237 24
sla@5237 25 #ifndef SHARE_VM_TRACE_TRACESTREAM_HPP
sla@5237 26 #define SHARE_VM_TRACE_TRACESTREAM_HPP
sla@5237 27
sla@5237 28 #include "utilities/macros.hpp"
sla@5237 29
sla@5237 30 #if INCLUDE_TRACE
sla@5237 31
sla@5237 32 #include "oops/klass.hpp"
sla@5237 33 #include "oops/method.hpp"
sla@5237 34 #include "oops/symbol.hpp"
sla@5237 35 #include "utilities/ostream.hpp"
sla@5237 36
sla@5237 37 class TraceStream : public StackObj {
sla@5237 38 private:
sla@5237 39 outputStream& _st;
sla@5237 40
sla@5237 41 public:
sla@5237 42 TraceStream(outputStream& stream): _st(stream) {}
sla@5237 43
sla@5237 44 void print_val(const char* label, u1 val) {
sla@5237 45 _st.print("%s = "UINT32_FORMAT, label, val);
sla@5237 46 }
sla@5237 47
sla@5237 48 void print_val(const char* label, u2 val) {
sla@5237 49 _st.print("%s = "UINT32_FORMAT, label, val);
sla@5237 50 }
sla@5237 51
sla@5237 52 void print_val(const char* label, s2 val) {
sla@5237 53 _st.print("%s = "INT32_FORMAT, label, val);
sla@5237 54 }
sla@5237 55
sla@5237 56 void print_val(const char* label, u4 val) {
sla@5237 57 _st.print("%s = "UINT32_FORMAT, label, val);
sla@5237 58 }
sla@5237 59
sla@5237 60 void print_val(const char* label, s4 val) {
sla@5237 61 _st.print("%s = "INT32_FORMAT, label, val);
sla@5237 62 }
sla@5237 63
sla@5237 64 void print_val(const char* label, u8 val) {
sla@5237 65 _st.print("%s = "UINT64_FORMAT, label, val);
sla@5237 66 }
sla@5237 67
sla@5237 68 void print_val(const char* label, s8 val) {
drchase@6680 69 _st.print("%s = "INT64_FORMAT, label, (int64_t) val);
sla@5237 70 }
sla@5237 71
sla@5237 72 void print_val(const char* label, bool val) {
sla@5237 73 _st.print("%s = %s", label, val ? "true" : "false");
sla@5237 74 }
sla@5237 75
sla@5237 76 void print_val(const char* label, float val) {
sla@5237 77 _st.print("%s = %f", label, val);
sla@5237 78 }
sla@5237 79
sla@5237 80 void print_val(const char* label, double val) {
sla@5237 81 _st.print("%s = %f", label, val);
sla@5237 82 }
sla@5237 83
sla@5237 84 // Caller is machine generated code located in traceEventClasses.hpp
sla@5237 85 // Event<TraceId>::writeEvent() (pseudocode) contains the
sla@5237 86 // necessary ResourceMark for the resource allocations below.
sla@5237 87 // See traceEventClasses.xsl for details.
sla@5237 88 void print_val(const char* label, const Klass* const val) {
sla@5237 89 const char* description = "NULL";
sla@5237 90 if (val != NULL) {
sla@5237 91 Symbol* name = val->name();
sla@5237 92 if (name != NULL) {
sla@5237 93 description = name->as_C_string();
sla@5237 94 }
sla@5237 95 }
sla@5237 96 _st.print("%s = %s", label, description);
sla@5237 97 }
sla@5237 98
sla@5237 99 // Caller is machine generated code located in traceEventClasses.hpp
sla@5237 100 // Event<TraceId>::writeEvent() (pseudocode) contains the
sla@5237 101 // necessary ResourceMark for the resource allocations below.
sla@5237 102 // See traceEventClasses.xsl for details.
sla@5237 103 void print_val(const char* label, const Method* const val) {
sla@5237 104 const char* description = "NULL";
sla@5237 105 if (val != NULL) {
sla@5237 106 description = val->name_and_sig_as_C_string();
sla@5237 107 }
sla@5237 108 _st.print("%s = %s", label, description);
sla@5237 109 }
sla@5237 110
sla@5237 111 void print_val(const char* label, const char* val) {
sla@5237 112 _st.print("%s = '%s'", label, val);
sla@5237 113 }
sla@5237 114
sla@5237 115 void print(const char* val) {
drchase@6680 116 _st.print("%s", val);
sla@5237 117 }
sla@5237 118 };
sla@5237 119
sla@5237 120 #endif /* INCLUDE_TRACE */
sla@5237 121 #endif /* SHARE_VM_TRACE_TRACESTREAM_HPP */

mercurial