Commit Graph

424 Commits

Author SHA1 Message Date
Dodji Seketeli
c022243aac Fix a race condition in queue::priv::do_bring_workers_down
It can happen that queue::priv_::do_bring_workers_down stays forever
waiting for a task to finish (via pthread_join).  The it waits for is
itself blocked in worker::wait_to_execute_a_task, in pthread_cond_wait.

It seems to me that this is because we forget to lock the
queue::priv::queue_cond_mutex before inspecting and updating the
variables on which the wait on the condition depend.

This patch fixes that.

The patch also moves tests/test-read-write.cc over to using the work queue
to increase test coverage for the work queue interface.

	* src/abg-workers.cc (queue::priv::tasks_todo_mutex): Make this
	data member mutable.
	(more_tasks_to_execute):
	(queue::priv::do_bring_workers_down): Update the
	queue::priv::bring_workers_down only in the critical section
	defined by queue::priv::queue_cond_mutex.
	(worker::wait_to_execute_a_task): Testing for
	queue::priv::bring_workers_down is done in the critical section
	defined by queue::priv::queue_cond_mutex.  The loop over waiting
	ont the condition is also in the critical section, as it ought to
	be.
	* tests/test-read-write.cc (struct test_task): New type.
	(main): Express in terms of the new test_task type.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-04-18 04:21:13 -04:00
Dodji Seketeli
530864b566 Launch fedabipkgdiff tests first
This fixes a race condition that seems to occur sometimes.  That is,
if the fedabipkgdiff test is run last, then it can stay idling for
ever.  I'll need to investigate this later.

	* tests/Makefile.am: Run the fedabipkgdiff test first.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-03-24 13:09:32 +01:00
Dodji Seketeli
0c820488d4 Bug 21296 - Reporting diff of const ref against non-const ref aborts
References are always const.  But then GCC sometimes emits DWARF that
represents a const reference.  This leads, for instance, to a given
reference to be considered as different from that same reference wraps
into a const qualifier.  Which is wrong.

Libabigail then represents those const references as a particular case
of a "no-op qualifier".  That is, a qualifier that should be ignored
by the comparison code.

In the case of this issue, the comparison engine considers the two
references (const and non-const) to be equal, but the reporting code
forgets to ignore the ignore no-op qualifier and thus (wrongly)
considers the two references as being different.  That inconsistency
leads to an abort of the process.

This patch moves the code that ignores no-op qualifiers at a lower
level of the comparison engine so that whenever function parameters
are compared, no-op qualifiers are ignored as they should.

	* include/abg-fwd.h (look_through_no_op_qualified_type): Declare
	new function.
	* src/abg-ir.cc (look_through_no_op_qualified_type): Define it.
	(compute_diff_for_types): Use the new
	look_through_no_op_qualified_type here rather than open-coding it.
	(equals): In the overload for function_decl::parameter, use the
	new look_through_no_op_qualified_type function.
	* tests/data/test-diff-dwarf/test40-PR21296-clanggcc.cc: Source
	code of the new test inputs.
	* tests/data/test-diff-dwarf/test40-PR21296-clanggcc-report0.txt:
	New test input.
	* tests/data/test-diff-dwarf/test40-PR21296-libgcc.so: New binary
	test input.
	* tests/data/test-diff-dwarf/test40-PR21296-libclang.so: Likewise.
	* tests/test-diff-dwarf.cc (in_out_specs): Add the new test inputs to
	the test harness.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-03-24 12:39:49 +01:00
Chenxiong Qi
33ee1f2a5d Bug 20087 - Clean cache before or after ABI comparison
Cache data, currently containing downloaded RPM packages from Koji, is
stored in XDG_CACHE_HOME. This patch allows user to delete cache before
or after the ABI comparison, or both.

	* configure.ac: Require shutil module.
	* doc/manuals/fedabipkgdiff.rst: Add document for new option
	clean-cache, clean-cache-before, and clean-cache-after.
	* tools/fedabipkgdiff (build_commandline_args_parser): Add new
	option --clean-cache, --clean-cache-before and
	--clean-cache-after.
	(diff_local_rpm_with_latest_rpm_from_koji): Delete download
	cache directory before or after downloading RPMs.
	(diff_latest_rpms_based_on_distros): Likewise.
	(diff_two_nvras_from_koji): Likewise.
	(diff_from_two_rpm_files): Likewise.
	* bash-completion/fedabipkgdiff: Add new options.
	* tests/mockfedabipkgdiff.in (get_download_dir): Rewrite to
	behave just like the original get_download_dir.
	(mock_get_download_dir): Removed.
	(DOWNLOAD_CACHE_DIR): New global variable pointing directory
	holding packages during tests.
	(run_fedabipkgdiff): Mock original get_download_dir with the
	rewrite get_download_dir.
	* tests/runtestfedabipkgdiff.py.in (run_fedabipkgdiff_tests):
	Add --clean-cache to run tests to ensure no regression.

Signed-off-by: Chenxiong Qi <cqi@redhat.com>
2017-03-22 15:43:37 +01:00
Dodji Seketeli
324996d24c Shut down a helgrind false positive in the "system" libc call
* tests/test-valgrind-suppressions.supp: Add a suppression that
	occurs during an internal libc signal handling occasion.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-03-17 09:02:19 +01:00
Dodji Seketeli
688d18dc71 Bug 21228 - Handle cloning union member functions
It turns out we allow member function cloning only for functions that
are members of classes, not for functions that are member of unions.

This patch fixes that by turning the method
class_decl::add_member_function into the
class_or_union::add_member_function.  Note that there was already an
overload of class_or_union::add_member_function; now, all the member
functions add_member_function are members of the class_or_union type.

The patch then modifies function_decl::clone to make that code avoid
assuming that only member functions of classes can be cloned.

	* include/abg-ir.h (class_or_union::add_member_function): Move the
	class_decl::add_member_function overload declaration into the
	class class_or_union class.
	(class class_decl): Make the class class_or_union be a friend of
	class_decl.
	* src/abg-ir.cc (class_decl::add_member_function): Transform the
	definition of this overload into ...
	(class_or_union::add_member_function): ... this one.  Make sure
	that when setting the virtual-ness attributes of the member
	function, we are effectively looking at the a function that is a
	member of a class.
	(function_decl::clone): Do not assert that a member function is
	necessarily a member of a class_decl.  It can also a member of a
	union_decl!.  So, rather, assert that the scope of the member
	function is of type class_or_union.
	* tests/data/test-diff-pkg/tbb-2017-8.20161128.fc26.x86_64.rpm:
	New test input RPM.
	* tests/data/test-diff-pkg/tbb-2017-9.20170118.fc27.x86_64.rpm:
	* tests/data/test-diff-pkg/tbb-debuginfo-2017-8.20161128.fc26.x86_64.rpm:
	Likewise.
	* tests/data/test-diff-pkg/tbb-debuginfo-2017-9.20170118.fc27.x86_64.rpm:
	Likewise.
	* tests/data/test-diff-pkg/tbb-2017-8.20161128.fc26.x86_64--tbb-2017-9.20170118.fc27.x86_64.txt:
	New reference test output.
	* tests/data/Makefile.am: Add the new test input RPMs to the
	source distribution.
	* tests/test-diff-pkg.cc (in_out_specs): Take the new input tests
	above into account.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-03-07 11:50:56 +01:00
