Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[mc] Use mc_snapshot_read in snapshot_compare (compatibility with per-page snapshots)
[simgrid.git] / src / mc / mc_compare.c
index 60bc78f..0d9389a 100644 (file)
@@ -319,8 +319,7 @@ static int compare_global_variables(int region_type, mc_mem_region_t r1,
 static int compare_local_variables(mc_snapshot_t snapshot1,
                                    mc_snapshot_t snapshot2,
                                    mc_snapshot_stack_t stack1,
-                                   mc_snapshot_stack_t stack2, void *heap1,
-                                   void *heap2)
+                                   mc_snapshot_stack_t stack2)
 {
   if (!compared_pointers) {
     compared_pointers =
@@ -338,7 +337,7 @@ static int compare_local_variables(mc_snapshot_t snapshot1,
   } else {
     unsigned int cursor = 0;
     local_variable_t current_var1, current_var2;
-    int offset1, offset2, res;
+    int res;
     while (cursor < xbt_dynar_length(stack1->local_variables)) {
       current_var1 =
           (local_variable_t) xbt_dynar_get_as(stack1->local_variables, cursor,
@@ -358,11 +357,8 @@ static int compare_local_variables(mc_snapshot_t snapshot1,
              current_var1->ip, current_var2->ip);
         return 1;
       }
-      offset1 = (char *) current_var1->address - (char *) std_heap;
-      offset2 = (char *) current_var2->address - (char *) std_heap;
       // TODO, fix current_varX->subprogram->name to include name if DW_TAG_inlined_subprogram
 
-
         dw_type_t subtype = current_var1->type;
         res =
             compare_areas_with_type(current_var1->address, snapshot1, mc_get_snapshot_region(current_var1->address, snapshot1),
@@ -373,8 +369,8 @@ static int compare_local_variables(mc_snapshot_t snapshot1,
         // TODO, fix current_varX->subprogram->name to include name if DW_TAG_inlined_subprogram
         XBT_VERB
             ("Local variable %s (%p - %p) in frame %s  is different between snapshots",
-             current_var1->name, (char *) heap1 + offset1,
-             (char *) heap2 + offset2, current_var1->subprogram->name);
+             current_var1->name, current_var1->address, current_var2->address,
+             current_var1->subprogram->name);
         xbt_dynar_free(&compared_pointers);
         compared_pointers = NULL;
         return res;
@@ -483,10 +479,11 @@ int snapshot_compare(void *state1, void *state2)
 #endif
 
   /* Init heap information used in heap comparison algorithm */
-  res_init =
-      init_heap_information((xbt_mheap_t) s1->regions[0]->data,
-                            (xbt_mheap_t) s2->regions[0]->data, s1->to_ignore,
-                            s2->to_ignore);
+  xbt_mheap_t heap1 = (xbt_mheap_t) mc_snapshot_read(std_heap, s1,
+    alloca(sizeof(struct mdesc)), sizeof(struct mdesc));
+  xbt_mheap_t heap2 = (xbt_mheap_t) mc_snapshot_read(std_heap, s2,
+    alloca(sizeof(struct mdesc)), sizeof(struct mdesc));
+  res_init = init_heap_information(heap1, heap2, s1->to_ignore, s2->to_ignore);
   if (res_init == -1) {
 #ifdef MC_DEBUG
     XBT_DEBUG("(%d - %d) Different heap information", num1, num2);
@@ -523,8 +520,7 @@ int snapshot_compare(void *state1, void *state2)
         (mc_snapshot_stack_t) xbt_dynar_get_as(s2->stacks, cursor,
                                                mc_snapshot_stack_t);
     diff_local =
-        compare_local_variables(s1, s2, stack1, stack2, s1->regions[0]->data,
-                                s2->regions[0]->data);
+        compare_local_variables(s1, s2, stack1, stack2);
     if (diff_local > 0) {
 #ifdef MC_DEBUG
       if (is_diff == 0) {