diff options
author | Nathan Binkert <binkertn@umich.edu> | 2007-02-10 15:14:50 -0800 |
---|---|---|
committer | Nathan Binkert <binkertn@umich.edu> | 2007-02-10 15:14:50 -0800 |
commit | 184decd1963a7f016231f7614b5e739ad514ed37 (patch) | |
tree | 255576eeee2401b9148aa9610559cc9b5e024807 /src/base/trace.hh | |
parent | 63a82400596b9331d1babe88624f97209286d0b9 (diff) | |
download | gem5-184decd1963a7f016231f7614b5e739ad514ed37.tar.xz |
Clean up tracing stuff more, get rid of the trace log since
its not all that useful. Fix a few bugs with python/C++
integration.
--HG--
extra : convert_revision : a706512f7dc8b0c88f1ff96fe35ab8fbf9548b78
Diffstat (limited to 'src/base/trace.hh')
-rw-r--r-- | src/base/trace.hh | 138 |
1 files changed, 23 insertions, 115 deletions
diff --git a/src/base/trace.hh b/src/base/trace.hh index dbe98a11b..8e380d8e1 100644 --- a/src/base/trace.hh +++ b/src/base/trace.hh @@ -32,132 +32,35 @@ #ifndef __BASE_TRACE_HH__ #define __BASE_TRACE_HH__ +#include <string> #include <vector> #include "base/cprintf.hh" #include "base/match.hh" +#include "base/traceflags.hh" #include "sim/host.hh" #include "sim/root.hh" -#include "base/traceflags.hh" - namespace Trace { - typedef std::vector<bool> FlagVec; - - extern FlagVec flags; - - extern std::ostream *dprintf_stream; - - inline bool - IsOn(int t) - { - return flags[t]; - } - - extern bool enabled; - - void dump(const uint8_t *data, int count); - - class Record - { - protected: - Tick cycle; - - Record(Tick _cycle) - : cycle(_cycle) - { - } - - public: - virtual ~Record() {} - - virtual void dump(std::ostream &) = 0; - }; - - class PrintfRecord : public Record - { - private: - const std::string &name; - const char *format; - CPrintfArgsList args; - - public: - PrintfRecord(Tick cycle, const std::string &_name, const char *_format, - CPRINTF_DECLARATION) - : Record(cycle), name(_name), format(_format), - args(VARARGS_ALLARGS) - { - } - - virtual ~PrintfRecord(); - - virtual void dump(std::ostream &); - }; - - class DataRecord : public Record - { - private: - const std::string &name; - uint8_t *data; - int len; +std::ostream &output(); +void setOutput(const std::string &filename); - public: - DataRecord(Tick cycle, const std::string &name, - const void *_data, int _len); - virtual ~DataRecord(); +extern bool enabled; +typedef std::vector<bool> FlagVec; +extern FlagVec flags; +inline bool IsOn(int t) { return flags[t]; } +bool changeFlag(const char *str, bool value); +void dumpStatus(); - virtual void dump(std::ostream &); - }; +extern ObjectMatch ignore; +extern const std::string DefaultName; - class Log - { - private: - int size; // number of records in log - Record **buffer; // array of 'size' Record ptrs (circular buf) - Record **nextRecPtr; // next slot to use in buffer - Record **wrapRecPtr; // &buffer[size], for quick wrap check +void dprintf(Tick when, const std::string &name, const char *format, + CPRINTF_DECLARATION); +void dump(Tick when, const std::string &name, const void *data, int len); - public: - Log(); - ~Log(); - - void init(int _size); - - void append(Record *); // append trace record to log - void dump(std::ostream &); // dump contents to stream - }; - - extern Log theLog; - - extern ObjectMatch ignore; - - inline void - dprintf(Tick when, const std::string &name, const char *format, - CPRINTF_DECLARATION) - { - if (!name.empty() && ignore.match(name)) - return; - - theLog.append(new Trace::PrintfRecord(when, name, format, - VARARGS_ALLARGS)); - } - - inline void - dataDump(Tick when, const std::string &name, const void *data, int len) - { - theLog.append(new Trace::DataRecord(when, name, data, len)); - } - - extern const std::string DefaultName; - -}; - -inline std::ostream & -DebugOut() -{ - return *Trace::dprintf_stream; -} +/* namespace Trace */ } // This silly little class allows us to wrap a string in a functor // object so that we can give a name() that DPRINTF will like @@ -186,7 +89,7 @@ inline const std::string &name() { return Trace::DefaultName; } #define DDUMP(x, data, count) do { \ if (DTRACE(x)) \ - Trace::dataDump(curTick, name(), data, count); \ + Trace::dump(curTick, name(), data, count); \ } while (0) #define DPRINTF(x, ...) do { \ @@ -199,6 +102,10 @@ inline const std::string &name() { return Trace::DefaultName; } Trace::dprintf((Tick)-1, std::string(), __VA_ARGS__); \ } while (0) +#define DDUMPN(data, count) do { \ + Trace::dump(curTick, name(), data, count); \ +} while (0) + #define DPRINTFN(...) do { \ Trace::dprintf(curTick, name(), __VA_ARGS__); \ } while (0) @@ -210,11 +117,12 @@ inline const std::string &name() { return Trace::DefaultName; } #else // !TRACING_ON #define DTRACE(x) (false) +#define DDUMP(x, data, count) do {} while (0) #define DPRINTF(x, ...) do {} while (0) #define DPRINTFR(...) do {} while (0) +#define DDUMPN(data, count) do {} while (0) #define DPRINTFN(...) do {} while (0) #define DPRINTFNR(...) do {} while (0) -#define DDUMP(x, data, count) do {} while (0) #endif // TRACING_ON |