#endif
-/** The initSnapShotLibrary function initializes the Snapshot library.
+/** The initSnapshotLibrary function initializes the snapshot library.
* @param entryPoint the function that should run the program.
*/
#if USE_MPROTECT_SNAPSHOT
-void initSnapShotLibrary(unsigned int numbackingpages,
+void initSnapshotLibrary(unsigned int numbackingpages,
unsigned int numsnapshots, unsigned int nummemoryregions,
unsigned int numheappages, VoidFuncPtr entryPoint) {
/* Setup a stack for our signal handler.... */
stack_t ss;
- ss.ss_sp = model_malloc(SIGSTACKSIZE);
+ ss.ss_sp = PageAlignAddressUpward(model_malloc(SIGSTACKSIZE+PAGESIZE-1));
ss.ss_size = SIGSTACKSIZE;
ss.ss_flags = 0;
sigaltstack(&ss, NULL);
entryPoint();
}
#else
-void initSnapShotLibrary(unsigned int numbackingpages,
+void initSnapshotLibrary(unsigned int numbackingpages,
unsigned int numsnapshots, unsigned int nummemoryregions,
unsigned int numheappages, VoidFuncPtr entryPoint) {
basemySpace=system_malloc((numheappages+1)*PAGESIZE);
* @param theID is the snapshot identifier to rollback to.
*/
void rollBack( snapshot_id theID ){
+#if USE_MPOTECT_SNAPSHOT==2
+ if (snapshotrecord->lastSnapShot==(theID+1)) {
+ for(unsigned int page=snapshotrecord->snapShots[theID].firstBackingPage; page<snapshotrecord->lastBackingPage; page++) {
+ memcpy(snapshotrecord->backingRecords[page].basePtrOfPage, &snapshotrecord->backingStore[page], sizeof(struct SnapShotPage));
+ }
+ return;
+ }
+#endif
+
#if USE_MPROTECT_SNAPSHOT
- HashTable< void *, bool, uintptr_t, 4, model_malloc, MYCALLOC, MYFREE> duplicateMap;
+ HashTable< void *, bool, uintptr_t, 4, model_malloc, model_calloc, model_free> duplicateMap;
for(unsigned int region=0; region<snapshotrecord->lastRegion;region++) {
if( mprotect(snapshotrecord->regionsToSnapShot[region].basePtr, snapshotrecord->regionsToSnapShot[region].sizeInPages*sizeof(struct SnapShotPage), PROT_READ | PROT_WRITE ) == -1 ){
perror("mprotect");