Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[mc] Split address/location in dw_variable_t (which were in a union)
authorGabriel Corona <gabriel.corona@loria.fr>
Fri, 7 Feb 2014 11:45:28 +0000 (12:45 +0100)
committerGabriel Corona <gabriel.corona@loria.fr>
Fri, 7 Feb 2014 11:45:32 +0000 (12:45 +0100)
src/mc/mc_checkpoint.c
src/mc/mc_compare.c
src/mc/mc_dwarf.c
src/mc/mc_global.c
src/mc/mc_private.h

index d2efa6e..7e8d185 100644 (file)
@@ -475,8 +475,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 6dda53a..9543f09 100644 (file)
@@ -285,11 +285,11 @@ static int compare_global_variables(int region_type, mc_mem_region_t r1, mc_mem_
     // 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.address < (char*) object_info->start_rw
-      || (char*) current_var->address.address > (char*) object_info->end_rw)
+    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.address - (char *)object_info->start_rw;
+    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){
index 84747d0..84e4260 100644 (file)
@@ -811,7 +811,6 @@ 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 klass = MC_dwarf_form_get_class(dwarf_whatform(&attr_location));
   switch (klass) {
@@ -832,9 +831,9 @@ static dw_variable_t MC_die_to_variable(mc_object_info_t info, Dwarf_Die* die, D
         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_exec : 0;
-        variable->address.address = (void*) (base + offset);
+        variable->address = (void*) (base + offset);
       } else {
-        variable->address.location = MC_dwarf_get_expression(expr, len);
+        variable->location = MC_dwarf_get_expression(expr, len);
       }
 
       break;
@@ -842,7 +841,7 @@ static dw_variable_t MC_die_to_variable(mc_object_info_t info, Dwarf_Die* die, D
   case MC_DW_CLASS_LOCLISTPTR:
   case MC_DW_CLASS_CONSTANT:
     // Reference to location list:
-    variable->address.location = MC_dwarf_get_location_list(die, &attr_location);
+    variable->location = MC_dwarf_get_location_list(die, &attr_location);
     break;
   default:
     xbt_die("Unexpected calss 0x%x (%i) list for location in <%p>%s",
index b3cc8ba..e0a8bdd 100644 (file)
@@ -164,7 +164,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);
   }
 }
@@ -385,9 +385,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;
@@ -398,7 +398,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;
@@ -410,7 +410,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 ?
index 85ef10f..206d531 100644 (file)
@@ -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{