summaryrefslogtreecommitdiff
path: root/sim
diff options
context:
space:
mode:
Diffstat (limited to 'sim')
-rw-r--r--sim/serialize.cc11
-rw-r--r--sim/serialize.hh2
2 files changed, 12 insertions, 1 deletions
diff --git a/sim/serialize.cc b/sim/serialize.cc
index 846d191e0..1976e6b3c 100644
--- a/sim/serialize.cc
+++ b/sim/serialize.cc
@@ -50,6 +50,9 @@
using namespace std;
+int Serializable::maxCount;
+int Serializable::count;
+
void
Serializable::nameOut(ostream &os)
{
@@ -224,6 +227,9 @@ Globals::unserialize(Checkpoint *cp)
void
Serializable::serializeAll()
{
+ if (maxCount && count++ > maxCount)
+ SimExit("Maximum number of checkpoints dropped");
+
string dir = Checkpoint::dir();
if (mkdir(dir.c_str(), 0775) == -1 && errno != EEXIST)
fatal("couldn't mkdir %s\n", dir);
@@ -321,7 +327,8 @@ Param<Counter> serialize_period(&serialParams,
"period to repeat serializations",
0);
-
+Param<int> serialize_count(&serialParams, "count",
+ "maximum number of checkpoints to drop");
SerializeParamContext::SerializeParamContext(const string &section)
: ParamContext(section), event(NULL)
@@ -342,6 +349,8 @@ SerializeParamContext::checkParams()
if (serialize_cycle > 0)
Checkpoint::setup(serialize_cycle, serialize_period);
+
+ Serializable::maxCount = serialize_count;
}
void
diff --git a/sim/serialize.hh b/sim/serialize.hh
index 5df168665..de208265e 100644
--- a/sim/serialize.hh
+++ b/sim/serialize.hh
@@ -119,6 +119,8 @@ class Serializable
static Serializable *create(Checkpoint *cp,
const std::string &section);
+ static int count;
+ static int maxCount;
static void serializeAll();
static void unserializeGlobals(Checkpoint *cp);
};