summaryrefslogtreecommitdiff
path: root/src/sim/serialize.cc
diff options
context:
space:
mode:
authorSteve Reinhardt <steve.reinhardt@amd.com>2010-07-05 21:39:38 -0700
committerSteve Reinhardt <steve.reinhardt@amd.com>2010-07-05 21:39:38 -0700
commit345dfd1b41729162ff31da010cce0659ce810897 (patch)
tree5fa83884b0e722ce0c71a68a431ffe4222e57a87 /src/sim/serialize.cc
parent820bb3044d203aafa955cdb84c259101f051620e (diff)
downloadgem5-345dfd1b41729162ff31da010cce0659ce810897.tar.xz
checkpointing: minor cleanup.
Move some static checkpoint stuff into the Checkpoint object namespace.
Diffstat (limited to 'src/sim/serialize.cc')
-rw-r--r--src/sim/serialize.cc61
1 files changed, 29 insertions, 32 deletions
diff --git a/src/sim/serialize.cc b/src/sim/serialize.cc
index 27831ef32..5f854a776 100644
--- a/src/sim/serialize.cc
+++ b/src/sim/serialize.cc
@@ -427,8 +427,7 @@ Serializable::unserialize(Checkpoint *cp, const string &section)
void
Serializable::serializeAll(const string &cpt_dir)
{
- setCheckpointDir(cpt_dir);
- string dir = Checkpoint::dir();
+ string dir = Checkpoint::setDir(cpt_dir);
if (mkdir(dir.c_str(), 0775) == -1 && errno != EEXIST)
fatal("couldn't mkdir %s\n", dir);
@@ -446,14 +445,10 @@ Serializable::serializeAll(const string &cpt_dir)
void
Serializable::unserializeAll(const string &cpt_dir)
{
- setCheckpointDir(cpt_dir);
- string dir = Checkpoint::dir();
- string cpt_file = dir + Checkpoint::baseFilename;
- string section = "";
+ string dir = Checkpoint::setDir(cpt_dir);
- DPRINTFR(Config, "Loading checkpoint dir '%s'\n",
- dir);
- Checkpoint *cp = new Checkpoint(dir, section);
+ DPRINTFR(Config, "Loading checkpoint dir '%s'\n", dir);
+ Checkpoint *cp = new Checkpoint(dir);
unserializeGlobals(cp);
SimObject::unserializeAll(cp);
}
@@ -464,27 +459,6 @@ Serializable::unserializeGlobals(Checkpoint *cp)
globals.unserialize(cp);
}
-const char *Checkpoint::baseFilename = "m5.cpt";
-
-static string checkpointDirBase;
-
-void
-setCheckpointDir(const string &name)
-{
- checkpointDirBase = name;
- if (checkpointDirBase[checkpointDirBase.size() - 1] != '/')
- checkpointDirBase += "/";
-}
-
-string
-Checkpoint::dir()
-{
- // use csprintf to insert curTick into directory name if it
- // appears to have a format placeholder in it.
- return (checkpointDirBase.find("%") != string::npos) ?
- csprintf(checkpointDirBase, curTick) : checkpointDirBase;
-}
-
void
debug_serialize(const string &cpt_dir)
{
@@ -554,8 +528,31 @@ Serializable::create(Checkpoint *cp, const string &section)
}
-Checkpoint::Checkpoint(const string &cpt_dir, const string &path)
- : db(new IniFile), basePath(path), cptDir(cpt_dir)
+const char *Checkpoint::baseFilename = "m5.cpt";
+
+string Checkpoint::currentDirectory;
+
+string
+Checkpoint::setDir(const string &name)
+{
+ // use csprintf to insert curTick into directory name if it
+ // appears to have a format placeholder in it.
+ currentDirectory = (name.find("%") != string::npos) ?
+ csprintf(name, curTick) : name;
+ if (currentDirectory[currentDirectory.size() - 1] != '/')
+ currentDirectory += "/";
+ return currentDirectory;
+}
+
+string
+Checkpoint::dir()
+{
+ return currentDirectory;
+}
+
+
+Checkpoint::Checkpoint(const string &cpt_dir)
+ : db(new IniFile), cptDir(cpt_dir)
{
string filename = cpt_dir + "/" + Checkpoint::baseFilename;
if (!db->load(filename)) {