summaryrefslogtreecommitdiff
path: root/sim/system.cc
diff options
context:
space:
mode:
authorLisa Hsu <hsul@eecs.umich.edu>2004-05-18 01:40:03 -0400
committerLisa Hsu <hsul@eecs.umich.edu>2004-05-18 01:40:03 -0400
commita0ccdf8aba8f71c8d66c03f5c6907d0a3c2e091f (patch)
tree71de26a0139e7db042c79989ae745377d98c3d23 /sim/system.cc
parent4d98ab1ca92c2d88d3ee13a7518acc36a6d5bf84 (diff)
parent02af86f7e813db27b12214ea377948f07f891b69 (diff)
downloadgem5-a0ccdf8aba8f71c8d66c03f5c6907d0a3c2e091f.tar.xz
merge m5 with linux for the event and binning lifting
--HG-- extra : convert_revision : 09d3678746c2e9a93a9982dc75d5e1ac309cb2fa
Diffstat (limited to 'sim/system.cc')
-rw-r--r--sim/system.cc79
1 files changed, 77 insertions, 2 deletions
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<string> &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 string, string>::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 std::string, std::string>::const_iterator iter;
+ pair<iter, iter> 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<fnCall *> 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)
{