Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
model-checker : if frame name is empty, stop stack unwinding
[simgrid.git] / src / mc / mc_checkpoint.c
index d23fbf5..904d127 100644 (file)
@@ -154,6 +154,8 @@ mc_snapshot_t MC_take_snapshot()
   memory_map_t maps = get_memory_map();
   int nb_reg = 0;
   void *heap = NULL;
+  size_t size = 0;
+  void *start = NULL;
 
   /* Save the std heap and the writable mapped pages of libsimgrid */
   while (i < maps->mapsize) {
@@ -170,17 +172,18 @@ mc_snapshot_t MC_take_snapshot()
         i++;
       } 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);
-          start_data_libsimgrid = reg.start_addr;
+          size = (char*)reg.end_addr - (char*)reg.start_addr;
+          start = reg.start_addr;
           nb_reg++;
           i++;
           reg = maps->regions[i];
           if(reg.pathname == NULL && (reg.prot & PROT_WRITE) && i < maps->mapsize){
-            MC_snapshot_add_region(snapshot, 1, reg.start_addr, (char*)reg.end_addr - (char*)reg.start_addr);
+            size += (char*)reg.end_addr - (char*)reg.start_addr;
             reg = maps->regions[i];
             i++;
             nb_reg++;
           }
+          MC_snapshot_add_region(snapshot, 1, start, size);
         } else {
           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);
@@ -197,24 +200,12 @@ mc_snapshot_t MC_take_snapshot()
           }
         }
       }
-    }else if ((reg.prot & PROT_READ)){
-      if (maps->regions[i].pathname != NULL){
-        if (!memcmp(basename(maps->regions[i].pathname), "libsimgrid", 10)){
-          start_text_libsimgrid = reg.start_addr;
-          libsimgrid_path = strdup(maps->regions[i].pathname);
-        }else{
-          if (!memcmp(basename(maps->regions[i].pathname), basename(xbt_binary_name), strlen(basename(xbt_binary_name)))){
-            start_text_binary = reg.start_addr;
-          }
-        }
-      }
-      i++;
     }else{
       i++;
     }
   }
 
-  if(_surf_mc_visited > 0 || strcmp(_surf_mc_property_file,""))
+  if(_sg_mc_visited > 0 || strcmp(_sg_mc_property_file,""))
     snapshot->stacks = take_snapshot_stacks(heap);
   
   free_memory_map(maps);
@@ -259,9 +250,6 @@ void get_libsimgrid_plt_section(){
   int i, plt_found = 0;
   unsigned long int size, offset;
 
-  if(libsimgrid_path == NULL)
-    libsimgrid_path = get_libsimgrid_path();
-
   char *command = bprintf("objdump --section-headers %s", libsimgrid_path);
 
   fp = popen(command, "r");
@@ -461,16 +449,14 @@ static xbt_strbuff_t get_local_variables_values(void *stack_context, void *heap)
     unw_get_reg(&c, UNW_REG_IP, &ip);
     unw_get_reg(&c, UNW_REG_SP, &sp);
 
-    unw_get_proc_name (&c, frame_name, sizeof (frame_name), &off);
-
-    xbt_strbuff_append(variables, bprintf("ip=%s\n", frame_name));
+    unw_get_proc_name(&c, frame_name, sizeof (frame_name), &off);
 
     frame = xbt_dict_get_or_null(mc_local_variables, frame_name);
 
-    if(frame == NULL){
-      ret = unw_step(&c);
-      continue;
-    }
+    if(frame == NULL)
+      return variables;
+
+    xbt_strbuff_append(variables, bprintf("ip=%s\n", frame_name));
 
     true_ip = (long)frame->low_pc + (long)off;