Dodji Seketeli
bebe3583eb Consider file path when sorting virtual member functions
When two virtual member functions have the same index, same ELF
symbol, same pretty representation and only differ from their source
file paths, then this patch takes the source path into account in the
sorting.

Otherwise, this breaks the runtestreaddwarf test on EL6.

	* src/abg-ir.cc (virtual_member_function_less_than::operator()):
	Take the file path into account in the sorting.
	* tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi:
	Adjust.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-03-03 14:06:34 +01:00
Dodji Seketeli
d65585a772 Fix virtual members sorting to unbreak the build on EL6
When two virtual members functions have the same virtual index, the
same pretty representation, and one of them has no ELF symbols, then
they might be sorted in a way or in an other.  This sorting hazard
breaks the runtestreaddwarf test on EL6.

This patch addresses that to make the virtual member function that has
no ELF symbol to come before the one with an ELF symbol.

Also, it turned out that runtestannotate is broken on EL6 too because
we are trying to demangle c++11-mangled symbols in there, and the
demangler (which is C++<11 only) on that platform doesn't really like
that.  So this patch removes the tests in which there are c++11 symbols
that we try to demangle.

	* src/abg-ir.cc (virtual_member_function_less_than::operator()):
	Update comment.  When two virtual functions have the same virtual
	index and one of them has no ELF symbol, then that function is
	less than the one with an ELF symbol.
	* tests/data/Makefile.am: Remove
	test-annotate/{test9-pr18818-clang.so.abi, test11-pr18828.so.abi,
	test12-pr18844.so.abi, test16-pr18904.so.abi,
	test22-pr19097-libstdc++.so.6.0.17.so.abi}.
	* tests/data/test-annotate/test10-pr18818-gcc.so.abi: Remove.
	* tests/data/test-annotate/test11-pr18828.so.abi: Likewise.
	* tests/data/test-annotate/test12-pr18844.so.abi: Likewise.
	* tests/data/test-annotate/test16-pr18904.so.abi: Likewise.
	* tests/data/test-annotate/test22-pr19097-libstdc++.so.6.0.17.so.abi:
	Likewise.
	* tests/test-annotate.cc (in_out_specs):  Remove those tests above
	which input files have been removed.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-03-03 12:56:44 +01:00
Dodji Seketeli
bca7132b47 Make Helgrind suppressions less specific to libgcc_s version
* tests/test-valgrind-suppressions.supp: Make Helgrind
	suppressions less specific to libgcc_s version.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-03-02 12:49:52 +01:00
Dodji Seketeli
3df69aa10e More Helgrind suppressions
* tests/test-valgrind-suppressions.supp: More specific suppressions.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-03-02 12:29:38 +01:00
Dodji Seketeli
70a476bd34 Silence Helgrind reports about exception stack unwinding
* tests/test-valgrind-suppressions.supp: Silence Helgrind reports
	about exception stack unwinding.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-03-02 11:55:30 +01:00
Dodji Seketeli
5867425971 Make the helgrind suppressions less specific
* tests/test-valgrind-suppressions.supp: Make the ostream writting
	suppressions be less specific so that they can apply to all the
	related false positives.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-03-01 16:17:31 +01:00
Dodji Seketeli
0ebb20c6c2 Move test-read-dwarf.cc to abigail::workers
Moving this test away from using pthreads directly to use
abigail::workers.

This patch also updates the valgrind suppression file to suppress some
Helgrind false positives.  Those are due to:
  - libstdc++ apparently having some benign data races when emitting
  data to ostream.  This seems related to some facet manipulation that
  happen at that point.
  - some benign data race in some elfutils functions.

	* tests/test-read-dwarf.cc (iospec, spec_lock, write_lock)
	(out_abi_base, in_elf_base, in_abi_base): Remove these global
	variables.
	(handle_in_out_spec): Remove this.
	(struct test_task): Write this task that does what
	handle_in_out_spec was doing.
	(test_task_sptr): Define new typedef.
	(main): Remove the pthreads artifacts.  Use the new test_task type
	along with the abigail::workers interface.
	* tests/test-valgrind-suppressions.supp: Add more helgrind
	suppressions for ostream writting false positives.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-03-01 14:34:58 +01:00
Dodji Seketeli
474cf47cd1 Display the command that failed the runtestfedabipkgdiff.py test
* tests/runtestfedabipkgdiff.py.in (run_fedabipkgdiff_tests): When
	A test fails, display the fedabipkgdiff command that triggered the failure.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-02-28 16:38:48 +01:00
Dodji Seketeli
f6bca156ca Make abipkgdiff.cc use the abigail::workers interface
With this patch, the code of abipkgdiff.cc doesn't use the pthreads
API directly anymore.  Rather, it uses the higher level "Workers
Queue" API provided by the abigail::workers namespace.

The main benefits are:

 - better code readability and maintainability.  The code base doesn't
   have any global variable anymore.  This is going to be helpful when
   adding new features to the abipkgdiff.cc code base.

 - faster code.  The tests/runtestdiffpkg test program executes on ~
   17s without the patch, and on ~ 11s with the patch on my old X220
   laptop.

	* tools/abipkgdiff.cc: Remove ftw.h, pthread.h, unistd.h, add
	fts.h and abg-workers.h.
	(verbose, elf_file_paths_tls_key, reports_map, env_map, map_lock)
	(arg_lock, prog_options): Remove all these global variables.
	(struct package_descriptor): Remove this type.
	(pthread_routine_extract_package)
	(first_package_tree_walker_callback_fn)
	(second_package_tree_walker_callback_fn, pthread_routine_compare)
	(pthread_join, pthread_routine_extract_pkg_and_map_its_content):
	Remove these functions.
	(options::{num_workers, verbose}): Define new data members.
	(options::options): Initialize the new verbose and num_workers data members.
	(package::erase_extraction_directory)
	(erase_created_temporary_directories_parent): Take the program
	options in parameter.  Don't use the global verbose variable
	anymore.
	(package::erase_extraction_directories)
	(erase_created_temporary_directories, extract_package): Take the
	program options in parameter.
	(extract_rpm, extract_deb, extract_tar): Likewise.  And don't use
	the global verbose variable anymore.
	(compare): Don't use the global verbose variable anymore.  Use the
	new compare_task type along with the abigail::workers::queue type.
	(pkg_extraction_task, pkg_prepare_task, compare_task)
	(comparison_done_notify): Define new classes.
	(maybe_update_vector_of_package_content): Define new static
	function.
	(create_maps_of_package_content): Don't take the ftw_cp_type
	anymore.  Don't use the global verbose variable anymore.  Use the
	fts_{open,read,close} functions, rather than the ftw one.
	(extract_package_and_map_its_content): Don't use pthreads anymore.
	Use the new pkg_extraction_task type created along with the
	abigail::workers::queue type.
	(prepare_packages): Don't use pthreads anymore.  Use the new
	pkg_prepare_task type along with the abigail::workers::queue type.
	(elf_size_is_greater): Adjust to use
	abigail::workers::queue::tasks, rather than the previous
	compaer_args_sptr type.
	(parse_command_line): Adjust to stop using the global verbose
	variable.
	(main): Remove use of global variables prog_options and also the
	packages variable.
	* tests/data/test-diff-pkg/dbus-glib-0.104-3.fc23.x86_64--dbus-glib-0.104-3.fc23.armv7hl-report-0.txt:
	Adjust.
	* tests/data/test-diff-pkg/dirpkg-0-report-0.txt: Likewise.
	* tests/data/test-diff-pkg/test-dbus-glib-0.80-3.fc12.x86_64-report-0.txt:
	Likewise.
	* tests/data/test-diff-pkg/test-rpm-report-0.txt: Likewise.
	* tests/data/test-diff-pkg/test-rpm-report-1.txt: Likewise.
	* tests/data/test-diff-pkg/test-rpm-report-2.txt: Likewise.
	* tests/data/test-diff-pkg/test-rpm-report-3.txt: Likewise.
	* tests/data/test-fedabipkgdiff/test0-from-fc20-to-fc23-dbus-glib-report-0.txt:
	Likewise.
	* tests/data/test-fedabipkgdiff/test1-from-fc20-to-dbus-glib-0.106-1.fc23.x86_64-report-0.txt:
	Likewise.
	* tests/data/test-fedabipkgdiff/test2-dbus-glib-0.100.2-2.fc20--dbus-glib-0.106-1.fc23-report-0.txt:
	Likewise.
	* tests/data/test-fedabipkgdiff/test3-dbus-glib-0.100.2-2.fc20.i686--dbus-glib-0.106-1.fc23.i686-report-0.txt:
	Likewise.
	* tests/data/test-fedabipkgdiff/test4-glib-0.100.2-2.fc20.x86_64.rpm-glib-0.106-1.fc23.x86_64.rpm-report-0.txt:
	Likewise.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-02-27 10:15:33 +01:00
