X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=base%2Ftrace.hh;h=5e14f1bfff7ce354217f1d741a4e164d12cc48d3;hb=9f584bcc6f247b844dc699bab38c684128c5afd2;hp=60ea015ea5aaa0f8e7e1bfab93e94f489bb949ad;hpb=2f316082e44259feb0bbd8e933d736e37244f3b7;p=gem5.git diff --git a/base/trace.hh b/base/trace.hh index 60ea015ea..5e14f1bff 100644 --- a/base/trace.hh +++ b/base/trace.hh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001-2004 The Regents of The University of Michigan + * Copyright (c) 2001-2005 The Regents of The University of Michigan * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -26,14 +26,15 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef __TRACE_HH__ -#define __TRACE_HH__ +#ifndef __BASE_TRACE_HH__ +#define __BASE_TRACE_HH__ #include #include "base/cprintf.hh" +#include "base/match.hh" #include "sim/host.hh" -#include "sim/universe.hh" +#include "sim/root.hh" #ifndef TRACING_ON #ifndef NDEBUG @@ -69,7 +70,7 @@ namespace Trace { class Record { protected: - Tick cycle; + Tick cycle; Record(Tick _cycle) : cycle(_cycle) @@ -101,15 +102,17 @@ namespace Trace { virtual void dump(std::ostream &); }; - class RawDataRecord : public Record + class DataRecord : public Record { private: + const std::string &name; uint8_t *data; int len; public: - RawDataRecord(Tick cycle, const void *_data, int _len); - virtual ~RawDataRecord(); + DataRecord(Tick cycle, const std::string &name, + const void *_data, int _len); + virtual ~DataRecord(); virtual void dump(std::ostream &); }; @@ -135,30 +138,35 @@ namespace Trace { extern Log theLog; - extern int dprintf_ignore_size; - - bool - dprintf_ignore_name(const std::string &name); + extern ObjectMatch ignore; inline void dprintf(const char *format, cp::ArgList &args, Tick cycle, const std::string &name) { - if (!dprintf_ignore_size || name.empty() || !dprintf_ignore_name(name)) + if (name.empty() || !ignore.match(name)) theLog.append(new Trace::PrintfRecord(format, args, cycle, name)); } inline void - rawDump(const void *data, int len) + dataDump(Tick cycle, const std::string &name, const void *data, int len) { - theLog.append(new Trace::RawDataRecord(curTick, data, len)); + theLog.append(new Trace::DataRecord(cycle, name, data, len)); } extern const std::string DefaultName; }; -inline const std::string &name() { return Trace::DefaultName; } +// 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 +struct StringWrap +{ + std::string str; + StringWrap(const std::string &s) : str(s) {} + const std::string &operator()() const { return str; } +}; +inline const std::string &name() { return Trace::DefaultName; } std::ostream &DebugOut(); // @@ -180,7 +188,7 @@ std::ostream &DebugOut(); #define DDUMP(x, data, count) \ do { \ if (Trace::IsOn(Trace::x)) \ - Trace::rawDump(data, count); \ + Trace::dataDump(curTick, name(), data, count); \ } while (0) #define __dprintf(cycle, name, format, args...) \ @@ -195,7 +203,7 @@ do { \ #define DPRINTFR(x, args...) \ do { \ if (Trace::IsOn(Trace::x)) \ - __dprintf((Tick)-1, string(), args, cp::ArgListNull()); \ + __dprintf((Tick)-1, std::string(), args, cp::ArgListNull()); \ } while (0) #define DPRINTFN(args...) \ @@ -220,4 +228,4 @@ do { \ #endif // TRACING_ON -#endif // __TRACE_HH__ +#endif // __BASE_TRACE_HH__