summaryrefslogtreecommitdiffstats
path: root/libdw/dwarf_getattrs.c
diff options
context:
space:
mode:
authorJosh Stone <[email protected]>2014-12-10 18:28:04 -0800
committerJosh Stone <[email protected]>2014-12-11 11:23:26 -0800
commitb849f813e6753ea60784175321d4bde78c0c2ad9 (patch)
tree188555c682eb0f62537aba273dbba673f61d570a /libdw/dwarf_getattrs.c
parent2098b3d315b612d12b1425639707552e06131cde (diff)
libdw: unify die->abbrev lookups
Add a new internal function, __libdw_dieabbrev, which deals with checking a die for an abbrev, and setting it as needed. Signed-off-by: Josh Stone <[email protected]>
Diffstat (limited to 'libdw/dwarf_getattrs.c')
-rw-r--r--libdw/dwarf_getattrs.c19
1 files changed, 7 insertions, 12 deletions
diff --git a/libdw/dwarf_getattrs.c b/libdw/dwarf_getattrs.c
index 627a8511..9ea70fca 100644
--- a/libdw/dwarf_getattrs.c
+++ b/libdw/dwarf_getattrs.c
@@ -44,17 +44,12 @@ dwarf_getattrs (Dwarf_Die *die, int (*callback) (Dwarf_Attribute *, void *),
if (unlikely (offset == 1))
return 1;
- const unsigned char *die_addr = die->addr;
+ const unsigned char *die_addr;
- /* Get the abbreviation code. */
- unsigned int u128;
- get_uleb128 (u128, die_addr);
+ /* Find the abbreviation entry. */
+ Dwarf_Abbrev *abbrevp = __libdw_dieabbrev (die, &die_addr);
- if (die->abbrev == NULL)
- /* Find the abbreviation. */
- die->abbrev = __libdw_findabbrev (die->cu, u128);
-
- if (unlikely (die->abbrev == DWARF_END_ABBREV))
+ if (unlikely (abbrevp == DWARF_END_ABBREV))
{
invalid_dwarf:
__libdw_seterrno (DWARF_E_INVALID_DWARF);
@@ -62,8 +57,8 @@ dwarf_getattrs (Dwarf_Die *die, int (*callback) (Dwarf_Attribute *, void *),
}
/* This is where the attributes start. */
- const unsigned char *attrp = die->abbrev->attrp;
- const unsigned char *const offset_attrp = die->abbrev->attrp + offset;
+ const unsigned char *attrp = abbrevp->attrp;
+ const unsigned char *const offset_attrp = abbrevp->attrp + offset;
/* Go over the list of attributes. */
Dwarf *dbg = die->cu->dbg;
@@ -105,7 +100,7 @@ dwarf_getattrs (Dwarf_Die *die, int (*callback) (Dwarf_Attribute *, void *),
/* Return the offset of the start of the attribute, so that
dwarf_getattrs() can be restarted from this point if the
caller so desires. */
- return remembered_attrp - die->abbrev->attrp;
+ return remembered_attrp - abbrevp->attrp;
}
/* Skip over the rest of this attribute (if there is any). */