X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=snapshot.cc;h=fb00d1511c8505df3c34fc22eaa0b7adad838937;hb=6b87c110fbda87ccec4f58b1e292d5f9434c8691;hp=59aad7220dc2388d2337f30cedb4584ecd6720e8;hpb=99928ab8d61239d499f5bf45ae9a2b41595350f8;p=model-checker.git diff --git a/snapshot.cc b/snapshot.cc index 59aad72..fb00d15 100644 --- a/snapshot.cc +++ b/snapshot.cc @@ -30,6 +30,13 @@ /* extern declaration definition */ struct SnapShot * snapshotrecord = NULL; +/** PageAlignedAdressUpdate return a page aligned address for the + * address being added as a side effect the numBytes are also changed. + */ +static void * PageAlignAddressUpward(void * addr) { + return (void *)((((uintptr_t)addr)+PAGESIZE-1)&~(PAGESIZE-1)); +} + #if !USE_MPROTECT_SNAPSHOT /** @statics * These variables are necessary because the stack is shared region and @@ -48,13 +55,6 @@ static snapshot_id snapshotid = 0; #else /* USE_MPROTECT_SNAPSHOT */ -/** PageAlignedAdressUpdate return a page aligned address for the - * address being added as a side effect the numBytes are also changed. - */ -static void * PageAlignAddressUpward(void * addr) { - return (void *)((((uintptr_t)addr)+PAGESIZE-1)&~(PAGESIZE-1)); -} - /** ReturnPageAlignedAddress returns a page aligned address for the * address being added as a side effect the numBytes are also changed. */ @@ -88,6 +88,8 @@ 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(); + printf("For debugging, place breakpoint at: %s:%d\n", + __FILE__, __LINE__); exit( EXIT_FAILURE ); } void* addr = ReturnPageAlignedAddress(si->si_addr); @@ -174,6 +176,12 @@ void initSnapshotLibrary(unsigned int numbackingpages, void * pagealignedbase=PageAlignAddressUpward(basemySpace); user_snapshot_space = create_mspace_with_base(pagealignedbase, numheappages * PAGESIZE, 1); addMemoryRegionToSnapShot(pagealignedbase, numheappages); + + void *base_model_snapshot_space = model_malloc((numheappages + 1) * PAGESIZE); + pagealignedbase = PageAlignAddressUpward(base_model_snapshot_space); + model_snapshot_space = create_mspace_with_base(pagealignedbase, numheappages * PAGESIZE, 1); + addMemoryRegionToSnapShot(pagealignedbase, numheappages); + entryPoint(); } #else @@ -183,6 +191,10 @@ void initSnapshotLibrary(unsigned int numbackingpages, if (!snapshotrecord) createSharedMemory(); + void *base_model_snapshot_space = malloc((numheappages + 1) * PAGESIZE); + void *pagealignedbase = PageAlignAddressUpward(base_model_snapshot_space); + model_snapshot_space = create_mspace_with_base(pagealignedbase, numheappages * PAGESIZE, 1); + //step 2 setup the stack context. ucontext_t newContext; getcontext( &newContext );