X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=snapshot-interface.cc;h=974e436f7210acfdc1035208cb6f736a92d2c79d;hb=3b08bb3248c8f63fc1c54da23da471cab0fe7239;hp=51fe2f08de1392dd6fe40cd3757edcf675367c60;hpb=fb619bf46f246eeaaa794e6e98ad30f300ec160e;p=model-checker.git diff --git a/snapshot-interface.cc b/snapshot-interface.cc index 51fe2f0..974e436 100644 --- a/snapshot-interface.cc +++ b/snapshot-interface.cc @@ -1,15 +1,10 @@ -#include "snapshot-interface.h" -#include "snapshot.h" -#include -#include +#include #include -#include #include -#include -#include -#include -#include #include + +#include "snapshot-interface.h" +#include "snapshot.h" #include "common.h" /* MYBINARYNAME only works because our pathname usually includes 'model' (e.g., @@ -25,13 +20,14 @@ SnapshotStack * snapshotObject; * that may contain globals and then configures the snapshotting * library to snapshot them. */ -static void SnapshotGlobalSegments(){ +static void SnapshotGlobalSegments() +{ int pid = getpid(); char buf[9000], execname[100]; FILE *map; sprintf(execname, "vmmap -interleaved %d", pid); - map=popen(execname, "r"); + map = popen(execname, "r"); if (!map) { perror("popen"); @@ -54,7 +50,7 @@ static void SnapshotGlobalSegments(){ void *begin, *end; //Skip out at the end of the section - if (buf[0]=='\n') + if (buf[0] == '\n') break; sscanf(buf, "%22s %p-%p [%5dK] %c%c%c/%c%c%c SM=%3s %200s\n", type, &begin, &end, &size, &r, &w, &x, &mr, &mw, &mx, smstr, regionname); @@ -81,7 +77,8 @@ static void get_binary_name(char *buf, size_t len) * that may contain globals and then configures the snapshotting * library to snapshot them. */ -static void SnapshotGlobalSegments(){ +static void SnapshotGlobalSegments() +{ char buf[9000]; char binary_name[800]; FILE *map; @@ -109,12 +106,14 @@ static void SnapshotGlobalSegments(){ } #endif -SnapshotStack::SnapshotStack(){ +SnapshotStack::SnapshotStack() +{ SnapshotGlobalSegments(); - stack=NULL; + stack = NULL; } -SnapshotStack::~SnapshotStack(){ +SnapshotStack::~SnapshotStack() +{ } @@ -124,24 +123,26 @@ SnapshotStack::~SnapshotStack(){ * @param seqindex is the sequence number to rollback before. * @return is the sequence number we actually rolled back to. */ -int SnapshotStack::backTrackBeforeStep(int seqindex) { - while(true) { - if (stack->index<=seqindex) { +int SnapshotStack::backTrackBeforeStep(int seqindex) +{ + while (true) { + if (stack->index <= seqindex) { //have right entry rollBack(stack->snapshotid); return stack->index; } - struct stackEntry *tmp=stack; - stack=stack->next; + struct stackEntry *tmp = stack; + stack = stack->next; model_free(tmp); } } /** This method takes a snapshot at the given sequence number. */ -void SnapshotStack::snapshotStep(int seqindex) { - struct stackEntry *tmp=(struct stackEntry *)model_malloc(sizeof(struct stackEntry)); - tmp->next=stack; - tmp->index=seqindex; - tmp->snapshotid=takeSnapshot(); - stack=tmp; +void SnapshotStack::snapshotStep(int seqindex) +{ + struct stackEntry *tmp = (struct stackEntry *)model_malloc(sizeof(struct stackEntry)); + tmp->next = stack; + tmp->index = seqindex; + tmp->snapshotid = takeSnapshot(); + stack = tmp; }