]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
Fix dwarfcmp -l case to save/restore visiting state around subtree recursions.
authorRoland McGrath <roland@redhat.com>
Tue, 13 Jul 2010 20:13:34 +0000 (13:13 -0700)
committerRoland McGrath <roland@redhat.com>
Tue, 13 Jul 2010 20:13:34 +0000 (13:13 -0700)
libdw/ChangeLog
libdw/c++/dwarf_comparator
src/ChangeLog
src/dwarfcmp.cc

index e4872780c55c78dec451abfcf470843f0136e380..e3645bb0e3beecae57590d222f274a34a4795740 100644 (file)
@@ -1,3 +1,9 @@
+2010-07-13  Roland McGrath  <roland@redhat.com>
+
+       * c++/dwarf_comparator (dwarf_tracker_base): Replace visit method with
+       visitor type.
+       (dwarf_comparator): Update caller.
+
 2010-07-01  Roland McGrath  <roland@redhat.com>
 
        * c++/values.cc (is_list, what_space): Handle v4 CU rules.
index 1fe062c8c383e75dad68268d4bd5b821beda3a46..fa167e5201b262cb143f2761a64b17bb777c3dc0 100644 (file)
@@ -1,5 +1,5 @@
 /* elfutils::dwarf_comparator -- -*- C++ -*- templates for comparing DWARF data
-   Copyright (C) 2009 Red Hat, Inc.
+   Copyright (C) 2009-2010 Red Hat, Inc.
    This file is part of Red Hat elfutils.
 
    Red Hat elfutils is free software; you can redistribute it and/or modify
@@ -90,10 +90,19 @@ namespace elfutils
       }
     };
 
-    inline void visit (const typename dwarf1::debug_info_entry &,
-                      const typename dwarf2::debug_info_entry &)
+    /* This is enough like step that they should probably be merged.
+       But it's separate.  */
+    struct visitor
     {
-    }
+      inline visitor (dwarf_tracker_base *,
+                     const typename dwarf1::debug_info_entry &,
+                     const typename dwarf2::debug_info_entry &)
+      {
+      }
+      inline ~visitor ()
+      {
+      }
+    };
 
     inline bool mismatch (cu1 &, const cu1 &, // at, end
                          cu2 &, const cu2 &)
@@ -250,7 +259,7 @@ namespace elfutils
 
     inline bool match (const die1 &a, const die2 &b)
     {
-      _m_tracker.visit (a, b);
+      typename tracker::visitor visit (&_m_tracker, a, b);
       if (a.tag () != b.tag ())
        return nomatch (a, b, "DIE tag");
       if (!equals (a.attributes (), b.attributes ()))
index 5bb85453bda4d5336f88559c64ea2ec2b463e978..21aed9dd1e6c1f05d57abccb8ca4a725d8954dbd 100644 (file)
@@ -1,3 +1,8 @@
+2010-07-13  Roland McGrath  <roland@redhat.com>
+
+       * dwarfcmp.cc (talker): Replace visit method with visitor type.
+       (noisy_compare): Update caller.
+
 2010-06-22  Roland McGrath  <roland@redhat.com>
 
        * readelf.c (print_debug_line_section): Fix braino in DW_LNS_set_isa.
index e4ad6d85727e893537b25b8828111a24a73c8a63..a853284153b7ef80985d3f99241a0c4294b445da 100644 (file)
@@ -208,18 +208,31 @@ struct talker : public dwarf_ref_tracker<dwarf1, dwarf2>
                << ": ";
   }
 
-  inline void visit (const typename dwarf1::debug_info_entry &a,
-                    const typename dwarf2::debug_info_entry &b)
+  struct visitor
   {
-    a_ = &a;
-    b_ = &b;
-    visiting_result_ = a.tag () == b.tag ();
-    if (!visiting_result_)
-      location () << dwarf::tags::name (a.tag ())
-                 << " vs "
-                 << dwarf::tags::name (b.tag ())
-                 << endl;
-  }
+    talker *t_;
+    const typename dwarf1::debug_info_entry *const save_a_;
+    const typename dwarf2::debug_info_entry *const save_b_;
+    inline visitor (talker *t,
+                   const typename dwarf1::debug_info_entry &a,
+                   const typename dwarf2::debug_info_entry &b)
+      : t_ (t), save_a_ (t->a_), save_b_ (t->b_)
+    {
+      t_->a_ = &a;
+      t_->b_ = &b;
+      t_->visiting_result_ = a.tag () == b.tag ();
+      if (!t_->visiting_result_)
+       t_->location () << dwarf::tags::name (a.tag ())
+                      << " vs "
+                      << dwarf::tags::name (b.tag ())
+                      << endl;
+    }
+    inline ~visitor ()
+    {
+      t_->a_ = save_a_;
+      t_->b_ = save_b_;
+    }
+  };
 
   inline bool keep_going ()
   {
@@ -436,7 +449,7 @@ struct talker : public dwarf_ref_tracker<dwarf1, dwarf2>
          }
 
        // This prints the differences if it finds some.
-       visit (*path_top (left), *path_top (right));
+       visitor visit (this, *path_top (left), *path_top (right));
        if (!visiting_result_)
          {
            cout << endl;
@@ -625,7 +638,8 @@ noisy_compare (const dwarf &file1, const dwarf &file2,
 
       if (cmp (file1, file2, a, b))
        {
-         cmp._m_tracker.visit (a, b);
+         typename noisy_cmp<dwarf, dwarf, print_all>::my_tracker::visitor
+           visit (&cmp._m_tracker, a, b);
          cmp._m_tracker.location () << "match" << endl;
        }
       else