//Initialize race detector
initRaceDetector();
- //Create the singleton SnapshotStack object
- snapshotObject = new SnapshotStack();
+ snapshot_stack_init();
model = new ModelChecker(params);
- snapshotObject->snapshotStep(0);
+ snapshot_record(0);
model->run();
delete model;
/* Print all model-checker output before rollback */
fflush(model_out);
- snapshotObject->backTrackBeforeStep(0);
+ snapshot_backtrack_before(0);
}
/** @return a thread ID for a new Thread */
#include "snapshot-interface.h"
#include "snapshot.h"
#include "common.h"
+#include "mymemory.h"
/* MYBINARYNAME only works because our pathname usually includes 'model' (e.g.,
* /.../model-checker/test/userprog.o) */
#define MYLIBRARYNAME "libmodel.so"
#define MAPFILE "/proc/self/maps"
-SnapshotStack *snapshotObject;
+struct stackEntry {
+ struct stackEntry *next;
+ snapshot_id snapshotid;
+ int index;
+};
+
+class SnapshotStack {
+ public:
+ SnapshotStack();
+ ~SnapshotStack();
+ int backTrackBeforeStep(int seq_index);
+ void snapshotStep(int seq_index);
+
+ MEMALLOC
+ private:
+ struct stackEntry *stack;
+};
+
+static SnapshotStack *snapshotObject;
#ifdef MAC
/** The SnapshotGlobalSegments function computes the memory regions
tmp->snapshotid = take_snapshot();
stack = tmp;
}
+
+
+void snapshot_stack_init()
+{
+ snapshotObject = new SnapshotStack();
+}
+
+void snapshot_record(int seq_index)
+{
+ snapshotObject->snapshotStep(seq_index);
+}
+
+int snapshot_backtrack_before(int seq_index)
+{
+ return snapshotObject->backTrackBeforeStep(seq_index);
+}
* @brief C++ layer on top of snapshotting system.
*/
-
#ifndef __SNAPINTERFACE_H
#define __SNAPINTERFACE_H
-#include "mymemory.h"
typedef unsigned int snapshot_id;
unsigned int numsnapshots, unsigned int nummemoryregions,
unsigned int numheappages, VoidFuncPtr entryPoint);
-struct stackEntry {
- struct stackEntry *next;
- snapshot_id snapshotid;
- int index;
-};
-
-class SnapshotStack {
- public:
- SnapshotStack();
- ~SnapshotStack();
- int backTrackBeforeStep(int seq_index);
- void snapshotStep(int seq_index);
-
- MEMALLOC
- private:
- struct stackEntry *stack;
-};
-
-/* Not sure what it even means to have more than one snapshot object,
- so let's just make a global reference to it.*/
+void snapshot_stack_init();
+void snapshot_record(int seq_index);
+int snapshot_backtrack_before(int seq_index);
-extern SnapshotStack *snapshotObject;
#endif