diff options
-rw-r--r-- | dwarflint/check_linkage_external_die.cc | 23 | ||||
-rw-r--r-- | libdw/c++/dwarf | 25 |
2 files changed, 29 insertions, 19 deletions
diff --git a/dwarflint/check_linkage_external_die.cc b/dwarflint/check_linkage_external_die.cc index 9d759dd1..d615afae 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<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 diff --git a/libdw/c++/dwarf b/libdw/c++/dwarf index c386f0ed..843f572f 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); |