Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
model-checker : conflit
authorMarion Guthmuller <marion.guthmuller@loria.fr>
Tue, 18 Feb 2014 14:41:16 +0000 (15:41 +0100)
committerMarion Guthmuller <marion.guthmuller@loria.fr>
Tue, 18 Feb 2014 14:41:16 +0000 (15:41 +0100)
src/mc/mc_checkpoint.c
src/mc/mc_compare.c
src/mc/mc_dpor.c
src/mc/mc_dwarf.c
src/mc/mc_global.c
src/mc/mc_private.h
src/xbt/mmalloc/mm_diff.c

index fb323a4..5f924c4 100644 (file)
@@ -239,14 +239,17 @@ void MC_init_memory_map_info(){
 
 }
 
+static void MC_post_process_types(mc_object_info_t info) {
+  // Nothing here
+}
+
 /** \brief Finds informations about a given shared object/executable */
 mc_object_info_t MC_find_object_info(memory_map_t maps, char* name) {
   mc_object_info_t result = MC_new_object_info();
   result->file_name = xbt_strdup(name);
-  result->start_data = NULL;
-  result->start_text = NULL;
   MC_find_object_address(maps, result);
   MC_dwarf_get_variables(result);
+  MC_post_process_types(result);
   return result;
 }
 
@@ -262,16 +265,31 @@ static void MC_find_object_address(memory_map_t maps, mc_object_info_t result) {
       // Nothing to do
     }
     else if ((reg.prot & PROT_WRITE)){
-          result->start_data = reg.start_addr;
+          xbt_assert(!result->start_rw,
+            "Multiple read-write segments for %s, not supported",
+            maps->regions[i].pathname);
+          result->start_rw = reg.start_addr;
+          result->end_rw   = reg.end_addr;
     } else if ((reg.prot & PROT_READ) && (reg.prot & PROT_EXEC)){
-          result->start_text = reg.start_addr;
+          xbt_assert(!result->start_exec,
+            "Multiple executable segments for %s, not supported",
+            maps->regions[i].pathname);
+          result->start_exec = reg.start_addr;
+          result->end_exec   = reg.end_addr;
+    }
+    else if((reg.prot & PROT_READ) && !(reg.prot & PROT_EXEC)) {
+        xbt_assert(!result->start_ro,
+          "Multiple read only segments for %s, not supported",
+          maps->regions[i].pathname);
+        result->start_ro = reg.start_addr;
+        result->end_ro   = reg.end_addr;
     }
     i++;
   }
 
   xbt_assert(result->file_name);
-  xbt_assert(result->start_data);
-  xbt_assert(result->start_text);
+  xbt_assert(result->start_rw);
+  xbt_assert(result->start_exec);
 }
 
 /************************************* Take Snapshot ************************************/
@@ -386,7 +404,7 @@ static xbt_dynar_t MC_get_local_variables_values(void *stack_context){
     xbt_abort();
   }
 
-  unw_word_t ip, sp, off;
+  unw_word_t ip, off;
   dw_frame_t frame;
 
   unsigned int cursor = 0;
