1 /* 2 * Copyright (c) 2012, 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 */ 24 25 #ifndef SHARE_VM_TRACE_TRACESTREAM_HPP 26 #define SHARE_VM_TRACE_TRACESTREAM_HPP 27 28 #if INCLUDE_TRACE 29 30 #include "utilities/ostream.hpp" 31 #include "oops/methodOop.hpp" 32 #include "oops/klassOop.hpp" 33 34 class TraceStream : public StackObj { 35 private: 36 outputStream& _st; 37 38 public: 39 TraceStream(outputStream& stream): _st(stream) {} 40 41 void print_val(const char* label, u1 val) { 42 _st.print("%s = "UINT32_FORMAT, label, val); 43 } 44 45 void print_val(const char* label, u2 val) { 46 _st.print("%s = "UINT32_FORMAT, label, val); 47 } 48 49 void print_val(const char* label, s2 val) { 50 _st.print("%s = "INT32_FORMAT, label, val); 51 } 52 53 void print_val(const char* label, u4 val) { 54 _st.print("%s = "UINT32_FORMAT, label, val); 55 } 56 57 void print_val(const char* label, s4 val) { 58 _st.print("%s = "INT32_FORMAT, label, val); 59 } 60 61 void print_val(const char* label, u8 val) { 62 _st.print("%s = "UINT64_FORMAT, label, val); 63 } 64 65 void print_val(const char* label, s8 val) { 66 _st.print("%s = "INT64_FORMAT, label, val); 67 } 68 69 void print_val(const char* label, bool val) { 70 _st.print("%s = %s", label, val ? "true" : "false"); 71 } 72 73 void print_val(const char* label, float val) { 74 _st.print("%s = %f", label, val); 75 } 76 77 void print_val(const char* label, double val) { 78 _st.print("%s = %f", label, val); 79 } 80 81 void print_val(const char* label, klassOop& val) { 82 _st.print("%s = %s", label, val->print_string()); 83 } 84 85 void print_val(const char* label, methodOop& val) { 86 _st.print("%s = %s", label, val->name_and_sig_as_C_string()); 87 } 88 89 void print_val(const char* label, const char* val) { 90 _st.print("%s = '%s'", label, val); 91 } 92 93 void print(const char* val) { 94 _st.print(val); 95 } 96 }; 97 98 #endif 99 #endif