public inbox for libabigail@sourceware.org
 help / color / mirror / Atom feed
* [PATCH, applied] abi{dw,diff}: Better error messages when alternate debuginfo not found
@ 2023-04-11 10:56 Dodji Seketeli
  0 siblings, 0 replies; only message in thread
From: Dodji Seketeli @ 2023-04-11 10:56 UTC (permalink / raw)
  To: libabigail

Hello,

When the alternate debug info referenced by the main debug info file
is missing, both abidw and abidiff fail to explain what is happening
to the user.  The patch adds explicit error messages to those two
programs in that case.

	* tools/abidiff.cc (handle_error): Handle cases where the
	fe_iface::STATUS[_ALT]_DEBUG_INFO_NOT_FOUND bits are set. Refer to
	the alternate debug info file in the error message.
	* tools/abidw.cc (load_corpus_and_write_abixml): Do not clear the
	reader before emitting the error message, rather clear it after.
	Also, refer to the alternate debug info file in the error message.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
---
 tools/abidiff.cc | 10 ++++++----
 tools/abidw.cc   | 22 +++++++++++++++++-----
 2 files changed, 23 insertions(+), 9 deletions(-)

diff --git a/tools/abidiff.cc b/tools/abidiff.cc
index d2fa5b63..427c1f19 100644
--- a/tools/abidiff.cc
+++ b/tools/abidiff.cc
@@ -1047,7 +1047,9 @@ handle_error(abigail::fe_iface::status status_code,
 	     const string& prog_name,
 	     const options& opts)
 {
-  if (!(status_code & abigail::fe_iface::STATUS_OK))
+  if (!(status_code & abigail::fe_iface::STATUS_OK)
+      || status_code & abigail::fe_iface::STATUS_DEBUG_INFO_NOT_FOUND
+      || status_code & abigail::fe_iface::STATUS_ALT_DEBUG_INFO_NOT_FOUND)
     {
       emit_prefix(prog_name, cerr)
 	<< "failed to read input file " << opts.file1 << "\n";
@@ -1110,10 +1112,10 @@ handle_error(abigail::fe_iface::status status_code,
 	  emit_prefix(prog_name, cerr)
 	    << "could not find the alternate debug info file";
 
-	   if (rdr->alternate_dwarf_debug_info())
+	  if (!rdr->alternate_dwarf_debug_info_path().empty())
 	    cerr << " at: "
-		 << rdr->alternate_dwarf_debug_info_path()
-		 << "\n";
+		 << rdr->alternate_dwarf_debug_info_path();
+	  cerr << "\n";
 	}
 
       if (status_code & abigail::fe_iface::STATUS_NO_SYMBOLS_FOUND)
diff --git a/tools/abidw.cc b/tools/abidw.cc
index ddb3846e..eead7889 100644
--- a/tools/abidw.cc
+++ b/tools/abidw.cc
@@ -662,11 +662,6 @@ load_corpus_and_write_abixml(char* argv[],
     emit_prefix(argv[0], cerr)
       << "read corpus from elf file in: " << t << "\n";
 
-  // Clear some resources to gain back some space.
-  t.start();
-  reader.reset();
-  t.stop();
-
   if (opts.do_log)
     emit_prefix(argv[0], cerr)
       << "reset reader ELF in: " << t << "\n";
@@ -709,10 +704,27 @@ load_corpus_and_write_abixml(char* argv[],
 	emit_prefix(argv[0], cerr)
 	  << "Could not read ELF symbol information from "
 	  << opts.in_file_path << "\n";
+      else if (s & fe_iface::STATUS_ALT_DEBUG_INFO_NOT_FOUND)
+	{
+	  emit_prefix(argv[0], cerr)
+	    << "Could not read alternate debug info file";
+	  if (!reader->alternate_dwarf_debug_info_path().empty())
+	    cerr << " '" << reader->alternate_dwarf_debug_info_path() << "'";
+	  cerr << " for '"
+	    << opts.in_file_path << "'.\n";
+	  emit_prefix(argv[0], cerr)
+	    << "You might have forgotten to install some "
+	    "additional needed debug info\n";
+	}
 
       return 1;
     }
 
+  // Clear some resources to gain back some space.
+  t.start();
+  reader.reset();
+  t.stop();
+
   // Now create a write context and write out an ABI XML description
   // of the read corpus.
   t.start();
-- 
2.39.2


-- 
		Dodji


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

only message in thread, other threads:[~2023-04-11 10:56 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-11 10:56 [PATCH, applied] abi{dw,diff}: Better error messages when alternate debuginfo not found 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).