Commit Graph

1596 Commits

Author SHA1 Message Date
Dodji Seketeli
5989cbe26c Fix typo in help string of abipkgdiff
* tools/abipkgdiff.cc (display_usage): Remove erroneous end line.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-02-15 16:12:22 +01:00
Dodji Seketeli
cac0cbb6d5 fedabipkgdiff refuses to compare packages with the same release number
I tried to run:

    fedabipkgdiff vte291-0.39.1-1.fc22.x86_64 vte291-0.39.90-1.fc22.x86_64

And it wouldn't work :-(

The program considers the two packages as not being "peers".  This has
to do with the RPM.is_peer method which considers the two package as
not being "peers", just because they have the same release number
(1.fc22).

They should be considered peers, though, because they have the same
name but different {version, release} pairs.

This patch fixes the RPM.is_peer method and adds the aforementioned
packages to the regression test suite for good measure.

	* tools/fedabipkgdiff (RPM.is_peer): Update comment.  Fix logic.
	* tests/data/test-fedabipkgdiff/packages/vte291/0.39.1/1.fc22/x86_64/vte291-0.39.1-1.fc22.x86_64.rpm:
	New test input file.
	* tests/data/test-fedabipkgdiff/packages/vte291/0.39.1/1.fc22/x86_64/vte291-debuginfo-0.39.1-1.fc22.x86_64.rpm: Likewise.
	* tests/data/test-fedabipkgdiff/packages/vte291/0.39.1/1.fc22/x86_64/vte291-devel-0.39.1-1.fc22.x86_64.rpm: Likewise.
	* tests/data/test-fedabipkgdiff/packages/vte291/0.39.90/1.fc22/x86_64/vte291-0.39.90-1.fc22.x86_64.rpm: Likewise.
	* tests/data/test-fedabipkgdiff/packages/vte291/0.39.90/1.fc22/x86_64/vte291-debuginfo-0.39.90-1.fc22.x86_64.rpm: Likewise.
	* tests/data/test-fedabipkgdiff/packages/vte291/0.39.90/1.fc22/x86_64/vte291-devel-0.39.90-1.fc22.x86_64.rpm:
	Likewise.
	* tests/data/test-fedabipkgdiff/vte291-0.39.1-1.fc22.x86_64--vte291-0.39.90-1.fc22.x86_64-report-0.txt: Likewise.
	* tests/data/Makefile.am: Add the new test input data to source
	distribution.
	* tests/mockfedabipkgdiff.in: Update the package and build
	information to add the new vte291-0.39.1-1.fc22.x86_64.rpm and
	vte291-0.39.90-1.fc22.x86_64.rpm packages (as well as their devel
	and debuginfo packages) into the "mock" Koji build database.
	* tests/runtestfedabipkgdiff.py.in:  Make this test harness run
	over the two aforementioned packages.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-02-15 16:06:32 +01:00
Dodji Seketeli
08b1ef7ae1 Add missing tests input files to distribution files
The runtestfedabipkgdiff.py test was missing some input files from the
source distribution.

This patch adds them back.

Also, the test file name
test-fedabipkgdiff/test6-missing-devel-debuginfo-nss-util-3.12.6-1.fc14.x86_64--nss-util-3.24.0-2.0.fc25.x86_64-report-0.txt
was too long for tar to handle so that file was left out of the final
source distribution tarball.  This patch renames that file to a
smaller name.

make distcheck should pass again now.

	* tests/data/Makefile.am: Add three missing test input files to
	the source distribution tarball.  Renamed
	test-fedabipkgdiff/test6-missing-devel-debuginfo-nss-util-3.12.6-1.fc14.x86_64--nss-util-3.24.0-2.0.fc25.x86_64-report-0.txt
	into
	test-fedabipkgdiff/test6-nss-util-3.12.6-1.fc14.x86_64--nss-util-3.24.0-2.0.fc25.x86_64-report-0.txt.
	* tests/runtestfedabipkgdiff.py.in (FEDABIPKGDIFF_TEST_SPECS):
	Renamed
	test6-missing-devel-debuginfo-nss-util-3.12.6-1.fc14.x86_64--nss-util-3.24.0-2.0.fc25.x86_64-report-0.txt
	into
	test6-nss-util-3.12.6-1.fc14.x86_64--nss-util-3.24.0-2.0.fc25.x86_64-report-0.txt.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-02-15 15:51:37 +01:00
Dodji Seketeli
8202ad17aa Add missing new line to an error message of runtestfedabipkgdiff.py
This patch is a quick one liner to add a missing new line to an error
message from the runtestfedabipkgdiff.py test harness.

	* tests/runtestfedabipkgdiff.py.in (run_fedabipkgdiff_tests): Add
	missing new line to an error message.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-02-15 15:49:39 +01:00
Dodji Seketeli
838aa6810b Fix silent failure of tests/runtestfedabipkgdiff.py
It turns out the test <builddir>/tests/runtestfedabipkgdiff.py is
failing, but "make check TESTS=runtestfedabipkgdiff.py" is not.

In other words, runtestfedabipkgdiff.py is failing silently; we don't
see it when doing "make check".

The reason why runtestfedabipkgdiff.py is failing is that
mockfedabipkgdiff is trying to patch the global variable
DEFAULT_KOJI_TOPDIR from the fedabipkgdiff file; and that global
variable is not present in that file.  The right global variable that
we want is DEFAULT_KOJI_TOPURL.

This patch fixes that issue.

The reason why the failing above is silent is because the the main
function wasn't returning 0 upon success and 1 otherwise.

This patch fixes that issue as well.

So with this patch, <builddir>/tests/runtestfedabipkgdiff does not
fail anymore and when it does, the "make check TESTS=runtestfedabipkgdiff.py"
fails as well.

	* tests/mockfedabipkgdiff.in (run_fedabipkgdiff): Patch
	fedabipkgdiff.DEFAULT_KOJI_TOPURL instead of
	fedabipkgdiff.DEFAULT_KOJI_TOPDIR.
	* tests/runtestfedabipkgdiff.py.in (main): Properly return 0 upon
	success, 1 otherwise.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-02-15 15:48:53 +01:00
Dodji Seketeli
2d828b3b32 Misc style fixes
* include/abg-ir.h (class_or_union): Fix indentation.
	* src/abg-dwarf-reader.cc (get_die_pretty_representation): Add new
	line.
	* src/abg-ir.cc (struct class_decl::priv): Fix indentation.
	(virtual_member_function_less_than::operator()): Fix a typo in a
	comment.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-02-14 12:49:48 +01:00
Dodji Seketeli
059c86ec0b Bug 20476 - Compare virtual member functions when comparing classes
There are cases where a virtual member function doesn't have an
implementation that is defined and publicly exported.  This is the
cases for virtual pure classes.

Even in those cases, users might want to detect vtable changes on
virtual member pure classes (interfaces).

Now that, for C++ binaries, all the partial representations of a class
are merged into one class (in a given binary), we can envision to
compare virtual member functions of classes as part of comparing two
classes.

This is what this patch does.  While comparing two classes, the
virtual member functions are compared too.

Note that as there can be several virtual member functions that have
the same vtable offset (think about a virtual destructor that might
have several generated functions that 'conceptually' share the same
vtable offset), comparing the virtual functions can be a little bit
non-trivial.

The approach taken is to check that in the first set of virtual
functions, each virtual function actually matches at least one virtual
function in the second set.  And the match is a "loose" one.  That is,
it doesn't take into account the symbol name or the mangled name.

The patch also fixes the "less than" operator used to sort virtual
member functions.

There is also a buglet in the way we compute the highest vtable offset
number today.  This patch provides a new function named
class_decl::get_biggest_vtable_offset that is used in the change reports.

