abicompat: Port this to the multi-front-end architecture

Message ID 87msrh7tq0.fsf@redhat.com
State New
Headers
Series abicompat: Port this to the multi-front-end architecture |

Commit Message

Dodji Seketeli March 1, 2024, 5:22 p.m. UTC
  Hello,

I forgot to port abicompat to the multi-front-end architecture that
was put in place a while ago.  Namely, all the other tools now use
abigail::tools_utils::create_best_elf_based_reader to create the best
elf-based reader depending on if they are given DWARF, BTF or CTF
debug information.

This patch make abicompat use
abigail::tools_utils::create_best_elf_based_reader too.

	* tools/abicompat.cc (read_corpus): Use
	abigail::tools_utils::create_best_elf_based_reader to create the
	right reader depending on the debug information at hand.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Applying to the master branch
---
 tools/abicompat.cc | 24 ++++++++++++++----------
 1 file changed, 14 insertions(+), 10 deletions(-)
  

Patch

diff --git a/tools/abicompat.cc b/tools/abicompat.cc
index 9e264b0e..c1e658b2 100644
--- a/tools/abicompat.cc
+++ b/tools/abicompat.cc
@@ -53,6 +53,8 @@  using std::ofstream;
 using std::vector;
 using std::shared_ptr;
 
+using abigail::tools_utils::create_best_elf_based_reader;
+
 using namespace abigail;
 
 using abigail::tools_utils::emit_prefix;
@@ -672,19 +674,21 @@  read_corpus(options			opts,
       break;
     case abigail::tools_utils::FILE_TYPE_ELF:
       {
+	corpus::origin requested_fe_kind = corpus::DWARF_ORIGIN;
 #ifdef WITH_CTF
 	if (opts.use_ctf)
-	  {
-	    rdr = ctf::create_reader(path, env);
-	    ABG_ASSERT(rdr);
-
-	    retval = ctf::read_corpus(rdr.get(), status);
-	  }
-	else
+	  requested_fe_kind = corpus::CTF_ORIGIN;
 #endif
-	  retval = dwarf::read_corpus_from_elf(path, di_roots, env,
-					       /*load_all_types=*/opts.weak_mode,
-					       status);
+#ifdef WITH_BTF
+	if (opts.use_btf)
+	  requested_fe_kind = corpus::BTF_ORIGIN;
+#endif
+
+	rdr = create_best_elf_based_reader (path, di_roots, env, requested_fe_kind,
+					    /*load_all_types=*/opts.weak_mode,
+					    status);
+	ABG_ASSERT(rdr);
+	retval = rdr->read_corpus(status);
       }
       break;
     case abigail::tools_utils::FILE_TYPE_XML_CORPUS: