mirror of
https://github.com/openharmony/third_party_elfutils.git
synced 2026-07-19 11:33:45 -04:00
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>
This commit is contained in:
@@ -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.
|
||||
|
||||
+13
-34
@@ -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)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user