The patch also fixes a related bug in where we were forgetting to
report about added and removed virtual member functions without an
associated elf symbol.  This patch fixes that.

	* include/abg-ir.h (class_decl::get_biggest_vtable_offset):
	Declare new member function.
	* src/abg-ir.cc (virtual_member_function_less_than::operator()):
	Either compare the symbol id strings if the functions have
	symbols or just compare their pretty representations.
	(class_decl::get_biggest_vtable_offset): Define new member
	function.
	(methods_equal_modulo_elf_symbol)
	(method_matches_at_least_one_in_vector): New static methods.
	(equals): In the overload for classes, compare the virtual member
	functions while comparing classes.
	* src/abg-comparison.cc (represent): In the overload for
	method_decl_sptr, fix the way we compute the highest vtable offset
	number for a give class_decl.
	(class_decl::ensure_lookup_tables_populated): Don't forget added
	and removed virtual member functions in the report for changed
	classes.
	* tests/data/test-diff-dwarf/libtest41-PR20476-hidden-old.so: New
	test binary input file.
	* tests/data/test-diff-dwarf/libtest41-PR20476-hidden-new.so: Likewise.
	* tests/data/test-diff-dwarf/test41-PR20476-hidden-report-0.txt:
	New reference output.
	* tests/data/Makefile.am: Add the new test material above to the
	source distribution.
	* tests/test-diff-dwarf.cc (in_out_spec): Add the new tests
	here.
	* tests/data/test-annotate/test10-pr18818-gcc.so.abi: Adjust.
	* tests/data/test-annotate/test11-pr18828.so.abi: Adjust.
	* tests/data/test-annotate/test18-pr19037-libvtkRenderingLIC-6.1.so.abi: Adjust.
	* tests/data/test-annotate/test20-pr19025-libvtkParallelCore-6.1.so.abi: Adjust.
	* tests/data/test-annotate/test22-pr19097-libstdc++.so.6.0.17.so.abi: Adjust.
	* tests/data/test-read-dwarf/test10-pr18818-gcc.so.abi: Adjust.
	* tests/data/test-read-dwarf/test11-pr18828.so.abi: Adjust.
	* tests/data/test-read-dwarf/test13-pr18894.so.abi: Adjust.
	* tests/data/test-read-dwarf/test14-pr18893.so.abi: Adjust.
	* tests/data/test-read-dwarf/test15-pr18892.so.abi: Adjust.
	* tests/data/test-read-dwarf/test18-pr19037-libvtkRenderingLIC-6.1.so.abi:
	Adjust.
	* tests/data/test-read-dwarf/test20-pr19025-libvtkParallelCore-6.1.so.abi:
	Adjust.
	* tests/data/test-read-dwarf/test21-pr19092.so.abi: Adjust.
	* tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi:
	Adjust.
2017-02-14 12:49:47 +01:00
Dodji Seketeli
1683cf350f Fix indentation in src/abg-writer.cc
* src/abg-writer.cc (annotate): Fix indentation.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-02-14 11:15:01 +01:00
Dodji Seketeli
1e1b3159a0 Adjust reference output of test-annotate
* tests/data/test-annotate/test15-pr18892.so.abi: Adjust this
	reference output.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-02-13 22:14:54 +01:00
Dodji Seketeli
3d0cb0cbba Fix help string for --header-dirs
* tools/abidw.cc (display_usage): Fix patch -> path typo.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-02-13 17:42:26 +01:00
Dodji Seketeli
b81b8f6f8c Make abidw --headers-dir work with the --out-file option
* tools/abidw.cc (parse_command_line): Don't require an empty
	output file when parsing the --headers-dir option.  This was a
	thinko.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-02-13 17:37:58 +01:00
Ondrej Oprala
aba99e5106 Bug 20970 - Add a --annotate option to abidw
This option annotates (read "pretty-prints") the types and elf symbols
in the form of XML comments in the ABIXML output emitted by the abidw
command.

Signed-off-by: Ondrej Oprala <ondrej.oprala@gmail.com>

	* doc/manuals/abidiff.rst: Document the '--no-corpus-path'
	option.
	* doc/manuals/abidw.rst: Document the '--no-corpus-path'
	and '--annotate' options.
	* include/abg-libxml-utils.h ({un,}escape_xml_comment): Add
	new function declarations.
	* include/abg-writer.h: Add new annotate functions
	(write_{translation_unit,corpus_to_{archive,native_xml_file}}):
	Add an optional "annotate" parameter defaulting to "false".
	* src/abg-libxml-utils.cc ({un,}escape_xml_comment): Add
	new function definitions.
	* src/abg-writer.cc (annotate): Define new templatized function
	and specialize it for necessary cases.
	* tests/Makefile.am: Add runtestannotate as a new test.
	* tests/data/Makefile.am: Add paths to below reference test
	outputs.
	* tests/data/test-annotate/libtest23.so.abi: New reference test
	output.
	* tests/data/test-annotate/libtest24-drop-fns-2.so.abi: Likewise.
	* tests/data/test-annotate/libtest24-drop-fns.so.abi: Likewise.
	* tests/data/test-annotate/test0.abi: Likewise.
	* tests/data/test-annotate/test1.abi: Likewise.
	* tests/data/test-annotate/test10-pr18818-gcc.so.abi: Likewise.
	* tests/data/test-annotate/test11-pr18828.so.abi: Likewise.
	* tests/data/test-annotate/test12-pr18844.so.abi: Likewise.
	* tests/data/test-annotate/test13-pr18894.so.abi: Likewise.
	* tests/data/test-annotate/test14-pr18893.so.abi: Likewise.
	* tests/data/test-annotate/test15-pr18892.so.abi: Likewise.
	* tests/data/test-annotate/test16-pr18904.so.abi: Likewise.
	* tests/data/test-annotate/test17-pr19027.so.abi: Likewise.
	* tests/data/test-annotate/test18-pr19037-libvtkRenderingLIC-6.1.so.abi: Likewise.
	* tests/data/test-annotate/test19-pr19023-libtcmalloc_and_profiler.so.abi: Likewise.
	* tests/data/test-annotate/test2.so.abi: Likewise.
	* tests/data/test-annotate/test20-pr19025-libvtkParallelCore-6.1.so.abi: Likewise.
	* tests/data/test-annotate/test21-pr19092.so.abi: Likewise.
	* tests/data/test-annotate/test22-pr19097-libstdc++.so.6.0.17.so.abi: Likewise.
	* tests/data/test-annotate/test3.so.abi: Likewise.
	* tests/data/test-annotate/test4.so.abi: Likewise.
	* tests/data/test-annotate/test5.o.abi: Likewise.
	* tests/data/test-annotate/test6.so.abi: Likewise.
	* tests/data/test-annotate/test7.so.abi: Likewise.
	* tests/data/test-annotate/test8-qualified-this-pointer.so.abi: Likewise.
	* tests/data/test-annotate/test9-pr18818-clang.so.abi: Likewise.
	* tests/test-annotate.cc: New test for ABIXML annotations.
	* tools/abidiff.cc: Add the new option '--no-corpus-path'.
	* tools/abidw.cc: Likewise. Also add the '--annotate' option.

reviews round 1

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-01-24 15:41:37 +01:00
Dodji Seketeli
5aa38407ce Fix test-diff-pkg after commit 2dcc606
The runtestdiffpkg test has wrong paths to the spice-server packages.

Fixed thus.

	* tests/test-diff-pkg.cc (in_out_specs): Fix paths to spice-server
	packages.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-01-20 15:47:16 +01:00
Dodji Seketeli
499f598907 Add --harmless option to abipkgdiff
This option that is present for the abidiff tool was missing for
abipkgdiff.

	* doc/manuals/abidiff.rst: Fix a typo.
	* doc/manuals/abipkgdiff.rst: Document the --harmless option.
	* tools/abipkgdiff.cc: Update copyright year.
	(options::show_harmless_changes): Add new data member.
	(options::options): Initialize the new data member.
	(display_usage): Add a help string for the new --harmless option.
	(parse_command_line): Parse the new --harmless option.
	(set_diff_context_from_opts): Configure the diff context
	accordingly, if the user provided the --harmless option.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-01-20 11:04:27 +01:00
