summaryrefslogtreecommitdiff
path: root/libdw/c++/dwarf_comparator
diff options
context:
space:
mode:
Diffstat (limited to 'libdw/c++/dwarf_comparator')
-rw-r--r--libdw/c++/dwarf_comparator51
1 files changed, 33 insertions, 18 deletions
diff --git a/libdw/c++/dwarf_comparator b/libdw/c++/dwarf_comparator
index 56bcd81d..b799ed42 100644
--- a/libdw/c++/dwarf_comparator
+++ b/libdw/c++/dwarf_comparator
@@ -128,22 +128,30 @@ namespace elfutils
return false;
}
+ struct reference_match
+ {
+ inline bool quick_match (const die2 &)
+ {
+ return false;
+ }
+
+ inline void notice_match (const die2 &, bool)
+ {
+ }
+ };
+ inline reference_match reference_matched (const die1 &)
+ {
+ return reference_match ();
+ }
+
inline dwarf_tracker_base ()
{}
- inline dwarf_tracker_base (const dwarf_tracker_base &,
+ inline dwarf_tracker_base (const dwarf_tracker_base &, reference_match &,
const left_context_type &, const die1 &,
const right_context_type &, const die2 &)
{}
- inline bool quick_reference_match (const die1 &, const die2 &)
- {
- return false;
- }
-
- inline void notice_reference_match (const die1 &, const die2 &)
- {
- }
};
template<class dwarf1, class dwarf2,
@@ -454,8 +462,8 @@ namespace elfutils
if (a.tag () != b.tag ())
return false;
- const bool any_children = a.has_children ();
- if (any_children != b.has_children ())
+ const bool has_children = a.has_children ();
+ if (has_children != b.has_children ())
return false;
// Now we have to get the tracker involved.
@@ -465,9 +473,15 @@ namespace elfutils
= _m_tracker.right_context (ref2);
// Maybe the tracker has already cached a correspondence of references.
- if (_m_tracker.quick_reference_match (ref1, ref2))
+ typename tracker::reference_match matched
+ = _m_tracker.reference_matched (ref1);
+ if (matched.quick_match (ref2))
return true;
+ std::cout << "considering ref "
+ << std::hex << a.offset () << " vs "
+ << std::hex << b.offset () << std::endl;
+
/* First do the cheap mismatch check on the contexts, then check the
contents and contexts in ascending order of costliness of a check. */
if (_m_tracker.context_quick_mismatch (lhs, rhs)
@@ -476,16 +490,17 @@ namespace elfutils
return false;
/* To compare the children, we have to clone the tracker and use a
- new one. The new tracker jump-starts its walk to the referenced
- DIE from the root of the CU. */
- bool result = !any_children || (dwarf_comparator (tracker (_m_tracker,
+ 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. */
+ bool result = !has_children || (dwarf_comparator (tracker (_m_tracker,
+ matched,
lhs, ref1,
rhs, ref2))
.match (a.children (), b.children ()));
- // Let the tracker cache a known match for its quick_reference_match.
- if (result)
- _m_tracker.notice_reference_match (ref1, ref2);
+ // Let the tracker cache a result for its reference_match::quick_match.
+ matched.notice_match (ref2, result);
return result;
}