cpu: Support trace termination in BaseTrafficGen
[gem5.git] / src / cpu / nativetrace.hh
index 6ad6b0242a897505aa30d97704352e3bc3979218..528e3bf65860c8a338ad291d139a460c6204a471 100644 (file)
 #ifndef __CPU_NATIVETRACE_HH__
 #define __CPU_NATIVETRACE_HH__
 
-#include <errno.h>
 #include <unistd.h>
 
+#include <cerrno>
+
 #include "base/socket.hh"
 #include "base/trace.hh"
 #include "base/types.hh"
@@ -54,10 +55,9 @@ class NativeTraceRecord : public ExeTracerRecord
   public:
     NativeTraceRecord(NativeTrace * _parent,
                Tick _when, ThreadContext *_thread,
-               const StaticInstPtr _staticInst, Addr _pc, bool spec,
-               const StaticInstPtr _macroStaticInst = NULL, MicroPC _upc = 0)
-        : ExeTracerRecord(_when, _thread, _staticInst, _pc, spec,
-                _macroStaticInst, _upc),
+               const StaticInstPtr _staticInst, TheISA::PCState _pc,
+               const StaticInstPtr _macroStaticInst = NULL)
+        : ExeTracerRecord(_when, _thread, _staticInst, _pc, _macroStaticInst),
         parent(_parent)
     {
     }
@@ -79,21 +79,18 @@ class NativeTrace : public ExeTracer
 
     NativeTraceRecord *
     getInstRecord(Tick when, ThreadContext *tc,
-            const StaticInstPtr staticInst, Addr pc,
-            const StaticInstPtr macroStaticInst = NULL, MicroPC upc = 0)
+            const StaticInstPtr staticInst, TheISA::PCState pc,
+            const StaticInstPtr macroStaticInst = NULL)
     {
-        if (tc->misspeculating())
-            return NULL;
-
         return new NativeTraceRecord(this, when, tc,
-                staticInst, pc, tc->misspeculating(), macroStaticInst, upc);
+                staticInst, pc, macroStaticInst);
     }
 
     template<class T>
     bool
     checkReg(const char * regName, T &val, T &realVal)
     {
-        if(val != realVal)
+        if (val != realVal)
         {
             DPRINTFN("Register %s should be %#x but is %#x.\n",
                     regName, realVal, val);
@@ -107,7 +104,7 @@ class NativeTrace : public ExeTracer
     {
         size_t soFar = 0;
         while (soFar < size) {
-            size_t res = ::read(fd, (uint8_t *)ptr + soFar, size - soFar);
+            ssize_t res = ::read(fd, (uint8_t *)ptr + soFar, size - soFar);
             if (res < 0)
                 panic("Read call failed! %s\n", strerror(errno));
             else
@@ -119,6 +116,6 @@ class NativeTrace : public ExeTracer
     check(NativeTraceRecord *record) = 0;
 };
 
-} /* namespace Trace */
+} // namespace Trace
 
 #endif // __CPU_NATIVETRACE_HH__