Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[mc] Fix sefault where a variable has no name
authorGabriel Corona <gabriel.corona@loria.fr>
Fri, 7 Feb 2014 14:44:15 +0000 (15:44 +0100)
committerGabriel Corona <gabriel.corona@loria.fr>
Fri, 7 Feb 2014 14:46:36 +0000 (15:46 +0100)
This happen when optimisation is enabled.

As the current code needs a name for the variable, we generate a fake
one. We might want to remove this assumption.

src/mc/mc_dwarf.c

index 84e4260..5839708 100644 (file)
@@ -795,6 +795,8 @@ static dw_location_t MC_dwarf_get_expression(Dwarf_Op* expr,  size_t len) {
   return loc;
 }
 
   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))
 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))
@@ -848,6 +850,12 @@ static dw_variable_t MC_die_to_variable(mc_object_info_t info, Dwarf_Die* die, D
       klass, klass, (void*) variable->dwarf_offset, variable->name);
   }
 
       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;
 }
 
   return variable;
 }