Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
model-checker : add type in s_mc_mem_region (0=std_heap, 1=libsimgrid)
[simgrid.git] / src / mc / mc_checkpoint.c
index dc85a3b..a2bb87b 100644 (file)
@@ -1,15 +1,20 @@
 #include <libgen.h>
 #include "private.h"
 
-static mc_mem_region_t MC_region_new(void *start_addr, size_t size);
+
+XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_checkpoint, mc,
+                                "Logging specific to mc_checkpoint");
+
+static mc_mem_region_t MC_region_new(int type, void *start_addr, size_t size);
 static void MC_region_restore(mc_mem_region_t reg);
 static void MC_region_destroy(mc_mem_region_t reg);
 
-static void MC_snapshot_add_region(mc_snapshot_t snapshot, void *start_addr, size_t size);
+static void MC_snapshot_add_region(mc_snapshot_t snapshot, int type, void *start_addr, size_t size);
 
-static mc_mem_region_t MC_region_new(void *start_addr, size_t size)
+static mc_mem_region_t MC_region_new(int type, void *start_addr, size_t size)
 {
   mc_mem_region_t new_reg = xbt_new0(s_mc_mem_region_t, 1);
+  new_reg->type = type;
   new_reg->start_addr = start_addr;
   new_reg->size = size;
   new_reg->data = xbt_malloc0(size);
@@ -30,9 +35,9 @@ static void MC_region_destroy(mc_mem_region_t reg)
   xbt_free(reg);
 }
 
-static void MC_snapshot_add_region(mc_snapshot_t snapshot, void *start_addr, size_t size)
+static void MC_snapshot_add_region(mc_snapshot_t snapshot, int type, void *start_addr, size_t size)
 {
-  mc_mem_region_t new_reg = MC_region_new(start_addr, size);
+  mc_mem_region_t new_reg = MC_region_new(type, start_addr, size);
   snapshot->regions = xbt_realloc(snapshot->regions, (snapshot->num_reg + 1) * sizeof(mc_mem_region_t));
   snapshot->regions[snapshot->num_reg] = new_reg;
   snapshot->num_reg++;
@@ -45,17 +50,19 @@ void MC_take_snapshot(mc_snapshot_t snapshot)
   s_map_region reg;
   memory_map_t maps = get_memory_map();
 
+  XBT_DEBUG("Take snapshot");
+
   /* Save the std heap and the writable mapped pages of libsimgrid */
   while (i < maps->mapsize) {
     reg = maps->regions[i];
     if ((reg.prot & PROT_WRITE)){
       if (maps->regions[i].pathname == NULL){
         if (reg.start_addr == std_heap){ // only save the std heap (and not the raw one)
-          MC_snapshot_add_region(snapshot, reg.start_addr, (char*)reg.end_addr - (char*)reg.start_addr);
+          MC_snapshot_add_region(snapshot, 0, 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);
+          MC_snapshot_add_region(snapshot, 1, reg.start_addr, (char*)reg.end_addr - (char*)reg.start_addr);
         }
       }
     }