Support for FP Paired Single Operations
[gem5.git] / base / trace.hh
index 9e595276549b4dcaf2fc257608dee9179feafe29..5e14f1bfff7ce354217f1d741a4e164d12cc48d3 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * 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
@@ -43,7 +44,7 @@
 #endif
 #endif
 
-#include "base/trace_flags.hh"
+#include "base/traceflags.hh"
 
 namespace Trace {
 
@@ -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 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 &);
     };
@@ -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 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();
 
 //
@@ -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__