public inbox for libabigail@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] kmidiff: Add --ctf option to compare kernel trees
@ 2022-07-04 15:44 Guillermo E. Martinez
  2022-07-08  8:29 ` Dodji Seketeli
  0 siblings, 1 reply; 2+ messages in thread
From: Guillermo E. Martinez @ 2022-07-04 15:44 UTC (permalink / raw)
  To: libabigail

Hello,

This patch add a new option to kmidiff tool to compare Kernel trees
with CTF debug information. Please let me know your thoughts.

Regards,
guillermo
---

	* tools/kmidiff.cc (option::use_ctf option): Declare new option.
	(display_usage): Create new option entry for `--ctf'.
	(parse_command_line): Handle `--ctf' option.
	(main): Set `corpus::origin' to {CTF,DWARF}_ORIGIN depending of
	command line arguments.
	* tools/kmidiff.cc: Add documentation for new option.

Signed-off-by: Guillermo E. Martinez <guillermo.e.martinez@oracle.com>
---
 doc/manuals/kmidiff.rst |  4 ++++
 tools/kmidiff.cc        | 25 +++++++++++++++++++++++--
 2 files changed, 27 insertions(+), 2 deletions(-)

diff --git a/doc/manuals/kmidiff.rst b/doc/manuals/kmidiff.rst
index 011dbafd..ce8168ae 100644
--- a/doc/manuals/kmidiff.rst
+++ b/doc/manuals/kmidiff.rst
@@ -165,6 +165,10 @@ Options
     the :ref:`default suppression specification files
     <abidiff_default_supprs_label>` are loaded .
 
+  * ``--ctf``
+
+    Extract ABI information from CTF debug information, if present in
+    the Kernel and Modules.
 
   * ``--impacted-interfaces | -i``
 
diff --git a/tools/kmidiff.cc b/tools/kmidiff.cc
index d89026f9..8fd3fed9 100644
--- a/tools/kmidiff.cc
+++ b/tools/kmidiff.cc
@@ -9,6 +9,7 @@
 ///
 /// The source code of the Kernel Module Interface Diff tool.
 
+#include "config.h"
 #include <sys/types.h>
 #include <dirent.h>
 #include <cstring>
@@ -59,6 +60,9 @@ struct options
   bool			show_hexadecimal_values;
   bool			show_offsets_sizes_in_bits;
   bool			show_impacted_interfaces;
+#ifdef WITH_CTF
+  bool			use_ctf;
+#endif
   string		wrong_option;
   string		kernel_dist_root1;
   string		kernel_dist_root2;
@@ -80,6 +84,10 @@ struct options
       show_hexadecimal_values(true),
       show_offsets_sizes_in_bits(false),
       show_impacted_interfaces(false)
+#ifdef WITH_CTF
+      ,
+      use_ctf(false)
+#endif
   {}
 }; // end struct options.
 
@@ -106,6 +114,9 @@ display_usage(const string& prog_name, ostream& out)
     << " --suppressions|--suppr <path>  specify a suppression file\n"
     << " --kmi-whitelist|-w <path>  path to a kernel module interface "
     "whitelist\n"
+#ifdef WITH_CTF
+    << " --ctf use CTF instead of DWARF in ELF files\n"
+#endif
     << " --impacted-interfaces|-i  show interfaces impacted by ABI changes\n"
     << " --full-impact|-f  show the full impact of changes on top-most "
 	 "interfaces\n"
@@ -241,6 +252,10 @@ parse_command_line(int argc, char* argv[], options& opts)
 	  opts.suppression_paths.push_back(argv[j]);
 	  ++i;
 	}
+#ifdef WITH_CTF
+      else if (!strcmp(argv[i], "--ctf"))
+	opts.use_ctf = true;
+#endif
       else if (!strcmp(argv[i], "--impacted-interfaces")
 	       || !strcmp(argv[i], "-i"))
 	opts.show_impacted_interfaces = true;
@@ -395,6 +410,12 @@ main(int argc, char* argv[])
 
   corpus_group_sptr group1, group2;
   string debug_info_root_dir;
+  corpus::origin origin =
+#ifdef WITH_CTF
+   opts.use_ctf ? corpus::CTF_ORIGIN :
+#endif
+   corpus::DWARF_ORIGIN;
+
   if (!opts.kernel_dist_root1.empty())
     {
       file_type ftype = guess_file_type(opts.kernel_dist_root1);
@@ -412,7 +433,7 @@ main(int argc, char* argv[])
 						      opts.kabi_whitelist_paths,
 						      opts.read_time_supprs,
 						      opts.verbose,
-						      env);
+						      env, origin);
 	  print_kernel_dist_binary_paths_under(opts.kernel_dist_root1, opts);
 	}
       else if (ftype == FILE_TYPE_XML_CORPUS_GROUP)
@@ -438,7 +459,7 @@ main(int argc, char* argv[])
 						      opts.kabi_whitelist_paths,
 						      opts.read_time_supprs,
 						      opts.verbose,
-						      env);
+						      env, origin);
 	  print_kernel_dist_binary_paths_under(opts.kernel_dist_root2, opts);
 	}
       else if (ftype == FILE_TYPE_XML_CORPUS_GROUP)
-- 
2.35.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] kmidiff: Add --ctf option to compare kernel trees
  2022-07-04 15:44 [PATCH] kmidiff: Add --ctf option to compare kernel trees Guillermo E. Martinez
