mirror of
git://sourceware.org/git/libabigail.git
synced 2025-02-15 21:16:54 +00:00
Bug URL: https://sourceware.org/bugzilla/show_bug.cgi?id=17649. abidiff stumbled accross a diff graph with cycles. And it kept walking that graph endlessly. Of course. It turned out on such graphs with cycles, the categorizing code that uses abigail::comparison::diff::traverse() to walk the graph and categorize the diff nodes was traversing the same class of equivalence of certain diff nodes more than once without even noticing. This patch changes the logic of the diff graph traversing code to make it always call diff_node_visitor::visit_begin() on the visitor for a diff node prior to visiting it (visiting means calling diff_node_visitor::visit()) and diff_node_visitor::visit_end() after visiting it. But when the diff node has already been visited and it's reached again by the traversing code (in case of a cycle) then the diff_node_visitor::visit_begin() is called, but diff_node_visitor::visit() is *NOT*. Then diff_node_visitor::visit_end() is called. In other words, even when the diff node is not visited (because it's already been visited) the pair diff_node_visitor::{visit_begin,visit_end}() is called. This avoids traversing the diff node (or rather the equivalence class of the diff node) more than once even in presence of cycles, but still gives a chance to custom visitors to detect that they are seeing a cycle and act accordingly if need be. This is a kind of cycle detection feature. Then the code of the (harmless and harmful categorization) filters has been adapted to always rely on the cycle detection feature. The code of the category propagation visitor has also been adapted to propagate the category of a given diff node to and from its canonical diff node. * include/abg-comp-filter.h (harm{less,ful}_filter::visit_end): Declare new methods. * include/abg-comparison.h (diff_context::maybe_apply_filters): Remove the traverse_nodes_once flag. * src/abg-comp-filter.cc (apply_filter): Force the traversing to operate in cycle avoidance mode. (harm{less,ful}_filter::visit): Update the category of the canonical node too. (harm{less,ful}_filter::visit_end): Define new method. * src/abg-comparison.cc (diff_context::maybe_apply_filters): Remove the traverse_nodes_once flag. Adjust. Simplify logic. (diff::traverse): Always call diff_node_visitor::{begin,end}. If the node has already been visited previously then do not call diff_node_visitor::visit() and do not visit the children nodes. (category_propagation_visitor::visit_end): If the node has already been visited, then propagate the category from the canonical nodes of the children nodes. (propagate_categories): Force the traversing to operate in cycle avoidance mode. Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
---|---|---|
.. | ||
abg-comp-filter.h | ||
abg-comparison.h | ||
abg-config.h | ||
abg-corpus.h | ||
abg-diff-utils.h | ||
abg-dwarf-reader.h | ||
abg-fwd.h | ||
abg-hash.h | ||
abg-ini.h | ||
abg-ir.h | ||
abg-libxml-utils.h | ||
abg-libzip-utils.h | ||
abg-reader.h | ||
abg-sptr-utils.h | ||
abg-tools-utils.h | ||
abg-traverse.h | ||
abg-version.h.in | ||
abg-viz-common.h | ||
abg-viz-dot.h | ||
abg-viz-svg.h | ||
abg-writer.h | ||
Makefile.am |