diff options
Diffstat (limited to 'cpu/o3/thread_state.hh')
-rw-r--r-- | cpu/o3/thread_state.hh | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/cpu/o3/thread_state.hh b/cpu/o3/thread_state.hh index 3f1208ea0..28f488143 100644 --- a/cpu/o3/thread_state.hh +++ b/cpu/o3/thread_state.hh @@ -31,8 +31,11 @@ #include "arch/faults.hh" #include "arch/isa_traits.hh" +#include "base/callback.hh" +#include "base/output.hh" #include "cpu/exec_context.hh" #include "cpu/thread_state.hh" +#include "sim/sim_exit.hh" class Event; class Process; @@ -83,8 +86,22 @@ struct O3ThreadState : public ThreadState { #if FULL_SYSTEM O3ThreadState(FullCPU *_cpu, int _thread_num, FunctionalMemory *_mem) : ThreadState(-1, _thread_num, _mem), - inSyscall(0), trapPending(0) - { } + 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(FullCPU *_cpu, int _thread_num, Process *_process, int _asid) : ThreadState(-1, _thread_num, _process->getMemory(), _process, _asid), @@ -138,6 +155,14 @@ struct O3ThreadState : public ThreadState { /** Handles the syscall. */ void syscall() { process->syscall(xcProxy); } #endif + +#if FULL_SYSTEM + void dumpFuncProfile() + { + std::ostream *os = simout.create(csprintf("profile.%s.dat", cpu->name())); + profile->dump(xcProxy, *os); + } +#endif }; #endif // __CPU_O3_THREAD_STATE_HH__ |