mirror of
git://sourceware.org/git/libabigail.git
synced 2025-03-06 14:47:32 +00:00
591a0f9e3e
738 Commits
Author | SHA1 | Message | Date | |
---|---|---|---|---|
|
f07151ff9b |
Bug 28013 - Acknowledge variadic parameter type is not canonicalized
Variadic parameter types are one of the rare types that should not be canonicalized, just like the void type. These types are created by the system (compiler/libabigail) and thus can be compared in O(1) time. So far, I forgot to prevent the canonicalization of variadic parameter type everywhere, as should have been the case since the recent introduction of the is_non_canonicalized_type function. This patch fixes that. * src/abg-ir.cc (is_non_canonicalized_type): Recognize variadic parameter types. * tests/data/test-diff-filter/test-PR28013-fn-variadic.c.{0,1}.abi: New test inputs. * tests/data/test-diff-filter/test-PR28013-fn-variadic.c.report.txt: Likewise. * tests/data/Makefile.am: Add the new test files to source distribution. * tests/test-diff-filter.cc (in_out_specs): Add the new tests to this harness. * tests/data/test-annotate/libtest23.so.abi: Likewise. * 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/test13-pr18894.so.abi: Likewise. * tests/data/test-annotate/test15-pr18892.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/test20-pr19025-libvtkParallelCore-6.1.so.abi: Likewise. * tests/data/test-annotate/test21-pr19092.so.abi: Likewise. * tests/data/test-diff-filter/test-PR28013-fn-variadic.c.0.abi: Likewise. * tests/data/test-diff-filter/test-PR28013-fn-variadic.c.1.abi: Likewise. * tests/data/test-diff-filter/test-PR28013-fn-variadic.c.report.txt: Likewise. * tests/data/test-read-dwarf/PR22015-libboost_iostreams.so.abi: Likewise. * tests/data/test-read-dwarf/PR22122-libftdc.so.abi: Likewise. * tests/data/test-read-dwarf/PR25042-libgdbm-clang-dwarf5.so.6.0.0.abi: Likewise. * tests/data/test-read-dwarf/libtest23.so.abi: Likewise. * 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/test-libaaudio.so.abi: Likewise. * tests/data/test-read-dwarf/test-libandroid.so.abi: Likewise. * tests/data/test-read-dwarf/test0.abi: Likewise. * tests/data/test-read-dwarf/test0.hash.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/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> |
||
|
f86ff3f7a7 |
Bug 26646 - unexpected declaration-only types
In a version of the kernel binary referred to in this problem report, the parameter 'skb' of the udp4_hwcsum function, which is of type "pointer to struct sk_buff", indirectly refers to a pointer to a declaration-only struct ip_mc_list. In another version of that kernel binary, the same parameter skb of the udp4_hwcsum function is still of type "pointer to struct sk_buff", but in that case, the sk_buff indirectly refers to a pointer to a fully defined struct ip_mc_list. The first kernel only contains a decl-only struct ip_mc_list whereas the second one contains a fully defined struct ip_mc_list. This problem comes from the fact that in add_or_update_class_type, we "reuse" the "struct sk_buff" that we've already seen in the same binary, if any. Depending on the order in which types are defined in the debug information, if the DIE for struct sk_buff that refers to a decl-only struct ip_mc_list has already been "seen" by the DWARF-reader, then add_or_update_class_type re-uses the IR of that DIE that's been constructed already; otherwise, the IR for the struct sk_buff represented by the current DIE is constructed. This patch fixes the problem by always constructing an IR for the DIE that is being seen, in add_or_update_class_type. * src/abg-dwarf-reader.cc (add_or_update_class_type): Do not reuse the IR for a DIE with the same textual representation as the one we are seeing now. * tests/data/test-annotate/test21-pr19092.so.abi: Adjust. * tests/data/test-read-dwarf/test21-pr19092.so.abi: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
|
194a3029bd |
abidiff: improve whitespace generation in symbol diff report
maybe_report_diff_for_symbol() has a few issues: 1. The responsibility for newline emission is somewhat unclear and indeed it would emit spurious blank lines before most of the sub-diffs it reports. 2. Different sub-diff text and terminal commas are emitted according to whether or not there had been a previous sub-diff - making the output harder to grep and post-process. 3. The function also returns a bool but that return value is never used. Hence, change the function to return void, the function stanzas to always emit newline-terminated lines and ensure the wording and punctuation of each sub-diff do not vary. This also tweaks (shortens) the wording used for CRC diffs. * src/abg-reporter-priv.cc (maybe_report_diff_for_symbol): Make return void. Simplify and fix new-line emission. Remove comma emission. Tweak CRC wording. * src/abg-reporter-priv.h (maybe_report_diff_for_symbol): Return void. * tests/data/test-abidiff-exit/test-crc-report.txt: Shorten CRC wording. * tests/data/test-abidiff/test-crc-report.txt: Likewise. * tests/data/test-diff-filter/test-PR27569-report-0.txt: Likewise. Reviewed-by: Giuliano Procida <gprocida@google.com> Signed-off-by: Matthias Maennich <maennich@google.com> |
||
|
16e3d3a6f3 |
XML writer: map type ids by bare pointer
This is a performance and safety improvement made possible by previous changes which ensure that the same pointers are used for insertion and look-up. This change affects two test cases. In more detail: The test case test-read-dwarf/PR22122-libftdc.so.abi has many duplicate type-id-60 which appear to all be types defined with a DWARF DW_AT_signature attribute. These are made into separate types by this change, but remain incomplete. The test case test-read-dwarf/PR25007-sdhci.ko.abi has duplicate declarations and these get split into duplicate declarations with new type ids following this change. The test suite runs with an implicit --no-linux-kernel-mode so the duplicates are treated separately. They presumably had the same type ids before this change due to deep equality considering them equal. * src/abg-writer.cc (type_ptr_map): use default equality on type_base pointer. * tests/data/test-read-dwarf/PR22122-libftdc.so.abi: Refresh test case, as described above. * tests/data/test-read-dwarf/PR25007-sdhci.ko.abi: Likewise. Reviewed-by: Giuliano Procida <gprocida@google.com> Signed-off-by: Matthias Maennich <maennich@google.com> |
||
|
16207c4af7 |
Bug 28191 - Interpret DWARF 5 addrx locations
This change uses libdw facilities to interpret location expressions instead of using libabigail's own mini-interpreter. With the fix for elfutils https://sourceware.org/bugzilla/show_bug.cgi?id=28220 in elfutils-0.186, abidw will correctly interpret Clang DWARF 5 symbol addresses. Without that fix many declarations will not be linked to their corresponding symbols due to the incorrect interpretation of location attribute data. * src/abg-dwarf-reader.cc (die_location_address): Use dwarf_attr_integrate, dwarf_getlocation and dwarf_getlocation_attr to decode addreses, instead of die_location_expr and eval_last_constant_dwarf_sub_expr. * tests/data/test-read-dwarf/PR25042-libgdbm-clang-dwarf5.so.6.0.0.abi: Refresh test reference output; two more symbols have types. Signed-off-by: Giuliano Procida <gprocida@google.com> |
||
|
8569491741 |
Bug 28319 - re-fix of rhbz1951526 - SELF CHECK FAILED for 'gimp-2.10'
This commit re-visit the commit below: commit |
||
|
71633a7c0c |
Handle several variants of Python 'imp', 'importlib' modules
Fix-up for recent commit |
||
|
b1bbb67b2f |
ctf-reader: Assert on ir::hash_as_canonical_type_or_constant
In some scenarios where we declare same data types `recursively' such as: like linked list, functions that accept the same pointer to function as arguments, forward types declarations to build structures with member fields with mutual dependencies, etc., an assertion is trigger: abidw: ../../../libabigail-upstream/src/abg-ir.cc:25251: size_t abigail::ir::hash_as_canonical_type_or_constant(const abigail::ir::type_base*): Assertion `__abg_cond__' failed. It is happening because the recursively behavior of `process_ctf_type' and `process_ctf_*' used to register ctf types doesn't verify when a ctf_type was processed and registered before by their subsequence _recursive_ calls, so `type_base' object is built more than once and the second time when it is inserted in `types_maps', it refuses in a silent way, being that the key was already inserted, however `add_decl_to_scope', `bind_function_type_life_time' successfully registered the ctf type object. In this patch `process_ctf_type' delegates register types task to `process_ctf_*' functions guaranteeing a single ctf type registration, also it improves the performance looking for the type before start to build it again. * src/abg-ctf-reader.cc (process_ctf_base_type): Add new `translation_unit_sptr' parameter. Add condition to validate success 'base_type' construction and register type object. (process_ctf_typedef): Add `lookup_type' to get a `type_base' object when this was previously created, if this is not the case, register ctf type. Add condition to validate success 'base_type' construction and register type object. (process_ctf_function_type): Likewise. (process_ctf_array_type): Likewise. (process_ctf_qualified_type): Likewise. (process_ctf_pointer_type): Likewise. (process_ctf_struct_type): Add `add_decl_to_scope'. (process_ctf_union_type): Likewise. (process_ctf_type): Add `lookup_type' to get a `type_base' object when this was previously created. Delegate register type object to `process_ctf_*'. * tests/data/Makefile.am: Add tests I/O and expected files. * tests/data/test-read-ctf/test-array-of-pointers.[co]: New testcase. * tests/data/test-read-ctf/test-list-struct.[co]: Likewise. * tests/data/test-read-ctf/test-callback.[co]: Likewise. * tests/data/test-read-ctf/test-callback2.[co]: Likewise. * tests/data/test-read-ctf/test-functions-declaration.[co]: Likewise. * tests/data/test-read-ctf/test-forward-type-decl.[co]: Likewise. * tests/data/test-read-ctf/test-array-of-pointers.abi: Expected test output. * tests/data/test-read-ctf/test-callback.abi: Likewise. * tests/data/test-read-ctf/test-callback2.abi: Likewise. * tests/data/test-read-ctf/test-forward-type-decl.abi: Likewise. * tests/data/test-read-ctf/test-functions-declaration.abi: Likewise. * tests/data/test-read-ctf/test-list-struct.abi: Likewise. * tests/test-read-ctf.cc: Add testcases to CTF test harness. Signed-off-by: Guillermo E. Martinez <guillermo.e.martinez@oracle.com> Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
|
cc1f38ffed |
Replace Python 'import importlib' with 'import importlib.machinery'
Fix-up for recent commit
|
||
|
f0582fdbf1 |
Replace use of deprecated Python 'imp' module with 'importlib'
In the test logs, I've found a number of: [...]/tests/mockfedabipkgdiff:42: DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses import imp I've asked The Internet what to do about that, and this commit is the result. But beware: I'm not a Python wizard. * tests/mockfedabipkgdiff.in: Replace use of deprecated Python 'imp' module with 'importlib'. CC: Chenxiong Qi <cqi@redhat.com> Signed-off-by: Thomas Schwinge <thomas@codesourcery.com> |
||
|
7015455949 |
configure: Instead of for rpm 4.15+ version, test actual rpm/zstd support
If no 'rpm' is available, we currently get:
[...]
checking for rpm... no
../git/configure: line 13119: rpm: command not found
configure: detected rpm version:
configure: rpm support in abipkgdiff is disabled
[...]
Here is the configuration of the package:
[...]
Enable rpm support in abipkgdiff : no
Enable rpm 4.15 support in abipkgdiff tests : no
[...]
Notice intermixed error output: 'rpm: command not found'.
If Ubuntu focal 'rpm' 4.14.2.1+dfsg1-1build2 is available, we currently get:
[...]
checking for rpm... yes
configure: detected rpm version: 4.14.2.1
configure: rpm support in abipkgdiff is enabled
configure: rpm 4.15 support in abipkgdiff tests is enabled
[...]
Here is the configuration of the package:
[...]
Enable rpm support in abipkgdiff : yes
Enable rpm 4.15 support in abipkgdiff tests : yes
[...]
Notice wrong 4.15+ version detection (due to '[[ "$rpmversion" > "4.14.0" ]]'),
which is satisfied by '4.14.2.1'. (Comparing versions with shell '[['
generally is fragile; instead use 'autoconf-archive/ax_compare_version.m4'
or similar?)
Also, 'configure'ing with '--disable-rpm415' doesn't work; same output as
before. That's due to commit
|
||
|
f76484cc9d |
Add regression tests for ctf reading
This patch implements some regression tests for ctf reading. Since the code shares a lot of functionalities already used in the readi-dwarf test, a library was built and test common harness were moved to a common location. So input files for test-read-{dwarf,ctf}.cc now are located in: tests/data/test-read-common directory, ABIs description are stored in the same location but in a separate file, one for each binary debugging information: (e.g, test4-ctf.so.abi and test4-dwarf.so.abi) * tests/test-read-ctf.cc: New ctf reading regression test. * tests/test-read-common.cc: New library to be used with test-read-{ctf,dwarf}.cc. * tests/test-read-common.h: Likewise. * tests/test-annotate.cc (in_out_specs): Adjust path for input files. * tests/Makefile.am: Build new tests/test-read-ctf.cc file. * tests/data/Makefile.am: Add test inputs and expected files. Add libtestreadcommon.a test library and use it for test-read-{ctf,dwarf}. * tests/test-read-dwarf.cc: Adapt test to use libtestreadcommon.a in test-read-common.{cc,h}. * tests/data/test-annotate/test3.so.abi: Adjust ELF input path file location to ./tests/data/test-read-common. * tests/data/test-annotate/test4.so.abi: Likewise. * tests/data/test-read-common/PR26261: Move test harness to test-read-common directory. * tests/data/test-read-common/PR27700: Likewise. * tests/data/test-read-common/test-PR26568-*: Likewise. * tests/data/test-read-common/test3.{c,so}: Likewise. * tests/data/test-read-common/test4.{c,so}: Likewise. * tests/data/test-read-common/crti*: Helper object to export _init and _fini sysmbols. * tests/data/test-read-ctf/test-ambiguous-struct-A.c: New testcase. * tests/data/test-read-ctf/test-ambiguous-struct-B.c: Likewise. * tests/data/test-read-ctf/test-conflicting-type-syms-a.c: Likewise. * tests/data/test-read-ctf/test-conflicting-type-syms-b.c: Likewise. * tests/data/test-read-ctf/test-enum.c: Likewise. * tests/data/test-read-ctf/test-enum-many.c: Likewise. * tests/data/test-read-ctf/test-enum-symbol.c: Likewise. * tests/data/test-read-ctf/test-struct-iteration.c: Likewise. * tests/data/test-read-ctf/test-dynamic-array.c: Likewise. * tests/data/test-read-ctf/test0.c: Likewise. * tests/data/test-read-ctf/test1.c: Likewise. * tests/data/test-read-ctf/test2.c: Likewise. * tests/data/test-read-ctf/test5.c: Likewise. * tests/data/test-read-ctf/test7.{c,h}: Likewise. * tests/data/test-read-ctf/test8.c: Likewise. * tests/data/test-read-ctf/test9.c: Likewise. * tests/data/test-read-ctf/test-ambiguous-struct-A.o.hash.abi: Testcase expected result. * tests/data/test-read-ctf/PR26261/PR26261-exe.abi: Likewise. * tests/data/test-read-ctf/PR27700/test-PR27700.abi: Likewise. * tests/data/test-read-ctf/test-ambiguous-struct-A.o.hash.abi: Likewise. * tests/data/test-read-ctf/test-ambiguous-struct-B.o.hash.abi: Likewise. * tests/data/test-read-ctf/test-conflicting-type-syms-a.o.hash.abi: Likewise. * tests/data/test-read-ctf/test-conflicting-type-syms-b.o.hash.abi: Likewise. * tests/data/test-read-ctf/test-enum.o.abi: Likewise. * tests/data/test-read-ctf/test-enum-many.o.hash.abi: Likewise. * tests/data/test-read-ctf/test-enum-symbol.o.hash.abi: Likewise. * tests/data/test-read-ctf/test-struct-iteration.o.abi: Likewise. * tests/data/test-read-ctf/test-dynamic-array.o.abi: Likewise. * tests/data/test-read-ctf/test0: Likewise. * tests/data/test-read-ctf/test0*.abi: Likewise. * tests/data/test-read-ctf/test1.so: Likewise. * tests/data/test-read-ctf/test1*.abi: Likewise. * tests/data/test-read-ctf/test2.so: Likewise. * tests/data/test-read-ctf/test2*.abi: Likewise. * tests/data/test-read-ctf/test3.so.abi: Likewise. * tests/data/test-read-ctf/test4*.abi: Likewise. * tests/data/test-read-ctf/test5.o.abi: Likewise. * tests/data/test-read-ctf/test7.o.abi: Likewise. * tests/data/test-read-ctf/test8.o.abi: Likewise. * tests/data/test-read-ctf/test9.o.abi: Likewise. * tests/data/test-read-dwarf/PR26261/PR26261-exe.abi: Update expected abixml file. * tests/data/test-read-dwarf/PR27700/test-PR27700.abi: Likewise. * tests/data/test-read-dwarf/test-PR26568-1.*.abi: Likewise. * tests/data/test-read-dwarf/test3*.abi: Likewise. * tests/data/test-read-dwarf/test4*.abi: Likewise. * doc/api/libabigail.doxy: Add tests/test-read-common.{cc,h} to doxygen. Signed-off-by: Guillermo E. Martinez <guillermo.e.martinez@oracle.com> Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
|
6ed534a300 |
XML writer: use exemplar types for tracking referenced types
The emitted type sets are used with some referenced type sets (which use bare type pointers). To keep consistency between what is being recorded in each set, switch to storing exemplar type pointers in the referenced type sets. This change results in the omission of a small number of duplicate types from various test cases. In each case the duplicates were previously caused by a referenced type being emitted for one translation unit and then the same type being emitted as a canonical type for a later translation unit. It also causes the movement of some function types in some test cases. Some of those types are now considered referenced and appear earlier as a result. * src/abg-writer.cc (record_type_as_referenced): Use exemplar type with referenced type sets. (type_is_referenced): Likewise. (tests/data/test-annotate/test14-pr18893.so.abi): Duplicate type(s) removed, as described above. (tests/data/test-read-dwarf/test14-pr18893.so.abi): Likewise. (tests/data/test-annotate/test19-pr19023-libtcmalloc_and_profiler.so.abi): Likewise. (tests/data/test-read-dwarf/test16-pr18904.so.abi): Likewise. (tests/data/test-read-dwarf/test19-pr19023-libtcmalloc_and_profiler.so.abi): Likewise. (tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi): Likewise. (tests/data/test-read-dwarf/PR25007-sdhci.ko.abi): Some function type(s) reordered, as described above. (tests/data/test-read-dwarf/PR25042-libgdbm-clang-dwarf5.so.6.0.0.abi): Likewise. (tests/data/test-annotate/test15-pr18892.so.abi):: Duplicate type(s) removed and some function type(s) reordered, as described above. (tests/data/test-read-dwarf/test15-pr18892.so.abi): Likewise. (tests/data/test-annotate/test21-pr19092.so.abi): Likewise. (tests/data/test-read-dwarf/test21-pr19092.so.abi): Likewise Reviewed-by: Giuliano Procida <gprocida@google.com> Signed-off-by: Matthias Maennich <maennich@google.com> Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
|
3e0eeb9f98 |
suppression: Fix has_data_member_inserted_between = {offset_of(), offset_of()}
This should fix bug https://sourceware.org/bugzilla/show_bug.cgi?id=28073 There is at least a case where the evaluation of the suppression specification rule incarnated by the property has_data_member_inserted_between doesn't work. This is in the context of the following suppression specification: [suppress_type] name = struct_foo has_data_member_inserted_between = {offset_of(dm1), offset_of(dm2)} The evaluation of the rule incarnated by has_data_member_inserted_between fails in the context of a type change where the data member "dm1" is removed from the type struct_foo. In that case, the evaluation of the suppression should ALWAYS yield to the suppression specification NOT suppressing the change. But in some cases the change is suppressed nonetheless. This patch fixes that. The idea of the patch is that if the class has a removed data member or if its size shrinks then no type change on that class can be suppressed. This is because those two kinds of change are incompatible ABI (or at least API) changes. So they should be reported. The patch also fixes the evaluation of the boundaries of the insertion range expressed as an "offset_after" expression. * doc/manuals/libabigail-concepts.rst: Update the documentation to reflect that has_data_member* properties will never suppress any type change if the change carries a data member suppression or a type size reduction. * include/abg-fwd.h (get_last_data_member) (get_next_data_member_offset): Declare new functions. * include/abg-suppression.h (insertion_range::boundary_value_is_end): Declare new static member function. (type_supression::insertion_range::eval_boundary): Make this static function take an uint64_t rather than ssize_t. (type_suppression::insertion_range::integer_boundary::{integer_boundary, as_integer, operator int}): Make these member functions and operator take or return uint64_t rather than int. * src/abg-ir.cc (get_last_data_member) (get_next_data_member_offset): Define new functions. * src/abg-suppression.cc (type_suppression::suppresses_diff): Rework logic to better handle "has_data_member_inserted_*" properties in the context of class diffs. If the diff object carries data member removal or size reduction, the diff object is not suppressed by the current type suppression. Also, the property "has_data_member_inserted_at = end", is now represented by an insertion range where the beginning and the end of the range are both the max possible value of insertion range boundaries; the code is made to recognize that. (type_suppression::insertion_range::eval_boundary): Make this static function take an uint64_t rather than ssize_t. If the boundary is expressed as a "offset_after" expression, make sure the offset of the next data member is considered if it's present. (type_suppression::insertion_range::integer_boundary::{integer_boundary, as_integer, operator int}): Make these take or return uint64_t rather than int. (type_suppression::insertion_range::boundary_value_is_end): Define new member function. (type_suppression::insertion_range::integer_boundary::priv::value_): Turn the type of this into uint64_t, from int. (type_suppression::insertion_range::integer_boundary::priv::priv): The parameter of this is now uint64_t, from int. * tests/data/test-diff-suppr/PR28073/PR28073-bitfield-removed.c: New test source code. * tests/data/test-diff-suppr/PR28073/PR28073-bitfield-removed.o: New test binary. * tests/data/test-diff-suppr/PR28073/PR28073-bitfield-removed.o.abi: New test input. * tests/data/test-diff-suppr/PR28073/PR28073-output-{1,2}.txt: New test reference output. * tests/data/test-diff-suppr/PR28073/PR28073.after.o: New test binary. * tests/data/test-diff-suppr/PR28073/PR28073.after.o.abi: New test input. * tests/data/test-diff-suppr/PR28073/PR28073.before.o: New test binary. * tests/data/test-diff-suppr/PR28073/PR28073.before.o.abi: New test input. * tests/data/test-diff-suppr/PR28073/PR28073.c: New test source code. * tests/data/test-diff-suppr/PR28073/bitfield.suppr: New test input. * tests/data/Makefile.am: Add the new test material to source distribution. * tests/test-diff-suppr.cc: Add the new test input to this test harness. Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
|
eea4e92b2d |
Standardize and improve the output of several tests
This patch updates several test harnesses to make their output show the command line of the failing tests, a brief informative summary about the number of unit tests executed, failed and executed with success. These tests now used the abigail::tests::emit_test_{summary,status_and_update_counters} functions provided in tests/test-utils.cc. * tests/test-abidiff-exit.cc (main): Use abigail::tests::emit_test_{summary, status_and_update_counters} functions to ameliorate and standardize test output. * tests/test-alt-dwarf-file.cc (main): Likewise. * tests/test-annotate.cc (main): Likewise. * tests/test-diff-dwarf-abixml.cc (main): Likewise. * tests/test-ini.cc (main): Likewise. * tests/test-lookup-syms.cc (main): Likewise. Signed-off-by: tangmeng <tangmeng@uniontech.com> Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
|
41625582a3 |
test-utils: Define test status reporting functions
* tests/test-utils.h (emit_test_status_and_update_counters) (emit_test_summary): Declare ... * tests/test-utils.cc (emit_test_status_and_update_counters) (emit_test_summary): ... new functions. Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
|
c9e74e49d6 |
test-utils: Define colors for test status messages
This patch defines pre-processor macros for the colors used to emit test SUCCESS/FAILURE status. These are going to be used by the code, onward. * tests/test-utils.h (TEST_FAILURE_COLOR, TEST_SUCCESS_COLOR): Define macros. Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
|
5ac010cc9b |
Bug 28584 - Don't drop global variables that lack DW_AT_external
Clang doesn't always emit the DW_AT_external property that flags a decl as being external. In those cases, the DWARF reader just drops the variable on the floor as it considers it as being "non-exported". This patch considers that a variable decl that is at named namespace scope is essentially "external". Then if the variable has an ELF symbol associated to it, then an IR node will be created for it. The other changes are just needed adaptations due to the core change. * src/abg-dwarf-reader.cc (die_is_effectively_public_decl): Define new static function. (die_flag_attribute, die_is_public_decl): Adjust const-ness. (build_ir_node_from_die): When building an IR for a variable, consider the variable as being external if the variable is at namespace scope, even if its DIE doesn't have the DW_AT_external attribute. * tests/data/test-read-dwarf/PR28584/PR28584-smv.cc: New source code for a new clang-built binary. * tests/data/test-read-dwarf/PR28584/PR28584-smv.clang.o: New clang-built input binary for testing purposes. * tests/data/test-read-dwarf/PR28584/PR28584-smv.clang.o.abi: The reference output abixml. * tests/data/Makefile.am: Add the new test material above to source distribution. * tests/test-read-dwarf.cc (in_out_specs): Add the new test input to this test harness. * tests/data/test-read-dwarf/PR22122-libftdc.so.abi: Adjust. * tests/data/test-read-dwarf/test-libandroid.so.abi: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
|
ddad560153 |
Move dwarf_reader::status facilities to an abigail::elf_reader namespace
The DWARF reader is no longer the only ELF-based reader in libabigail: the CTF reader also operates on ELF files. Other ELF-based formats (such as BTF) may also join in the future. These readers share a lot of similarities: they all operate on object files, they fetch debugging information from certain sections, they rely on the symtab of the read object, the debugging info may be in a separated file (for certain formats) and so on. It follows that a lot of logic can be shared among all the ELF-based readers. This patch is oriented to that direction. A new namespace, abigail::elf_reader, is introduced with the goal of holding features and definitions useful for any ELF-based abigail reader. Then all the definitions related to the status resulting from extracting a corpus from an object file (the dwarf_reader::status) are moved to abigail::elf_reader. The utilities and tests are adjusted accordingly. Signed-off-by: Jose E. Marchesi <jose.marchesi@oracle.com> * include/abg-reader-common.h: New file. * include/abg-dwarf-reader.h (enum status): Move to abg-reader-status.h. (status_to_diagnostic_string): Likewise. (operator|): Likewise. (operator&): Likewise. (operator|=): Likewise. (operator&=): Likewise. Include abg-reader-common.h. * include/Makefile.am (pkginclude_HEADERS): Add abg-elf-reader-common.h. * src/abg-elf-reader-status.cc: New file. * src/abg-dwarf-reader.cc (operator|): Move to abg-elf-reader-common.cc. (operator&): Likewise. (operator|): Likewise. (operator|=): Likewise. (operator&=): Likewise. (status_to_diagnostic_string): Likewise. * src/Makefile.am (libabigail_la_SOURCES): Add elf-reader-common.cc. * src/abg-tools-utils.cc: Use abigail::elf_reader instead of abigail::dwarf_reader for the status definitions. * tools/abicompat.cc: Likewise. * tools/abidiff.cc: Likewise. * tools/abidw.cc: Likewise. * tools/abilint.cc: Likewise. * tools/abipkgdiff.cc: Likewise. * tests/print-diff-tree.cc: Likewise. * tests/test-diff-dwarf.cc: Likewise. * tests/test-read-dwarf.cc: Likewise. * tests/test-symtab.cc: Likewise. * tests/test-ir-walker.cc: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
|
861e4670b6 |
Bug 28450 - Fix cloned member function handling in DWARF
When the DWARF reader encounters a function DIE 'f' that has a DW_AT_specification that points to a member function, the current implementation creates a function IR for the member function. The problem is that the member function has no ELF symbol associated to it. The ELF symbol is associated to 'f', not to the member function. The DWARF reader then wrongly drops the member function on the floor because it has no ELF symbol function associated. So that member function specification never gets its concrete function represented in the IR. This patch fixes the issue by detecting that the member function is the "specification" for 'f' and that the ELF symbol associated to it might not be there. In that case, if the ELF symbol is on the 'f' DIE itself, we get it from there. The patch makes more member functions to be represented so it uncovers a latent issue which is explained below. Today, some compilers can emit redundant DWARF constructs like "const reference" or "const void". A reference is always const so the const is superfluous. A similar thing can be said about "const void". maybe_strip_qualification detects those constructs and rewrites the IR into a "no-op qualified reference", or a "no-op qualified void". The no-op was needed in the previous incarnations of the DWARF reader because it was expecting a 'qualified type' IR to be associated to a qualified type DIE. Note, however, that that expectation has been generally relaxed since then. The problem is that the comparison engine, when building the diff IR needs to strip those no-op qualified types off, to avoid having spurious change diagnostics. That stripping introduces some challenges because the tree is more or less un-mutable at that point (after type canonicalization) so the stripping can only be partial. This patch removes the no-op qualified types altogether, rather than trying harder to handle them down the line. In other words, a const reference is now represented as a reference and a const void as a void. This makes things much simpler. The problem however is that the in-memory IR (and thus the emitted ABIXML) doesn't have any no-op qualified type anymore. So comparing an old ABIXML that contains those no-op qualified types against its origin ELF corpus can yield some spurious diagnostics. To fix it, one needs to re-generate the ABIXML file. This patch bumps the ABIXML version to 2.1 and introduces a new ABIXML-FORMAT-VERSIONS file that documents the format changes. * ABIXML-FORMAT-VERSIONS: New file that documents the version changes of the ABIXML-FORMAT-VERSIONS. * include/abg-fwd.h (look_through_no_op_qualified_type): Remove this function declaration. (strip_useless_const_qualification): Declare new function declaration. * src/abg-comparison.cc (compute_diff_for_types): Avoid stripping off no-op-qualified types as these beasts don't exist anymore. (redundancy_marking_visitor::visit_end): Allow a variable which type has local changes to be considered redundant if its type is itself redundant. * src/abg-config.cc (config::config): Bump the abixml version from 2.0 to 2.1. * src/abg-dwarf-reader.cc (maybe_strip_qualification): Factorize out the new strip_useless_const_qualification function from here. (build_or_get_fn_decl_if_not_suppressed): If the function is created but doesn't have an ELF symbol associated to it, then update it so that the ELF symbol can be associated. Otherwise, potential_member_fn_should_be_dropped might later drop that function on the floor because it doesn't have any ELF symbol associated. * src/abg-ir.cc (strip_useless_const_qualification): Define this, which is has been factorized out of maybe_strip_qualification. (look_through_no_op_qualified_type): Remove this definition. (equals): In the overload for reference_type_def, do not peel typedefs off from the reference before comparison. This is now useless as the comparison infrastructure got a lot better. In the overload for references, stop using look_through_no_op_qualified_type as this function doesn't exist anymore. * src/abg-tools-utils.cc (abidiff_status_has_error): Detect when there is a usage error as well. * tests/data/test-types-stability/PR28450-libepetra.so.13.0: Add new testing binary to the repository. * tests/data/Makefile.am: Add the new testing binary above to source distribution. * tests/test-types-stability.cc (elf_paths): Add the new test to this test harness. * tests/test-diff-dwarf-abixml.cc (main): Add better error messages. * tests/data/test-abidiff-exit/test-member-size-report0.txt: Adjust. * tests/data/test-annotate/libtest23.so.abi: Likewise. * 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/test-anonymous-members-0.o.abi: Likewise. * tests/data/test-annotate/test0.abi: Likewise. * tests/data/test-annotate/test1.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/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/test20-pr19025-libvtkParallelCore-6.1.so.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-diff-dwarf-abixml/test0-pr19026-libvtkIOSQL-6.1.so.1.abi: Likewise. * tests/data/test-diff-dwarf/test0-report.txt: Likewise. * tests/data/test-diff-dwarf/test28-vtable-changes-report-0.txt: Likewise. * tests/data/test-diff-dwarf/test42-PR21296-clanggcc-report0.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/test10-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/test30-pr18904-rvalueref-report2.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-filter/test35-pr18754-no-added-syms-report-0.txt: Likewise. * tests/data/test-diff-filter/test35-pr18754-no-added-syms-report-1.txt: Likewise. * tests/data/test-diff-filter/test41-report-0.txt: Likewise. * tests/data/test-diff-filter/test9-report.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/test24-soname-report-1.txt: Likewise. * tests/data/test-diff-suppr/test24-soname-report-10.txt: Likewise. * tests/data/test-diff-suppr/test24-soname-report-12.txt: Likewise. * tests/data/test-diff-suppr/test24-soname-report-14.txt: Likewise. * tests/data/test-diff-suppr/test24-soname-report-16.txt: Likewise. * tests/data/test-diff-suppr/test24-soname-report-4.txt: Likewise. * tests/data/test-diff-suppr/test31-report-1.txt: Likewise. * tests/data/test-read-dwarf/PR22015-libboost_iostreams.so.abi: Likewise. * tests/data/test-read-dwarf/PR22122-libftdc.so.abi: Likewise. * tests/data/test-read-dwarf/libtest23.so.abi: Likewise. * 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/test-libaaudio.so.abi: Likewise. * tests/data/test-read-dwarf/test-libandroid.so.abi: Likewise. * tests/data/test-read-dwarf/test0.abi: Likewise. * tests/data/test-read-dwarf/test0.hash.abi: Likewise. * tests/data/test-read-dwarf/test1.abi: Likewise. * tests/data/test-read-dwarf/test1.hash.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/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/test2.so.abi: Likewise. * tests/data/test-read-dwarf/test2.so.hash.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/test3-alias-1.so.hash.abi: Likewise. * tests/data/test-read-dwarf/test3-alias-2.so.hash.abi: Likewise. * tests/data/test-read-dwarf/test3-alias-3.so.hash.abi: Likewise. * tests/data/test-read-dwarf/test3-alias-4.so.hash.abi: Likewise. * tests/data/test-read-dwarf/test3.so.abi: Likewise. * tests/data/test-read-dwarf/test3.so.hash.abi: Likewise. * tests/data/test-read-dwarf/test4.so.abi: Likewise. * tests/data/test-read-dwarf/test4.so.hash.abi: Likewise. * tests/data/test-read-dwarf/test5.o.abi: Likewise. * tests/data/test-read-dwarf/test5.o.hash.abi: Likewise. * tests/data/test-read-dwarf/test6.so.abi: Likewise. * tests/data/test-read-dwarf/test6.so.hash.abi: Likewise. * tests/data/test-read-dwarf/test7.so.abi: Likewise. * tests/data/test-read-dwarf/test7.so.hash.abi: Likewise. * tests/data/test-read-dwarf/test8-qualified-this-pointer.so.abi: Likewise. * tests/data/test-read-dwarf/test8-qualified-this-pointer.so.hash.abi: Likewise. * tests/data/test-read-dwarf/test9-pr18818-clang.so.abi: Likewise. * tests/data/test-read-write/test-crc.xml: Likewise. * tests/data/test-read-write/test26.xml: Likewise. * tests/data/test-read-write/test27.xml: Likewise. * tests/data/test-read-write/test28-without-std-fns-ref.xml: Likewise. * tests/data/test-read-write/test28-without-std-vars-ref.xml: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
|
b7ba0fe8f5 |
test-abicompat: Make the test output more pleasant
When testing with runtestabicompat, the following problems were found: 1. abicompat tested multiple scenarios, but the last result was used as the basis for the return value of the command. 2. For multiple test scenarios, the execution results cannot be known after the test, which is easy to cause confusion. * test/test-abicompat.cc (main): make test output more pleasant. Signed-off-by: tangmeng <tangmeng@uniontech.com> Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
|
824e104a23 |
Add debug info package for wireshark-cli-3.4.9-1.fc36.x86_64.rpm
I forgot to add the wireshark-cli-3.4.9-1.fc36.x86_64.rpm debug info package for the test entry that uses it in tests/test-diff-pkg.cc. It's not necessary on the x86-64 platform, but on many others, it seems the alternate debug info contained in that package is needed. So I am adding it in here. * tests/data/test-diff-pkg/wireshark/wireshark-debuginfo-3.4.9-1.fc36.x86_64.rpm: Add new debug info package. * tests/data/Makefile.am: Add it to the source distribution. * tests/test-diff-pkg.cc: Use the new debug info package in the test harness. Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
|
991283269e |
Bug 28364 - libwiretap fails self comparison
In this case, thanks to all the debugging infrastructure in place, especially the canonical type debugging infrastructure, I was able to notice that there was a canonicalization error on a function type when reading the libwiretap binary as in: $ build/tools/abidw --debug-tc /usr/lib64/libwiretap.so.11.0.8 structural & canonical equality different for type: function type void (wtap*) in compare_types_during_canonicalization at: /home/dodji/git/libabigail/PR28364/src/abg-ir.cc:13575: execution should not have reached this point! Abandon (core dumped) $ When digging deeper, I noticed that, in the DWARF reader, when building a function type, we are associating a "textual representation" of the function type 'void (wtap*)' to its DIE (inside the current translation) way too early. By too early, I mean, the association was done before the function type was fully 'built'. Its parameters were not 'collected', for instance. So that means that a 'pointer to that function type' could be formed, with a wrong representation, during the time where the function type wasn't fully formed. Just moving the association to after the type was fully constructed solved the issue. This one was hard to spot! Later, this uncovered the fact that we could now have (and thus serialize) member functions of unions. And it turned out the abixml reader didn't expect those. Oops. I fixed that one as well. * src/abg-dwarf-reader.cc (build_function_type): Associate the DIE representation to the constructed type once it's fully built. * src/abg-reader.cc (build_function_type): Support member function of unions. * tests/data/Makefile.am: Add the new test input files to the source distribution. * tests/data/test-diff-pkg/wireshark/wireshark-cli-3.4.9-1.fc36.x86_64-self-check-report.txt: Add new test input file. * tests/data/test-diff-pkg/wireshark/wireshark-cli-3.4.9-1.fc36.x86_64.rpm: Likewise. * tests/data/test-diff-pkg/wireshark/wireshark-cli-debuginfo-3.4.9-1.fc36.x86_64.rpm: Likewise. * tests/test-diff-pkg.cc (in_out_specs): Add these new test input files to this test harness. * tests/data/test-read-dwarf/PR25007-sdhci.ko.abi: Adjust. Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
|
a10aee0763 |
ir: Avoid canonicalizing types that are not meant to
hash_as_canonical_type_or_constant asserts that a certain number of types are not meant to be canonicalized. We ought to make sure that type_base::get_canonical_type_for always agrees with hash_as_canonical_type_or_constant. This patch enforces that for good measure. * src/abg-ir.cc (type_base::get_canonical_type_for): Do not canonicalize types that are not meant to. (maybe_adjust_canonical_type): Do not crash when dealing with a nil canonical type. * tests/data/test-annotate/libtest23.so.abi: Adjust. * 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/test-anonymous-members-0.o.abi: Likewise. * tests/data/test-annotate/test0.abi: Likewise. * tests/data/test-annotate/test1.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/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/test3.so.abi: Likewise. * tests/data/test-annotate/test5.o.abi: Likewise. * tests/data/test-annotate/test8-qualified-this-pointer.so.abi: Likewise. * tests/data/test-read-dwarf/PR22015-libboost_iostreams.so.abi: Likewise. * tests/data/test-read-dwarf/PR22122-libftdc.so.abi: Likewise. * tests/data/test-read-dwarf/PR24378-fn-is-not-scope.abi: Likewise. * tests/data/test-read-dwarf/PR25007-sdhci.ko.abi: Likewise. * tests/data/test-read-dwarf/PR25042-libgdbm-clang-dwarf5.so.6.0.0.abi: Likewise. * tests/data/test-read-dwarf/PR26261/PR26261-exe.abi: Likewise. * tests/data/test-read-dwarf/PR27700/test-PR27700.abi: Likewise. * tests/data/test-read-dwarf/libtest23.so.abi: Likewise. * 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/test-PR26568-1.o.abi: Likewise. * tests/data/test-read-dwarf/test-PR26568-2.o.abi: Likewise. * tests/data/test-read-dwarf/test-libaaudio.so.abi: Likewise. * tests/data/test-read-dwarf/test-libandroid.so.abi: Likewise. * tests/data/test-read-dwarf/test-suppressed-alias.o.abi: Likewise. * tests/data/test-read-dwarf/test0.abi: Likewise. * tests/data/test-read-dwarf/test0.hash.abi: Likewise. * tests/data/test-read-dwarf/test1.abi: Likewise. * tests/data/test-read-dwarf/test1.hash.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/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/test2.so.abi: Likewise. * tests/data/test-read-dwarf/test2.so.hash.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/test3-alias-1.so.hash.abi: Likewise. * tests/data/test-read-dwarf/test3-alias-2.so.hash.abi: Likewise. * tests/data/test-read-dwarf/test3-alias-3.so.hash.abi: Likewise. * tests/data/test-read-dwarf/test3.so.abi: Likewise. * tests/data/test-read-dwarf/test3.so.hash.abi: Likewise. * tests/data/test-read-dwarf/test5.o.abi: Likewise. * tests/data/test-read-dwarf/test5.o.hash.abi: Likewise. * tests/data/test-read-dwarf/test8-qualified-this-pointer.so.abi: Likewise. * tests/data/test-read-dwarf/test8-qualified-this-pointer.so.hash.abi: Likewise. * tests/data/test-read-dwarf/test9-pr18818-clang.so.abi: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
|
53c0601b04 |
tests/Makefile.am: Fix warning
Fix a nagging warning coming from referencing test binaries that are no more present. * tests/Makefile.am: Stop referring to test-dot.cc which is no more. Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
|
c00add2a21 |
Bug 27086 - Consider all C++ virtual destructors when there are many
The complete and deleting C++ destructors have the same signature. Because the dwarf-reader re-uses the IR of functions that have the same signature, it can happen that one of the two destructors of a class is missed and thus not represented in the IR. When these destructors are virtual, that can have an impact on class comparison, because virtual member functions are take part in class comparison, just like data member and unlike non-virtual member functions. This patch fixes the build_or_get_fn_decl_if_not_suppressed to avoid "reusing" virtual destructors, based on their signature when several are present. Instead an IR is built for all virtual destructors that are seen. * src/abg-dwarf-reader.c (build_or_get_fn_decl_if_not_suppressed): Do not try to re-use a virtual destructor of a class, based on its signature. Several different of these can have the same signature, inside a given class. * tests/data/test-types-stability/PR27086-libstdc++.so.6.0.26: Add new binary test input. * tests/data/Makefile.am: Add the new test input to source distribution. * tests/test-types-stability.cc (elf_paths): Add the test input above to this harness. Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
|
86a1738d96 |
Bug 27970 - Duplicated member functions cause spurious self comparison changes
Sometimes, in DWARF, a given class can even be defined piece-wise across several DIEs. The first DIE would defined some properties and subsequent DIEs would define others. dwarf-reader already supports this for most properties. Some properties however can be duplicated across two DIES. For instance, a DIE describing a class 'C' can define a virtual member function, and then a subsequent different DIE further describing other properties of the same class C would define the same virtual member function again. In that case, we should not define the virtual member function twice in the IR of C that is being built. Libabigail is failing to do exactly that. It's representing the virtual member function of C twice in this case. * src/abg-dwarf-reader.cc (fixup_functions_with_no_symbols): When the function decl is finally associated to its (publicly defined) ELF symbol, mark it as being exported. (finish_member_function_reading): Don't risk marking a virtual function as being non-virtual when updating its properties. (build_or_get_fn_decl_if_not_suppressed): Update comment. If the member function is already present in the class, do not create a new one; rather, reuse the existing one. It's going to be later updated by finish_member_function_reading. * tests/data/test-annotate/test18-pr19037-libvtkRenderingLIC-6.1.so.abi: Adjust. * tests/data/test-annotate/test20-pr19025-libvtkParallelCore-6.1.so.abi: 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-filter/test41-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-read-dwarf/PR22015-libboost_iostreams.so.abi: Likewise. * tests/data/test-read-dwarf/test10-pr18818-gcc.so.abi: Likewise. * tests/data/test-read-dwarf/test18-pr19037-libvtkRenderingLIC-6.1.so.abi: Likewise. * tests/data/test-read-dwarf/test20-pr19025-libvtkParallelCore-6.1.so.abi: Likewise. * tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
|
1115e3f08e |
abipkgdiff: Do not erase working dirs before we are done using them
* tools/abipkgdiff.cc (compare_prepared_userspace_packages): Removing working directories "early" prevents e.g, dwarf_reader::get_soname_of_elf_file from accessing those files. So do not remove them until the very end. * tests/data/test-diff-pkg/libxcrypt-4.1.1-6.el8.x86_64--libxcrypt-4.1.1-6.el8.x86_64-output-1.txt: Adjust. Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
|
321da66678 |
Bug 28316 - Failure to represent typedef named anonymous enums
Consider these two anonymous enum declarations in these different contexts: enum {A0 = 0; A1 = 1;} global0; // 1/: anonymous enum typedef enum {E0 = 0; E1 = 1;} E; // 2/: anonymous enum named by a typedef. E global0; In the first context "1/", the type of the global variable is an anonymous enum that is used as such. In the second context "2/", the type of the global variable is an anonymous type that is named by the typedef 'E'. So then, it's E that is used to designate the enum. The anonymous type is thus never used directly. In essence, it's the same thing as if it was declared as enum E {E0 = 0; E1 = 1;}; Right now, libabigail canonicalizes the enum 1/ and 2/ together and that results in 1/ being canonically equal to 2/. So, when saving the corpus into abixml, because enum 1/ and enum 2/ can be used interchangeably, either 1/ or 2/ is going to be saved. That can result in spurious change reports in which the reporter refer to the enum 1/ where it should refer to enum 2/ or vice versa. Intrinsically, the enum 1/ and enum 2/ are different because one essentially has a name (provided by a typedef) and the second does not. One is anonymous whereas the second is not, essentially. At the moment, libabigail supports typedef-named anonymous classes. But it doesn't support this concept for enums. This patch extends that concept to enums as well. It makes it so that any anonymous type can now by typedef-named. In that case, the type now looks like it has a name which is the typedef name. The information about the typedef naming a given type is kept and serialized into abixml. Thus with this patch, the enum in 1/ is now considered (canonically) different from enum 2/. So there is no possible confusion once the type is serialized into abixml. * include/abg-fwd.h (scope_anonymous_or_typedef_named) (is_anonymous_or_typedef_named): Declare new functions. * include/abg-ir.h (decl_base::set_has_anonymous_parent): Remove declaration. (decl_base::{get,set}_naming_typedef): Declare new member functions. * src/abg-ir.cc (update_qualified_name): Define static function. (decl_base::priv::naming_typedef_): Define new data member. (decl_base::priv::has_anonymous_parent_): Remove data member. (decl_base::priv::priv): Adjust constructor. (decl_base::get_has_anonymous_parent): Rather than storing a flag for this, dynamically look at if the scope is anonymous. (decl_base::set_has_anonymous_parent): Remove definition. (decl_base::{get,set}_naming_typedef): Define new member functions. (scope_anonymous_or_typedef_named) (is_anonymous_or_typedef_named): Define new functions. (get_decl_name_for_comparison): Define new sub-routine for the decl_base overload of equals. (equals): In the overload for decl_base, use the new get_decl_name_for_comparison. It helps to ensure that all anonymous decls of the same kind have the same name for the purpose of comparison. It also ensures that non anonymous decls that are part of anonymous scopes should be compared only by looking at their non-qualified names. In the overload for class_or_union, adjust. (scope_decl::add_member_decl): No more need to flag the fast that the parent scope is anonymous here. (get_debug_representation): Fix a thinko. (class_or_union::get_naming_typedef): Remove member function as it's now handled by decl_base::get_naming_typedef. * src/abg-dwarf-reader.cc (build_typedef_type): When a typedef is a naming typedef, then mark the named decl as being typedef-named. (maybe_canonicalize_type): Delay canonicalization of anonymous types because they can be typedef-named later. * src/abg-reader.cc (read_naming_typedef_id_string) (maybe_set_naming_typedef): Define new static function. (build_class_decl): Use it here, rather than reading the "naming-typedef-id" by hand. (build_enum_type_decl, build_union_decl): Read the "naming-typedef-id" property. * src/abg-writer.cc (write_naming_typedef): Make this accept decl_base_sptr, rather than just class_decl_sptr. (write_enum_type_decl): Write the naming-typedef-id property if needed. * tests/data/test-abidiff-exit/test-PR28316-report.txt: New test reference output. * tests/data/test-abidiff-exit/test-PR28316-v{0,1}.cc: Source code of new binary test input. * tests/data/test-abidiff-exit/test-PR28316-v{0,1}.o: New binary test input files. * tests/data/Makefile.am: Add the new test files to the source distribution. * tests/test-abidiff-exit.cc: Add the new test files above to this harness. * tests/data/test-annotate/libtest23.so.abi: Adjust. * 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/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/test21-pr19092.so.abi: Likewise. * tests/data/test-diff-dwarf/test15-enum-report.txt: Likewise. * tests/data/test-diff-filter/test19-enum-report-1.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/test30-pr18904-rvalueref-report2.txt: Likewise. * tests/data/test-diff-filter/test35-pr18754-no-added-syms-report-0.txt: Likewise. * tests/data/test-diff-pkg/PR24690/PR24690-report-0.txt: Likewise. * tests/data/test-diff-pkg/nss-3.23.0-1.0.fc23.x86_64-report-0.txt: Likewise. * tests/data/test-diff-pkg/spice-server-0.12.4-19.el7.x86_64-0.12.8-1.el7.x86_64-report-0.txt: Likewise. * tests/data/test-diff-pkg/spice-server-0.12.4-19.el7.x86_64-0.12.8-1.el7.x86_64-report-1.txt: Likewise. * tests/data/test-diff-pkg/spice-server-0.12.4-19.el7.x86_64-0.12.8-1.el7.x86_64-report-2.txt: Likewise. * tests/data/test-diff-pkg/spice-server-0.12.4-19.el7.x86_64-0.12.8-1.el7.x86_64-report-3.txt: Likewise. * tests/data/test-read-dwarf/PR22015-libboost_iostreams.so.abi: Likewise. * tests/data/test-read-dwarf/PR22122-libftdc.so.abi: Likewise. * tests/data/test-read-dwarf/PR25007-sdhci.ko.abi: Likewise. * tests/data/test-read-dwarf/PR25042-libgdbm-clang-dwarf5.so.6.0.0.abi: Likewise. * tests/data/test-read-dwarf/libtest23.so.abi: Likewise. * 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/test-libaaudio.so.abi: Likewise. * tests/data/test-read-dwarf/test-libandroid.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> |
||
|
6dc5e281da |
abipkgdiff: Fix showing added/removed files
When two packages are different just because one adds or removes binaries -- and no binary have any ABI change otherwise, abipkgdiff quits early and doesn't report the added and removed binaries. This patch fixes the issue by reporting added/removed binaries even when no ABI comparison took place. * tools/abipkgdiff.cc (compare_prepared_userspace_packages): Do not return early if there are no binaries to compare. Also add more verbose messages. * tests/data/test-diff-pkg/libxcrypt-4.1.1-6.el8.x86_64--libxcrypt-4.1.1-6.el8.x86_64-output-1.txt: New reference output file. * tests/data/test-diff-pkg/libxcrypt-4.1.1-6.el8.x86_64--libxcrypt-compat-4.4.18-3.el9.x86_64-report-1.txt: New reference output file. * tests/data/test-diff-pkg/libxcrypt-4.1.1-6.el8.x86_64.rpm: New binary input file. * tests/data/test-diff-pkg/libxcrypt-4.4.18-3.el9.x86_64.rpm: Likewise. * tests/data/test-diff-pkg/libxcrypt-compat-4.4.18-3.el9.x86_64.rpm: Likewise. * tests/data/test-diff-pkg/libxcrypt-compat-debuginfo-4.4.18-3.el9.x86_64.rpm: Likewise. * tests/data/test-diff-pkg/libxcrypt-debuginfo-4.1.1-6.el8.x86_64.rpm: Likewise. * tests/data/test-diff-pkg/libxcrypt-debuginfo-4.4.18-3.el9.x86_64.rpm: Likewise. * tests/data/Makefile.am: Add the new testing files to source distribution. * tests/test-diff-pkg.cc (in_out_specs): Add these binary packages to this testing harness. Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
|
190350a35f |
Bug 27985 - abidiff: bad array types in report
Reporting the change in array type exhibits a glitch in the type name. As the bug report says: The resulting abidiff output contains: type of 'int numbers[2]' changed: type name changed from 'void[2]' to 'void[3]' array type size changed from 64 to 96 array type subrange 1 changed length from 2 to 3 instead of type of 'int numbers[2]' changed: type name changed from 'int[2]' to 'int[3]' array type size changed from 64 to 96 array type subrange 1 changed length from 2 to 3 The problem comes from array_type_def::get_qualified_name() where we fail to generate a "new" qualified name once the type of the array is canonicalized. Fixed thus. * src/abg-ir.cc (array_type_def::get_qualified_name): Use the cache for temporary qualified names when the type is not yet canonicalized. That way, the cache for (non-temporary) qualified names is used only for canonicalized types. * tests/data/test-abidiff/test-PR27985-report.txt: Reference output for the new test. * tests/data/test-abidiff/test-PR27985-v{0,1}.c: Source code for the new test binary inputs. * tests/data/test-abidiff/test-PR27985-v{0,1}.o: New test binary inputs. * tests/data/test-abidiff/test-PR27985-v{0,1}.o.abi: New test abixml input. * tests/data/Makefile.am: Add the new test materials above to source distribution. * tests/test-abidiff.cc (specs): Add the tests above to the harness. * tests/data/test-diff-pkg/nss-3.23.0-1.0.fc23.x86_64-report-0.txt: Adjust. * tests/data/test-abidiff-exit/qualifier-typedef-array-report-1.txt: Adjust. Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
|
ca08bae742 |
RHBZ 1925886 - Compare anonymous types without qualified names
An anonymous struct/union is, by definition an entity that is not named (unless a naming typedef is provided for it). It turns out that in C++ binaries, there are anonymous types that are logically equivalent (as far as ABI is concerned) because they have the same members and layout, but turn out to be evaluated as being different because they are defined in different name spaces. And because they are not named, showing them as being different just because of their name space doesn't bring anything but spurious error reporting. Consider the DWARF representing this: struct S { union { int a; int b; } member; }; where the 'member' is of type S::<anonymous-union>. Probably due to LTO, we see some DWARF that represents the type of 'member' as just <anonymous-union>, in some translation units. I could not generate that DWARF from a small test case, myself. But it comes from the binary 'usr/bin/lto-dump', from the https://bugzilla.redhat.com/show_bug.cgi?id=1925886 problem report. So in that case, we want the S::<anonymous-union> to compare equal to the <anonymous-union>, otherwise, this produces spurious type changes, especially when doing self comparison. This is what this patch does. * include/abg-fwd.h (is_anonymous_type): Constify this function. * src/abg-ir.cc (equals): In the overload for decl_base, do not take scope of anonymous types into account. In the overload for array_type_def do not peel of typedefs. This is not directly related to anonymous types, but it make comparison more robust against naming typedefs used for anonymous types in array elements. (get_type_name): Do not take into account the scope of anonymous types when building internal representation of types. Note that the internal representation is what is used for canonicalization. This means that all anonymous types are compared against each others during type canonicalization. * src/abg-reader.cc (build_class_decl): Do not try to re-use anonymous types, just like we already do for DWARF. * tests/data/test-annotate/test17-pr19027.so.abi: Adjust. * 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-diff-filter/test31-pr18535-libstdc++-report-0.txt: Likewise. * tests/data/test-diff-filter/test31-pr18535-libstdc++-report-1.txt: Likewise. * tests/data/test-read-dwarf/PR22122-libftdc.so.abi: Likewise. * tests/data/test-read-dwarf/test-libaaudio.so.abi: Likewise. * tests/data/test-read-dwarf/test-libandroid.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/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/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> |
||
|
cc2574121f |
Bug 27236 - Allow updating classes from abixml
Some classes can be defined piece-wise, in some rare cases in the abixml. build_class_decl is currently preventing that to happen, leading to some spurious self comparison errors. Fixed thus. * src/abg-reader.cc (build_class_decl): Keep going when the class has already been built. The rest of the code knows how to add new stuff. * tests/data/test-abidiff/test-PR18791-report0.txt: Adjust. Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
|
39ba859603 |
Bug 27236 - Fix the canonical type propagation optimization
While working on another bug, it turned out the initial fix for the bug https://sourceware.org/bugzilla/show_bug.cgi?id=27236 was just papering over the real issue. I think the real issue is that "canonical type propagation" optimization was being done even in cases where it shouldn't have been done. This patch recognizes the limits of that optimization and avoid performing it when we are off limits. So here is what that optimization is. The text below is also present in the comments in the source code. I am putting it here to explain the context. During the canonicalization of a type T (which doesn't yet have a canonical type), T is compared structurally (member-wise) against a type C which already has a canonical type. The comparison expression is C == T. During that structural comparison, if a subtype of C (which also already has a canonical type) is structurally compared to a subtype of T (which doesn't yet have a canonical type) and if they are equal, then we can deduce that the canonical type of the subtype of C is the canonical type of the subtype of C. Thus, we can canonicalize the sub-type of the T, during the canonicalization of T itself. That canonicalization of the sub-type of T is what we call "propagating the canonical type of the sub-type of C onto the sub-type of T". It's also called "on-the-fly canonicalization". It's on the fly because it happens during a comparison -- which itself happens during the canonicalization of T. So this is the general description of the "canonical type propagation optimization". Now we must recognize the limits of that optimization. Said otherwise, there is a case when a type is *NOT* eligible to this canonical type propagation optimization. The reason why a type is deemed NON-eligible to the canonical type propagation optimization is that it "depends" on a recursively present type. Let me explain. Suppose we have a type T that has sub-types named ST0 and ST1. Suppose ST1 itself has a sub-type that is T itself. In this case, we say that T is a recursive type, because it has T (itself) as one of its sub-types: T +-- ST0 | +-- ST1 | + | | | +-- T | +-- ST2 ST1 is said to "depend" on T because it has T as a sub-type. But because T is recursive, then ST1 is said to depend on a recursive type. Notice however that ST0 does not depend on any recursive type. Now suppose we are comparing T to a type T' that has the same structure with sub-types ST0', ST1' and ST2'. During the comparison of ST1 against ST1', their sub-type T is compared against T'. Because T (resp. T') is a recursive type that is already being compared, the comparison of T against T' (as a subtypes of ST1 and ST1') returns true, meaning they are considered equal. This is done so that we don't enter an infinite recursion. That means ST1 is also deemed equal to ST1'. If we are in the course of the canonicalization of T' and thus if T (as well as as all of its sub-types) is already canonicalized, then the canonical type propagation optimization will make us propagate the canonical type of ST1 onto ST1'. So the canonical type of ST1' will be equal to the canonical type of ST1 as a result of that optmization. But then, later down the road, when ST2 is compared against ST2', let's suppose that we find out that they are different. Meaning that ST2 != ST2'. This means that T != T', i.e, the canonicalization of T' failed for now. But most importantly, it means that the propagation of the canonical type of ST1 to ST1' must now be invalidated. Meaning, ST1' must now be considered as not having any canonical type. In other words, during type canonicalization, if ST1' depends on a recursive type T', its propagated canonical type must be invalidated (set to nullptr) if T' appears to be different from T, a.k.a, the canonicalization of T' temporarily failed. This means that any sub-type that depends on recursive types and that has been the target of the canonical type propagation optimization must be tracked. If the dependant recursive type fails its canonicalization, then the sub-type being compared must have its propagated canonical type cleared. In other words, its propagated canonical type must be cancelled. This concept of cancelling the propagated canonical type when needed is what this patch introduces. New data members have been introduced to the environment::priv private structure. Those are to keep track of the stack of sub-types being compared so that we can detect if a candidate to the canonical type propagation optimization depends on a recursive type. There is also a data structure in there to track the targets of the canonical type propagation optimization that "might" need to see their propagated canonical types be cancelled. Then new functions have been introduced to detect when a type depends on a recursive type, to cancel or confirm propagated canonical types etc. In abg-ir.cc, The RETURN* macros used in the equals() overloads have been factorized using the newly introduced function templates return_comparison_result(). This now contains the book keeping that was previously done (in the RETURN* macros) to detect recursive cycles in the comparison, as well as triggering the canonical type propagation. This i also where the logic of properly limiting the optimization is implemented now. * include/abg-ir.h (pointer_set): This typedef is now for an unordered_set<uintptr_t> rather than an unordered_set<size_t>. (environment::priv_): Make this public so that code in free form function from abg-ir.cc can access it. * src/abg-ir-priv.h (struct type_base::priv): Move this private structure here, from abg-ir.cc. (type_base::priv::{depends_on_recursive_type_, canonical_type_propagated_}): Added these two new data members. (type_base::priv::priv): Initialize the two new data members. (type_base::priv::{depends_on_recursive_type, set_depends_on_recursive_type, set_does_not_depend_on_recursive_type, canonical_type_propagated, set_canonical_type_propagated, clear_propagated_canonical_type}): Define new member functions. (struct environment::priv): Move this struct here, from abg-ir.cc. (environment::priv::{types_with_non_confirmed_propagated_ct_, left_type_comp_operands_, right_type_comp_operands_}): New data members. (environment::priv::{mark_dependant_types, mark_dependant_types_compared_until, confirm_ct_propagation, collect_types_that_depends_on, cancel_ct_propagation, remove_from_types_with_non_confirmed_propagated_ct}): New member functions. * src/abg-ir.cc (struct environment::priv, struct) (type_base::priv, struct class_or_union::priv): Move these struct to include/abg-ir-priv.h. (push_composite_type_comparison_operands) (pop_composite_type_comparison_operands) (mark_dependant_types_compared_until) (maybe_cancel_propagated_canonical_type): Define new functions. (notify_equality_failed, mark_types_as_being_compared): Re-indent. (is_comparison_cycle_detected, return_comparison_result): Define new function templates. (RETURN_TRUE_IF_COMPARISON_CYCLE_DETECTED): Define new macro. (equals(const function_type& l, const function_type& r)): Redefine the RETURN macro using the new return_comparison_result function template. Use the new RETURN_TRUE_IF_COMPARISON_CYCLE_DETECTED and mark_types_as_being_compared functions. (equals(const class_or_union& l, const class_or_union&, change_kind*)): Likewise. (equals(const class_decl& l, const class_decl&, change_kind*)): Likewise. Because this uses another equal() function to compare the class_or_union part the type, ensure that no canonical type propagation occurs at that point. (types_are_being_compared): Remove as it's not used anymore. (maybe_propagate_canonical_type): Use the new environment::priv::propagate_ct() function here. (method_matches_at_least_one_in_vector): Ensure the right-hand-side operand of the equality stays on the right. This is important because the equals() functions expect that. * src/abg-reader.cc (build_type): Ensure all types are canonicalized. * tests/data/test-diff-dwarf/PR25058-liblttng-ctl-report-1.txt: Adjust. * tests/data/test-diff-pkg/nss-3.23.0-1.0.fc23.x86_64-report-0.txt: Likewise. * tests/data/test-diff-pkg/spice-server-0.12.4-19.el7.x86_64-0.12.8-1.el7.x86_64-report-2.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-read-dwarf/test-libaaudio.so.abi: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
|
46b1ab08b0 |
Bug 27995 - Self comparison error from abixml file
There are several self comparison issues uncovered by comparing the file test-PR27995.abi (provided in the bug report) against itself. This patch address them all as well as the regressions induced on some of the test suite and then and updates the other reference test suite output that need it. In the equals overload for decl_base, we compare the non-internal versions of qualified decl names. For var_decls of anonymous class or union types, the non-internal version is the flat-representation of the type. Thus a benign change in a data member name of the anonymous type might cause the equals function to consider the var_decls to be wrongly different. The internal version of the qualified decl name should return a name that is stable for types, irrespective of these benign variations. The patch thus makes the equals overload for decl_base to compare internal versions of qualified decl names instead. The patch ensures that enum_type_decl::get_pretty_representation return and internal pretty representation that is "stable" for anonymous types. Basically, all anonymous enums will have the same of name that looks like "__anonymous_enum__". This is to ensure two things: first, that all anonymous enums are compared against each other during type canonicalization, ensuring that when two anonymous enums are canonically different, it really is because of changes in their enumerators or basic type, not because of anything having to do with their artificial names. Second, that in the equals overload for decl_base, their internal qualified name always compare equal. This nullifies the risk of having anonymous types compare different because of their (non existent) name. This is because libabigail's dwarf reader assigns artificial unique names to anonymous types, so we don't want to use these during actual type comparison. We do something similar for class_decl::get_pretty_representation and union_decl::get_pretty_representation where the pretty internal representation for class/union decl would now be __anonymous_{struct,union}__. The patch scouts the uses of get_pretty_representation() to make sure to use avoid using the internal-form of the pretty representations when it's not warranted. It also updates the doxygen comments of the overloads of that function. In the abixml reader, we were wrongly canonicalizing array types early, even before they were fully created. The was leading to spurious type chances down the road. The patch also fixes the caching of the name of function types by making it consistent with caching of the names of the other types of the system. The idea is that we don't cache the name of a function type until it's canonicalize. This is because the type might be edited during its pre-canonicalization life time; and that editing might change its name. However once the type is canonicalized, it becomes immutable. At that point we can cache its name, for performance purposes. Note that we need to do that both for the "internal version" of the type name (used for canonilization purposes) and the "non-internal version" one, which is used for other purposes. This caching scheme wasn't respected for function types, so we were caching a potentially wrong name for the type after its canonicalization. Last but not least, there is a problem that makes canonical type comparison different from structural type comparison. Let's consider these two declarations: typedef int FirstInt; typedef int SecondInt; Now, consider these two pointer types: FirstInt* and SecondInt*; These two pointer types are canonically different because they have different type names. This is because during type canonicalization, types with the same "pretty representation" are compared against each other. So types with different type names will certainly have different pretty representations and won't be compared; they are thus going to have different canonical types. However, FirstInt* and SecondInt* do compare equal, structurally, because the equals overload for pointer_type_def compares the pointed-to types of pointers by peeling off typedefs. So, here, as both pointed-to types are 'int' when the typedefs are peeled off, the two pointers structurally compare equal. This discrepancy between structural and canonical equality introduces subtle and spurious type changes depending on the order in which types are canonicalized. For instance: struct {FirstInt* m0;}; /* First type. */ struct {SecondInt* m0;}; /* Second type. */ If FirstInt* and SecondInt* are canonicalized before their containing anonymous types, then the two anonymous types will compare different (because FirstInt* and SecondInt* compare different) and have different canonical types. If, however, the anonymous types are canonicalized before FirstInt* and SecondInt*, then will compare equal because FirstInt* and SecondInt* are structurally equivalent. FirstInt* and SecondInt* will be canonicalized latter and have different canonical types (because they have different type names) despite being structurally equivalent. The change in the order of canonicalization can happen when canonicalizing types from a corpus coming from DWARF as opposed to canonicalizing types from a corpus coming from abixml. The patch fixes this discrepancy by not peeling off typedefs from the pointed-to types when comparing pointers. Note that this makes us regress on bug https://sourceware.org/bugzilla/show_bug.cgi?id=27236, where the typedef peeling was introduced. In hindsight, introducing that typedef peeling was a mistake. I'll try to address that bug again in a subsequent patch. * doc/manuals/abidiff.rst: Add documentation for the --debug option. * src/abg-ir.cc (equals): In the overload for decl_base consider the internal version of qualified decl name. In the overload for pointer_type_def do not peel typedefs off from the compared pointed-to types. In the overload for typedef_decl compare the typedef as a decl as well. In the overload for var_decl, compare variables that have the same ELF symbols without taking into account their qualified name, rather than their name. Stop comparing data member without considering their names. In the overload for class_or_union, when a decl-only class that is ODR-relevant is compared against another type, assume that equality if names are equal. This is useful in environments where some TUs are ODR-relevant and others aren't. (*::get_pretty_representation): Update doxygen comments. (enum_type_decl::get_pretty_representation): Return an internal pretty representation that is stable across all anonymous enums. (var_decl::get_anon_dm_reliable_name): Use the non-internal pretty representation for anonymous data members. (function_type::priv::temp_internal_cached_name_): New data member. (function_type::get_cached_name): Cache the internal name after the function type is canonicalized. Make sure internal name and non-internal name are cached separately. (class_or_union::find_anonymous_data_member): Look for the anonymous data member by looking at its non-internal name. ({class, union}_decl::get_pretty_representation): Use something like "class __anonymous_{union,struct}__" for all anonymous classes, so that they can all be compared against each other during type canonicalization. (type_has_sub_type_changes): Use non-internal pretty representation. (hash_type_or_decl, function_decl_is_less_than:): Use internal pretty representation for comparison here. * src/abg-reader.cc (read_context::maybe_canonicalize_type): Don't early canonicalize array types. * src/abg-writer.cc (annotate): Use non-internal pretty representation. * tests/data/test-diff-filter/test-PR27995-report-0.txt: New reference report. * tests/data/test-diff-filter/test-PR27995.abi: New test input abixml file. * tests/data/Makefile.am: Add test-PR27995.abi, test-PR27995-report-0.txt to the source distribution. * tests/data/test-annotate/libtest23.so.abi: Adjust. * tests/data/test-diff-dwarf/test6-report.txt: Adjust. * tests/data/test-diff-filter/test31-pr18535-libstdc++-report-0.txt: Adjust. * tests/data/test-diff-filter/test31-pr18535-libstdc++-report-1.txt: Adjust. * tests/data/test-diff-filter/test41-report-0.txt: Adjust. * tests/data/test-diff-filter/test43-decl-only-def-change-leaf-report-0.txt: Adjust. * tests/data/test-diff-filter/test8-report.txt: Adjust. * tests/data/test-diff-pkg/libICE-1.0.6-1.el6.x86_64.rpm--libICE-1.0.9-2.el7.x86_64.rpm-report-0.txt: Adjust. * tests/data/test-diff-pkg/spice-server-0.12.4-19.el7.x86_64-0.12.8-1.el7.x86_64-report-0.txt: Adjust. * tests/data/test-diff-pkg/spice-server-0.12.4-19.el7.x86_64-0.12.8-1.el7.x86_64-report-2.txt: Adjust. * tests/data/test-diff-pkg/spice-server-0.12.4-19.el7.x86_64-0.12.8-1.el7.x86_64-report-3.txt: Adjust. * tests/data/test-diff-pkg/tbb-4.1-9.20130314.fc22.x86_64--tbb-4.3-3.20141204.fc23.x86_64-report-0.txt: Adjust. * tests/data/test-diff-pkg/tbb-4.1-9.20130314.fc22.x86_64--tbb-4.3-3.20141204.fc23.x86_64-report-1.txt: Adjust. * tests/data/test-diff-suppr/test39-opaque-type-report-0.txt: Adjust. * tests/data/test-read-dwarf/PR22015-libboost_iostreams.so.abi: Adjust. * tests/data/test-read-dwarf/PR22122-libftdc.so.abi: Adjust. * tests/data/test-read-dwarf/libtest23.so.abi: Adjust. * tests/data/test-read-dwarf/test-libandroid.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/test9-pr18818-clang.so.abi: Adjust. * tests/test-diff-filter.cc (in_out_specs): Add the test-PR27995.abi to the test harness. * tools/abidiff.cc (options::do_debug): New data member. (options::options): Initialize it. (parse_command_line): Parse --debug. (main): Activate self comparison debug if the user provided --debug. Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
|
cfd81dec10 |
PR28060 - Invalid offset for bitfields
Bitfield and other member offsets can be specified in DWARF using: - DW_AT_data_bit_offset, or - DW_AT_data_member_location and optionally DW_AT_bit_offset. The code would only use the value DW_AT_data_member_location if there was no DW_AT_bit_offset. This commit fixes this and adjusts documentation and affected tests. * src/abg-dwarf-reader.cc (read_and_convert_DW_at_bit_offset): Update documentation. (die_member_offset): Treat DW_AT_bit_offset as an optional adjustment to DW_AT_data_member_location. * tests/data/test-annotate/test13-pr18894.so.abi: Update. * tests/data/test-annotate/test15-pr18892.so.abi: Update. * tests/data/test-annotate/test17-pr19027.so.abi: Update. * tests/data/test-annotate/test19-pr19023-libtcmalloc_and_profiler.so.abi: Update. * tests/data/test-annotate/test21-pr19092.so.abi: Update. * tests/data/test-diff-dwarf-abixml/PR25409-librte_bus_dpaa.so.20.0.abi: Regenerate. * tests/data/test-diff-pkg/libcdio-0.94-1.fc26.x86_64--libcdio-0.94-2.fc26.x86_64-report.1.txt: Report now empty. * tests/data/test-read-dwarf/PR25007-sdhci.ko.abi: Update. * tests/data/test-read-dwarf/PR25042-libgdbm-clang-dwarf5.so.6.0.0.abi: Update. * tests/data/test-read-dwarf/test13-pr18894.so.abi: Update. * tests/data/test-read-dwarf/test15-pr18892.so.abi: Update. * tests/data/test-read-dwarf/test17-pr19027.so.abi: Update. * tests/data/test-read-dwarf/test19-pr19023-libtcmalloc_and_profiler.so.abi: Update. * tests/data/test-read-dwarf/test21-pr19092.so.abi: Update. * tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi: Update. Signed-off-by: Giuliano Procida <gprocida@google.com> Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
|
578ba12139 |
symtab-reader: add support for binaries compiled with CFI
Control-Flow-Integrity (CFI) when enabled in clang built binaries introduces an indirection when looking up ELF symbols. For DSO, the symbol table (.dynsym) will still contain the symbols, but additional symbols with suffix .cfi will be added to the full .symtab. Unfortunately, the DWARF debug information refers to CFI symbols by address to the .cfi suffixed variants as they point to the actual implementation. When the dwarf reader is determining whether to suppress variable or function declarations, it does so by identifying if there is an associated ELF symbol at the given address read from DWARF. Unless we know about the alternative address, this will fail and the type information will be suppressed. Hence add the .cfi symbol values to the lookup map to associate their address with the corresponding publicly exported symbol. * src/abg-symtab-reader.cc (symtab::load_): use new add_alternative_address_lookups method. (add_alternative_address_lookups): New method. * src/abg-symtab-reader.h (add_alternative_address_lookups): new function declaration. * tests/data/test-read-dwarf/test-libaaudio.so: New test data. * tests/data/test-read-dwarf/test-libaaudio.so.abi: New test data. * tests/data/Makefile.am: Add the two new tests input to source distribution. * tests/test-read-dwarf.cc: New test case. Reported-by: Dan Albert <danalbert@google.com> Reviewed-by: Giuliano Procida <gprocida@google.com> Signed-off-by: Matthias Maennich <maennich@google.com> Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
|
e2e253e5b1 |
Bug 27980 - Fix updating of type scope upon type canonicalization
Once a type T is canonicalized, its scope is updated so that the vector returned by scope_decl::get_canonical_types() now contains the new canonical type of T. This works, obviously, even when the scope is itself a type. This works well on binaries compiled using C only because, currently, libabigail de-duplicates the DIEs of types. This means that if the scope of T is a non-anonymous type, the class of equivalence of that scope contains just one element. So updating the scope of T implies updating just one scope. On binaries where some files are compiled using C++ however, type DIEs are not de-duplicated. This is just because that feature hasn't yet been implemented in libabigail. Anyway, in that case, if the scope of T is a non-anonymous type, the class of equivalence of that scope contains more than one element. So updating the scope of T implies updating the scope of all the elements of the class of equivalence T. In practise, that means updating the canonical type (scope) of T. Libabigail fails to update the canonical type (scope) of T. Later at abixml emitting time, just emitting the canonical types of the scope of T is not enough to emit the canonical type of T. And that's how the abixml emitter forgets to emit some types as reported in the bug https://sourceware.org/bugzilla/show_bug.cgi?id=27980. This patch fixes that issue. I also noticed that when emitting abixml for unions, the emitter fails to emit the canonical member types of the union, unlike what is done for class types. So that is fixed as well. The binary provided in the bug report is added to the regression testsuite. * src/abg-ir.cc (canonicalize): Update the scope_decl::get_canonical_types() of canonical type of the containing type of the newly canonicalized type. * src/abg-writer.cc (write_union_decl): Write the canonical types contained in the current union scope, just like we do for classes. * tests/data/test-read-dwarf/test16-pr18904.so.abi: Adjust. * tests/data/test-types-stability/pr27980-libc.so: New binary input file. * tests/data/Makefile.am: Add the test input file above to source distribution. * tests/test-types-stability.cc (elf_paths): Add the new test input file to this test harness. Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
|
1cfbff1b30 |
rhbz1951526 - SELF CHECK FAILED for 'gimp-2.10'
This is a fix for bug https://bugzilla.redhat.com/show_bug.cgi?id=1951526. Although it's a patch for one bug, it addresses several different issues that cause the observed self comparison failure. As is often the case on this kind of problems, the failure is difficult to reproduce on a synthetic test case so I'll explain the root causes in this commit log. There are 4 different root causes to this problem. As I couldn't come up with a reduced test case for each one of them I am adding the fixes for those 4 issues in this commit, along with a new regression test extracted from the initial bugzilla problem report. So, overall, the symptom we are seeing here is that when we build an IR for the input binary gimp-2.0, save that IR into abixml, and read back that abixml into another IR, comparing the two IR shows changes; it should show no change whatsoever. This is what we call in libabigail jargon a self comparison (or self check) failure. As alluded to in my introduction above, there appear to be 4 different root causes for that self comparison failure. 1/ The first cause has to do with a situation about two anymous enums that are (wrongly) considered different from an ABI point of view. Using the debugging capabilities recently gained by libabigail, I could notice that the two enums are: (gdb) p debug(&l) enum __anonymous_enum__ : unnamed-enum-underlying-type-32 { // size in bits: 32 // translation unit: /usr/src/debug/gimp-2.10.22-2.el9.1.aarch64/app/<artificial>-757de // @: 0x698fb68, @canonical: 0 GIMP_INTERPOLATION_NONE = 0, GIMP_INTERPOLATION_LINEAR = 1, GIMP_INTERPOLATION_CUBIC = 2, GIMP_INTERPOLATION_NOHALO = 3, GIMP_INTERPOLATION_LOHALO = 4, }; $1 = (abigail::ir::decl_base *) 0x698fba0 (gdb) p debug(&r) enum __anonymous_enum__ : unnamed-enum-underlying-type-32 { // size in bits: 32 // translation unit: /usr/src/debug/gimp-2.10.22-2.el9.1.aarch64/app/app.c // @: 0xa6d83e8, @canonical: 0 GIMP_INTERPOLATION_NONE = 0, GIMP_INTERPOLATION_LINEAR = 1, GIMP_INTERPOLATION_CUBIC = 2, GIMP_INTERPOLATION_NOHALO = 3, GIMP_INTERPOLATION_LOHALO = 4, GIMP_INTERPOLATION_LANCZOS = 3, }; $2 = (abigail::ir::decl_base *) 0xa6d8420 (gdb) Note how the second enum has a new enumerator named 'GIMP_INTERPOLATION_LANCZOS', but its value is '3', which is the exact same value of as the one of the existing enumerator GIMP_INTERPOLATION_NOHALO. During type canonicalization of the IR from the input binary, libabigail (wrongly) considers these two enums as being different. This leads to the type 'Gimp*' (or anything type indirectly using any one of the anonymous enums above) coming from one translation unit being considered different from a type 'Gimp*' coming from another translation unit, just because their are not using either one version of the anonymous enum above or the other. This leads to a *LOT* of spurious type changes from the first IR, that are saved into abixml. To fix this first problem, this patch introduces "two modes" of comparing enums. There is a binary-only mode which only looks enumerator values, not enumerator names. And then there is the source-level mode which looks at both enumerator names and values when comparing enums. The former mode is used during type canonicalization. However, when a change is detected between two enums, then the diff-IR built to describe the change is constructed using the later mode. Using the later mode allows to describe precisely things like enumerator insertion/removal by referring to the names of the added/removed enumerators. 2/ The second root cause is that a struct, say, 'struct _GimpImage' from a translation unit is considered different from a 'struct _GimpImage' because the DWARF reader wrongly assign them different sizes. Here is what it looks like in the debugger: (gdb) p debug(&l) struct _GimpImage { // size in bits: 384 // definition point: ../../app/core/gimpimage.h:39:1 // translation unit: /usr/src/debug/gimp-2.10.22-2.el9.1.aarch64/app/<artificial>-757de // @: 0x69b9d10, @canonical: 0 GimpViewable parent_instance;' Gimp* gimp;' GimpImagePrivate* priv;' }; $8 = (abigail::ir::type_base *) 0x69b9d10 (gdb) p debug(&r) struct _GimpImage { // size in bits: 0 // definition point: :0:0 // translation unit: /usr/src/debug/gimp-2.10.22-2.el9.1.aarch64/app/<artificial>-8813f // @: 0x6ac7a50, @canonical: 0 }; Notice how the second 'struct _GimpImage' has a size of zero. This is because when reading the DWARF, we first encounter the DIE for the first' struct _GimpImage' and we properly build a type for it, along with its declaration. Then when we encounter another DIE defining 'struct _GimpImage' again, from a different translation unit, the DWARF reader recognizes that it's a DIE for a declaration of 'struct _GimpImage' and fails to re-use the previous definition for 'struct _GimpImage'. So it wrongly builds declaration-only 'struct _GimpImage' for it, hence the second struct _GimpImage with a zero size. Here again that creates spurious changes (after type canonicalization) in types using struct _GimpImage. And that is a lot of types, including things like 'Gimp*' and the like. The fix for this root cause issue is to change add_or_update_class_type in the DWARF reader to recognize that we are seeing a type declaration for which there was already a definition and return that definition instead of creating a new declaration. 3/ The third root cause is better explained with a "screen shot". Consider these two 'versions' of the same struct _GdkDevice from two different translation units: struct _GdkDevice { // size in bits: 576 // definition point: /usr/include/gtk-2.0/gdk/gdkinput.h:98:1 // translation unit: /usr/src/debug/gimp-2.10.22-2.el9.1.aarch64/app/<artificial>-2d0352 // @: 0x8820530, @canonical: 0 GObject parent_instance;' gchar* name; // uses canonical type '@0x6892980' GdkInputSource source;' GdkInputMode mode;' gboolean has_cursor; // uses canonical type '@0x688dd00' gint num_axes; // uses canonical type '@0x688dd00' GdkDeviceAxis* axes;' gint num_keys; // uses canonical type '@0x688dd00' GdkDeviceKey* keys;' }; $9 = (abigail::ir::type_base *) 0x8820530 (gdb) p debug(&r) struct _GdkDevice { // size in bits: 576 // definition point: /usr/include/gtk-2.0/gdk/gdkinput.h:98:1 // translation unit: /usr/src/debug/gimp-2.10.22-2.el9.1.aarch64/app/<artificial>-1fdb18 // @: 0x7cd71e0, @canonical: 0 GObject parent_instance;' gchar* _g_sealed__name; // uses canonical type '@0x6892980' GdkInputSource _g_sealed__source;' GdkInputMode _g_sealed__mode;' gboolean _g_sealed__has_cursor; // uses canonical type '@0x688dd00' gint _g_sealed__num_axes; // uses canonical type '@0x688dd00' GdkDeviceAxis* _g_sealed__axes;' gint _g_sealed__num_keys; // uses canonical type '@0x688dd00' GdkDeviceKey* _g_sealed__keys;' }; $10 = (abigail::ir::type_base *) 0x7cd71e0 (gdb) Notice how the name of the second data member 'name' was changed to '_g_sealed_name'. A similar scheme happens to several other data member names. The offsets and types of the struct _GdkDevice haven't changed however. So from an ABI standpoint, the two versions of that struct are equal. Libabigail consider them different however. Because that type is used by tons of other types of the binary being analyzed, this leads to lots of spurious canonical type difference that shouldn't be there. These three issues are magnified by the fact that the gimp binary is compiled using "link time optimization". That brings in a lot more opportunities to see these underlying issues that have been there for a long time. 4/ The fourth and last root cause issue. When the abixml writer emits a translation unit (TU), it keeps track of the 'non-emitted referred to type' of the currently emitted translation unit and emits them at the end of each TU. For instance, if the type 'Gimp*' (pointer to Gimp) was emitted, and yet the referred-to type 'Gimp' wasn't emitted, the TU writer makes sure to emit the referred-to 'Gimp' type at the end of the TU. This has been going on for quite some time now. The problem however is that although the non-emitted referred-to type was referred to in this current TU, it might no have been *DEFINED* in this TU. In that case, it should not be emitted in this TU. Otherwise, the TU where that type is defined in the abixml might appear different from where it is defined in the initial binary, leading to self comparison failures down the road. This patch ensures that a non-emitted referred-to type is always emitted in the TU it belongs to. 5/ After doing all this, it appears that we were forgetting to emit some function types that were defined in TUs emitted earlier and yet were being referred-to later. Looking closer, I realized that we should just emit function types seen in a given TU, regardless of the referred-to relation. The problem with that is that function types are special in libabigail because there are two situation in which they are created. Basically, a function type is created by the DWARF DIE DW_TAG_subroutine_type. This is for instance how pointer to functions are represented in DWARF, namely, by a DW_TAG_pointer_type that points to a DW_TAG_subroutine_type. That is represented in the libabigail ir by an instance of the abigail::ir::function_type type. This is represented in abixml as a 'function-type' XML element. But then, libabigail considers that all decls have a type. This applies obviously for variables or data member. Right. But then, libabigail considers that a function is also a decl, which has a type. And the type of a function is a function type, represented by the same abigail::ir::function_type. A practical difference with the former situation is that function decls are *NOT* represented in abixml using a 'function-type' element. Instead a 'function-decl' XML element uses return type and parameter elements to represent the types involved with a function decl. Said otherwise, the former 'function type' concept used to represent the type of functions in the libabigail IR is artificial. This artificial-ness was not explicitly expressed in libabigail. This patch now expresses that artificial-ness for function types. So the abixml writer now just decide to not emit artificial function types, and instead, emit all the non-artificial function types instead. This addresses this last issues by being able to emit all non-artificial function types defined in a given TU, without having to bother with the fact that they are referred-to or not. Together, fixing these 5 problems fixes this reported problem. The changes to the reference test outputs are adjustments needed because of the abixml output indeed changes. * include/abg-ir.h (environment::use_enum_binary_only_equality): Declare accessors. (type_or_decl_base::{s,g}et_is_artificial): Likewise. (decl_base::{s,g}et_is_artificial): Remove accessors. * src/abg-ir.cc (environment::priv::use_enum_binary_only_equality): Define new data member. (environment::priv::use_enum_binary_only_equality): Define accessors. (type_or_decl_base::priv::is_artificial_): Define new data member. It has actually moved here from decl_base::priv::is_artificial_. (type_or_decl_base::priv::priv): Initialize it. (type_or_decl_base::{g,s}et_is_artificial): Define accessors. (decl_base::is_artificial_): Move this to type_or_decl_base::is_artificial_. (maybe_adjust_canonical_type): In a given class of equivalence of function types, if there is one non-artificial function type, then the entire class of equivalence is considered non-artificial; so flag the canonical function type as being non-artificial. (is_enumerator_present_in_enum): Define new static function. (equals): Re-arrange the overload for enums so the order of the enumerators doesn't count in the comparison. Also, two enums with different numbers of enumerators can still be equal, with the right redundancy. In the overload for var_decl, avoid taking into account the names of data members in the comparison. (enum_type_decl::enumerator::operator==): In the binary-level comparison mode, only compare the value of enumerators, not their name. * src/abg-comparison.cc (compute_diff): In the overload for enum_type_decl, if the enums compare different using binary-level comparison, then use source-level comparison to build the diff-IR. * src/abg-dwarf-reader.cc (read_context::compare_before_canonicalisation): Compare enums using binary-level comparison. (add_or_update_class_type): If we are looking at the definition of an existing declaration that has been already defined then use the previous definition, in case we are going to need to update the definition. Also, update the size only if it's needed. (build_function_type): By default, consider the newly built function type as artificial. (build_ir_node_from_die): When looking at a DW_TAG_subroutine_type DIE, consider the built function type as non-artificial. * src/abg-reader.cc (read_context::maybe_check_abixml_canonical_type_stability): Don't consider declaration-only classes in an ODR context because they don't have canonical types. (build_function_decl): Flag the function type of the function as artificial. (build_class_decl): Make sure to reuse class types that were already created. * src/abg-writer.cc (write_translation_unit): Allow emitting empty classes. Make sure referenced types are emitting in the translation unit where they belong. Avoid emitting artificial function types. * tests/data/test-alt-dwarf-file/rhbz1951526/rhbz1951526-report-0.txt: New test reference output. * tests/data/test-alt-dwarf-file/rhbz1951526/usr/bin/gimp-2.10: New reference test binary input. * tests/data/test-alt-dwarf-file/rhbz1951526/usr/lib/debug/.dwz/gimp-2.10.22-2.el9.1.aarch64: Likewise. * tests/data/test-alt-dwarf-file/rhbz1951526/usr/lib/debug/usr/bin/gimp-2.10-2.10.22-2.el9.1.aarch64.debug: Likewise. * tests/data/Makefile.am: Add the new test files to source directory. * tests/test-alt-dwarf-file.cc: Add the new test inputs to this test harness. * tests/data/test-abidiff/test-PR18791-report0.txt: Adjust. * tests/data/test-abidiff/test-enum0-report.txt: Likewise. * tests/data/test-annotate/libtest23.so.abi: Likewise. * 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/test-anonymous-members-0.o.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/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/test20-pr19025-libvtkParallelCore-6.1.so.abi: Likewise. * tests/data/test-annotate/test21-pr19092.so.abi: Likewise. * tests/data/test-diff-dwarf-abixml/test0-pr19026-libvtkIOSQL-6.1.so.1.abi: Likewise. * tests/data/test-diff-dwarf/PR25058-liblttng-ctl-report-1.txt: Likewise. * tests/data/test-diff-dwarf/test6-report.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-filter/test8-report.txt: Likewise. * tests/data/test-diff-pkg/spice-server-0.12.4-19.el7.x86_64-0.12.8-1.el7.x86_64-report-2.txt: Likewise. * tests/data/test-diff-pkg/spice-server-0.12.4-19.el7.x86_64-0.12.8-1.el7.x86_64-report-3.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-read-dwarf/PR22015-libboost_iostreams.so.abi: Likewise. * tests/data/test-read-dwarf/PR22122-libftdc.so.abi: Likewise. * tests/data/test-read-dwarf/PR25007-sdhci.ko.abi: Likewise. * tests/data/test-read-dwarf/PR25042-libgdbm-clang-dwarf5.so.6.0.0.abi: Likewise. * tests/data/test-read-dwarf/PR26261/PR26261-exe.abi: Likewise. * tests/data/test-read-dwarf/libtest23.so.abi: Likewise. * 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/test-libandroid.so.abi: Likewise. * tests/data/test-read-dwarf/test10-pr18818-gcc.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. * tests/data/test-read-write/test28-without-std-fns-ref.xml: Likewise. * tests/data/test-read-write/test28-without-std-vars-ref.xml: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
|
7a9fa3fe5a |
abixml reader: Fix recursive type definition handling
This should fix self comparison bug https://bugzilla.redhat.com/show_bug.cgi?id=1944088 This arose from a self comparison check failing on the library libgvpr.so.2 from the graphviz-2.44.0-17.el9.aarch64.rpm package. Now that we have facilities to see what type (instantiated from the abixml representation of the libgvpr.so library) exactly the canonicalization process is failing for, I decided to use it ;-) I extracted the package and its associating debug info into a directory named 'extract' and ran abidw --debug-abidiff on it: $ build/tool/abidw --debug-abidiff -d extract/usr/lib/debug extract/usr/lib64/libgvpr.so.2 That yielded the output below: error: problem detected with type 'typedef Vmalloc_t' from second corpus error: canonical type for type 'typedef Vmalloc_t' of type-id 'type-id-170' changed from 'd72618' to '14a7448' error: problem detected with type 'Vmalloc_t*' from second corpus error: canonical type for type 'Vmalloc_t*' of type-id 'type-id-188' changed from 'd72ba8' to '14a7968' [...] This tells me that "typedef Vmalloc_t", created from the abixml compares different from its originating peer that was created from the binary directly. The same goes for the pointer type "Vmalloc_t*", etc. Using the new debugging/logging functionalities from the command line of the debugger, I could see that in the abixml reader, build_typedef_decl can fail subtly when the underlying type of the typedef refers to the typedef itself. In that case, we need to ensure that the typedef created by build_typedef_decl is the same one that is used by the underlying type. which is not the case at the moment. At the moment, the underlying type would create a new typedef beside the one currently being created by build_typedef_decl. That leads to more than one typedef in the system to designate "typedef Vmalloc_t". And that wreaks havoc later down the road. This patch arranges so that build_typedef_decl creates the typedef "early" before the underlying type is created. That typedef temporarily has no underlying type. It's registered as being the typedef for the type-id string that identifies it in the abixml. And then the function goes to create the underlying type. This arrangement ensures that if the underlying type refers to the typedef being created (via its type-id string), then the typedef that was created early is effectively re-used. This ensures that a typedef which recursively refer to itself is properly represented. It's only when the underlying type is fully created that it's added to the typedef. Something similar is done for pointer types, in build_pointer_type_def. Note that to do this, the patch adjusts the typedef_decl and pointer_type_def classes so that they can be created with no underlying/pointed-to types. The underlying/pointed-to type can thus be added later. I believe this patch is the minimal patch necessary to fix this issue. The graphviz RPM is added to the regression test suite for good measure. After visual inspection, I realized that there are other types besides typedef and pointer types that exhibit the same class of problem even if they are not involved in this issue on this particular binary. A subsequent patch is going to address the problem for those types, namely, qualified and reference types. * include/abg-ir.h (pointer_type_def::pointer_type_def): Declare a constructor with no pointed-to type. (pointer_type_def::set_pointed_to_type): Declare new method. (typedef_decl::typedef_decl): Declare a constructor with no underlying type. * src/abg-ir.cc (pointer_type_def::pointer_type_def): Define a constructor with no pointed-to type. The pointed-to type can thus later be set when it becomes available. (pointer_type_def::set_pointed_to_type): Define new method. (pointer_type_def::get_qualified_name): Make this work on a pointer type that (momentarily) has no pointed-to type. (typedef_decl::typedef_decl): Define a constructor with no underlying type. (typedef_decl::get_size_in_bits): Make this work on a typedef that has (momentarily) no underlying type. (typedef_decl::set_underlying_type): Update the size and alignment of the typedef from its new underlying type. * src/abg-reader.cc (build_pointer_type_def): Construct the pointer type early /BEFORE/ we even try to construct its pointed-to type. Associate this incomplete type with the type-id. Then try to construct the pointed-to type. During the construction of the pointed-to type, if this pointer is needed (due to recursion) then the incomplete pointer type can be used, leading to just one pointer type used (recursively) as it should be. (build_typedef_decl): Likewise for building typedef type early without its underlying type so that it can used by the underlying type if needed. * tests/data/test-diff-pkg/graphviz-2.44.0-18.el9.aarch64-self-check-report-0.txt: New test reference output. * tests/data/test-diff-pkg/graphviz-2.44.0-18.el9.aarch64.rpm: New binary test input. * tests/data/test-diff-pkg/graphviz-debuginfo-2.44.0-18.el9.aarch64.rpm: Likewise. * tests/data/Makefile.am: Add the new test material above to source distribution. * tests/test-diff-pkg.cc (in_out_specs): Add the test inputs above to this test harness. Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
|
d94947440e |
Introduce artificial locations
When an abixml file is "read in" and the resulting in-memory internal representation is saved back into abixml, the saved result can often differ from the initial input in a non deterministic manner. That read-write instability is non-desirable because it generates unnecessary changes that cloud our ability to build reliable regression tests, among other things. Also, that unnecessarily increases the changes to the existing regression test reference outputs leading to a lot more churn than necessary. This patch tries to minimize that abixml read-write instability in preparation of patches that would otherwise cause too much churn in reference output files of the regression test suite. The main reason why this read-write instability occurs is that a lot of type definitions don't have source location. For instance, all the types that are not user defined fall into that category. Those types can't be topologically sorted by using their location as a sorting criteria. Instead, we are currently using the order in which those location-less types are processed by the reader as the output (i.e, write time) order. The problem with that approach is that the processing order can be dependant on the other of which OTHER TYPES likes class types are processed. And that order can be changed by patches in the future. That in and of itself shouldn't change the write order of these types. For instance, if a class Foo has data members and member functions whose types are non-user-defined types, then, the order in which those data members are processed can possibly determine the order in which those non-user-defined are processed. This patch thus introduces the concept of artificial location. A *NON-ARTIFICIAL* location is a source location that was emitted by the original emitter of the type meta-data. In the case of DWARF type meta-data, the compiler originally emitted source location. That location when read is considered non-artificial, or natural, if you prefer. In the case of abixml however, an artificial location would be the source location at which an XML element is encountered. For instance, consider the abixml file below "path/to/exmaple.abi" below: 1 <abi-corpus version='2.0' path='path/to/example.abi'> 2 <abi-instr address-size='64' path='test24-drop-fns.cc' language='LANG_C_plus_plus'> 3 <type-decl name='bool' size-in-bits='8' id='type-id-1'/> 4 </abi-instr> 5 </abi-corpus/> I've added line numbers for ease of reading. At line 3 of that file, the non-user defined type name "bool" is defined using the XML element "type-decl". Note how that element lacks the "filepath", "line" and "column" attributes that would collectively define the source location of that type. So this type "bool" don't carry any natural location. The abixml reader can however generate an artificial location for it. That the filepath of that artificial location would thus be the path to that ABI corpus, i.e, "path/to/example.abi". The line number would be 3. The column would be left to zero. That artificial location will never be explicitly be written down as an XML attribute as it can always be implicitly retrieved by construction. The patch changes the internal representation so that each ABI artifact of the internal representation can now carry both an artificial and a natural location. When two artifacts have an artificial location, then its used to topologically sort them. The one that is defined topologically "earlier" obviously comes first. When two artifacts have a natural location then its used to topologically sort them. Otherwise, they are sorted lexicographically. This makes the output of abilint a lot more read-write stable. * include/abg-fwd.h (get_artificial_or_natural_location): Declare new function. * include/abg-ir.h (location::location): Initialize & copy ... (location::is_artificial_): ... a new data member. (location::{g,s}et_is_artificial): New accessors. (location::{operator=}): Adjust. (type_or_decl_base::{set,get,has}_artificial_location): Declare new member functions. * src/abg-ir.cc (decl_topo_comp::operator()): In the overload for decl_base*, use artificial location for topological sort in priority. Otherwise, use natural location. Otherwise, sort lexicographically. (type_topo_comp::operator()): In the overload for type_base*, use lexicographical sort only for types that don't have location at all. (type_or_decl_base::priv::artificial_location_): Define new data member. (type_or_decl_base::{set,get,has}_artificial_location): Define new member functions. (decl_base::priv): Allow a constructor without location. That one sets no natural location to the artifact. (decl_base::decl_base): Use decl_base::set_location in the constructor now. (decl_base::set_location): Adjust this to support setting a natural or an artificial location. (get_debug_representation): Emit debugging log showing the location of an artifact, using its artificial location in priority. (get_natural_or_artificial_location): Define new function. * src/abg-reader.cc (read_artificial_location) (maybe_set_artificial_location): Define new static functions. (read_location): Read artificial location when no natural location was found. (build_namespace_decl, build_function_decl, build_type_decl) (build_qualified_type_decl, build_pointer_type_def) (build_reference_type_def, build_subrange_type) (build_array_type_def, build_enum_type_decl, build_typedef_decl) (build_class_decl, build_union_decl, build_function_tdecl) (build_class_tdecl, build_type_tparameter) (build_non_type_tparameter, build_template_tparameter): Read and set artificial location. * src/abg-writer.cc (write_location): Don't serialize artificial locations. (write_namespace_decl): Topologically sort member declarations before serializing them. * tests/data/test-read-write/test28-without-std-fns-ref.xml: Adjust. * tests/data/test-read-write/test28-without-std-vars-ref.xml: Likewise. * tests/data/test-annotate/libtest23.so.abi: Likewise. * 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/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/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/test20-pr19025-libvtkParallelCore-6.1.so.abi: Likewise. * tests/data/test-annotate/test21-pr19092.so.abi: Likewise. * tests/data/test-read-dwarf/PR22015-libboost_iostreams.so.abi: Likewise. * tests/data/test-read-dwarf/PR22122-libftdc.so.abi: Likewise. * tests/data/test-read-dwarf/PR25007-sdhci.ko.abi: Likewise. * tests/data/test-read-dwarf/PR25042-libgdbm-clang-dwarf5.so.6.0.0.abi: Likewise. * tests/data/test-read-dwarf/PR26261/PR26261-exe.abi: Likewise. * tests/data/test-read-dwarf/libtest23.so.abi: Likewise. * 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/test-libandroid.so.abi: Likewise. * tests/data/test-read-dwarf/test-suppressed-alias.o.abi: Likewise. * tests/data/test-read-dwarf/test0.abi: Likewise. * tests/data/test-read-dwarf/test0.hash.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/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. * tests/data/test-read-write/test28-without-std-fns-ref.xml: Likewise. * tests/data/test-read-write/test28-without-std-vars-ref.xml: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
|
dd55550355 |
reader: Handle 'abi-corpus' element being possibly empty
This problem was reported at https://sourceware.org/bugzilla/show_bug.cgi?id=27616. The abixml reader wrongly assumes that the 'abi-corpus' element is always non-empty. Note that until now, the only emitter of abixml consumed in practice was abg-writer.cc and it only emits non-empty 'abi-corpus' elements. So the issue wasn't exposed. So, the reader assumes that an 'abi-corpus' element has at least a text node. For instance, consider this minimal input file named test-v0.abi: $cat test-v0.abi <abi-corpus-group architecture='elf-arm-aarch64'> <abi-corpus path='vmlinux' architecture='elf-arm-aarch64'> </abi-corpus> </abi-corpus-group> $ Now, compare it to this file where the abi-corpus element is an empty element (doesn't even contain any text): $cat test-v0.abi <abi-corpus-group architecture='elf-arm-aarch64'> <abi-corpus path='vmlinux'/> </abi-corpus-group> $ comparing the two files with abidiff (wrongly) reports: $ abidiff test-v0.abi test-v1.abi ELF architecture changed Functions changes summary: 0 Removed, 0 Changed, 0 Added function Variables changes summary: 0 Removed, 0 Changed, 0 Added variable architecture changed from 'elf-arm-aarch64' to '' $ What's happening is that read_corpus_from_input is getting out early when it sees that the node is empty. This is at: xmlNodePtr node = ctxt.get_corpus_node(); @@ -1907,10 +1925,14 @@ read_corpus_from_input(read_context& ctxt) corp.set_soname(reinterpret_cast<char*>(soname_str.get())); } if (!node->children) // <---- we get out early here and we return nil; // forget about the properties of // the current empty corpus element node So, at its core, fixing the issue at hand involves avoiding the early return there. But then, it turns out that's not enough. In the current setting, the different abixml processing entry points are designed to be used in a semi "streaming" mode. So for instance, read_translation_unit_from_input can be invoked repeatedly to "stream in" the next translation unit at each invocation. Alternatively, the lower level xmlTextReaderNext can be used to iterate over XML node until we reach the translation unit XML element we are interested in. At that point xmlTextReaderExpand can be used to expand the XML node, then we let the context know that this is the current node of the corpus that needs to be processed, using read_context::get_corpus_node. Once we've done that, read_translation_unit_from_input can be called to process that particular corpus node. Note that the corpus node at hand, that needs to be processed will be retrieved by read_context::get_corpus_node. These two modes of operation are also available for read_corpus_from_input, read_symbol_db_from_input, read_elf_needed_from_input etc. Today, these functions all assume that the current node returned by read_context::get_corpus_node is the node /before/ the node of the corpus to be processed. So they all start looking at the /next sibling/ of the node returned by read_context::get_corpus_node. So the code was implicitly assuming that read_context::get_corpus_node was pointing to a text node that was before the node of the corpus that we want to process. This is wrong. read_context::get_corpus_node should just return the current node of the corpus that needs to be processed and voila. And so read_context::set_corpus_node should be used to set the current node of the corpus to the current element node that needs to be processed. That's the spirit of the change done by this patch. As its name suggests, the existing xml::advance_to_next_sibling_element is used to skip non element xml nodes (including text nodes) and move to the next element node to process, which is set to the context using read_context::set_corpus_node. Then the actual processing functions like read_corpus_from_input get the node to process, using read_context::get_corpus_node and process it rather than processing the sibling node that comes after it. The other changes are either to prevent related crashes that I noticed while doing various tests, update the abilint tool used to read and debug abixml input files and add better documentation. * src/abg-reader.cc (read_context::get_corpus_node): Add comment to this member function. (read_translation_unit_from_input, read_symbol_db_from_input) (read_elf_needed_from_input): Start processing the current node of the corpus that needs to be processed rather than its next sibling. Once the processing is done, set the new "current node of the corpus to be processed" properly by skipping to the next element node to be processed. (read_corpus_from_input): Don't get out early when the 'abi-corpus' element is empty. If, however, it has children node, skip to the first child element and flag it -- using read_context::set_corpus_node -- as being the element node to be processed by the processing facilities of the reader. If we are in a mode where we called xmlTextReaderExpand ourselves to get the node to process, then it means we need to free that node indirectly by calling xmlTextReaderNext. In that case, that node should not be flagged by read_context::set_corpus_node. Add more comments. * src/abg-corpus.cc (corpus::is_empty): Do not crash when no symtab is around. * src/abg-libxml-utils.cc (go_to_next_sibling_element_or_stay): Fix typo in comment. (advance_to_next_sibling_element): Don't crash when given a nil node. * tests/data/test-abidiff/test-PR27616-squished-v0.abi: Add new test input. * tests/data/test-abidiff/test-PR27616-squished-v1.abi: Likewise. * tests/data/test-abidiff/test-PR27616-v0.xml: Likewise. * tests/data/test-abidiff/test-PR27616-v1.xml: Likewise. * tests/data/Makefile.am: Add the new test inputs above to source distribution. * tests/test-abidiff.cc (specs): Add the new tests inputs above to this harness. * tools/abilint.cc (main): Support writing corpus groups. Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
|
b215a21153 |
dwarf-reader: properly set artificial-ness in opaque types
get_opaque_version_of_type forgets to set the "is-artificial" property according to the initial type the opaque type is derived from. This can lead to some instability in the abixml output. Fixed thus. * src/abg-dwarf-reader.cc (get_opaque_version_of_type): Propagate the artificial-ness of the original type here. * tests/data/test-read-dwarf/PR27700/test-PR27700.abi: Adjust. Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
|
a16b922b11 |
dwarf-reader: Canonicalize opaque enums and classes
This issue was reported in bug https://sourceware.org/bugzilla/show_bug.cgi?id=27700. When we construct an opaque type (triggered by the use of --drop-private-types along with the --headers-dir option on abidw, for instance) with get_opaque_version_of_type we forget to canonicalize the resulting type. Later, at abixml emitting time (for instance) hash_as_canonical_type_or_constant would rightfully abort because the type wasn't canonicalized. We want all types (okay, modulo one exception) in the system to be canonicalized. This patch fixes the problem by canonicalizing opaque types. * src/abg-dwarf-reader.cc (build_ir_node_from_die): Canonicalize opaque enums and classes. * tests/data/test-read-dwarf/PR27700/include-dir/priv.h: New test header file. * tests/data/test-read-dwarf/PR27700/include-dir/pub.h: Likewise * tests/data/test-read-dwarf/PR27700/pub-incdir/inc.h: Likewise. * tests/data/test-read-dwarf/PR27700/test-PR27700.o: New binary input file. * tests/data/test-read-dwarf/PR27700/test-PR27700.abi: Reference abi file of the binary above. * tests/data/test-read-dwarf/PR27700/test-PR27700.c: Source file of the binary above. * tests/data/Makefile.am: Add the test material above to source distribution. * tests/test-read-dwarf.cc (InOutSpec::in_public_headers_path): Add new data member. (in_out_specs): Adjust to reflect the new data member in the InOutSpec type. Add a new test input. (set_suppressions_from_headers): Define new static function. (test_task::perform): Use the content of the new InOutSpec::in_public_headers_path to construct and add "--headers-dir <headers-dir> --drop-private-types" to the options of the abidw program run. Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
|
acc4bea0b8 |
symtab: Add support for MODVERSIONS (CRC checksums)
The Linux Kernel has a mechanism (MODVERSIONS) to checksum symbols based on their type. In a way similar to what libabigail does, but different. The CRC values for symbols can be extracted from the symtab either by following the __kcrctab_<symbol> entry or by using the __crc_<symbol> value directly. This patch adds support for extracting those CRC values and storing them as a property of elf_symbol. Subsequently, 'crc' gets emitted as an attribute of 'elf-symbol' in the XML representation. CRC comparisons are also added to the abidiff machinery such that if both representations of a comparison contain a CRC value, they will be compared and if any of the values is unset (i.e. == 0), equality is assumed. Differences will be reported in the format that the Kernel presents them e.g. via Module.symvers. It is likely, but not necessary, that a CRC difference comes along with an ABI difference reported by libabigail. Not everything that leads to a change of the CRC value an ABI breakage in the libabigail sense. In case a function or variable symbol changes in a harmless way, we would previously also consider a CRC change harmless (or more precise: not harmful). Explicitly testing for CRC changes when analyzing whether diff nodes need to be considered harmful, allows to still classify them harmful. Also add some test cases to ensure reading CRC values from kernel binaries works as expected. The empty-report files have been consolidated to one file: empty-report.txt. That also clarifies the expected outcome for the affected tests. * include/abg-ir.h (elf_symbol::elf_symbol): Add CRC parameter. (elf_symbol::create): Likewise. (elf_symbol::get_crc): New member method. (elf_symbol::set_crc): New member method. * src/abg-comp-filter.cc (crc_changed): New function. (categorize_harmful_diff_node): Also test for CRC changes. * src/abg-ir.cc (elf_symbol::priv::crc_): New data member. * src/abg-ir.cc (elf_symbol::priv::priv): Add CRC parameter. (elf_symbol::elf_symbol): Likewise. (elf_symbol::create): Likewise. (elf_symbol::textually_equals): Add CRC support. (elf_symbol::get_crc): New member method. (elf_symbol::set_crc): New member method. * src/abg-reader.cc (build_elf_symbol): Add CRC support. * src/abg-reporter-priv.cc (maybe_report_diff_for_symbol): Likewise. * src/abg-symtab-reader.cc (symtab::load): Likewise. * src/abg-writer.cc (write_elf_symbol): Likewise. * tests/data/Makefile.am: Add new test data files. * tests/data/test-abidiff-exit/test-crc-report.txt: New test file. * tests/data/test-abidiff-exit/test-crc-v0.abi: Likewise. * tests/data/test-abidiff-exit/test-crc-v1.abi: Likewise. * tests/data/test-abidiff/empty-report.txt: New file. * tests/data/test-abidiff/test-PR18166-libtirpc.so.report.txt: Deleted. * tests/data/test-abidiff/test-PR24552-report0.txt: Deleted. * tests/data/test-abidiff/test-crc-0.xml: New test file. * tests/data/test-abidiff/test-crc-1.xml: Likewise. * tests/data/test-abidiff/test-crc-2.xml: Likewise. * tests/data/test-abidiff/test-crc-report.txt: Likewise. * tests/data/test-abidiff/test-empty-corpus-report.txt: Deleted. * tests/data/test-read-dwarf/PR25007-sdhci.ko.abi: Add CRC values. * tests/data/test-read-write/test-crc.xml: New test data file. * tests/data/test-symtab/kernel-modversions/Makefile: New test source. * tests/data/test-symtab/kernel-modversions/one_of_each.c: Likewise. * tests/data/test-symtab/kernel-modversions/one_of_each.ko: Likewise. * tests/test-abidiff-exit.cc: Add new test case. * tests/test-abidiff.cc: Add new test case. * tests/test-read-write.cc: Likewise. * tests/test-symtab.cc (Symtab::KernelSymtabsWithCRC): New test case. Reviewed-by: Giuliano Procida <gprocida@google.com> Reviewed-by: Dodji Seketeli <dodji@seketeli.org> Signed-off-by: Matthias Maennich <maennich@google.com> |
||
|
7e223bfc04 |
dwarf-reader/writer: consider aliases when dealing with suppressions
When the symbol of a decl is suppressed and it happens to be the main symbol of a group of aliased symbols where another symbol is not suppressed, the dwarf reader discards the decl from the internal representation altogether upon reading and thus the writer will not be able to connect that decl to the non-suppressed aliased elf symbol. In order to address this, ensure we are not suppressing decls for which an alias is not suppressed. We therefore keep the decl in the IR when at least one its underlying aliased symbols is non-suppressed. Likewise, when the abg-writer is having to attach an elf-symbol-id to the decl, instead of omitting the symbol altogether, rather make use of the property of aliases and connect the dwarf information to an alias instead. This way the function dwarf information stays connected to the elf symbol that we want to track. When reading from XML with a symbol whitelist that leads to suppression of aliased symbols, abidiff would hit an assertion and crash when looking up the aliased symbol due to it being suppressed. In the new symtab reader we can still suppress a symbol without removing it from the lookup. Make use of that property to fix this bug. A test has been added for this as well. * src/abg-dwarf-reader.cc(function_is_suppressed): Do not suppress a function for which there is an alias that is not suppressed. (variable_is_suppressed): Likewise for variables. * src/abg-reader.cc (build_elf_symbol): Improve handling of suppressed aliased symbols when reading from XML. * src/abg-symtab-reader.cc (load): Likewise. * src/abg-writer.cc(write_elf_symbol_reference): Fall back to any aliased symbol if the main symbol is suppressed. * tests/data/Makefile.am: Add new test files. * tests/data/test-abidiff-exit/test-missing-alias-report.txt: New test file. * tests/data/test-abidiff-exit/test-missing-alias.abi: Likewise. * tests/data/test-abidiff-exit/test-missing-alias.suppr: Likewise. * tests/test-abidiff-exit.cc: Add support for whitelists and add new testcase. * tests/data/test-read-dwarf/test-suppressed-alias.c: New test file. * tests/data/test-read-dwarf/test-suppressed-alias.o: Likewise. * tests/data/test-read-dwarf/test-suppressed-alias.o.abi: Likewise. * tests/data/test-read-dwarf/test-suppressed-alias.suppr: Likewise. * tests/data/test-read-dwarf/test3-alias-1.so.hash.abi: Likewise. * tests/data/test-read-dwarf/test3-alias-1.suppr: Likewise. * tests/data/test-read-dwarf/test3-alias-2.so.hash.abi: Likewise. * tests/data/test-read-dwarf/test3-alias-2.suppr: Likewise. * tests/data/test-read-dwarf/test3-alias-3.so.hash.abi: Likewise. * tests/data/test-read-dwarf/test3-alias-3.suppr: Likewise. * tests/data/test-read-dwarf/test3-alias-4.so.hash.abi: Likewise. * tests/data/test-read-dwarf/test3-alias-4.suppr: Likewise. * tests/test-read-dwarf.cc: Add new test cases. Reviewed-by: Giuliano Procida <gprocida@google.com> Reviewed-by: Dodji Seketeli <dodji@seketeli.org> Signed-off-by: Matthias Maennich <maennich@google.com> |
||
|
ff4b4a56b4 |
symtab/dwarf-reader: allow hinting of main symbols for aliases
In case of aliased symbols, the "main symbol" cannot be deduced from the symtab as this solely contains a name->addr mapping and aliases are represented by multiple names resolving to the same address. Therefore the main symbol can only be picked rather randomly and unpredictable. Unlike DWARF, which contains a single symbol entry for only the main symbol. Hence we can (late) detect the main symbol. Exploiting that property allows to correct the addr->symbol lookup in the symtab to return the correct main symbol and it also allows to correct the aliased symbols to maintain the correct main symbol. This patch adds the `update_main_symbol` functionality to `elf_symbol` to update the main symbol by name (ELF symbols need unique names) and adds `update_main_symbol` to `symtab` that makes use of said new method. When we discover a main symbol during DWARF reading, we instruct the symtab to update the mapping. This creates consistent representations across different builds of the same binary with the same ABI by pinning down the main symbol to the defined one. Knowing the main symbol also helps to keep the correct dwarf information in the representation in the presence of symbol suppressions. A later patch will address that. Some test cases in tests/data need adjustment and they have all been verified to be valid changes. - main symbol changed for various elf symbols - test-annotate/test15-pr18892.so.abi - test-annotate/test19-pr19023-libtcmalloc_and_profiler.so.abi - test-annotate/test3.so.abi - test-read-dwarf/test15-pr18892.so.abi - test-read-dwarf/test19-pr19023-libtcmalloc_and_profiler.so.abi - test-read-dwarf/test3.so.abi - test-read-dwarf/test3.so.hash.abi - due to main symbol changes, the symbol diff needs to be corrected - test-diff-dwarf/test12-report.txt - test-diff-pkg/tbb-4.1-9.20130314.fc22.x86_64--tbb-4.3-3.20141204.fc23.x86_64-report-0.txt - test-diff-pkg/tbb-4.1-9.20130314.fc22.x86_64--tbb-4.3-3.20141204.fc23.x86_64-report-1.txt - the test scenario needed adjustments as the main symbol changed - test-diff-suppr/test23-alias-filter-4.suppr - test-diff-suppr/test23-alias-filter-report-0.txt - test-diff-suppr/test23-alias-filter-report-2.txt As usual, the complete changelog follows. * include/abg-ir.h (elf_symbol::update_main_symbol): New method. * include/abg-symtab-reader.h (symtab::update_main_symbol): New method. * src/abg-dwarf-reader.cc (build_var_decl): Hint symtab about main symbol discovered in DWARF. (build_function_decl): Likewise. * src/abg-ir.cc (elf_symbol::get_main_symbol): Lock the weak_ptr on access in both overloads. (update_main_symbol): New method to allow updating the main symbol. * src/abg-symtab-reader.cc (symtab::update_main_symbol): New method. * data/Makefile.am: Add new test data files. * tests/data/test-annotate/test15-pr18892.so.abi: Updated test file. * tests/data/test-annotate/test19-pr19023-libtcmalloc_and_profiler.so.abi: Likewise. * tests/data/test-annotate/test2.so.abi: Likewise. * tests/data/test-annotate/test3.so.abi: Likewise. * tests/data/test-diff-dwarf/test12-report.txt: Likewise. * tests/data/test-diff-dwarf/test42-PR21296-clanggcc-report0.txt: Likewise. * tests/data/test-diff-filter/test31-pr18535-libstdc++-report-0.txt: Likewise. * tests/data/test-diff-filter/test31-pr18535-libstdc++-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/test23-alias-filter-4.suppr: 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-read-dwarf/PR22015-libboost_iostreams.so.abi: Likewise. * tests/data/test-read-dwarf/PR22122-libftdc.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/test15-pr18892.so.abi: Likewise. * tests/data/test-read-dwarf/test16-pr18904.so.abi: Likewise. * tests/data/test-read-dwarf/test19-pr19023-libtcmalloc_and_profiler.so.abi: Likewise. * tests/data/test-read-dwarf/test2.so.abi: Likewise. * tests/data/test-read-dwarf/test2.so.hash.abi: Likewise. * tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi: Likewise. * tests/data/test-read-dwarf/test3.so.abi: Likewise. * tests/data/test-read-dwarf/test3.so.hash.abi: Likewise. * tests/data/test-symtab/basic/aliases.c: New test source file. * tests/data/test-symtab/basic/aliases.so: Likewise. * tests/test-symtab.cc (Symtab::AliasedFunctionSymbols): New test case. (Symtab::AliasedVariableSymbols): Likewise. Reviewed-by: Giuliano Procida <gprocida@google.com> Reviewed-by: Dodji Seketeli <dodji@seketeli.org> Signed-off-by: Matthias Maennich <maennich@google.com> |
||
|
f427346262 |
test-symtab: add tests for whitelisted functions
Extend the test functionality in test-symtab to allow processing of KMI whitelists and add additional test cases for whitelist handling. * tests/data/Makefile.am: add new test files * tests/data/test-symtab/basic/one_function_one_variable_all.whitelist: New test file, * tests/data/test-symtab/basic/one_function_one_variable_function.whitelist: Likewise. * tests/data/test-symtab/basic/one_function_one_variable_irrelevant.whitelist: Likewise. * tests/data/test-symtab/basic/one_function_one_variable_variable.whitelist: Likewise. * tests/test-symtab.cc (read_corpus): Add support for whitelists. (assert_symbol_count): Likewise. (Symtab::SymtabWithWhitelist): New testcase. Reviewed-by: Giuliano Procida <gprocida@google.com> Reviewed-by: Dodji Seketeli <dodji@seketeli.org> Signed-off-by: Matthias Maennich <maennich@google.com> |
||
|
7851ca2b91 |
abg-corpus: remove symbol maps and their setters
With the prework in previous commits, we are now able to drop the public symbols maps in corpus::priv and replace them by private members with access through getters. The getters use the new symtab implementation to generate the maps on the fly. Setters are not required anymore and are removed. Also remove redundant getters. We could also remove the getters for the symbol maps and the local caching variable and leave it all to lookup_symbol, but this is left for a later change. * include/abg-corpus.h (corpus::set_fun_symbol_map): Remove method declaration. (corpus::set_undefined_fun_symbol_map): Likewise. (corpus::set_var_symbol_map): Likewise. (corpus::set_undefined_var_symbol_map): Likewise. (corpus::get_fun_symbol_map_sptr): Likewise. (corpus::get_undefined_fun_symbol_map_sptr): Likewise. (corpus::get_var_symbol_map_sptr): Likewise. (corpus::get_undefined_var_symbol_map_sptr): Likewise. * src/abg-corpus-priv.h (corpus::priv::var_symbol_map): make private and mutable (corpus::priv::undefined_var_symbol_map): Likewise. (corpus::priv::fun_symbol_map): Likewise. (corpus::priv::undefined_fun_symbol_map): Likewise. (corpus::priv::get_fun_symbol_map): New method declaration. (corpus::priv::get_undefined_fun_symbol_map): Likewise. (corpus::priv::get_var_symbol_map): Likewise. (corpus::priv::get_undefined_var_symbol_map): Likewise. * src/abg-corpus.cc (corpus::priv::get_fun_symbol_map): New method implementation. (corpus::priv::get_undefined_fun_symbol_map): Likewise. (corpus::priv::get_var_symbol_map): Likewise. (corpus::priv::get_undefined_var_symbol_map): Likewise. (corpus::is_empty): depend on symtab only. (corpus::set_fun_symbol_map): Remove method. (corpus::set_undefined_fun_symbol_map): Likewise. (corpus::set_var_symbol_map): Likewise. (corpus::set_undefined_var_symbol_map): Likewise. (corpus::get_fun_symbol_map_sptr): Likewise. (corpus::get_undefined_fun_symbol_map_sptr): Likewise. (corpus::get_var_symbol_map_sptr): Likewise. (corpus::get_undefined_var_symbol_map_sptr): Likewise. (corpus::get_fun_symbol_map): Use corpus::priv proxy method. (corpus::get_undefined_fun_symbol_map): Likewise. (corpus::get_var_symbol_map): Likewise. (corpus::get_undefined_var_symbol_map): Likewise. * src/abg-dwarf-reader.cc (read_debug_info_into_corpus): Do not set corpus symbol maps anymore. * src/abg-reader.cc (read_corpus_from_input): Likewise. * tests/test-symtab.cc (assert_symbol_count): Do not access the corpus symbol maps through sptr anymore. * tests/data/test-read-dwarf/PR25007-sdhci.ko.abi: Adjust expected test output. Reviewed-by: Giuliano Procida <gprocida@google.com> Reviewed-by: Dodji Seketeli <dodji@seketeli.org> Signed-off-by: Matthias Maennich <maennich@google.com> Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
|
2ed1ca7031 |
corpus: make get_(undefined_)?_(var|fun)_symbols use the new symtab
Make the corresponding members an implementation detail of corpus::priv. They get computed based on the new symtab whenever they are accessed first with an atomic instantiation. That simplifies the implementation and homogenizes the access to functions and variables. Sorting does not need to be done as the symtab already gives a guarantee for that. Due to improved alias detection in the new symtab reader, ensure we only write symbol aliases to ksymtab symbols if having a ksymtab main symbol. Test data needed to be adjusted as the new symtab reader is stricter in regards to symbols listed in ksymtab. I.e. init_module is not an exported symbol in the ksymtab of a kernel module. * src/abg-corpus-priv.h (corpus::priv::sorted_var_symbols): make private, mutable and optional. (corpus::sorted_undefined_var_symbols): Likewise. (corpus::sorted_fun_symbols): Likewise. (corpus::sorted_undefined_fun_symbols): Likewise. (corpus::priv::get_sorted_fun_symbols): New method declaration. (corpus::priv::get_sorted_undefined_fun_symbols): Likewise. (corpus::priv::get_sorted_var_symbols): Likewise. (corpus::priv::get_sorted_undefined_var_symbols): Likewise. * src/abg-corpus.cc (corpus::elf_symbol_comp_functor): Delete struct. (corpus::priv::get_sorted_fun_symbols): New method implementation. (corpus::priv::get_sorted_undefined_fun_symbols): Likewise. (corpus::priv::get_sorted_var_symbols): Likewise. (corpus::priv::get_sorted_undefined_var_symbols): Likewise. (corpus::get_sorted_fun_symbols): Proxy call to corpus::priv. (corpus::get_sorted_undefined_fun_symbols): Likewise. (corpus::get_sorted_var_symbols): Likewise. (corpus::get_sorted_undefined_var_symbols): Likewise. * src/abg-writer.cc (write_elf_symbol_aliases): When emitting aliases for a kernel symbol, ensure to only emit exported, public aliases. * tests/data/test-read-dwarf/PR25007-sdhci.ko.abi: update test data. Reviewed-by: Giuliano Procida <gprocida@google.com> Reviewed-by: Dodji Seketeli <dodji@seketeli.org> Signed-off-by: Matthias Maennich <maennich@google.com> |