Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[mc] Try to DRY in MC main loops
[simgrid.git] / src / mc / mc_checkpoint.c
index 2449821..07e80ab 100644 (file)
@@ -171,8 +171,8 @@ static void MC_snapshot_add_region(mc_snapshot_t snapshot, int type,
 static void MC_get_memory_regions(mc_snapshot_t snapshot)
 {
 
-  void *start_heap = ((xbt_mheap_t) std_heap)->base;
-  void *end_heap = ((xbt_mheap_t) std_heap)->breakval;
+  void *start_heap = std_heap->base;
+  void *end_heap = std_heap->breakval;
   MC_snapshot_add_region(snapshot, 0, start_heap, start_heap,
                          (char *) end_heap - (char *) start_heap);
   snapshot->heap_bytes_used = mmalloc_get_bytes_used(std_heap);
@@ -389,12 +389,22 @@ static void mc_fill_local_variables_values(mc_stack_frame_t stack_frame,
     if (current_variable->address != NULL) {
       new_var->address = current_variable->address;
     } else if (current_variable->locations.size != 0) {
-      new_var->address =
-          (void *) mc_dwarf_resolve_locations(&current_variable->locations,
+      s_mc_location_t location;
+      mc_dwarf_resolve_locations(&location, &current_variable->locations,
                                               current_variable->object_info,
                                               &(stack_frame->unw_cursor),
                                               (void *) stack_frame->frame_base,
                                               NULL, process_index);
+
+      switch(mc_get_location_type(&location)) {
+      case MC_LOCATION_TYPE_ADDRESS:
+        new_var->address = location.memory_location;
+        break;
+      case MC_LOCATION_TYPE_REGISTER:
+      default:
+        xbt_die("Cannot handle non-address variable");
+      }
+
     } else {
       xbt_die("No address");
     }
@@ -669,7 +679,13 @@ void MC_restore_snapshot(mc_snapshot_t snapshot)
     }
   }
   if(snapshot->privatization_index >= 0) {
-    smpi_switch_data_segment(snapshot->privatization_index);
+    // We just rewrote the global variables.
+    // The privatisation segment SMPI thinks
+    // is mapped might be inconsistent with the segment which
+    // is really mapped in memory (kernel state).
+    // We ask politely SMPI to map the segment anyway,
+    // even if it thinks it is the current one:
+    smpi_really_switch_data_segment(snapshot->privatization_index);
   }
 #endif