1 #include "snapshot-interface.h"
17 #define MYBINARYNAME "model"
18 #define MYLIBRARYNAME "libmodel.so"
19 #define MAPFILE_FORMAT "/proc/%d/maps"
21 SnapshotStack * snapshotObject;
23 void SnapshotGlobalSegments(){
25 char buf[9000], filename[100];
28 sprintf(filename, MAPFILE_FORMAT, pid);
29 map = fopen(filename, "r");
34 while (fgets(buf, sizeof(buf), map)) {
35 char regionname[200] = "";
39 sscanf(buf, "%p-%p %c%c%c%c %*x %*x:%*x %*u %200s\n", &begin, &end, &r, &w, &x, &p, regionname);
40 if (w == 'w' && (strstr(regionname, MYBINARYNAME) || strstr(regionname, MYLIBRARYNAME))) {
41 size_t len = ((uintptr_t)end - (uintptr_t)begin) / PAGESIZE;
43 addMemoryRegionToSnapShot(begin, len);
44 DEBUG("%45s: %18p - %18p\t%c%c%c%c\n", regionname, begin, end, r, w, x, p);
50 //class definition of SnapshotStack.....
51 //declaration of constructor....
52 SnapshotStack::SnapshotStack(){
53 SnapshotGlobalSegments();
57 SnapshotStack::~SnapshotStack(){
60 int SnapshotStack::backTrackBeforeStep(int seqindex) {
62 if (stack->index<=seqindex) {
64 rollBack(stack->snapshotid);
67 struct stackEntry *tmp=stack;
73 void SnapshotStack::snapshotStep(int seqindex) {
74 struct stackEntry *tmp=(struct stackEntry *)MYMALLOC(sizeof(struct stackEntry));
77 tmp->snapshotid=takeSnapshot();