Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
model-checker : update include file
[simgrid.git] / src / mc / mc_checkpoint.c
index 5df49f1..5910aeb 100644 (file)
@@ -1,5 +1,11 @@
+/* Copyright (c) 2008-2012 Da SimGrid Team. All rights reserved.            */
+
+/* This program is free software; you can redistribute it and/or modify it
+ * under the terms of the license (GNU LGPL) which comes with this package. */
+
 #include <libgen.h>
-#include "private.h"
+#include "mc_private.h"
+#include "xbt/module.h"
 
 
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_checkpoint, mc,
@@ -18,7 +24,7 @@ static mc_mem_region_t MC_region_new(int type, void *start_addr, size_t size)
   new_reg->start_addr = start_addr;
   new_reg->size = size;
   new_reg->data = xbt_malloc0(size);
-  XBT_DEBUG("New reg data %p, start_addr %p", new_reg->data, start_addr);
+  XBT_DEBUG("New reg data %p, start_addr %p, size %zu", new_reg->data, start_addr, size);
   memcpy(new_reg->data, start_addr, size);
   
   return new_reg;
@@ -32,7 +38,7 @@ static void MC_region_restore(mc_mem_region_t reg)
     memory_map_t maps = get_memory_map();
     MC_UNSET_RAW_MEM;
     unsigned int i=0;
-    s_map_region r;
+    s_map_region_t r;
     while(i < maps->mapsize){
       r = maps->regions[i];
       if (maps->regions[i].pathname != NULL){
@@ -72,10 +78,7 @@ static void MC_snapshot_add_region(mc_snapshot_t snapshot, int type, void *start
     XBT_DEBUG("New region libsimgrid (%zu)", size);
     break;
   case 2 : 
-    XBT_DEBUG("New region program (%zu)", size);
-    break;
-  case 3 : 
-    XBT_DEBUG("New region stack (%zu)", size);
+    XBT_DEBUG("New region program data (%zu)", size);
     break;
   }
   mc_mem_region_t new_reg = MC_region_new(type, start_addr, size);
@@ -88,7 +91,7 @@ static void MC_snapshot_add_region(mc_snapshot_t snapshot, int type, void *start
 void MC_take_snapshot(mc_snapshot_t snapshot)
 {
   unsigned int i = 0;
-  s_map_region reg;
+  s_map_region_t reg;
   memory_map_t maps = get_memory_map();
 
   /* Save the std heap and the writable mapped pages of libsimgrid */
@@ -111,11 +114,10 @@ void MC_take_snapshot(mc_snapshot_t snapshot)
   /* FIXME: free the memory map */
 }
 
-
 void MC_take_snapshot_liveness(mc_snapshot_t snapshot)
 {
   unsigned int i = 0;
-  s_map_region reg;
+  s_map_region_t reg;
   memory_map_t maps = get_memory_map();
 
   for(i=0; i< snapshot->num_reg; i++){
@@ -138,49 +140,7 @@ void MC_take_snapshot_liveness(mc_snapshot_t snapshot)
         if (!memcmp(basename(maps->regions[i].pathname), "libsimgrid", 10)){
           MC_snapshot_add_region(snapshot, 1, reg.start_addr, (char*)reg.end_addr - (char*)reg.start_addr);
         } else {
-         if (!memcmp(basename(maps->regions[i].pathname), basename(prog_name), strlen(basename(prog_name)))){
-           MC_snapshot_add_region(snapshot, 2, reg.start_addr, (char*)reg.end_addr - (char*)reg.start_addr);
-         } /*else {
-           if (!memcmp(maps->regions[i].pathname, "[stack]", 7)){
-             MC_snapshot_add_region(snapshot, 3, reg.start_addr, (char*)reg.end_addr - (char*)reg.start_addr);
-           }
-           }*/
-       }
-      }
-    }
-    i++;
-  }
-
-  /* FIXME: free the memory map */
-}
-
-void MC_take_snapshot_to_restore_liveness(mc_snapshot_t snapshot)
-{
-  unsigned int i = 0;
-  s_map_region reg;
-  memory_map_t maps = get_memory_map();
-
-  for(i=0; i< snapshot->num_reg; i++){
-    MC_region_destroy(snapshot->regions[i]);
-  }
-
-  snapshot->num_reg = 0;
-
-  i = 0;
-
-  /* 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, 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, 1, reg.start_addr, (char*)reg.end_addr - (char*)reg.start_addr);
-        } else {
-         if (!memcmp(basename(maps->regions[i].pathname), basename(prog_name), strlen(basename(prog_name)))){
+         if (!memcmp(basename(maps->regions[i].pathname), basename(xbt_binary_name), strlen(basename(xbt_binary_name)))){
            MC_snapshot_add_region(snapshot, 2, reg.start_addr, (char*)reg.end_addr - (char*)reg.start_addr);
          } 
        }
@@ -205,10 +165,7 @@ void MC_restore_snapshot(mc_snapshot_t snapshot)
       XBT_DEBUG("libsimgrid (data) restored");
       break;
     case 2:
-      XBT_DEBUG("program (data) restored");
-      break;
-    case 3:
-      XBT_DEBUG("stack restored");
+      XBT_DEBUG("data program restored");
       break;
     }