static mspace sStaticSpace = NULL;
#endif
+/** Non-snapshotting malloc for our use. */
+
void *MYMALLOC(size_t size) {
#if USE_MPROTECT_SNAPSHOT
static void *(*mallocp)(size_t size);
}
freep(ptr);
}
+
+/** Non-snapshotting free for our use. */
void MYFREE(void *ptr) {
#if USE_MPROTECT_SNAPSHOT
static void (*freep)(void *);
mspace_free( sStaticSpace, ptr );
#endif
}
+
+
+/** This global references the mspace for the snapshotting heap */
mspace mySpace = NULL;
+
+/** This global references the unaligned memory address that was malloced for the snapshotting heap */
void * basemySpace = NULL;
+//Subramanian --- please make these work for the fork based approach
+
+/** Snapshotting malloc implementation for user programs. */
+
void *malloc( size_t size ) {
return mspace_malloc( mySpace, size );
}
+/** Snapshotting free implementation for user programs. */
+
void free( void * ptr ){
mspace_free( mySpace, ptr );
}
+/** Snapshotting realloc implementation for user programs. */
+
void *realloc( void *ptr, size_t size ){
return mspace_realloc( mySpace, ptr, size );
}
+/** Snapshotting new operator for user programs. */
+
void * operator new(size_t size) throw(std::bad_alloc) {
return malloc(size);
}
+/** Snapshotting delete operator for user programs. */
+
void operator delete(void *p) throw() {
free(p);
}
+/** Snapshotting new[] operator for user programs. */
+
void * operator new[](size_t size) throw(std::bad_alloc) {
return malloc(size);
}
+/** Snapshotting delete[] operator for user programs. */
+
void operator delete[](void *p, size_t size) {
free(p);
}
+/** @file mymemory.h
+ * @brief Memory allocation functions.
+ */
+
#ifndef _MY_MEMORY_H
#define _MY_MEMORY_H
#include <stdlib.h>
SnapshotStack * snapshotObject;
#ifdef MAC
+/** The SnapshotGlobalSegments function computes the memory regions
+ * that may contain globals and then configures the snapshotting
+ * library to snapshot them.
+ */
+
void SnapshotGlobalSegments(){
int pid = getpid();
char buf[9000], execname[100];
pclose(map);
}
#else
+/** The SnapshotGlobalSegments function computes the memory regions
+ * that may contain globals and then configures the snapshotting
+ * library to snapshot them.
+ */
void SnapshotGlobalSegments(){
int pid = getpid();
char buf[9000], filename[100];
}
#endif
-//class definition of SnapshotStack.....
-//declaration of constructor....
SnapshotStack::SnapshotStack(){
SnapshotGlobalSegments();
stack=NULL;
SnapshotStack::~SnapshotStack(){
}
+
+/** This method returns to the last snapshot before the inputted
+ * sequence number. This function must be called from the model
+ * checking thread and not from a snapshotted stack.
+ * @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) {
}
}
+/** This method takes a snapshot at the given sequence number.
+ */
+
void SnapshotStack::snapshotStep(int seqindex) {
struct stackEntry *tmp=(struct stackEntry *)MYMALLOC(sizeof(struct stackEntry));
tmp->next=stack;
+/** @file snapshot-interface.h
+ * @brief C++ layer on top of snapshotting system.
+ */
+
+
#ifndef __SNAPINTERFACE_H
#define __SNAPINTERFACE_H
#include "mymemory.h"
}
#endif //nothing to initialize for the fork based snapshotting.
+/** HandlePF is the page fault handler for mprotect based snapshotting
+ * algorithm.
+ */
+
void HandlePF( int sig, siginfo_t *si, void * unused){
#if USE_MPROTECT_SNAPSHOT
if( si->si_code == SEGV_MAPERR ){
#endif //nothing to handle for non snapshotting case.
}
-//Return a page aligned address for the address being added
-//as a side effect the numBytes are also changed.
+/** ReturnPageAlignedAddress returns a page aligned address for the
+ * address being added as a side effect the numBytes are also changed.
+ */
+
void * ReturnPageAlignedAddress(void * addr) {
return (void *)(((uintptr_t)addr)&~(PAGESIZE-1));
}
-//Return a page aligned address for the address being added
-//as a side effect the numBytes are also changed.
+/** PageAlignedAdressUpdate return a page aligned address for the
+ * address being added as a side effect the numBytes are also changed.
+ */
+
void * PageAlignAddressUpward(void * addr) {
return (void *)((((uintptr_t)addr)+PAGESIZE-1)&~(PAGESIZE-1));
}
#ifdef __cplusplus
}
#endif
+
+/** The initSnapShotLibrary function initializes the Snapshot library.
+ * @param entryPoint the function that should run the program.
+ */
void initSnapShotLibrary(unsigned int numbackingpages,
unsigned int numsnapshots, unsigned int nummemoryregions,
unsigned int numheappages, VoidFuncPtr entryPoint) {
#endif
}
-/* This function assumes that addr is page aligned */
+
+/** The addMemoryRegionToSnapShot function assumes that addr is page aligned.
+ */
void addMemoryRegionToSnapShot( void * addr, unsigned int numPages) {
#if USE_MPROTECT_SNAPSHOT
unsigned int memoryregion=snapshotrecord->lastRegion++;
snapshotrecord->regionsToSnapShot[ memoryregion ].sizeInPages=numPages;
#endif //NOT REQUIRED IN THE CASE OF FORK BASED SNAPSHOTS.
}
-//take snapshot
+
+/** The takeSnapshot function takes a snapshot.
+ * @return The snapshot identifier.
+ */
+
snapshot_id takeSnapshot( ){
#if USE_MPROTECT_SNAPSHOT
for(unsigned int region=0; region<snapshotrecord->lastRegion;region++) {
return snapshotid;
#endif
}
+
+/** The rollBack function rollback to the given snapshot identifier.
+ * @param theID is the snapshot identifier to rollback to.
+ */
+
void rollBack( snapshot_id theID ){
#if USE_MPROTECT_SNAPSHOT
std::map< void *, bool, std::less< void * >, MyAlloc< std::pair< const void *, bool > > > duplicateMap;
#endif
}
+/** The finalize method shuts down the snapshotting system. */
+
void finalize(){
#if !USE_MPROTECT_SNAPSHOT
sTheRecord->mbFinalize = true;
+/** @file snapshot.h
+ * @brief Snapshotting interface header file.
+ */
+
#ifndef _SNAPSHOT_H
#define _SNAPSHOT_H
+/** @file snapshotimp.h
+ * @brief Snapshotting implementation header file..
+ */
+
#ifndef _SNAPSHOTIMP_H
#define _SNAPSHOTIMP_H
#include "snapshot.h"