public inbox for libabigail@sourceware.org
 help / color / mirror / Atom feed
* [PATCH, applied] abidiff: add a --debug-tc option
@ 2022-10-10 11:55 Dodji Seketeli
  0 siblings, 0 replies; only message in thread
From: Dodji Seketeli @ 2022-10-10 11:55 UTC (permalink / raw)
  To: libabigail

Hello,

Like what was done for abidw, this patch adds a --debug-tc option to
abidiff to debug type canonicalization issues.

With this option, just like for abidw, during type canonicalization,
each type comparison is done twice: once using structural comparison
and once using canonical comparison.  Both comparisons should yield
the same result otherwise, an abort signal is emitted, asking for
in-depth debugging to understand reason of the difference.

This option is enabled by the configure option
--enable-debug-type-canonicalization.

It proved useful in debugging some comparison errors I was looking at
recently.

	* doc/manuals/abidiff.rst: Add documentation for the new
	--debug-tc option.  Fix the existing documentation for
	--debug-self-comparison.
	* tools/abidiff.cc (options::do_debug_self_comparison): Renamed
	options::do_debug into this.
	(options::do_debug_type_canonicalization): Add new data member.
	(display_usage): Fix help string for the --debug option that is
	now --debug-self-comparison.  Also, add a help string for the new
	option --debug-tc option.
	(main): Adjust use options::do_debug into
	options::do_debug_self_comparison.  Call
	environment::debug_type_canonicalization() if the user provided
	the --debug-tc option.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
---
 doc/manuals/abidiff.rst | 31 +++++++++++++++++++++++++++----
 tools/abidiff.cc        | 31 +++++++++++++++++++++++++------
 2 files changed, 52 insertions(+), 10 deletions(-)

diff --git a/doc/manuals/abidiff.rst b/doc/manuals/abidiff.rst
index 0c711d9e..c728b373 100644
--- a/doc/manuals/abidiff.rst
+++ b/doc/manuals/abidiff.rst
@@ -65,14 +65,37 @@ Options
 
     Display a short help about the command and exit.
 
-  * ``--debug``
+  * ``--debug-self-comparison``
 
-    In this mode, error messages are emitted for types which fail type canonicalization.
+    In this mode, error messages are emitted for types which fail type
+    canonicalization, in some circumstances, when comparing a binary
+    against itself.
 
-    This is an optional ebugging and sanity check option.  To enable
+    When comparing a binary against itself, canonical types of the
+    second binary should be equal (as much as possible) to canonical
+    types of the first binary.  When some discrepancies are detected
+    in this mode, an abort signal is emitted and execution is halted.
+    This option should be used while executing the tool in a debugger,
+    for troubleshooting purposes.
+
+    This is an optional debugging and sanity check option.  To enable
     it the libabigail package needs to be configured with
-    the --enable-debug-self-comparison option.
+    the --enable-debug-self-comparison configure option.
+
+  * ``--debug-tc``
 
+    In this mode, the process of type canonicalization is put under
+    heavy scrutiny.  Basically, during type canonicalization, each
+    type comparison is performed twice: once in a structural mode
+    (comparing every sub-type member-wise), and once using canonical
+    comparison.  The two comparisons should yield the same result.
+    Otherwise, an abort signal is emitted and the process can be
+    debugged to understand why the two kinds of comparison yield
+    different results.
+
+    This is an optional debugging and sanity check option.  To enable
+    it the libabigail package needs to be configured with
+    the --enable-debug-type-canonicalization configure option.
 
   * ``--version | -v``
 
diff --git a/tools/abidiff.cc b/tools/abidiff.cc
index e0bb35ac..9b2ab784 100644
--- a/tools/abidiff.cc
+++ b/tools/abidiff.cc
@@ -109,7 +109,10 @@ struct options
   bool			show_stats;
   bool			do_log;
 #ifdef WITH_DEBUG_SELF_COMPARISON
-  bool			do_debug;
+  bool			do_debug_self_comparison;
+#endif
+#ifdef WITH_DEBUG_TYPE_CANONICALIZATION
+  bool			do_debug_type_canonicalization;
 #endif
 #ifdef WITH_CTF
   bool			use_ctf;
@@ -162,7 +165,11 @@ struct options
 #endif
 #ifdef WITH_DEBUG_SELF_COMPARISON
     ,
-    do_debug()
+      do_debug_self_comparison()
+#endif
+#ifdef WITH_DEBUG_TYPE_CANONICALIZATION
+    ,
+      do_debug_type_canonicalization()
 #endif
   {}
 
@@ -256,7 +263,11 @@ display_usage(const string& prog_name, ostream& out)
     << " --ctf use CTF instead of DWARF in ELF files\n"
 #endif
 #ifdef WITH_DEBUG_SELF_COMPARISON
-    << " --debug debug the process of comparing an ABI corpus against itself"
+    << " --debug-self-comparison debug the process of comparing "
+    "an ABI corpus against itself"
+#endif
+#ifdef WITH_DEBUG_TYPE_CANONICALIZATION
+    << " --debug-tc debug the type canonicalization process"
 #endif
     << " --verbose show verbose messages about internal stuff\n";
 }
@@ -612,8 +623,12 @@ parse_command_line(int argc, char* argv[], options& opts)
         opts.use_ctf = true;
 #endif
 #ifdef WITH_DEBUG_SELF_COMPARISON
-      else if (!strcmp(argv[i], "--debug"))
-	opts.do_debug = true;
+      else if (!strcmp(argv[i], "--debug-self-comparison"))
+	opts.do_debug_self_comparison = true;
+#endif
+#ifdef WITH_DEBUG_TYPE_CANONICALIZATION
+      else if (!strcmp(argv[i], "--debug-tc"))
+	opts.do_debug_type_canonicalization = true;
 #endif
       else
 	{
@@ -1143,8 +1158,12 @@ main(int argc, char* argv[])
 	env->analyze_exported_interfaces_only(*opts.exported_interfaces_only);
 
 #ifdef WITH_DEBUG_SELF_COMPARISON
-	    if (opts.do_debug)
+	    if (opts.do_debug_self_comparison)
 	      env->self_comparison_debug_is_on(true);
+#endif
+#ifdef WITH_DEBUG_TYPE_CANONICALIZATION
+	    if (opts.do_debug_type_canonicalization)
+	      env->debug_type_canonicalization_is_on(true);
 #endif
       translation_unit_sptr t1, t2;
       abigail::elf_reader::status c1_status =
-- 
2.38.0.rc2


-- 
		Dodji


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

only message in thread, other threads:[~2022-10-10 11:55 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-10 11:55 [PATCH, applied] abidiff: add a --debug-tc option 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).