]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
nu?
authorRoland McGrath <roland@redhat.com>
Mon, 29 Jun 2009 08:55:55 +0000 (01:55 -0700)
committerRoland McGrath <roland@redhat.com>
Mon, 29 Jun 2009 08:55:55 +0000 (01:55 -0700)
libdw/c++/dwarf_comparator
libdw/c++/dwarf_tracker

index b799ed42da098d08f3292e26a86ce6c145154bf9..60196cf1eaecfb7d26e5e538e3a34e517066ff8c 100644 (file)
@@ -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;
index 2fefc426b80e01e52b2953410cb63058d71b1d4e..1e46366eb8b1c208485928f9a78efd781f3e9eb8 100644 (file)
@@ -202,7 +202,7 @@ namespace elfutils
     tracker2 _m_right;
 
     typedef std::tr1::unordered_map<
-      ::Dwarf_Off, std::pair<dwarf_ref_tracker *,
+      ::Dwarf_Off, std::pair<const std::list<die2> *,
                             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");
     }