diff options
author | Roland McGrath <roland@redhat.com> | 2009-09-24 13:05:41 -0700 |
---|---|---|
committer | Roland McGrath <roland@redhat.com> | 2009-09-24 13:06:31 -0700 |
commit | 2e2a5d82cfd03db7be2e9ff1457b5ea50e46bc3a (patch) | |
tree | e11572dbb27ac79da1acb29507b5b99b2d58991d /loc2c-test.c | |
parent | a1c1924486c8a29451898a9fe0cb83c8b472a78e (diff) | |
download | systemtap-steved-2e2a5d82cfd03db7be2e9ff1457b5ea50e46bc3a.tar.gz systemtap-steved-2e2a5d82cfd03db7be2e9ff1457b5ea50e46bc3a.tar.xz systemtap-steved-2e2a5d82cfd03db7be2e9ff1457b5ea50e46bc3a.zip |
Support DW_AT_const_value cases in loc2c and loc2c-test.
* loc2c.c (c_translate_constant): New function.
* loc2c.h: Declare it.
* loc2c-test.c (main): Use it for DW_AT_const_value cases.
Diffstat (limited to 'loc2c-test.c')
-rw-r--r-- | loc2c-test.c | 36 |
1 files changed, 22 insertions, 14 deletions
diff --git a/loc2c-test.c b/loc2c-test.c index 495a95f1..17edf1a8 100644 --- a/loc2c-test.c +++ b/loc2c-test.c @@ -122,22 +122,29 @@ handle_variable (Dwarf_Die *lscopes, int lnscopes, int out, } } - Dwarf_Attribute attr_mem; + struct location *head, *tail = NULL; - if (dwarf_attr_integrate (vardie, DW_AT_location, &attr_mem) == NULL) - error (2, 0, _("cannot get location of variable: %s"), - dwarf_errmsg (-1)); + Dwarf_Attribute attr_mem; + if (dwarf_attr_integrate (vardie, DW_AT_const_value, &attr_mem) != NULL) + /* There is no location expression, but a constant value instead. */ + head = tail = c_translate_constant (&pool, &fail, NULL, NULL, + 1, cubias, &attr_mem); + else + { -#define FIELD "addr" -#define emit(fmt, ...) printf (" addr = " fmt "\n", ## __VA_ARGS__) + if (dwarf_attr_integrate (vardie, DW_AT_location, &attr_mem) == NULL) + error (2, 0, _("cannot get location of variable: %s"), + dwarf_errmsg (-1)); - size_t locexpr_len; - const Dwarf_Op *locexpr = get_location (cubias, pc, &attr_mem, &locexpr_len); + 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, pc, &attr_mem, locexpr, locexpr_len, - &tail, fb_attr, cfa_ops); + head = c_translate_location (&pool, &fail, NULL, NULL, + 1, cubias, pc, &attr_mem, + locexpr, locexpr_len, + &tail, fb_attr, cfa_ops); + } if (dwarf_attr_integrate (vardie, DW_AT_type, &attr_mem) == NULL) error (2, 0, _("cannot get type of variable: %s"), @@ -244,8 +251,9 @@ handle_variable (Dwarf_Die *lscopes, int lnscopes, int out, else #endif { - locexpr = get_location (cubias, pc, &attr_mem, - &locexpr_len); + size_t locexpr_len; + const Dwarf_Op *locexpr = get_location (cubias, pc, &attr_mem, + &locexpr_len); c_translate_location (&pool, NULL, NULL, NULL, 1, cubias, pc, &attr_mem, locexpr, locexpr_len, |