/*
- * Copyright (c) 2003 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
* 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 <vector>
#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
#endif
#endif
-#include "base/trace_flags.hh"
+#include "base/traceflags.hh"
namespace Trace {
class Record
{
protected:
- Tick cycle;
+ Tick cycle;
Record(Tick _cycle)
: cycle(_cycle)
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 uint8_t *_data, int _len);
- virtual ~RawDataRecord();
+ DataRecord(Tick cycle, const std::string &name,
+ const void *_data, int _len);
+ virtual ~DataRecord();
virtual void dump(std::ostream &);
};
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 uint8_t *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();
//
#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...) \
#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...) \
#endif // TRACING_ON
-#endif // __TRACE_HH__
+#endif // __BASE_TRACE_HH__