-/* -*- Mode: C; indent-tabs-mode: t -*- */
-
-#define MYBINARYNAME "model"
-#define MYLIBRARYNAME "libmodel.so"
-#define MYALLOCNAME "libmymemory.so"
-#define PROCNAME "/proc/*/maps"
-#define REPLACEPOS 6
-#define PAGESIZE 4096
#include "snapshot-interface.h"
#include <iostream>
#include <fstream>
#include <sys/types.h>
#include <sstream>
#include <cstring>
+#include <string>
#include <cassert>
+#include <vector>
+#include <utility>
+
+#define MYBINARYNAME "model"
+#define MYLIBRARYNAME "libmodel.so"
+#define PROCNAME "/proc/*/maps"
+#define REPLACEPOS 6
+#define PAGESIZE 4096
+
+typedef std::basic_string<char, std::char_traits<char>, MyAlloc<char> > MyString;
-snapshotStack * snapshotObject;
+SnapshotStack * snapshotObject;
/*This looks like it might leak memory... Subramanian should fix this. */
void SnapshotGlobalSegments(){
MyString fn = PROCNAME;
static char sProcessSize[ 12 ] = { 0 };
- std::pair< const char *, bool > dataSect[ 3 ];
+ std::pair< const char *, bool > dataSect[ 2 ];
dataSect[ 0 ] = std::make_pair( MYBINARYNAME, false );
dataSect[ 1 ] = std::make_pair( MYLIBRARYNAME, false );
- dataSect[ 2 ] = std::make_pair( MYALLOCNAME, false );
static pid_t sProcID = 0;
if( 0 == sProcID ) {
sProcID = getpid();
}
}
-//class definition of snapshotStack.....
+//class definition of SnapshotStack.....
//declaration of constructor....
-snapshotStack::snapshotStack(){
+SnapshotStack::SnapshotStack(){
SnapshotGlobalSegments();
stack=NULL;
}
-snapshotStack::~snapshotStack(){
+SnapshotStack::~SnapshotStack(){
}
-int snapshotStack::backTrackBeforeStep(int seqindex) {
+int SnapshotStack::backTrackBeforeStep(int seqindex) {
while(true) {
if (stack->index<=seqindex) {
//have right entry
return stack->index;
}
struct stackEntry *tmp=stack;
- free(tmp);
+ MYFREE(tmp);
stack=stack->next;
}
}
-void snapshotStack::snapshotStep(int seqindex) {
- struct stackEntry *tmp=(struct stackEntry *)malloc(sizeof(struct stackEntry));
+void SnapshotStack::snapshotStep(int seqindex) {
+ struct stackEntry *tmp=(struct stackEntry *)MYMALLOC(sizeof(struct stackEntry));
tmp->next=stack;
tmp->index=seqindex;
tmp->snapshotid=takeSnapshot();