summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAli Saidi <Ali.Saidi@ARM.com>2012-06-05 01:23:10 -0400
committerAli Saidi <Ali.Saidi@ARM.com>2012-06-05 01:23:10 -0400
commit70d7d6cc7f7c25d43f0dc56fe133073eb4a97298 (patch)
tree5736150e2002e2fecc733ad8cb69078e0659137b /src
parent2e988bbab0c1a3c90c69b03fc79a62d7c61a540a (diff)
downloadgem5-70d7d6cc7f7c25d43f0dc56fe133073eb4a97298.tar.xz
sim: Provide a framework for detecting out of data checkpoints and migrating them.
Diffstat (limited to 'src')
-rwxr-xr-xsrc/SConscript1
-rw-r--r--src/sim/root.cc37
-rw-r--r--src/sim/root.hh4
-rw-r--r--src/sim/serialize.hh9
4 files changed, 51 insertions, 0 deletions
diff --git a/src/SConscript b/src/SConscript
index c30a4fd66..24d31fccf 100755
--- a/src/SConscript
+++ b/src/SConscript
@@ -354,6 +354,7 @@ def makeTheISA(source, target, env):
#define THE_ISA ${{define(target_isa)}}
#define TheISA ${{namespace(target_isa)}}
+#define THE_ISA_STR "${{target_isa}}"
#endif // __CONFIG_THE_ISA_HH__''')
diff --git a/src/sim/root.cc b/src/sim/root.cc
index 2d28499a7..34150083d 100644
--- a/src/sim/root.cc
+++ b/src/sim/root.cc
@@ -32,6 +32,7 @@
*/
#include "base/misc.hh"
+#include "config/the_isa.hh"
#include "debug/TimeSync.hh"
#include "sim/full_system.hh"
#include "sim/root.hh"
@@ -121,9 +122,45 @@ Root::initState()
void
Root::loadState(Checkpoint *cp)
{
+ SimObject::loadState(cp);
timeSyncEnable(params()->time_sync_enable);
}
+void
+Root::serialize(std::ostream &os)
+{
+ uint64_t cpt_ver = gem5CheckpointVersion;
+ SERIALIZE_SCALAR(cpt_ver);
+ SERIALIZE_SCALAR(FullSystem);
+ std::string isa = THE_ISA_STR;
+ SERIALIZE_SCALAR(isa);
+}
+
+void
+Root::unserialize(Checkpoint *cp, const std::string &section)
+{
+ uint64_t cpt_ver = 0;
+ UNSERIALIZE_OPT_SCALAR(cpt_ver);
+ if (cpt_ver < gem5CheckpointVersion) {
+ warn("**********************************************************\n");
+ warn("!!!! Checkpoint ver %#x is older than current ver %#x !!!!\n",
+ cpt_ver, gem5CheckpointVersion);
+ warn("You might experience some issues when restoring and should run "
+ "the checkpoint upgrader (util/cpt_upgrade.py) on your "
+ "checkpoint\n");
+ warn("**********************************************************\n");
+ } else if (cpt_ver > gem5CheckpointVersion) {
+ warn("**********************************************************\n");
+ warn("!!!! Checkpoint ver %#x is newer than current ver %#x !!!!\n",
+ cpt_ver, gem5CheckpointVersion);
+ warn("Running a new checkpoint with an older version of gem5 is not "
+ "supported. While it might work, you may experience incorrect "
+ "behavior or crashes.\n");
+ warn("**********************************************************\n");
+ }
+}
+
+
bool FullSystem;
unsigned int FullSystemInt;
diff --git a/src/sim/root.hh b/src/sim/root.hh
index 3c3b3c2f3..6a7b5dc93 100644
--- a/src/sim/root.hh
+++ b/src/sim/root.hh
@@ -111,6 +111,10 @@ class Root : public SimObject
/** Schedule the timesync event at initState() when not unserializing
*/
void initState();
+
+ virtual void serialize(std::ostream &os);
+ virtual void unserialize(Checkpoint *cp, const std::string &section);
+
};
#endif // __SIM_ROOT_HH__
diff --git a/src/sim/serialize.hh b/src/sim/serialize.hh
index bc64e74f8..ae20b40c2 100644
--- a/src/sim/serialize.hh
+++ b/src/sim/serialize.hh
@@ -50,6 +50,15 @@ class Serializable;
class Checkpoint;
class SimObject;
+/** The current version of the checkpoint format.
+ * This should be incremented by 1 and only 1 for every new version, where a new
+ * version is defined as a checkpoint created before this version wont work on
+ * the current version until the checkpoint format is updated. Adding a new
+ * SimObject shouldn't cause the version number to increase, only changes to
+ * existing objects such as serializing/unserializing more stote, changing sizes
+ * of serialized arrays, etc. */
+static const uint64_t gem5CheckpointVersion = 0x0000000000000001;
+
template <class T>
void paramOut(std::ostream &os, const std::string &name, const T &param);