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