From b8082eb508f15f09eb7416a67b6d3a1886b4fa34 Mon Sep 17 00:00:00 2001 From: Lisa Hsu Date: Mon, 17 May 2004 15:08:24 -0400 Subject: lift system-independent binning stuff out of Tru64System into System. kern/tru64/tru64_system.cc: make binned_fns a parameter for System in addition to Tru64System. Do all the fnEvents setting at the System level, since that is system-independent. kern/tru64/tru64_system.hh: deal with FnEvents in the System, and move some fns over to System. sim/system.cc: sim/system.hh: lift binning stuff into System out of Tru64System --HG-- extra : convert_revision : 591dee6f2013f5c43037726c529a00682b5cf82e --- sim/system.cc | 79 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++-- sim/system.hh | 22 ++++++++++++----- 2 files changed, 93 insertions(+), 8 deletions(-) (limited to 'sim') diff --git a/sim/system.cc b/sim/system.cc index 43f43baec..791a092ac 100644 --- a/sim/system.cc +++ b/sim/system.cc @@ -30,6 +30,7 @@ #include "targetarch/vtophys.hh" #include "sim/param.hh" #include "sim/system.hh" +#include "base/trace.hh" using namespace std; @@ -41,12 +42,15 @@ System::System(const std::string _name, const uint64_t _init_param, MemoryController *_memCtrl, PhysicalMemory *_physmem, - const bool _bin) + const bool _bin, + const std::vector &binned_fns) + : SimObject(_name), init_param(_init_param), memCtrl(_memCtrl), physmem(_physmem), - bin(_bin) + bin(_bin), + binned_fns(binned_fns) { // add self to global system list systemList.push_back(this); @@ -54,6 +58,31 @@ System::System(const std::string _name, Kernel = new Statistics::MainBin("non TCPIP Kernel stats"); Kernel->activate(); User = new Statistics::MainBin("User stats"); + + int end = binned_fns.size(); + assert(!(end & 1)); + + Statistics::MainBin *Bin; + + fnEvents.resize(end>>1); + + for (int i = 0; i < end; i +=2) { + Bin = new Statistics::MainBin(binned_fns[i]); + fnBins.insert(make_pair(binned_fns[i], Bin)); + + fnEvents[(i>>1)] = new FnEvent(&pcEventQueue, binned_fns[i], this); + + if (binned_fns[i+1] == "null") + populateMap(binned_fns[i], ""); + else + populateMap(binned_fns[i], binned_fns[i+1]); + } + + fnCalls + .name(name() + ":fnCalls") + .desc("all fn calls being tracked") + ; + } else Kernel = NULL; } @@ -61,6 +90,13 @@ System::System(const std::string _name, System::~System() { + if (bin == true) { + int end = fnEvents.size(); + for (int i = 0; i < end; ++i) { + delete fnEvents[i]; + } + fnEvents.clear(); + } } @@ -103,6 +139,45 @@ printSystems() System::printSystems(); } +void +System::populateMap(std::string callee, std::string caller) +{ + multimap::const_iterator i; + i = callerMap.insert(make_pair(callee, caller)); + assert(i != callerMap.end() && "should not fail populating callerMap"); +} + +bool +System::findCaller(std::string callee, std::string caller) const +{ + typedef multimap::const_iterator iter; + pair range; + + range = callerMap.equal_range(callee); + for (iter i = range.first; i != range.second; ++i) { + if ((*i).second == caller) + return true; + } + return false; +} + +void +System::dumpState(ExecContext *xc) const +{ + if (xc->swCtx) { + stack copy(xc->swCtx->callStack); + if (copy.empty()) + return; + DPRINTF(TCPIP, "xc->swCtx, size: %d:\n", copy.size()); + fnCall *top; + DPRINTF(TCPIP, "|| call : %d\n",xc->swCtx->calls); + for (top = copy.top(); !copy.empty(); copy.pop() ) { + top = copy.top(); + DPRINTF(TCPIP, "|| %13s : %s \n", top->name, top->myBin->name()); + } + } +} + Statistics::MainBin * System::getBin(const std::string &name) { diff --git a/sim/system.hh b/sim/system.hh index 050d1dd11..564579fe4 100644 --- a/sim/system.hh +++ b/sim/system.hh @@ -35,6 +35,7 @@ #include "base/loader/symtab.hh" #include "base/statistics.hh" #include "cpu/pc_event.hh" +#include "kern/system_events.hh" #include "sim/sim_object.hh" #include "sim/sw_context.hh" @@ -48,17 +49,20 @@ class ExecContext; class System : public SimObject { // lisa's binning stuff - protected: + private: std::map fnBins; std::map swCtxMap; + protected: + std::vector fnEvents; + public: Statistics::Scalar<> fnCalls; Statistics::MainBin *Kernel; Statistics::MainBin *User; Statistics::MainBin * getBin(const std::string &name); - virtual bool findCaller(std::string, std::string) const = 0; + bool findCaller(std::string, std::string) const; SWContext *findContext(Addr pcb); bool addContext(Addr pcb, SWContext *ctx) { @@ -68,18 +72,23 @@ class System : public SimObject swCtxMap.erase(pcb); return; } - - virtual void dumpState(ExecContext *xc) const = 0; + void dumpState(ExecContext *xc) const; virtual void serialize(std::ostream &os); virtual void unserialize(Checkpoint *cp, const std::string §ion); - // + + + private: + std::multimap callerMap; + void populateMap(std::string caller, std::string callee); +// public: const uint64_t init_param; MemoryController *memCtrl; PhysicalMemory *physmem; bool bin; + std::vector binned_fns; PCEventQueue pcEventQueue; @@ -90,7 +99,8 @@ class System : public SimObject public: System(const std::string _name, const uint64_t _init_param, - MemoryController *, PhysicalMemory *, const bool); + MemoryController *, PhysicalMemory *, const bool, + const std::vector &binned_fns); ~System(); virtual Addr getKernelStart() const = 0; -- cgit v1.2.3