Dodji Seketeli
8327d61b66 Add a "make check-valgrind-helgrind-recursive" target
* tests/Makefile.am (check-valgrind-helgrind-recursive): New
	target to run the tests recursively under the control of
	Valgrind's Helgrind tool.
	* tests/test-valgrind-suppressions.supp: Update this suppression
	file with suppressions for Helgrind.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-02-27 10:01:06 +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
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
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
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
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
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
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
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
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
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
e95f8cbac2 Update tests/data/test-diff-pkg/libICE-1.0.6-1.el6.x86_64.rpm--libICE-1.0.9-2.el7.x86_64.rpm-report-0.txt
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-pkg test harness.

	* tests/data/test-diff-pkg/libICE-1.0.6-1.el6.x86_64.rpm--libICE-1.0.9-2.el7.x86_64.rpm-report-0.txt: Adjust.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-01-05 12:23:39 +01:00
Dodji Seketeli
772414848e Update tests/data/test-read-write/test27.xml
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-write test harness.

	* tests/data/test-read-write/test27.xml: Adjust.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-01-05 12:22:54 +01:00
Ondrej Oprala
ee00b09f21 Properly report missing files for abipkgdiff
Currently, if abipkgdiff is given a path to a nonexistent file,
it propagates all the way until package classification
and ends up being reported as "PKG should be a valid package file",
which doesn't hint it's not there at all.

        * tools/abipkgdiff.cc: (class options): Add the "nonexistent_file" flag
        (parse_command_line): Check if the files given exist.
        (main): Check the nonexistent_file flag. If any of the input
        files don't exist, report it and exit. Also, for present and future test
        uniformity, only show the base names of the packages when using their
        names in error output.
        * tests/test-diff-pkg.cc: Add a new regression test.
        * tests/data/test-diff-pkg/test-nonexistent-report-0.txt: The
        expected output of the above regression test.
        * tests/data/Makefile.am: Add the above file to the list.

Signed-off-by: Ondrej Oprala <ondrej.oprala@gmail.com>
2016-12-15 20:16:01 +01:00
Ondrej Oprala
125c0c3c7c Bug 19272 - abipkgdiff doesn't report arch change
Previously, architecture change wasn't included in the incompatible
changes check.

This patch makes corpus_diff::has_incompatible_changes take
architecture change into account.

It turns out corpus_diff::has_net_changes wasn't taking architecture
or soname change into account either.  This patch fixes that as well.

The patch also updates abicompat.cc to make it use
corpus_diff::has_net_changes() and
corpus_diff::has_incompatible_changes(), instead of open-coding these
member functions.

	* src/abg-comparison.cc (corpus_diff::has_incompatible_changes):
	The architecture change into account.
	(corpus_diff::has_net_changes): Take architecture and soname
	changes into account.
	* tools/abicompat.cc (perform_compat_check_in_normal_mode): Use
	corpus_diff::{has_net_changes, has_incompatible_changes}.
	* tests/data/test-diff-pkg/dbus-glib-0.104-3.fc23.armv7hl.rpm: New
	test input.
	* tests/data/test-diff-pkg/dbus-glib-0.104-3.fc23.x86_64--dbus-glib-0.104-3.fc23.armv7hl-report-0.txt:
	New test reference output.
 	* tests/data/Makefile.am: Add the new test material above to
	source distribution.
	* tests/test-diff-pkg.cc (in_out_spec): Compare the new package
	above against an x86_64 one.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-12-12 19:55:23 +01:00
Chenxiong Qi
783099cd25 Bug 20380 - Compare two local RPMs
Bug 20270 is also fixed.

This patch allows developer to compare two local RPMs in form

    fedabipkgdiff some/place/foo.rpm another/place/bar.rpm

But, network is still needed to talk with Koji.