Dodji Seketeli
2dcc6062f2 Fix suppression category propagation in diff node graph
Under certain circumstances, a diff node (which we shall name N) that
belongs to the SUPPRESSED_CATEGORY category sees its belonging to that
category been propagated to its parent diff node, effectively
suppressing that parent diff node as well.  This is how some function
diff nodes ends up being suppressed just because some of their
children diff nodes were suppressed.

This suppression category propagation is performed by a pass that
walks the diff nodes graph.  To avoid infinite cycles, the pass avoids
visiting a diff node that is equivalent to a node that has already
been visited.

As a result, diff nodes equivalent to N (the class of equivalence of
N) are not traversed by the propagation pass.  So their parent diff
nodes are not suppressed.

This leads to some functions not being suppressed as they should.
This phenomenon can be observed by comparing the two packages that are
provided in the regression test accompanying this patch using
abipkgdiff with the --redundant option.

Here is how the patch addresses the issue.

When the suppression category propagation pass considers a parent diff
node (named P) of a node N' (with N' being equivalent to N), it now
looks at the category of the *class of equivalence of N'* to determine
if that category should be propagated to P.

Previously, that pass would just look at the at the category of N'
(not the category of the class of equivalence of N') for the
propagation.  But as N' has not been visited (because N has already
been visited and nodes equivalent to N are thus not visited) the
belonging of N' to the SUPPRESSED_CATEGORY hasn't been updated.  So N'
isn't marked as being in SUPPRESSED_CATEGORY.  So the
SUPPRESSED_CATEGORY wouldn't be propagated to P as it should.

So, with this patch abipkgdiff invoked with the --redundant option now
correctly yields:

$ abipkgdiff --redundant --d1 spice-debuginfo-0.12.4-19.el7.x86_64.rpm --d2 spice-debuginfo-0.12.8-1.el7.x86_64.rpm --devel1 spice-server-devel-0.12.4-19.el7.x86_64.rpm --devel2 spice-server-devel-0.12.8-1.el7.x86_64.rpm spice-server-0.12.4-19.el7.x86_64.rpm spice-server-0.12.8-1.el7.x86_64.rpm
================ changes of 'libspice-server.so.1.8.0'===============
  Functions changes summary: 1 Removed, 2 Changed (62 filtered out), 8 Added functions
  Variables changes summary: 0 Removed, 0 Changed, 0 Added variable

[...]

  2 functions with some indirect sub-type change:

    [C]'function spice_image_compression_t spice_server_get_image_compression(SpiceServer*)' at reds.c:3618:1 has some indirect sub-type changes:
      return type changed:
        underlying type 'enum __anonymous_enum__' changed:
          type size hasn't changed
          7 enumerator deletions:
            '__anonymous_enum__::SPICE_IMAGE_COMPRESS_INVALID' value '0'
            '__anonymous_enum__::SPICE_IMAGE_COMPRESS_OFF' value '1'
            '__anonymous_enum__::SPICE_IMAGE_COMPRESS_AUTO_GLZ' value '2'
            '__anonymous_enum__::SPICE_IMAGE_COMPRESS_AUTO_LZ' value '3'
            '__anonymous_enum__::SPICE_IMAGE_COMPRESS_QUIC' value '4'
            '__anonymous_enum__::SPICE_IMAGE_COMPRESS_GLZ' value '5'
            '__anonymous_enum__::SPICE_IMAGE_COMPRESS_LZ' value '6'

          9 enumerator insertions:
            'SpiceImageCompression::SPICE_IMAGE_COMPRESSION_INVALID' value '0'
            'SpiceImageCompression::SPICE_IMAGE_COMPRESSION_OFF' value '1'
            'SpiceImageCompression::SPICE_IMAGE_COMPRESSION_AUTO_GLZ' value '2'
            'SpiceImageCompression::SPICE_IMAGE_COMPRESSION_AUTO_LZ' value '3'
            'SpiceImageCompression::SPICE_IMAGE_COMPRESSION_QUIC' value '4'
            'SpiceImageCompression::SPICE_IMAGE_COMPRESSION_GLZ' value '5'
            'SpiceImageCompression::SPICE_IMAGE_COMPRESSION_LZ' value '6'
            'SpiceImageCompression::SPICE_IMAGE_COMPRESSION_LZ4' value '7'
            'SpiceImageCompression::SPICE_IMAGE_COMPRESSION_ENUM_END' value '8'

    [C]'function int spice_server_set_image_compression(SpiceServer*, spice_image_compression_t)' at reds.c:3602:1 has some indirect sub-type changes:
      parameter 2 of type 'typedef spice_image_compression_t' changed:
        underlying type 'enum __anonymous_enum__' changed:
          type size hasn't changed
          7 enumerator deletions:
            '__anonymous_enum__::SPICE_IMAGE_COMPRESS_INVALID' value '0'
            '__anonymous_enum__::SPICE_IMAGE_COMPRESS_OFF' value '1'
            '__anonymous_enum__::SPICE_IMAGE_COMPRESS_AUTO_GLZ' value '2'
            '__anonymous_enum__::SPICE_IMAGE_COMPRESS_AUTO_LZ' value '3'
            '__anonymous_enum__::SPICE_IMAGE_COMPRESS_QUIC' value '4'
            '__anonymous_enum__::SPICE_IMAGE_COMPRESS_GLZ' value '5'
            '__anonymous_enum__::SPICE_IMAGE_COMPRESS_LZ' value '6'

          9 enumerator insertions:
            'SpiceImageCompression::SPICE_IMAGE_COMPRESSION_INVALID' value '0'
            'SpiceImageCompression::SPICE_IMAGE_COMPRESSION_OFF' value '1'
            'SpiceImageCompression::SPICE_IMAGE_COMPRESSION_AUTO_GLZ' value '2'
            'SpiceImageCompression::SPICE_IMAGE_COMPRESSION_AUTO_LZ' value '3'
            'SpiceImageCompression::SPICE_IMAGE_COMPRESSION_QUIC' value '4'
            'SpiceImageCompression::SPICE_IMAGE_COMPRESSION_GLZ' value '5'
            'SpiceImageCompression::SPICE_IMAGE_COMPRESSION_LZ' value '6'
            'SpiceImageCompression::SPICE_IMAGE_COMPRESSION_LZ4' value '7'
            'SpiceImageCompression::SPICE_IMAGE_COMPRESSION_ENUM_END' value '8'

================ end of changes of 'libspice-server.so.1.8.0'===============

$

	* include/abg-comparison.h (diff::get_class_of_equiv_category):
	Declare new member function.
	* src/abg-comparison.cc: Update copyright year.
	(diff::get_class_of_equiv_category): Define new member function.
	(suppression_categorization_visitor::visit_end): When considering
	children nodes category for propagation, consider the category of
	the class of equivalence of children nodes.
	* spice-debuginfo-0.12.4-19.el7.x86_64.rpm: New input test package.
	* spice-debuginfo-0.12.8-1.el7.x86_64.rpm: Likewise.
	* spice-server-0.12.4-19.el7.x86_64.rpm: Likewise.
	* spice-server-0.12.8-1.el7.x86_64.rpm: Likewise.
	* spice-server-devel-0.12.4-19.el7.x86_64.rpm: Likewise.
	* spice-server-devel-0.12.8-1.el7.x86_64.rpm: Likewise.
	* spice-server-0.12.4-19.el7.x86_64-0.12.8-1.el7.x86_64-report-0.txt:
	New reference test output.
	* spice-server-0.12.4-19.el7.x86_64-0.12.8-1.el7.x86_64-report-1.txt: Likewise.
	* spice-server-0.12.4-19.el7.x86_64-0.12.8-1.el7.x86_64-report-2.txt: Likewise.
	* tests/data/Makefile.am: Add the new test material above to
	source distribution.
	* tests/test-diff-pkg.cc (in_out_specs): Add the new test inputs
	to the list of packages to test.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-01-20 10:59:58 +01:00
