Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[mc] Fix bug when trying to handle DW_OP_regN in MC_dwarf_resolve_location
[simgrid.git] / src / mc / mc_dwarf.c
index 3107c9d..4f86800 100644 (file)
@@ -139,6 +139,7 @@ static int MC_dwarf_form_get_class(int form) {
   case DW_FORM_block:
   case DW_FORM_block1:
     return MC_DW_CLASS_BLOCK;
+  case DW_FORM_data1:
   case DW_FORM_data2:
   case DW_FORM_data4:
   case DW_FORM_data8:
@@ -301,6 +302,7 @@ static dw_location_t MC_dwarf_get_location(mc_object_info_t info, Dwarf_Die* die
 
   // The attribute is a reference to a location list entry:
   case DW_FORM_sec_offset:
+  case DW_FORM_data1:
   case DW_FORM_data2:
   case DW_FORM_data4:
   case DW_FORM_data8:
@@ -466,9 +468,6 @@ Dwarf_Off MC_dwarf_resolve_location(unw_cursor_t* c, dw_location_t location, voi
     }
     dw_location_t location_entry = xbt_dynar_get_as(location->location.compose, 0, dw_location_t);
     switch (location_entry->type){
-    case e_dw_register:
-      unw_get_reg(c, location_entry->location.reg, &res);
-      return res;
     case e_dw_bregister_op:
       unw_get_reg(c, location_entry->location.breg_op.reg, &res);
       return (Dwarf_Off) ((long)res + location_entry->location.breg_op.offset);
@@ -506,7 +505,8 @@ 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);
-  int klass = MC_dwarf_form_get_class(dwarf_whatform(&attr));
+  int form = dwarf_whatform(&attr);
+  int klass = MC_dwarf_form_get_class(form);
   switch (klass) {
   case MC_DW_CLASS_EXPRLOC:
   case MC_DW_CLASS_BLOCK:
@@ -546,7 +546,9 @@ static void MC_dwarf_fill_member_location(dw_type_t type, dw_type_t member, Dwar
     // 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);
+    xbt_die(
+      "Can't handle form class (%i) / form 0x%x as DW_AT_member_location",
+      klass, form);
   }
 
 }
@@ -845,7 +847,8 @@ static dw_variable_t MC_die_to_variable(mc_object_info_t info, Dwarf_Die* die, D
   variable->name = xbt_strdup(MC_dwarf_attr_string(die, DW_AT_name));
   variable->type_origin = MC_dwarf_at_type(die);
 
-  int klass = MC_dwarf_form_get_class(dwarf_whatform(&attr_location));
+  int form = dwarf_whatform(&attr_location);
+  int klass = form == DW_FORM_sec_offset ? MC_DW_CLASS_CONSTANT : MC_dwarf_form_get_class(form);
   switch (klass) {
   case MC_DW_CLASS_EXPRLOC:
   case MC_DW_CLASS_BLOCK:
@@ -877,8 +880,8 @@ static dw_variable_t MC_die_to_variable(mc_object_info_t info, Dwarf_Die* die, D
     variable->location = MC_dwarf_get_location_list(info, die, &attr_location);
     break;
   default:
-    xbt_die("Unexpected calss 0x%x (%i) list for location in <%p>%s",
-      klass, klass, (void*) variable->dwarf_offset, variable->name);
+    xbt_die("Unexpected form 0x%x (%i), class 0x%x (%i) list for location in <%p>%s",
+      form, form, klass, klass, (void*) variable->dwarf_offset, variable->name);
   }
 
   // The current code needs a variable name,
@@ -992,14 +995,6 @@ void MC_dwarf_get_variables(mc_object_info_t info) {
     Dwarf_Die die;
 
     if(dwarf_offdie(dwarf, offset+length, &die)!=NULL) {
-
-      // Skip C++ for now (we will add support for it soon):
-      int lang = dwarf_srclang(&die);
-      if((lang==DW_LANG_C_plus_plus) || (lang==DW_LANG_ObjC_plus_plus)) {
-        offset = next_offset;
-        continue;
-      }
-
       MC_dwarf_handle_die(info, &die, &die, NULL);
     }
     offset = next_offset;