@ 2022-07-08  8:29 ` Dodji Seketeli
  0 siblings, 0 replies; 2+ messages in thread
From: Dodji Seketeli @ 2022-07-08  8:29 UTC (permalink / raw)
  To: Guillermo E. Martinez via Libabigail

Hello Guillermo,

"Guillermo E. Martinez via Libabigail" <libabigail@sourceware.org> a
écrit:

> Hello,
>
> This patch add a new option to kmidiff tool to compare Kernel trees
> with CTF debug information. Please let me know your thoughts.


Thanks a lot for this great patch!

I have just added the ChangeLog part to its commit log and applied to
the master branch, thanks again!

Please find below the patch that was applied.

Cheers,

From 68f369f2182fe1f1fce5434111ced1742b27b31c Mon Sep 17 00:00:00 2001
From: "Guillermo E. Martinez via Libabigail" <libabigail@sourceware.org>
Date: Mon, 4 Jul 2022 10:44:35 -0500
Subject: [PATCH] kmidiff: Add CTF support to comparing Kernel trees

This patch adds a new --ctf option to kmidiff to make it support CTF
type information when analysing Linux Kernel trees.

	* doc/manuals/kmidiff.rst: Add documentation for the new --ctf option.
	* tools/kmidiff.cc (options::use_ctf): Define new data member.
	(display_usage): Add a help string for the --ctf option.
	(main): Adjust call to pass
	build_corpus_group_from_kernel_dist_under with origin being
	corpus::CTF_ORIGIN when the user provides the --ctf option.

Signed-off-by: Guillermo E. Martinez <guillermo.e.martinez@oracle.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
---
 doc/manuals/kmidiff.rst |  4 ++++
 tools/kmidiff.cc        | 25 +++++++++++++++++++++++--
 2 files changed, 27 insertions(+), 2 deletions(-)

diff --git a/doc/manuals/kmidiff.rst b/doc/manuals/kmidiff.rst
index 011dbafd..ce8168ae 100644
--- a/doc/manuals/kmidiff.rst
+++ b/doc/manuals/kmidiff.rst
@@ -165,6 +165,10 @@ Options
     the :ref:`default suppression specification files
     <abidiff_default_supprs_label>` are loaded .
 
+  * ``--ctf``
+
+    Extract ABI information from CTF debug information, if present in
+    the Kernel and Modules.
 
   * ``--impacted-interfaces | -i``
 
diff --git a/tools/kmidiff.cc b/tools/kmidiff.cc
index d89026f9..8fd3fed9 100644
--- a/tools/kmidiff.cc
+++ b/tools/kmidiff.cc
@@ -9,6 +9,7 @@
 ///
 /// The source code of the Kernel Module Interface Diff tool.
 
+#include "config.h"
 #include <sys/types.h>
 #include <dirent.h>
 #include <cstring>
@@ -59,6 +60,9 @@ struct options
   bool			show_hexadecimal_values;
   bool			show_offsets_sizes_in_bits;
   bool			show_impacted_interfaces;
+#ifdef WITH_CTF
+  bool			use_ctf;
+#endif
   string		wrong_option;
   string		kernel_dist_root1;
   string		kernel_dist_root2;
@@ -80,6 +84,10 @@ struct options
       show_hexadecimal_values(true),
       show_offsets_sizes_in_bits(false),
       show_impacted_interfaces(false)
+#ifdef WITH_CTF
+      ,
+      use_ctf(false)
+#endif
   {}
 }; // end struct options.
 
@@ -106,6 +114,9 @@ display_usage(const string& prog_name, ostream& out)
     << " --suppressions|--suppr <path>  specify a suppression file\n"
     << " --kmi-whitelist|-w <path>  path to a kernel module interface "
     "whitelist\n"
+#ifdef WITH_CTF
+    << " --ctf use CTF instead of DWARF in ELF files\n"
+#endif
     << " --impacted-interfaces|-i  show interfaces impacted by ABI changes\n"
     << " --full-impact|-f  show the full impact of changes on top-most "
 	 "interfaces\n"
@@ -241,6 +252,10 @@ parse_command_line(int argc, char* argv[], options& opts)
 	  opts.suppression_paths.push_back(argv[j]);
 	  ++i;
 	}
+#ifdef WITH_CTF
+      else if (!strcmp(argv[i], "--ctf"))
+	opts.use_ctf = true;
+#endif
       else if (!strcmp(argv[i], "--impacted-interfaces")
 	       || !strcmp(argv[i], "-i"))
 	opts.show_impacted_interfaces = true;
@@ -395,6 +410,12 @@ main(int argc, char* argv[])
 
   corpus_group_sptr group1, group2;
   string debug_info_root_dir;
+  corpus::origin origin =
+#ifdef WITH_CTF
+   opts.use_ctf ? corpus::CTF_ORIGIN :
+#endif
+   corpus::DWARF_ORIGIN;
+
   if (!opts.kernel_dist_root1.empty())
     {
       file_type ftype = guess_file_type(opts.kernel_dist_root1);
@@ -412,7 +433,7 @@ main(int argc, char* argv[])
 						      opts.kabi_whitelist_paths,
 						      opts.read_time_supprs,
 						      opts.verbose,
-						      env);
+						      env, origin);
 	  print_kernel_dist_binary_paths_under(opts.kernel_dist_root1, opts);
 	}
       else if (ftype == FILE_TYPE_XML_CORPUS_GROUP)
@@ -438,7 +459,7 @@ main(int argc, char* argv[])
 						      opts.kabi_whitelist_paths,
 						      opts.read_time_supprs,
 						      opts.verbose,
-						      env);
+						      env, origin);
 	  print_kernel_dist_binary_paths_under(opts.kernel_dist_root2, opts);
 	}
       else if (ftype == FILE_TYPE_XML_CORPUS_GROUP)
-- 
2.36.1



-- 
		Dodji

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-07-08  8:29 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-04 15:44 [PATCH] kmidiff: Add --ctf option to compare kernel trees Guillermo E. Martinez
2022-07-08  8:29 ` 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).