Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[mc] Use resolved addresses in frame->low_pc and frame->high_pc
authorGabriel Corona <gabriel.corona@loria.fr>
Thu, 20 Feb 2014 10:41:03 +0000 (11:41 +0100)
committerGabriel Corona <gabriel.corona@loria.fr>
Thu, 20 Feb 2014 10:41:03 +0000 (11:41 +0100)
src/mc/mc_dwarf.c
src/mc/mc_global.c

index 5a371c9..b4427da 100644 (file)
@@ -879,10 +879,15 @@ static void MC_dwarf_handle_subprogram_die(mc_object_info_t info, Dwarf_Die* die
     name = MC_dwarf_attr_string(die, DW_AT_name);
   frame->name = xbt_strdup(name);
 
+  // This is the base address for DWARF addresses.
+  // Relocated addresses are offset from this base address.
+  // See DWARF4 spec 7.5
+  void* base = info->flags & MC_OBJECT_INFO_EXECUTABLE ? 0 : MC_object_base_address(info);
+
   // Variables are filled in the (recursive) call of MC_dwarf_handle_children:
   frame->variables = xbt_dynar_new(sizeof(dw_variable_t), dw_variable_free_voidp);
-  frame->high_pc = (void*) MC_dwarf_attr_addr(die, DW_AT_high_pc);
-  frame->low_pc = (void*) MC_dwarf_attr_addr(die, DW_AT_low_pc);
+  frame->high_pc = ((char*) base) + MC_dwarf_attr_addr(die, DW_AT_high_pc);
+  frame->low_pc = ((char*) base) + MC_dwarf_attr_addr(die, DW_AT_low_pc);
   frame->frame_base = MC_dwarf_at_location(die, DW_AT_frame_base);
   frame->end = -1; // This one is now useless:
 
index 2b56b16..adc2241 100644 (file)
@@ -225,12 +225,6 @@ static int MC_compare_frame_index_items(mc_function_index_item_t a, mc_function_
 static void MC_make_functions_index(mc_object_info_t info) {
   xbt_dynar_t index = xbt_dynar_new(sizeof(s_mc_function_index_item_t), NULL);
 
-  // The base address of the function must be used to offset the addresses.
-  // This should be fixed this in the frame_t structure instead.
-  // Relocated addresses are offset for shared objets and constant for executables objects.
-  // See DWARF4 spec 7.5
-  void* offset = info->flags & MC_OBJECT_INFO_EXECUTABLE ? 0 : MC_object_base_address(info);
-
   // Populate the array:
   dw_frame_t frame = NULL;
   xbt_dict_cursor_t cursor = NULL;
@@ -239,8 +233,8 @@ static void MC_make_functions_index(mc_object_info_t info) {
     if(frame->low_pc==NULL)
       continue;
     s_mc_function_index_item_t entry;
-    entry.low_pc = (char*) frame->low_pc + (unsigned long) offset;
-    entry.high_pc = (char*) frame->high_pc + (unsigned long) offset;
+    entry.low_pc = frame->low_pc;
+    entry.high_pc = frame->high_pc;
     entry.function = frame;
     xbt_dynar_push(index, &entry);
   }