From: Roland McGrath Date: Tue, 13 Jul 2010 20:13:34 +0000 (-0700) Subject: Fix dwarfcmp -l case to save/restore visiting state around subtree recursions. X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=c28d2e5c0448b5c32f39fa1753115d2daaa0b06f;p=thirdparty%2Felfutils.git Fix dwarfcmp -l case to save/restore visiting state around subtree recursions. --- diff --git a/libdw/ChangeLog b/libdw/ChangeLog index e4872780c..e3645bb0e 100644 --- a/libdw/ChangeLog +++ b/libdw/ChangeLog @@ -1,3 +1,9 @@ +2010-07-13 Roland McGrath + + * c++/dwarf_comparator (dwarf_tracker_base): Replace visit method with + visitor type. + (dwarf_comparator): Update caller. + 2010-07-01 Roland McGrath * c++/values.cc (is_list, what_space): Handle v4 CU rules. diff --git a/libdw/c++/dwarf_comparator b/libdw/c++/dwarf_comparator index 1fe062c8c..fa167e520 100644 --- a/libdw/c++/dwarf_comparator +++ b/libdw/c++/dwarf_comparator @@ -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 ())) diff --git a/src/ChangeLog b/src/ChangeLog index 5bb85453b..21aed9dd1 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2010-07-13 Roland McGrath + + * dwarfcmp.cc (talker): Replace visit method with visitor type. + (noisy_compare): Update caller. + 2010-06-22 Roland McGrath * readelf.c (print_debug_line_section): Fix braino in DW_LNS_set_isa. diff --git a/src/dwarfcmp.cc b/src/dwarfcmp.cc index e4ad6d857..a85328415 100644 --- a/src/dwarfcmp.cc +++ b/src/dwarfcmp.cc @@ -208,18 +208,31 @@ struct talker : public dwarf_ref_tracker << ": "; } - 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 } // 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::my_tracker::visitor + visit (&cmp._m_tracker, a, b); cmp._m_tracker.location () << "match" << endl; } else