From: cristianrosa Date: Thu, 20 Jan 2011 15:45:11 +0000 (+0000) Subject: Bugfix: save only the state of the heap and libsimgrid. X-Git-Tag: v3.6_beta2~473 X-Git-Url: http://bilbo.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/de30dba5106391865d3f7fe96bb6e6782f0ee5b5?hp=aea722d33a8fba9c4913c4378fc06e41f808c56f Bugfix: save only the state of the heap and libsimgrid. git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@9456 48e7efb5-ca39-0410-a469-dd3cf9ba447f --- diff --git a/src/mc/mc_checkpoint.c b/src/mc/mc_checkpoint.c index c1e8ea98aa..a43de263c4 100644 --- a/src/mc/mc_checkpoint.c +++ b/src/mc/mc_checkpoint.c @@ -1,3 +1,4 @@ +#include #include "private.h" static mc_mem_region_t MC_region_new(void *start_addr, size_t size); @@ -40,19 +41,35 @@ static void MC_snapshot_add_region(mc_snapshot_t snapshot, void *start_addr, siz void MC_take_snapshot(mc_snapshot_t snapshot) { - unsigned int i; + unsigned int i = 0; + char copy = 0; s_map_region reg; memory_map_t maps = get_memory_map(); - /* Save all the writable mapped pages except the raw_heap and the stack */ - for (i = 0; i < maps->mapsize; i++) { - reg = maps->regions[i]; - if((reg.prot & PROT_WRITE) && reg.start_addr != raw_heap - && (reg.pathname == NULL || strncmp(reg.pathname, "[stack]", 7))){ - MC_snapshot_add_region(snapshot, reg.start_addr, - (char*)reg.end_addr - (char*)reg.start_addr); + /* Save the std heap and the writtable mapped pages of libsimgrid */ + while(i < maps->mapsize + && (maps->regions[i].pathname == NULL + || memcmp(maps->regions[i].pathname, "/lib/ld", 7))){ + reg = maps->regions[i]; + if((reg.prot & PROT_WRITE)){ + if(reg.start_addr == std_heap){ + MC_snapshot_add_region(snapshot, reg.start_addr, + (char*)reg.end_addr - (char*)reg.start_addr); + + }else if(copy || (reg.pathname != NULL + && !memcmp(basename(maps->regions[i].pathname), "libsimgrid", 10))){ + MC_snapshot_add_region(snapshot, reg.start_addr, + (char*)reg.end_addr - (char*)reg.start_addr); + /* This will force the save of the regions in the next iterations, + * but we assume that ld will be found mapped and break the loop + * before saving a wrong region.(This is ugly I know). */ + copy = TRUE; + } + } + i++; } - } + + /* FIXME: free the memory map */ } void MC_restore_snapshot(mc_snapshot_t snapshot)