void suspend() override { setStatus(Suspended); }
void halt() override { setStatus(Halted); }
- void
- dumpFuncProfile() override
- {
- panic("%s not implemented.", __FUNCTION__);
- }
-
void
takeOverFrom(::ThreadContext *old_context) override
{
panic("%s not implemented.", __FUNCTION__);
}
- void
- profileClear() override
- {
- panic("%s not implemented.", __FUNCTION__);
- }
- void
- profileSample() override
- {
- panic("%s not implemented.", __FUNCTION__);
- }
-
void
copyArchRegs(::ThreadContext *tc) override
{
do_statistics_insts = Param.Bool(True,
"enable statistics pseudo instructions")
- profile = Param.Latency('0ns', "trace the kernel stack")
-
wait_for_remote_gdb = Param.Bool(False,
"Wait for a remote GDB connection");
#include "base/output.hh"
#include "base/trace.hh"
#include "cpu/checker/cpu.hh"
-#include "cpu/profile.hh"
#include "cpu/thread_context.hh"
#include "debug/Mwait.hh"
#include "debug/SyscallVerbose.hh"
_dataMasterId(p->system->getMasterId(this, "data")),
_taskId(ContextSwitchTaskId::Unknown), _pid(invldPid),
_switchedOut(p->switched_out), _cacheLineSize(p->system->cacheLineSize()),
- interrupts(p->interrupts), profileEvent(NULL),
- numThreads(p->numThreads), system(p->system),
+ interrupts(p->interrupts), numThreads(p->numThreads), system(p->system),
previousCycle(0), previousState(CPU_STATE_SLEEP),
functionTraceStream(nullptr), currentFunctionStart(0),
currentFunctionEnd(0), functionEntryTick(0),
}
}
- if (FullSystem) {
- if (params()->profile)
- profileEvent = new EventFunctionWrapper(
- [this]{ processProfileEvent(); },
- name());
- }
tracer = params()->tracer;
if (params()->isa.size() != numThreads) {
BaseCPU::~BaseCPU()
{
- delete profileEvent;
}
void
void
BaseCPU::startup()
{
- if (FullSystem) {
- if (!params()->switched_out && profileEvent)
- schedule(profileEvent, curTick());
- }
-
if (params()->progress_interval) {
new CPUProgressEvent(this, params()->progress_interval);
}
{
assert(!_switchedOut);
_switchedOut = true;
- if (profileEvent && profileEvent->scheduled())
- deschedule(profileEvent);
// Flush all TLBs in the CPU to avoid having stale translations if
// it gets switched in later.
}
oldCPU->interrupts.clear();
- if (FullSystem) {
- for (ThreadID i = 0; i < size; ++i)
- threadContexts[i]->profileClear();
-
- if (profileEvent)
- schedule(profileEvent, curTick());
- }
-
// All CPUs have an instruction and a data port, and the new CPU's
// ports are dangling while the old CPU has its ports connected
// already. Unbind the old CPU and then bind the ports of the one
}
}
-void
-BaseCPU::processProfileEvent()
-{
- ThreadID size = threadContexts.size();
-
- for (ThreadID i = 0; i < size; ++i)
- threadContexts[i]->profileSample();
-
- schedule(profileEvent, curTick() + params()->profile);
-}
-
void
BaseCPU::serialize(CheckpointOut &cp) const
{
return FullSystem && interrupts[tid]->checkInterrupts();
}
- void processProfileEvent();
- EventFunctionWrapper * profileEvent;
-
protected:
std::vector<ThreadContext *> threadContexts;
/// Set the status to Halted.
void halt() override { actualTC->halt(); }
- void dumpFuncProfile() override { actualTC->dumpFuncProfile(); }
-
void
takeOverFrom(ThreadContext *oldContext) override
{
Tick readLastActivate() override { return actualTC->readLastActivate(); }
Tick readLastSuspend() override { return actualTC->readLastSuspend(); }
- void profileClear() override { return actualTC->profileClear(); }
- void profileSample() override { return actualTC->profileSample(); }
-
// @todo: Do I need this?
void
copyArchRegs(ThreadContext *tc) override
updateComInstStats(head_inst);
if (FullSystem) {
- if (thread[tid]->profile) {
- thread[tid]->profilePC = head_inst->instAddr();
- ProfileNode *node = thread[tid]->profile->consume(
- thread[tid]->getTC(), head_inst->staticInst);
-
- if (node)
- thread[tid]->profileNode = node;
- }
if (CPA::available()) {
if (head_inst->isControl()) {
ThreadContext *tc = thread[tid]->getTC();
/** Set the status to Halted. */
void halt() override;
- /** Dumps the function profiling information.
- * @todo: Implement.
- */
- void dumpFuncProfile() override;
-
/** Takes over execution of a thread from another CPU. */
void takeOverFrom(ThreadContext *old_context) override;
/** Reads the last tick that this thread was suspended on. */
Tick readLastSuspend() override;
- /** Clears the function profiling information. */
- void profileClear() override;
- /** Samples the function profiling information. */
- void profileSample() override;
-
/** Copies the architectural registers from another TC into this TC. */
void copyArchRegs(ThreadContext *tc) override;
return thread->getVirtProxy();
}
-template <class Impl>
-void
-O3ThreadContext<Impl>::dumpFuncProfile()
-{
- thread->dumpFuncProfile();
-}
-
template <class Impl>
void
O3ThreadContext<Impl>::takeOverFrom(ThreadContext *old_context)
return thread->lastSuspend;
}
-template <class Impl>
-void
-O3ThreadContext<Impl>::profileClear()
-{
- thread->profileClear();
-}
-
-template <class Impl>
-void
-O3ThreadContext<Impl>::profileSample()
-{
- thread->profileSample();
-}
-
template <class Impl>
void
O3ThreadContext<Impl>::copyArchRegs(ThreadContext *tc)
#ifndef __CPU_O3_THREAD_STATE_HH__
#define __CPU_O3_THREAD_STATE_HH__
-#include "arch/stacktrace.hh"
#include "base/callback.hh"
#include "base/compiler.hh"
#include "base/output.hh"
class Event;
class FunctionalMemory;
-class FunctionProfile;
class Process;
-class ProfileNode;
/**
* Class that has various thread state, such as the status, the
comInstEventQueue("instruction-based event queue"),
noSquashFromTC(false), trapPending(false), tc(nullptr)
{
- if (!FullSystem)
- return;
-
- if (cpu->params()->profile) {
- profile = new FunctionProfile(
- m5::make_unique<TheISA::StackTrace>(),
- cpu->params()->system->workload->symtab(tc));
- 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;
}
void serialize(CheckpointOut &cp) const override
{
process->syscall(tc, fault);
}
-
- void dumpFuncProfile()
- {
- OutputStream *os(
- simout.create(csprintf("profile.%s.dat", cpu->name())));
- profile->dump(*os->stream());
- simout.close(os);
- }
};
#endif // __CPU_O3_THREAD_STATE_HH__
#include "cpu/simple/base.hh"
-#include "arch/stacktrace.hh"
#include "arch/utility.hh"
#include "base/cp_annotate.hh"
#include "base/cprintf.hh"
#include "cpu/checker/thread_context.hh"
#include "cpu/exetrace.hh"
#include "cpu/pred/bpred_unit.hh"
-#include "cpu/profile.hh"
#include "cpu/simple/exec_context.hh"
#include "cpu/simple_thread.hh"
#include "cpu/smt.hh"
BaseSimpleCPU::postExecute()
{
SimpleExecContext &t_info = *threadInfo[curThread];
- SimpleThread* thread = t_info.thread;
assert(curStaticInst);
TheISA::PCState pc = threadContexts[curThread]->pcState();
Addr instAddr = pc.instAddr();
- if (FullSystem && thread->profile) {
- bool usermode = TheISA::inUserMode(threadContexts[curThread]);
- thread->profilePC = usermode ? 1 : instAddr;
- ProfileNode *node = thread->profile->consume(threadContexts[curThread],
- curStaticInst);
- if (node)
- thread->profileNode = node;
- }
if (curStaticInst->isMemRef()) {
t_info.numMemRefs++;
#include <string>
#include "arch/isa_traits.hh"
-#include "arch/stacktrace.hh"
#include "arch/utility.hh"
#include "base/callback.hh"
#include "base/compiler.hh"
#include "base/trace.hh"
#include "config/the_isa.hh"
#include "cpu/base.hh"
-#include "cpu/profile.hh"
#include "cpu/thread_context.hh"
#include "mem/se_translating_port_proxy.hh"
#include "mem/translating_port_proxy.hh"
assert(isa);
clearArchRegs();
-
- if (baseCpu->params()->profile) {
- profile = new FunctionProfile(m5::make_unique<TheISA::StackTrace>(),
- system->workload->symtab(this));
- Callback *cb =
- new MakeCallback<SimpleThread,
- &SimpleThread::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;
}
void
::unserialize(*this, cp);
}
-void
-SimpleThread::dumpFuncProfile()
-{
- OutputStream *os(simout.create(csprintf("profile.%s.dat", baseCpu->name())));
- profile->dump(*os->stream());
- simout.close(os);
-}
-
void
SimpleThread::activate()
{
class BaseCPU;
class CheckerCPU;
-class FunctionProfile;
-class ProfileNode;
-
/**
* The SimpleThread object provides a combination of the ThreadState
* object and the ThreadContext interface. It implements the
dtb->demapPage(vaddr, asn);
}
- void dumpFuncProfile() override;
-
/*******************************************
* ThreadContext interface functions.
******************************************/
return ThreadState::readLastSuspend();
}
- void profileClear() override { ThreadState::profileClear(); }
- void profileSample() override { ThreadState::profileSample(); }
-
void copyArchRegs(ThreadContext *tc) override;
void
/// Quiesce, suspend, and schedule activate at resume
void quiesceTick(Tick resume);
- virtual void dumpFuncProfile() = 0;
-
virtual void takeOverFrom(ThreadContext *old_context) = 0;
virtual void regStats(const std::string &name) {};
virtual Tick readLastActivate() = 0;
virtual Tick readLastSuspend() = 0;
- virtual void profileClear() = 0;
- virtual void profileSample() = 0;
-
virtual void copyArchRegs(ThreadContext *tc) = 0;
virtual void clearArchRegs() = 0;
#include "base/output.hh"
#include "cpu/base.hh"
-#include "cpu/profile.hh"
#include "mem/port.hh"
#include "mem/port_proxy.hh"
#include "mem/se_translating_port_proxy.hh"
: numInst(0), numOp(0), numLoad(0), startNumLoad(0),
_status(ThreadContext::Halted), baseCpu(cpu),
_contextId(0), _threadId(_tid), lastActivate(0), lastSuspend(0),
- profile(NULL), profileNode(NULL), profilePC(0),
process(_process), physProxy(NULL), virtProxy(NULL),
funcExeInst(0), storeCondFailures(0)
{
assert(virtProxy != NULL);
return *virtProxy;
}
-
-void
-ThreadState::profileClear()
-{
- if (profile)
- profile->clear();
-}
-
-void
-ThreadState::profileSample()
-{
- if (profile)
- profile->sample(profileNode, profilePC);
-}
#include "arch/types.hh"
#include "config/the_isa.hh"
#include "cpu/base.hh"
-#include "cpu/profile.hh"
#include "cpu/thread_context.hh"
#include "sim/process.hh"
-class FunctionProfile;
-class ProfileNode;
-
class Checkpoint;
/**
*/
void initMemProxies(ThreadContext *tc);
- void dumpFuncProfile();
-
- void profileClear();
-
- void profileSample();
-
PortProxy &getPhysProxy();
PortProxy &getVirtProxy();
/** Last time suspend was called on this thread. */
Tick lastSuspend;
- public:
- FunctionProfile *profile;
- ProfileNode *profileNode;
- Addr profilePC;
-
protected:
Process *process;