This patch also introduces new terms for libabigail, that is the
subject, ancillary package, and comparison half. Subject represents a
package that is subject of the ABI comparison, a subject could be a RPM
and maybe it would be a DEB or some other kind of "package". A subject
may have several ancillary packages that are used to compare the
subject.  Generally, a subject may have devel, debuginfo, or both.

	* configure.ac: add dependent mimetype module.
	* doc/manuals/fedabipkgdiff.rst: Update to add document for the
	new use case of comparing two local RPMs.
	* tests/data/Makefile.am: Include new RPMs for tests.
	* tests/data/test-fedabipkgdiff/dbus-glib/dbus-glib-0.100.2-2.fc20.x86_64.rpm:
	New RPM for running test.
	* tests/data/test-fedabipkgdiff/dbus-glib/dbus-glib-0.106-1.fc23.x86_64.rpm:
	Likewise.
	* tests/data/test-fedabipkgdiff/nss-util/nss-util-3.12.6-1.fc14.x86_64.rpm:
	Likewise.
	* tests/data/test-fedabipkgdiff/nss-util/nss-util-3.24.0-2.0.fc25.x86_64.rpm:
	Likewise.
	* tests/data/test-fedabipkgdiff/nss-util/nss-util-devel-3.24.0-2.0.fc25.x86_64.rpm:
	Likewise.
	* tests/data/test-fedabipkgdiff/test4-glib-0.100.2-2.fc20.x86_64.rpm-glib-0.106-1.fc23.x86_64.rpm-report-0.txt:
	Rename filename by adding .rpm extension.
	* tests/data/test-fedabipkgdiff/test5-same-dir-dbus-glib-0.100.2-2.fc20.x86_64--dbus-glib-0.106-1.fc23.x86_64-report-0.txt:
	New reference output for testing comparing local RPMs.
	* tests/data/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:
	New reference output for testing comparison without non-existent
	debuginfo or development package.
	* tests/runtestfedabipkgdiff.py.in (FEDABIPKGDIFF_TEST_SPECS):
	Rename filename for test4. Add two new test cases.
	(run_fedabipkgdiff_tests): Remove semicolon and trailing
	whitespaces.
	(main): Likewise.
	(ensure_output_dir_created): Likewise.
	* tools/fedabipkgdiff: Require some new modules.
	Fix of return code.
	(PkgInfo): Renamed to ComparisonHalf.
	(match_nvr): New method to determine if a string matches format
	of N-V-R.
	(match_nvra): New method to determine if a string matches format
	of N-V-R.A.
	(is_rpm_file): New method to guess if a file is a RPM file.
	(RPM.is_peer): New method to determine if current RPM is a peer
	of another.
	(RPM.filename): Use Koji module API to construct the filename.
	(RPM.nvra): Get nvra from filename instead of constructing
	manually that is duplicated with Koji module API.
	(RPMCollection): New class to represent a set of RPMs.
	(generate_pkg_info_pair_for_abipkgdiff): New method working as a
	generator to yeild comparison halves for running abipkgdiff.
	(Brew.getRPM): Fix string format with incorrect argument.
	(Brew.select_rpms_from_a_build): Return instance of
	RPMCollection.
	(abipkgdiff): If there is no debuginfo or development package,
	just ignore it and leave a warning. If --error-on-warning is
	specified, raise an exception instead. Arguments are modified
	to represent the new name ComparisonHalf, and relative docstring
	is also updated.
	(magic_construct): Removed.
	(run_abipkgdiff): Rewrite.
	(make_rpms_usable_for_abipkgdiff): Removed.
	(diff_local_rpm_with_latest_rpm_from_koji): Rewrite by using
	RPMCollection.
	(diff_latest_rpms_based_on_distros): Likewise.
	(diff_two_nvras_from_koji): Likewise.
	(diff_from_two_rpm_files): New method to compare two local RPMs.
	(build_commandline_args_parser): Add new option
	--error-on-warning.
	(main): Add support to compare local RPMs.

Signed-off-by: Chenxiong Qi <cqi@redhat.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-12-12 15:21:10 +01:00
Dodji Seketeli
d7faae38f6 Fix aborting when reading .foo symbols from a ppc64 binary
On ppc64, the value of a function symbol is *usually* the pointer to
the function.  That function pointer value refers to an index inside
the ".opd" (Official Procedure Descriptor) section.  That section is a
record of tripplets values.  One of these values is the address of the
entry point of the function.  A debug information entry for a
function, in DWARF, refers to the entry point of the function; not to
the function pointer address.

So libabigail builds a table that associates a function entry point
address to its function pointer address.

So, if a function is named "foo", it has an entry in the symbol table
for the symbol name "foo"; the value of that symbol is the function
pointer address of foo, which refers to an offset in the ".opd"
section.

But then it turns out that there is also going to be an entry in the
symbol table for an artificial symbol named ".foo".  Pleast note the
dot before the suffix "foo".  The value of the ".foo" symbol is the
address of the entry point of the function "foo"; it's an address in
the ".text" section this time.

Libabigail's ELF symbols reading code was (wrongly) expecting all
entries in the symbol table that refer to function to have values that
are offset in the ".opd" section.  It wasn't expecting the ".foo"
symbols whose value are an address in the ".text" section.

This patch fixes the ELF symbol reading code to make it be aware of
the ".foo" symbols too.

	* abg-dwarf-reader.cc (read_context::find_opd_section): Fix
	comment.
	(read_context::load_symbol_maps): If for a given function entry
	point (that we got by looking at the ".opd" section for a given
	function pointer value) we already had an entry in the
	function_entry_address -> symbol, maybe it means that the previous
	entry that we had was from an entry in the symbol table which
	value was directly the entry point address of a function.  In that
	case, if the name of the symbol is "foo", the name of the symbol
	which value is directly the entry point address is ".foo".  What
	we do in this case is that we just keep the reference to the "foo"
	symbol in the function_entry_address -> symbol map.
	(read_context::address_is_in_opd_section): Define new member
	function.
	* tests/data/test-diff-pkg/gmp-4.3.1-10.el6.ppc64.rpm: New test input.
	* tests/data/test-diff-pkg/gmp-4.3.1-7.el6_2.2.ppc64.rpm: Likewise.
	* tests/data/test-diff-pkg/gmp-debuginfo-4.3.1-10.el6.ppc64.rpm: Likewise.
	* tests/data/test-diff-pkg/gmp-debuginfo-4.3.1-7.el6_2.2.ppc64.rpm: Likewise.
	* tests/data/test-diff-pkg/gmp-4.3.1-7.el6_2.2.ppc64--gmp-4.3.1-10.el6.ppc64-report-0.txt:
	New test reference output.
	* tests/data/Makefile.am: Add the new test input and reference
	output to source distribution.
	* tests/test-diff-pkg.cc (in_out_specs): Add the new test inputs
	and reference output to the set of inputs that are compared.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-12-09 01:07:05 +01:00
Dodji Seketeli
5ed0e40bfd Bug 20887 - Show relative change of offsets
Until now, an offset change is reported by showing the old and new
offsets of the data member that changed.

This patch adds the string "(by +N bits)" with 'N' being the number of
bits by which the offset of the data member was increased, or "(by -N
bits) if the offset of the data member was decreased of N bits.

The patch also emits a string that says "size hasn't changed" if the
size of the structure did not change.

