X-Git-Url: http://plrg.eecs.uci.edu/git/?p=model-checker.git;a=blobdiff_plain;f=snapshot.cc;h=b7e4ec1ca5ae789915e6ff2931e73668bb845034;hp=9020bb70e840ab445ab059fe3a0a2cbda7fb7653;hb=0f0bd83aa330ef6461acb1b0758615e1e15a9322;hpb=123c66e0c1b0f58aae2916cc22b2100143a2ceb4 diff --git a/snapshot.cc b/snapshot.cc index 9020bb7..b7e4ec1 100644 --- a/snapshot.cc +++ b/snapshot.cc @@ -3,7 +3,7 @@ #include #include #include -#include +#include "hashtable.h" #include #include #include "snapshot.h" @@ -17,6 +17,8 @@ #include #include +#include "common.h" + #define FAILURE(mesg) { printf("failed in the API: %s with errno relative message: %s\n", mesg, strerror( errno ) ); exit(EXIT_FAILURE); } #ifdef CONFIG_SSDEBUG @@ -86,6 +88,7 @@ static void initSnapShotRecord(unsigned int numbackingpages, unsigned int numsna static void HandlePF( int sig, siginfo_t *si, void * unused){ if( si->si_code == SEGV_MAPERR ){ printf("Real Fault at %p\n", si->si_addr); + print_trace(); exit( EXIT_FAILURE ); } void* addr = ReturnPageAlignedAddress(si->si_addr); @@ -281,7 +284,7 @@ snapshot_id takeSnapshot( ){ */ void rollBack( snapshot_id theID ){ #if USE_MPROTECT_SNAPSHOT - std::map< void *, bool, std::less< void * >, MyAlloc< std::pair< const void *, bool > > > duplicateMap; + HashTable< void *, bool, uintptr_t, 4, MYMALLOC, MYCALLOC, MYFREE> duplicateMap; for(unsigned int region=0; regionlastRegion;region++) { if( mprotect(snapshotrecord->regionsToSnapShot[region].basePtr, snapshotrecord->regionsToSnapShot[region].sizeInPages*sizeof(struct SnapShotPage), PROT_READ | PROT_WRITE ) == -1 ){ perror("mprotect"); @@ -290,14 +293,8 @@ void rollBack( snapshot_id theID ){ } } for(unsigned int page=snapshotrecord->snapShots[theID].firstBackingPage; pagelastBackingPage; page++) { - bool oldVal = false; - if( duplicateMap.find( snapshotrecord->backingRecords[page].basePtrOfPage ) != duplicateMap.end() ){ - oldVal = true; - } - else{ - duplicateMap[ snapshotrecord->backingRecords[page].basePtrOfPage ] = true; - } - if( !oldVal ){ + if( !duplicateMap.contains(snapshotrecord->backingRecords[page].basePtrOfPage )) { + duplicateMap.put(snapshotrecord->backingRecords[page].basePtrOfPage, true); memcpy(snapshotrecord->backingRecords[page].basePtrOfPage, &snapshotrecord->backingStore[page], sizeof(struct SnapShotPage)); } }