summaryrefslogtreecommitdiff
path: root/src/sim
diff options
context:
space:
mode:
authorGabe Black <gblack@eecs.umich.edu>2007-08-02 15:14:36 -0700
committerGabe Black <gblack@eecs.umich.edu>2007-08-02 15:14:36 -0700
commitfa9e4d110aba05fb860e299d1765249589e9b810 (patch)
tree2b2aaac3026d0b540f1557f273febfb5db5069b1 /src/sim
parent4af5740afdbd10fc4e8f9370d7b5ad49642c20e4 (diff)
parent4041e1ddd98ce0d3e21714b5830ac5f3e66c3765 (diff)
downloadgem5-fa9e4d110aba05fb860e299d1765249589e9b810.tar.xz
Merge with head.
--HG-- extra : convert_revision : 7700f475caa676948175cdf126ee018b0c4ad35c
Diffstat (limited to 'src/sim')
-rw-r--r--src/sim/serialize.cc71
-rw-r--r--src/sim/serialize.hh9
-rw-r--r--src/sim/system.cc3
3 files changed, 80 insertions, 3 deletions
diff --git a/src/sim/serialize.cc b/src/sim/serialize.cc
index a01e053b9..a7f81d5fb 100644
--- a/src/sim/serialize.cc
+++ b/src/sim/serialize.cc
@@ -40,6 +40,7 @@
#include <string>
#include <vector>
+#include "base/annotate.hh"
#include "base/inifile.hh"
#include "base/misc.hh"
#include "base/output.hh"
@@ -178,6 +179,22 @@ paramOut(ostream &os, const std::string &name, const T &param)
os << "\n";
}
+template <class T>
+void
+arrayParamOut(ostream &os, const std::string &name,
+ const std::vector<T> &param)
+{
+ int size = param.size();
+ os << name << "=";
+ if (size > 0)
+ showParam(os, param[0]);
+ for (int i = 1; i < size; ++i) {
+ os << " ";
+ showParam(os, param[i]);
+ }
+ os << "\n";
+}
+
template <class T>
void
@@ -251,6 +268,49 @@ arrayParamIn(Checkpoint *cp, const std::string &section,
}
}
+template <class T>
+void
+arrayParamIn(Checkpoint *cp, const std::string &section,
+ const std::string &name, std::vector<T> &param)
+{
+ std::string str;
+ if (!cp->find(section, name, str)) {
+ fatal("Can't unserialize '%s:%s'\n", section, name);
+ }
+
+ // code below stolen from VectorParam<T>::parse().
+ // it would be nice to unify these somehow...
+
+ vector<string> tokens;
+
+ tokenize(tokens, str, ' ');
+
+ // Need this if we were doing a vector
+ // value.resize(tokens.size());
+
+ param.resize(tokens.size());
+
+ for (int i = 0; i < tokens.size(); i++) {
+ // need to parse into local variable to handle vector<bool>,
+ // for which operator[] returns a special reference class
+ // that's not the same as 'bool&', (since it's a packed
+ // vector)
+ T scalar_value;
+ if (!parseParam(tokens[i], scalar_value)) {
+ string err("could not parse \"");
+
+ err += str;
+ err += "\"";
+
+ fatal(err);
+ }
+
+ // assign parsed value to vector
+ param[i] = scalar_value;
+ }
+}
+
+
void
objParamIn(Checkpoint *cp, const std::string &section,
@@ -273,7 +333,13 @@ arrayParamOut(ostream &os, const std::string &name, \
type const *param, int size); \
template void \
arrayParamIn(Checkpoint *cp, const std::string &section, \
- const std::string &name, type *param, int size);
+ const std::string &name, type *param, int size); \
+template void \
+arrayParamOut(ostream &os, const std::string &name, \
+ const std::vector<type> &param); \
+template void \
+arrayParamIn(Checkpoint *cp, const std::string &section, \
+ const std::string &name, std::vector<type> &param);
INSTANTIATE_PARAM_TEMPLATES(signed char)
INSTANTIATE_PARAM_TEMPLATES(unsigned char)
@@ -343,6 +409,7 @@ Serializable::serializeAll(const std::string &cpt_dir)
outstream << "// checkpoint generated: " << ctime(&t);
globals.serialize(outstream);
+ Annotate::annotations.serialize(outstream);
SimObject::serializeAll(outstream);
}
@@ -358,7 +425,7 @@ Serializable::unserializeAll(const std::string &cpt_dir)
dir);
Checkpoint *cp = new Checkpoint(dir, section);
unserializeGlobals(cp);
-
+ Annotate::annotations.unserialize(cp);
SimObject::unserializeAll(cp);
}
diff --git a/src/sim/serialize.hh b/src/sim/serialize.hh
index 43cd4ecf4..e72eedb30 100644
--- a/src/sim/serialize.hh
+++ b/src/sim/serialize.hh
@@ -39,6 +39,7 @@
#include <list>
+#include <vector>
#include <iostream>
#include <map>
@@ -61,9 +62,17 @@ void arrayParamOut(std::ostream &os, const std::string &name,
const T *param, int size);
template <class T>
+void arrayParamOut(std::ostream &os, const std::string &name,
+ const std::vector<T> &param);
+
+template <class T>
void arrayParamIn(Checkpoint *cp, const std::string &section,
const std::string &name, T *param, int size);
+template <class T>
+void arrayParamIn(Checkpoint *cp, const std::string &section,
+ const std::string &name, std::vector<T> &param);
+
void
objParamIn(Checkpoint *cp, const std::string &section,
const std::string &name, SimObject * &param);
diff --git a/src/sim/system.cc b/src/sim/system.cc
index 3c4746e93..eb0655aa5 100644
--- a/src/sim/system.cc
+++ b/src/sim/system.cc
@@ -72,7 +72,8 @@ System::System(Params *p)
#if FULL_SYSTEM
kernelSymtab = new SymbolTable;
- debugSymbolTable = new SymbolTable;
+ if (!debugSymbolTable)
+ debugSymbolTable = new SymbolTable;
/**