This can be disabled by a new --no-show-relative-offset-changes
option.

	* doc/manuals/abidiff.rst: Document the new
	--no-show-relative-offset-changes.
	* doc/manuals/abipkgdiff.rst: Likewise.
	* include/abg-comparison.h
	(diff_context::show_relative_offset_changes): New accessors.
	* include/abg-ir.h ({set,get}_data_member_offset): Return uint64_t
	instead of the less portable size_t.
	* src/abg-comparison.cc
	(diff_context::priv::show_relative_offset_changes_): New data
	member.
	(dif_context::show_relative_offset_changes): Define accessor.
	(maybe_show_relative_offset_change): Define new function.
	(represent): In the overload for var_diff, call the new
	maybe_show_relative_offset_change.
	(report_size_and_alignment_changes):  If the size of the type
	didn't change then say it now.
	* src/abg-ir.cc (set_data_member_offset, get_data_member_offset):
	Take or return a uint64_t instead of a size_t.
	* tools/abidiff.cc (options::show_relative_offset_changes): New
	data member.
	(options::options): Initialize it.
	(display_usage): Display help string for the new
	--no-show-relative-offset-changes.
	(parse_command_line): Parse the new
	--no-show-relative-offset-changes options.
	(set_diff_context_from_opts): Set the
	"show-relative-offset-changes" flag according to the new option.n
	* tools/abipkgdiff.cc (options::show_relative_offset_changes): New
	data member.
	(options::options): Initialize it.
	(display_usage): Add help string for the new
	--no-show-relative-offset-changes option.
	(set_diff_context_from_opts): Set the
	"show-relative-offset-changes" flag according to the new option.
	(parse_command_line): Parse the new command line option.
	* tests/data/test-diff-dwarf/test40-report-0.txt: Add new
	reference output.
	* tests/data/test-diff-dwarf/test40-v0.c: Source code of the first
	test binary.
	* tests/data/test-diff-dwarf/test40-v1.c: Source code of the
	second test binay.
	* tests/data/test-diff-dwarf/libtest40-v0.so: New first test binary.
	* tests/data/test-diff-dwarf/libtest40-v1.so: New second test binary.
	* tests/test-diff-dwarf.cc (in_out_spec): Add the new test
	binaries above to the set of binaries that are compared.
	* tests/data/Makefile.am: Add the new test material to source
	distribution.
	* tests/data/test-abicompat/test7-fn-changed-report-0.txt: Adjust.
	* tests/data/test-abidiff/test-PR18791-report0.txt: Likewise.
	* tests/data/test-abidiff/test-enum0-report.txt: Likewise.
	* tests/data/test-abidiff/test-enum1-report.txt: Likewise.
	* tests/data/test-abidiff/test-struct1-report.txt: Likewise.
	* tests/data/test-diff-dwarf/test0-report.txt: Likewise.
	* tests/data/test-diff-dwarf/test1-report.txt: Likewise.
	* tests/data/test-diff-dwarf/test10-report.txt: Likewise.
	* tests/data/test-diff-dwarf/test11-report.txt: Likewise.
	* tests/data/test-diff-dwarf/test13-report.txt: Likewise.
	* tests/data/test-diff-dwarf/test15-enum-report.txt: Likewise.
	* tests/data/test-diff-dwarf/test27-local-base-diff-report.txt: Likewise.
	* tests/data/test-diff-dwarf/test32-fnptr-changes-report-0.txt: Likewise.
	* tests/data/test-diff-dwarf/test33-fnref-changes-report-0.txt: Likewise.
	* tests/data/test-diff-dwarf/test38-union-report-0.txt: Likewise.
	* tests/data/test-diff-dwarf/test4-report.txt: Likewise.
	* tests/data/test-diff-dwarf/test5-report.txt: Likewise.
	* tests/data/test-diff-dwarf/test6-report.txt: Likewise.
	* tests/data/test-diff-dwarf/test8-report.txt: Likewise.
	* tests/data/test-diff-filter/test0-report.txt: Likewise.
	* tests/data/test-diff-filter/test01-report.txt: Likewise.
	* tests/data/test-diff-filter/test1-report.txt: Likewise.
	* tests/data/test-diff-filter/test13-report.txt: Likewise.
	* tests/data/test-diff-filter/test16-report-2.txt: Likewise.
	* tests/data/test-diff-filter/test16-report.txt: Likewise.
	* tests/data/test-diff-filter/test17-0-report.txt: Likewise.
	* tests/data/test-diff-filter/test17-1-report.txt: Likewise.
	* tests/data/test-diff-filter/test18-report.txt: Likewise.
	* tests/data/test-diff-filter/test19-enum-report-1.txt: Likewise.
	* tests/data/test-diff-filter/test2-report.txt: Likewise.
	* tests/data/test-diff-filter/test23-redundant-fn-parm-change-report-0.txt:
	Likewise.
	* tests/data/test-diff-filter/test24-compatible-vars-report-1.txt:
	Likewise.
	* tests/data/test-diff-filter/test25-cyclic-type-report-0.txt:
	Likewise.
	* tests/data/test-diff-filter/test25-cyclic-type-report-1.txt:
	Likewise.
	* tests/data/test-diff-filter/test26-qualified-redundant-node-report-0.t:
	Likewise.xt
	* tests/data/test-diff-filter/test26-qualified-redundant-node-report-1.txt:
	Likewise.
	* tests/data/test-diff-filter/test27-redundant-and-filtered-children-nodes-report-1.txt:
	Likewise.
	* tests/data/test-diff-filter/test27-redundant-and-filtered-children-nodes-report-2.txt:
	Likewise.
	* tests/data/test-diff-filter/test29-finer-redundancy-marking-report-0.txt:
	Likewise.
	* tests/data/test-diff-filter/test3-report.txt: Likewise.
	* tests/data/test-diff-filter/test30-pr18904-rvalueref-report0.txt:
	Likewise.
	* tests/data/test-diff-filter/test30-pr18904-rvalueref-report1.txt:
	Likewise.
	* tests/data/test-diff-filter/test31-pr18535-libstdc++-report-0.txt:
	Likewise.
	* tests/data/test-diff-filter/test31-pr18535-libstdc++-report-1.txt:
	Likewise.
	* tests/data/test-diff-pkg/libICE-1.0.6-1.el6.x86_64.rpm--libICE-1.0.9-2.el7.x86_64.rpm-report-0.txt: Likewise.
	* tests/data/test-diff-pkg/libsigc++-2.0-0c2a_2.4.0-1_amd64--libsigc++-2.0-0v5_2.4.1-1ubuntu2_amd64-report-0.txt: Likewise.
	* tests/data/test-diff-pkg/tbb-4.1-9.20130314.fc22.x86_64--tbb-4.3-3.20141204.fc23.x86_64-report-0.txt: Likewise.
	* tests/data/test-diff-pkg/tbb-4.1-9.20130314.fc22.x86_64--tbb-4.3-3.20141204.fc23.x86_64-report-1.txt: Likewise.
	* tests/data/test-diff-suppr/test0-type-suppr-report-0.txt: Likewise.
	* tests/data/test-diff-suppr/test0-type-suppr-report-3.txt: Likewise.
	* tests/data/test-diff-suppr/test0-type-suppr-report-5.txt: Likewise.
	* tests/data/test-diff-suppr/test0-type-suppr-report-7.txt: Likewise.
	* tests/data/test-diff-suppr/test1-typedef-suppr-report-0.txt: Likewise.
	* tests/data/test-diff-suppr/test1-typedef-suppr-report-2.txt: Likewise.
	* tests/data/test-diff-suppr/test10-changed-parm-c-report-0.txt: Likewise.
	* tests/data/test-diff-suppr/test2-struct-suppr-report-0.txt: Likewise.
	* tests/data/test-diff-suppr/test23-alias-filter-report-0.txt: Likewise.
	* tests/data/test-diff-suppr/test23-alias-filter-report-2.txt: Likewise.
	* tests/data/test-diff-suppr/test3-struct-suppr-report-0.txt: Likewise.
	* tests/data/test-diff-suppr/test3-struct-suppr-report-1.txt: Likewise.
	* tests/data/test-diff-suppr/test3-struct-suppr-report-2.txt: Likewise.
	* tests/data/test-diff-suppr/test30-report-0.txt: Likewise.
	* tests/data/test-diff-suppr/test4-local-suppr-report-0.txt: Likewise.
	* tests/data/test-diff-suppr/test4-local-suppr-report-1.txt: Likewise.
	* tests/data/test-diff-suppr/test5-fn-suppr-report-0.txt: Likewise.
	* tests/data/test-diff-suppr/test5-fn-suppr-report-1.txt: Likewise.
	* tests/data/test-diff-suppr/test5-fn-suppr-report-2.txt: Likewise.
	* tests/data/test-diff-suppr/test5-fn-suppr-report-3.txt: Likewise.
	* tests/data/test-diff-suppr/test5-fn-suppr-report-4.txt: Likewise.
	* tests/data/test-diff-suppr/test5-fn-suppr-report-5.txt: Likewise.
	* tests/data/test-diff-suppr/test6-fn-suppr-report-0-1.txt: Likewise.
	* tests/data/test-diff-suppr/test6-fn-suppr-report-0.txt: Likewise.
	* tests/data/test-diff-suppr/test6-fn-suppr-report-1.txt: Likewise.
	* tests/data/test-diff-suppr/test6-fn-suppr-report-2.txt: Likewise.
	* tests/data/test-diff-suppr/test6-fn-suppr-report-3.txt: Likewise.
	* tests/data/test-diff-suppr/test7-var-suppr-report-0.txt: Likewise.
	* tests/data/test-diff-suppr/test7-var-suppr-report-1.txt: Likewise.
	* tests/data/test-diff-suppr/test7-var-suppr-report-2.txt: Likewise.
	* tests/data/test-diff-suppr/test7-var-suppr-report-3.txt: Likewise.
	* tests/data/test-diff-suppr/test7-var-suppr-report-4.txt: Likewise.
	* tests/data/test-diff-suppr/test7-var-suppr-report-7.txt: Likewise.
	* tests/data/test-diff-suppr/test7-var-suppr-report-8.txt: Likewise.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-12-02 21:29:28 +01:00
