From: Mark Wielaard Date: Tue, 12 Apr 2011 13:01:02 +0000 (+0200) Subject: Add elfutils::dwarf::attribute_type::find_integrate (). X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=1f282b3fd8fcde13ba8acf21aca9e40e4328c222;p=thirdparty%2Felfutils.git Add elfutils::dwarf::attribute_type::find_integrate (). 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. --- diff --git a/dwarflint/check_linkage_external_die.cc b/dwarflint/check_linkage_external_die.cc index 9d759dd1f..d615afaef 100644 --- a/dwarflint/check_linkage_external_die.cc +++ b/dwarflint/check_linkage_external_die.cc @@ -99,27 +99,12 @@ namespace static bool is_external (all_dies_iterator 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 diff --git a/libdw/c++/dwarf b/libdw/c++/dwarf index c386f0ed6..843f572f5 100644 --- a/libdw/c++/dwarf +++ b/libdw/c++/dwarf @@ -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);