[2/9] dwarf-reader: Log the number of canonicalized types

Message ID 87jyqcpcq9.fsf@seketeli.org
State New
Headers
Series [1/9] tests/mockfedabipkgdiff.in: Fix python module loading |

Commit Message

Dodji Seketeli July 30, 2026, 6:13 p.m. UTC
  Hello,

When doing abidw --verbose, log the number of unique canonicalized
types.

	* src/abg-dwarf-reader.cc (reader::canonicalize_types_scheduled):
	Log the number of unique canonicalized types in the system using
	the new function environment::priv::get_number_of_canonical_types.
	* src/abg-ir-priv.h
	(environment::priv::get_number_of_canonical_types): Define new
	function.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>

Applied to the master branch.
---
 src/abg-dwarf-reader.cc |  6 +++++-
 src/abg-ir-priv.h       | 14 ++++++++++++++
 2 files changed, 19 insertions(+), 1 deletion(-)
  

Patch

diff --git a/src/abg-dwarf-reader.cc b/src/abg-dwarf-reader.cc
index 5b66fed2..db09958c 100644
--- a/src/abg-dwarf-reader.cc
+++ b/src/abg-dwarf-reader.cc
@@ -5091,9 +5091,13 @@  public:
 	if (do_log())
 	  {
 	    cn_timer.stop();
+	    const environment& env = types_to_canonicalize().front()->get_environment();
 	    cerr << "DWARF Reader finished types "
 		 << "sorting, hashing & canonicalizing in: "
-		 << cn_timer << "\n";
+		 << cn_timer
+		 << ", for "
+		 << env.priv_->get_number_of_canonical_types()
+		 << " types\n";
 	  }
   }
 
diff --git a/src/abg-ir-priv.h b/src/abg-ir-priv.h
index 24da0f02..b9e2d63e 100644
--- a/src/abg-ir-priv.h
+++ b/src/abg-ir-priv.h
@@ -806,6 +806,20 @@  struct environment::priv
     right_type_comp_operands_.pop_back();
   }
 
+  /// Get the number of canonical types in the system.
+  ///
+  /// @return the number of canonical types in the system.
+  size_t
+  get_number_of_canonical_types()
+  {
+    size_t n = 0;
+    for (auto& entry : canonical_types_)
+      for(unsigned i = 0; i < entry.second.size(); ++i)
+	++n;
+
+    return n;
+  }
+
 #ifdef WITH_DEBUG_SELF_COMPARISON
 
   const unordered_map<string, uintptr_t>&