public inbox for libabigail@sourceware.org
 help / color / mirror / Atom feed
* [PATCH, applied] ir: Add some debugging facilities for the comparison machinery
@ 2022-06-30 12:52 Dodji Seketeli
  0 siblings, 0 replies; only message in thread
From: Dodji Seketeli @ 2022-06-30 12:52 UTC (permalink / raw)
  To: libabigail

Hello,

When looking at something else, I felt the need to write the
debugging facilities below to dump the content of the set of types
being compared, to better understand why some comparison take more or
less time.

	* src/abg-ir-priv.h: Include iostream to access std::cerr.
	(environment::priv::{dump_classes_being_compared,
	dump_fn_types_being_compared}): Define new member functions.
	* src/abg-ir.cc (dump_classes_being_compared)
	(dump_fn_types_being_compared): Define new functions.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Applied to master.
---
 src/abg-ir-priv.h | 43 +++++++++++++++++++++++++++++++++++++++++++
 src/abg-ir.cc     | 24 ++++++++++++++++++++++++
 2 files changed, 67 insertions(+)

diff --git a/src/abg-ir-priv.h b/src/abg-ir-priv.h
index 0a5ab00d..3d7f9cb0 100644
--- a/src/abg-ir-priv.h
+++ b/src/abg-ir-priv.h
@@ -14,6 +14,7 @@
 #define __ABG_IR_PRIV_H__
 
 #include <string>
+#include <iostream>
 
 #include "abg-ir.h"
 #include "abg-corpus.h"
@@ -546,6 +547,48 @@ struct environment::priv
   clear_type_comparison_results_cache()
   {type_comparison_results_cache_.clear();}
 
+  /// Dumps a textual representation (to the standard error output) of
+  /// the content of the set of classes being currently compared using
+  /// the @ref equal overloads.
+  ///
+  /// This function is for debugging purposes.
+  void
+  dump_classes_being_compared()
+  {
+    std::cerr << "classes being compared: " << classes_being_compared_.size()
+	      << "\n"
+	      << "=====================================\n";
+    for (auto& p : classes_being_compared_)
+      {
+	class_or_union* c = reinterpret_cast<class_or_union*>(p.first);
+	std::cerr << "'" << c->get_pretty_representation()
+		  << " / (" << std::hex << p.first << "," << p.second << ")"
+		  << "'\n";
+      }
+    std::cerr << "=====================================\n";
+  }
+
+  /// Dumps a textual representation (to the standard error output) of
+  /// the content of the set of classes being currently compared using
+  /// the @ref equal overloads.
+  ///
+  /// This function is for debugging purposes.
+  void
+  dump_fn_types_being_compared()
+  {
+    std::cerr << "fn_types being compared: " << fn_types_being_compared_.size()
+	      << "\n"
+	      << "=====================================\n";
+    for (auto& p : fn_types_being_compared_)
+      {
+	function_type* c = reinterpret_cast<function_type*>(p.first);
+	std::cerr << "'" << c->get_pretty_representation()
+		  << " / (" << std::hex << p.first << "," << p.second << ")"
+		  << "'\n";
+      }
+    std::cerr << "=====================================\n";
+  }
+
   /// Push a pair of operands on the stack of operands of the current
   /// type comparison, during type canonicalization.
   ///
diff --git a/src/abg-ir.cc b/src/abg-ir.cc
index 7a5db60f..9bbe99f2 100644
--- a/src/abg-ir.cc
+++ b/src/abg-ir.cc
@@ -21429,6 +21429,30 @@ class_or_union::operator==(const class_or_union& other) const
   return class_or_union::operator==(o);
 }
 
+/// Dumps a textual representation (to the standard error output) of
+/// the content of the set of classes being currently compared using
+/// the @ref equal overloads.
+///
+/// This function is for debugging purposes.
+///
+/// @param c an artifact that belongs to the environment in which the
+/// classes of interest are being compared.
+void
+dump_classes_being_compared(const type_or_decl_base& c)
+{c.get_environment()->priv_->dump_classes_being_compared();}
+
+/// Dumps a textual representation (to the standard error output) of
+/// the content of the set of function types being currently compared
+/// using the @ref equal overloads.
+///
+/// This function is for debugging purposes.
+///
+/// @param c an artifact that belongs to the environment in which the
+/// function types of interest are being compared.
+void
+dump_fn_types_being_compared(const type_or_decl_base& t)
+{t.get_environment()->priv_->dump_fn_types_being_compared();}
+
 /// Compares two instances of @ref class_or_union.
 ///
 /// If the two intances are different, set a bitfield to give some
-- 
2.36.1


-- 
		Dodji


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-06-30 12:53 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-30 12:52 [PATCH, applied] ir: Add some debugging facilities for the comparison machinery Dodji Seketeli

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).