O3PCU: Split loads and stores that cross cache line boundaries.
[gem5.git] / src / cpu / nativetrace.hh
index 48395792d08a959d7785c5e4386f42d612d733b2..6ad6b0242a897505aa30d97704352e3bc3979218 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001-2005 The Regents of The University of Michigan
+ * Copyright (c) 2006-2009 The Regents of The University of Michigan
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *
- * Authors: Steve Reinhardt
- *          Nathan Binkert
+ * Authors: Gabe Black
  */
 
-#ifndef __NATIVETRACE_HH__
-#define __NATIVETRACE_HH__
+#ifndef __CPU_NATIVETRACE_HH__
+#define __CPU_NATIVETRACE_HH__
 
+#include <errno.h>
+#include <unistd.h>
+
+#include "base/socket.hh"
 #include "base/trace.hh"
+#include "base/types.hh"
+#include "cpu/exetrace.hh"
 #include "cpu/static_inst.hh"
-#include "sim/host.hh"
-#include "sim/insttracer.hh"
 
 class ThreadContext;
 
-
 namespace Trace {
 
 class NativeTrace;
 
-class NativeTraceRecord : public InstRecord
+class NativeTraceRecord : public ExeTracerRecord
 {
   protected:
     NativeTrace * parent;
 
-    bool
-    checkIntReg(const char * regName, int index, int size);
-
-    bool
-    checkPC(const char * regName, int size);
-
   public:
     NativeTraceRecord(NativeTrace * _parent,
                Tick _when, ThreadContext *_thread,
-               const StaticInstPtr &_staticInst, Addr _pc, bool spec)
-        : InstRecord(_when, _thread, _staticInst, _pc, spec), parent(_parent)
+               const StaticInstPtr _staticInst, Addr _pc, bool spec,
+               const StaticInstPtr _macroStaticInst = NULL, MicroPC _upc = 0)
+        : ExeTracerRecord(_when, _thread, _staticInst, _pc, spec,
+                _macroStaticInst, _upc),
+        parent(_parent)
     {
     }
 
     void dump();
 };
 
-class NativeTrace : public InstTracer
+class NativeTrace : public ExeTracer
 {
   protected:
     int fd;
@@ -75,22 +74,51 @@ class NativeTrace : public InstTracer
 
   public:
 
-    NativeTrace(const std::string & name);
+    NativeTrace(const Params *p);
+    virtual ~NativeTrace() {}
 
     NativeTraceRecord *
     getInstRecord(Tick when, ThreadContext *tc,
-            const StaticInstPtr staticInst, Addr pc)
+            const StaticInstPtr staticInst, Addr pc,
+            const StaticInstPtr macroStaticInst = NULL, MicroPC upc = 0)
     {
         if (tc->misspeculating())
             return NULL;
 
         return new NativeTraceRecord(this, when, tc,
-                staticInst, pc, tc->misspeculating());
+                staticInst, pc, tc->misspeculating(), macroStaticInst, upc);
+    }
+
+    template<class T>
+    bool
+    checkReg(const char * regName, T &val, T &realVal)
+    {
+        if(val != realVal)
+        {
+            DPRINTFN("Register %s should be %#x but is %#x.\n",
+                    regName, realVal, val);
+            return false;
+        }
+        return true;
+    }
+
+    void
+    read(void *ptr, size_t size)
+    {
+        size_t soFar = 0;
+        while (soFar < size) {
+            size_t res = ::read(fd, (uint8_t *)ptr + soFar, size - soFar);
+            if (res < 0)
+                panic("Read call failed! %s\n", strerror(errno));
+            else
+                soFar += res;
+        }
     }
 
-    friend class NativeTraceRecord;
+    virtual void
+    check(NativeTraceRecord *record) = 0;
 };
 
-/* namespace Trace */ }
+} /* namespace Trace */
 
-#endif // __EXETRACE_HH__
+#endif // __CPU_NATIVETRACE_HH__