summaryrefslogtreecommitdiffstats
path: root/loc2c-test.c
diff options
context:
space:
mode:
authorroland <roland>2005-11-22 00:29:54 +0000
committerroland <roland>2005-11-22 00:29:54 +0000
commitd1531387ba69eb6b31197a5be26a63ce20bb9d40 (patch)
treece9d6d4d872a2650e7d6ebf8cb8fef0f3093bf08 /loc2c-test.c
parent422d1ceb1e08c1174154cf19bb03f788e1e10fb8 (diff)
downloadsystemtap-steved-d1531387ba69eb6b31197a5be26a63ce20bb9d40.tar.gz
systemtap-steved-d1531387ba69eb6b31197a5be26a63ce20bb9d40.tar.xz
systemtap-steved-d1531387ba69eb6b31197a5be26a63ce20bb9d40.zip
2005-11-21 Roland McGrath <roland@redhat.com>
* loc2c.c (c_translate_location): Take Dwarf_Op vector as argument directly, not Dwarf_Attribute.p * loc2c.h: Update decl. * loc2c-test.c (get_location): New function. (handle_variable): Use it. * tapsets.cxx (dwflpp::translate_location): New method. (dwflpp::translate_components, dwflpp::literal_stmt_for_local): Use it.
Diffstat (limited to 'loc2c-test.c')
-rw-r--r--loc2c-test.c42
1 files changed, 38 insertions, 4 deletions
diff --git a/loc2c-test.c b/loc2c-test.c
index 2967b9ed..4376b578 100644
--- a/loc2c-test.c
+++ b/loc2c-test.c
@@ -44,6 +44,34 @@ fail (void *arg __attribute__ ((unused)), const char *fmt, ...)
exit (2);
}
+static const Dwarf_Op *
+get_location (Dwarf_Addr dwbias, Dwarf_Addr pc, Dwarf_Attribute *loc_attr,
+ size_t *len)
+{
+ Dwarf_Op *expr;
+
+ switch (dwarf_getlocation_addr (loc_attr, pc - dwbias, &expr, len, 1))
+ {
+ case 1: /* Should always happen. */
+ if (*len == 0)
+ goto inaccessible;
+ break;
+
+ default: /* Shouldn't happen. */
+ case -1:
+ fail (NULL, _("dwarf_addrloclists (form %#x): %s"),
+ dwarf_whatform (loc_attr), dwarf_errmsg (-1));
+ return NULL;
+
+ case 0: /* Shouldn't happen. */
+ inaccessible:
+ fail (NULL, _("not accessible at this address"));
+ return NULL;
+ }
+
+ return expr;
+}
+
static void
handle_variable (Dwarf_Die *scopes, int nscopes, int out,
Dwarf_Addr cubias, Dwarf_Die *vardie, Dwarf_Addr pc,
@@ -86,9 +114,12 @@ handle_variable (Dwarf_Die *scopes, int nscopes, int out,
#define FIELD "addr"
#define emit(fmt, ...) printf (" addr = " fmt "\n", ## __VA_ARGS__)
+ size_t locexpr_len;
+ const Dwarf_Op *locexpr = get_location (cubias, pc, &attr_mem, &locexpr_len);
+
struct location *head, *tail = NULL;
head = c_translate_location (&pool, &fail, NULL, NULL,
- 1, cubias, &attr_mem, pc,
+ 1, cubias, pc, locexpr, locexpr_len,
&tail, fb_attr);
if (dwarf_attr_integrate (vardie, DW_AT_type, &attr_mem) == NULL)
@@ -181,9 +212,12 @@ handle_variable (Dwarf_Die *scopes, int nscopes, int out,
*fields, dwarf_errmsg (-1));
}
else
- c_translate_location (&pool, NULL, NULL, NULL,
- 1, cubias, &attr_mem, pc,
- &tail, NULL);
+ {
+ locexpr = get_location (cubias, pc, &attr_mem, &locexpr_len);
+ c_translate_location (&pool, NULL, NULL, NULL,
+ 1, cubias, pc, locexpr, locexpr_len,
+ &tail, NULL);
+ }
++fields;
break;