1/* 2 * Copyright (c) 2001-2006 The Regents of The University of Michigan 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions are 7 * met: redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer; --- 18 unchanged lines hidden (view full) --- 27 * 28 * Authors: Nathan Binkert 29 * Steve Reinhardt 30 */ 31 32#ifndef __BASE_TRACE_HH__ 33#define __BASE_TRACE_HH__ 34 |
35#include <string> |
36#include <vector> 37 38#include "base/cprintf.hh" 39#include "base/match.hh" |
40#include "base/traceflags.hh" |
41#include "sim/host.hh" 42#include "sim/root.hh" 43 |
44namespace Trace { 45 |
46std::ostream &output(); 47void setOutput(const std::string &filename); |
48 |
49extern bool enabled; 50typedef std::vector<bool> FlagVec; 51extern FlagVec flags; 52inline bool IsOn(int t) { return flags[t]; } 53bool changeFlag(const char *str, bool value); 54void dumpStatus(); |
55 |
56extern ObjectMatch ignore; 57extern const std::string DefaultName; |
58 |
59void dprintf(Tick when, const std::string &name, const char *format, 60 CPRINTF_DECLARATION); 61void dump(Tick when, const std::string &name, const void *data, int len); |
62 |
63/* namespace Trace */ } |
64 |
65// This silly little class allows us to wrap a string in a functor 66// object so that we can give a name() that DPRINTF will like 67struct StringWrap 68{ 69 std::string str; 70 StringWrap(const std::string &s) : str(s) {} 71 const std::string &operator()() const { return str; } 72}; --- 11 unchanged lines hidden (view full) --- 84// 85 86#if TRACING_ON 87 88#define DTRACE(x) (Trace::IsOn(Trace::x) && Trace::enabled) 89 90#define DDUMP(x, data, count) do { \ 91 if (DTRACE(x)) \ |
92 Trace::dump(curTick, name(), data, count); \ |
93} while (0) 94 95#define DPRINTF(x, ...) do { \ 96 if (DTRACE(x)) \ 97 Trace::dprintf(curTick, name(), __VA_ARGS__); \ 98} while (0) 99 100#define DPRINTFR(x, ...) do { \ 101 if (DTRACE(x)) \ 102 Trace::dprintf((Tick)-1, std::string(), __VA_ARGS__); \ 103} while (0) 104 |
105#define DDUMPN(data, count) do { \ 106 Trace::dump(curTick, name(), data, count); \ 107} while (0) 108 |
109#define DPRINTFN(...) do { \ 110 Trace::dprintf(curTick, name(), __VA_ARGS__); \ 111} while (0) 112 113#define DPRINTFNR(...) do { \ 114 Trace::dprintf((Tick)-1, string(), __VA_ARGS__); \ 115} while (0) 116 117#else // !TRACING_ON 118 119#define DTRACE(x) (false) |
120#define DDUMP(x, data, count) do {} while (0) |
121#define DPRINTF(x, ...) do {} while (0) 122#define DPRINTFR(...) do {} while (0) |
123#define DDUMPN(data, count) do {} while (0) |
124#define DPRINTFN(...) do {} while (0) 125#define DPRINTFNR(...) do {} while (0) |
126 127#endif // TRACING_ON 128 129#endif // __BASE_TRACE_HH__ |