From: Roland McGrath Date: Mon, 29 Jun 2009 08:55:55 +0000 (-0700) Subject: nu? X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=47a586dd713093304a79e51693b9fa1d5888191c;p=thirdparty%2Felfutils.git nu? --- diff --git a/libdw/c++/dwarf_comparator b/libdw/c++/dwarf_comparator index b799ed42d..60196cf1e 100644 --- a/libdw/c++/dwarf_comparator +++ b/libdw/c++/dwarf_comparator @@ -130,18 +130,20 @@ namespace elfutils struct reference_match { - inline bool quick_match (const die2 &) + inline bool cannot_match () const { return false; } - - inline void notice_match (const die2 &, bool) + inline void notice_match (const die2 &, bool) const { } }; - inline reference_match reference_matched (const die1 &) + + inline bool reference_matched (reference_match &, + const left_context_type &, const die1 &, + const right_context_type &, const die2 &) { - return reference_match (); + return false; } inline dwarf_tracker_base () @@ -473,11 +475,13 @@ namespace elfutils = _m_tracker.right_context (ref2); // Maybe the tracker has already cached a correspondence of references. - typename tracker::reference_match matched - = _m_tracker.reference_matched (ref1); - if (matched.quick_match (ref2)) + typename tracker::reference_match matched; + if (_m_tracker.reference_matched (matched, lhs, ref1, rhs, ref2)) return true; + if (matched.cannot_match ()) + return false; + std::cout << "considering ref " << std::hex << a.offset () << " vs " << std::hex << b.offset () << std::endl; diff --git a/libdw/c++/dwarf_tracker b/libdw/c++/dwarf_tracker index 2fefc426b..1e46366eb 100644 --- a/libdw/c++/dwarf_tracker +++ b/libdw/c++/dwarf_tracker @@ -202,7 +202,7 @@ namespace elfutils tracker2 _m_right; typedef std::tr1::unordered_map< - ::Dwarf_Off, std::pair *, std::tr1::unordered_set< ::Dwarf_Off> > > equiv_map; equiv_map *_m_equiv; @@ -291,13 +291,6 @@ namespace elfutils private: typename equiv_map::mapped_type *_m_elt; - inline reference_match (dwarf_ref_tracker *tracker, - typename equiv_map::mapped_type *elt) - : _m_elt (elt) - { - _m_elt->first = tracker; - } - public: inline reference_match () @@ -306,30 +299,40 @@ namespace elfutils inline ~reference_match () { - _m_elt->first = NULL; + if (_m_elt != NULL) + _m_elt->first = NULL; } - inline bool quick_match (const die2 &b) + inline bool cannot_match () const { - return _m_elt->second.find (b->identity ()) != _m_elt->second.end (); + return _m_elt == NULL; } - inline void notice_match (const die2 &b, bool matches) + inline void notice_match (const die2 &b, bool matches) const { - if (matches) + if (matches && _m_elt != NULL) _m_elt->second.insert (b->identity ()); } }; - inline reference_match reference_matched (const die1 &a) + inline bool + reference_matched (reference_match &matched, + const left_context_type &lhs, const die1 &a, + const right_context_type &rhs, const die2 &b) { typename equiv_map::mapped_type *elt = &(*_m_equiv)[a->identity ()]; if (elt->first == NULL) - return reference_match (this, elt); + { + elt->first = &rhs; + matched._m_elt = elt; + return elt->second.find (b->identity ()) != elt->second.end (); + } - // We have a circularity. std::cout << "recursing? on " << std::hex << a->offset () << std::endl; + // We have a circularity. + return elt->first == &rhs; // ??? + throw std::logic_error ("XXX can't handle circularity"); }