summaryrefslogtreecommitdiffstats
path: root/loc2c-test.c
diff options
context:
space:
mode:
authorRoland McGrath <roland@redhat.com>2009-09-16 01:57:39 -0700
committerRoland McGrath <roland@redhat.com>2009-09-16 01:57:39 -0700
commite3e5c5563d361c206fba99b98b0f9f8a135089ce (patch)
tree8a0bdd19fe1cf0a72d34aa7c587b0b6f08b1df14 /loc2c-test.c
parentf09d0d1e7fd437f6a3b8c21e4817de8af458c888 (diff)
downloadsystemtap-steved-e3e5c5563d361c206fba99b98b0f9f8a135089ce.tar.gz
systemtap-steved-e3e5c5563d361c206fba99b98b0f9f8a135089ce.tar.xz
systemtap-steved-e3e5c5563d361c206fba99b98b0f9f8a135089ce.zip
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.
Diffstat (limited to 'loc2c-test.c')
-rw-r--r--loc2c-test.c44
1 files changed, 17 insertions, 27 deletions
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) ?: "<anonymous>",
- 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;