public inbox for libabigail@sourceware.org
 help / color / mirror / Atom feed
From: Dodji Seketeli <dodji@redhat.com>
To: libabigail@sourceware.org
Subject: [PATCH, applied] ir: Add some debugging facilities for the comparison machinery
Date: Thu, 30 Jun 2022 14:52:57 +0200	[thread overview]
Message-ID: <87bkuae2ja.fsf@redhat.com> (raw)

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


                 reply	other threads:[~2022-06-30 12:53 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87bkuae2ja.fsf@redhat.com \
    --to=dodji@redhat.com \
    --cc=libabigail@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).