From 41f3954b57bb395357db96b8066dffc332539a1b Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Wed, 30 Sep 2009 16:16:02 -0700 Subject: [PATCH] Use the subtracker/subcomparator for attributes too. --- libdw/ChangeLog | 3 +++ libdw/c++/dwarf_comparator | 22 +++++++++++++++------- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/libdw/ChangeLog b/libdw/ChangeLog index 498e6ef32..dbd97019e 100644 --- a/libdw/ChangeLog +++ b/libdw/ChangeLog @@ -1,5 +1,8 @@ 2009-09-30 Roland McGrath + * c++/dwarf_comparator (dwarf_comparator::reference_match): Use the + subtracker/subcomparator for attributes too. + * c++/subr.hh (subr::sharing_stack::clear): New method. * c++/values.cc (dwarf::attr_value::what_space): diff --git a/libdw/c++/dwarf_comparator b/libdw/c++/dwarf_comparator index 87c1bf377..88f656f50 100644 --- a/libdw/c++/dwarf_comparator +++ b/libdw/c++/dwarf_comparator @@ -521,20 +521,28 @@ namespace elfutils contents and contexts in ascending order of costliness of a check. */ if (_m_tracker.context_quick_mismatch (lhs, rhs)) return nomatch (a, b, "quick context"); - if (!match (a.attributes (), b.attributes ())) - return nomatch (a, b, "attribute"); - if (!_m_tracker.context_match (lhs, rhs)) - return nomatch (a, b, "context"); /* To compare the children, we have to clone the tracker and use a new one, in case of any reference attributes in their subtrees. The new tracker jump-starts its walk to the referenced DIE from - the root of the CU. */ + the root of the CU. + + We use the subtracker and subcomparator for the attributes as well, + in case the main tracker has side-effects like printing. */ + + typename tracker::subtracker t (_m_tracker, matched, lhs, rhs); + subcomparator cmp (t); + + if (!cmp.equals (a.attributes (), b.attributes ())) + return nomatch (a, b, "attribute"); + + if (!_m_tracker.context_match (lhs, rhs)) + return nomatch (a, b, "context"); + bool result = !has_children; if (has_children) { - typename tracker::subtracker t (_m_tracker, matched, lhs, rhs); - result = subcomparator (t).equals (a.children (), b.children ()); + result = cmp.equals (a.children (), b.children ()); if (!result) result = nomatch (a, b, "children"); } -- 2.47.3