From: Gabriel Corona Date: Thu, 16 Jan 2014 10:50:23 +0000 (+0100) Subject: [mc] Use libdw for location list X-Git-Tag: v3_11~199^2~2^2~35^2~8 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/f037dbaa06a4fca5291b56b421a8de3f7f3e9920 [mc] Use libdw for location list --- diff --git a/src/mc/mc_dwarf.c b/src/mc/mc_dwarf.c index 1a69987860..f4c609a4dc 100644 --- a/src/mc/mc_dwarf.c +++ b/src/mc/mc_dwarf.c @@ -94,6 +94,38 @@ static dw_location_t MC_dwarf_resolve_location_list(mc_object_info_t info, Dwarf return loc; } +/** \brief Create a location_list from a given attribute */ +static dw_location_t MC_dwarf_get_location_list_libdw(Dwarf_Die* die, Dwarf_Attribute* attr) { + + + dw_location_t location = xbt_new0(s_dw_location_t, 1); + location->type = e_dw_loclist; + xbt_dynar_t loclist = xbt_dynar_new(sizeof(dw_location_entry_t), NULL); + location->location.loclist = loclist; + + ptrdiff_t offset = 0; + Dwarf_Addr base, start, end; + Dwarf_Op *expr; + size_t len; + + while (1) { + + offset = dwarf_getlocations(attr, offset, &base, &start, &end, &expr, &len); + if (offset==0) + return location; + else if (offset==-1) + 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; + new_entry->location = MC_dwarf_get_expression(expr, len); + + xbt_dynar_push(loclist, &new_entry); + + } +} + static dw_location_t MC_dwarf_get_location(Dwarf_Die* die, Dwarf_Attribute* attr, mc_object_info_t info) { int form = dwarf_whatform(attr); switch (form) { @@ -114,6 +146,9 @@ static dw_location_t MC_dwarf_get_location(Dwarf_Die* die, Dwarf_Attribute* attr case DW_FORM_data4: case DW_FORM_data8: { + if (MC_USE_LIBDW_LOCATION_LIST) + return MC_dwarf_get_location_list_libdw(die, attr); + Dwarf_Word offset; if (!dwarf_formudata(attr, &offset)) return MC_dwarf_resolve_location_list(info, offset); @@ -769,4 +804,3 @@ void MC_dwarf_get_variables_libdw(mc_object_info_t info) { dwarf_end(dwarf); close(fd); } - diff --git a/src/mc/mc_private.h b/src/mc/mc_private.h index 0498fbb1de..d5c3fae2b5 100644 --- a/src/mc/mc_private.h +++ b/src/mc/mc_private.h @@ -454,6 +454,7 @@ typedef struct s_local_variable{ }s_local_variable_t, *local_variable_t; #define MC_USE_LIBDW (getenv("MC_USE_OBJDUMP") == NULL) +#define MC_USE_LIBDW_LOCATION_LIST (getenv("MC_USE_OBJDUMP_LL") == NULL) #endif