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