Dodji Seketeli
8ae81a8e16 Bug 21058 - abipkgdiff wrongly drops non-public types
When using abipkgdiff types that are defined in files not present in
the devel packages provided by the --devel1 and --devel2 option are
dropped from the internal representation by default.

This has been designed as such, not only to avoid showing changes on
types that are not part of the public headers of a shared library, but
also to help lower the memory consumption of libabigail.

In this particular bug report, we see a library that uses types (in
its public interface) that are defined in headers of a *different*
package.  For instance, suppose a particular package foo that uses
types defined in headers of the glib package.  And some of those Glib
types can be present in its public interface.

So in this case, libabigail is dropping a type that is actually part
of the public interface of the library that is being analyzed, even if
the type was not defined in the devel package of the current package.

This patch addresses the issue by doing a number of things:

    1/ If a type is defined in a file which path starts with
    "/usr/include/", then consider it as a public type.  This is so
    that type coming from the public interface of other packages, and
    that are defined in system headers are considered as part of the
    public types of the package being analyzed.

    2/ by default, don't drop types not defined in the associated
    devel package.  This will hinder our ability to decrease the
    memory usage, but there have been a number of recent optimization
    that help in that regard independently.  So I am hoping this
    shouldn't have a big impact now.

    Incidentally, the option --dont-drop-private-types (from abidiff)
    is changed into --drop-private-types, so that interested users can
    still drop non-private types from the model, if they wish.  That
    --drop-private-types option is added to abipkgdiff too.

As the offended types are not dropped from the model anymore, the
usual filtering mechanisms of libabigail can take place.

	* doc/manuals/abidiff.rst (--dont-drop-private-types): Remove documentation.
	(--drop-private-types): Document this new option.
	* src/abg-tools-utils.cc: Update copyright notice
	(handle_fts_entry): On the generated suppression specification, do
	not set the flag to drop matched types.  Also, don't match types
	defined in files which patch start with "/usr/include/".
	* tools/abidiff.cc (options::options): Initialize the
	drop_private_types data member to false.
	(display_usage): Remove usage string for
	--dont-drop-private-types.  Add a new one for
	--drop-private-types.
	(parse_command_line): Don't part --dont-drop-private-types,
	rather, parse --drop-private-types.
	(set_suppressions): When the suppression for private types is
	generated, if --drop-private-types was provided, then instruct the
	suppression to drop matched types.
	* tools/abipkgdiff.cc (options::drop_private_types): New option.
	(options::options): Initialize the new drop_private_types data
	member to false.
	(display_usage): Add a usage string for --drop-private-types.
	(parse_command_line): Parse the new --drop-private-types option.
	(maybe_create_private_types_suppressions): Don't take just a
	package, but a package_descriptor because the latter carries the
	options.  So when the user used the --drop-private-types option,
	make the generated private types suppression to drop matched
	types.
	* tests/data/test-diff-pkg/tbb-4.1-9.20130314.fc22.x86_64--tbb-4.3-3.20141204.fc23.x86_64-report-1.txt:
	Adjust.
	* tests/test-diff-suppr.cc (in_out_specs): Likewise.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-01-18 10:14:02 +01:00
Dodji Seketeli
fd7e0083db Fix some include logic in abg-suppression.cc
* src/abg-suppression.cc: Update copyright notice. Fix include
	files logic.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-01-18 10:11:38 +01:00
Dodji Seketeli
a821154753 Support virtual member functions with vtable offset not yet set
When reading C++ class informatin DWARF, it can happen that a given
virtual member function does not yet have a vtable offset.  Right now,
that offset is set to zero.  Just like a virtual member function which
actual vtable offset is zero.  So we don't make a difference between a
virtual function with no vtable offset and a virtual function with a
vtable offset set to zero.

This can lead to confusions during class comparison.

This patch fixes that problem by setting the default vtable offset to
-1.  So whenever a vtable offset is -1 it means that the virtual
member function doesn't yet have a vtable offset.

	* include/abg-fwd.h (member_function_has_vtable_offset): Declare
	new function.
	(get_member_function_vtable_offset): Return a ssize_t, not a
	size_t.
	(set_member_function_vtable_offset): Take a ssize_t, not a size_t.
	* include/abg-ir.h (class_decl::virtual_mem_fn_map_type): Adjust
	the map typedef to make it take ssize_t as the type of the key.
	(mem_fn_context_rel::vtable_offset_in_bits_): Make this data
	member be of ssize_t type, not size_t.
	(mem_fn_context_rel::mem_fn_context_rel): Initialize the
	vtable_offset_in_bits_ data member to -1.
	* src/abg-ir.cc (member_function_has_vtable_offset): Define new
	function.
	(get_member_function_vtable_offset): Return a ssize_t, not a
	size_t.
	(set_member_function_vtable_offset): Take a ssize_t, not a size_t.
	* src/abg-dwarf-reader.cc (die_virtual_function_index): Take an
	int64_t& rather than a uint64_t&.
	(finish_member_function_reading): Don't set the vtable offset if
	it's -1.
	* src/abg-reader.cc (build_class_decl): Likewise.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-01-16 21:00:56 +01:00
Dodji Seketeli
c6666f5176 [comparison engine] Don't crash when the context is null
* src/abg-comparison.cc
	(RETURN_IF_BEING_REPORTED_OR_WAS_REPORTED_EARLIER): Guard against
	null context.
	(diff::is_filtered_out): Likewise.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-01-16 21:00:56 +01:00
Dodji Seketeli
a7b6999602 [dwarf reader] Don't abort when trying to canonicalize a non-type
maybe_canonicalize_type is too strict when given a non type.  In that
case, it should just return, not abort.

	* src/abg-dwarf-reader.cc (maybe_canonicalize_type): Don't abort
	when trying to canonicalize a decl.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-01-16 21:00:56 +01:00
Dodji Seketeli
970248b5ed [dwarf reader] properly separate function decls and types in lookup
We were sometimes forgetting to properly add some types to the lookup
maps as such.  Instead, the types were added as if they were decls,
leading to later type lookup to fail.

Fixed thus.

	* src/abg-dwarf-reader.cc
	(read_context::associate_die_to_artifact_by_repr_internal):
	Choose the right type of representation depending on if we are
	associating a type or a decl.
	* tests/data/test-diff-filter/test31-pr18535-libstdc++-report-0.txt: Adjust.
	* tests/data/test-diff-filter/test31-pr18535-libstdc++-report-1.txt: Adjust.
	* tests/data/test-read-dwarf/test10-pr18818-gcc.so.abi: Adjust.
	* tests/data/test-read-dwarf/test11-pr18828.so.abi: Adjust.
	* tests/data/test-read-dwarf/test12-pr18844.so.abi: Adjust.
	* tests/data/test-read-dwarf/test13-pr18894.so.abi: Adjust.
	* tests/data/test-read-dwarf/test14-pr18893.so.abi: Adjust.
	* tests/data/test-read-dwarf/test15-pr18892.so.abi: Adjust.
	* tests/data/test-read-dwarf/test16-pr18904.so.abi: Adjust.
	* tests/data/test-read-dwarf/test17-pr19027.so.abi: Adjust.
	* tests/data/test-read-dwarf/test18-pr19037-libvtkRenderingLIC-6.1.so.abi:
	Adjust.
	* tests/data/test-read-dwarf/test19-pr19023-libtcmalloc_and_profiler.so.abi:
	Adjust.
	* tests/data/test-read-dwarf/test20-pr19025-libvtkParallelCore-6.1.so.abi:
	Adjust.
	* tests/data/test-read-dwarf/test21-pr19092.so.abi: Adjust.
	* tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi:
	Adjust.
	* tests/data/test-read-dwarf/test9-pr18818-clang.so.abi: Adjust.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-01-16 21:00:54 +01:00
