public inbox for libabigail@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] ctf: ctf_reader::read_corpus now sets a status
@ 2021-11-16 17:43 Jose E. Marchesi
  2021-11-18  8:49 ` Dodji Seketeli
  0 siblings, 1 reply; 2+ messages in thread
From: Jose E. Marchesi @ 2021-11-16 17:43 UTC (permalink / raw)
  To: libabigail

This patch makes ctf_reader::read_corpus to get a reference to a
`status' variable as an argument, and set it to reflect the result of
the read operation.  The utilities calling to ctf_reader::read_corpus
are updated accordingly.

Salud!

Signed-off-by: Jose E. Marchesi <jose.marchesi@oracle.com>

	* include/abg-ctf-reader.h: Include abg-elf-reader-common.h.
	read_corpus now gets an extra argument `status'.
	* src/abg-ctf-reader.cc (read_corpus): Likewise, and set `status'
	accordingly when the debug info is not found.
	* tools/abilint.cc (main): Pass a status argument to
	ctf_reader::read_corpus.
	* tools/abidiff.cc (main): Likewise.
---
 include/abg-ctf-reader.h |  4 +++-
 src/abg-ctf-reader.cc    | 19 +++++++++++++++----
 tools/abidiff.cc         |  4 ++--
 tools/abilint.cc         |  2 +-
 4 files changed, 21 insertions(+), 8 deletions(-)

diff --git a/include/abg-ctf-reader.h b/include/abg-ctf-reader.h
index 07eccec6..c0d8bb2b 100644
--- a/include/abg-ctf-reader.h
+++ b/include/abg-ctf-reader.h
@@ -17,6 +17,7 @@
 #include <ostream>
 #include "abg-corpus.h"
 #include "abg-suppression.h"
+#include "abg-elf-reader-common.h"
 
 namespace abigail
 {
@@ -26,7 +27,8 @@ namespace ctf_reader
 class read_context;
 read_context *create_read_context (std::string elf_path,
                                    ir::environment *env);
-corpus_sptr read_corpus (read_context *ctxt);
+corpus_sptr read_corpus (read_context *ctxt,
+                         elf_reader::status& status);
 
 } // end namespace ctf_reader
 } // end namespace abigail
diff --git a/src/abg-ctf-reader.cc b/src/abg-ctf-reader.cc
index 27eddc2e..9cfa6cb7 100644
--- a/src/abg-ctf-reader.cc
+++ b/src/abg-ctf-reader.cc
@@ -1073,19 +1073,28 @@ create_read_context(std::string elf_path, ir::environment *env)
 /// @return a shared pointer to the read corpus.
 
 corpus_sptr
-read_corpus(read_context *ctxt)
+read_corpus(read_context *ctxt, elf_reader::status &status)
 {
   corpus_sptr corp
     = std::make_shared<corpus>(ctxt->ir_env, ctxt->filename);
 
+  /* Be optimist.  */
+  status = elf_reader::STATUS_OK;
+
   /* Open the ELF file.  */
   if (!open_elf_handler(ctxt))
-    return corp;
+    {
+      status = elf_reader::STATUS_DEBUG_INFO_NOT_FOUND;
+      return corp;
+    }
 
   /* Set some properties of the corpus first.  */
   corp->set_origin(corpus::CTF_ORIGIN);
   if (!slurp_elf_info(ctxt, corp))
-    return corp;
+    {
+      status = elf_reader::STATUS_NO_SYMBOLS_FOUND;
+      return corp;
+    }
 
   /* Build the ctfa from the contents of the relevant ELF sections,
      and process the CTF archive in the read context, if any.
@@ -1094,7 +1103,9 @@ read_corpus(read_context *ctxt)
   int errp;
   ctxt->ctfa = ctf_arc_bufopen(&ctxt->ctf_sect, &ctxt->symtab_sect,
                                &ctxt->strtab_sect, &errp);
-  if (ctxt->ctfa != NULL)
+  if (ctxt->ctfa == NULL)
+    status = elf_reader::STATUS_DEBUG_INFO_NOT_FOUND;
+  else
     process_ctf_archive(ctxt, corp);
 
   /* Cleanup and return.  */
diff --git a/tools/abidiff.cc b/tools/abidiff.cc
index 157d192f..f145f4f1 100644
--- a/tools/abidiff.cc
+++ b/tools/abidiff.cc
@@ -1174,7 +1174,7 @@ main(int argc, char* argv[])
                                                               env.get());
 
                 assert (ctxt);
-                c1 = abigail::ctf_reader::read_corpus (ctxt);
+                c1 = abigail::ctf_reader::read_corpus (ctxt, c1_status);
               }
             else
 #endif
@@ -1257,7 +1257,7 @@ main(int argc, char* argv[])
                                                               env.get());
 
                 assert (ctxt);
-                c2 = abigail::ctf_reader::read_corpus (ctxt);
+                c2 = abigail::ctf_reader::read_corpus (ctxt, c2_status);
               }
             else
 #endif
diff --git a/tools/abilint.cc b/tools/abilint.cc
index d8c44f82..49643b66 100644
--- a/tools/abilint.cc
+++ b/tools/abilint.cc
@@ -375,7 +375,7 @@ main(int argc, char* argv[])
                                                               env.get());
 
                 assert (ctxt);
-                corp = abigail::ctf_reader::read_corpus (ctxt);
+                corp = abigail::ctf_reader::read_corpus (ctxt, s);
               }
             else
 #endif
-- 
2.11.0


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

* Re: [PATCH] ctf: ctf_reader::read_corpus now sets a status
  2021-11-16 17:43 [PATCH] ctf: ctf_reader::read_corpus now sets a status Jose E. Marchesi
@ 2021-11-18  8:49 ` Dodji Seketeli
  0 siblings, 0 replies; 2+ messages in thread
From: Dodji Seketeli @ 2021-11-18  8:49 UTC (permalink / raw)
  To: Jose E. Marchesi via Libabigail

Hello,

[...]

"Jose E. Marchesi via Libabigail" <libabigail@sourceware.org> a écrit:


> diff --git a/src/abg-ctf-reader.cc b/src/abg-ctf-reader.cc
> index 27eddc2e..9cfa6cb7 100644
> --- a/src/abg-ctf-reader.cc
> +++ b/src/abg-ctf-reader.cc
> @@ -1073,19 +1073,28 @@ create_read_context(std::string elf_path, ir::environment *env)
>  /// @return a shared pointer to the read corpus.
>  
>  corpus_sptr
> -read_corpus(read_context *ctxt)
> +read_corpus(read_context *ctxt, elf_reader::status &status)
>  {

I have just added a comment to this function.

[...]

>
> 	* include/abg-ctf-reader.h: Include abg-elf-reader-common.h.
> 	read_corpus now gets an extra argument `status'.
> 	* src/abg-ctf-reader.cc (read_corpus): Likewise, and set `status'
> 	accordingly when the debug info is not found.
> 	* tools/abilint.cc (main): Pass a status argument to
> 	ctf_reader::read_corpus.
> 	* tools/abidiff.cc (main): Likewise.
>
> Signed-off-by: Jose E. Marchesi <jose.marchesi@oracle.com>

Applied to master.

Thanks!

Cheers,

-- 
		Dodji

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

end of thread, other threads:[~2021-11-18  8:49 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-16 17:43 [PATCH] ctf: ctf_reader::read_corpus now sets a status Jose E. Marchesi
2021-11-18  8:49 ` 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).