]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
Add elfutils::dwarf::attribute_type::find_integrate ().
authorMark Wielaard <mjw@redhat.com>
Tue, 12 Apr 2011 13:01:02 +0000 (15:01 +0200)
committerMark Wielaard <mjw@redhat.com>
Tue, 12 Apr 2011 13:01:02 +0000 (15:01 +0200)
Same as find (), but if the attribute name isn't found,
but there is  is an abstract_origin or specification
attribute, then will try to find_integrate () the name
from that reference.

check_linkage_external_die.is_external () now uses it.

dwarflint/check_linkage_external_die.cc
libdw/c++/dwarf

index 9d759dd1ffb08a0404b1dbd3f6d628b7211e1d1e..d615afaefafda64aa2d08b01c9a61b00a4b68ed0 100644 (file)
@@ -99,27 +99,12 @@ namespace
 
     static bool is_external (all_dies_iterator<dwarf> const &it)
     {
-      bool candidates = true;
       dwarf::debug_info_entry entry = *it;
-      do
-       {
-         dwarf::debug_info_entry::attributes_type attrs = entry.attributes ();
-         if (attrs.find (DW_AT_external) != attrs.end ())
-           return true;
-
-         dwarf::debug_info_entry::attributes_type::const_iterator origin
-           = attrs.find (DW_AT_abstract_origin);
-         if (origin == attrs.end ())
-           origin = attrs.find (DW_AT_specification);
-
-         if (origin != attrs.end ())
-           entry = *(*origin).second.reference ();
-         else
-           candidates = false;
-       }
-      while (candidates);
+      dwarf::debug_info_entry::attributes_type attrs = (*it).attributes ();
+      dwarf::debug_info_entry::attributes_type::const_iterator external
+       = attrs.find_integrate (DW_AT_external);
 
-      return false;
+      return external != attrs.end () && (*external).second.flag ();
     }
 
     virtual void
index c386f0ed69de3faba93d21f317b465f76f23012c..843f572f5c23227c9054456b89933af46eb112e7 100644 (file)
@@ -978,6 +978,31 @@ namespace elfutils
        return const_iterator (_m_raw.find (name), _m_raw.end ());
       }
 
+      /*
+       Same as find (), but if the attribute name isn't found,
+       but there is  is an abstract_origin or specification
+       attribute, then will try to find_integrate () the name
+       from that reference.
+      */
+      inline const_iterator find_integrate (int name) const
+      {
+       const_iterator result = find (name);
+       if (result != end ())
+         return result;
+
+       result = find (DW_AT_abstract_origin);
+       if (result == end ())
+         result = find (DW_AT_specification);
+
+       if (result != end ())
+         {
+           debug_info_entry integrate = (*(*result).second.reference ());
+           return integrate.attributes ().find_integrate (name);
+         }
+
+       return end ();
+      }
+
       inline const attr_value at (int name)
       {
        const_iterator i = find (name);