From 843f65d8af9e9b4c73f844ecc2a22fbafaee7967 Mon Sep 17 00:00:00 2001 From: Brian Demsky Date: Sun, 3 Jun 2012 22:35:41 -0700 Subject: [PATCH] Changes needed to run on OS X... Example runs on my laptop now. No need to push code back and forth to test... Out of time for fun hack, have to get back to real work now. :( --- snapshot-interface.cc | 3 +-- snapshot.cc | 2 ++ snapshot.h | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/snapshot-interface.cc b/snapshot-interface.cc index cece58d..58e1dd2 100644 --- a/snapshot-interface.cc +++ b/snapshot-interface.cc @@ -56,11 +56,10 @@ void SnapshotGlobalSegments(){ sscanf(buf, "%22s %p-%p [%5dK] %c%c%c/%c%c%c SM=%3s %200s\n", &type, &begin, &end, &size, &r, &w, &x, &mr, &mw, &mx, smstr, regionname); if (w == 'w' && (strstr(regionname, MYBINARYNAME) || strstr(regionname, MYLIBRARYNAME))) { - printf("%s\n", buf); - size_t len = ((uintptr_t)end - (uintptr_t)begin) / PAGESIZE; if (len != 0) addMemoryRegionToSnapShot(begin, len); + DEBUG("%s\n", buf); DEBUG("%45s: %18p - %18p\t%c%c%c%c\n", regionname, begin, end, r, w, x, p); } } diff --git a/snapshot.cc b/snapshot.cc index e3ca558..2440b6e 100644 --- a/snapshot.cc +++ b/snapshot.cc @@ -68,6 +68,7 @@ void HandlePF( int sig, siginfo_t *si, void * unused){ exit( EXIT_FAILURE ); } void* addr = ReturnPageAlignedAddress(si->si_addr); + unsigned int backingpage=snapshotrecord->lastBackingPage++; //Could run out of pages... if (backingpage==snapshotrecord->maxBackingPages) { printf("Out of backing pages at %p\n", si->si_addr); @@ -155,6 +156,7 @@ void initSnapShotLibrary(unsigned int numbackingpages, siginfo_t si; si.si_addr=ss.ss_sp; + si.si_code = 0; HandlePF(SIGSEGV, &si, NULL); snapshotrecord->lastBackingPage--; //remove the fake page we copied diff --git a/snapshot.h b/snapshot.h index 3b33a7e..cc5e7e5 100644 --- a/snapshot.h +++ b/snapshot.h @@ -10,7 +10,7 @@ #define USE_MPROTECT_SNAPSHOT 1 /* Size of signal stack */ -#define SIGSTACKSIZE 16384 +#define SIGSTACKSIZE 32768 void addMemoryRegionToSnapShot( void * ptr, unsigned int numPages ); -- 2.34.1