From a9c8f5a0cae115769db9e7d4de1778aac1ccd77c Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Thu, 26 Feb 2009 16:38:20 -0800 Subject: [PATCH] Track containing DIE tag in C++ reader attr_value interface. --- libdw/ChangeLog | 7 +++++++ libdw/c++/dwarf | 10 ++++++---- libdw/c++/values.cc | 5 ++--- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/libdw/ChangeLog b/libdw/ChangeLog index cbd457dfc..fc0817645 100644 --- a/libdw/ChangeLog +++ b/libdw/ChangeLog @@ -1,3 +1,10 @@ +2009-02-26 Roland McGrath + + * c++/dwarf (dwarf::attr_value): Add _m_tag private member. + (dwarf::attr_value, dwarf::attribute): Update initializers. + (dwarf::raw_attributes::const_iterator): Update caller. + * c++/values.cc (attr_value::what_space): Use it. + 2009-02-01 Roland McGrath * c++/edit-values.cc: New file. diff --git a/libdw/c++/dwarf b/libdw/c++/dwarf index 69127aa09..862b9a146 100644 --- a/libdw/c++/dwarf +++ b/libdw/c++/dwarf @@ -670,7 +670,7 @@ namespace elfutils { if (unlikely (_m_offset == 1)) throw std::runtime_error ("dereferencing end iterator"); - return attribute (_m_attr); + return attribute (_m_die, _m_attr); } }; inline const_iterator begin () const @@ -1027,13 +1027,15 @@ namespace elfutils friend class location_attr; friend class range_list; private: + const int _m_tag; ::Dwarf_Attribute _m_attr; inline ::Dwarf_Attribute *thisattr () const { return const_cast< ::Dwarf_Attribute *> (&_m_attr); } - attr_value (const ::Dwarf_Attribute &attr) : _m_attr (attr) {} + attr_value (int tag, const ::Dwarf_Attribute &attr) + : _m_tag (tag), _m_attr (attr) {} inline bool same (const attr_value &other) const { @@ -1757,8 +1759,8 @@ namespace elfutils } }; - attribute (const ::Dwarf_Attribute &attr) - : first (*this), second (attr) {} + attribute (const debug_info_entry &die, const ::Dwarf_Attribute &attr) + : first (*this), second (die.tag (), attr) {} public: lhs first; diff --git a/libdw/c++/values.cc b/libdw/c++/values.cc index 335b80d19..0c31d5b3f 100644 --- a/libdw/c++/values.cc +++ b/libdw/c++/values.cc @@ -120,9 +120,8 @@ dwarf::attr_value::what_space () const throw std::runtime_error ("XXX bad form"); } - unsigned int expected = expected_value_space - (dwarf_whatattr (thisattr ()), 0); // XXX need tag! - + unsigned int expected = expected_value_space (dwarf_whatattr (thisattr ()), + _m_tag); if (unlikely ((expected & possible) == 0)) { if (expected == 0 && possible == (VS(unit_reference) | VS(reference))) -- 2.47.2