Dodji Seketeli
4f9d682d0b Rename tests/update-test-read-dwarf-output.py
Renamed tests/update-test-read-dwarf-output.py into
tests/update-test-output.py as it can be used for all tests that emit
an output and compare it against a reference output.

	* tests/update-test-output.py: renamed
	tests/update-test-read-dwarf-output.py into this.  Update its
	comments.  Make this script executable.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-12-02 12:59:32 +01:00
Dodji Seketeli
b4fc841a73 Add tests/data/test-diff-suppr/test33-report-0.txt to tarball
I forgot to add the file testing file
tests/data/test-diff-suppr/test33-report-0.txt to
tests/data/Makefile.am.  This makes the test runtestdiffsupp fail
under 'make distcheck'.

Fixed thus.

	* tests/data/Makefile.am: Add test-diff-suppr/test33-report-0.txt.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-11-30 11:01:38 +01:00
Dodji Seketeli
e861bd3368 Introduce on-the-fly type canonicalization
During canonicalization of a type T, when T is structurally compared
to an already canonicalized type C, it can happen that
non-canonicalized sub-types of T are structurally compared again and
again to canonicalized sub-types of C.

This patch introduces a new optimization or those cases: on-the-fly
type canonicalized.

That means, if a not-yet-canonicalized sub-type S of the type T being
canonicalized structurally compares equal to a canonicalized sub-type,
then the canonical type of S is said to be the canonical type of the
canonicalized sub-type.  So sub-type S is canonicalized, on-the-fly,
during canonicalization of type T.

This considerably speeds up the canonicalization process while doing
"abidiff vmlinux vmlinux".  It goes from taking forever to taking 45
seconds on a non-optimized build.

	* include/abg-ir.h (environment::do_on_the_fly_canonicalization):
	Declare new member functions.
	({type_base, function_type}::priv_): Make this public so that
	static non-member functions defined in abg-ir.cc can access it.
	* src/abg-ir.cc
	(environment::priv::do_on_the_fly_canonicalization_): New data
	member.
	(environment::priv::priv): Initialize it.
	(environment::do_on_the_fly_canonicalization): Define new member
	functions.
	(type_base::get_canonical_type_for): Trigger on-the-fly
	canonicalization during comparison of the type being canonicalized
	and an already canonicalized type.
	(types_are_being_compared, maybe_propagate_canonical_type): Define
	new static functions.
	(equals): In overloads for class_decl and function_type, call
	maybe_propagate_canonical_type when the two types compare equal.
	* tests/data/test-diff-pkg/tbb-4.1-9.20130314.fc22.x86_64--tbb-4.3-3.20141204.fc23.x86_64-report-0.txt:
	Adjust.
	* tests/data/test-read-dwarf/test9-pr18818-clang.so.abi: Likewise.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-11-29 17:07:28 +01:00
Dodji Seketeli
bd3fe4c748 Fix pretty representation of array types
It turned out we were wrongly emitting the pretty representation of
array types in two cases:

  1/ in case of qualified array types: a const array of string type
  was being pretty-represented as: "const string[]" instead of
  "string[] const".

  2/ in case of array with an empty sub-range DIE; that is a sub-range
  DIE with no attribute at all.  For instance an array of char with an
  empty sub-range DIE was being represented as: "char", instead of
  "char[]".

This patch fixes 1 and 2.  It also updates numerous test reference
output files.

	* include/abg-ir.h (array_type_def::is_infinite): Fix indentation.
	* src/abg-ir.cc (qualified_type_def::build_name): An empty set of
	sub-ranges for a vector is represented by "[]".
	(array_type_def::is_infinite): If a vector has no sub-range, that
	means it has an infinite size.  Adjust comment.
	* tests/data/test-diff-filter/test33-report-0.txt: Adjust.
	* 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.
	* 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/test14-pr18893.so.abi: Adjust.
	* tests/data/test-read-dwarf/test19-pr19023-libtcmalloc_and_profiler.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>
2016-11-29 16:51:19 +01:00
Dodji Seketeli
cfaa7d42b6 Implement de-duplication for types and decls at DWARF loading time
Many types and decls are redefined in every translation unit that make
up an ELF binary.  This patch detects that a DIE represents a type or
decl that has already been defined in the current corpus and so will
not create a new internal representation for it.

The patch defines facilities to build the pretty representation of a
type or decl.  It's by looking at the pretty representation of a DIE
that the patch detects that a different DIE has already defined the
same type or decl.

The patch also fixes detection of the const-ness of member functions
as there were many cases where const member functions were not
recognized as const.  This fix makes it so that the pretty
representation of the DIE of said member functions match the pretty
representation of their internal representation, as far as the
const-ness is concerned.

