]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
libdw: Simplify __libdw_visit_scopes' tag checks
authorJosh Stone <jistone@redhat.com>
Tue, 24 Sep 2013 22:52:05 +0000 (15:52 -0700)
committerJosh Stone <jistone@redhat.com>
Wed, 25 Sep 2013 16:39:32 +0000 (09:39 -0700)
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>
libdw/ChangeLog
libdw/libdw_visit_scopes.c

index 8e1dd92cb7f1411148ed7a2199e69477bc8a68fc..21cc4854b23553e06823cf2a208e74102f4bcbaf 100644 (file)
@@ -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.
index a8555ce4b19c35bf8402c8d253ecdef27e63e4cf..487375dcc4a6c03aa2d0617c314a67c809332f60 100644 (file)
 #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)
          {