aoqi@0: /* aoqi@0: * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved. aoqi@0: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. aoqi@0: * aoqi@0: * This code is free software; you can redistribute it and/or modify it aoqi@0: * under the terms of the GNU General Public License version 2 only, as aoqi@0: * published by the Free Software Foundation. aoqi@0: * aoqi@0: * This code is distributed in the hope that it will be useful, but WITHOUT aoqi@0: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or aoqi@0: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License aoqi@0: * version 2 for more details (a copy is included in the LICENSE file that aoqi@0: * accompanied this code). aoqi@0: * aoqi@0: * You should have received a copy of the GNU General Public License version aoqi@0: * 2 along with this work; if not, write to the Free Software Foundation, aoqi@0: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. aoqi@0: * aoqi@0: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA aoqi@0: * or visit www.oracle.com if you need additional information or have any aoqi@0: * questions. aoqi@0: * aoqi@0: */ aoqi@0: aoqi@0: #ifndef SHARE_VM_TRACE_TRACESTREAM_HPP aoqi@0: #define SHARE_VM_TRACE_TRACESTREAM_HPP aoqi@0: aoqi@0: #include "utilities/macros.hpp" aoqi@0: aoqi@0: #if INCLUDE_TRACE aoqi@0: aoqi@0: #include "oops/klass.hpp" aoqi@0: #include "oops/method.hpp" aoqi@0: #include "oops/symbol.hpp" aoqi@0: #include "utilities/ostream.hpp" aoqi@0: aoqi@0: class TraceStream : public StackObj { aoqi@0: private: aoqi@0: outputStream& _st; aoqi@0: aoqi@0: public: aoqi@0: TraceStream(outputStream& stream): _st(stream) {} aoqi@0: aoqi@0: void print_val(const char* label, u1 val) { aoqi@0: _st.print("%s = "UINT32_FORMAT, label, val); aoqi@0: } aoqi@0: aoqi@0: void print_val(const char* label, u2 val) { aoqi@0: _st.print("%s = "UINT32_FORMAT, label, val); aoqi@0: } aoqi@0: aoqi@0: void print_val(const char* label, s2 val) { aoqi@0: _st.print("%s = "INT32_FORMAT, label, val); aoqi@0: } aoqi@0: aoqi@0: void print_val(const char* label, u4 val) { aoqi@0: _st.print("%s = "UINT32_FORMAT, label, val); aoqi@0: } aoqi@0: aoqi@0: void print_val(const char* label, s4 val) { aoqi@0: _st.print("%s = "INT32_FORMAT, label, val); aoqi@0: } aoqi@0: aoqi@0: void print_val(const char* label, u8 val) { aoqi@0: _st.print("%s = "UINT64_FORMAT, label, val); aoqi@0: } aoqi@0: aoqi@0: void print_val(const char* label, s8 val) { aoqi@0: _st.print("%s = "INT64_FORMAT, label, (int64_t) val); aoqi@0: } aoqi@0: aoqi@0: void print_val(const char* label, bool val) { aoqi@0: _st.print("%s = %s", label, val ? "true" : "false"); aoqi@0: } aoqi@0: aoqi@0: void print_val(const char* label, float val) { aoqi@0: _st.print("%s = %f", label, val); aoqi@0: } aoqi@0: aoqi@0: void print_val(const char* label, double val) { aoqi@0: _st.print("%s = %f", label, val); aoqi@0: } aoqi@0: aoqi@0: // Caller is machine generated code located in traceEventClasses.hpp aoqi@0: // Event::writeEvent() (pseudocode) contains the aoqi@0: // necessary ResourceMark for the resource allocations below. aoqi@0: // See traceEventClasses.xsl for details. aoqi@0: void print_val(const char* label, const Klass* const val) { aoqi@0: const char* description = "NULL"; aoqi@0: if (val != NULL) { aoqi@0: Symbol* name = val->name(); aoqi@0: if (name != NULL) { aoqi@0: description = name->as_C_string(); aoqi@0: } aoqi@0: } aoqi@0: _st.print("%s = %s", label, description); aoqi@0: } aoqi@0: aoqi@0: // Caller is machine generated code located in traceEventClasses.hpp aoqi@0: // Event::writeEvent() (pseudocode) contains the aoqi@0: // necessary ResourceMark for the resource allocations below. aoqi@0: // See traceEventClasses.xsl for details. aoqi@0: void print_val(const char* label, const Method* const val) { aoqi@0: const char* description = "NULL"; aoqi@0: if (val != NULL) { aoqi@0: description = val->name_and_sig_as_C_string(); aoqi@0: } aoqi@0: _st.print("%s = %s", label, description); aoqi@0: } aoqi@0: aoqi@0: void print_val(const char* label, const char* val) { aoqi@0: _st.print("%s = '%s'", label, val); aoqi@0: } aoqi@0: aoqi@0: void print(const char* val) { aoqi@0: _st.print("%s", val); aoqi@0: } aoqi@0: }; aoqi@0: aoqi@0: #endif /* INCLUDE_TRACE */ aoqi@0: #endif /* SHARE_VM_TRACE_TRACESTREAM_HPP */