Fixes to get MIPS_SE to compile.
[gem5.git] / src / cpu / o3 / thread_state.hh
index 1c81052042e72ff50c1074f5a204eb01b4b0d997..d8720b3ab90a9f69d694daa374c862dfc7b85757 100644 (file)
 #ifndef __CPU_O3_THREAD_STATE_HH__
 #define __CPU_O3_THREAD_STATE_HH__
 
-#include "arch/faults.hh"
-#include "arch/isa_traits.hh"
+#include "base/callback.hh"
+#include "base/output.hh"
 #include "cpu/thread_context.hh"
 #include "cpu/thread_state.hh"
+#include "sim/sim_exit.hh"
 
 class Event;
 class Process;
@@ -76,13 +77,26 @@ struct O3ThreadState : public ThreadState {
 
 #if FULL_SYSTEM
     O3ThreadState(O3CPU *_cpu, int _thread_num)
-        : ThreadState(-1, _thread_num),
-          inSyscall(0), trapPending(0)
-    { }
+        : ThreadState(_cpu, -1, _thread_num),
+          cpu(_cpu), inSyscall(0), trapPending(0)
+    {
+        if (cpu->params->profile) {
+            profile = new FunctionProfile(cpu->params->system->kernelSymtab);
+            Callback *cb =
+                new MakeCallback<O3ThreadState,
+                &O3ThreadState::dumpFuncProfile>(this);
+            registerExitCallback(cb);
+        }
+
+        // let's fill with a dummy node for now so we don't get a segfault
+        // on the first cycle when there's no node available.
+        static ProfileNode dummyNode;
+        profileNode = &dummyNode;
+        profilePC = 3;
+    }
 #else
-    O3ThreadState(O3CPU *_cpu, int _thread_num, Process *_process, int _asid,
-                  MemObject *mem)
-        : ThreadState(-1, _thread_num, _process, _asid, mem),
+    O3ThreadState(O3CPU *_cpu, int _thread_num, Process *_process, int _asid)
+        : ThreadState(_cpu, -1, _thread_num, _process, _asid),
           cpu(_cpu), inSyscall(0), trapPending(0)
     { }
 #endif
@@ -97,6 +111,14 @@ struct O3ThreadState : public ThreadState {
     /** Handles the syscall. */
     void syscall(int64_t callnum) { process->syscall(callnum, tc); }
 #endif
+
+#if FULL_SYSTEM
+    void dumpFuncProfile()
+    {
+        std::ostream *os = simout.create(csprintf("profile.%s.dat", cpu->name()));
+        profile->dump(tc, *os);
+    }
+#endif
 };
 
 #endif // __CPU_O3_THREAD_STATE_HH__