Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
fix MC in 32bit [Marion, still learning git -- shame on Lucas]
[simgrid.git] / src / mc / mc_checkpoint.c
index c1e8ea9..f2d404b 100644 (file)
@@ -1,3 +1,4 @@
+#include <libgen.h>
 #include "private.h"
 
 static mc_mem_region_t MC_region_new(void *start_addr, size_t size);
@@ -40,19 +41,29 @@ 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;
   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++) {
+  /* Save the std heap and the writable mapped pages of libsimgrid */
+  while (i < maps->mapsize) {
     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);
+    if ((reg.prot & PROT_WRITE)){
+      if (maps->regions[i].pathname == NULL){
+        if (reg.start_addr == std_heap){
+          MC_snapshot_add_region(snapshot, reg.start_addr, (char*)reg.end_addr - (char*)reg.start_addr);
+        }
+      } else {
+        if (!memcmp(basename(maps->regions[i].pathname), "libsimgrid", 10)){
+          MC_snapshot_add_region(snapshot, reg.start_addr, (char*)reg.end_addr - (char*)reg.start_addr);
+        }
+      }
     }
+    i++;
   }
+
+
+  /* FIXME: free the memory map */
 }
 
 void MC_restore_snapshot(mc_snapshot_t snapshot)