Dodji Seketeli
45e6599334 [dwarf reader] Allow updating and de-duplicating member functions
We forget to register member functions for lookup (by DWARF DIE
representation).  So member functions are not correctly found (by
lookup) and thus are not properly de-duplicated or updated.

	* src/abg-dwarf-reader.cc (add_or_update_class_type): Register
	member functions for lookup by member function DIE representation.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-01-16 21:00:54 +01:00
Dodji Seketeli
2421bcc877 [dwarf reader] Do not over de-duplicate function *definitions*
When a function needs to be completed, we sometimes wrongly
try to de-duplicate rather than just complete it.

	* src/abg-dwarf-reader.cc
	(build_or_get_fn_decl_if_not_suppressed): Do try to de-duplicate a
	function if it's to be completed.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-01-16 21:00:54 +01:00
Dodji Seketeli
78c26e6a23 [dwarf reader] Fix pretty printing static methods from DWARF
When pretty printing static methods from DWARF, we were forgetting the
first parameter for static methods.

	* src/abg-dwarf-reader.cc
	(die_return_and_parm_names_from_fn_type_die): Take a new
	'is_static' parameter.
	(die_qualified_type_name, die_pretty_print_type): Adjust calling
	die_return_and_parm_names_from_fn_type_die.
	(die_function_signature): Likewise.  Also, do not forget to print
	the first parameter for a static method.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-01-16 21:00:54 +01:00
Dodji Seketeli
9136c6a639 Handle several virtual member functions having the same vtable offset
In the DWARF for C++, it can happens that a virtual constructor leads
to several (up to 3) destructor functions that all have the same
vtable offset.  That vtable offset is the same as the offset of the
virtual destructor that the user actually defined in her source code.

This patch adds a map data structure to the private data of
class_decl.  That map associates a vtable offset X to a vector of
virtual member functions that have the same vtable offset X.

That new map is populated whenever a virtual member function is added
to the class.

	* include/abg-ir.h (class_or_union::virtual_mem_fn_map_type):
	Define new typedef.
	(class_decl::get_virtual_mem_fns_map): Declare new accessor.
	* src/abg-ir.cc (class_decl::priv::virtual_mem_fns_map_): New data
	member.
	(class_decl::get_virtual_mem_fns_map): Define new accessor.
	(fixup_virtual_member_function): Populate the new virtual member
	functions map.
	(class_decl::on_canonical_type_set): Sort the virtual member
	function vectors stored in the new virtual member functions map.
	(class_decl::add_member_function): Call
	set_member_function_is_virtual *after* calling
	set_member_function_vtable_offset because the former updates the
	virtual function map, so it needs the vtable offset.
	* src/abg-dwarf-reader.cc (finish_member_function_reading):
	Likewise.
	* src/abg-reader.cc (build_class_decl): Likewise.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-01-16 21:00:54 +01:00
Dodji Seketeli
367da46e7a Speed up pretty representing (function) types
During structural (function) type comparison, computing the pretty
representation of the type at hand appears high on performance profiles,
especially when type canonicalization wasn't really effective.

This patch adds a type_base::get_cached_pretty_representation() and a
function_type::get_cached_name() to cache the pretty representation of
a type, as well as the function type name.  This is way, the type
representation is computed just once and stored into a cache.
subsequent invocations of the function just look into the cache
instead of computing the representation again.

Note that we do this only for non-canonicalized types because these
types can still be modified, and so caching the representation of a
type that might be changed (and thus see its representation change)
leads to issue.  So the representation of non-canonicalized types is
not cached.

	* include/abg-ir.h (type_base::get_cached_pretty_representation):
	Declare new function.
	(function_type::get_cached_name): Likewise.
	* src/abg-ir.cc (get_method_type_name): Use the new
	type_base::get_cached_pretty_representation function.
	(type_base::priv::{internal_cached_repr_, cached_repr_}): Add new
	data members.
	(function_type::priv::{internal_cached_name_, cached_name_}):
	Likewise.
	(type_base::get_cached_pretty_representation): Define new
	function.
	(function_type::get_cached_name): Likewise.
	(type_base::get_canonical_type_for): Call
	type_base::get_cached_pretty_representation here, so the internal
	representation is cached right before canonicalization.
	(function_type::{mark_as_being_compared, unmark_as_being_compared,
	comparison_started}): Uset he new type_base::get_cached_name to
	speed up function type name retrieval.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-01-16 21:00:54 +01:00
Dodji Seketeli
b49119584b Add missing deep comparison operators for {function, method}_decl_sptr
It turned out we were missing deep comparison operators for smart
pointers to function_decl and method_decl.  Because of coming patches
that compare virtual member functions as part of comparing classes, we
need these deep comparison operators.

	* include/abg-ir.h (operator==): Declare two new overloads for
	function_decl_sptr an method_decl_sptr.
	* src/abg-ir.cc (operator==): Define two new overloads for
	function_decl_sptr an method_decl_sptr.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-01-16 21:00:54 +01:00
Dodji Seketeli
0af65e6364 Fix performance regression while analyzing libjvm.so
abidiff libjvm.so libjvm.so is taking forever in the master branch
these days.  At some point it was taking ~ 15 minutes and 15GB of RAM
on a non-optimized build.

Profiling of CPU usage showed that sorting virtual member
functions of a class whenever a new virtual member function is added
was the hot spot.

This patch now sorts virtual member functions once right after the
type was canonicalized.  The patch adds a virtual function
type_base::on_canonical_type_set() that is invoked right after the
canonical type is set for a given type.  class_decl gets its own
version of that virtual function: class_decl::on_canonical_type_set.
In that function, the patch does sort the virtual member functions of
the current class_decl.

Now with this patch, abidiff is still taking around 15 minutes but it
consumes less than 12GB of ram.  This means the memory consumption was
reduced by 20%.  abipkgdiff performs on 16:30 minutes and in less than
12GB of RAM as well.  All these times are measured on a non-optimized
build.

	* include/abg-ir.h ({type_base,
	class_decl}::on_canonical_type_set): Declare new virtual member
	function.
	* src/abg-ir.cc (type_base::on_canonical_type_set): Define new
	virtual member function that does nothing.
	(class_decl::on_canonical_type_set): Define new virtual member
	function that sorts the virtual member functions of class_decl.
	(canonicalize): Invoke type_base::on_canonical_type_set when the
	canonical type is set.
	(fixup_virtual_member_function): Don't sort virtual member
	functions here.
	* src/abg-dwarf-reader.cc (finish_member_function_reading): Do not
	sort virtual member functions here.
	* tests/data/test-read-dwarf/test13-pr18894.so.abi: Adjust.
	* tests/data/test-read-dwarf/test14-pr18893.so.abi: Adjust.
	* tests/data/test-read-dwarf/test15-pr18892.so.abi: Adjust.
	* tests/data/test-read-dwarf/test21-pr19092.so.abi: Adjust.
	* tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi: Adjust.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-01-16 19:25:36 +01:00
Dodji Seketeli
9dc07f5534 Update copyright notice for abg-fwd.h, abg-ir.h and test-abidiff.cc
* include/abg-fwd.h: Adjust copyright.
	* include/abg-ir.h: Likewise.
	* tests/test-abidiff.cc: Likewise.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-01-16 15:36:20 +01:00
Dodji Seketeli
192c8d00ff Remove unused functions from abg-ir.cc
* src/abg-ir.cc (convert_node_to_decl): Remove specializations for
	class_decl_sptr, type_base_sptr and var_decl_sptr.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-01-16 08:57:55 +01:00
