From e3e5c5563d361c206fba99b98b0f9f8a135089ce Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Wed, 16 Sep 2009 01:57:39 -0700 Subject: Clean up loc2c-test workaround for constant DW_AT_data_member_location. * loc2c-test.c (handle_variable): Skip the workaround for elfutils 0.142. When doing it, use a synthetic location expression. Never use c_translate_add_offset, which is broken. --- loc2c-test.c | 44 +++++++++++++++++--------------------------- 1 file changed, 17 insertions(+), 27 deletions(-) (limited to 'loc2c-test.c') diff --git a/loc2c-test.c b/loc2c-test.c index 48691a33..46c45827 100644 --- a/loc2c-test.c +++ b/loc2c-test.c @@ -230,34 +230,24 @@ handle_variable (Dwarf_Die *lscopes, int lnscopes, int out, } else { - /* We are expection a block, constant or loclistptr. */ - unsigned int form = dwarf_whatform (&attr_mem); - Dwarf_Sword off; - switch (form) + /* We expect a block or a constant. In older elfutils, + dwarf_getlocation_addr would not handle the constant for + us, but newer ones do. For older ones, we work around + it by faking an expression, which is what newer ones do. */ +#if !_ELFUTILS_PREREQ (0,142) + Dwarf_Op offset_loc = { .atom = DW_OP_plus_uconst }; + if (dwarf_formudata (&attr_mem, &offset_loc.number) == 0) + c_translate_location (&pool, NULL, NULL, NULL, + 1, cubias, pc, &offset_loc, 1, + &tail, NULL, NULL); + else +#endif { - /* constant */ - case DW_FORM_data1: - case DW_FORM_data2: - case DW_FORM_sdata: - case DW_FORM_udata: - if (dwarf_formsdata (&attr_mem, &off) != 0) - error (2, 0, _("Bad offset for %s %s: %s"), - typetag == DW_TAG_union_type ? "union" : "struct", - dwarf_diename (die) ?: "", - dwarf_errmsg (-1)); - if (off != 0) - c_translate_add_offset (&pool, 1, - dwarf_diename (die) - ?: "", off, &tail); - break; - - default: - locexpr = get_location (cubias, pc, &attr_mem, - &locexpr_len); - c_translate_location (&pool, NULL, NULL, NULL, - 1, cubias, pc, locexpr, locexpr_len, - &tail, NULL, NULL); - break; + locexpr = get_location (cubias, pc, &attr_mem, + &locexpr_len); + c_translate_location (&pool, NULL, NULL, NULL, + 1, cubias, pc, locexpr, locexpr_len, + &tail, NULL, NULL); } } ++fields; -- cgit From 6be6402d1514d149e6e6adf66a5c50b80b8bbb0f Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Wed, 16 Sep 2009 13:45:57 -0700 Subject: Handle DW_TAG_reference_type in loc2c-test. * loc2c-test.c (handle_variable): Handle DW_TAG_reference_type. --- loc2c-test.c | 1 + 1 file changed, 1 insertion(+) (limited to 'loc2c-test.c') diff --git a/loc2c-test.c b/loc2c-test.c index 46c45827..b8883876 100644 --- a/loc2c-test.c +++ b/loc2c-test.c @@ -304,6 +304,7 @@ handle_variable (Dwarf_Die *lscopes, int lnscopes, int out, break; case DW_TAG_pointer_type: + case DW_TAG_reference_type: if (store) error (2, 0, _("store not supported for pointer type")); c_translate_pointer (&pool, 1, cubias, typedie, &tail); -- cgit From 24c7957b4dbddc8545d0e0c734377746a5ae6e60 Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Thu, 17 Sep 2009 15:06:57 +0200 Subject: PR10417 Pass around attributes for supporting DW_OP_{implicit,stack}_value. Preparation for retrieving the Dwarf_Block that holds the value of an DW_OP_implicit_value. We need the Dwarf_Attribute that is associated with the location expression operants. Depends on new elfutils 0.143 functionality. Recognizes, but does not yet handle the new operants DW_OP_{implicit,stack}_value. * loc2c.h (c_translate_location): Take an Dwarf_Attribute. * loc2c.c (c_translate_location): Likewise and pass it on. (location_relative): Likewise. (location_from_address): Likewise. (translate): Likewise and capture Dwarf_Block. * loc2c-test.c (handle_variable): Pass in Dwarf_Attribute. * dwflpp.cxx (translate_location): Likewise. (literal_stmt_for_return): Pass in NULL to indicate no attribute. --- loc2c-test.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'loc2c-test.c') diff --git a/loc2c-test.c b/loc2c-test.c index b8883876..495a95f1 100644 --- a/loc2c-test.c +++ b/loc2c-test.c @@ -136,7 +136,7 @@ handle_variable (Dwarf_Die *lscopes, int lnscopes, int out, struct location *head, *tail = NULL; head = c_translate_location (&pool, &fail, NULL, NULL, - 1, cubias, pc, locexpr, locexpr_len, + 1, cubias, pc, &attr_mem, locexpr, locexpr_len, &tail, fb_attr, cfa_ops); if (dwarf_attr_integrate (vardie, DW_AT_type, &attr_mem) == NULL) @@ -238,7 +238,8 @@ handle_variable (Dwarf_Die *lscopes, int lnscopes, int out, Dwarf_Op offset_loc = { .atom = DW_OP_plus_uconst }; if (dwarf_formudata (&attr_mem, &offset_loc.number) == 0) c_translate_location (&pool, NULL, NULL, NULL, - 1, cubias, pc, &offset_loc, 1, + 1, cubias, pc, &attr_mem, + &offset_loc, 1, &tail, NULL, NULL); else #endif @@ -246,7 +247,8 @@ handle_variable (Dwarf_Die *lscopes, int lnscopes, int out, locexpr = get_location (cubias, pc, &attr_mem, &locexpr_len); c_translate_location (&pool, NULL, NULL, NULL, - 1, cubias, pc, locexpr, locexpr_len, + 1, cubias, pc, &attr_mem, + locexpr, locexpr_len, &tail, NULL, NULL); } } -- cgit