Add a --fail-no-debug-info to abidiff
authorDodji Seketeli <dodji@redhat.com>
Thu, 8 Nov 2018 08:04:53 +0000 (09:04 +0100)
committerDodji Seketeli <dodji@redhat.com>
Thu, 8 Nov 2018 08:04:53 +0000 (09:04 +0100)
Add an option to make abidiff to fail if doesn't find debug info.
Without this option, abidiff keeps going and works with only ELF
information, as it can't get the debug info.

* doc/manuals/abidiff.rst: Document the new --fail-no-debug-info
option.
* tools/abidiff.cc (options::fail_no_debug_info): Define new data
member.
(display_usage): Provide a help string for the new
--fail-no-debug-info option.
(parse_command_line): Parse the new option.
(main): If --fail-no-debug-info and no debug info was found, or
not alternate debuginfo file was found, bail out.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
doc/manuals/abidiff.rst
tools/abidiff.cc

index b4981613f9347a3671dfebc19074e7b584dbe8fe..0c334b445eb469dcd756b4e755293c3751358c57 100644 (file)
@@ -359,6 +359,13 @@ Options
 
     Do not emit the path attribute for the ABI corpus.
 
+  * ``--fail-no-debug-info``
+
+    If no debug info was found, then this option makes the program to
+    fail.  Otherwise, without this option, the program will attempt to
+    compare properties of the binaries that are not related to debug
+    info, like pure ELF properties.
+
   * ``--leaf-changes-only|-l`` only show leaf changes, so don't show
     impact analysis report.
 
index 7a0859f3662e7dd38355b50be0885a1e7729e9b6..a7cdeb0846f9c65caf86569c337e19faa2da1790 100644 (file)
@@ -86,6 +86,7 @@ struct options
   bool                 no_arch;
   bool                 no_corpus;
   bool                 leaf_changes_only;
+  bool                 fail_no_debug_info;
   bool                 show_hexadecimal_values;
   bool                 show_offsets_sizes_in_bits;
   bool                 show_relative_offset_changes;
@@ -125,6 +126,7 @@ struct options
       no_arch(),
       no_corpus(),
       leaf_changes_only(),
+      fail_no_debug_info(),
       show_hexadecimal_values(),
       show_offsets_sizes_in_bits(true),
       show_relative_offset_changes(true),
@@ -192,6 +194,7 @@ display_usage(const string& prog_name, ostream& out)
        "default suppression specification\n"
     << " --no-architecture  do not take architecture in account\n"
     << " --no-corpus-path  do not take the path to the corpora into account\n"
+    << " --fail-no-debug-info  bail out if no debug info was found\n"
     << " --leaf-changes-only|-l  only show leaf changes, "
     "so no change impact analysis\n"
     << " --deleted-fns  display deleted public functions\n"
@@ -355,6 +358,8 @@ parse_command_line(int argc, char* argv[], options& opts)
        opts.no_arch = true;
       else if (!strcmp(argv[i], "--no-corpus-path"))
        opts.no_corpus = true;
+      else if (!strcmp(argv[i], "--fail-no-debug-info"))
+       opts.fail_no_debug_info = true;
       else if (!strcmp(argv[i], "--leaf-changes-only")
               ||!strcmp(argv[i], "-l"))
        opts.leaf_changes_only = true;
@@ -1063,7 +1068,10 @@ main(int argc, char* argv[])
            set_suppressions(*ctxt, opts);
            abigail::dwarf_reader::set_do_log(*ctxt, opts.do_log);
            c1 = abigail::dwarf_reader::read_corpus_from_elf(*ctxt, c1_status);
-           if (!c1)
+           if (!c1
+               || (opts.fail_no_debug_info
+                   && (c1_status & STATUS_ALT_DEBUG_INFO_NOT_FOUND)
+                   && (c1_status & STATUS_DEBUG_INFO_NOT_FOUND)))
              return handle_error(c1_status, ctxt.get(),
                                  argv[0], opts);
          }
@@ -1133,7 +1141,10 @@ main(int argc, char* argv[])
            set_suppressions(*ctxt, opts);
 
            c2 = abigail::dwarf_reader::read_corpus_from_elf(*ctxt, c2_status);
-           if (!c2)
+           if (!c2
+               || (opts.fail_no_debug_info
+                   && (c2_status & STATUS_ALT_DEBUG_INFO_NOT_FOUND)
+                   && (c2_status & STATUS_DEBUG_INFO_NOT_FOUND)))
              return handle_error(c2_status, ctxt.get(), argv[0], opts);
 
          }