One bit of infrastructure change that is used by the const-ness fix is
that method_type now carries const-ness.  So a method_decl that has a
const method_type is going to be const itself.

	* include/abg-ir.h (method_type::priv_): Introduce new pimpl
	pointer here.
	(method_type::class_type_): Move this into the pimpl idiom.
	(method_type::method_type): Take a new is_const flag.
	(method_type::get_class_type): Make this method out-of-line.
	(method_type::{s,g}et_is_const): Declare new member functions.
	(get_method_type_name): Declare this function as a friend of
	the method_type type.
	* src/abg-dwarf-reader.cc: Include the new abg-ir-priv.h and
	abg-corpus-priv.h.
	(typedef die_tu_map_type): Fix comment.
	(typedef die_istring_map_type): New typedef.
	(class read_context::die_source_dependant_container_set): New
	class template.
	(read_context::{die_qualified_name_maps_, die_pretty_repr_maps_,
	die_pretty_type_repr_maps_}): Define new data members.
	(read_context::{get_die_qualified_name, get_die_qualified_name,
	get_die_qualified_type_name, get_die_pretty_type_representation,
	get_die_pretty_representation, lookup_type_artifact_from_die,
	lookup_artifact_from_die, lookup_artifact_from_die_representation,
	associate_die_to_artifact_by_repr,
	associate_die_to_artifact_by_repr_internal,
	lookup_type_from_die}): Define new member functions.
	(read_context::lookup_type_from_die_offset): Fix comment.
	(get_parent_die, get_scope_die, die_is_decl)
	(die_is_namespace, die_is_unspecified, die_is_void_type)
	(die_is_pointer_type, die_is_reference_type)
	(die_is_pointer_or_reference_type, die_is_class_type)
	(die_has_object_pointer, die_this_pointer_from_object_pointer)
	(die_this_pointer_is_const, is_decl_tag)
	(die_object_pointer_is_for_const_method, die_is_at_class_scope)
	(die_name, die_qualified_type_name, die_qualified_decl_name)
	(die_qualified_name, die_qualified_type_name_empty)
	(die_return_and_parm_names_from_fn_type_die)
	(die_function_signature, die_peel_qual_ptr)
	(die_function_type_is_method_type, die_pretty_print_type)
	(die_pretty_print_decl, die_pretty_print)
	(build_subranges_from_array_type_die)
	(build_or_get_fn_decl_if_not_suppressed)
	(lookup_class_or_typedef_type)
	(lookup_class_typedef_or_enum_type_from_corpus)
	(is_function_for_die_a_member_of_class)
	(add_or_update_member_function): Define new static functions.
	(read_context::associate_die_to_decl): Call
	associate_die_to_artifact_by_repr.
	(read_context::{associate_die_to_type,
	schedule_type_for_late_canonicalization}): Take just one "die"
	parameter rather than taking a die offset and a die source; adjust
	accordingly.
	(maybe_canonicalize_type): Likewise.
	(finish_member_function_reading): Take a const reference to
	function_decl_sptr.
	(die_loc_and_name): Use the new die_name function.
	(die_is_type): Rename is_type_die into this.
	(build_type_decl): Take a new "where_offset" parameter.  Adjust.
	If a type of the same name as the one for the current DIE is is
	already present, do not create a new type; just return the
	already-existing one.
	(build_enum_type): Take a new "where_offset" parameter.  Adjust.
	(finish_member_function_reading): Pass two smart pointers by const
	reference.  Assert that the type of the member function is a
	method_type.  Some light cleanups.
	(add_or_update_class_type): Rename build_class_type_and_add_to_ir.
	If a DIE defining the same class has already been seen, then
	return that class; don't construct any other internal
	representation for the same class.  Better handle the updating of
	member data and functions.  Do not duplicate member types.
	(build_qualified_type, build_pointer_type_def)
	(build_reference_type): Support de-duplication here.
	(build_function_type): Likewise.  Support detection and building
	of method type.  This also supports *const* method type building.
	(build_array_type): Use the new
	build_subranges_from_array_type_die.
	(build_type_decl): Cleanup logic.
	(build_or_get_var_decl_if_not_suppressed): Renamed
	build_var_decl_if_not_suppressed into this.  Perform
	de-duplication for data members.
	(build_function_decl): Don't set an empty source location.  If the
	function type cannot be constructed, do not construct the function
	decl either.  Adjust.
	(build_ir_node_from_die): Adjust.  When building a function for a
	DW_TAG_subroutine_type DIE, use the new
	build_or_get_fn_decl_if_not_suppressed.
	* src/abg-ir.cc (translation_unit::bind_function_type_life_time):
	Fix comment.
	(strip_typedef): Adjust.
	(qualified_type_def::build_name): Set the prefix name of a the
	name of a noop qualifier to "noop-qual", just like what is done in
	the new die_qualified_name function.
	(struct method_type::priv): New priv type for the method_type
	class.
	(method_type::method_type): Take a new 'is_const' parameter.
	Adjust as the method_type is now pimpl'ed.
	(method_type::{get_class_type, set_is_const, get_is_const}):
	Define new member functions.
	(function_decl::get_pretty_representation_of_declarator): Better
	detecter of const-ness.
	(class_decl::insert_member_decl):  Better setting of the
	const-ness.
	(class_decl::method_decl::method_decl): Adjust.  Deduce the
	const-ness of the method_decl from the const-ness of its
	method_type.
	(copy_member_function): Adjust.
	(set_member_is_static): Do not assume a non-nil scope anymore
	because member_decl can now be scope-less, at least for a little
	while.
	* src/abg-reader.cc (push_decl_to_current_scope): Adjust.
	(build_function_decl): Style adjustment.  Adjust for method_type
	const-ness changes.
	(build_function_type): Likewise.  Also, support the new
	"method-class-id" property that flags a function type as being a
	method type.
	* src/abg-writer.cc (write_function_decl): Style fixes.
	(write_function_type): Likewise.  Emit a new "method-class-id"
	property for function type that is actually a method type.  That
	property's value is the id of the class of the method type.
	* tests/data/test-diff-dwarf-abixml/test0-pr19026-libvtkIOSQL-6.1.so.1.abi: Adjust.
	* tests/data/test-diff-dwarf/test0-report.txt: Adjust.
	* tests/data/test-diff-filter/test0-report.txt: Adjust.
	* tests/data/test-diff-filter/test01-report.txt: Adjust.
	* tests/data/test-diff-filter/test30-pr18904-rvalueref-report0.txt: Adjust.
	* tests/data/test-diff-filter/test30-pr18904-rvalueref-report1.txt: Adjust.
	* 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-diff-pkg/libICE-1.0.6-1.el6.x86_64.rpm--libICE-1.0.9-2.el7.x86_64.rpm-report-0.txt: Adjust.
	* tests/data/test-diff-pkg/libsigc++-2.0-0c2a_2.4.0-1_amd64--libsigc++-2.0-0v5_2.4.1-1ubuntu2_amd64-report-0.txt: Adjust.
	* tests/data/test-diff-pkg/tbb-4.1-9.20130314.fc22.x86_64--tbb-4.3-3.20141204.fc23.x86_64-report-0.txt: Adjust.
	* 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/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.
	* 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/test8-qualified-this-pointer.so.abi: Adjust.
	* tests/data/test-read-dwarf/test9-pr18818-clang.so.abi: Adjust.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-11-29 16:16:56 +01:00
Dodji Seketeli
ccdc44b3eb Setup per-corpus type maps indexed by type names
This patch creates per-corpus maps that associate, for a certain kind
of type, the fully qualified name of the type to the type.

So there is a map for class_decl, one for enum_type_decl, one for
type_decl, etc.

These maps are populated when a new type is added to its scope.

The patch defines overloads of the function
maybe_update_types_lookup_map() that update the right map, depending
on the kind of type we are looking at.

Note that there also is a map in each class that associates a
signature string to a member functions.  This is so that member
functions of a given class can be looked up by signature.

This is so that looking up a type becomes now much faster than having
to walk all the translation units of a corpus to find one.

Note that this patch is specifically part of the series of patches
that implements types and declarations de-duplication while reading
DWARF information.