@@ -402,14 +420,13 @@ static xbt_dynar_t MC_get_local_variables_values(void *stack_context){
   while(ret >= 0 && !stop){
 
     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);
 
     if(!strcmp(frame_name, "smx_ctx_sysv_wrapper")) /* Stop before context switch with maestro */
       stop = 1;
 
-    if((long)ip > (long) mc_libsimgrid_info->start_text)
+    if((long)ip > (long) mc_libsimgrid_info->start_exec)
       frame = xbt_dict_get_or_null(mc_libsimgrid_info->local_variables, frame_name);
     else
       frame = xbt_dict_get_or_null(mc_binary_info->local_variables, frame_name);
@@ -445,7 +462,7 @@ static xbt_dynar_t MC_get_local_variables_values(void *stack_context){
 
     xbt_dynar_foreach(frame->variables, cursor, current_variable){
       
-      if((long)ip > (long)mc_libsimgrid_info->start_text)
+      if((long)ip > (long)mc_libsimgrid_info->start_exec)
         region_type = 1;
       else
         region_type = 2;
@@ -457,8 +474,11 @@ static xbt_dynar_t MC_get_local_variables_values(void *stack_context){
       new_var->type = strdup(current_variable->type_origin);
       new_var->region= region_type;
       
-      if(current_variable->address.location != NULL){
-        new_var->address = (void*) MC_dwarf_resolve_location(&c, current_variable->address.location, frame_pointer_address);
+      /* if(current_variable->address!=NULL) {
+        new_var->address = current_variable->address;
+      } else */
+      if(current_variable->location != NULL){
+        new_var->address = (void*) MC_dwarf_resolve_location(&c, current_variable->location, frame_pointer_address);
       }
 
       xbt_dynar_push(variables, &new_var);
index f9feecf..8d71ad4 100644 (file)
@@ -138,11 +138,9 @@ static int compare_areas_with_type(void *area1, void *area2, xbt_dict_t types, x
     break;
   case DW_TAG_typedef:
   case DW_TAG_volatile_type:
+  case DW_TAG_const_type:
     return compare_areas_with_type(area1, area2, types, other_types, type->dw_type_id, region_size, region_type, start_data, pointer_level);
     break;
-  case DW_TAG_const_type: /* Const variable cannot be modified */
-    return -1;
-    break;
   case DW_TAG_array_type:
     subtype = xbt_dict_get_or_null(types, type->dw_type_id);
     switch(subtype->type){
@@ -160,6 +158,7 @@ static int compare_areas_with_type(void *area1, void *area2, xbt_dict_t types, x
       }
       elm_size = subtype->byte_size;
       break;
+    case DW_TAG_const_type:
     case DW_TAG_typedef:
     case DW_TAG_volatile_type:
       subsubtype = xbt_dict_get_or_null(types, subtype->dw_type_id);
@@ -202,14 +201,29 @@ static int compare_areas_with_type(void *area1, void *area2, xbt_dict_t types, x
 
       pointer_level++;
       
-      if(addr_pointed1 > std_heap && (char *)addr_pointed1 < (char*) std_heap + STD_HEAP_SIZE && addr_pointed2 > std_heap && (char *)addr_pointed2 < (char*) std_heap + STD_HEAP_SIZE){
+      // Some cases are not handled here:
+      // * the pointers lead to different areas (one to the heap, the other to the RW segment ...);
+      // * a pointer leads to the read-only segment of the current object;
+      // * a pointer lead to a different ELF object.
+
+      // The pointers are both in the heap:
+      if(addr_pointed1 > std_heap && (char *)addr_pointed1 < (char*) std_heap + STD_HEAP_SIZE){
+        if(!(addr_pointed2 > std_heap && (char *)addr_pointed2 < (char*) std_heap + STD_HEAP_SIZE))
+          return 1;
         return compare_heap_area(addr_pointed1, addr_pointed2, NULL, types, other_types, type->dw_type_id, pointer_level); 
-      }else if(addr_pointed1 > start_data && (char*)addr_pointed1 <= (char *)start_data + region_size && addr_pointed2 > start_data && (char*)addr_pointed2 <= (char *)start_data + region_size){
+      }
+
+      // The pointers are both in the current object R/W segment:
+      else if(addr_pointed1 > start_data && (char*)addr_pointed1 <= (char *)start_data + region_size){
+        if(!(addr_pointed2 > start_data && (char*)addr_pointed2 <= (char *)start_data + region_size))
+          return 1;
         if(type->dw_type_id == NULL)
           return  (addr_pointed1 != addr_pointed2);
         else
           return  compare_areas_with_type(addr_pointed1, addr_pointed2, types, other_types, type->dw_type_id, region_size, region_type, start_data, pointer_level); 
-      }else{
+      }
+
+      else{
         return (addr_pointed1 != addr_pointed2);
       }
     }
@@ -248,8 +262,8 @@ static int compare_global_variables(int region_type, mc_mem_region_t r1, mc_mem_
   dw_variable_t current_var;
   size_t offset;
   void *start_data;
-  void* start_data_binary = mc_binary_info->start_data;
-  void* start_data_libsimgrid = mc_libsimgrid_info->start_data;
+  void* start_data_binary = mc_binary_info->start_rw;
+  void* start_data_libsimgrid = mc_libsimgrid_info->start_rw;
 
   mc_object_info_t object_info = NULL;
   mc_object_info_t other_object_info = NULL;
@@ -268,10 +282,14 @@ static int compare_global_variables(int region_type, mc_mem_region_t r1, mc_mem_
 
   xbt_dynar_foreach(variables, cursor, current_var){
 
-    if(region_type == 2)
-      offset = (char *)current_var->address.address - (char *)start_data_binary;
-    else
-      offset = (char *)current_var->address.address - (char *)start_data_libsimgrid;
+    // If the variable is not in this object, skip it:
+    // We do not expect to find a pointer to something which is not reachable
+    // by the global variables.
+    if((char*) current_var->address < (char*) object_info->start_rw
+      || (char*) current_var->address > (char*) object_info->end_rw)
+       continue;
+
+    offset = (char *)current_var->address - (char *)object_info->start_rw;
 
     res = compare_areas_with_type((char *)r1->data + offset, (char *)r2->data + offset, types, other_types, current_var->type_origin, r1->size, region_type, start_data, 0);
     if(res == 1){
@@ -291,8 +309,8 @@ static int compare_global_variables(int region_type, mc_mem_region_t r1, mc_mem_
 }
 
 static int compare_local_variables(mc_snapshot_stack_t stack1, mc_snapshot_stack_t stack2, void *heap1, void *heap2){
-  void* start_data_binary = mc_binary_info->start_data;
-  void* start_data_libsimgrid = mc_libsimgrid_info->start_data;
+  void* start_data_binary = mc_binary_info->start_rw;
+  void* start_data_libsimgrid = mc_libsimgrid_info->start_rw;
 
   if(!compared_pointers){
     compared_pointers = xbt_dynar_new(sizeof(pointers_pair_t), pointers_pair_free_voidp);
@@ -528,55 +546,38 @@ int snapshot_compare(void *state1, void *state2){
     cursor++;
   }
 
-  #ifdef MC_DEBUG
-    if(is_diff == 0)
-      xbt_os_walltimer_stop(timer);
-    xbt_os_walltimer_start(timer);
-  #endif
 
-  /* Compare binary global variables */
-  is_diff = compare_global_variables(2, s1->regions[2], s2->regions[2]);
-  if(is_diff != 0){
-    #ifdef MC_DEBUG
-      xbt_os_walltimer_stop(timer);
-      mc_comp_times->binary_global_variables_comparison_time = xbt_os_timer_elapsed(timer);
-      XBT_DEBUG("(%d - %d) Different global variables in binary", num1, num2);
-      errors++;
-    #else
-      #ifdef MC_VERBOSE
-      XBT_VERB("(%d - %d) Different global variables in binary", num1, num2);
-      #endif
 
-      reset_heap_information();
-      xbt_os_walltimer_stop(timer);
-      xbt_os_timer_free(timer);
-      xbt_os_walltimer_stop(global_timer);
-      mc_snapshot_comparison_time = xbt_os_timer_elapsed(global_timer);
-      xbt_os_timer_free(global_timer);
+ const char* names[3] = { "?", "libsimgrid", "binary" };
+#ifdef MC_DEBUG
+ double *times[3] = {
+   NULL,
+   &mc_comp_times->libsimgrid_global_variables_comparison_time,
+   &mc_comp_times->binary_global_variables_comparison_time
+ };
+#endif
 
-      return 1;
+ int k=0;
+ for(k=2; k!=0; --k) {
+    #ifdef MC_DEBUG
+      if(is_diff == 0)
+        xbt_os_walltimer_stop(timer);
+      xbt_os_walltimer_start(timer);
     #endif
-  }
 
-  #ifdef MC_DEBUG
-    if(is_diff == 0)
-      xbt_os_walltimer_stop(timer);
-    xbt_os_walltimer_start(timer);
-  #endif
-
-  /* Compare libsimgrid global variables */
-  is_diff = compare_global_variables(1, s1->regions[1], s2->regions[1]);
+  /* Compare global variables */
+  is_diff = compare_global_variables(k, s1->regions[k], s2->regions[k]);
   if(is_diff != 0){
     #ifdef MC_DEBUG
       xbt_os_walltimer_stop(timer);
-      mc_comp_times->libsimgrid_global_variables_comparison_time = xbt_os_timer_elapsed(timer);
-      XBT_DEBUG("(%d - %d) Different global variables in libsimgrid", num1, num2);
+      *times[k] = xbt_os_timer_elapsed(timer);
+      XBT_DEBUG("(%d - %d) Different global variables in %s", num1, num2, names[k]);
       errors++;
     #else
       #ifdef MC_VERBOSE
-      XBT_VERB("(%d - %d) Different global variables in libsimgrid", num1, num2);
+      XBT_VERB("(%d - %d) Different global variables in %s", num1, num2, names[k]);
       #endif
-        
+
       reset_heap_information();
       xbt_os_walltimer_stop(timer);
       xbt_os_timer_free(timer);
@@ -587,6 +588,7 @@ int snapshot_compare(void *state1, void *state2){
       return 1;
     #endif
   }
+ }
 
   #ifdef MC_DEBUG
     xbt_os_walltimer_start(timer);
index a45cc5f..a3e2949 100644 (file)
@@ -92,7 +92,7 @@ static void deterministic_pattern(xbt_dynar_t initial_pattern, xbt_dynar_t patte
     recv_index = 0;
     current_process++;
   }
-  XBT_DEBUG("Communication-deterministic : %d, Send-deterministic : %d", initial_state_safety->comm_deterministic, initial_state_safety->send_deterministic);
+  // XBT_DEBUG("Communication-deterministic : %d, Send-deterministic : %d", initial_state_safety->comm_deterministic, initial_state_safety->send_deterministic);
 }
 
 static int complete_comm_pattern(xbt_dynar_t list, mc_comm_pattern_t pattern){
@@ -157,7 +157,7 @@ static void print_communications_pattern(xbt_dynar_t comms_pattern){
   unsigned int cursor = 0;
   mc_comm_pattern_t current_comm;
   xbt_dynar_foreach(comms_pattern, cursor, current_comm){
-    fprintf(stderr, "%s (%d - comm %p, src : %lu, dst %lu, rdv name %s, data %p, matched with %d)\n", current_comm->type == SIMIX_COMM_SEND ? "iSend" : "iRecv", current_comm->num, current_comm->comm, current_comm->src_proc, current_comm->dst_proc, current_comm->rdv, current_comm->data, current_comm->matched_comm);
+    // fprintf(stderr, "%s (%d - comm %p, src : %lu, dst %lu, rdv name %s, data %p, matched with %d)\n", current_comm->type == SIMIX_COMM_SEND ? "iSend" : "iRecv", current_comm->num, current_comm->comm, current_comm->src_proc, current_comm->dst_proc, current_comm->rdv, current_comm->data, current_comm->matched_comm);
   }
 }
 
index a6124c9..5839708 100644 (file)
@@ -118,6 +118,56 @@ const char* MC_dwarf_tagname(int tag) {
   }
 }
 
+#define MC_DW_CLASS_UNKNOWN 0
+#define MC_DW_CLASS_ADDRESS 1   // Location in the address space of the program
+#define MC_DW_CLASS_BLOCK 2     // Arbitrary block of bytes
+#define MC_DW_CLASS_CONSTANT 3
+#define MC_DW_CLASS_STRING 3    // String
+#define MC_DW_CLASS_FLAG 4      // Boolean
+#define MC_DW_CLASS_REFERENCE 5 // Reference to another DIE
+#define MC_DW_CLASS_EXPRLOC 6   // DWARF expression/location description
+#define MC_DW_CLASS_LINEPTR 7
+#define MC_DW_CLASS_LOCLISTPTR 8
+#define MC_DW_CLASS_MACPTR 9
+#define MC_DW_CLASS_RANGELISTPTR 10
+
+static int MC_dwarf_form_get_class(int form) {
+  switch(form) {
+  case DW_FORM_addr:
+    return MC_DW_CLASS_ADDRESS;
+  case DW_FORM_block2:
+  case DW_FORM_block4:
+  case DW_FORM_block:
+  case DW_FORM_block1:
+    return MC_DW_CLASS_BLOCK;
+  case DW_FORM_data2:
+  case DW_FORM_data4:
+  case DW_FORM_data8:
+  case DW_FORM_udata:
+  case DW_FORM_sdata:
+    return MC_DW_CLASS_CONSTANT;
+  case DW_FORM_string:
+  case DW_FORM_strp:
+    return MC_DW_CLASS_STRING;
+  case DW_FORM_ref_addr:
+  case DW_FORM_ref1:
+  case DW_FORM_ref2:
+  case DW_FORM_ref4:
+  case DW_FORM_ref8:
+  case DW_FORM_ref_udata:
+    return MC_DW_CLASS_REFERENCE;
+  case DW_FORM_flag:
+  case DW_FORM_flag_present:
+    return MC_DW_CLASS_FLAG;
+  case DW_FORM_exprloc:
+    return MC_DW_CLASS_EXPRLOC;
+  // TODO sec offset
+  // TODO indirect
+  default:
+    return MC_DW_CLASS_UNKNOWN;
+  }
+}
+
 /** \brief Get the name of the tag of a given DIE
  *
  *  \param die DIE
@@ -345,7 +395,7 @@ static uint64_t MC_dwarf_subrange_element_count(Dwarf_Die* die, Dwarf_Die* unit)
     return MC_dwarf_attr_uint(die, DW_AT_count, 0);
   }
 
-  // Otherwise compute DW_TAG_upper_bound-DW_TAG_lower_bound:
+  // Otherwise compute DW_TAG_upper_bound-DW_TAG_lower_bound + 1:
 
   if (!dwarf_hasattr_integrate(die, DW_AT_upper_bound)) {
        // This is not really 0, but the code expects this (we do not know):
@@ -359,7 +409,7 @@ static uint64_t MC_dwarf_subrange_element_count(Dwarf_Die* die, Dwarf_Die* unit)
   } else {
        lower_bound = MC_dwarf_default_lower_bound(dwarf_srclang(unit));
   }
-  return upper_bound - lower_bound;
+  return upper_bound - lower_bound + 1;
 }
 
 static uint64_t MC_dwarf_array_element_count(Dwarf_Die* die, Dwarf_Die* unit) {
@@ -429,9 +479,11 @@ static void MC_dwarf_fill_member_location(dw_type_t type, dw_type_t member, Dwar
 
   Dwarf_Attribute attr;
   dwarf_attr_integrate(child, DW_AT_data_member_location, &attr);
-  switch (dwarf_whatform(&attr)) {
-
-  case DW_FORM_exprloc:
+  int klass = MC_dwarf_form_get_class(dwarf_whatform(&attr));
+  switch (klass) {
+  case MC_DW_CLASS_EXPRLOC:
+  case MC_DW_CLASS_BLOCK:
+    // Location expression:
     {
       Dwarf_Op* expr;
       size_t len;
@@ -444,28 +496,32 @@ static void MC_dwarf_fill_member_location(dw_type_t type, dw_type_t member, Dwar
       if (len==1 && expr[0].atom == DW_OP_plus_uconst) {
         member->offset =  expr[0].number;
       } else {
-        xbt_die("Can't groke this location expression yet. %i %i",
-          len==1 , expr[0].atom == DW_OP_plus_uconst);
+        xbt_die("Can't groke this location expression yet.");
       }
       break;
     }
-  case DW_FORM_data1:
-  case DW_FORM_data2:
-  case DW_FORM_data4:
-  case DW_FORM_data8:
-  case DW_FORM_sdata:
-  case DW_FORM_udata:
+  case MC_DW_CLASS_CONSTANT:
+    // Offset from the base address of the object:
     {
       Dwarf_Word offset;
       if (!dwarf_formudata(&attr, &offset))
         member->offset = offset;
       else
-        xbt_die("Cannot get DW_AT_data_member_%s location <%p>%s",
+        xbt_die("Cannot get %s location <%p>%s",
           MC_dwarf_attr_string(child, DW_AT_name),
           type->id, type->name);
       break;
     }
+  case MC_DW_CLASS_LOCLISTPTR:
+    // Reference to a location list:
+    // TODO
+  case MC_DW_CLASS_REFERENCE:
+    // It's supposed to be possible in DWARF2 but I couldn't find its semantic
+    // in the spec.
+  default:
+    xbt_die("Can't handle form class 0x%x (%i) as DW_AT_member_location", klass, klass);
   }
+
 }
 
 static void MC_dwarf_add_members(mc_object_info_t info, Dwarf_Die* die, Dwarf_Die* unit, dw_type_t type) {
@@ -739,6 +795,8 @@ static dw_location_t MC_dwarf_get_expression(Dwarf_Op* expr,  size_t len) {
   return loc;
 }
 
+static int mc_anonymous_variable_index = 0;
+
 static dw_variable_t MC_die_to_variable(mc_object_info_t info, Dwarf_Die* die, Dwarf_Die* unit, dw_frame_t frame) {
   // Drop declaration:
   if (MC_dwarf_attr_flag(die, DW_AT_declaration, false))
@@ -755,12 +813,12 @@ static dw_variable_t MC_die_to_variable(mc_object_info_t info, Dwarf_Die* die, D
   variable->global = frame == NULL; // Can be override base on DW_AT_location
   variable->name = xbt_strdup(MC_dwarf_attr_string(die, DW_AT_name));
   variable->type_origin = MC_dwarf_at_type(die);
-  variable->address.address = NULL;
 
-  int form;
-  switch (form = dwarf_whatform(&attr_location)) {
-  case DW_FORM_exprloc:
-  case DW_FORM_block1: // Not in the spec but found in the wild.
+  int klass = MC_dwarf_form_get_class(dwarf_whatform(&attr_location));
+  switch (klass) {
+  case MC_DW_CLASS_EXPRLOC:
+  case MC_DW_CLASS_BLOCK:
+    // Location expression:
     {
       Dwarf_Op* expr;
       size_t len;
@@ -774,23 +832,28 @@ static dw_variable_t MC_die_to_variable(mc_object_info_t info, Dwarf_Die* die, D
         variable->global = 1;
         Dwarf_Off offset = expr[0].number;
         // TODO, Why is this different base on the object?
-        Dwarf_Off base = strcmp(info->file_name, xbt_binary_name) !=0 ? (Dwarf_Off) info->start_text : 0;
-        variable->address.address = (void*) (base + offset);
+        Dwarf_Off base = strcmp(info->file_name, xbt_binary_name) !=0 ? (Dwarf_Off) info->start_exec : 0;
+        variable->address = (void*) (base + offset);
       } else {
-        variable->address.location = MC_dwarf_get_expression(expr, len);
+        variable->location = MC_dwarf_get_expression(expr, len);
       }
 
       break;
     }
-  case DW_FORM_sec_offset: // type loclistptr
-  case DW_FORM_data2:
-  case DW_FORM_data4:
-  case DW_FORM_data8:
-    variable->address.location = MC_dwarf_get_location_list(die, &attr_location);
+  case MC_DW_CLASS_LOCLISTPTR:
+  case MC_DW_CLASS_CONSTANT:
+    // Reference to location list:
+    variable->location = MC_dwarf_get_location_list(die, &attr_location);
     break;
   default:
-    xbt_die("Unexpected form %i list for location in <%p>%s",
-      form, (void*) variable->dwarf_offset, variable->name);
+    xbt_die("Unexpected calss 0x%x (%i) list for location in <%p>%s",
+      klass, klass, (void*) variable->dwarf_offset, variable->name);
+  }
+
+  // The current code needs a variable name,
+  // generate a fake one:
+  if(!variable->name) {
+    variable->name = bprintf("@anonymous#%i", mc_anonymous_variable_index++);
   }
 
   return variable;
index a72abfe..668bea0 100644 (file)
@@ -19,8 +19,6 @@
 #include "xbt/automaton.h"
 #include "xbt/dict.h"
 
-static void MC_post_process_types(mc_object_info_t info);
-
 XBT_LOG_NEW_CATEGORY(mc, "All MC categories");
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_global, mc,
                                 "Logging specific to MC (global)");
@@ -174,7 +172,7 @@ void dw_variable_free(dw_variable_t v){
     xbt_free(v->name);
     xbt_free(v->type_origin);
     if(!v->global)
-      dw_location_free(v->address.location);
+      dw_location_free(v->location);
     xbt_free(v);
   }
 }
@@ -186,11 +184,7 @@ void dw_variable_free_voidp(void *t){
 // object_info
 
 mc_object_info_t MC_new_object_info(void) {
-  mc_object_info_t res = xbt_new(s_mc_object_info_t, 1);
-  res->file_name = NULL;
-  res->start_text = NULL;
-  res->start_data = NULL;
-  res->start_bss = NULL;
+  mc_object_info_t res = xbt_new0(s_mc_object_info_t, 1);
   res->local_variables = xbt_dict_new_homogeneous(NULL);
   res->global_variables = xbt_dynar_new(sizeof(dw_variable_t), dw_variable_free_voidp);
   res->types = xbt_dict_new_homogeneous(NULL);
@@ -399,9 +393,9 @@ static int MC_dwarf_get_variable_index(xbt_dynar_t variables, char* var, void *a
       end = cursor - 1;
     }else{
       if(address){ /* global variable */
-        if(var_test->address.address == address)
+        if(var_test->address == address)
           return -1;
-        if(var_test->address.address > address)
+        if(var_test->address > address)
           end = cursor - 1;
         else
           start = cursor + 1;
@@ -412,7 +406,7 @@ static int MC_dwarf_get_variable_index(xbt_dynar_t variables, char* var, void *a
   }
 
   if(strcmp(var_test->name, var) == 0){
-    if(address && var_test->address.address < address)
+    if(address && var_test->address < address)
       return cursor+1;
     else
       return cursor;
@@ -424,7 +418,7 @@ static int MC_dwarf_get_variable_index(xbt_dynar_t variables, char* var, void *a
 }
 
 void MC_dwarf_register_global_variable(mc_object_info_t info, dw_variable_t variable) {
-  int index = MC_dwarf_get_variable_index(info->global_variables, variable->name, variable->address.address);
+  int index = MC_dwarf_get_variable_index(info->global_variables, variable->name, variable->address);
   if (index != -1)
     xbt_dynar_insert_at(info->global_variables, index, &variable);
   // TODO, else ?
@@ -447,26 +441,6 @@ void MC_dwarf_register_variable(mc_object_info_t info, dw_frame_t frame, dw_vari
     MC_dwarf_register_non_global_variable(info, frame, variable);
 }
 
-static void MC_post_process_array_size(mc_object_info_t info, dw_type_t type) {
-  xbt_assert(type->dw_type_id, "No base type for array <%p>%s", type->id, type->name);
-  dw_type_t subtype = xbt_dict_get_or_null(info->types, type->dw_type_id);
-  xbt_assert(subtype, "Unkown base type <%s> for array <%p>%s", type->dw_type_id, type->id, type->name);
-  if(subtype->type==DW_TAG_array_type && type->byte_size==0) {
-         MC_post_process_array_size(info, subtype);
-  }
-  type->byte_size = type->element_count*subtype->byte_size;
-}
-
-static void MC_post_process_types(mc_object_info_t info) {
-  xbt_dict_cursor_t cursor;
-  char *origin;
-  dw_type_t type;
-  xbt_dict_foreach(info->types, cursor, origin, type){
-    if(type->type==DW_TAG_array_type && type->byte_size==0)
-      MC_post_process_array_size(info, type);
-  }
-}
-
 /*******************************  Ignore mechanism *******************************/
 /*********************************************************************************/
 
index 7fe3f6b..206d531 100644 (file)
@@ -323,9 +323,9 @@ void MC_dump_stack_liveness(xbt_fifo_t stack);
 
 typedef struct s_mc_object_info {
   char* file_name;
-  char* start_text;
-  char* start_data;
-  char* start_bss;
+  char *start_exec, *end_exec; // Executable segment
+  char *start_rw, *end_rw; // Read-write segment
+  char *start_ro, *end_ro; // read-only segment
   xbt_dict_t local_variables; // xbt_dict_t<frame_name, dw_frame_t>
   xbt_dynar_t global_variables; // xbt_dynar_t<dw_variable_t>
   xbt_dict_t types; // xbt_dict_t<origin as hexadecimal string, dw_type_t>
@@ -410,10 +410,11 @@ typedef struct s_dw_variable{
   int global;
   char *name;
   char *type_origin;
-  union{
-    dw_location_t location; // For global==0
-    void *address; // For global!=0
-  }address;
+
+  // Use either of:
+  dw_location_t location;
+  void* address;
+
 }s_dw_variable_t, *dw_variable_t;
 
 typedef struct s_dw_frame{
index 52792d6..c9154e0 100644 (file)
@@ -704,7 +704,8 @@ static int compare_heap_area_without_type(void *real_area1, void *real_area2, vo
 
   int i = 0;
   void *addr_pointed1, *addr_pointed2;
-  int pointer_align, ignore1, ignore2, res_compare;
+  int pointer_align, res_compare;
+  ssize_t ignore1, ignore2;
 
   while(i<size){
 
@@ -762,7 +763,7 @@ static int compare_heap_area_with_type(void *real_area1, void *real_area2, void
   if(is_stack(real_area1) && is_stack(real_area2))
     return 0;
 
-  size_t ignore1, ignore2;
+  ssize_t ignore1, ignore2;
 
   if((check_ignore > 0) && ((ignore1 = heap_comparison_ignore_size(to_ignore1, real_area1)) > 0) && ((ignore2 = heap_comparison_ignore_size(to_ignore2, real_area2))  == ignore1)){
     return 0;
@@ -778,7 +779,7 @@ static int compare_heap_area_with_type(void *real_area1, void *real_area2, void
 
   switch(type->type){
   case DW_TAG_base_type:
-    if(strcmp(type->name, "char") == 0){ /* String, hence random (arbitrary ?) size */
+    if(type->name!=NULL && strcmp(type->name, "char") == 0){ /* String, hence random (arbitrary ?) size */
       if(real_area1 == real_area2)
         return -1;
       else
@@ -798,10 +799,9 @@ static int compare_heap_area_with_type(void *real_area1, void *real_area2, void
       return (memcmp(area1, area2, type->byte_size) != 0);
     break;
   case DW_TAG_typedef:
-    return compare_heap_area_with_type(real_area1, real_area2, area1, area2, previous, all_types, other_types, type->dw_type_id, area_size, check_ignore, pointer_level);
-    break;
   case DW_TAG_const_type:
-    return 0;
+  case DW_TAG_volatile_type:
+    return compare_heap_area_with_type(real_area1, real_area2, area1, area2, previous, all_types, other_types, type->dw_type_id, area_size, check_ignore, pointer_level);
     break;
   case DW_TAG_array_type:
     subtype = xbt_dict_get_or_null(all_types, type->dw_type_id);
@@ -823,6 +823,7 @@ static int compare_heap_area_with_type(void *real_area1, void *real_area2, void
       elm_size = subtype->byte_size;
       break;
     // TODO, just remove the type indirection?
+    case DW_TAG_const_type:
     case DW_TAG_typedef:
     case DW_TAG_volatile_type:
       subsubtype = xbt_dict_get_or_null(all_types, subtype->dw_type_id);
@@ -918,9 +919,6 @@ static int compare_heap_area_with_type(void *real_area1, void *real_area2, void
   case DW_TAG_union_type:
     return compare_heap_area_without_type(real_area1, real_area2, area1, area2, previous, all_types, other_types, type->byte_size, check_ignore);
     break;
-  case DW_TAG_volatile_type:
-    return compare_heap_area_with_type(real_area1, real_area2, area1, area2, previous, all_types, other_types, type->dw_type_id, area_size, check_ignore, pointer_level);
-    break;
   default:
     break;
   }
@@ -1042,7 +1040,7 @@ int compare_heap_area(void *area1, void* area2, xbt_dynar_t previous, xbt_dict_t
         type = xbt_dict_get_or_null(all_types, type->dw_type_id);
       }
     }
-    if((type->byte_size == DW_TAG_pointer_type) || ((type->type == DW_TAG_base_type) && (!strcmp(type->name, "char"))))
+    if((type->byte_size == DW_TAG_pointer_type) || ((type->type == DW_TAG_base_type) && type->name!=NULL && (!strcmp(type->name, "char"))))
       type_size = -1;
     else
       type_size = type->byte_size;
@@ -1069,7 +1067,7 @@ int compare_heap_area(void *area1, void* area2, xbt_dynar_t previous, xbt_dict_t
     }
 
     if(type_size != -1){
-      if(type_size != heapinfo1[block1].busy_block.busy_size && type_size != heapinfo2[block2].busy_block.busy_size && !strcmp(type->name, "s_smx_context")){
+      if(type_size != heapinfo1[block1].busy_block.busy_size && type_size != heapinfo2[block2].busy_block.busy_size && type->name!=NULL && !strcmp(type->name, "s_smx_context")){
         if(match_pairs){
           match_equals(previous);
           xbt_dynar_free(&previous);