diff options
author | Josh Stone <jistone@redhat.com> | 2013-09-24 15:52:05 -0700 |
---|---|---|
committer | Josh Stone <jistone@redhat.com> | 2013-09-25 09:39:32 -0700 |
commit | f06c858f10d41b5156cc818c937d2ddd403d906d (patch) | |
tree | e99d02f1c2d703f54bf2ee4a88681ff7eaba43ae | |
parent | 2cfec29465e4d1882256f85eb92bbde4a9bdedbe (diff) | |
download | elfutils-f06c858f10d41b5156cc818c937d2ddd403d906d.tar.gz |
libdw: Simplify __libdw_visit_scopes' tag checks
The former classify_die() was splitting tags into more classes than
actually needed.
The one place that used the "imported" die_class now just compares to
DW_TAG_imported_unit directly.
The recursion check was squashing "match", "match_inline", and "walk"
into the same action. Now that uses the new may_have_scopes(), which
just returns true for all tags that had those classifications.
The net result has no functional change, but performs better.
Signed-off-by: Josh Stone <jistone@redhat.com>
-rw-r--r-- | libdw/ChangeLog | 8 | ||||
-rw-r--r-- | libdw/libdw_visit_scopes.c | 47 |
2 files changed, 21 insertions, 34 deletions
diff --git a/libdw/ChangeLog b/libdw/ChangeLog index 8e1dd92c..21cc4854 100644 --- a/libdw/ChangeLog +++ b/libdw/ChangeLog @@ -1,3 +1,11 @@ +2013-09-24 Josh Stone <jistone@redhat.com> + + * libdw_visit_scopes.c (classify_die): Removed. + (may_have_scopes): New function to replace classify_die. There's no + need for full classification; just find tags that may contain scopes. + (__libdw_visit_scopes): Use a direct tag comparison for imported + units, and use may_have_scopes to test if recursion is needed. + 2013-09-20 Mark Wielaard <mjw@redhat.com> * dwarf_getfuncs.c (visitor_info): New struct. diff --git a/libdw/libdw_visit_scopes.c b/libdw/libdw_visit_scopes.c index a8555ce4..487375dc 100644 --- a/libdw/libdw_visit_scopes.c +++ b/libdw/libdw_visit_scopes.c @@ -33,10 +33,9 @@ #include "libdwP.h" #include <dwarf.h> -enum die_class { ignore, match, match_inline, walk, imported }; -static enum die_class -classify_die (Dwarf_Die *die) +static bool +may_have_scopes (Dwarf_Die *die) { switch (INTUSE(dwarf_tag) (die)) { @@ -48,31 +47,21 @@ classify_die (Dwarf_Die *die) case DW_TAG_catch_block: case DW_TAG_try_block: case DW_TAG_entry_point: - return match; case DW_TAG_inlined_subroutine: - return match_inline; case DW_TAG_subprogram: - /* This might be a concrete out-of-line instance of an inline, in - which case it is not guaranteed to be owned by the right scope and - we will search for its origin as for DW_TAG_inlined_subroutine. */ - return (INTUSE(dwarf_hasattr) (die, DW_AT_abstract_origin) - ? match_inline : match); + return true; /* DIEs without addresses that can own DIEs with addresses. */ case DW_TAG_namespace: case DW_TAG_class_type: case DW_TAG_structure_type: - return walk; - - /* Special indirection required. */ - case DW_TAG_imported_unit: - return imported; + return true; /* Other DIEs we have no reason to descend. */ default: break; } - return ignore; + return false; } int @@ -104,7 +93,7 @@ __libdw_visit_scopes (depth, root, previsit, postvisit, arg) that unit are siblings of the other children. So don't do a full recursion into the imported unit, but just walk the children in place before moving to the next real child. */ - while (classify_die (&child.die) == imported) + while (INTUSE(dwarf_tag) (&child.die) == DW_TAG_imported_unit) { Dwarf_Die orig_child_die = child.die; Dwarf_Attribute attr_mem; @@ -134,23 +123,13 @@ __libdw_visit_scopes (depth, root, previsit, postvisit, arg) return result; } - if (!child.prune) - switch (classify_die (&child.die)) - { - case match: - case match_inline: - case walk: - if (INTUSE(dwarf_haschildren) (&child.die)) - { - int result = recurse (); - if (result != DWARF_CB_OK) - return result; - } - break; - - default: - break; - } + if (!child.prune && may_have_scopes (&child.die) + && INTUSE(dwarf_haschildren) (&child.die)) + { + int result = recurse (); + if (result != DWARF_CB_OK) + return result; + } if (postvisit != NULL) { |