From 01810beb59acf79a551d344942f520a8cb304d16 Mon Sep 17 00:00:00 2001 From: Gabriel Corona Date: Thu, 20 Feb 2014 11:54:46 +0100 Subject: [PATCH] [mc] Use resolved addresses in entry.low_pc and entry.high_pc --- src/mc/mc_checkpoint.c | 16 +--------------- src/mc/mc_dwarf.c | 21 ++++++++++++--------- src/mc/mc_hash.c | 2 +- src/mc/mc_private.h | 6 +++--- 4 files changed, 17 insertions(+), 28 deletions(-) diff --git a/src/mc/mc_checkpoint.c b/src/mc/mc_checkpoint.c index 6f6825a6ab..f04d8e9370 100644 --- a/src/mc/mc_checkpoint.c +++ b/src/mc/mc_checkpoint.c @@ -317,21 +317,7 @@ static xbt_dynar_t MC_unwind_stack_frames(void *stack_context) { if(frame) { stack_frame->frame_name = xbt_strdup(frame->name); - - mc_object_info_t info = MC_ip_find_object_info((void*)ip); - - // This is the instruction pointer as present in the DWARF of the object: - // Relocated addresses are offset for shared objets and constant for executables objects. - // See DWARF4 spec 7.5 - unw_word_t normalized_ip; - if(info->flags & MC_OBJECT_INFO_EXECUTABLE) { - normalized_ip = ip; - } else { - void* base = MC_object_base_address(info); - normalized_ip = (unw_word_t) ip - (unw_word_t) base; - } - - stack_frame->frame_base = (unw_word_t)mc_find_frame_base(normalized_ip, frame, &c); + stack_frame->frame_base = (unw_word_t)mc_find_frame_base((void*)ip, frame, &c); } else { stack_frame->frame_base = 0; } diff --git a/src/mc/mc_dwarf.c b/src/mc/mc_dwarf.c index b4427da5d2..6b7959877d 100644 --- a/src/mc/mc_dwarf.c +++ b/src/mc/mc_dwarf.c @@ -214,7 +214,7 @@ static const char* MC_dwarf_at_linkage_name(Dwarf_Die* die) { * \return MC specific representation of the location list represented by the given attribute * of the given die */ -static dw_location_t MC_dwarf_get_location_list(Dwarf_Die* die, Dwarf_Attribute* attr) { +static dw_location_t MC_dwarf_get_location_list(mc_object_info_t info, Dwarf_Die* die, Dwarf_Attribute* attr) { dw_location_t location = xbt_new0(s_dw_location_t, 1); location->type = e_dw_loclist; @@ -235,8 +235,11 @@ static dw_location_t MC_dwarf_get_location_list(Dwarf_Die* die, Dwarf_Attribute* xbt_die("Error while loading location list"); dw_location_entry_t new_entry = xbt_new0(s_dw_location_entry_t, 1); - new_entry->lowpc = start; - new_entry->highpc = end; + + void* base = info->flags & MC_OBJECT_INFO_EXECUTABLE ? 0 : MC_object_base_address(info); + + new_entry->lowpc = (char*) base + start; + new_entry->highpc = (char*) base + end; new_entry->location = MC_dwarf_get_expression(expr, len); xbt_dynar_push(loclist, &new_entry); @@ -253,7 +256,7 @@ static dw_location_t MC_dwarf_get_location_list(Dwarf_Die* die, Dwarf_Attribute* * \return MC specific representation of the location represented by the given attribute * of the given die */ -static dw_location_t MC_dwarf_get_location(Dwarf_Die* die, Dwarf_Attribute* attr) { +static dw_location_t MC_dwarf_get_location(mc_object_info_t info, Dwarf_Die* die, Dwarf_Attribute* attr) { int form = dwarf_whatform(attr); switch (form) { @@ -277,7 +280,7 @@ static dw_location_t MC_dwarf_get_location(Dwarf_Die* die, Dwarf_Attribute* attr case DW_FORM_data4: case DW_FORM_data8: { - return MC_dwarf_get_location_list(die, attr); + return MC_dwarf_get_location_list(info, die, attr); } break; @@ -300,13 +303,13 @@ static dw_location_t MC_dwarf_get_location(Dwarf_Die* die, Dwarf_Attribute* attr * \return MC specific representation of the location represented by the given attribute * of the given die */ -static dw_location_t MC_dwarf_at_location(Dwarf_Die* die, int attribute) { +static dw_location_t MC_dwarf_at_location(mc_object_info_t info, Dwarf_Die* die, int attribute) { if(!dwarf_hasattr_integrate(die, attribute)) return xbt_new0(s_dw_location_t, 1); Dwarf_Attribute attr; dwarf_attr_integrate(die, attribute, &attr); - return MC_dwarf_get_location(die, &attr); + return MC_dwarf_get_location(info, die, &attr); } static char* MC_dwarf_at_type(Dwarf_Die* die) { @@ -846,7 +849,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->location = MC_dwarf_get_location_list(die, &attr_location); + 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", @@ -888,7 +891,7 @@ static void MC_dwarf_handle_subprogram_die(mc_object_info_t info, Dwarf_Die* die frame->variables = xbt_dynar_new(sizeof(dw_variable_t), dw_variable_free_voidp); 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->frame_base = MC_dwarf_at_location(info, die, DW_AT_frame_base); frame->end = -1; // This one is now useless: // Handle children: diff --git a/src/mc/mc_hash.c b/src/mc/mc_hash.c index 8283392da6..c46dc4a2f1 100644 --- a/src/mc/mc_hash.c +++ b/src/mc/mc_hash.c @@ -253,7 +253,7 @@ static void mc_hash_stack_frame( * \param frame * \param unw_cursor */ -void* mc_find_frame_base(unw_word_t ip, dw_frame_t frame, unw_cursor_t* unw_cursor) { +void* mc_find_frame_base(void* ip, dw_frame_t frame, unw_cursor_t* unw_cursor) { switch(frame->frame_base->type) { case e_dw_loclist: { diff --git a/src/mc/mc_private.h b/src/mc/mc_private.h index 12783b6af3..60a07695a5 100644 --- a/src/mc/mc_private.h +++ b/src/mc/mc_private.h @@ -427,8 +427,8 @@ typedef struct s_dw_location{ }s_dw_location_t, *dw_location_t; typedef struct s_dw_location_entry{ - long lowpc; - long highpc; + void* lowpc; + void* highpc; dw_location_t location; }s_dw_location_entry_t, *dw_location_entry_t; @@ -472,7 +472,7 @@ void* MC_object_base_address(mc_object_info_t info); /********************************** DWARF **********************************/ Dwarf_Off MC_dwarf_resolve_location(unw_cursor_t* c, dw_location_t location, void* frame_pointer_address); -void* mc_find_frame_base(unw_word_t ip, dw_frame_t frame, unw_cursor_t* unw_cursor); +void* mc_find_frame_base(void* ip, dw_frame_t frame, unw_cursor_t* unw_cursor); /********************************** Miscellaneous **********************************/ -- 2.20.1