Slava Barinov [Wed, 22 Mar 2017 09:53:41 +0000 (12:53 +0300)]
Merge branch 'master' into sandbox/vbarinov/multiarch
Slava Barinov [Wed, 22 Mar 2017 09:21:39 +0000 (12:21 +0300)]
Fix types in header to meet sources
Package fails to build for 32bit architectures since size_t is not 64 bits.
Make header consistent with source
* include/abg-fwd.h: fixed declarations.
(ir::set_data_member_offset) fixed argument type.
(ir::get_data_member_offset) fixed retval type.
Signed-off-by: Slava Barinov <v.barinov@samsung.com>
Slava Barinov [Wed, 22 Mar 2017 09:06:57 +0000 (12:06 +0300)]
Remove the ExclusiveArch tag to check build for arm
Signed-off-by: Slava Barinov <v.barinov@samsung.com>
Dodji Seketeli [Fri, 17 Mar 2017 08:02:19 +0000 (09:02 +0100)]
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>
Dodji Seketeli [Wed, 15 Mar 2017 15:15:37 +0000 (16:15 +0100)]
Fix data race on worker::queue::priv::bring_workers_down
When one thread calls queue::wait_to_execute_a_task and another calls
queue::priv::do_bring_workers_down, a data race occurs on the
queue::priv::bring_workers_down variable.
This patch protects the read of the queue::priv::bring_workers_down
variable (in worker::wait_to_execute_a_task) by the
queue::priv::tasks_todo_mutex mutex. Note that that mutex is the one
that protects the write to queue::priv::bring_workers_down in
queue::priv::do_bring_workers_down.
* src/abg-workers.cc (worker::wait_to_execute_a_task): Protect the
read of the queue::priv::bring_workers_down down variable with the
queue::priv::tasks_todo_mutex.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Dodji Seketeli [Tue, 7 Mar 2017 10:14:52 +0000 (11:14 +0100)]
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>
Dodji Seketeli [Fri, 3 Mar 2017 13:06:34 +0000 (14:06 +0100)]
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>
Dodji Seketeli [Fri, 3 Mar 2017 11:56:44 +0000 (12:56 +0100)]
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>
Dodji Seketeli [Thu, 2 Mar 2017 11:49:52 +0000 (12:49 +0100)]
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>
Dodji Seketeli [Thu, 2 Mar 2017 11:29:38 +0000 (12:29 +0100)]
More Helgrind suppressions
* tests/test-valgrind-suppressions.supp: More specific suppressions.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Dodji Seketeli [Thu, 2 Mar 2017 10:52:06 +0000 (11:52 +0100)]
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>
Dodji Seketeli [Wed, 1 Mar 2017 15:15:45 +0000 (16:15 +0100)]
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>
Dodji Seketeli [Wed, 1 Mar 2017 13:13:39 +0000 (14:13 +0100)]
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>
Dodji Seketeli [Tue, 28 Feb 2017 15:37:06 +0000 (16:37 +0100)]
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>
Dodji Seketeli [Fri, 24 Feb 2017 13:16:35 +0000 (14:16 +0100)]
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>
Dodji Seketeli [Fri, 24 Feb 2017 13:55:01 +0000 (14:55 +0100)]
Do not ignore valgrind checks returning an error
Under "make check-valgrindk", when valgrind returns errors, these
errors are ignored by make. It turns out it is the autoconf
VALGRIND_CHECK_RULES macro that does this. Fixed thus.
* autoconf-archive/ax_valgrind_check.m4 (check-valgrind): Don't
ignore errors.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Dodji Seketeli [Fri, 24 Feb 2017 13:57:52 +0000 (14:57 +0100)]
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>
Dodji Seketeli [Fri, 24 Feb 2017 09:58:16 +0000 (10:58 +0100)]
Several fixes and enhancements to abigail::workers
While making abipkgdiff to use the abigail::workers API to do away
with using pthreads directory, it appeared that the abigail::workers
API needs fixes and enhancements.
Fixes
=====
* Don't try to schedule a task if the pointer to the task is nil
* Fix a data race when bringing workers (of a queue) down
* Always try to wake up all waiting threads when bringing down queue
workers.
* Fix a data race when accessing the queue condition variable
* Fix a data race when notifying listeners about the end of the job
performed by the task.
Enhancements
============
* Pass the "task done" notifier by reference, to the worker queue.
Without this, the worker queue needs to copy the "task done" notifier
by value. This implies that user code needs to provide task done
notifier instances that come with potentially complicated copy
constructors. By passing it by reference and by just re-using the
notifier from the user code, we do away with the need for copying
altogether. This also fixes some latent copying bugs.
* Add a workers::queue::schedule_tasks() method
This allows user code to schedule a vector of tasks at once.
* make workers::queue::get_completed_tasks() return a non-const vector
This enables user code to sort the completed tasks as they wish.
* include/abg-workers.h (queue::tasks_type): New typedef.
(queue::queue): Pass task_done_notify by reference.
(queue::schedule_tasks): Declare new member function.
(queue::get_completed_tasks): Return non-const vector.
* src/abg-workers.cc (queue::priv::default_notify): New data
member.
(queue::priv::notify): Make this data member be a reference.
(queue::priv::priv): Initialize the notify data member to either
the new default_notify (if no notifier is provided by the
constructor) or to the notifier provided by the constructor.
(queue::priv::schedule_task): Do not schedule a nil task. Update
comment.
(queue::priv::schedule_tasks): Add a new member function.
(queue::priv::do_bring_workers_down): Update comment. Protect
access to "bring_workers_down" with tasks_todo_mutex to prevent a
data race. Call pthread_cond_broadcast on the queue_cond
unconditionaly to prevent some worker threads to keep waiting for
ever. Also, protect the access to the queue_cond by the
queue_cond_mutex to precent a data race.
(queue::queue): Pass the notifier by reference. Update comment.
(queue::schedule_task): Update comment.
(queue::schedule_tasks): Define new member function.
(queue::wait_for_workers_to_complete): Update comment.
(queue::get_completed_tasks): Return a non-const vector. Update
comment.
(worker::wait_to_execute_a_task): Update several comments. Make
the execution of the notification code to be synchronized (on the
tasks_done_mutex).
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Dodji Seketeli [Tue, 14 Feb 2017 18:22:56 +0000 (19:22 +0100)]
Fix typo in help string of abipkgdiff
* tools/abipkgdiff.cc (display_usage): Remove erroneous end line.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Dodji Seketeli [Mon, 23 Jan 2017 22:28:12 +0000 (23:28 +0100)]
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>
Dodji Seketeli [Mon, 23 Jan 2017 23:33:22 +0000 (00:33 +0100)]
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>
Dodji Seketeli [Mon, 23 Jan 2017 23:31:03 +0000 (00:31 +0100)]
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>
Dodji Seketeli [Mon, 23 Jan 2017 23:37:22 +0000 (00:37 +0100)]
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>
Slava Barinov [Thu, 29 Sep 2016 06:52:00 +0000 (09:52 +0300)]
Add .spec file and elfutils.
Static internal build of elfutils is needed since it's GPLv3 now and Tizen
package can't be upgraded due to license issues. The build is performed with
static archives only, no shared objects are produced to prevent possibility of
GPLv3 software introduction to platform.
Signed-off-by: Slava Barinov <v.barinov@samsung.com>
Dodji Seketeli [Fri, 13 Jan 2017 23:53:24 +0000 (00:53 +0100)]
Misc style fixes
* include/abg-ir.h (class_or_union): Fix indentation.
* src/abg-dwarf-reader.cc (get_die_pretty_representation): Add new
line.
* src/abg-ir.cc (struct class_decl::priv): Fix indentation.
(virtual_member_function_less_than::operator()): Fix a typo in a
comment.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Dodji Seketeli [Fri, 13 Jan 2017 22:11:00 +0000 (23:11 +0100)]
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.
Dodji Seketeli [Tue, 14 Feb 2017 10:15:01 +0000 (11:15 +0100)]
Fix indentation in src/abg-writer.cc
* src/abg-writer.cc (annotate): Fix indentation.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Dodji Seketeli [Mon, 13 Feb 2017 21:14:54 +0000 (22:14 +0100)]
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>
Dodji Seketeli [Mon, 13 Feb 2017 16:42:26 +0000 (17:42 +0100)]
Fix help string for --header-dirs
* tools/abidw.cc (display_usage): Fix patch -> path typo.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Dodji Seketeli [Mon, 13 Feb 2017 16:37:58 +0000 (17:37 +0100)]
Make abidw --headers-dir work with the --out-file option
* tools/abidw.cc (parse_command_line): Don't require an empty
output file when parsing the --headers-dir option. This was a
thinko.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Ondrej Oprala [Tue, 17 Jan 2017 18:41:51 +0000 (19:41 +0100)]
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>
Dodji Seketeli [Fri, 20 Jan 2017 14:47:16 +0000 (15:47 +0100)]
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>
Dodji Seketeli [Fri, 20 Jan 2017 10:00:37 +0000 (11:00 +0100)]
Add --harmless option to abipkgdiff
This option that is present for the abidiff tool was missing for
abipkgdiff.
* doc/manuals/abidiff.rst: Fix a typo.
* doc/manuals/abipkgdiff.rst: Document the --harmless option.
* tools/abipkgdiff.cc: Update copyright year.
(options::show_harmless_changes): Add new data member.
(options::options): Initialize the new data member.
(display_usage): Add a help string for the new --harmless option.
(parse_command_line): Parse the new --harmless option.
(set_diff_context_from_opts): Configure the diff context
accordingly, if the user provided the --harmless option.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Dodji Seketeli [Fri, 20 Jan 2017 09:28:29 +0000 (10:28 +0100)]
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>
Dodji Seketeli [Wed, 18 Jan 2017 09:10:10 +0000 (10:10 +0100)]
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>
Dodji Seketeli [Wed, 18 Jan 2017 09:10:47 +0000 (10:10 +0100)]
Fix some include logic in abg-suppression.cc
* src/abg-suppression.cc: Update copyright notice. Fix include
files logic.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Dodji Seketeli [Mon, 16 Jan 2017 12:40:47 +0000 (13:40 +0100)]
Support virtual member functions with vtable offset not yet set
When reading C++ class informatin DWARF, it can happen that a given
virtual member function does not yet have a vtable offset. Right now,
that offset is set to zero. Just like a virtual member function which
actual vtable offset is zero. So we don't make a difference between a
virtual function with no vtable offset and a virtual function with a
vtable offset set to zero.
This can lead to confusions during class comparison.
This patch fixes that problem by setting the default vtable offset to
-1. So whenever a vtable offset is -1 it means that the virtual
member function doesn't yet have a vtable offset.
* include/abg-fwd.h (member_function_has_vtable_offset): Declare
new function.
(get_member_function_vtable_offset): Return a ssize_t, not a
size_t.
(set_member_function_vtable_offset): Take a ssize_t, not a size_t.
* include/abg-ir.h (class_decl::virtual_mem_fn_map_type): Adjust
the map typedef to make it take ssize_t as the type of the key.
(mem_fn_context_rel::vtable_offset_in_bits_): Make this data
member be of ssize_t type, not size_t.
(mem_fn_context_rel::mem_fn_context_rel): Initialize the
vtable_offset_in_bits_ data member to -1.
* src/abg-ir.cc (member_function_has_vtable_offset): Define new
function.
(get_member_function_vtable_offset): Return a ssize_t, not a
size_t.
(set_member_function_vtable_offset): Take a ssize_t, not a size_t.
* src/abg-dwarf-reader.cc (die_virtual_function_index): Take an
int64_t& rather than a uint64_t&.
(finish_member_function_reading): Don't set the vtable offset if
it's -1.
* src/abg-reader.cc (build_class_decl): Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Dodji Seketeli [Fri, 13 Jan 2017 23:56:02 +0000 (00:56 +0100)]
[comparison engine] Don't crash when the context is null
* src/abg-comparison.cc
(RETURN_IF_BEING_REPORTED_OR_WAS_REPORTED_EARLIER): Guard against
null context.
(diff::is_filtered_out): Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Dodji Seketeli [Fri, 13 Jan 2017 23:43:57 +0000 (00:43 +0100)]
[dwarf reader] Don't abort when trying to canonicalize a non-type
maybe_canonicalize_type is too strict when given a non type. In that
case, it should just return, not abort.
* src/abg-dwarf-reader.cc (maybe_canonicalize_type): Don't abort
when trying to canonicalize a decl.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Dodji Seketeli [Fri, 13 Jan 2017 23:18:44 +0000 (00:18 +0100)]
[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>
Dodji Seketeli [Fri, 13 Jan 2017 23:14:34 +0000 (00:14 +0100)]
[dwarf reader] Allow updating and de-duplicating member functions
We forget to register member functions for lookup (by DWARF DIE
representation). So member functions are not correctly found (by
lookup) and thus are not properly de-duplicated or updated.
* src/abg-dwarf-reader.cc (add_or_update_class_type): Register
member functions for lookup by member function DIE representation.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Dodji Seketeli [Fri, 13 Jan 2017 23:06:19 +0000 (00:06 +0100)]
[dwarf reader] Do not over de-duplicate function *definitions*
When a function needs to be completed, we sometimes wrongly
try to de-duplicate rather than just complete it.
* src/abg-dwarf-reader.cc
(build_or_get_fn_decl_if_not_suppressed): Do try to de-duplicate a
function if it's to be completed.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Dodji Seketeli [Fri, 13 Jan 2017 22:47:55 +0000 (23:47 +0100)]
[dwarf reader] Fix pretty printing static methods from DWARF
When pretty printing static methods from DWARF, we were forgetting the
first parameter for static methods.
* src/abg-dwarf-reader.cc
(die_return_and_parm_names_from_fn_type_die): Take a new
'is_static' parameter.
(die_qualified_type_name, die_pretty_print_type): Adjust calling
die_return_and_parm_names_from_fn_type_die.
(die_function_signature): Likewise. Also, do not forget to print
the first parameter for a static method.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Dodji Seketeli [Fri, 13 Jan 2017 21:46:36 +0000 (22:46 +0100)]
Handle several virtual member functions having the same vtable offset
In the DWARF for C++, it can happens that a virtual constructor leads
to several (up to 3) destructor functions that all have the same
vtable offset. That vtable offset is the same as the offset of the
virtual destructor that the user actually defined in her source code.
This patch adds a map data structure to the private data of
class_decl. That map associates a vtable offset X to a vector of
virtual member functions that have the same vtable offset X.
That new map is populated whenever a virtual member function is added
to the class.
* include/abg-ir.h (class_or_union::virtual_mem_fn_map_type):
Define new typedef.
(class_decl::get_virtual_mem_fns_map): Declare new accessor.
* src/abg-ir.cc (class_decl::priv::virtual_mem_fns_map_): New data
member.
(class_decl::get_virtual_mem_fns_map): Define new accessor.
(fixup_virtual_member_function): Populate the new virtual member
functions map.
(class_decl::on_canonical_type_set): Sort the virtual member
function vectors stored in the new virtual member functions map.
(class_decl::add_member_function): Call
set_member_function_is_virtual *after* calling
set_member_function_vtable_offset because the former updates the
virtual function map, so it needs the vtable offset.
* src/abg-dwarf-reader.cc (finish_member_function_reading):
Likewise.
* src/abg-reader.cc (build_class_decl): Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Dodji Seketeli [Fri, 13 Jan 2017 12:27:27 +0000 (13:27 +0100)]
Speed up pretty representing (function) types
During structural (function) type comparison, computing the pretty
representation of the type at hand appears high on performance profiles,
especially when type canonicalization wasn't really effective.
This patch adds a type_base::get_cached_pretty_representation() and a
function_type::get_cached_name() to cache the pretty representation of
a type, as well as the function type name. This is way, the type
representation is computed just once and stored into a cache.
subsequent invocations of the function just look into the cache
instead of computing the representation again.
Note that we do this only for non-canonicalized types because these
types can still be modified, and so caching the representation of a
type that might be changed (and thus see its representation change)
leads to issue. So the representation of non-canonicalized types is
not cached.
* include/abg-ir.h (type_base::get_cached_pretty_representation):
Declare new function.
(function_type::get_cached_name): Likewise.
* src/abg-ir.cc (get_method_type_name): Use the new
type_base::get_cached_pretty_representation function.
(type_base::priv::{internal_cached_repr_, cached_repr_}): Add new
data members.
(function_type::priv::{internal_cached_name_, cached_name_}):
Likewise.
(type_base::get_cached_pretty_representation): Define new
function.
(function_type::get_cached_name): Likewise.
(type_base::get_canonical_type_for): Call
type_base::get_cached_pretty_representation here, so the internal
representation is cached right before canonicalization.
(function_type::{mark_as_being_compared, unmark_as_being_compared,
comparison_started}): Uset he new type_base::get_cached_name to
speed up function type name retrieval.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Dodji Seketeli [Fri, 13 Jan 2017 12:11:45 +0000 (13:11 +0100)]
Add missing deep comparison operators for {function, method}_decl_sptr
It turned out we were missing deep comparison operators for smart
pointers to function_decl and method_decl. Because of coming patches
that compare virtual member functions as part of comparing classes, we
need these deep comparison operators.
* include/abg-ir.h (operator==): Declare two new overloads for
function_decl_sptr an method_decl_sptr.
* src/abg-ir.cc (operator==): Define two new overloads for
function_decl_sptr an method_decl_sptr.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Dodji Seketeli [Mon, 16 Jan 2017 18:25:36 +0000 (19:25 +0100)]
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>
Dodji Seketeli [Fri, 13 Jan 2017 23:52:16 +0000 (00:52 +0100)]
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>
Dodji Seketeli [Mon, 16 Jan 2017 07:57:55 +0000 (08:57 +0100)]
Remove unused functions from abg-ir.cc
* src/abg-ir.cc (convert_node_to_decl): Remove specializations for
class_decl_sptr, type_base_sptr and var_decl_sptr.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Dodji Seketeli [Thu, 10 Nov 2016 12:49:08 +0000 (13:49 +0100)]
Support Linux Kernel ABI whitelist files
Enterprise Linux (at least) kernels come with ABI whitelist files that list the
names of the set of functions to be considered when looking at the ABI
exposed by the kernel to its modules.
This patch adds a new --linux-kernel-abi-whitelist option to abidiff
so that it drops changes that relate to functions that are *NOT*
defined in the whitelist.
The patch reads the whitelist file and generates one or several
instances of function_suppression that are applied when the two
binaries are loaded.
* include/abg-suppression.h
(function_suppression::function_suppression): Make the declaration
of the default constructor public.
* src/abg-suppression-priv.h (function_suppression::priv::priv):
Declare a default constructor.
* src/abg-suppression.cc
(function_suppression::function_suppression): Define default
constructor.
* include/abg-tools-utils.h
(gen_suppr_spec_from_kernel_abi_whitelist): Declare new function.
* src/abg-tools-utils.cc
(gen_suppr_spec_from_kernel_abi_whitelist): Define new function.
* tools/abidiff.cc (options::kernel_abi_whitelist_paths):
(display_usage): Display a help string for the new
--linux-kernel-abi-whitelist option.
(parse_command_line): Parse the --linux-kernel-abi-whitelist from
the command line.
(maybe_check_suppression_files): Check the presence of the kernel
abi whitelist files.
(set_suppressions): Generate suppression specifications from the
whitelist files.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Dodji Seketeli [Mon, 10 Oct 2016 10:18:51 +0000 (12:18 +0200)]
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>
Dodji Seketeli [Fri, 6 Jan 2017 00:47:05 +0000 (01:47 +0100)]
Add debug routines to dump locations to a stream
* src/abg-writer.cc (dump_location): Define new function and one
overload.
(dump_decl_location): Re-write in terms of the new dump_location.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Dodji Seketeli [Thu, 5 Jan 2017 23:48:24 +0000 (00:48 +0100)]
Better de-duplicate classes, unions, enums in non-odr contexts
When reading an ELF/DWARF binary that doesn't support the One
Definition Rule[1] (aka ODR), type de-duplication is done on a
per-translation unit basis only. That means that a type definition
must be unique only in a given translation unit, in that case.
[1]: https://en.wikipedia.org/wiki/One_Definition_Rule
When handling big C binaries like the Linux Kernel, this implies a lot
of type duplication still, as the same type can be re-defined in a lot
of different translation units.
This patch tries to de-duplicate types on a per-corpus basis, even in
cases where the ODR doesn't apply. It does so by noting that if two
types of the same kind and name are seen in two different translation
units and yet have the same source location (are defined in the same
spot) then they are the same type.
The patch does this for class, union and enum types as these seem to
be the kinds of types which are duplicated the most and thus consume
the most memory and later take the most time to canonicalize. In a
subsequent patch, we might want to try to de-duplicate typedef types
too, and see if gain anything.
Comparing two linux kernels shows that with this patch, we come back
to a speed (and memory consumption) that is comparable to when we were
considering C-based binaries as being suited to our (too aggressive)
ODR-based type de-duplication algorithm.
Below are the output of the comparison measured with /usr/bin/time
with the aggressive ODR-based type de-duplication algorithm and with
this patch. We compare the vmlinux binary coming from the package
kernel-3.10.0-515 against the one from kernel-3.10.0-327.el7.x86_64.
We use the kabi whitelists provided by the relevant
kernel-abi-whitelists packages for these kernels to restrict the
comparison to a meaningful subset of interfaces.
52.66user 0.64system 0:53.34elapsed 99%CPU (0avgtext+0avgdata 944416maxresident)k 0inputs+48outputs (0major+250750minor)pagefaults 0swaps
vs:
51.04user 0.87system 0:51.91elapsed 100%CPU (0avgtext+0avgdata 972560maxresident)k
0inputs+232outputs (0major+279983minor)pagefaults 0swaps
The full invocation and results are available at:
http://people.redhat.com/~dseketel/kabidiff/vmlinuz-3.10.0-327.el7.x86_64--vmlinuz-3.10.0-515.el7.x86_64.diff.whitelisted.with-unions.txt
vs
http://people.redhat.com/~dseketel/kabidiff/vmlinuz-3.10.0-327.el7.x86_64--vmlinuz-3.10.0-515.el7.x86_64.diff.whitelisted.with-unions.with-non-odr-support.txt
Note that to be able to compare the two kernels, the current tree must
contain the necessary patches that make libabigail understand Linux
Kernel binaries.
* src/abg-dwarf-reader.cc (build_enum_type)
(add_or_update_class_type, add_or_update_union_type): When the ODR
is not relevant, use the location of the type to detect if two
enum, class or union types of the same name actually represent the
same type.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Dodji Seketeli [Fri, 6 Jan 2017 00:41:09 +0000 (01:41 +0100)]
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>
Ondrej Oprala [Tue, 3 Jan 2017 23:03:08 +0000 (00:03 +0100)]
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>
Dodji Seketeli [Thu, 5 Jan 2017 10:22:51 +0000 (11:22 +0100)]
Update copyright year on a bunch of files
* include/abg-corpus.h: Update copyright year to 2017.
* src/abg-dwarf-reader.cc: Likewise.
* src/abg-ir.cc: Likewise.
* src/abg-reader.cc: Likewise.
* src/abg-writer.cc: Likewise.
* tools/abicompat.cc: Likewise.
* tools/abidw.cc: Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Dodji Seketeli [Thu, 5 Jan 2017 10:21:14 +0000 (11:21 +0100)]
[apidoc] Allow brief description at the top of class description pages
* doc/api/libabigail.doxy: Don't disable "brief member desc".
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Dodji Seketeli [Thu, 5 Jan 2017 09:58:14 +0000 (10:58 +0100)]
Misc style fixes
* include/abg-corpus.h: Remove corpus_sptr typedef. It's in
abg-fwd.h now.
* src/abg-ir.cc: Remove some unnecessary vertical space.
* src/abg-reader.cc (build_function_decl): Cleanup some asserts.
* src/abg-writer.cc (write_function_type): Each the inspection of
the type id from within the debugger.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Dodji Seketeli [Thu, 5 Jan 2017 09:50:45 +0000 (10:50 +0100)]
Misc comments and apidoc fixes
* src/abg-dwarf-reader.cc (lookup_symbol_from_gnu_hash_tab): Fix
typo in comment.
* tools/abicompat.cc (perform_compat_check_in_weak_mode): Better
comments.
* tools/abidw.cc (dislay_usage): Fix white spaces.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Conflicts:
tools/abidw.cc
Dodji Seketeli [Wed, 4 Jan 2017 23:57:10 +0000 (00:57 +0100)]
Speedup set_member_is_static
set_member_is_static dominates some performance profile because that
function compares data members before their types are canonicalizing.
This means the comparison is done structurally. So it's potentially
super long.
This patch fixes the issue by comparing data members by just looking at
their names, and that should be enough.
* src/abg-ir.cc (set_member_is_static): When comparing data
members, consider only their names.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Dodji Seketeli [Wed, 4 Jan 2017 23:50:34 +0000 (00:50 +0100)]
Avoid unnecessary updates to type lookup maps
In class_or_union::set_is_declaration_only we should update the type
lookup maps only when a class type that was previously a
declaration-only type is now a defined type. Otherwise, updating the type
lookup maps is unnecessary and profiling shows that it takes a
significant amount of time.
This patch does away with the unnecessary attempts to update type
lookup maps.
* src/abg-ir.cc (class_or_union::get_is_declaration_only): Try
to update the type maps only when a declaration-only class
type is now defined.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Dodji Seketeli [Thu, 5 Jan 2017 11:39:41 +0000 (12:39 +0100)]
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>
Dodji Seketeli [Thu, 5 Jan 2017 11:35:18 +0000 (12:35 +0100)]
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>
Dodji Seketeli [Thu, 5 Jan 2017 09:32:48 +0000 (10:32 +0100)]
[abixml writer] Make sure all function types are emitted
The abixml writer forgets to emit some function types that are only
referenced by other types. Fixed thus.
Note that the necessary adjustment to reference outputs of abidw in
the regression test suite is not provided with this patch to ease
backporting. Those adjustments are in a patch that comes at the end
of this patch series.
* src/abg-writer.cc (write_translation_unit): Fix logic to avoid
forgetting referenced function types.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Dodji Seketeli [Thu, 5 Jan 2017 08:55:13 +0000 (09:55 +0100)]
[abixml writer] Fix comparison of pointer to types
When two type pointers designate two types with the same pretty
printed representatin don't already have an associated type id, the
comparison code was mistakenly associating them with empty type id.
This patch fixes that.
Note that the necessary adjustment to reference outputs of abidw in
the regression test suite is not provided with this patch to ease
backporting. Those adjustments are in a patch that comes at the end
of this patch series.
* src/abg-writer.cc (type_ptr_comp::operator()): Do not add an
empty type id string to the type -> type id map when the entry for
a given type is empty.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Dodji Seketeli [Thu, 5 Jan 2017 00:05:04 +0000 (01:05 +0100)]
[dwarf-reader] Don't early canonicalize function types
Make sure we don't early-canonicalize function types. We need to wait
after the end of building the ABI corpus before canonicalizing these.
Normally this should be taken care of by using
type_has_non_canonicalized_subtype but there are cases where that
function does not detect that a type has sub-types that are not
canonicalized.
Fixed thus.
* src/abg-dwarf-reader.cc (maybe_canonicalize_type):
Late-canonicalize function types.
signed-off-by: Dodji Seketeli <dodji@redhat.com>
Dodji Seketeli [Wed, 4 Jan 2017 23:15:40 +0000 (00:15 +0100)]
Fix qualified name caching for some types
When ::get_qualified_name() is invoked for some types, the value is
cached for performance reasons.
One thing to keep in mind is that the structure of a type can change
between the time when the type is first built and the time when it's
canonicalized. This is because the type can be built progressively,
with sub-types being added over time until the type is fully built.
Then it can be canonicalized.
So if ::get_qualified_name is invoked on a non-canonicalized type and
the result is cached, then that result might not reflect the state of
the type *after* its canonicalized. So the cached value might be
wrong.
To address that issue, the solution is to *not* cache the result of
::get_qualified_name() until the type is canonicalized. After the
type is canonicalized and so we know the structur of the type won't
change, then the result of ::get_qualified_name is cached.
And this is what this patch does for qualified, pointer and array
types.
Note that the necessary update to the regression test suite is not
provided with this patch. It's provided by a separate patch at the
end of the current series of patches.
* src/abg-ir.cc ({qualified, pointer,
array}_type_def::get_qualified_name): Don't cache internal and
non-internal qualified name when the type is not canonicalized.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Dodji Seketeli [Wed, 4 Jan 2017 22:54:16 +0000 (23:54 +0100)]
Cleanup ODR-based type canonicalization optimization gating logic
During type canonicalization we use an ODR-based optimization which
consists of saying that if two types of the same kind have the same
name and are defined in the same ABI corpus, then they are the same
type -- whithout needing to actually perform a structural comparison
of both types. This speeds up type canonicalization greatly for types
that are duplicated in the ABI corpus.
The condition to apply that ODR-based optimization is basically that
the binary we are looking at must be in C++.
This patch just makes that condition clearer.
* src/abg-ir.cc (type_base::get_canonical_type_for): Make it clear
that the ODR-based optimization is allowed only on C++ ABI
corpora.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Dodji Seketeli [Wed, 4 Jan 2017 16:03:27 +0000 (17:03 +0100)]
Fix a typo in method name computation
It turns out we forget a "return" keyword when we want to return the
name of a method. Ooops.
Fixed thus.
Please note that this patch doesn't come with its necessary update to
the tests/data/test-read-dwarf/test9-pr18818-clang.so.abi and
tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi
files. Those updates to regression tests are coming in a subsequent
patch.
* src/abg-ir.cc (get_method_type_name): Really return the method
name.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Dodji Seketeli [Thu, 5 Jan 2017 10:31:07 +0000 (11:31 +0100)]
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>
Dodji Seketeli [Thu, 5 Jan 2017 11:03:35 +0000 (12:03 +0100)]
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>
Dodji Seketeli [Wed, 4 Jan 2017 09:50:52 +0000 (10:50 +0100)]
[dwarf-reader] Handle per translation-unit type de-duplication
Until now, when the elf/dwarf reader builds ABI artifacts, it performs
type de-duplication by considering that a type with a given name should
be defined only once in a given ABI corpus. This is per-corpus
de-duplication.
The problem with that approach is that it assumes that the binary
respects the One Definition Rule[1], aka ODR. But then many non-C++
binaries don't respect the ODR.
So, for non-c++ binaries, we shouldn't assume the ODR. We should be
able to assume a per translation unit (aka per-tu) de-duplication.
That is, consider that a type with a given name is defined just once
in a given translation unit. Or perform no de-deplication at all,
depending on the kind of type we are looking at.
And this is what this patch does. It allows the ELF/DWARF reader to
perform per-tu type de-duplication by assuming that it's only in a given
translation unit that a type definition must be unique. It also allows it
perform no de-duplication at all for some kind of types.
In practice, function types are de-duplicated on a per-tu basis if ODR
is not relevant, otherwise, they are de-duplicated on a per-corpus
basis when ODR is relevant.
For most of the other types, if ODR is not relevant, then no
de-duplication is performed at all. Otherwise, for these types, if
ODR is relevant, per-corpus de-duplication is performed.
* src/abg-dwarf-reader.cc
(read_context::per_tu_name_artefacts_map_): New data member.
(read_context::clear_per_translation_unit_data): Clear the new
read_context::per_tu_name_artefacts_map_.
(read_context::associate_die_to_decl): Take a flag to say if we
should associate a DIE to its representation and another one to
say if the association should be done per-tu or per-corpus.
(read_context::lookup_{type_artifact, artifact}_from_die): Update
apidoc.
(read_context::lookup_artifact_from_die_representation): Likewise.
(read_context::{associate_die_to_artifact_by_repr,
associate_die_to_artifact_by_repr_internal,
associate_die_to_type}): Take a flag to say if the associating
should be done on a per-tu basis.
(read_context::lookup_{type_artifact, artifact}_from_die_per_tu):
New member functions.
(read_context::{lookup_artifact_from_per_tu_die_representation,
odr_is_relevant}): Likewise.
(build_enum_type, add_or_update_class_type)
(add_or_update_union_type): If ODR is not relevant, do not perform
per-corpus de-duplication.
(build_pointer_type_def, build_typedef_type): Do not associate the
type to its representation as these kinds of typs are not
de-duplicated.
(build_function_type): If ODR is not relevant, perform per-tu
de-duplication. When ODR is relevant, per-corpus de-duplication
is performed.
(build_or_get_fn_decl_if_not_suppressed): Function decls are
always de-duplicated per-corpus.
(build_ir_node_from_die): For data members, do not update the die
representation map as data members are not de-duplicated. Do not
do it for function decls either.
[1]: https://en.wikipedia.org/wiki/One_Definition_Rule
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Dodji Seketeli [Mon, 2 Jan 2017 21:40:39 +0000 (22:40 +0100)]
Handle per translation unit and per corpus types maps
Today, whenever a type is added to its scope, a map that associates
the qualified type name to the type is updated. There is only one
such map in a given ABI corpus.
So whenever a type is looked up from its name, it's that per-corpus
type map that is used.
This setup makes libabigail type lookup be tailored only for binaries
that respect the One Definition Rule of C++[1] (aka ODR) which
basically says that there should be only one type of a given name in
an ABI corpus.
It turns out that many binaries, especically C binaries, don't respect
the ODR. So a type "struct foo" can be defined in a file a.c and
another *different* type "struct foo" can also be defined in b.c.
What a useful and safe feature! Not.
For those binaries, just having one type map doesn't work. We need to
have one type map per translation unit, and one map per-corpus map.
This is the strategy implemented by this patch.
With this patch, whenever a type is added to its scope, a
per translation unit type map is updated. The per corpus map is
updated as well. If there are more than one type of a given name, the
entry in the per corpus type map for that type is left empty.
Type lookup now potentially becomes a two phases lookup. Whenever a
type is looked up from its name, the per corpus type map is looked at
first. If the type is not in that per corpus type map, then the per
translation unit type maps are lookup up, in sequence.
The patch thus re-visits the type maps updating and lookup routines to
adapt them to the new scheme. The patch also updates the clients of
the type map updating and lookup code.
Note that this patch is part of a series of patches which aims to move
libabigails away from its ODR-centric organization to make it work
well also on binary where the ODR is not relevant. As such, the patch
doesn't assure that "make check" passes. To have "make check" pass,
you need to have all the patches of the series applied.
[1]: https://en.wikipedia.org/wiki/One_Definition_Rule
* include/abg-fwd.h (lookup_type_in_corpus): Remove. This is to
be replaced by the new lookup_type below.
(lookup_{basic, class, union, enum, typedef, qualified, pointer,
reference, array, function, class_or_typedef,
class_typedef_or_enum}_type):
(lookup_class_type_through_scopes, lookup_type)
(lookup_type_through_scopes, lookup_or_synthesize_fn_type)
* src/abg-ir-priv.h (struct translation_unit::priv): Move this
private type here, from abg-ir.h.
(synthesize_type_from_translation_unit): Declare new functions.
* include/abg-ir.h (class type_maps): Define new type.
(translation_unit::get_function_types): Remove.
(translation_unit::get_types): Now return a type_maps.
(translation_unit::get_live_fn_types): Declare new type.
(class decl_base): Make canonicalize be a friend of this class.
* src/abg-ir.cc (struct translation_unit::priv): Move this to
abg-ir-priv.h
(struct type_maps::priv): Define new type.
(type_maps::{basic, class, union, enum, typedef, qualified,
pointer, reference, array, function}_types): Define new accessors.
(translation_unit::bind_function_type_life_time): Adjust.
(translation_unit::get_function_types): Remove accessor.
(translation_unit::get_types, get_live_fn_types): Define new
accessors.
(lookup_type_in_translation_unit)
(lookup_class_type_in_translation_unit)
(lookup_function_type_in_translation_unit)
(synthesize_type_from_translation_unit)
(synthesize_function_type_from_translation_unit)
(lookup_class_type_in_translation_unit) Remove function
definitions.
(lookup_type_in_map): Define function template.
(lookup_{basic, class, union, typedef, class_or_typedef,
class_typedef_or_enum, qualified, pointer, reference, array,
function}_type): Define functions.
(lookup_function_type, lookup_type_through_scopes)
(lookup_class_type_through_scopes)
(lookup_basic_type_through_translation_units)
(lookup_union_type_through_translation_units)
(lookup_enum_type_through_translation_units)
(lookup_class_type_through_translation_units)
(lookup_typedef_type_through_translation_units)
(lookup_qualified_type_through_translation_units)
(lookup_pointer_type_through_translation_units)
(lookup_reference_type_through_translation_units)
(lookup_array_type_through_translation_units)
(lookup_function_type_through_translation_units)
(lookup_type_through_translation_units)
(lookup_or_synthesize_fn_type, lookup_type): Likewise.
(maybe_update_types_lookup_map)
(maybe_update_types_lookup_map<class_decl>)
(maybe_update_types_lookup_map<function_type>): Define function
template, specilizations and functions.
(synthesize_type_from_translation_unit)
(synthesize_function_type_from_translation_unit): Define
functions.
* include/abg-corpus.h (corpus::get_types): Declare new accessor.
* src/abg-corpus.cc (corpus::priv::get_types): Define new
accessor.
(corpus::get_types): Likewise.
(lookup_type_in_corpus, lookup_class_type_in_corpus)
(lookup_type_in_corpus, lookup_function_type_in_corpus)
(maybe_update_types_lookup_map)
(maybe_update_types_lookup_map<class_decl>)
(maybe_update_types_lookup_map<function_type>): Remove.
(lookup_{basic, class, union, enum, typedef, qualified, pointer,
reference, array, function, class_or_typedef,
class_typedef_or_enum}_type): Likewise.
* src/abg-corpus-priv.h (corpus::priv::{basic, class, union,
typedef, qualified, pointer, reference, array, function}_types):
Remove these data members.
(corpus::priv::get_scopes): Remove member function.
(corpus::priv::get_{basic, class, union, enum, typedef, qualified,
pointer, reference, array, function}_types): Remove member
function declarations.
(corpus::priv::types_): New data member.
(corpus::priv::get_types): Declare new member function.
(lookup_{basic, class, enum, typedef, class_or_typedef, qualified,
pointer, reference, array, function}_type): Declare new functions.
* src/abg-dwarf-reader.cc
(read_context::resolve_declaration_only_classes)
(build_translation_unit_and_add_to_ir): Adjust use of
lookup_class_type.
* src/abg-reader.cc (read_context::type_is_from_translation_unit):
Adjust to the use of lookup_function_type_in_translation_unit that
got renamed into lookup_function_type.
* src/abg-writer.cc (type_ptr_cmp::operator()): New operator
implementation.
(read_context::sort_type): Add new overloads.
(write_translation_unit): Adjust to get the function types from
the new translation_unit::get_live_fn_types and sort them.
* tools/abicompat.cc (perform_compat_check_in_weak_mode): Adjust
to use the new lookup_or_synthesize_fn_type, in lieu of
lookup_function_type_in_corpus. Adjust to use lookup_type in lieu
of lookup_type_in_corpus.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Dodji Seketeli [Wed, 21 Dec 2016 19:50:08 +0000 (20:50 +0100)]
Make abg-fwd.h use *_sptr typedefs
Until now, the abg-fwd.h where the necessary forward generic
declarations where put didn't contain the convenience typedefs of the
form foo_sptr that designate a shared pointer to type foo.
This patch moves these convenience typedefs as well as the missing
forward declarations from abg-ir.h to abg-fwd.h. The patch also
adjusts the function declarations in abg-fwd.h to make them use these
convenience typedefs.
* include/abg-ir.h: Move convience typedef declarations and some
necessary forward declarations to ...
* include/abg-fwd.h: ... here.
(is_enum_type, is_var_decl): Take a pointer to type_or_decl_base.
(lookup_type_in_scope): Return a type_base_sptr.
(lookup_type_through_scopes): Introduce this to later replace the
overload of lookup_type_in_translation_unit that takes a list of
strings.
(lookup_type_in_scope): Return a type_base_sptr, not a
decl_base_sptr.
* src/abg-ir.cc (lookup_type_in_scope, lookup_node_in_scope)
(lookup_var_decl_in_scope): Adjust.
(is_enum_type, is_var_decl): Take a pointer to type_or_decl_base.
(lookup_node_in_scope): Return a type_or_decl_base_sptr.
(lookup_type_in_scope): Return a type_base_sptr.
(lookup_node_in_translation_unit): Return a
type_or_decl_base_sptr.
(lookup_type_through_scopes): Replace
lookup_type_in_translation_unit.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Chenxiong Qi [Sun, 18 Dec 2016 15:43:24 +0000 (23:43 +0800)]
Fix wrong variable name
* tools/fedabipkgdiff: (diff_latest_rpms_based_on_distros): Fix
wrong variable name distro.
Signed-off-by: Chenxiong Qi <cqi@redhat.com>
Chenxiong Qi [Sun, 18 Dec 2016 15:12:51 +0000 (23:12 +0800)]
Warn properly when cannot find peer RPM
* tools/fedabipkgdiff: (RPMCollection.get_peer_rpm): Return None
when cannot find peer RPM due to nonexistent arch.
Signed-off-by: Chenxiong Qi <cqi@redhat.com>
Chenxiong Qi [Mon, 19 Dec 2016 11:09:53 +0000 (12:09 +0100)]
Read Koji config via Koji API
Besides reading Koji config via Koji API read_config, option --topdir is
also renamed to --topurl that is the correct one should be used.
* tools/fedabipkgdiff: Read DEFAULT_KOJI_TOPURL and
DEFAULT_KOJI_SERVER from Koji config via Koji API read_config.
(build_commandline_args_parser): --topdir is renamed to
--topurl.
* doc/manuals/fedabipkgdiff.rst: Rename --topdir to --topurl.
Signed-off-by: Chenxiong Qi <cqi@redhat.com>
Chenxiong Qi [Mon, 19 Dec 2016 11:07:12 +0000 (12:07 +0100)]
Follow moved packages when download
This patch makes fedabipkgdiff able to follow the new place to download
packages.
* tools/fedabipkgdiff: (download_rpm) Add --location to curl
CLI.
Signed-off-by: Chenxiong Qi <cqi@redhat.com>
Chenxiong Qi [Tue, 13 Dec 2016 06:06:21 +0000 (14:06 +0800)]
More document for local RPMs comparison
* doc/manuals/fedabipkgdiff.rst: Add more document for local RPMs
comparison. Also fixed a typo.
Signed-off-by: Chenxiong Qi <cqi@redhat.com>
Ondrej Oprala [Thu, 15 Dec 2016 19:15:38 +0000 (20:15 +0100)]
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>
Dodji Seketeli [Thu, 15 Dec 2016 14:06:51 +0000 (15:06 +0100)]
Misc style cleanup
* src/abg-dwarf-reader.cc (build_function_type): Remove
unnecessary new line.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Dodji Seketeli [Thu, 15 Dec 2016 14:09:35 +0000 (15:09 +0100)]
make is_anonymous_type work for unions and classes
* src/abg-ir.cc (is_anonymous_type): Make this work for class or
union types, no only classes.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Dodji Seketeli [Thu, 15 Dec 2016 13:29:38 +0000 (14:29 +0100)]
Naming typedefs of classes are not read properly from abixml
When loading a class from abixml and when that class has a naming
typedef, build_class_decl fails to build the naming typedef from its
ID because it calls read_context::get_type_decl() instead of
read_context::build_or_get_type_decl().
This patch fixes that issue by using
read_context::build_or_get_type_decl rather than
read_context::get_type_decl.
Also, as read_context::build_or_get_type_decl can trigger the creation
of a class (and recursively call build_class_decl), it needs to be
called after the class type being built is marked as work-in-progress
(aka WIP). So the handling of the naming typedef is moved to after
the class type being built is marked as WIP.
* src/abg-reader.cc (build_class_decl): Use
read_context::build_or_get_type_decl rather than
read_context::get_type_decl to build the naming typedef referred
to by the class being built. Move the handling of naming typedefs
after the class is marked as WIP and keyed.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Dodji Seketeli [Thu, 15 Dec 2016 13:12:57 +0000 (14:12 +0100)]
Don't early-canonicalize function types when reading abixml
When reading from an abixml file, we sometimes canonicalize function
types before the entire abixml file is read. This can lead to, e.g, a
function type that is not yet fully built being canonicalized too
early and so its canonical type being wrong because it reflects the
state of the function type at canonicalization time -- but then that
state changed later.
This patch fixes that by forcing us to late-canonicalize function
types, just like we do for all aggregate types.
* src/abg-reader.cc (read_context::maybe_canonicalize_type):
late-canonicalize function types too.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Ondrej Oprala [Mon, 12 Dec 2016 15:37:54 +0000 (16:37 +0100)]
Check --enable-rpm dependencies more rigorously
If a user has explicitly specified --enable-rpm when running
"configure", it will now fail unless both rpm2cpio and cpio
are present on the system.
* configure.ac: Check if both rpm2cpio and cpio
exist on the system. If not, disable the option and fail the
configuration if --enable-rpm was specified explicitly.
Signed-off-by: Ondrej Oprala <ondrej.oprala@gmail.com>
Ondrej Oprala [Mon, 12 Dec 2016 15:08:01 +0000 (16:08 +0100)]
abipkgdiff doesn't mention --no-default-suppression in help
* tools/abipkgdiff.cc (display_usage): Mention
--no-default-suppression as one of the options.
Signed-off-by: Ondrej Oprala <ondrej.oprala@gmail.com>
Ondrej Oprala [Mon, 12 Dec 2016 14:44:29 +0000 (15:44 +0100)]
Fix a few remarks made by cppcheck
* src/abg-comparison.cc (types_or_decls_equal::operator()): Pass
arguments by reference.
(class_diff::ensure_lookup_tables_populated): Expression
!A || (A && B) can be reduced to !A || B.
* src/abg-suppression.cc (suppression_matches_type_no_name):
Likewise.
Signed-off-by: Ondrej Oprala <ondrej.oprala@gmail.com>
Ondrej Oprala [Fri, 9 Dec 2016 22:01:58 +0000 (23:01 +0100)]
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>
Chenxiong Qi [Thu, 11 Aug 2016 13:48:00 +0000 (21:48 +0800)]
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>
Dodji Seketeli [Mon, 12 Dec 2016 11:14:21 +0000 (12:14 +0100)]
Fix template_decl::hash::operator()
While hashing template_decl we inadvertently forget the contribution
of the name of the type to the hash.
This was spotted by Ondrej Oprala.
Fixed thus.
* src/abg-hash.cc (template_decl::hash::operator()): Combine the
contribution of the qualified name to the contribution of the type
name to the hash.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Dodji Seketeli [Thu, 8 Dec 2016 23:37:43 +0000 (00:37 +0100)]
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>
Dodji Seketeli [Mon, 5 Dec 2016 09:11:19 +0000 (10:11 +0100)]
Bug 20927 - Segfault when $HOME is not set
When comparing two binaries with abi{pkg}diff, if $HOME is not set, we
segfault at some places because we don't expect that. I ran "make
check" after doing "unset HOME" to help me catch most of those places.
This patch updates the code to handle that case.
* src/abg-tools-utils.cc
(get_default_user_suppression_file_path): Handle the case where
the HOME environment variable is not set.
* tools/abipkgdiff.cc (package::extracted_packages_parent_dir):
Likewise. When $HOME is empty set then use $TMPDIR. If it's
empty too then use "/tmp".
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Dodji Seketeli [Fri, 2 Dec 2016 13:41:07 +0000 (14:41 +0100)]
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>
Dodji Seketeli [Fri, 2 Dec 2016 11:54:49 +0000 (12:54 +0100)]
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>
Dodji Seketeli [Wed, 30 Nov 2016 10:01:38 +0000 (11:01 +0100)]
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>
Dodji Seketeli [Wed, 30 Nov 2016 08:28:34 +0000 (09:28 +0100)]
Bug 20670 - abipkgdiff aborts if $XDG_CACHE_HOME does not exist
This patch creates $XDG_CACHE_HOME if it doesn't exist, rather than
just aborting.
* tools/abipkgdiff.cc (package::extracted_packages_parent_dir):
Ensure that the cache directory is created, even when
XDG_CACHE_HOME is set. Also, remove the now useless "using
abigail::tools_utils::get_random_number_as_string" statement.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Dodji Seketeli [Wed, 9 Nov 2016 14:10:27 +0000 (15:10 +0100)]
Very light speed improvements
When comparing of two kernel trees showed that for huge changesets
involving highly recursive types, leaf functions used by the
categorization code dominate the performance profile.
This patch introduces some changes that help gain around 30 seconds
(out of 14 minutes) on a non-optimized build, when comparing 4.7 nd
4.8 fedora kernels (between fedora 24 and 26).
* include/abg-comp-filter.h (has_harmless_name_change): Pass smart
pointers by reference.
* src/abg-comp-filter.cc (access_changed)
(function_name_changed_but_not_symbol)
(non_static_data_member_type_size_changed)
(static_data_member_type_size_changed, is_compatible_change)
(decl_name_changed, has_harmless_name_change): Pass smart
pointers by reference.
* include/abg-ir.h (decl_base::set_context_rel): Take a bare
pointer, not a smart pointer.
* src/abg-ir.cc (decl_base::priv::context_): Make this data member
be a naked pointer, not a smart pointer.
(decl_base::priv::priv): Initialize it.
(decl_base::priv::~priv): New constructor.
(decl_base::{get_context_rel, set_scope}): Adjust.
(class_decl::method_decl::{method_decl, set_scope}): Likewise.
(equals): In the overload for var_decl, compare the type of the
var first as that might be faster (to detect var_decls with
different types) in the general case where types are
canonicalized.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Dodji Seketeli [Tue, 8 Nov 2016 10:48:58 +0000 (11:48 +0100)]
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>
Dodji Seketeli [Sun, 6 Nov 2016 11:15:41 +0000 (12:15 +0100)]
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>
Dodji Seketeli [Tue, 11 Oct 2016 13:06:02 +0000 (15:06 +0200)]
Support naming typedef and use them to speed up type canonicalization
There is a common C idiom in which an anonymous struct is named using
a typedef:
typedef struct {int member;} anonymous_struct_type;
The typedef name "anonymous_struct_type" becomes the name of the
otherwise anonymous struct. That is what a naming typedef is.
So, the nice thing about naming typedefs is that an anonymous class
type suddenly becomes non anymous. So that type becomes eligible to
the ODR-based optimization during type canonicalization. That speeds
up type canonicalization, at least for 'abidw'.
This patch represents naming typedefs for class_decl types in the
internal representation. The patch also changes the meaning of an
anonymous class. Whenever such a class becomes named by a typedef,
the class is not considered anonymous anymore, at least for the
purpose of type canonicalization.
* include/abg-ir.h (typedef_decl_wptr): New typedef.
(class_decl::{g,s}et_naming_typedef): Declare new member
functions.
* src/abg-dwarf-reader.cc (build_typedef_type): When the
underlying type of a typedef is an anonymous class, the class type
is said to have a naming typedef.
* src/abg-ir.cc (is_anonymous_type): An anonymous class that has
a naming typedef is said to not be anonymous anymore.
(class_decl::priv::naming_typedef): New data member.
(class_decl::{g,s}et_naming_typedef): Define new member functions.
(class_decl::get_pretty_representation): When called for internal
purposes (e.g, for type canonicalization) compute the pretty
representation of the class by using its typedef name, when class
is anonymous and has a naming typedef.
* src/abg-reader.cc (build_class_decl): Read the new
"naming-typedef-id" attribute.
* src/abg-writer.cc (write_naming_typedef): New function.
(write_class_decl_opening_tag): Use the new write_naming_typedef
function.
* tests/data/test-read-dwarf/libtest23.so.abi: Adjust.
* tests/data/test-read-dwarf/libtest24-drop-fns-2.so.abi:
Likewise.
* tests/data/test-read-dwarf/libtest24-drop-fns.so.abi: Likewise.
* tests/data/test-read-dwarf/test10-pr18818-gcc.so.abi: Likewise.
* 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/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>