summaryrefslogtreecommitdiff
path: root/sim/system.cc
diff options
context:
space:
mode:
authorLisa Hsu <hsul@eecs.umich.edu>2004-03-05 05:09:05 -0500
committerLisa Hsu <hsul@eecs.umich.edu>2004-03-05 05:09:05 -0500
commit4fa703f2ec733ccb8b5ffaa741db0b8510fbe188 (patch)
tree9e3d7ba5e6019181408a50123f7ef2fea55cc1db /sim/system.cc
parent2ef27db62c403e4b9e4fea0c2f894a1504309b2e (diff)
downloadgem5-4fa703f2ec733ccb8b5ffaa741db0b8510fbe188.tar.xz
serialization for binning. it is WAAAAAAAY past my bedtime.
cpu/exec_context.cc: sim/system.cc: sim/system.hh: serialization for binning --HG-- extra : convert_revision : f8417794a3a5ec7f2addc9c2da0f48e851899112
Diffstat (limited to 'sim/system.cc')
-rw-r--r--sim/system.cc61
1 files changed, 60 insertions, 1 deletions
diff --git a/sim/system.cc b/sim/system.cc
index 36275f400..fa8e8c463 100644
--- a/sim/system.cc
+++ b/sim/system.cc
@@ -108,7 +108,7 @@ System::getBin(const std::string &name)
std::map<const std::string, Statistics::MainBin *>::const_iterator i;
i = fnBins.find(name);
if (i == fnBins.end())
- panic("trying to getBin that is not on system map!");
+ panic("trying to getBin %s that is not on system map!", name);
return (*i).second;
}
@@ -125,5 +125,64 @@ System::findContext(Addr pcb)
return NULL;
}
+void
+System::serialize(std::ostream &os)
+{
+ if (bin == true) {
+ map<const Addr, SWContext *>::const_iterator iter, end;
+ iter = swCtxMap.begin();
+ end = swCtxMap.end();
+
+ int numCtxs = swCtxMap.size();
+ SERIALIZE_SCALAR(numCtxs);
+ SWContext *ctx;
+ for (int i = 0; iter != end; ++i) {
+ paramOut(os, csprintf("Addr[%d]",i), (*iter).first);
+ ctx = (*iter).second;
+ paramOut(os, csprintf("calls[%d]",i), ctx->calls);
+
+ stack<fnCall *> *stack = &(ctx->callStack);
+ fnCall *top;
+ int size = stack->size();
+ paramOut(os, csprintf("stacksize[%d]",i), size);
+ for (int j=0; j<size; ++j) {
+ top = stack->top();
+ paramOut(os, csprintf("ctx[%d].stackpos[%d]",i,j), top->name);
+ }
+ }
+ }
+}
+
+void
+System::unserialize(Checkpoint *cp, const std::string &section)
+{
+ if (bin == true) {
+ int numCtxs;
+ UNSERIALIZE_SCALAR(numCtxs);
+
+ SWContext *ctxs = new SWContext[numCtxs];
+ Addr addr;
+ int size;
+ for(int i = 0; i < numCtxs; ++i) {
+ paramIn(cp, section, csprintf("Addr[%d]",i), addr);
+ paramIn(cp, section, csprintf("calls[%d]",i), ctxs[i].calls);
+
+ paramIn(cp, section, csprintf("stacksize[%d]",i), size);
+ fnCall *call = new fnCall[size];
+ for (int j = 0; j < size; ++j) {
+ paramIn(cp, section, csprintf("ctx[%d].stackpos[%d]",i,j),
+ call[j].name);
+ call[j].myBin = getBin(call[j].name);
+ }
+
+ for (int j=size-1; j>=0; --j) {
+ ctxs[i].callStack.push(&(call[j]));
+ }
+
+ addContext(addr, &(ctxs[i]));
+ }
+ }
+}
+
DEFINE_SIM_OBJECT_CLASS_NAME("System", System)