Dodji Seketeli
08e760221b Support Linux Kernel ABI whitelist files
Enterprise Linux (at least) kernels come with ABI whitelist files that list the
names of the set of functions to be considered when looking at the ABI
exposed by the kernel to its modules.

This patch adds a new --linux-kernel-abi-whitelist option to abidiff
so that it drops changes that relate to functions that are *NOT*
defined in the whitelist.

The patch reads the whitelist file and generates one or several
instances of function_suppression that are applied when the two
binaries are loaded.

	* include/abg-suppression.h
	(function_suppression::function_suppression): Make the declaration
	of the default constructor public.
	* src/abg-suppression-priv.h (function_suppression::priv::priv):
	Declare a default constructor.
	* src/abg-suppression.cc
	(function_suppression::function_suppression): Define default
	constructor.
	* include/abg-tools-utils.h
	(gen_suppr_spec_from_kernel_abi_whitelist): Declare new function.
	* src/abg-tools-utils.cc
	(gen_suppr_spec_from_kernel_abi_whitelist): Define new function.
	* tools/abidiff.cc (options::kernel_abi_whitelist_paths):
	(display_usage): Display a help string for the new
	--linux-kernel-abi-whitelist option.
	(parse_command_line): Parse the --linux-kernel-abi-whitelist from
	the command line.
	(maybe_check_suppression_files): Check the presence of the kernel
	abi whitelist files.
	(set_suppressions): Generate suppression specifications from the
	whitelist files.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-01-06 12:41:57 +01:00
Dodji Seketeli
fadfa1a6f6 Support Linux Kernel binaries
This patch teaches the ELF/DWARF reader of libabigail to load special
ELF sections that are specific to Linux Kernel binaries (either
vmlinux or linux kernel modules).

The patch creates a new flag that tells the ELF reader that it needs
to consider the input binary as a Linux Kernel binary.  This is the
new 'Linux Kernel mode'.

In this linux kernel mode, the reader expects sections that are named
__ksymtab and/or __ksymtab_gpl sections.  Those sections contain
indexes (of ELF symbols described in the normal ELF symbol table) of
exported ELF symbols that are specifically marked by developers using
EXPORT_SYMBOL or EXPORT_SYMBOL_GPL macros.  These are symbols of
global variables and functions defined and meant to be used by kernel
modules.  They constitute the interface exported by the Linux Kernel
to its modules.  So the patch only exports the publicly defined and
exported ELF symbols that are also listed in __ksymtab and
__ksymtab_gpl sections.

The patch also fixes and re-organizes things left and right so that
this new mode works in a well integrated manner with the other parts
of the reader:

  - The load address of the binary is no more assumed to be the load
    address specified by the program header that is at offset zero.
    This is usually the case for user-space programs.  To handle Linux
    Kernel binaries, the load address is now the one specified by the
    program header that is at the smallest offset.

  - The patch now tries to populate the various symbol maps only when
    necessary.  That way, the new symbol maps defined for the ksymtab
    and ksymtab_gpl section are also loaded only when necessary; that
    is, when in Linux Kernel mode.

  - The patch (more) agressively suppresses non-member functions or
    variables that are not declarations and that have no associated
    ELF symbol.

The patch knows how to recognize and read relevant ELF symbol
information from __ksymtab and __ksymtab_gpl sections.

The patch makes abidiff and abidw detect that a binary is a
Linux Kernel binary (either a vmlinux or a module).  It does this by
detecting the presence of the speciall __ksymtab_strings section.

If it detects that a binary is a Linux Kernel binary then it only
considers functions and variables which are defined and exported in
the sense of ELF *AND* which ELF symbols are listed in the __ksymtab
and __ksymtab_gpl sections.

If users want abidiff and abidw to consider their input binaries as
normal ELF binaries then they can use the option --no-linux-kernel-mode.

	* include/abg-dwarf-reader.h (create_read_context): Take a new
	flag to say if the context is to read an ELF binary in linux
	kernel mode.
	* src/abg-dwarf-reader.cc (typedef address_set_type)
	(address_set_sptr): New typedefs.
	(get_binary_load_address):  The load address of the binary is
	the load address specified by the program header that is at the
	smallest offset; not by the program header that is at offset zero.
	(read_context::{ksymtab_section_, ksymtab_gpl_section_,
	linux_exported_fn_syms_, linux_exported_var_syms_,
	linux_exported_gpl_fn_syms_, linux_exported_gpl_var_syms_,
	load_in_linux_kernel_mode_}): New data members.
	(read_context::read_context): Initialize ksymtab_section_,
	ksymtab_gpl_section_ and load_in_linux_kernel_mode_.
	(read_context::{find_symbol_table_section, find_opd_section,
	lookup_elf_fn_symbol_from_address,
	lookup_elf_var_symbol_from_address, get_function_address,
	get_variable_address}): Make these const.
	(read_context::{find_ksymtab_section, find_ksymtab_gpl_section,
	lookup_elf_symbol_from_address, function_symbol_is_exported,
	variable_symbol_is_exported, linux_exported_fn_syms,
	create_or_get_linux_exported_fn_syms, linux_exported_var_syms,
	create_or_get_linux_exported_var_syms, linux_exported_gpl_fn_syms,
	linux_exported_gpl_var_syms,
	create_or_get_linux_exported_gpl_fn_syms,
	linux_exported_gpl_var_syms,
	create_or_get_linux_exported_gpl_var_syms, architecture_word_size,
	load_kernel_symbol_table, load_ksymtab_symbols,
	load_ksymtab_gpl_symbols,
	load_linux_specific_exported_symbol_maps,
	load_in_linux_kernel_mode}): New member functions.
	(read_context::read_int_from_array_of_bytes): Factorize this
	new member function out of ...
	(read_context::{lookup_ppc64_elf_fn_entry_point_address}):
	... this.  Make this function const too.
	(read_context::read_uint64_from_array_of_bytes): New function.
	Uses read_int_from_array_of_bytes above.
	(read_context::{fun_entry_addr_sym_map_sptr}): Try to load symbol
	maps only when it's necessary.
	(read_context::elf_architecture_is_big_endian): Fix logic.
	(read_context::{var_addr_sym_map}):  Express the const variant in
	terms of the non-const one.  In the non-const one, load the map
	only when necessary.
	(read_context::load_symbol_maps_from_symtab_section): Renamed
	load_symbol_maps into this.
	(read_context::is_linux_kernel_binary): Define new member
	function.
	(read_context::{function, variable}_symbol_is_exported): If we are
	not prevented from considering loading in linux kernel mode, then
	just looking at a linux kernel binary makes us consider the
	special kernel sections.
	(read_debug_info_into_corpus): Likewise.
	(build_ir_node_from_die): Take a new flag that says if the ir node
	is a declaration required by another concrete IR node.
	(enum read_context::kernel_symbol_table_kind): New enum.
	(read_context::load_symbol_maps): Support loading linux kernel
	specific sections too.
	(build_var_decl): Use the new
	read_context::variable_symbol_is_exported.
	(function_is_suppressed): Suppress non-member functions or
	variables that are not declarations and that have no symbol.
	(variable_is_suppressed, build_var_decl_if_not_suppressed): Take a
	new flag that says if the variable is a declaration required by a
	concrete variable.  If non member variable that is a declaration
	is not the specification of another concrete variable, then it's
	suppressed.
	(add_fn_symbols_to_map, add_var_symbols_to_map): New function
	definitions.
	(read_debug_info_into_corpus): If we are reading linux kernel or
	linux kernel modules, only set explicitely exported symbols (in
	the linux kernel binary sense) as exported function or variable
	symbols.
	(create_read_context): Take a new flag to say if the context is to
	read an ELF binary in linux kernel mode.
	* tools/abidiff.cc (options::options): Initialize
	options::linux_kernel_mode to true.
	(display_usage): Display usage of the --no-linux-kernel-mode option.
	(parse_command_line): Parse the --no-linux-kernel-mode option.
	* tools/abidw.cc (options::options): Initialize
	options::linux_kernel_mode to true.
	(display_usage): Display usage of --no-linux-kernel-mode option.
	(parse_command_line): Parse the --no-linux-kernel-mode option.
	* doc/manuals/abidiff.rst: Document the new --no-linux-kernel-mode
	options.
	* doc/manuals/abidw.rst: Likewise.
	* tests/data/test-diff-dwarf-abixml/test0-pr19026-libvtkIOSQL-6.1.so.1.abi:
	Adjust.
	* tests/data/test-read-dwarf/test9-pr18818-clang.so.abi: Adjust.
	* tests/data/test-read-dwarf/test10-pr18818-gcc.so.abi: Adjust.
	* tests/data/test-read-dwarf/test11-pr18828.so.abi: Adjust.
	* tests/data/test-read-dwarf/test12-pr18844.so.abi: Likewise.
	* tests/data/test-read-dwarf/test13-pr18894.so.abi: Likewise.
	* tests/data/test-read-dwarf/test14-pr18893.so.abi: Likewise.
	* tests/data/test-read-dwarf/test15-pr18892.so.abi: Likewise.
	* tests/data/test-read-dwarf/test16-pr18904.so.abi: Likewise.
	* tests/data/test-read-dwarf/test17-pr19027.so.abi: Likewise.
	* tests/data/test-read-dwarf/test18-pr19037-libvtkRenderingLIC-6.1.so.abi:
	Likewise.
	* tests/data/test-read-dwarf/test19-pr19023-libtcmalloc_and_profiler.so.abi:
	Likewise.
	* tests/data/test-read-dwarf/test20-pr19025-libvtkParallelCore-6.1.so.abi:
	Likewise.
	* tests/data/test-read-dwarf/test21-pr19092.so.abi: Likewise.
	* tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi: Likewise.
	* tests/data/test-read-dwarf/libtest23.so.abi: Adjust.
	* tests/data/test-read-dwarf/libtest24-drop-fns-2.so.abi: Adjust.
	* tests/data/test-read-dwarf/libtest24-drop-fns.so.abi: Adjust.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-01-06 12:35:22 +01:00
