summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Wielaard <mjw@redhat.com>2011-04-12 15:01:02 +0200
committerMark Wielaard <mjw@redhat.com>2011-04-12 15:01:02 +0200
commit1f282b3fd8fcde13ba8acf21aca9e40e4328c222 (patch)
tree9f540547885919c031808fc2cb09428fef0eb983
parent41aa345222e2981e395fecb9c498885253063409 (diff)
downloadelfutils-1f282b3fd8fcde13ba8acf21aca9e40e4328c222.tar.gz
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.
-rw-r--r--dwarflint/check_linkage_external_die.cc23
-rw-r--r--libdw/c++/dwarf25
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);