Separate public types of first binary from those of the second
authorDodji Seketeli <dodji@redhat.com>
Tue, 15 Jan 2019 17:33:12 +0000 (18:33 +0100)
committerDodji Seketeli <dodji@redhat.com>
Wed, 16 Jan 2019 11:27:45 +0000 (12:27 +0100)
In abidiff when the user uses --headers-dir{1,2}, she implicitly
indicates the public types of the first and the second binary.  That
means that any type that is defined in a file that is not located
under the directory tree designated by --headers-dir{1,2} is
considered private and any change involving those private types will
be suppressed.

In practice, what happens is that libabigail constructs a suppression
specification which suppress all types that are defined in files that
are not under the directories located by --headers-dir{1,2}.

abidiff has a problem, though.  It uses the same private type
suppressions (derived from --headers-dir1 and --headers-dir2) when
looking at the first binary *and* the second binary.  It should rather
only use the private type suppression specifications derived from
--headers-dir1 when looking at the first binary, and use the private
type suppression specifications derived from --headers-dir2 when
looking at the second binary.

This problem leads to some false positives like the one reported at
https://gitlab.gnome.org/GNOME/pango/issues/343#note_397761.

This patch fixes this issue by using the private type suppression
specifications derived from --headers-dir1 only when looking at the
first binary, and using the private type suppression specifications
derived from --headers-dir2 only when looking at the second binary.

* include/abg-dwarf-reader.h (read_context_get_path): Declare new
function.
* include/abg-reader.h (read_context_get_path): Likewise.
* src/abg-dwarf-reader.cc (read_context_get_path): Define new function.
* src/abg-reader.cc (read_context_get_path): Likewise.
* tools/abidiff.cc (set_suppressions): Set the suppression
specification derived from the --headers-dir1 option only for the first
binary, and similarly, from the --headers-dir2 option only for the
second binary.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
include/abg-dwarf-reader.h
include/abg-reader.h
src/abg-dwarf-reader.cc
src/abg-reader.cc
tools/abidiff.cc

index 09d3966..31b733f 100644 (file)
@@ -107,6 +107,9 @@ create_read_context(const std::string&      elf_path,
                    bool                read_all_types = false,
                    bool                linux_kernel_mode = false);
 
+const string&
+read_context_get_path(const read_context&);
+
 void
 reset_read_context(read_context_sptr &ctxt,
                   const std::string&   elf_path,
index 59dc8bc..4ddc8b0 100644 (file)
@@ -64,6 +64,9 @@ create_native_xml_read_context(const string& path, environment *env);
 read_context_sptr
 create_native_xml_read_context(std::istream* in, environment* env);
 
+const string&
+read_context_get_path(const read_context&);
+
 abigail::corpus_sptr
 read_corpus_from_file(const string& path);
 
index 100c8f9..77d4822 100644 (file)
@@ -16096,6 +16096,13 @@ create_read_context(const std::string&         elf_path,
   return result;
 }
 
+/// Getter for the path to the binary this @ref read_context is for.
+///
+/// @return the path to the binary the @ref read_context is for.
+const string&
+read_context_get_path(const read_context& ctxt)
+{return ctxt.elf_path();}
+
 /// Re-initialize a read_context so that it can re-used to read
 /// another binary.
 ///
index 0855531..cd23d63 100644 (file)
@@ -5763,6 +5763,13 @@ create_native_xml_read_context(std::istream* in, environment* env)
   return result;
 }
 
+/// Getter for the path to the binary this @ref read_context is for.
+///
+/// @return the path to the binary the @ref read_context is for.
+const string&
+read_context_get_path(const read_context& ctxt)
+{return ctxt.get_path();}
+
 /// De-serialize an ABI corpus from an input XML document which root
 /// node is 'abi-corpus'.
 ///
index 02902dd..1e29888 100644 (file)
@@ -720,10 +720,12 @@ set_suppressions(ReadContextType& read_ctxt, const options& opts)
        ++i)
     read_suppressions(*i, supprs);
 
-  if (!opts.headers_dir1.empty())
+  if (read_context_get_path(read_ctxt) == opts.file1
+      && !opts.headers_dir1.empty())
     {
       // Generate suppression specification to avoid showing ABI
-      // changes on types that are not defined in public headers.
+      // changes on types that are not defined in public headers for
+      // the first binary.
       //
       // As these suppression specifications are applied during the
       // corpus loading, they are going to be dropped from the
@@ -738,10 +740,12 @@ set_suppressions(ReadContextType& read_ctxt, const options& opts)
        }
     }
 
-  if (!opts.headers_dir2.empty())
+  if (read_context_get_path(read_ctxt) == opts.file2
+      && !opts.headers_dir2.empty())
     {
       // Generate suppression specification to avoid showing ABI
-      // changes on types that are not defined in public headers.
+      // changes on types that are not defined in public headers for
+      // the second binary.
       //
       // As these suppression specifications are applied during the
       // corpus loading, they are going to be dropped from the