Dodji Seketeli
3d267a6fbf Add debug routines to dump locations to a stream
* src/abg-writer.cc (dump_location): Define new function and one
	overload.
	(dump_decl_location): Re-write in terms of the new dump_location.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-01-06 01:48:33 +01:00
Dodji Seketeli
7a313fc9c9 Better de-duplicate classes, unions, enums in non-odr contexts
When reading an ELF/DWARF binary that doesn't support the One
Definition Rule[1] (aka ODR), type de-duplication is done on a
per-translation unit basis only.  That means that a type definition
must be unique only in a given translation unit, in that case.

[1]: https://en.wikipedia.org/wiki/One_Definition_Rule

When handling big C binaries like the Linux Kernel, this implies a lot
of type duplication still, as the same type can be re-defined in a lot
of different translation units.

This patch tries to de-duplicate types on a per-corpus basis, even in
cases where the ODR doesn't apply.  It does so by noting that if two
types of the same kind and name are seen in two different translation
units and yet have the same source location (are defined in the same
spot) then they are the same type.

The patch does this for class, union and enum types as these seem to
be the kinds of types which are duplicated the most and thus consume
the most memory and later take the most time to canonicalize.  In a
subsequent patch, we might want to try to de-duplicate typedef types
too, and see if gain anything.

Comparing two linux kernels shows that with this patch, we come back
to a speed (and memory consumption) that is comparable to when we were
considering C-based binaries as being suited to our (too aggressive)
ODR-based type de-duplication algorithm.

Below are the output of the comparison measured with /usr/bin/time
with the aggressive ODR-based type de-duplication algorithm and with
this patch.  We compare the vmlinux binary coming from the package
kernel-3.10.0-515 against the one from kernel-3.10.0-327.el7.x86_64.
We use the kabi whitelists provided by the relevant
kernel-abi-whitelists packages for these kernels to restrict the
comparison to a meaningful subset of interfaces.

52.66user 0.64system 0:53.34elapsed 99%CPU (0avgtext+0avgdata 944416maxresident)k 0inputs+48outputs (0major+250750minor)pagefaults 0swaps

vs:

51.04user 0.87system 0:51.91elapsed 100%CPU (0avgtext+0avgdata 972560maxresident)k
0inputs+232outputs (0major+279983minor)pagefaults 0swaps

The full invocation and results are available at:

http://people.redhat.com/~dseketel/kabidiff/vmlinuz-3.10.0-327.el7.x86_64--vmlinuz-3.10.0-515.el7.x86_64.diff.whitelisted.with-unions.txt

vs

http://people.redhat.com/~dseketel/kabidiff/vmlinuz-3.10.0-327.el7.x86_64--vmlinuz-3.10.0-515.el7.x86_64.diff.whitelisted.with-unions.with-non-odr-support.txt

Note that to be able to compare the two kernels, the current tree must
contain the necessary patches that make libabigail understand Linux
Kernel binaries.

	* src/abg-dwarf-reader.cc (build_enum_type)
	(add_or_update_class_type, add_or_update_union_type): When the ODR
	is not relevant, use the location of the type to detect if two
	enum, class or union types of the same name actually represent the
	same type.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-01-06 01:43:57 +01:00
Dodji Seketeli
bdac61cc32 Adjust some reference outputs of the test-read-dwarf test harness
* tests/data/test-read-dwarf/test12-pr18844.so.abi: Adjust.
	* tests/data/test-read-dwarf/test9-pr18818-clang.so.abi: Adjust.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-01-06 01:41:09 +01:00
Ondrej Oprala
5aff747c5e Bug 18754 - Add the "--no-added-syms" option to abidiff
With this option, abidiff is now able to filter out added
symbols just like abipkgdiff is.

	* doc/manuals/abidiff.rst: Document the new --no-added-syms
	option.
        * tools/abidiff.cc (struct options): Add show_added_syms and
        set it to true by default.
        (display_usage): Document the new options --no-added-syms. If
        this is the only suppression option specified, it is equivalent
        to specifying --show_{changed,deleted}_{fns,vars} as arguments
        to abidiff. If any of those options are specified before
        --no-added-syms, then it has no effect.
        (parse_command_line): Parse the new option and set
	show_added_{fns,vars,syms} and show_all_{fns,vars} to false if
	--no-added-syms is specified.
        * tests/test-diff-filter.cc: Add a test for the new option.
        * tests/data/test-diff-filter/test35-pr18754-no-added-syms-report-0.txt:
        Reference results for the new test.
        * tests/data/test-diff-filter/test35-pr18754-no-added-syms-report-1.txt:
        Likewise.
        * tests/data/Makefile.am: Add the above test files to the list of
        test data.

Signed-off-by: Ondrej Oprala <ondrej.oprala@gmail.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-01-05 13:44:25 +01:00
Dodji Seketeli
d198b27b64 Update copyright year on a bunch of files
* include/abg-corpus.h: Update copyright year to 2017.
	* src/abg-dwarf-reader.cc: Likewise.
	* src/abg-ir.cc: Likewise.
	* src/abg-reader.cc: Likewise.
	* src/abg-writer.cc: Likewise.
	* tools/abicompat.cc: Likewise.
	* tools/abidw.cc: Likewise.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-01-05 12:51:49 +01:00
Dodji Seketeli
bf138a22c3 [apidoc] Allow brief description at the top of class description pages
* doc/api/libabigail.doxy: Don't disable "brief member desc".

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-01-05 12:51:38 +01:00
Dodji Seketeli
4063dfe487 Misc style fixes
* include/abg-corpus.h: Remove corpus_sptr typedef. It's in
	abg-fwd.h now.
	* src/abg-ir.cc: Remove some unnecessary vertical space.
	* src/abg-reader.cc (build_function_decl): Cleanup some asserts.
	* src/abg-writer.cc (write_function_type): Each the inspection of
	the type id from within the debugger.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-01-05 12:51:30 +01:00
