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;
}
* \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;
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);
* \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) {
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;
* \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) {
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",
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:
}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;
/********************************** 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 **********************************/