The patch might slightly change the output of abi serialization or
comparison so it needs some adjustments of some test reference files.
That adjustment is not done here.  Rather, it's done at once in
another patch of the set.

	* include/abg-corpus.h (corpus::priv_): Make this public so that
	functions from outside of the class can access it.  These
	functions are meant to be used only by code that is *inside*
	libabigail.so, though.
	* src/abg-corpus-priv.h: New file.
	* src/abg-corpus.cc: Include the new abg-corpus-priv.h file.
	(struct regex_t_deleter): Move this to abg-sptr-utils.h.
	(build_sptr<regex_t>): Move the declaration of this function
	template specialization to abg-sptr-utils.h and its definition to
	abg-sptr-utils.cc.
	(typedef regex_t_sptrs_type, typedef str_var_ptr_map_type)
	(struct corpus::exported_decls_builder::priv, struct
	corpus::priv): Move these declarations to the new
	abg-corpus-priv.h.
	(maybe_update_types_lookup_map): Define overloads of this (one per
	kind of type).
	(lookup_{basic, class, enum, typedef, class_or_typedef,
	class_typedef_or_enum, qualified, pointer, reference, array,
	function}_type): Define new functions.
	* include/abg-ir.h (typedef istring_type_base_wptr_map_type)
	(typedef istring_type_or_decl_base_sptr_map_type): Declare new
	typedefs.
	(class_decl::find_member_function_from_signature): Declare new
	member function.
	* src/abg-ir.cc: Include the new abg-corpus-priv.h file.
	(maybe_update_types_lookup_map): Remove this initial function.
	There are now new overloads in abg-corpus.cc for it.
	(scope_decl::{add_member_decl, insert_member_decl}): Adjust.
	(class_decl::{set_is_declaration_only, find_member_function,
	add_member_function}): Adjust.
	(class_decl::find_member_function_from_signature): Define new
	member function.
	* include/abg-sptr-utils.h (struct regex_t_deleter): Declare new
	type.
	(build_sptr<regex_t>): New build function template
	specializations.
	* src/abg-sptr-utils.cc: New file.
	* src/Makefile.am: Add src/abg-sptr-utils.cc and
	src/abg-corpus-priv.h to the build system.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-11-29 16:16:43 +01:00
Dodji Seketeli
f27520d767 A suppressed diff node implies suppressing all equivalent nodes too
When a diff node N is suppressed (for instance, using the
--headers-dir{1,2} option of abidiff}, it's only that diff node that
is suppressed.  We forget to suppress diff nodes that are equivalent
to N.

Here is why we forget to suppress diff ndoes that are equivalent.

apply_suppressions walks the diff node graph to mark diff nodes as
suppressed.  But it does the walking by making sure each diff node's
*class of equivalence* is visited once.  This is not only a way to
prevent infinite loops while visiting the graph, but also an
optimization as it avoids walking two equivalent diff nodes.

But then it can happen that we forget to categorize some diff nodes
inside a given class of equivalence, even though we categorized some
others.

This patch makes it so that when a diff node inside a class of
equivalence is categorized as SUPPRESSED, the canonical diff node of
that class of equivalence is categorized as SUPPRESSED too.  That way,
to know if a diff node is suppressed, we just need to look at its
canonical diff node.

While doing this, I noticed that abidiff and abipkgdiff are not
dropping private types from libabigail's internal representation, even
though the Library now has that capability.  The patch fixes that.
But then the patch adds a --dont-drop-private-types option to abidiff
to avoid dropping those private types from the IR, so that regression
tests can make sure that a suppressed diff node implies suppression
all equivalent nodes too.

	* doc/manuals/abidiff.rst b/doc/manuals/abidiff.rst: Document the
	new --dont-drop-private-types option.
	* src/abg-comparison.cc (diff::is_filtered_out): If the canonical
	type was suppressed then the current diff node is filtered out.
	(suppression_categorization_visitor::visit_{begin,end}):
	Categorized the canonical node as SUPPRESSED if the current node
	is suppressed.
	* tools/abidiff.cc (options::drop_private_types): New data member.
	(options::options): Initialize it.
	(display_usage): Add new help string for the new
	--dont-drop-private-types option.
	(parse_command_line): Parse the new --dont-drop-private-types
	option.
	(set_suppressions): Generate suppression specification from header
	directories given in parameter and stick them to the read context.
	* tools/abipkgdiff.cc (compare): Likewise.
	* tests/data/test-diff-suppr/libtest34-v0.so: New test input.
	* tests/data/test-diff-suppr/libtest34-v1.so: Likewise.
	* tests/data/test-diff-suppr/test34-report-0.txt: New reference
	report.
	* tests/data/test-diff-suppr/test34-v0.c: Source code for the new
	test input.
	* tests/data/test-diff-suppr/test34-v1.c: Likewise.
	* tests/data/test-diff-suppr/test34-priv-include-dir-v0/test34-priv-include-v0.h:
	Likewise.
	* tests/data/test-diff-suppr/test34-priv-include-dir-v1/test34-priv-include-v1.h:
	Likewise.
	* tests/data/test-diff-suppr/test34-pub-include-dir-v0/test34-pub-include-v0.h:
	Likewise.
	* tests/data/test-diff-suppr/test34-pub-include-dir-v1/test34-pub-include-v1.h:
	Likewise.
	* tests/data/Makefile.am: Add new test input material above to
	source distribution.
	* tests/test-diff-suppr.cc (in_out_spec): Compare the two new test
	library provided.  Add --dont-drop-private-types to test30*.

signed-off-by: Dodji Seketeli <dodji@redhat.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-11-26 11:54:19 +01:00
Dodji Seketeli
eac363eb66 Forgot to consider libtest33-v{0,1}.so in test-diff-suppr.cc
I forgot the make test-diff-suppr.cc run over libtest33-v{0,1}.so even
though this test was added to the source distribution.  Fixed thus.

	* tests/data/test-diff-suppr/test33-report-0.txt: New refernce report.
	* tests/test-diff-suppr.cc (in_out_specs): Compare libtest33-v0.so
	and libtest33-v1.so.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-11-26 10:37:19 +01:00
Dodji Seketeli
09a15b6e60 Support reading data member offset from DW_AT_bit_offset
There are times where the DW_AT_data_member_location attribute is set
to zero and where the actual offset of the data member is the value of
the DW_AT_bit_offset.  This seems to be happening when a union type is
involved.

To get the offset of a data member, this patch makes us read the
DW_AT_bit_offset when it's present.  Otherwise, it gets the offset
from the DW_AT_data_member_location as we used to do.

In the passing the patch fixes the offset of base classes; the
nubmer of bytes value was what was being used, rather than the number
bits value.

	* src/abg-dwarf-reader.cc (die_member_offset): Better comments.
	Support reading the bit offset also from the DW_AT_bit_offset
	attribute when it's present.  Make sure this always returns a
	value in bits.
	(build_class_type_and_add_to_ir): No need to multiply (by 8) the
	value returned by die_member_offset anymore because it's now in
	bits directly.
	* tests/data/test-diff-filter/test30-pr18904-rvalueref-report0.txt: Adjust.
	* tests/data/test-diff-filter/test30-pr18904-rvalueref-report1.txt: Adjust.
	* tests/data/test-read-dwarf/test1.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/test19-pr19023-libtcmalloc_and_profiler.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>
2016-11-24 15:25:43 +01:00