Dodji Seketeli
2d53328bf4 Misc comments and apidoc fixes
* src/abg-dwarf-reader.cc (lookup_symbol_from_gnu_hash_tab): Fix
	typo in comment.
	* tools/abicompat.cc (perform_compat_check_in_weak_mode): Better
	comments.
	* tools/abidw.cc (dislay_usage): Fix white spaces.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>

Conflicts:
	tools/abidw.cc
2017-01-05 12:51:08 +01:00
Dodji Seketeli
b23abed949 Speedup set_member_is_static
set_member_is_static dominates some performance profile because that
function compares data members before their types are canonicalizing.
This means the comparison is done structurally.  So it's potentially
super long.

This patch fixes the issue by comparing data members by just looking at
their names, and that should be enough.

	* src/abg-ir.cc (set_member_is_static): When comparing data
	members, consider only their names.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-01-05 12:47:20 +01:00
Dodji Seketeli
b8452d2d59 Avoid unnecessary updates to type lookup maps
In class_or_union::set_is_declaration_only we should update the type
lookup maps only when a class type that was previously a
declaration-only type is now a defined type.  Otherwise, updating the type
lookup maps is unnecessary and profiling shows that it takes a
significant amount of time.

This patch does away with the unnecessary attempts to update type
lookup maps.

	* src/abg-ir.cc (class_or_union::get_is_declaration_only): Try
          to update the type maps only when a declaration-only class
          type is now defined.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-01-05 12:47:20 +01:00
Dodji Seketeli
7c004d6922 Update tests/data/test-read-dwarf/*.abi files
After the preceding patch series to handle ABI corpora in which the
ODR is not applicable (and the inevitable fallouts) this patch updates
the reference output for the test-read-dwarf test harness.

	* tests/data/test-read-dwarf/test10-pr18818-gcc.so.abi: Adjust.
	* tests/data/test-read-dwarf/test11-pr18828.so.abi: Likewise.
	* tests/data/test-read-dwarf/test12-pr18844.so.abi: Likewise.
	* tests/data/test-read-dwarf/test13-pr18894.so.abi: Likewise.
	* tests/data/test-read-dwarf/test14-pr18893.so.abi: Likewise.
	* tests/data/test-read-dwarf/test15-pr18892.so.abi: Likewise.
	* tests/data/test-read-dwarf/test16-pr18904.so.abi: Likewise.
	* tests/data/test-read-dwarf/test17-pr19027.so.abi: Likewise.
	* tests/data/test-read-dwarf/test18-pr19037-libvtkRenderingLIC-6.1.so.abi: Likewise.
	* tests/data/test-read-dwarf/test19-pr19023-libtcmalloc_and_profiler.so.abi: Likewise.
	* tests/data/test-read-dwarf/test20-pr19025-libvtkParallelCore-6.1.so.abi: Likewise.
	* tests/data/test-read-dwarf/test21-pr19092.so.abi: Likewise.
	* tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi: Likewise.
	* tests/data/test-read-dwarf/test9-pr18818-clang.so.abi: Likewise.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-01-05 12:39:41 +01:00
Dodji Seketeli
f88dbad75d Update tests/data/test-diff-dwarf-abixml/test0-pr19026-libvtkIOSQL-6.1.so.1.abi
After the preceding patch series to handle ABI corpora in which the
ODR is not applicable (and the inevitable fallouts) this patch updates
the reference output for the test-diff-dwarf-abixml test harness.

	* tests/data/test-diff-dwarf-abixml/test0-pr19026-libvtkIOSQL-6.1.so.1.abi:
	Update.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-01-05 12:35:18 +01:00
Dodji Seketeli
ef3ecb295c [abixml writer] Make sure all function types are emitted
The abixml writer forgets to emit some function types that are only
referenced by other types.  Fixed thus.

Note that the necessary adjustment to reference outputs of abidw in
the regression test suite is not provided with this patch to ease
backporting.  Those adjustments are in a patch that comes at the end
of this patch series.

	* src/abg-writer.cc (write_translation_unit): Fix logic to avoid
	forgetting referenced function types.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-01-05 12:26:20 +01:00
Dodji Seketeli
f4a4794f29 [abixml writer] Fix comparison of pointer to types
When two type pointers designate two types with the same pretty
printed representatin don't already have an associated type id, the
comparison code was mistakenly associating them with empty type id.

This patch fixes that.

Note that the necessary adjustment to reference outputs of abidw in
the regression test suite is not provided with this patch to ease
backporting.  Those adjustments are in a patch that comes at the end
of this patch series.

	* src/abg-writer.cc (type_ptr_comp::operator()): Do not add an
	empty type id string to the type -> type id map when the entry for
	a given type is empty.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-01-05 12:26:20 +01:00
Dodji Seketeli
2e3a4dfb67 [dwarf-reader] Don't early canonicalize function types
Make sure we don't early-canonicalize function types.  We need to wait
after the end of building the ABI corpus before canonicalizing these.

Normally this should be taken care of by using
type_has_non_canonicalized_subtype but there are cases where that
function does not detect that a type has sub-types that are not
canonicalized.

Fixed thus.

	* src/abg-dwarf-reader.cc (maybe_canonicalize_type):
	Late-canonicalize function types.

signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-01-05 12:26:20 +01:00
Dodji Seketeli
ab37f767b7 Fix qualified name caching for some types
When ::get_qualified_name() is invoked for some types, the value is
cached for performance reasons.

One thing to keep in mind is that the structure of a type can change
between the time when the type is first built and the time when it's
canonicalized.  This is because the type can be built progressively,
with sub-types being added over time until the type is fully built.
Then it can be canonicalized.

So if ::get_qualified_name is invoked on a non-canonicalized type and
the result is cached, then that result might not reflect the state of
the type *after* its canonicalized.  So the cached value might be
wrong.

To address that issue, the solution is to *not* cache the result of
::get_qualified_name() until the type is canonicalized.  After the
type is canonicalized and so we know the structur of the type won't
change, then the result of ::get_qualified_name is cached.

And this is what this patch does for qualified, pointer and array
types.

Note that the necessary update to the regression test suite is not
provided with this patch.  It's provided by a separate patch at the
end of the current series of patches.

	* src/abg-ir.cc ({qualified, pointer,
	array}_type_def::get_qualified_name): Don't cache internal and
	non-internal qualified name when the type is not canonicalized.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-01-05 12:26:20 +01:00
Dodji Seketeli
bf62a050c7 Cleanup ODR-based type canonicalization optimization gating logic
During type canonicalization we use an ODR-based optimization which
consists of saying that if two types of the same kind have the same
name and are defined in the same ABI corpus, then they are the same
type -- whithout needing to actually perform a structural comparison
of both types.  This speeds up type canonicalization greatly for types
that are duplicated in the ABI corpus.

The condition to apply that ODR-based optimization is basically that
the binary we are looking at must be in C++.

This patch just makes that condition clearer.

	* src/abg-ir.cc (type_base::get_canonical_type_for): Make it clear
	that the ODR-based optimization is allowed only on C++ ABI
	corpora.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-01-05 12:26:20 +01:00
Dodji Seketeli
6734da6a04 Fix a typo in method name computation
It turns out we forget a "return" keyword when we want to return the
name of a method.  Ooops.

Fixed thus.

Please note that this patch doesn't come with its necessary update to
the tests/data/test-read-dwarf/test9-pr18818-clang.so.abi and
tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi
files.  Those updates to regression tests are coming in a subsequent
patch.

	* src/abg-ir.cc (get_method_type_name): Really return the method
	name.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-01-05 12:26:20 +01:00