mirror of
git://sourceware.org/git/libabigail.git
synced 2025-03-10 08:37:41 +00:00
457f5cb202
656 Commits
Author | SHA1 | Message | Date | |
---|---|---|---|---|
|
2f61188d43 |
dwarf-reader: Do not re-use typedefs in a scope
Sometimes, two typedefs of the same name can appear at the same scope but point to different types, in DWARF. Unbelievable but true. In those case, we do not want to re-use the typedef, obviously, as we can possibly misrepresent the type graph in that case. This fixes one self-comparison issue for the x86_64 sub-package of the gcc-gnat package that is tested by doing: $ fedabipkgdiff --self-compare -a --from fc37 gcc-gnat * src/abg-dwarf-reader.cc (build_ir_node_from_die): Do not re-use a typedef from a given scope. * src/abg-reader.cc (build_typedef_type): Do not re-use typedefs with the same ID. * 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-read-dwarf/PR22122-libftdc.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/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. * tests/data/test-read-dwarf/test9-pr18818-clang.so.abi: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
|
d8de76cfa8 |
ir: Use non qualified typedef name for type canonicalization
While looking into fixing self-comparison errors for the gcc-gnat package[1], I stumbled upon the fact that a typedef that is defined in the global scope is different from a typedef defined in a scope, even if they both point to the same underlying type. This is a spurious difference that feeds a spurious explosion of the number of canonical types, for no reason. It can lead to spurious self-comparison errors down the road. Sadly, fixing this issue is not enough to fix the self-comparison error in [1]. [1]: The command is: $ fedabipkgdiff --self-compare -a --from fc37 gcc-gnat * include/abg-ir.h (reference_type_def::{pointed_to_type_, is_lvalue_}): Remove these data members. (reference_type_def::priv_): Add a unique data member. (typedef_decl::get_qualified_name): Add new virtual member functions. * src/abg-ir.cc (get_decl_name_for_comparison): If the decl we are comparing is a typedef, only consider its non-qualified name. (get_type_name): For internal purposes, the type name of a typedef is its non-qualified name. (pointer_type_def::get_qualified_name): For internal purposes, if the pointed-to name is a typedef, use the non-qualified name of the typedef. (reference_type_def::priv): Define new data type. (reference_type_def::reference_type_def): Initialize the new reference_type_def::priv_ data member and adjust to the move of the reference_type_def::pointed_to_type_ data member to reference_type_def::priv::pointed_to_type_. (reference_type_def::{s,g}et_pointed_to_type): Adjust. (reference_type_def::is_lvalue): Likewise. (reference_type_def::get_qualified_name): Support caching qualified names for internal and non-internal purposes. (typedef_decl::get_pretty_representation): For internal purposes, use non-qualified typedef name. (typedef_decl::get_qualified_name): Define the two overloads for this virtual member function. (function_decl::get_pretty_representation): Use the 'qualified_name' parameter. Also, rather than systematically using the qualified name of the return type, use get_type_name instead that knows when to use qualified names and when not to. (qualified_name_setter::do_update): * tests/data/test-abidiff/test-PR18791-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/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-diff-dwarf/test42-PR21296-clanggcc-report0.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.hash.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/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/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> |
||
|
0239f89b4f |
ir: Really avoid canonicalizing decl-only classes
is_non_canonicalized_type uses is_declaration_only_class_or_union_type to detect decl-only classes, but it doesn't differentiate between decl-only classes that are associated to a class definition and those that are not. We want to avoid canonicalizing decl-only classes that are not associated to any class definition. This patch fixes the invocation of is_declaration_only_class_or_union_type to express the above assertion. This fix uncovered another self-comparison issue that was being expressed when running the command below: $ abidw --abidiff tests/data/test-types-stability/PR27086-libstdc++.so.6.0.26 That one was due to an error in method_decl::set_linkage_name which was making classes contain the wrong overloads of methods. The patch fixes that error too. * include/abg-fwd.h (is_pointer_to_decl_only_class_or_union_type) (is_reference_to_decl_only_class_or_union_type) (is_typedef_to_decl_only_class_or_union_type): Remove declarations. (is_typedef_ptr_or_ref_to_decl_only_class_or_union_type): Declare new function. * src/abg-ir.cc (is_pointer_to_decl_only_class_or_union_type) (is_reference_to_decl_only_class_or_union_type) (is_typedef_to_decl_only_class_or_union_type): Remove definitions. (is_typedef_ptr_or_ref_to_decl_only_class_or_union_type): Define new function. (is_non_canonicalized_type): Change the invocation of is_declaration_only_class_or_union_type to make it look through decl-only types. Use is_typedef_ptr_or_ref_to_decl_only_class_or_union_type in lieu of is_{pointer,reference,typedef}_to_decl_only_class_or_union_type that got removed. (method_decl::set_linkage_name): Remove the mapping between the method and the old linkage name, only if the old name is different from the new name. Duh. * tests/data/test-annotate/libtest23.so.abi: Adjust. * 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/libtest23.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/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> |
||
|
0447eb27aa |
ir: Avoid forgetting potential seemingly duplicated member functions
In some rare cases expressed in DWARF from C++, a member function can belong to both a declaration-only class (having no data member) in one translation unit, and to a fully defined class in another translation unit. In those cases, the two classes are represented and considered different. But then, consider a destructor which mangled name is "D1". D1 is represented in both the decl-only class and the fully-defined class. In the former case, its "this pointer" points to a decl-only class, while in the later case its "this pointer" points a fully-defined class. So, D1 coming from the former case will compare different from the D1 coming from the later case, because of the spurious difference "decl-only class" versus "fully-defined class". This is in the context of a self-comparison. One way to fix this self-comparison subtle change is to give the former D1 and the later D1 two different "function ID"s. Today, the function ID is just the mangled name, D1. This patch is defining a more involved ID which makes the difference between a member function on a decl-only class and a member function on a fully-defined class. Note that the only member functions that matter are virtual member functions because they are the only member functions that are considered when comparing two classes. This fixes the self-comparison error found on the binary gcc-gnat-12.3.1-1.fc37.x86_64/usr/libexec/gcc/x86_64-redhat-linux/12/gnat1 while running the self-comparison command below: $ fedabipkgdiff --self-compare -a --from fc37 gcc-gnat * src/abg-ir.cc (is_declaration_only_class_or_union_type): Add an overload for type_base_sptr. (function_decl::get_id): Virtual member functions that are defined on decl-only classes have a special ID to avoid confusing them with their counterparts defined on defined classes. * src/abg-reader.cc (build_function_decl) (build_function_decl_if_not_suppressed): Add a new add_to_exported_decls parameter to avoid adding the function to the set of exported decls to early. For the function to be properly added to the set of exported decls, all its attributes must be set, including virtualness. In some case, those attributes are not yet known by the end of the call to build_function_decl. The caller must then set those properties and then add the function to the set of exported decls. (build_{class,union}_decl): Build the function first, then add its missing properties and *then* add it to the set of exported decls. (handle_function_decl): Adjust. * tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi: Adjust. Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
|
bad389f01a |
abipkgdiff: Avoid comparing binaries that are outside of the package
Some symlinks in some RPMs resolve to binaries outside of the package. In those cases, avoid considering them. * src/abg-tools-utils.cc (maybe_get_symlink_target_file_path): Do not require that the file path points to a symlink. A file path can point to a file that is not a symlink and yet the whole path can be in parent directory that is a symlink. In this case, realpath will correctly resolve to the correct target file. * tools/abipkgdiff.cc (maybe_update_package_content): A path to a binary that is not inside the RPM (because a symlink resolved to a file outside of the RPM) should not be added to the set of binaries to be analyzed. * tests/data/test-diff-pkg/symlink-dir-test1-report1.txt: Add new test file. * tests/data/test-diff-pkg-ctf/symlink-dir-test1-report1.txt: Likewise. * tests/data/Makefile.am: Add new test file to source distribution. * tests/test-diff-pkg.cc (in_out_specs): for the data/test-diff-pkg/symlink-dir-test1/dir{1,2}/symlinks test, the root dir of the package is data/test-diff-pkg/symlink-dir-test1/dir{1,2}. Use that to test that the symlinks are properly handled. Also, use the data/test-diff-pkg/symlink-dir-test1/dir{1,2}/symlinks as a root of an alternative package for which the symlinks resolve outside the package, under data/test-diff-pkg/symlink-dir-test1/dir{1,2}/targets. In this later case, the symlinked files should be ignored in the comparison. Likewise for data/test-diff-pkg-ctf/symlink-dir-test1/dir1/symlinks. Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
|
0b338dfaf6 |
abidiff: Add --{follow,list}-dependencies & add-binaries{1,2} support
This patch implements comparing two sets of binaries constituted by the binaries given in argument of the abidiff command, as well as their respective dependencies (specified by the DT_NEEDED ELF property for ELF binaries) or an arbitrary set of libraries found in the directories determined by --added-binaries-dir{1,2}. The detected dependencies can also be listed by the option --list-dependencies. * tools/abidiff.cc (options::{follow_dependencies, list_dependencies, added_bins_dirs1, added_bins_dirs2, added_bins1, added_bins2}): Add new data members. (options::options): Initialize the new follow_dependencies and list_dependencies boolean data members. (display_usage): Add usage strings for --added-binaries-dir{1,2}, --add-binaries{1,2}, --follow-dependencies, --list-dependencies. (parse_command_line): Parse the options --follow-dependencies, --list-dependencies, --added-binaries-dir{1,2}, --add-binaries{1,2}. (display_dependencies): Add new static function. (main): Support the new --add-binaries{1,2}, --follow-dependencies, --list-dependencies. * doc/manuals/abidiff.rst: Document the new options above. * tests/data/test-abidiff-exit/test-PR30034/libabigail.abignore: Add test input. * tests/data/test-abidiff-exit/test-PR30034/reference/include/rte_log.h: Likewise. * tests/data/test-abidiff-exit/test-PR30034/reference/lib64/librte_eal.so: Likewise. * tests/data/test-abidiff-exit/test-PR30034/reference/lib64/librte_eal.so.23: Likewise. * tests/data/test-abidiff-exit/test-PR30034/reference/lib64/librte_eal.so.23.1: Likewise. * tests/data/test-abidiff-exit/test-PR30034/reference/lib64/librte_kvargs.so: Likewise. * tests/data/test-abidiff-exit/test-PR30034/reference/lib64/librte_kvargs.so.23: Likewise. * tests/data/test-abidiff-exit/test-PR30034/reference/lib64/librte_kvargs.so.23.1: Likewise. * tests/data/test-abidiff-exit/test-PR30034/reference/lib64/librte_telemetry.so: Likewise. * tests/data/test-abidiff-exit/test-PR30034/reference/lib64/librte_telemetry.so.23: Likewise. * tests/data/test-abidiff-exit/test-PR30034/reference/lib64/librte_telemetry.so.23.1: Likewise. * tests/data/test-abidiff-exit/test-PR30034/split/include/rte_log.h: Likewise. * tests/data/test-abidiff-exit/test-PR30034/split/lib64/librte_eal.so: Likewise. * tests/data/test-abidiff-exit/test-PR30034/split/lib64/librte_eal.so.23: Likewise. * tests/data/test-abidiff-exit/test-PR30034/split/lib64/librte_eal.so.23.2: Likewise. * tests/data/test-abidiff-exit/test-PR30034/split/lib64/librte_kvargs.so: Likewise. * tests/data/test-abidiff-exit/test-PR30034/split/lib64/librte_kvargs.so.23: Likewise. * tests/data/test-abidiff-exit/test-PR30034/split/lib64/librte_kvargs.so.23.2: Likewise. * tests/data/test-abidiff-exit/test-PR30034/split/lib64/librte_log.so: Likewise. * tests/data/test-abidiff-exit/test-PR30034/split/lib64/librte_log.so.23: Likewise. * tests/data/test-abidiff-exit/test-PR30034/split/lib64/librte_log.so.23.2: Likewise. * tests/data/test-abidiff-exit/test-PR30034/split/lib64/librte_telemetry.so: Likewise. * tests/data/test-abidiff-exit/test-PR30034/split/lib64/librte_telemetry.so.23: Likewise. * tests/data/test-abidiff-exit/test-PR30034/split/lib64/librte_telemetry.so.23.2: Likewise. * tests/data/test-abidiff-exit/test-PR30034/test-PR30034-report-1.txt: Likewise. * tests/data/Makefile.am: Add the test inputs to source distribution. * tests/test-abidiff-exit.cc (InOutSpec::in_elfv{0,1}_added_bins_dir): Add new data member. (main): Add --added-binaries-dir{1,2} option to abidiff if the InOutSpec::in_elfv{0,1}_added_bins_dir data members are non-empty. (in_out_specs): Add test inputs to this test harness. Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
|
a69bbac706 |
Bug 30461 - insight fails self-compare
This self-comparison issue is due to several different underlying problems. Class destructors are often implemented by the compiler using cloned functions, even for virtual destructors. In DWARF, for a given class, the cloned function implementing the virtual destructor might come way after the point where the class and its member functions (including the destructors) have been declared. So the DWARF reader needs to match the "dangling" cloned function that implements the virtual destructor with the destructor declared in the class declaration. Note that it's the cloned definition that contains the address of the ELF symbol for the destructor, not the declaration. So we really need to see the cloned function to build a proper IR (that also represents the ELF symbol) for the destructor. As the destructor is implemented by a cloned function, we might see (in the DWARF) other clones of that function that have the same linkage name. In that case, if the IR of the class already has a destructor with the same linkage name, then we not build another IR for it, otherwise we'd wrongly duplicate the destructor. And this is exactly the error we were doing in this issue. This patch addresses that issue. The ABIXML does unfortunately have classes with duplicated destructors, due to this. So as the DWARF reader is now going to be fixed, the ABIXML reader also needs to be fixed to avoid reading duplicated member functions. The patch addresses that issue as well. Then, when the above was fixed, I stumbled across an issue related to type fundamentals of type canonicalization: I think we will ultimately need to be able to canonicalize types in the same order, if they come from DWARF or ABIXML. It now appears to me that because of recursive types in the context of ODR-violations (two different types being present in different translation units and yet having the same name. For instance, the BFD type from binutils and this insight package), type canonicalization is not a commutative operation, unfortunately. That is why we need to either store some type hash in ABIXML to avoid having to re-do type canonicalization when reading ABIXML, or canonicalize types coming from ABIXML in the same order as they were, when they came from their initial format (DWARF or otherwise). This would be a project in it own right. Until then, a workaround that seems to be enough in this case is to clear the type comparison result cache after canonicalizing each type. The rest of the patch adjusts the regression tests output as needed. For the record, below is the command line that triggered the issue: $ fedabipkgdiff --debug --self-compare -a --from fc38 insight * src/abg-dwarf-reader.cc (build_ir_node_from_die): If we are looking at a cloned function that's a member function to be added to an existing class, make sure a member function with the same linkage name doesn't already exist in the class before adding this one. Otherwise, we'd be duplicating a member function inside the class. * src/abg-ir.cc (method_decl::set_linkage_name): When setting the linkage name of a method to a new one, erase the old method that had the old linkage name from the containing class. (compare_canonical_type_against_candidate): Clear the comparison type result cache after each type canonicalization to avoid re-using cached result that should have been invalidated. This is a work-around the more fundamental type canonicalization issue outlined in the preamble of this commit log. * src/abg-reader.cc (build_function_decl): Avoid loading duplicated member functions. The key of the function being its mangled name. (build_class_decl): The XML node to map when looking a member function is really the XML node for the member function. * tests/data/test-abidiff/test-PR18791-report0.txt: Adjust. * 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/test-libandroid.so.abi: Likewise. * tests/data/test-read-dwarf/test10-pr18818-gcc.so.abi: Likewise. * tests/data/test-read-dwarf/test16-pr18904.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> |
||
|
7b565f399e |
Bug 30503 - Fail to compare non-anonymous struct vs named struct data members
Since this commit
commit
|
||
|
d00a2cc2da |
Bug 30466 - harfbuzz fails self-check on f38
Since this commit:
commit
|
||
|
676d8a8149 |
dwarf-reader: Don't compute canonical type while propagating one
When propagate_canonical_type sees that the source type doesn't have a canonical type, it tries to compute one for it. But then suppose we are into computing the canonical type of a type T to begin with. At some point we want to try to propagate the canonical type of a sub-type S of T. Suppose S recursively references T. When propagate_canonical_type is called from maybe_propagate_canonical_type on S, it's going to try to compute a canonical type for T (indirectly), as T doesn't yet have a canonical type. We then end up in a recursive calling loop that overflows the execution stack. * src/abg-dwarf-reader.cc (propagate_canonical_type): If the source (right-hand-side) type has no canonical type, do not compute it and thus, do not try to propagate its canonical type to the destination (left-hand-side) type. * tests/data/test-annotate/test15-pr18892.so.abi: Adjust. * tests/data/test-read-dwarf/test15-pr18892.so.abi: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
|
1392a720a8 |
ini: Do not crash on incorrect property value
When the value of the 'name_regexp' property is incorrect, the ini parser can crash. Pancake, of Radare2 fame, reported this one by email. Fixed thus. * src/abg-ini.cc (read_context::read_property_value): Do not dereference a null pointer to list property value. * tests/data/test-ini/test02-buggy-property-value.abignore: New test input. * tests/data/test-ini/test02-buggy-property-value.abignore.expected: Likewise. * tests/data/Makefile.am: Add the two new test inputs to source distribution. * tests/test-ini.cc (in_out_spec): Add the new test input pair to this test harness. Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
|
6c65b54fbd |
Fix the test of the patch for Bug 30309
It turns out I forgot to add a test file to the source distribution. Fixed thus. * tests/data/Makefile.am: Add test-abidiff-exit/PR30329/PR30329-report-1.txt to source distribution. Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
|
6ba26ed6ae |
Bug 30309 - Support absolute path to alt debug info file in DWARF
Until now, the path to the alternate DWARF file, given by the content of the .gnu_debugaltlink section has generally been a relative path. That is what the elf reader has grown to expect. In bug https://sourceware.org/bugzilla/show_bug.cgi?id=30329 the .gnu_debugaltlink section seems an absolute path: '/usr/lib/debug/dwz/components/sqlite.bst/x86_64-unknown-linux-gnu'. The elf-reader thus fails to find the alternate DWARF file as it's looking for a relative path under the debug info root directory. This path teaches the elf-reader to handle absolute alternate debuginfo files too. * src/abg-elf-reader.cc (find_alt_dwarf_debug_info_path): Trim the "/usr/lib/debug" prefix from the alt dwarf file path, if it was provided. The function is going to look for the alt dwarf file under the debug info root file instead. * src/abg-tools-utils.cc (entry_of_file_with_name): Add a parameter for the path to the root directory under which the files visit is taking place. Then, consider the file path being looked for as being relative to the root directory under which the files visit is taking place. * tests/data/test-abidiff-exit/PR30329/new-image/usr/lib/debug/dwz/components/sqlite.bst/x86_64-unknown-linux-gnu: New test input. * tests/data/test-abidiff-exit/PR30329/new-image/usr/lib/debug/usr/lib/x86_64-linux-gnu/libsqlite3.so.0.8.6.debug: Likewise. * tests/data/test-abidiff-exit/PR30329/new-image/usr/lib/x86_64-linux-gnu/libsqlite3.so.0.8.6: Likewise. * tests/data/test-abidiff-exit/PR30329/old-image/usr/lib/debug/dwz/components/sqlite.bst/x86_64-unknown-linux-gnu: Likewise. * tests/data/test-abidiff-exit/PR30329/old-image/usr/lib/debug/usr/lib/x86_64-linux-gnu/libsqlite3.so.0.8.6.debug: Likewise. * tests/data/test-abidiff-exit/PR30329/old-image/usr/lib/x86_64-linux-gnu/libsqlite3.so.0.8.6: Likewise. * tests/data/test-abidiff-exit/PR30329/PR30329-report-1.txt: Likewise. * tests/data/Makefile.am: Add the new test material above to source distribution. * tests/test-abidiff-exit.cc (InOutSpec::in_elfv{0,1}_debug_dir): New data members. Carry the debuginfo root dirs for the input binaries. (in_out_specs): Update the existing to adjust for the new InOutSpec::in_elfv{0,1}_debug_dir data members. Also, add a new entry for this new test case. (main): Pass the root debug info dirs to abidiff. Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
|
0f48cb2172 |
reader: Recognize variadic parameter type from abixml
When reading a variadic parameter type from the ABIXML, the reader forget to recognize it as THE unique variadic parameter type as returned by abigail::ir::environment::get_variadic_parameter_type(). That makes abigil::ir::environment::is_variadic_parameter_type() to fail on the variadic type that is build from ABIXML. Fixed thus. * include/abg-ir.h (environment::get_variadic_parameter_type_name) Declare ... * src/abg-ir.cc (environment::get_variadic_parameter_type_name): ... a new static member function. (environment::get_variadic_parameter_type): Use the new environment::get_variadic_parameter_type_name rather than using an open coded constant here. * src/abg-dwarf-reader.cc (die_return_and_parm_names_from_fn_type_die): Likewise. * src/abg-reader.cc (build_type_decl): For a variadic parameter type, return abigail::ir::environment::get_variadic_parameter_type() rather than building a new type. * tests/data/test-read-ctf/test2.so.abi: Adjust. * tests/data/test-read-ctf/test2.so.hash.abi: Likewise. * tests/data/test-read-ctf/test8.o.abi: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
|
7d71d4eaec |
writer: Annotate pointer representation
When starring at abixml I noticed that abixml --annotate would not annotate pointer-type-def XML elements. This patch fixes that and makes the code of write_pointer_type_def easier to debug. * src/abg-writer.cc (write_pointer_type_def): Invoke annotate. Add a temporary for the output of write_context::get_id_for_type. It makes it easier to inspect in the debugger. * tests/data/test-annotate/libtest23.so.abi: Adjust. * tests/data/test-annotate/libtest24-drop-fns-2.so.abi: Adjust. * tests/data/test-annotate/libtest24-drop-fns.so.abi: Adjust. * tests/data/test-annotate/test1.abi: Adjust. * tests/data/test-annotate/test13-pr18894.so.abi: Adjust. * tests/data/test-annotate/test14-pr18893.so.abi: Adjust. * tests/data/test-annotate/test15-pr18892.so.abi: Adjust. * tests/data/test-annotate/test17-pr19027.so.abi: Adjust. * tests/data/test-annotate/test18-pr19037-libvtkRenderingLIC-6.1.so.abi: Adjust. * tests/data/test-annotate/test19-pr19023-libtcmalloc_and_profiler.so.abi: Adjust. * tests/data/test-annotate/test20-pr19025-libvtkParallelCore-6.1.so.abi: Adjust. * tests/data/test-annotate/test21-pr19092.so.abi: Adjust. * tests/data/test-annotate/test5.o.abi: Adjust. Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
|
95abd39b5d |
Improve self-comparison debug mode
When looking at debugging some self-comparison difference errors, I felt the need to improve the debugging support for self-comparison (triggered by 'abidw --debug-abidiff <binary>'). This patch fixes some typos in the existing diagnostics emitted by the self-comparison debugging mode and improves the detection of a change in a canonical type value between a type that is serialized to abixml, and the same type that is de-serialized from abixml. This later check is now performed during the process of handling canonical type propagation when confirming/canceling (speculatively) propagated canonical types. It's useful to find problems in that process of confirming/canceling. * include/abg-ir.h (environment::{get_type_id_canonical_type_map}): Const-ify the existing member function and add non-const overloads. (environment::{get_type_id_from_pointer, get_canonical_type_from_type_id}): Const-ify. (environment::get_pointer_type_id_map): Add new member function. * src/abg-ir-priv.h (environment::priv::{confirm_ct_propagation_for_types_dependant_on, confirm_ct_propagation}): Call check_abixml_canonical_type_propagation_during_self_comp() here. (environment::priv::{get_type_id_canonical_type_map, get_pointer_type_id_map, get_type_id_from_pointer, get_type_id_from_type, get_canonical_type_from_type_id, check_abixml_canonical_type_propagation_during_self_comp}): Add new member functions. * src/abg-ir.cc (return_comparison_result): Call check_abixml_canonical_type_propagation_during_self_comp on every single type with non confirmed propagated canonical type. (environment::{get_type_id_canonical_type_map, get_pointer_type_id_map, get_type_id_from_pointer, get_type_id_from_type, get_canonical_type_from_type_id}): Delegate to the new implementations that are now member functions of environment::priv. (type_base::get_canonical_type_for): Fix typo in diagnostics when debugging self-comparison. Add more context. * src/abg-reader.cc (abixml::reader::maybe_check_abixml_canonical_type_stability): Likewise. * src/abg-writer.cc (write_type_record): Do not try to get abixml type-id for a type (originating from the DWARF) that has no canonical type, otherwise, that /can/ introduce a gap in the type-ids as those can turn out not being emitted in the abixml after all. Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
|
43cbdd1501 |
ir: Recognize "void* as being equal to all other pointers in C
Today, the pointer-to-void type is naively considered as being different to all other pointers by Libabigail. This indirectly leads to spurious changes in code bases where we have this kind of pattern: /* in foo.h */ typedef void* some_pointer_type; struct foo { some_pointer_type member; }; bool test_some_pointer_type(some_pointer_type); /* This header file is included by client code */ /*in foo.c */ typedef int* some_pointer_type; struct foo { some_pointer_type member; }; bool test_some_pointer_type(some_pointer_type f) { /* The actual implementation. */ } Another way to reproduce that spurious change is to run this command: $ fedabipkgdiff --self-compare -a --from fc37 glibc * include/abg-fwd.h (is_void_pointer_type): Declare new function. * src/abg-ir.cc (is_void_pointer_type): Define new function. (equals): In the overload for pointer_type_def, handle the special case pointer to void, making it equal to all other pointer, for the C language. (is_non_canonicalized_type): pointer to void is no more canonicalized as it can be equal to all other types. * 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/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/test21-pr19092.so.abi: Likewise. * tests/data/test-annotate/test5.o.abi: Likewise. * tests/data/test-diff-filter/test31-pr18535-libstdc++-report-1.txt: Likewise. * tests/data/test-diff-filter/test47-filter-void-ptr-change-report-0.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/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/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/test5.o.abi: Likewise. * tests/data/test-read-dwarf/test5.o.hash.abi: Likewise. * tests/data/test-read-dwarf/test9-pr18818-clang.so.abi: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
|
5a6c04c8bd |
abipkgdiff: Don't use user-specific filesystem info in error msg
The recent patch "Bug rhbz#2182807 -- abipkgdiff crashes on missing debuginfo package" inadvertently introduced user-specific filesystem information in error messages, making tests/runtestdiffpkg be non-deterministic. Fixed thus. * tools/abipkgdiff.cc (get_pretty_printed_list_of_packages): Emit base names of packages, not the absolute filesystem path. * tests/data/test-diff-pkg/libxfce4ui-devel-4.12.1-8.fc27.ppc64-self-report-0.txt: Adjust. Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
|
fee06608fc |
dwarf-reader: Support Ada subranges having upper_bound < lower_bound
If the subrange's upper_bound is lower than its lower_bound, that means the subrange has a length of zero. This is Ada lingo. You can learn more about this at https://en.wikibooks.org/wiki/Ada_Programming/Types/array#Array_Attributes, for instance. This patch teaches the DWARF reader about this. * src/abg-dwarf-reader.cc (build_subrange_type): Be aware that the upper_bound can be lower than lower_bound.. This most likely means the length of the subrange is zero. * src/abg-ir.cc (array_type_def::subrange_type::get_length): If lower_bound > upper_bound, then length is zero. This is Ada lingo. * src/abg-writer.cc (write_array_subrange_type): Always emit lower_bound and upper_bound. Acknowledge that if lower_bound > upper_bound, it means length is zero. * tests/data/test-annotate/libtest24-drop-fns-2.so.abi: Adjust. * 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/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-annotate/test7.so.abi: Likewise. * tests/data/test-diff-dwarf-abixml/PR25409-librte_bus_dpaa.so.20.0.abi: Likewise. * tests/data/test-diff-dwarf-abixml/test0-pr19026-libvtkIOSQL-6.1.so.1-report-0.txt: Likewise. * tests/data/test-diff-dwarf-abixml/test0-pr19026-libvtkIOSQL-6.1.so.1.abi: Likewise. * tests/data/test-read-btf/test0.o.abi: Likewise. * tests/data/test-read-ctf/test-ambiguous-struct-A.o.hash.abi: Likewise. * tests/data/test-read-ctf/test-array-mdimension.abi: Likewise. * tests/data/test-read-ctf/test-array-of-pointers.abi: Likewise. * tests/data/test-read-ctf/test-array-size.abi: Likewise. * tests/data/test-read-ctf/test-const-array.abi: Likewise. * tests/data/test-read-ctf/test-dynamic-array.o.abi: Likewise. * tests/data/test-read-ctf/test0.abi: Likewise. * tests/data/test-read-ctf/test0.hash.abi: Likewise. * tests/data/test-read-ctf/test9.o.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/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/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/test7.so.abi: Likewise. * tests/data/test-read-dwarf/test7.so.hash.abi: Likewise. * tests/data/test-read-dwarf/test9-pr18818-clang.so.abi: Likewise. * tests/data/test-read-write/test25.xml: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
|
ed205e0e79 |
Bug rhbz#2182807 -- abipkgdiff crashes on missing debuginfo package
When abipkgdiff is called with a debug info package that references an alternate debug info file that is not found -- because debug info package is missing from the command line -- the program aborts. This is because the libabigail library is further invoked by the tool with debuginfo in an inconsistent state (missing alternate debug info). Note however that abipkgdiff only emits an explanatory message when invoked with the --verbose option. This patch teaches abipkgdiff to emit explanatory messages when an alternate debug info file is not found. The message suggests that the user adds the missing RPM package (which contains the alternate missing debuginfo file) to the command line using the --d1/--d2 switches. * src/abg-fe-iface.cc (status_to_diagnostic_string): Remove the newline from the end of the returned diagnostic string. * tools/abipkgdiff.cc (get_pretty_printed_list_of_packages) (emit_alt_debug_info_not_found_error): Define new static functions. (compare, compare_to_self): Add an ostream& parameter as a destination of diagnostic messages. If the abigail::fe_iface::STATUS_ALT_DEBUG_INFO_NOT_FOUND bit is set in the status code, emit the explanatory message to output stream associated to the current comparison task. Remove the previous handling of this case. (compare_task::maybe_emit_pretty_error_message_to_output): Define new member function to get the output stream associated to the current task massage it and stick to result into the pretty output string to be emitted to the user in the end, namely the compare_task::pretty_output string data member. ({compares, self_compare}_task::perform): Adjust this to call the new maybe_emit_pretty_error_message_to_output in case of error. * tests/data/test-diff-pkg/libxfce4ui-devel-4.12.1-8.fc27.ppc64-self-report-0.txt: Adjust. * tests/data/test-diff-pkg/test-dbus-glib-0.80-3.fc12.x86_64-report-0.txt: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
|
ddb6abd2d3 |
Fix redundancy filtering of range types
After the support for Ada range types was added, it appeared that redundancy propagation was not being correctly handled for range types, especially when those are sub-types of a function parameter type, like a const range. This patch goes through the various problematic spots and addresses the issues. * src/abg-comparison.cc (redundancy_marking_visitor::visit_end): Propagate redundancy category to function parameter diff nodes if they don't carry any local non-type change. * src/abg-default-reporter.cc (default_reporter::report_underlying_changes_of_qualified_type): Define new member function. (default_reporter::report): In the qualified_type_diff overload, use the new report_underlying_changes_of_qualified_type above. * src/abg-ir.cc (types_have_similar_structure): If two arrays are accessed indirectly and if they have size and dimension changes, then the two arrays are considered having a similar structure. Otherwise, if they are accessed directly, having size or dimension change make them considered as having non similar structure. This has an impact on if a change between two array types is considered local or not. * src/abg-leaf-reporter.cc (leaf_reporter::report): Local changes to underlying types of a qualified type are considered local to the qualified type. This change reflects that in the overload for qualified type diff nodes. Otherwise, we won't report what would otherwise be a leaf change to the a qualified type, just because it's actually a leaf change to the underlying type of the qualified type. * tests/data/test-abidiff-exit/ada-subrange/test2-ada-subrange-redundant/test2-ada-subrange-redundant-report-{1,2}.txt: New reference output files. * tests/data/test-abidiff-exit/ada-subrange/test2-ada-subrange-redundant/v0/test.ad{b,s}: Source code for the new binary input below. * tests/data/test-abidiff-exit/ada-subrange/test2-ada-subrange-redundant/v0/test.o: New binary input file. * tests/data/test-abidiff-exit/ada-subrange/test2-ada-subrange-redundant/v1/test.ad{b,s}: Source code for the new binary input below. * tests/data/test-abidiff-exit/ada-subrange/test2-ada-subrange-redundant/v1/test.o: New binary input file. * tests/data/Makefile.am: Add the new test input files above to source distribution. * tests/test-abidiff-exit.cc (in_out_specs): Add the new input tests above to this test harness. * tests/data/test-diff-filter/libtest45-basic-type-change-report-1.txt: Adjust. Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
|
7535d74c3c |
Bug 29340 - Add support for Ada range types
Libabigail doesn't yet support generic range types like in Ada. Ranges are supported as a kind of implementation detail of array types. But then its use like in the construct below is not supported: type My_Int is range 0 .. 5; function My_Function return My_Int; Here, the integer type "My_Int" can take the discrete values that go from 0 to 5. It's represented in the DWARF debug info as being a range type of length 6 and whose underlying type has a size of 8 bits. This patch adds support for a range type to be (de-)serialized from and to abixml, diffed, diff-analyzed and diff-reported. The ABIXML version number has been bumped from 2.1 to 2.2 accordingly. * configure.ac: Bump the abixml version to 2.2 from 2.1 * include/abg-comparison.h (diff_maps::get_subrange_diff_map): Declare new member functions. (class subrange_diff): Define new class. (subrange_diff_sptr): Define new typedef. (compute_diff): New overload for subrange_diff. (is_subrange_diff): Declare new function. * include/abg-ir.h (equals): Declare an overload for subrange_type. * include/abg-reporter.h (reporter_base::report): Declare an overload for subrange_diff. (default_reporter::report_underlying_changes_of_qualified_type): Declare member function. (leaf_reporter::report): Declare and overload for subrange_diff. Declare new member function. * include/abg-tools-utils.h (get_anonymous_subrange_internal_name_prefix): Declare new function. * src/abg-comparison-priv.h (struct subrange_diff::priv): Define new type. * src/abg-comparison.cc (diff_maps::priv::subrange_diff_map_): Define data member. (diff_maps::get_subrange_diff_map): Define member function. (is_subrange_diff, compute_diff): Define new functions. (compute_diff_for_types): Handle array_type::subrange_type types. (subrange_diff::{subrange_diff, first_subrange, second_subrange, get_pretty_representation, has_changes, has_local_changes, report, chain_into_hierarchy}): Define member functions. (diff_maps::insert_diff_node): Handle subrange diff nodes. (corpus_diff::priv::count_leaf_type_changes): Count subranges diff nodes. * src/abg-default-reporter.cc (default_reporter::report): Define an overload for subrange_diff. * src/abg-ir.cc (has_generic_anonymous_internal_type_name): Support subrange types. * src/abg-leaf-reporter.cc (report_type_changes_from_diff_maps): Report about subrange types. (leaf_reporter::report): Define and overload for subrange_diff nodes. * src/abg-reader.cc (build_subrange_type): Add a boolean to add the subrange type to the current scope. (build_array_type_def): Adjust when calling build_subrange_type. (build_type): Support building subrange types. * src/abg-reporter-priv.cc (represent): Define a new overload for the subrange_diff type. * src/abg-reporter-priv.h (represent): Declare a new overload for the subrange_diff type. * src/abg-tools-utils.cc (ANONYMOUS_SUBRANGE_INTERNAL_NAME) (ANONYMOUS_SUBRANGE_INTERNAL_NAME_LEN): Define new static const variables. (get_anonymous_subrange_internal_name_prefix): Define new function. * src/abg-writer.cc (write_array_subrange_type): Define new static function. (write_decl): Support emitting subrange_types. * tests/data/test-abidiff-exit/ada-subrange/test1-ada-subrange/test1-ada-subrange-report-1.txt: New reference output. * tests/data/test-abidiff-exit/ada-subrange/test1-ada-subrange/test1-ada-subrange-report-2.txt: Likewise. * tests/data/test-abidiff-exit/ada-subrange/test1-ada-subrange/v0/test1.ad{b,s}: Source code of the input binary below. * tests/data/test-abidiff-exit/ada-subrange/test1-ada-subrange/v0/test1.o: New input test. * tests/data/test-abidiff-exit/ada-subrange/test1-ada-subrange/v1/test1.ad{b,s}: Source code of the input binary below. * tests/data/test-abidiff-exit/ada-subrange/test1-ada-subrange/v1/test1.o: New input test. * tests/data/Makefile.am: Add the new test files to source distributions. * tests/test-abidiff-exit.cc (in_out_specs): Add the new tests input above to this test harness. * tests/data/test-annotate/PR29443-missing-xx.o.annotated.abi: 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/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/test4.so.abi: Likewise. * tests/data/test-annotate/test5.o.abi: Likewise. * tests/data/test-annotate/test6.so.abi: Likewise. * tests/data/test-annotate/test7.so.abi: Likewise. * tests/data/test-annotate/test8-qualified-this-pointer.so.abi: Likewise. * tests/data/test-read-btf/test0.o.abi: Likewise. * tests/data/test-read-btf/test1.o.abi: Likewise. * tests/data/test-read-ctf/PR27700/test-PR27700.abi: Likewise. * tests/data/test-read-ctf/test-PR26568-1.o.abi: Likewise. * tests/data/test-read-ctf/test-PR26568-2.o.abi: Likewise. * tests/data/test-read-ctf/test-alias.o.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-anonymous-fields.o.abi: Likewise. * tests/data/test-read-ctf/test-array-mdimension.abi: Likewise. * tests/data/test-read-ctf/test-array-of-pointers.abi: Likewise. * tests/data/test-read-ctf/test-array-size.abi: Likewise. * tests/data/test-read-ctf/test-bitfield-enum.abi: Likewise. * tests/data/test-read-ctf/test-bitfield.abi: Likewise. * tests/data/test-read-ctf/test-callback.abi: Likewise. * tests/data/test-read-ctf/test-callback2.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-const-array.abi: Likewise. * tests/data/test-read-ctf/test-dynamic-array.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-enum.o.abi: Likewise. * tests/data/test-read-ctf/test-fallback.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-linux-module.abi: Likewise. * tests/data/test-read-ctf/test-list-struct.abi: Likewise. * tests/data/test-read-ctf/test0.abi: Likewise. * tests/data/test-read-ctf/test0.hash.abi: Likewise. * tests/data/test-read-ctf/test1.so.abi: Likewise. * tests/data/test-read-ctf/test1.so.hash.abi: Likewise. * tests/data/test-read-ctf/test2.so.abi: Likewise. * tests/data/test-read-ctf/test2.so.hash.abi: Likewise. * tests/data/test-read-ctf/test3.so.abi: Likewise. * tests/data/test-read-ctf/test3.so.hash.abi: Likewise. * tests/data/test-read-ctf/test4.so.abi: Likewise. * tests/data/test-read-ctf/test4.so.hash.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/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/PR28584/PR28584-smv.clang.o.abi: Likewise. * tests/data/test-read-dwarf/PR29443-missing-xx.o.abi: Likewise. * tests/data/test-read-dwarf/PR29692-kdelibs3-libkjava.so.1.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-PR26568-1.o.abi: Likewise. * tests/data/test-read-dwarf/test-PR26568-2.o.abi: Likewise. * tests/data/test-read-dwarf/test-fallback.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-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> |
||
|
e2040f2838 |
Bug 29686 - Fix testing the presence of anonymous data member in a struct
* include/abg-fwd.h (anonymous_data_member_to_class_or_union): Add a new overload. (anonymous_data_member_exists_in_class): Declare new function. * src/abg-dwarf-reader.cc (add_or_update_class_type): Use the new anonymous_data_member_exists_in_class function. * src/abg-ir.cc (anonymous_data_member_to_class_or_union): Define new function. * tests/data/test-read-dwarf/test-libandroid.so.abi: Adjust. Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
|
6641e71a03 |
Bug 29692 - Support binaries with empty symbol table
Some binaries can have a symbol table in which no symbol is actually defined and exported. That binary would thus have an empty ABI corpus. Interestingly, Libabigail's DWARF reader is emits an error when it encounters such binaries. This patch adds the support for those binaries. * src/abg-dwarf-reader.cc (reader::read_debug_info_into_corpus): Get out early also upon having an empty symbol table. * src/abg-elf-reader.cc (reader::read_corpus): Error out only if there is no symbol table for the binary. If an empty symbol table is found however, that is not an error. * tests/data/test-read-dwarf/PR29692-kdelibs3-libkjava.so.1.0.0: New binary test input. * tests/data/test-read-dwarf/PR29692-kdelibs3-libkjava.so.1.0.0.abi: New expected abixml file. * tests/data/Makefile.am: Add the new input test files to source distribution. * tests/test-read-dwarf.cc (in_out_specs): Add the new test inputs above to this test harness. Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
|
aab0bc10bc |
comparison, suppression: Support [allow_type] directive
This patch adds support for a new 'allow_type' suppression directive. It suppresses all the changes that are NOT matched by the directive. In other words, this directive determines the set of type changes that are NOT suppressed. Any other change is suppressed. This thus called a "negated suppression directive". The way these negated suppression directives interact with the direct suppression directives that already exist is the following. The suppression evaluation pass visits every single diff node (carrying a type change) of the diff graph. Negated suppressions are evaluated first, in order of occurrence. There are thus, two alternatives: 1/ At least one negated suppression matches the current diff node. or 2/ No negated suppression matches the current diff node. In case of 1/ then direct suppression specifications are considered. There are two alternatives: 1.1/ At least one direct suppression matches the current diff node. The diff node is suppressed: categorized as being in the SUPPRESSED_CATEGORY category) or 1.2/ No direct suppression matches the current diff node. The diff node is not suppressed: categorized as being in the HAS_ALLOWED_CHANGE_CATEGORY category. In case of 2/ then direct suppression specifications are considered. There are two alternatives: 2.1 At least one direct suppression matches the current diff node. The diff node is categorized as being in the SUPPRESSED_CATEGORY category, just like in 1.1. 2.2 No direct suppression matches the current diff node. The diff node is not suppressed and not categorized. As a result of the category propagation pass, a node which has a parent node categorized as HAS_ALLOWED_CHANGE_CATEGORY is itself categorized as HAS_PARENT_WITH_ALLOWED_CHANGE_CATEGORY. A node which has a descendant categorized as HAS_ALLOWED_CHANGE_CATEGORY will itself be categorized as HAS_DESCENDANT_WITH_ALLOWED_CHANGE_CATEGORY. Nodes that are categorized as HAS_ALLOWED_CHANGE_CATEGORY, HAS_DESCENDANT_WITH_ALLOWED_CHANGE_CATEGORY and HAS_PARENT_WITH_ALLOWED_CHANGE_CATEGORY are not suppressed by the reporting passes. This is needed for the reporting passes to emit the impact sub-tree up to the diff node which carry the change that was actually categorized as HAS_ALLOWED_CHANGE_CATEGORY. * include/abg-comparison.h: Include abg-suppression.h (diff, diff_context, diff_sptr, diff_context_sptr): Remove these forward decls from here. (enum diff_category::{HAS_ALLOWED_CHANGE_CATEGORY, HAS_DESCENDANT_WITH_ALLOWED_CHANGE_CATEGORY, HAS_PARENT_WITH_ALLOWED_CHANGE_CATEGORY}): Add new enumerators. (enum diff_category::EVERYTHING_CATEGORY): Update enumerator. (diff_context::{negated_suppressions, direct_suppressions}): Declare new member functions. (diff_context::suppressions): Add overload. (diff::{is_filtered_out_without_looking_at_allowed_changes, is_allowed_by_specific_negated_suppression, has_descendant_allowed_by_specific_negated_suppression, has_parent_allowed_by_specific_negated_suppression}): Declare new member functions. * include/abg-suppression.h (class negated_suppression_base, class negated_type_suppression): Declare new classes. (negated_suppression_sptr, negated_suppression_type): Define new typedefs. (is_negated_suppression): Declare new functions. * src/abg-suppression.cc (negated_suppression_base::{negated_suppression_base, ~negated_suppression_base}): Define member functions. (negated_type_suppression::{negated_type_suppression, suppresses_diff, ~negated_type_suppression}): Likewise. (is_negated_suppression): Define functions. (read_type_suppression): Allow parsing the "allow_type" directive and instantiate a negated_type_suppression. * src/abg-comparison-priv.h (diff_context::priv::{negated_suppression_type_, direct_suppressions}): Define new data members. (diff::priv::is_filtered_out): A node categorized as HAS_DESCENDANT_ALLOWED_BY_SPECIFIC_NEGATED_SUPPRESSION, HAS_PARENT_ALLOWED_BY_SPECIFIC_NEGATED_SUPPRESSION and HAS_ALLOWED_CHANGE_CATEGORY is not filtered out. * src/abg-comparison.cc (diff_context::suppressions): Add a non-const overload. (diff_context::{negated,direct}_suppressions): Define new member function. (diff_context::add_suppression): Invalidate the cache data members diff_context::priv::{negated,direct}_suppressions_. (diff::is_filtered_out): A node categorized as HAS_DESCENDANT_ALLOWED_BY_SPECIFIC_NEGATED_SUPPRESSION, HAS_PARENT_ALLOWED_BY_SPECIFIC_NEGATED_SUPPRESSION and HAS_ALLOWED_CHANGE_CATEGORY is not filtered out. (diff::is_filtered_out_without_looking_at_allowed_changes): Define new member function. (diff::is_suppressed): If there is at least one negated suppression that match the diff node, then it's not suppressed, unless it's matched by a direct suppression. (diff::{is_allowed_by_specific_negated_suppression, has_descendant_allowed_by_specific_negated_suppression, has_parent_allowed_by_specific_negated_suppression}): Define new member functions. (operator<<(ostream& o, diff_category c)): Serialize HAS_{DESCENDANT_WITH,PARENT_WITH}_ALLOWED_CHANGE_CATEGORY enumerators. (category_propagation_visitor::visit_end): Do not propagate HAS_ALLOWED_CHANGE_CATEGORY, HAS_DESCENDANT_WITH_ALLOWED_CHANGE_CATEGORY and HAS_PARENT_WITH_ALLOWED_CHANGE_CATEGORY categories. (suppression_categorization_visitor::visit_begin): Categorize a node that is not suppressed by a direct suppression and is suppressed by a negated one as HAS_ALLOWED_CHANGE_CATEGORY. Propagate it to descendant nodes as HAS_PARENT_WITH_ALLOWED_CHANGE_CATEGORY ... (suppression_categorization_visitor::visit_end): ... and to parent node as HAS_DESCENDANT_WITH_ALLOWED_CHANGE_CATEGORY. * src/abg-default-reporter.cc (default::reporter): In the overload for typedef_diff, qualified_type_diff, reference_diff, fn_parm_diff, function_type_diff, array_diff, base_diff, function_decl_diff, report local changes only on node that are not filtered out wrt allowed changed. * tests/data/test-abidiff-exit/test-allow-type-array-suppr.txt: New test input. * tests/data/test-abidiff-exit/test-allow-type-array-v0--v1-report-{1,2}.txt: Likewise. * tests/data/test-abidiff-exit/test-allow-type-array-v0--v2-report-{1,2}.txt: Likewise. * tests/data/test-abidiff-exit/test-allow-type-array-v0--v3-report-{1,2}.txt: Likewise. * tests/data/test-abidiff-exit/test-allow-type-array-v{0,1,2,3}.c: Source code of new binary test inputs. * tests/data/test-abidiff-exit/test-allow-type-array-v{0,1,2,3}.o: New binary test inputs. * tests/data/test-abidiff-exit/test-allow-type-region-suppr.txt: New test input. * tests/data/test-abidiff-exit/test-allow-type-region-v0--v1-report-{1,2}.txt: * tests/data/test-abidiff-exit/test-allow-type-region-v0--v2-report-{1,2}.txt: Likewise. * tests/data/test-abidiff-exit/test-allow-type-region-v0--v3-report-{1,2}.txt: Likewise. * tests/data/test-abidiff-exit/test-allow-type-region-v0--v4-report-{1,2}.txt: Likewise. * tests/data/test-abidiff-exit/test-allow-type-region-v0--v5-report-{1,2}.txt: Likewise. * tests/data/test-abidiff-exit/test-allow-type-region-v{0,1,2,3,4,5}.c: Source code of new binary test input. * tests/data/test-abidiff-exit/test-allow-type-region-v{0,1,2,3,4,5}.o: New binary test inputs. * tests/data/test-abidiff-exit/test-allow-type-suppr{1,2}.txt: New test inputs. * tests/data/Makefile.am: Add the new testing files above to source distribution. Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
|
b4fb1fb539 |
suppression: Support offset_of_{first,last}_data_member_regexp offset selectors
This patch adds support for two data member offset selector expressions for properties of the [suppress_type] directive: offset_of_first_data_member_regexp() and offset_of_last_data_member_regexp(). These function-call expressions take a regular expression argument and evaluate to the offset of the first (resp. last) data member matching the regular expression argument. An example of their use would be be: [suppress_type] type_kind = struct has_data_member_inserted_between = { offset_of_first_data_member_regexp(^__special_padding_space), offset_of_last_data_member_regexp(^__special_padding_space) } This would be useful to suppress change reports involving a struct which has "padding" data members added on-purpose like: struct S { int member0; char member1; unsigned __special_padding_space1; unsigned __special_padding_space2; unsigned __special_padding_space3; }; * doc/manuals/libabigail-concepts.rst: Document the new properties. * include/abg-fwd.h: Forward declare comparison::{diff_context, diff_context_sptr, diff_context_wptr, diff, diff_wptr} and regex::regex_t_sptr. (find_first_data_member_matching_regexp) (find_last_data_member_matching_regexp): Declare new functions. * include/abg-suppression.h: Inject std::{string, shared_ptr, vector} and comparison::{diff, diff_context_sptr} into the suppr namespace. Remove the "abg-comparison.h" header. * src/abg-elf-helpers.cc: Include sstream. * src/abg-ir.cc (find_first_data_member_matching_regexp) (find_last_data_member_matching_regexp): Define new functions. * src/abg-suppression.cc (type_suppression::insertion_range::eval_boundary): Support evaluating "offset_of_first_data_member_regexp" and "offset_of_first_data_member_regexp". * src/abg-ctf-reader.cc: Include sstream. * tests/data/test-diff-suppr/test-has-data-member-inserted-between-1-report-[1-4].txt: New test reference outputs. * tests/data/test-diff-suppr/test-has-data-member-inserted-between-1-v[0-4].c: Source code of new test input. * tests/data/test-diff-suppr/test-has-data-member-inserted-between-1-v[0-4].o: New binary test input. * tests/data/test-diff-suppr/test-has-data-member-inserted-between-1.suppr: New suppression specification. * tests/data/Makefile.am: Add the new test input files to source distribution. * tests/test-diff-suppr.cc (in_out_specs): Add the new test input to this test harness. Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
|
e68701e7ea |
suppression: Support the has_size_change property for suppress_type
The "has_data_member_inserted_between" and "has_data_members_inserted_between" properties of the [suppress_type] directive allows the suppression of type changes when a data member is inserted in a given range. It turns out that suppressing type changes that incur a change in the size of the type might not be what the user wants by default, because the type size in itself might actually be an incompatible ABI change that would then fly under the radar because of this suppression specification. An arguably better default behavior in this case would be to NOT suppress the type change if the data member insertion does incur a change in the size of the type. But then, there would be cases where the user would really want to suppress the type change due to data member insertion in a given range even if it incurs a change in the type size. This is where this patch enters into play. The patch introduces the "has_size_change" property of the [suppress_type] directive. In the presence of "has_data_members_inserted_between" or "has_data_member_inserted_between" properties, if the "has_size_change" property is set to "yes", then the type change would be suppressed if data members are inserted in the given range even if the insertion incurs a type size change. Otherwise, with this patch, in the absence of the "has_size_change" property, the "has_data_member_inserted_between" and "has_data_members_inserted_between" properties won't trigger the type change suppression if the data member insertion incurs a type size change. * doc/manuals/libabigail-concepts.rst: Document the new has_size_change property. * include/abg-suppression.h (type_suppression::{g,s}et_has_size_change): Declare new accessors. * src/abg-suppression-priv.h (type_suppression::priv::has_size_change_): Define new data member. (type_suppression::priv::priv): Initialize the new data member. * src/abg-suppression.cc (type_suppression::{g,s}et_has_size_change): Define new accessors. (type_suppression::suppresses_diff): Make the has_data_member_inserted_* clauses have effect only if the class size hasn't changed, unless the class has as the "has_size_change" property. Also, allow members to be deleted in the right insertion range if the resulting size stays the same or if the has_size_change property is present. This allows some custom behaviours where "padding" data members would be removed while some new data members would be added, resulting in a type which size would not change. (read_type_suppression): Support parsing the "has_size_change" property. * tests/data/test-diff-suppr/test11-add-data-member-0.1.suppr: New test suppression specification. * tests/data/test-diff-suppr/test11-add-data-member-1.1.suppr: Likewise. * tests/data/test-diff-suppr/test11-add-data-member-2.1.suppr: Likewise. * tests/data/test-diff-suppr/test11-add-data-member-3.1.suppr: Likewise. * tests/data/test-diff-suppr/test11-add-data-member-4.1.suppr: Likewise. * tests/data/test-diff-suppr/test11-add-data-member-report-1.1.txt: Likewise. * tests/data/test-diff-suppr/test12-add-data-member-0.1.suppr: Likewise. * tests/data/test-diff-suppr/test12-add-data-member-report-1.1.txt: New test reference output. * tests/data/test-diff-suppr/test13-suppr-through-pointer-0.1.suppr: New test suppression specification. * tests/data/test-diff-suppr/test13-suppr-through-pointer-report-1.1.txt: New test reference output. * tests/data/test-diff-suppr/test35-leaf-report-0.1.txt: Likewise. * tests/data/test-diff-suppr/test35-leaf.1.suppr: New test suppression specification. * tests/data/Makefile.am: Add the new testing material to source distribution. * tests/data/test-diff-suppr/test11-add-data-member-1.suppr: Add the has_size_change property to explicitly allow suppressing type changes involving data member insertion even when the type size changes. * tests/data/test-diff-suppr/test11-add-data-member-0.suppr: Likewise. * tests/data/test-diff-suppr/test11-add-data-member-2.suppr: Likewise. * tests/data/test-diff-suppr/test11-add-data-member-3.suppr: Likewise. * tests/data/test-diff-suppr/test11-add-data-member-4.suppr: Likewise. * tests/data/test-diff-suppr/test12-add-data-member-0.suppr: Likewise. * tests/data/test-diff-suppr/test13-suppr-through-pointer-0.suppr: Likewise. * tests/data/test-diff-suppr/test35-leaf.suppr: Likewise. * tests/test-diff-suppr.cc (in_out_specs): Add the new test input to the test harness. Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
|
153b37a164 |
suppr: Support has_data_member and has_data_member_regexp properties
In the [supress_type] directive, this patch adds support for two new properties: * has_data_data_member = {foo, bar, blah} Suppresses change reports involving a type which has data members with names specified by the value of this property. * has_data_member_regexp = some-regexp Suppresses change reports involving a type which has data members with names specified by the regular expression given as a value of this property. * include/abg-fwd.h (string_set_type): Define new typedef. * src/abg-suppression-priv.h * include/abg-suppression.h (type_suppression::{get,set}_potential_data_member_names[_regex_str]): Declare new data member. (type_suppression::priv::{potential_data_members_, potential_data_members_regex_str_, potential_data_members_regex_}): Define new data members. (type_suppression::priv::{get,set}_potential_data_member_names_regex): Define new member functions. * src/abg-suppression.cc (type_suppression::{get,set}_potential_data_member_names): Define new member functions. (type_suppression::{get,set}_potential_data_member_names_regex_str): Likewise. (type_suppression::suppresses_diff): Implement suppression using the new "has_data_member" and "has_data_member_regexp" properties. (read_type_suppression): Support parsing the new "has_data_member" and "has_data_member_regexp" properties of the type suppression directive. * tests/data/test-diff-suppr/has-data-member-[1-7].suppr: New suppression specifications for test purposes. * tests/data/test-diff-suppr/test-has-data-member-output-{1,2}.txt: New reference test outputs. * tests/data/test-diff-suppr/test-has-data-member-v{0,1}.cc: Source code of new input binary tests. * tests/data/test-diff-suppr/test-has-data-member-v{0,1}.o: New binary test inputs. * tests/data/Makefile.am: Add the test inputs below to source distribution. * tests/test-diff-suppr.cc (in_out_specs): Add the new test inputs above to this test harness. Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
|
03d8b52fc7 |
PR30048 - wrong pretty representation of qualified pointers
A qualified type is textually represented as the following: <qualifier> <underlying-type> were "qualifier" is the qualifier carried by the qualified type and "underlying-type" is the type being qualified. In this case, the qualifier prefixes the textual representation of the qualified type. This is true if the underlying type of the qualified type is a non-const, non-reference type. For instance: const int; But when the underlying type is a pointer, then the qualified type is represented as: int* const; In that later case, the qualifier comes /after/ the textual representation of the underlying type. Now suppose the underlying type is itself a qualified type. In that case, for a non-const underlying type, we'd have, e.g: const volatile int; where the qualifier precedes the qualified type (which is itself a qualified type) /IF/ the ultimate underlying type (a.k.a the leaf underlying type) is itself a non-const, non-reference type. But if the ultimate underlying type is a pointer, a qualified type with an underlying qualified type would be textually represented as, e.g: int* const volatile; In other words, if the leaf type is a pointer, the qualifier suffixes the textual representation the underlying qualified type. Libabigail is failing to apply this later rule. As the type name is used as a key to cache IR nodes of DIEs (among other things), getting it wrong can lead to a bumpy ride down the road. Fixed thus. * src/abg-dwarf-reader.cc (die_is_pointer_array_or_reference_type): Rename die_is_pointer_or_reference_type into this. This new name reflects more what the function does as it tests if a DIE is for pointer, an array or a reference. (pointer_or_qual_die_of_anonymous_class_type): Adjust to use the newly (and better) named die_is_pointer_array_or_reference_type. (die_is_pointer_or_reference_type): Make this really test if a DIE is for a pointer or a reference. Now the name matches what the function does. (die_peel_qualified): Define new function. (die_qualified_type_name): When a qualified name Q has another qualified name as its underlying type, it's important to know if the leaf type is a pointer type or not to know how to construct the name of Q. This change now peels the potential qualifiers from the underlying type of the qualified type to see if the leaf type is a pointer or not. * src/abg-ir.cc (get_name_of_qualified_type): Likewise. Also, the name of array types doesn't follow the same rule as for pointers and references. * tests/data/test-abidiff-exit/PR30048-test-report-0.txt: Add new reference test output. * tests/data/test-abidiff-exit/PR30048-test-2-report-1.txt: Likewise. * tests/data/test-abidiff-exit/PR30048-test-v{0,1}.c: Add source code of binary input data. * tests/data/test-abidiff-exit/PR30048-test-2-v{0,1}.cc: Likewise. * tests/data/test-abidiff-exit/PR30048-test-v{0,1}.o: Add binary input data. * tests/data/test-abidiff-exit/PR30048-test-2-v{0,1}.o: Likewise. * tests/data/Makefile.am: Add the new test material above to source distribution. * tests/test-abidiff-exit.cc (in_out_specs): Add the input binaries to this test harness. * tests/data/test-abidiff-exit/qualifier-typedef-array-report-1.txt: Adjust. Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
|
82973c898a |
default-reporter: Fix source location in functions change report
While looking at something else, I realized that the default-reporter mentions the source location of the new function in lieu of the old function when reporting about a function change. Fixed thus. * src/abg-default-reporter.cc (default_reporter::report): In the overload of function_decl, use the source location of the old function. * tests/data/test-abicompat/test0-fn-changed-report-2.txt: Adjust. * tests/data/test-abidiff-exit/qualifier-typedef-array-report-1.txt: Likewise. * tests/data/test-abidiff-exit/test-PR28316-report.txt: Likewise. * tests/data/test-abidiff-exit/test-decl-enum-report.txt: Likewise. * tests/data/test-abidiff-exit/test-decl-struct-report.txt: Likewise. * tests/data/test-abidiff-exit/test-fun-param-report.txt: Likewise. * tests/data/test-abidiff-exit/test-headers-dirs/test-headers-dir-report-2.txt: Likewise. * tests/data/test-abidiff-exit/test-loc-with-locs-report.txt: Likewise. * tests/data/test-abidiff-exit/test-member-size-report0.txt: Likewise. * tests/data/test-abidiff-exit/test-rhbz2114909-report-1.txt: Likewise. * tests/data/test-diff-filter/libtest45-basic-type-change-report-0.txt: Likewise. * tests/data/test-diff-filter/test-PR24731-report-1.txt: Likewise. * tests/data/test-diff-filter/test-PR25661-1-report-2.txt: Likewise. * tests/data/test-diff-filter/test-PR25661-2-report-2.txt: Likewise. * tests/data/test-diff-filter/test-PR25661-3-report-2.txt: Likewise. * tests/data/test-diff-filter/test-PR25661-4-report-2.txt: Likewise. * tests/data/test-diff-filter/test-PR25661-5-report-2.txt: Likewise. * tests/data/test-diff-filter/test-PR25661-6-report-3.txt: Likewise. * tests/data/test-diff-filter/test-PR25661-7-report-3.txt: Likewise. * tests/data/test-diff-filter/test-PR26739-2-report-0.txt: Likewise. * tests/data/test-diff-filter/test-PR29387-report.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-1.txt: Likewise. * tests/data/test-diff-filter/test36-report-0.txt: Likewise. * tests/data/test-diff-filter/test37-report-0.txt: Likewise. * tests/data/test-diff-filter/test39/test39-report-0.txt: Likewise. * tests/data/test-diff-filter/test41-report-0.txt: Likewise. * tests/data/test-diff-filter/test44-anonymous-data-member-report-0.txt: Likewise. * tests/data/test-diff-pkg/dirpkg-3-report-2.txt: Likewise. * tests/data/test-diff-pkg/libICE-1.0.6-1.el6.x86_64.rpm--libICE-1.0.9-2.el7.x86_64.rpm-report-0.txt: Likewise. * tests/data/test-diff-pkg/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/symlink-dir-test1-report0.txt: Likewise. * tests/data/test-diff-pkg/tarpkg-1-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/PR28073/PR28073-output-2.txt: Likewise. * tests/data/test-diff-suppr/libtest48-soname-abixml-report-1.txt: Likewise. * tests/data/test-diff-suppr/test30-report-0.txt: Likewise. * tests/data/test-diff-suppr/test41-enumerator-changes-report-0.txt: Likewise. * tests/data/test-diff-suppr/test42-negative-suppr-type-report-0.txt: Likewise. * tests/data/test-diff-suppr/test42-negative-suppr-type-report-1.txt: Likewise. * tests/data/test-diff-suppr/test6-fn-suppr-report-0-1.txt: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
|
12641b1130 |
Add support for BTF
This adds support for the BTF debug information format. It provides a new BTF front-end which can be instantiated by the function tools::create_best_elf_based_reader(). For now, the BTF front-end supports the basic types (integers, pointers, qualified types, typedefs, struct and unions and function pointers) for functions and variables as emitted for the C language by GCC. It seems to be able to support the BTF debug information emitted for the vmlinux kernel by the pahole tool as well. When configured with the --enable-btf option, the WITH_BTF pre-processor macro is defined, enabling the BTF support. That option is turned on by default if the /usr/include/bpf/btf.h header is found on the system. To disable this, one can use the --disable-btf option. The abidw and abidiff programs have been adapted to use the BTF front-end when provided with the '--btf' option, or if BTF debug information is the only one present in the binary. * configure.ac: If the header /usr/include/bpf/btf.h exists, then define the WITH_BTF pre-processor macro, unless --disable-btf was provided. * doc/manuals/abidiff.rst: Document the new --btf option. * doc/manuals/abidw.rst: Likewise. * doc/manuals/kmidiff.rst: Likewise. * doc/manuals/abipkgdiff.rst: Likewise. * include/abg-btf-reader.h: New header file. Contains the declaration of the new btf::reader class. * src/abg-btf-reader.cc: New source file. Contains the definitions of the new btf::reader class. * include/Makefile.am: Add the new include/abg-btf-reader.h header file to source distribution. * include/abg-corpus.h (enum origin): Add a new BTF_ORIGIN enumerator. * include/abg-tools-utils.h (file_has_btf_debug_info): Declare new function. * src/abg-tools-utils.cc (file_has_btf_debug_info): Define new function. (create_best_elf_based_reader): Adapt to support BTF input. If the user requested the BTF front-end, instantiate it. Otherwise, if the input file has only BTF debug info, instantiate the BTF front end. * include/abg-elf-reader.h (elf::reader::find_btf_section): Declare new member function. (elf::reader::{function, variable}_symbol_is_exported): Add new overloads. * src/abg-elf-reader.cc (reader::priv::btf_section): New data member. (reader::find_btf_section): Define new member function. * src/Makefile.am: Add the new abg-ctf-reader.cc file to source distribution. * tools/abidw.cc (options::use_btf): New data member. (display_usage): Add a help string for the new --btf option. (parse_command_line): Support the new --btf option. (load_corpus_and_write_abixml): If the user asked to use the btf front-end then use that one. * tools/abidiff.cc (options::use_btf): New data member. (options::options): Initialize it. (display_usage):: Add a help string to the new --btf options. (parse_command_line): Support the new --btf options. (main): If the user asked to use the btf front-end, then use that one. * tools/abidw.cc (options::use_btf): New data member. (options::options): Initialize it. (parse_command_line): Add a help string to the new --btf options. (load_corpus_and_write_abixml): If the user asked to use the btf front-end, then use that one. * tools/kmidiff.cc (options::use_btf): New data member. (options::options): Initialize it. (display_usage): Add a help string to the new --btf options. (parse_command_line): Add a help string to the new --btf options. (main): If the user asked to use the btf front-end, then use that one. * tools/abipkgdiff.cc (options::use_btf): New data member. (options::options): Initialize it. (display_usage): Add a help string to the new --btf options. (parse_command_line): Add a help string to the new --btf options. (compare, compare_to_self) (compare_prepared_linux_kernel_packages): If the user asked to use the btf front-end, then use that one. * tests/data/test-read-btf/test{0,1}.o: New binary test input file. * tests/data/test-read-btf/test{0,1}.c: Source code of the binary input file above. * tests/data/test-read-btf/test{0,1}.o.abi: Reference ABIXML output. * tests/data/test-abidiff-exit/btf/test0-report-{1,2}.txt: New test reference output. * tests/data/test-abidiff-exit/btf/test0-v{0,1}.o: New binary test input. * tests/data/test-abidiff-exit/btf/test0-v{0,1}.c: The source files of the binary inputs above. * tests/test-read-btf.cc: New test file to run the btf/abixml tests. * tests/Makefile.am: Add the new test files to the source distribution. Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
|
e02d3b85e3 |
Bug 29811 - Better categorize harmless unknown array size changes
Let's compile the code snippet: $ echo "unsigned int is_basic_table[];" | gcc -g -c -o test-v0.o -x c - Let's see what abidw sees from it: $ abidw test-v0.o | cat -n 1 <abi-corpus version='2.1' path='test-v0.o' architecture='elf-amd-x86_64'> 2 <elf-variable-symbols> 3 <elf-symbol name='is_basic_table' size='4' type='object-type' binding='global-binding' visibility='default-visibility' is-defined='yes'/> 4 </elf-variable-symbols> 5 <abi-instr address-size='64' path='<stdin>' comp-dir-path='/home/dodji/git/libabigail/PR29811/prtests' language='LANG_C11'> 6 <type-decl name='unsigned int' size-in-bits='32' id='type-id-1'/> 7 <array-type-def dimensions='1' type-id='type-id-1' size-in-bits='infinite' id='type-id-2'> 8 <subrange length='infinite' id='type-id-3'/> 9 </array-type-def> 10 <var-decl name='is_basic_table' type-id='type-id-2' mangled-name='is_basic_table' visibility='default' filepath='/home/dodji/git/libabigail/PR29811/prtests/<stdin>' line='1' column='1' elf-symbol-id='is_basic_table'/> 11 </abi-instr> 12 </abi-corpus> See how the at line 7, the array type of ID 'type-id-2' has an unknown size. This is the type of the 'is_basic_table' variable defined at line 10. Note however that the symbol size of the is_basic_table symbol is 4 bytes (32 bits). Now, let's compile a similar code where the is_basic_table variable is now initialized: $ echo "unsigned int is_basic_table[] = {0};" | gcc -g -c -o test-v1.o -x c - $ $ abidw test-v1.o | cat -n 1 <abi-corpus version='2.1' path='test-v1.o' architecture='elf-amd-x86_64'> 2 <elf-variable-symbols> 3 <elf-symbol name='is_basic_table' size='4' type='object-type' binding='global-binding' visibility='default-visibility' is-defined='yes'/> 4 </elf-variable-symbols> 5 <abi-instr address-size='64' path='<stdin>' comp-dir-path='/home/dodji/git/libabigail/PR29811/prtests' language='LANG_C11'> 6 <type-decl name='unsigned int' size-in-bits='32' id='type-id-1'/> 7 <array-type-def dimensions='1' type-id='type-id-1' size-in-bits='32' id='type-id-2'> 8 <subrange length='1' type-id='type-id-3' id='type-id-4'/> 9 </array-type-def> 10 <type-decl name='unsigned long int' size-in-bits='64' id='type-id-3'/> 11 <var-decl name='is_basic_table' type-id='type-id-2' mangled-name='is_basic_table' visibility='default' filepath='/home/dodji/git/libabigail/PR29811/prtests/<stdin>' line='1' column='1' elf-symbol-id='is_basic_table'/> 12 </abi-instr> 13 </abi-corpus> Now, see like at line 7, the array type is now of 4 bytes (32 bits). Note that the size of is_basic_table is still 32 bits. Normally, abidiff-ing test-v0 and test-v1 should tell us that the two versions of the is_basic_table variable are compatible because fundamentally the structure and the size of the ELF symbol is_basic_table hasn't changed, even if in the first case, it's an array of unknown size. It's ELF symbol size was already 32 bits. Here is what abidiff says: $ abidiff test-v0.o test-v1.o Functions changes summary: 0 Removed, 0 Changed, 0 Added function Variables changes summary: 0 Removed, 1 Changed, 0 Added variable 1 Changed variable: [C] 'unsigned int is_basic_table[]' was changed to 'unsigned int is_basic_table[1]' at <stdin>:1:1: type of variable changed: type name changed from 'unsigned int[]' to 'unsigned int[1]' array type size changed from infinity to 32 array type subrange 1 changed length from infinity to 1 $ This is because the comparison engine doesn't recognize we are looking at a type change that is harmless because the ELF size hasn't changed and because this is an array of one dimension so fundamentally, the "meaning" of the type of the array hasn't fundamentally changed for ABI-related purposes. This patch teaches the diff node categorizer to recognise that we are in a case where the (one dimension) array of unknown size actually is the type of an array which symbol size is 4 bytes. In the second case, the one dimension array has a size of 4 bytes, just as its ELF symbol size. The diff node categorizer then categorizes the diff node into the existing category BENIGN_INFINITE_ARRAY_CHANGE_CATEGORY, which is a harmless diff node category. Everything then falls into place to filter the change out. Also, the patch adapts the diff reporter to better describe this type of harmless array variable type changes. The output then becomes: $ abidiff test-v0.o test-v1.o Functions changes summary: 0 Removed, 0 Changed, 0 Added function Variables changes summary: 0 Removed, 0 Changed (1 filtered out), 0 Added variable $ The change is filtered out. To have details about the change that has been filtered out, one has to use "--harmless" option: $ abidiff --harmless test-v0.o test-v1.o Functions changes summary: 0 Removed, 0 Changed, 0 Added function Variables changes summary: 0 Removed, 1 Changed, 0 Added variable 1 Changed variable: [C] 'unsigned int is_basic_table[]' was changed to 'unsigned int is_basic_table[1]' at <stdin>:1:1: size of variable symbol ( 32 (in bits)) hasn't changed but it does have a harmless type change type of variable changed: type name changed from 'unsigned int[]' to 'unsigned int[1]' array type size changed from 'unknown' to 32 array type subrange 1 changed length from 'unknown' to 1 $ * include/abg-comp-filter.h (is_var_1_dim_unknown_size_array_change): Declare new function. * src/abg-comp-filter.cc (is_var_1_dim_unknown_size_array_change): Define new function. (has_benign_array_of_unknown_size_change): Rename has_benign_infinite_array_change into this. Make this call the new is_var_1_dim_unknown_size_array_change. (categorize_harmless_diff_node): Adjust the call to has_benign_infinite_array_change into the new has_benign_array_of_unknown_size_change. * include/abg-ir.h (var_equals_modulo_types): Declare new function. Make it friend of class decl_base. * src/abg-default-reporter.cc (default_reporter::report): In the overload for var_diff, call the new maybe_report_diff_for_variable. * src/abg-ir.cc (var_equals_modulo_types): Factorize this out of the equals() function for var_decl. (equals): In the overload for var_decl, call the new var_equals_modulo_types. * src/abg-reporter-priv.h (maybe_report_diff_for_variable): Declare new function. * src/abg-reporter-priv.cc (maybe_report_diff_for_variable): Define new function. * tests/data/test-diff-filter/test-PR29811-0-report-0.txt: Add new reference test output. * tests/data/test-diff-filter/test-PR29811-0-report-1.txt: Likewise. * tests/data/test-diff-filter/test-PR29811-0-v{0,1}.o: Add new binary test inputs. * tests/data/test-diff-filter/test-PR29811-0-v{0,1}.c: Add source code of the binary test inputs. * tests/data/Makefile.am: Add new test input files above to source distribution. * tests/test-diff-filter.cc (in_out_specs): Add new tests to harness. Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
|
4545e9a23a |
dwarf-reader: Bug 29811 - Support updating of variable type
Let's look at the source code reported at https://sourceware.org/bugzilla/show_bug.cgi?id=29811: extern unsigned int is_basic_table[]; unsigned int is_basic_table[] = {0}; Let's look at the DWARF output from GCC. The variable is_basic_table is described by the DIE at offset 0x51: [ 51] variable abbrev: 7 specification (ref4) [ 2f] decl_line (data1) 3 decl_column (data1) 14 type (ref4) [ 3b] location (exprloc) [ 0] addr .bss+0 <is_basic_table> The type of the variable is defined at the offset 0x3b: [ 3b] array_type abbrev: 1 type (ref4) [ 29] sibling (ref4) [ 4b] [ 44] subrange_type abbrev: 6 type (ref4) [ 4b] upper_bound (data1) 0 But then, we see that the DIE at 0x51 has a DW_AT_specification attribute that refers to the DIE at offset 0x2f: [ 2f] variable abbrev: 5 name (strp) "is_basic_table" decl_file (data1) test-v2.c (1) decl_line (data1) 1 decl_column (data1) 21 type (ref4) [ 1e] external (flag_present) yes declaration (flag_present) yes That DIE at offset 0x2f represents the first external variable declared in the source code. It's type is an array defined at offset 0x1e: [ 1e] array_type abbrev: 1 type (ref4) [ 29] sibling (ref4) [ 29] [ 27] subrange_type abbrev: 4 This array has one dimension of 'unknown' size; this is because the dimension is described by the DIE at offset 0x27 of kind DW_TAG_subrange_type and has no DW_AT_upper_bound DIE. But then, I said earlier, the real type of the is_basic_table variable is the DIE at offset 0x3b, which is an array which single dimension described by the DIE at offset 0x44 of kind DW_TAG_subrange_type with a DW_AT_upper_bound attribute of value 0. Let's see the output of abidw on this program, from the DWARF debug info: 1 <abi-corpus version='2.1' path='test-PR29811-unknown-size-array-dwarf-ctf-DWARF.o' architecture='elf-amd-x86_64'> 2 <elf-variable-symbols> 3 <elf-symbol name='is_basic_table' size='4' type='object-type' binding='global-binding' visibility='default-visibility' is-defined='yes'/> 4 </elf-variable-symbols> 5 <abi-instr address-size='64' path='test-PR29811-unknown-size-array-dwarf-ctf.c' comp-dir-path='/home/dodji/git/libabigail/PR29811/prtests' language='LANG_C11'> 6 <type-decl name='unsigned int' size-in-bits='32' id='type-id-1'/> 7 <array-type-def dimensions='1' type-id='type-id-1' size-in-bits='32' id='type-id-2'> 8 <subrange length='1' type-id='type-id-3' id='type-id-4'/> 9 </array-type-def> 10 <array-type-def dimensions='1' type-id='type-id-1' size-in-bits='infinite' id='type-id-5'> 11 <subrange length='infinite' id='type-id-6'/> 12 </array-type-def> 13 <type-decl name='unsigned long int' size-in-bits='64' id='type-id-3'/> 14 <var-decl name='is_basic_table' type-id='type-id-5' mangled-name='is_basic_table' visibility='default' filepath='/home/dodji/git/libabigail/PR29811/prtests/test-PR29811-unknown-size-array-dwarf-ctf.c' line='10' column='1' elf-symbol-id='is_basic_table'/> 15 </abi-instr> 16 </abi-corpus> The variable is_basic_table is described by the element at line 14: 14 <var-decl name='is_basic_table' type-id='type-id-5' mangled-name='is_basic_table' visibility='default' filepath='/home/dodji/git/libabigail/PR29811/prtests/test-PR29811-unknown-size-array-dwarf-ctf.c' line='10' column='1' elf-symbol-id='is_basic_table'/> Its type has the ID 'type-id-5' which is defined at line 10: 10 <array-type-def dimensions='1' type-id='type-id-1' size-in-bits='infinite' id='type-id-5'> 11 <subrange length='infinite' id='type-id-6'/> 12 </array-type-def> Which has an unknown size. But the, at line 7, there is another array type defined with a size of 32 bits: 7 <array-type-def dimensions='1' type-id='type-id-1' size-in-bits='32' id='type-id-2'> 8 <subrange length='1' type-id='type-id-3' id='type-id-4'/> 9 </array-type-def> So, libabigail links the is_basic_table variable to the wrong array type. This is because when the DWARF reader builds the internal representation for the DW_TAG_variable DIE at offset 0x51, it first builds it with the type (and the other properties such as the name for instance) of the "declaration" DIE specified by the DW_AT_specification attribute. But then, this DW_TAG_variable DIE has its own type at offset 0x3b ; libabigail should update the internal representation it just built to set the type to the one referred to at offset 0x3b. It's that updating that is not being done. So the variable wrongly points to the type of the "declaration" DIE at offset 0x2f. This patch fixes build_var_decl to make it update the type of the variable when necessary. * include/abg-ir.h (var_decl::set_type): Declare new member function. * src/abg-ir.cc (var_decl::priv::set_type): Define new member function. (var_decl::set_type): Likewise. * src/abg-dwarf-reader.cc (build_var_decl): In "updating mode", update the type of the variable as well. * tests/data/test-diff-filter/test-PR29811-unknown-size-array-dwarf-ctf-CTF.o: Add new test binary input. * tests/data/test-diff-filter/test-PR29811-unknown-size-array-dwarf-ctf-DWARF.o: Likewise. * tests/data/test-diff-filter/test-PR29811-unknown-size-array-dwarf-ctf-report.txt: Add test reference output. * tests/data/test-diff-filter/test-PR29811-unknown-size-array-dwarf-ctf.c: Add source code of the new test binary input. * tests/data/Makefile.am: Add the new files above to source distribution. * tests/test-diff-filter.cc (in_out_specs): Add the input binaries to the test harness. * tests/data/test-annotate/test19-pr19023-libtcmalloc_and_profiler.so.abi: Adjust. * tests/data/test-read-dwarf/test19-pr19023-libtcmalloc_and_profiler.so.abi: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
|
aef4f0fd1b |
Don't use the "infinite" keyword for arrays of unknown size
In the ABIXML format and in diff reports, array dimensions of unknown size are described with the "infinite" keyword. This is not explicit enough. This patch uses the keyword "unknown" instead. Note that the keyword "infinite" is still recognized by the ABIXML reader. * src/abg-reader.cc (build_subrange_type, build_array_type_def): Support the "unknown" keyword, as well as the "infinite" keyword. * src/abg-reporter-priv.cc (report_size_and_alignment_changes): Emit the "unknown" keyword, not the "infinity" one. * src/abg-writer.cc (write_array_size_and_alignment): Likewise. * tests/data/test-annotate/libtest24-drop-fns-2.so.abi: Adjust. * tests/data/test-annotate/libtest24-drop-fns.so.abi: Likewise. * tests/data/test-annotate/test14-pr18893.so.abi: Likewise. * tests/data/test-annotate/test19-pr19023-libtcmalloc_and_profiler.so.abi: Likewise. * tests/data/test-annotate/test7.so.abi: Likewise. * tests/data/test-read-ctf/test-array-size.abi: Likewise. * tests/data/test-read-ctf/test-dynamic-array.o.abi: Likewise. * tests/data/test-read-dwarf/PR25007-sdhci.ko.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/test11-pr18828.so.abi: Likewise. * tests/data/test-read-dwarf/test14-pr18893.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/test7.so.abi: Likewise. * tests/data/test-read-dwarf/test7.so.hash.abi: Likewise. * tests/data/test-read-dwarf/test9-pr18818-clang.so.abi: Likewise. * tests/data/test-read-write/test25.xml: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
|
9af85a7032 |
ctf-reader: Fix missing initializer for member in test suite
With -Werror=missing-field-initializers on, the compiler chokes on CTF test suite. Fixed thus. * tests/test-read-ctf.cc (in_out_specs): Add initializer for `option' field in test entry. * tests/data/test-read-ctf/test-alias.o.abi: Adjust. Signed-off-by: Guillermo E. Martinez <guillermo.e.martinez@oracle.com> Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
|
4cf2ef8f97 |
ctf-front-end: Add test for alias symbols
This patch adds a new test case in the ctf-front-end test suite to to test for alias symbols support. * tests/data/test-read-ctf/test-alias.o: New binary test input file. * tests/data/test-read-ctf/test-alias.o.abi: New exported abixml file. * tests/data/Makefile.am: Add the new test input above * tests/test-read-ctf.cc: Add the new test input above to the test harness. Signed-off-by: Guillermo E. Martinez <guillermo.e.martinez@oracle.com> Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
|
fc71e519bb |
Bug 29857 - dwarf-reader: Resolve decl-only unions
When looking at https://sourceware.org/bugzilla/show_bug.cgi?id=29857 I noticed that decl-only unions where not resolved to their definition union, unlike what is done for classes and enums. At type canonicalization, a type A defined in a translation unit TU, that depends on a decl-only union U will compare different from a type A defined in a translation unit TU', that depends on the definition of U, even though the types A should be equal. This patch teaches the decl-only class resolver to also resolve decl-only unions, as opposed to resolving just decl-only classes. * include/abg-fwd.h (typedef classes_or_unions_type): Declare new typedef. (lookup_union_types): Declare new function. * src/abg-dwarf-reader.cc (reader::decl_only_classes_map_): Change the type of this from string_classes_map to string_classes_or_unions_map. (reader::declaration_only_classes): Return a string_classes_or_unions_map, no more a string_classes_map. (reader::{maybe_schedule_declaration_only_class_for_resolution, is_decl_only_class_scheduled_for_resolution}): Handle class_or_union, not just class_decl. This is a way to make this handle unions as well as classes. (get_opaque_version_of_type): Adjust. * src/abg-ir.cc (lookup_union_types): Define new function. * tests/data/test-annotate/test19-pr19023-libtcmalloc_and_profiler.so.abi: Adjust. * tests/data/test-read-dwarf/test19-pr19023-libtcmalloc_and_profiler.so.abi: Adjust. Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
|
4bdaf30bbb |
dwarf-reader: Avoid duplicating member functions
Depending on how the DWARF DIEs are encountered, it can happen that the reader mistakenly adds the same member function several times. This is because due to DIE canonicalization, when we encounter the class DIE C' that is equivelent to a class C that we have already encountered, C' is dropped on the floor and C is kept. But then, the member functions of C' should not added to C, rather, if they are already present in C, we shouldn't add them anymore. This is what build_or_get_fn_decl_if_not_suppressed is supposed to do, but fails to do in a subtle way. This patch fixes it. * src/abg-dwarf-reader.cc (build_or_get_fn_decl_if_not_suppressed): Fix the code that is supposed to avoid duplicating a member function. * tests/data/test-annotate/test14-pr18893.so.abi: Adjust. * 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/PR22122-libftdc.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/test14-pr18893.so.abi: Likewise. * tests/data/test-read-dwarf/test15-pr18892.so.abi: Likewise. * tests/data/test-read-dwarf/test16-pr18904.so.abi: Likewise. * tests/data/test-read-dwarf/test17-pr19027.so.abi: Likewise. * tests/data/test-read-dwarf/test18-pr19037-libvtkRenderingLIC-6.1.so.abi: Likewise. * tests/data/test-read-dwarf/test19-pr19023-libtcmalloc_and_profiler.so.abi: Likewise. * tests/data/test-read-dwarf/test20-pr19025-libvtkParallelCore-6.1.so.abi: Likewise. * tests/data/test-read-dwarf/test21-pr19092.so.abi: Likewise. * tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi: Likewise. * tests/data/test-read-dwarf/test9-pr18818-clang.so.abi: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
|
754364d5ca |
Fix spurious deleted/added virtual destructor change report
While looking at something else, I noticed this spurious change report: 1 member function deletion: 'method virtual tbb::internal::concurrent_queue_base_v3::~concurrent_queue_base_v3(int)' at concurrent_queue.cpp:361:1 1 member function insertion: 'method virtual tbb::internal::concurrent_queue_base_v3::~concurrent_queue_base_v3(int)' at concurrent_queue.cpp:370:1 This is when running tests/runtestdiffpkg and the result is in tests/data/test-diff-pkg/tbb-4.1-9.20130314.fc22.x86_64--tbb-4.3-3.20141204.fc23.x86_64-report-0.txt. To understand what is going on, one need to refer to the definitions of the C++ ABI at https://itanium-cxx-abi.github.io/cxx-abi/abi.html#definitions. When a class has a virtual destructor, historically, there might be 3 different and co-existing actual implementations of the destructors: the D0, D1 and D2 destructors. There might even be a D3 destructor, actually. In https://github.com/itanium-cxx-abi/cxx-abi/issues/73, one can see that there might be new D4 and D5 destructors. Each one of them might replace the set of the D0,D1,D2 destructors. So, in a new version of a binary, the virtual D4 destructor might replace the previous ones, without it being an ABI issue. The switch to the D4 virtual destructor is what libabigail is naively reporting in the change report above. This patch detects this kind of changes in the pipeline when the edit script from the diff2 algorithm is interpreted for virtual member functions and drops it on the floor. * src/abg-comparison.cc (find_virtual_dtor_in_map): Define new static function. (class_diff::ensure_lookup_tables_populated): If a virtual destructor is removed from the old binary version but is added to the new one (but through a different name), let's assume the virtual destructor is still there so there is no ABI issue from that point of view. * 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. Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
|
77ae314176 |
ctf-reader: Fix array size representation
A variable length array (VLA), or a flexible array member (with its size set to zero to recognize such cases) is represented in the libabigail IR as an array with "non-finite" length. This is a way to say that the length of the array is not statically known. The ABIXML array-type-def element looks like: <array-type-def dimensions='1' ... size-in-bits='infinite' ...> <subrange length='infinite' type-id='type-id-3' .../> </array-type-def> The patch teaches the ctf-reader to correctly set the size of the array for VLAs. * src/abg-ctf-reader.cc (build_array_ctf_range): Use * tests/data/Makefile.am: Add new test. `upper_bound' and number of elements to indicate infinite array size. * tests/data/test-read-ctf/test-array-size.abi: New test. * tests/data/test-read-ctf/test-array-size.c: Likewise. * tests/data/test-read-ctf/test-array-size.o: Likewise. * tests/test-read-ctf.cc: Update testsuite. Signed-off-by: Guillermo E. Martinez <guillermo.e.martinez@oracle.com> Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
|
e33a74fb8c |
ctf-reader: Fix representation of multidimensional arrays
To build an IR for multidimensional array the CTF front-end iterates over the element types recursively. So, consider the array definition: char a[2][3][4][5]; It's represented as 'char[2][3][4] a[5]' instead of: 'char a[2][3][4][5]' It always considers multidimensional arrays as unidimensional creating a `array-type-def' node for each dimension: <array-type-def dimensions='1' type-id='type-id-1' ... > <subrange length='2' type-id='type-id-3' id='type-id-4'/> </array-type-def> <array-type-def dimensions='1' type-id='type-id-2' ... > <subrange length='3' type-id='type-id-3' id='type-id-6'/> </array-type-def> ... Instead of: <array-type-def dimensions='4' type-id='type-id-1' ... > <subrange length='2' type-id='type-id-3' id='type-id-4'/> <subrange length='3' type-id='type-id-3' id='type-id-5'/> ... </array-type-def> Fixed thus. * src/abg-ctf-reader.cc (+build_array_ctf_range): New definition. * tests/data/Makefile.am: Add new testcase. * tests/data/test-read-ctf/test-array-mdimension.abi: New testcase. * tests/data/test-read-ctf/test-array-mdimension.c: Likewise. * tests/data/test-read-ctf/test-array-mdimension.o: Likewise. * tests/data/test-read-ctf/test9.o.abi: Adjust. * tests/test-read-ctf.cc: Update testsuite. Signed-off-by: Guillermo E. Martinez <guillermo.e.martinez@oracle.com> Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
|
916f541a9a |
ctf-reader: Strip qualification from a qualified array type
Sometimes, GCC emits some redundant const qualifiers around arrays. For instance, consider this function: $ cat -n test.c 1 const char a[32]; 2 3 char 4 foo() 5 { 6 return a[0]; 7 } $ Notice how at line 1, the type of the variable 'a' is "array of const char". Let's compile the function and emit CTF debug info: $ gcc -gctf -c test.c $ Let's see what IR libabigail emits from the CTF information: $ abidw --ctf --annotate test.o | cat -n 1 <abi-corpus version='2.1' path='test.o' architecture='elf-amd-x86_64'> 2 <elf-function-symbols> 3 <!-- foo --> 4 <elf-symbol name='foo' type='func-type' binding='global-binding' visibility='default-visibility' is-defined='yes'/> 5 </elf-function-symbols> 6 <elf-variable-symbols> 7 <!-- signed char --> 8 <elf-symbol name='a' size='32' type='object-type' binding='global-binding' visibility='default-visibility' is-defined='yes'/> 9 </elf-variable-symbols> 10 <abi-instr address-size='64' language='LANG_C'> 11 <!-- char --> 12 <type-decl name='char' size-in-bits='8' alignment-in-bits='8' id='type-id-1'/> 13 <!-- const char[32] --> 14 <array-type-def dimensions='1' type-id='type-id-2' size-in-bits='256' alignment-in-bits='8' id='type-id-3'> 15 <!-- <anonymous range>[32] --> 16 <subrange length='32' type-id='type-id-4' id='type-id-5'/> 17 </array-type-def> 18 <!-- unsigned long int --> 19 <type-decl name='unsigned long int' size-in-bits='64' alignment-in-bits='64' id='type-id-4'/> 20 <!-- const char --> 21 <qualified-type-def type-id='type-id-1' const='yes' id='type-id-2'/> 22 <!-- const char[32] const --> 23 <qualified-type-def type-id='type-id-3' const='yes' id='type-id-6'/> 24 <!-- const char[32] const a --> 25 <var-decl name='a' type-id='type-id-6' mangled-name='a' visibility='default' elf-symbol-id='a'/> 26 <!-- char foo() --> 27 <function-decl name='foo' visibility='default' binding='global' size-in-bits='64' alignment-in-bits='8' elf-symbol-id='foo'> 28 <!-- char --> 29 <return type-id='type-id-1'/> 30 </function-decl> 31 </abi-instr> 32 </abi-corpus> $ Notice how at line 25, the variable 'a' is described as having the type which ID is 'type-id-6' defined at line 23. It's a "const array of const char". GCC has thus added a redundant "const" qualifier to the array. The C language specification in paragraph [6.7.3]/8 says: If the specification of an array type includes any type qualifiers, the element type is so- qualified, not the array type. This means that a "const array of char" is the same as an "array of const char". So a "const array of const char" is the same an "array of const char". This patch performs that removal of redundant qualifier. * src/abg-ctf-reader.cc (maybe_strip_qualification): New definition. (process_ctf_qualified_type): Strip redundant qualifiers. * tests/data/test-read-ctf/test-const-array.abi: New test. * tests/data/test-read-ctf/test-const-array.c: Likewise. * tests/data/test-read-ctf/test-const-array.o: Likewise. * tests/Makefile.am: Add the new test material to source distribution. Signed-off-by: Guillermo E. Martinez <guillermo.e.martinez@oracle.com> Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
|
5efe2247c3 |
test-read-ctf: Update tests for fixing size and name for underlying types
When applying the patch "217f579b ctf-reader: Fix size and name for underlying types" the testing parts felt through the cracks. Oops. This patch adds back the testing parts of the original patch. Here is the link to the initial post: https://inbox.sourceware.org/libabigail/871qpmou3k.fsf@seketeli.org/T/#m5f37b419e580a2a4ea9d91a9394382d886358809 * src/abg-ctf-reader.cc (process_ctf_{base_type,enum_type}): Look at ctf refence type to build the underlying type if present. * tests/data/Makefile.am: New test cases. * tests/data/test-read-ctf/PR27700/test-PR27700.abi: New test input. * tests/data/test-read-ctf/test-bitfield-enum.abi: Likewise. * tests/data/test-read-ctf/test-bitfield-enum.c: Likewise. * tests/data/test-read-ctf/test-bitfield-enum.o: Likewise. * tests/data/test-read-ctf/test-bitfield.abi: Likewise. * tests/data/test-read-ctf/test-bitfield.c: Likewise. * tests/data/test-read-ctf/test-bitfield.o: Likewise. * tests/data/test-read-ctf/test-enum-many.o.hash.abi: Adjust. * tests/data/test-read-ctf/test-enum-symbol.o.hash.abi: Likewise. * tests/data/test-read-ctf/test-enum.o.abi: Likewise: * tests/data/test-read-ctf/test0.abi: Likewise. * tests/data/test-read-ctf/test0.hash.abi: Likewise. * tests/data/test-read-ctf/test1.so.abi: Likewise. * tests/data/test-read-ctf/test1.so.hash.abi: Likewise. * tests/data/test-read-ctf/test5.o.abi: Likewise. * tests/test-read-ctf.cc: Update test suite. Signed-off-by: Dodji Seketeli <dodji@redhat.com> Signed-off-by: Guillermo E. Martinez <guillermo.e.martinez@oracle.com> |
||
|
8b832a9edf |
ctf-reader: Set alignment-in-bits property to 0
When comparing the IR generated with the CTF front-end against the one generated with the DWARF front-end, the report shows changes in type alignments: 1 Changed variable: [C] 'int a' was changed at test-abi.c:8:1: type of variable changed: type size hasn't changed type alignment changed from 32 to 0 For the sake of consistency, this patch makes the CTF front-end set the alignment to `0' for base types, function types and struct types similarly to what the DWARF front-end does. * src/abg-ctf-reader.cc (process_ctf_base_type) (process_ctf_function_type, process_ctf_struct_type): Adjust `align_in_bits' argument to `0'. * tests/data/test-diff-pkg-ctf/dirpkg-3-report-1.txt: Adjust test. * tests/data/test-diff-pkg-ctf/dirpkg-3-report-2.txt: Likewise. * tests/data/test-diff-pkg-ctf/gmp-6.x.x86_64-report-0.txt: Likewise. * tests/data/test-read-ctf/PR27700/test-PR27700.abi: Likewise. * tests/data/test-read-ctf/test-PR26568-1.o.abi: Likewise. * tests/data/test-read-ctf/test-PR26568-2.o.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-anonymous-fields.o.abi: Likewise. * tests/data/test-read-ctf/test-array-of-pointers.abi: Likewise. * tests/data/test-read-ctf/test-callback.abi: Likewise. * tests/data/test-read-ctf/test-callback2.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-dynamic-array.o.abi: Likewise. * tests/data/test-read-ctf/test-fallback.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-linux-module.abi: Likewise. * tests/data/test-read-ctf/test-linux-module.abi: Likewise. * tests/data/test-read-ctf/test-list-struct.abi: Likewise. * tests/data/test-read-ctf/test0.abi: Likewise. * tests/data/test-read-ctf/test0.hash.abi: Likewise. * tests/data/test-read-ctf/test1.so.abi: Likewise. * tests/data/test-read-ctf/test1.so.hash.abi: Likewise. * tests/data/test-read-ctf/test2.so.abi: Likewise. * tests/data/test-read-ctf/test2.so.hash.abi: Likewise. * tests/data/test-read-ctf/test3.so.abi: Likewise. * tests/data/test-read-ctf/test3.so.hash.abi: Likewise. * tests/data/test-read-ctf/test4.so.abi: Likewise. * tests/data/test-read-ctf/test4.so.hash.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. Signed-off-by: Guillermo E. Martinez <guillermo.e.martinez@oracle.com> Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
|
8fd02e0a10 |
Use the CTF reader by default when applicable
At the moment, the tools abidw, abidiff, abipkgdiff and kmidiff all use the DWARF front-end by default. When the "--ctf" option is added to the command line, they use the CTF front-end. This patch changes that behaviour in the way described below. If the "--ctf" command line option is passed to the tool and if the binary to analyze contains CTF debug info, then the CTF front-end is used. If the binary contains ONLY CTF debug info, then the CTF front-end is used, even if no "--ctf" option was provided. In all the other cases, the DWARF front-end is used. Of course, the CTF front-end is not used at all if the CTF functionality hasn't been enabled at configure time. This new behaviour is effective for user space and Linux kernel binaries. * doc/manuals/abidiff.rst: Adjust. * doc/manuals/abidw.rst: Likewise. * doc/manuals/abipkgdiff.rst: Likewise. * doc/manuals/kmidiff.rst: Likewise. * include/abg-elf-based-reader.h (initialize): Add member function. * include/abg-elf-reader.h (has_{dwarf,ctf}_debug_info): Add predicate functions. * include/abg-tools-utils.h (create_best_elf_based_reader): Add arguments. * src/abg-ctf-reader.cc (process_ctf_typedef, process_ctf_base_type) (process_ctf_function_type, process_ctf_sou_members, process_ctf_forward_type) (process_ctf_struct_type, process_ctf_union_type, process_ctf_array_type) (process_ctf_qualified_type, process_ctf_pointer_type, process_ctf_enum_type): Remove arguments. Using getters to access required information instead. (reader::cur_tu_): Add data member. (initialize): Add arguments. (cur_transl_unit): Add {get,set)ter. (slurp_elf_info): Clear `STATUS_DEBUG_INFO_NOT_FOUND' if corpus is `LINUX_KERNEL_BINARY_ORIGIN'. (reader::lookup_type): Remove. (reader::build_type): New member function. * src/abg-elf-reader.cc (reader::reader): Locate ctf debug info from binary file. (reader::reader): Reset base `fe_iface' constructor. (reader::has_{dwarf,ctf}_debug_info): New definitions. (reader::read_corpus): Set `STATUS_DEBUG_INFO_NOT_FOUND' according to corpus::origin. * src/abg-tools-utils.cc (dir_contains_ctf_archive): Define new member. (file_has_ctf_debug_info): Looks for kernel ctf debug information archive. (maybe_load_vmlinux_{dwarf,ctf}_corpus): Remove. (load_vmlinux_corpus): Define function to load IR from kernel regardless of the corpus::origin. (build_corpus_group_from_kernel_dist_under): Use create_best_elf_based_reader to select the front-end. (create_best_elf_based_reader): Adjust to allow fallback behaviour for different front-ends. * tests/data/Makefile.am: Add tests. * tests/data/test-diff-pkg-ctf/dirpkg-3-report-2.txt: Adjust. * tests/data/test-read-ctf/test-fallback.abi: New test case. * tests/data/test-read-ctf/test-fallback.c: Likewise. * tests/data/test-read-ctf/test-fallback.o: Likewise. * tests/data/test-read-dwarf/test-fallback.abi: Likewise. * tests/data/test-read-dwarf/test-fallback.c: Likewise. * tests/data/test-read-dwarf/test-fallback.o: Likewise. * tests/test-diff-pkg.cc: Adjust. * tests/test-read-common.cc (test_task::run_abidw): Use the `options:option' field. * tests/test-read-common.h (InOutSpec): Add new member. * tests/test-read-ctf.cc (in_out_specs): Add option field to test suite. Add new test case. * tests/test-read-dwarf.cc: Likewise. * tools/abidiff.cc (main): Use create_best_elf_based_reader. * tools/abidw.cc: Likewise. * tools/abipkgdiff.cc: Likewise. Signed-off-by: Guillermo E. Martinez <guillermo.e.martinez@oracle.com> Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
|
7bd6983052 |
Make Front Ends first class citizens
This patch is a reorganization of the code to better support the need for having several different front-ends. In the libabigail pipeline of operation, a front-end is the part of the pipeline that analyses the input file. For instance, to analyse an ELF file, there is going to be one front-end. To analyse an ABIXML file, there is going to be another front-end. The middle-end is the part of the pipeline that interacts with the internal representation of ABIs. The middle-end knows how to analyse, compare ABI corpora provide an internal representation of the comparison result and analyse it as well. The back-end would be the part of the front-end that knows how to serialize internal representations of ABIs and ABI comparison results. One could thus imagine a front-end that understands the DWARF debug info format embedded in an ELF file. Another front-end would be dedicated to the CTF debug info format, and so on. Front-ends can share capabilities. For instance, DWARF and CTF front-ends are ELF based front end. As such, they share capabilities to understand the ELF format. They don't share much with the ABIXML front-end, however, as it's based on XML, which has almost nothing in common with ELF. To support this organization of concepts, this patch introduces a new hierarchy of types in the form of C++ classes. All front-ends implements the "Front End Interface". As such, they all inherit the abigail::fe_iface class. That class provides properties and behaviours that are shared by all front-ends that libabigail supports today. Namely, that class provides access to some of the options that are relevant to operating the front-end, to the ABI corpus or corpus group being constructed and to the suppression specifications that are considered. It also provides an abstract interface to perform the actual loading of the ABI corpus. That abstract interface has to be implemented by every single concrete front-end that is provided in libabigail. Then, there is the "ELF Reader" front-end. Its class name is abigail:🧝:reader. It inherits the abigail::fe_iface class and implements the fe_iface::load_corpus() so that the ELF properties of the ELF file be loaded and exposed in the ABI corpus as returned by the fe_iface::corpus() accessor. This ELF reader front-end also provides lots of capabilities that are specific to accessing ELF content. Then, there is a common base class for ELF-based front-ends to come, named abigail::elf_based_reader, which inherits the abigail:🧝:reader class. The purpose of this base class is to provide common properties and behaviours that are necessary to implement things like a DWARF or a CTF front-end, or any other front-end to support an ELF-based debug info format. Then, there is a CTF front-end which class is named abigail::ctf::reader. It inherits the abigail::elf_based_reader class and implements the fe_iface::load_corpus() interface to load and analyse the CTF-specific properties of the ELF file. To do this, abigail::ctf::reader::load_corpus() re-uses the abigail:🧝:load_corpus() member function to load the generic ELF parts of the ABI corpus. This reader then constructs the internal representation of the ABI corpus and passes it to the middle-end for further analysis. Then, there is a DWARF front-end which class is named abigail::dwarf::reader. It inherits the abigail::elf_based_reader class and implements the fe_iface::load_corpus() interface to load and analyse the DWARF-specific properties of the ELF file. To do this, abigail::dwarf::reader re-uses the abigail:🧝:load_corpus() member function to load the generic ELF parts of the ABI corpus, just like what the CTF front-end does. And then, just like the CTF front-end, this reader then constructs the internal representation of the ABI corpus and passes it to the middle-end for further analysis. Lastly, there is an ABIXML front-end which class is named abigail::abixml::reader. It inherits the abigail::fe_iface class directly. Note that unlike the two previous front-ends, this one doesn't inherit the elf_based_reader base class, for reasons that should be obvious to the astute reader by now. So, this front-end implements the abigail::fe_iface::load_corpus() abstract interface to load the properties for the ABI corpus represented in the ABIXML format, construct the internal representation and pass it to the middle-end for further analysis. The code of the tools got adapted to use these front-ends. The support of CTF is still guarded by #ifdef WITH_CTF pre-processor macros, but the one cool side effect is that the amount of guarded code is reduced. Basically, it's only the creation of the CTF front-end that is guarded. After its creation, what is returned is an instance of abigail::elf_based_reader::reader, exactly like what is returned by the creation of a DWARF front-end. Thus, the rest of the code is exactly the same, regardless of the kind of front-end. I believe this results in a more elegant and maintainable code. As a proof-of-concept, this patch also provides the create_best_elf_based_reader function. This function analyses the ELF file and depending on the kind of debug info it provides, returns the right front-end for it. Maybe at some point, all the #ifdef WITH_CTF guard pre-processing macros will be constrained in a single function like this one that will take the decision of instantiating the right front-end. The rest of the code will be as generic as it gets. The patch adjusts the reference abixml files produced by the CTF front-end because it now emits the <elf-needed> XML element which was not emitted before. This is done because the CTF front-end inherits the elf-reader which reads the "elf-needed" property from the binary, without explicit intervention from the CTF front-end. The patch passes 'make distcheck' on all the supported platforms. * include/abg-fwd.h (build_internal_underlying_enum_type_name): Move this here from src/abg-dwarf-reader.cc. * include/abg-elf-reader-common.h: Delete this file. Its content is going to be put in the new include/abg-elf-reader.h. * src/abg-elf-reader-common.cc: Likewise. * include/abg-{elf-based-reader, elf-reader, fe-iface}.h: Add new files. * src/abg-fe-iface.cc: Likewise. * include/Makefile.am: Add the new file abg-fe-iface.h, abg-elf-based-reader.h and abg-elf-reader.h to source distribution and remove include/abg-elf-reader-common.h from source distribution. * src/abg-ir.cc (build_internal_underlying_enum_type_name): Move this here from abg-dwarf-reader.cc so that it can be used by other readers. * include/abg-reader.h (abigail::abixml::reader): Rename the namespace abigail::xml_reader into this one. (read_context, create_native_xml_read_context) (read_context_get_path, read_corpus_from_native_xml) (read_corpus_from_native_xml_file) (read_corpus_group_from_native_xml) (read_corpus_group_from_native_xml_file): Remove. (read_translation_unit_from_file) (read_translation_unit_from_buffer) (read_translation_unit_from_istream) (read_translation_unit) (consider_types_not_reachable_from_public_interfaces) (get_types_from_type_id, get_artifact_used_by_relation_map) (load_canonical_type_ids): Take an fe_iface&, not a read_context. (create_reader): Declare new function that returns a fe_iface_sptr. (read_corpus_from_abixml, read_corpus_from_abixml_file) (read_corpus_group_from_abixml) (read_corpus_group_from_abixml_file): Declare new functions. * src/abg-reader.cc (namespace abixml): Rename the xml_reader namespace into this. (abixml::reader_sptr): New typedef. (abixml::reader): Rename read_context into this. Make it inherit the fe_iface interface. (abixml::reader::{m_path, m_env, m_corpus, m_corpus_group, m_exported_decls_builder, m_supprs}): Remove these data members that are now part of the fe_iface parent type. (abixml::reader::{set_environment, get_corpus, set_corpus, set_corpus_group, maybe_add_fn_to_exported_decls, maybe_add_var_to_exported_decls, maybe_check_abixml_canonical_type_stability, suppression_matches_function_sym_name, suppression_matches_variable_name, suppression_matches_variable_sym_name}): Remove. (read_corpus_from_input): Remove. Actually the code of this went into abixml::reader::read_context(). (abixml::reader::get_libxml_reader): Rename the get_reader member function into this. (abixml::add_reader_suppressions): Rename add_read_context_suppressions into this. (abixml::reader::read_corpus): Implement this virtual member function if the fe_iface parent interface. (maybe_set_naming_typedef, advance_cursor) (handle_version_attribute, walk_xml_node_to_map_type_ids) (read_elf_needed_from_input, read_symbol_db_from_input) (get_or_read_and_add_translation_unit, build_needed) (read_elf_needed_from_input, add_read_context_suppressions) (maybe_set_artificial_location, maybe_set_naming_typedef) (build_namespace_decl, build_elf_symbol) (build_elf_symbol_from_reference, build_elf_symbol_db) (build_function_parameter, build_function_decl) (build_function_decl_if_not_suppressed, function_is_suppressed) (type_is_suppressed, build_var_decl_if_not_suppressed) (variable_is_suppressed, variable_is_suppressed, build_var_decl) (build_type_decl, build_qualified_type_decl) (build_pointer_type_def, build_reference_type_def) (build_function_type, build_subrange_type, build_array_type_def) (build_enum_type_decl_if_not_suppressed, build_enum_type_decl) (build_typedef_decl, build_class_decl_if_not_suppressed) (build_union_decl_if_not_suppressed, build_class_decl) (build_union_decl, build_function_tdecl, build_class_tdecl) (build_type_tparameter, build_type_composition) (build_non_type_tparameter, build_non_type_tparameter) (build_template_tparameter, build_template_parameter, build_type) (handle_type_decl, handle_namespace_decl) (handle_qualified_type_decl, handle_pointer_type_def) (handle_reference_type_def, handle_function_type) (handle_array_type_def, handle_enum_type_decl) (handle_typedef_decl, handle_var_decl, handle_function_decl) (handle_class_decl, handle_union_decl, handle_function_tdecl) (read_translation_unit_from_istream): Take or use an abixml::reader rather than a read_context. (read_translation_unit, read_translation_unit_from_input) (consider_types_not_reachable_from_public_interfaces) (get_types_from_type_id, get_artifact_used_by_relation_map) (read_corpus_group_from_input, read_translation_unit) (handle_element_node, read_location, read_artificial_location) (load_canonical_type_ids) : Take an fe_iface&, not a read_context. (create_abixml_reader): Rename create_native_xml_read_context into this. Make it return a fe_iface_sptr. (read_corpus_from_abixml): Rename read_corpus_from_abixml into this. (read_corpus_from_abixml_file): Rename read_corpus_from_native_xml_file into this. (read_context_get_path): Remove. * include/abg-tools-utils.h (abigail::tools_utils::{file_has_dwarf_debug_info, file_has_ctf_debug_info}): Declare new functions. (create_best_elf_based_reader): Declare new function. * include/abg-corpus.h (corpus::add): Pass the translation unit by reference. (corpus::exported_decls_builder::maybe_add_{fn,var}_to_exported_fns): Take a const parameter. * src/abg-corpus-priv.h (corpus::exported_decls_builder::priv::add_{fn,var}_to_exported): Take a const parameter and adjust. * src/abg-corpus.cc (corpus::exported_decls_builder::maybe_add_{fn,var}_to_exported_fns): Take a const parameter. (corpus::add): Take a reference to translation_unit_sptr. * include/abg-suppression.h (abigail::fe_iface): Forward-declare this. (abigail::{suppression_sptr, suppressions_type}): Declare these types here. (abigail::suppr::{suppression_can_match, suppression_matches_function_name, suppression_matches_function_sym_name, suppression_matches_variable_name, suppression_matches_variable_sym_name, suppression_matches_type_name_or_location, is_elf_symbol_suppressed, is_elf_symbol_suppressed, is_function_suppressed, is_variable_suppressed, is_type_suppressed}): Declare these functions here. * src/abg-suppression-priv.h (function_is_suppressed) (variable_is_suppressed, type_is_suppressed) (is_elf_symbol_suppressed): Remove these template functions. * src/abg-suppression.cc (suppression_matches_function_name) (suppression_matches_function_sym_name): Remove. (variable_is_suppressed, suppression_can_match) (suppression_matches_function_name) (suppression_matches_function_sym_name) (suppression_matches_variable_name) (suppression_matches_variable_sym_name) (suppression_matches_type_name_or_location) (is_elf_symbol_suppressed, is_elf_symbol_suppressed) (is_function_suppressed, is_variable_suppressed) (is_type_suppressed): New functions. * include/abg-ctf-reader.h (abigail::ctf::{read_context, create_read_context, read_corpus, read_and_add_corpus_to_group_from_elf, set_read_context_corpus_group, reset_read_context, dic_type_key}): Remove. (ctf::{create_reader, reset_reader}): Declare new functions. * src/abg-ctf-reader.cc (read_context): Remove. (process_ctf_typedef, process_ctf_base_type) (build_ir_node_for_variadic_parameter_type) (process_ctf_function_type, process_ctf_sou_members) (process_ctf_forward_type, process_ctf_struct_type) (process_ctf_union_type, process_ctf_array_type) (process_ctf_qualified_type, process_ctf_pointer_type) (process_ctf_enum_type, fill_ctf_section) (lookup_symbol_in_ctf_archive, dic_type_key): Forward-declare these static functions. (ctf::reader): New class that is the abstraction of the CTF reader. It extends the abigail::elf_based_reader class. This is a renaming of the abigail::ctf::read_context class. (ctf::reader::{elf_handler, elf_fd, elf_handler_dbg, elf_fd_dbg, symtab, debug_info_root_paths_, debug_info_root_paths_}): Remove these data members as they are now properties of the abigail::elf_reader class, which is a parent class of this abigail::ctf::reader class. (ctf::reader::{exported_decls_builder, maybe_add_fn_to_exported_decls, current_corpus_group, has_corpus_group, main_corpus_from_current_group, current_corpus_is_main_corpus_from_current_group, should_reuse_type_from_corpus_group}): Remove these accessors that can now be used from the parent classes abigail::{elf_reader, elf_based_reader}. (ctf::reader::reader): This now delegates to the constructor of elf_based_reader. It doesn't pass any argument to initialize() anymore. (ctf::reader::initialize): Add an overload with no parameter. In the other overload, do not take a pointer to an environment as no new environment can be passed to the instance of reader that is being reset. Adjust the code of the initializer to reflect all the data members that got removed. (ctf::{env, find_ctfa_file, slurp_elf_info, process_ctf_archive, process_ctf_type, lookup_type, read_corpus, ~reader}): New member functions. Most of these were free-form functions that took ctf::read_context as first parameter. In read_corpus, do not set the corpus::LINUX_KERNEL_BINARY_ORIGIN origin as that is now done by elf::reader when it reads the binary. (lookup_type): Remove. These are now member functions of the ctf::reader class. (process_ctf_typedef, process_ctf_base_type) (build_ir_node_for_variadic_parameter_type) (process_ctf_function_type, process_ctf_sou_members) (process_ctf_forward_type, process_ctf_struct_type) (process_ctf_union_type, process_ctf_array_type) (process_ctf_qualified_type, process_ctf_pointer_type): Take a ctf::reader rather an ctf::read_context. Adjust the content of the functions. (process_ctf_type, lookup_type, process_ctf_archive): Remove these and turn them into member functions of ctf::reader. (open_elf_handler, close_elf_handler, find_alt_debuginfo): Remove these ELF handling functions as ELF handling is now done by the elf_reader parent class. (fill_ctf_section): Take a const pointer to Elf_Scn. (slurp_elf_info, find_ctfa_file): Remove this and make it be a member of ctf::reader. Also, make it handle only CTF reader specific pieces. slurp_elf_info now delegates the reading of generic ELF properties to elf::reader by calling elf::reader::read_corpus(). (create_read_context, read_corpus, set_read_context_corpus_group) (read_and_add_corpus_to_group_from_elf): Remove these functions. (create_reader, reset_reader): Create new functions (dic_type_key): Make this static. * include/abg-dwarf-reader.h (abigail::dwarf::elf_type): Move this enum into the namespace abigail::elf_reader in the file include/abg-elf-reader.h. (abigail::dwarf::{read_context, read_context_sptr, create_read_context, read_context_get_path, reset_read_context, add_read_context_suppressions, set_read_context_corpus_group, read_corpus_from_elf, read_and_add_corpus_to_group_from_elf, read_and_add_corpus_to_group_from_elf, add_read_context_suppressions, refers_to_alt_debug_info, has_alt_debug_info, get_soname_of_elf_file, get_type_of_elf_file, set_debug_info_root_path, get_debug_info_root_path, get_show_stats, set_show_stats, set_drop_undefined_syms, set_do_log, set_environment, get_environment}): Remove. * src/abg-dwarf-reader.cc (struct dwfl_deleter, dwfl_sptr) (addr_elf_symbol_sptr_map_type, address_set_type) (address_set_sptr): Delete these types. (read_context::options_type): Remove. The data members of this type got moved to struct fe_iface::options_type. (find_alt_debug_info_link, find_alt_debug_info_path) (find_alt_debug_info, lookup_data_tag_from_dynamic_segment) (elf_file_type, refers_to_alt_debug_info, has_alt_debug_info) (get_soname_of_elf_file, get_type_of_elf_file) : Remove these ELF specific functions from here; move them to the elf_reader namespace. (dwarf::reader): Create new class that extends elf_based_reader. dwarf::read_context is renamed into this type, actually. (dwarf::reader::die_source_dependant_container_set::get_container): Adjust. (dwarf::reader::{supprs_, dwarf_version_, offline_callbacks_, debug_info_root_paths_, handle_, dwarf_, alt_fd_, alt_dwarf_, alt_debug_info_path_, elf_module_, elf_handle_, elf_path_, symtab_section_, cur_corpus_group_, cur_corpus_, dt_needed_, dt_soname_, elf_architecture_, exported_decls_builder_, options_, drop_undefined_syms_}): Remove these ELF-related data members to move them into the elf_reader namespace. (maybe_propagate_canonical_type) (build_translation_unit_and_add_to_ir, build_ir_node_from_die) (add_or_update_class_type, add_or_update_union_type) (build_ir_node_for_void_type) (build_ir_node_for_variadic_parameter_type, build_function_decl) (function_is_suppressed, build_or_get_fn_decl_if_not_suppressed) (build_var_decl, build_or_get_var_decl_if_not_suppressed) (variable_is_suppressed) (propagate_canonical_type) (get_parent_die, get_scope_die, die_is_at_class_scope) (die_location, die_qualified_type_name, die_qualified_name) (die_qualified_type_name_empty) (die_return_and_parm_names_from_fn_type_die) (die_function_signature, die_function_type_is_method_type) (die_pretty_print_type, die_pretty_print_decl, die_pretty_print) (maybe_canonicalize_type, build_subrange_type) (build_subranges_from_array_type_die, compare_dies, die_location) (die_loc_and_name, die_is_effectively_public_decl) (maybe_cache_type_comparison_result) (get_cached_type_comparison_result) (maybe_get_cached_type_comparison_result, die_is_at_class_scope) (die_function_type_is_method_type, die_member_offset) (die_qualified_type_name, die_qualified_decl_name) (die_qualified_name, die_qualified_type_name_empty) (die_return_and_parm_names_from_fn_type_die) (die_function_signature, die_pretty_print_type) (die_pretty_print_decl, die_pretty_print) (at_least_one_decl_only_among_odr_relevant_dies) (compare_as_type_dies, compare_as_decl_and_type_dies) (fn_die_equal_by_linkage_name, try_canonical_die_comparison) (maybe_propagate_canonical_type, propagate_canonical_type) (compare_dies, compare_dies_during_canonicalization) (find_import_unit_point_between_dies, get_parent_die) (get_scope_die, find_lower_bound_in_imported_unit_points) (build_translation_unit_and_add_to_ir) (build_namespace_decl_and_add_to_ir, build_type_decl) (build_enum_underlying_type, build_enum_type) (finish_member_function_reading) (maybe_finish_function_decl_reading) (lookup_class_or_typedef_from_corpus) (is_function_for_die_a_member_of_class) (add_or_update_member_function, add_or_update_class_type) (add_or_update_union_type, build_qualified_type) (schedule_array_tree_for_late_canonicalization) (maybe_strip_qualification, build_pointer_type_def) (build_reference_type, build_function_type, build_subrange_type) (build_subranges_from_array_type_die, build_array_type) (build_typedef_type, build_or_get_var_decl_if_not_suppressed) (build_var_decl, function_is_suppressed) (build_or_get_fn_decl_if_not_suppressed, variable_is_suppressed) (type_is_suppressed, type_is_suppressed) (get_opaque_version_of_type, create_default_fn_sym) (build_function_decl, maybe_canonicalize_type) (build_ir_node_from_die) (build_ir_node_for_variadic_parameter_type): Take a reference to the new dwarf::reader rather than to the previous read_context. Adjust the function body. (return_comparison_result): Adjust. (dwarf::reader::reader): Adjust this from read_context::read_context. (dwarf::reader::initialize): Adjust from dwarf::read_context::initialize. (dwarf::reader::create): New factory static member function. (dwarf::reader::~reader): This doesn't have to clear anything for now. (dwarf::reader::read_corpus): New virtual member function which implements the fe_iface::read_corpus pure virtual interface. This now delegates the reading of the generic ELF properties to elf::reader by calling elf::reader::read_corpus(). Newer front-ends will be able to do the same. (dwarf::reader::reset_corpus): New member function. (dwarf::reader::read_debug_info_into_corpus): Adjust. This is now a member function. Also, do not set the corpus::LINUX_KERNEL_BINARY_ORIGIN here as it's now set by the elf::reader when it loads the binary. (dwarf::reader::{env, drop_undefined_syms, drop_undefined_syms, dwarf_elf_handle, dwarf_per_die_source, elf_path, compute_canonical_die_offset, get_die_source, get_die_from_offset, get_die_qualified_name, get_die_pretty_type_representation, get_die_qualified_type_name, get_die_pretty_representation, odr_is_relevant, set_canonical_die_offset, get_canonical_die_offset, erase_canonical_die_offset, die_wip_classes_map, die_wip_function_types_map, compare_before_canonicalisation, resolve_declaration_only_classes, resolve_declaration_only_enums, symbol_already_belongs_to_a_function, fixup_functions_with_no_symbols, canonicalize_types_scheduled, tu_die_imported_unit_points_map, die_parent_map, find_symbol_table_section, get_variable_address, exported_decls_builder, load_all_types, load_in_linux_kernel_mode, show_stats, do_log, build_die_parent_maps): Adjust. (offset_pairs_stack_type::rdr_): Changed the ctxt_ into this. (offset_pairs_stack_type::offset_pairs_stack_type): Adjust. (offset_pairs_stack_type::{erase_redundant_type_pair_entry, cancel_canonical_propagated_type}): Adjust. (dwarf::reader::{get_suppressions, offline_callbacks, create_default_dwfl, dwfl_handle, elf_module, elf_handle, add_debug_info_root_paths, add_debug_info_root_path, find_alt_debug_info, dwarf, alt_dwarf, alt_debug_info_path, current_corpus, reset_current_corpus, current_corpus_group, has_corpus_group, main_corpus_from_current_group, current_corpus_is_main_corpus_from_current_group, should_reuse_type_from_corpus_group, function_symbol_is_exported, variable_symbol_is_exported, symtab, dt_needed, dt_soname, elf_architecture, is_elf_symbol_suppressed, load_dt_soname_and_needed, load_elf_architecture, load_elf_properties, maybe_add_fn_to_exported_decls, maybe_add_var_to_exported_decls}): Remove these member functions as they got moved into the elf_reader namespace or into the fe_iface class. (dwarf::read_context::{suppression_can_match, suppression_matches_function_sym_name, suppression_matches_function_name, suppression_matches_variable_name, suppression_matches_variable_sym_name, suppression_matches_type_name_or_location}): Move these into the suppr namespace. Make it take an additional parameter that is reference fe_iface. (dwarf::reader::load_debug_info): Remove. This became merged into dwarf::read_debug_info_into_corpus. (dwarf::{set_debug_info_root_path, get_debug_info_root_path, get_show_stats, set_drop_undefined_syms, set_do_log}): Remove. (add_read_context_suppressions) (set_read_context_corpus_group, read_corpus_from_elf): Remove. (read_debug_info_into_corpus): This became a member function of dwarf::reader. (create_reader): Renamed create_read_context into this. Make it return an elf_based_reader_sptr, like the other front-end factory functions. Adjust. (reset_dwarf_reader): Renamed reset_read_context into this. Adjust. (read_corpus_from_elf): Adjust. * src/abg-elf-based-reader.cc: New file. * src/abg-elf-helpers.h (struct dwfl_deleter, dwfl_sptr) (addr_elf_symbol_sptr_map_type, address_set_sptr): Move these types here from abg-dwarf-reader.cc (initialize_dwfl_callbacks, lookup_data_tag_from_dynamic_segment): * src/abg-elf-helpers.cc (lookup_data_tag_from_dynamic_segment) (lookup_data_tag_from_dynamic_segment, initialize_dwfl_callbacks) (create_new_dwfl_handle, get_soname_of_elf_file): New functions that got moved here from the factorizing of abg-dwarf-reader.cc and abg-ctf-reader.cc. * src/abg-tools-utils.cc (file_has_dwarf_debug_info) (file_has_ctf_debug_info): New functions. (load_generate_apply_suppressions): Take an elf_based_reader, not a dwarf::read_context. (maybe_load_vmlinux_dwarf_corpus): Adjust the body to use the new front-end types. * src/Makefile.am: Add the new files src/abg-{fe-iface, elf-based-reader, elf-reader}.cc to source distribution. Remove src/abg-elf-reader-common.cc. * tools/Makefile.am: Factorize linking to libabigail.so by using LDADD. * tools/abicompat.cc (read_corpus, main): Adjust. * tools/abidiff.cc (set_suppressions) (set_native_xml_reader_options, handle_error, main): Adjust. * tools/abidw.cc (set_suppressions, load_corpus_and_write_abixml) (load_kernel_corpus_group_and_write_abixml): Adjust. * tools/abilint.cc (build_type_use_tree, show_how_type_is_used) (set_suppressions, main): Adjust. * tools/abipkgdiff.cc (elf_file::type, compare, compare_to_self) (create_maps_of_package_content) (compare_prepared_userspace_packages) (self_compare_prepared_userspace_package): Adjust. * tools/abisym.cc: Adjust invocation to abigail::dwarf::lookup_symbol_from_elf, from abigail::dwarf_reader::lookup_symbol_from_elf. * tools/kmidiff.cc (main): Adjust. * tests/print-diff-tree.cc (main): Adjust. * tests/test-abidiff.cc (main): Likewise. * tests/test-diff-dwarf.cc (main): Likewise. * tests/test-ir-walker.cc (main): Likewise. * tests/test-read-ctf.cc (test_task_ctf::perform): Likewise. * tests/test-read-dwarf.cc: Remove the useless "using" statements. * tests/test-read-write.cc: Likewise. * tests/test-symtab.cc (read_corpus, TEST_CASE) (assert_symbol_count): Adjust. * tests/data/test-read-ctf/test0.abi: Adjust. * tests/data/test-read-ctf/test0.hash.abi: Likewise. * tests/data/test-read-ctf/test1.so.abi: Likewise. * tests/data/test-read-ctf/test1.so.hash.abi: Likewise. * tests/data/test-read-ctf/test2.so.abi: Likewise. * tests/data/test-read-ctf/test2.so.hash.abi: Likewise. * tests/data/test-read-ctf/test3.so.abi: Likewise. * tests/data/test-read-ctf/test3.so.hash.abi: Likewise. * tests/data/test-read-ctf/test4.so.abi: Likewise. * tests/data/test-read-ctf/test4.so.hash.abi: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
|
c2458fe1ae |
rhbz2114909 - Refer to changed base classes using their non-qualified names
This was filled at https://bugzilla.redhat.com/show_bug.cgi?id=2114909 When analysing the edit script representing the changes in the base base classes of a given class, libabigail refers to the changed base classes using their names. The problem is that there can be several changed base classes that have the same name, even though their /qualified/ names are different. That was wreaking having havoc down the road. To solve the problem, use the qualified name of the base classes, instead of their simple name. Note that this change did also ameliorate other existing change reports in the test suite. While testing the fix, I realized that class_decl::base_spec doesn't set its qualified name. That leads to the fact that it's the non-qualified name that is used for sorting the base class names in the change reports. This can lead to instabilities, depending on the platform, in test output. This is also fixed. Fixed thus. * src/abg-comparison.cc (class_diff::ensure_lookup_tables_populated): Refer to the added or removed base class using its qualified name. * src/abg-ir.cc (class_decl::base_spec::base_spec): Set the qualified name of the base_spec. * tests/data/test-abidiff-exit/test-rhbz2114909-report-1.txt: New reference test output. * tests/data/test-abidiff-exit/test-rhbz2114909-v{0,1}.o: New input test binaries. * tests/data/test-abidiff-exit/test-rhbz2114909-v{0,1}.cc: Source code of the binaries, above. * tests/data/Makefile.am: Add the new test materials above to source distribution. * tests/test-abidiff-exit.cc (in_out_specs): Add the new tests to this harness. * tests/data/test-diff-pkg/libsigc++-2.0-0c2a_2.4.0-1_amd64--libsigc++-2.0-0v5_2.4.1-1ubuntu2_amd64-report-0.txt: Adjust. Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
|
d3e63ef8f6 |
dwarf-reader: Fix class size setting bug
While looking at something else, I saw cases in DWARF where we don't set the size of some classes, especially when the DIE of the class is an implementation of a specification (which obviously has a zero size). And those cases lead to some classes wrongly considered as having zero size. Fixed thus with test cases output updated. * src/abg-dwarf-reader.cc (add_or_update_class_type): If we are looking at a class DIE with children node, if it's advertized as having non-zero size, then update the size. * tests/data/test-annotate/libtest23.so.abi: Adjust. * 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-diff-dwarf-abixml/test0-pr19026-libvtkIOSQL-6.1.so.1-report-0.txt: Likewise. * tests/data/test-read-dwarf/libtest23.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. Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
|
0d49c09e9c |
Bug 29650 - Caching class comparison result potentially too early
When structurally comparing two classes T and T' the overload of the equals() function for abigail::ir::class_decl calls the overload of equals() for abigail::ir::class_or_union to compare the data members of the class. If data members are equal, that later call caches the result of comparing the data-members-only sub-object of T and T'. That caching appears as if it's the result of comparing all of T and T' that was cached, leading to misleading results down the road. Result caching should not take place until the end of fulling comparing T and T'. Fixed thus. * src/abg-ir.cc (equal): In the overload of class_or_union do not cache the result comparing just the data members sub-types of of classes. In the overload for class_decl, put cycle detection management code /after/ the call to equals for class_or_union, because that called function does perform the cycle detection management as well; otherwise, that introduces an unwarranted redundancy. In the overload of equals for union_decl, cache the result of the comparison. * tests/data/test-abidiff/test-PR18791-report0.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. Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
|
aad0e11f50 |
comparison: Ensure that fn parms with basic types can't be redundant
When comparing the two libc binaries from "https://the.owo.foundation/Ac1Ksw8.tgz", abidiff crashes. It appears to be due to an assert that is hit because the overload of default_reporter::report for fn_parm_diff momentarily removes the redundant-ness from the categorization of the diff node of the type of a function parameter. The problem is that the sole child diff node of that type diff node is itself redundant. So the function parameter type diff node should really be redundant too. Oops, there is a logic violation there, hence the assert violation. I commented out the line that removes the redundant-ness. After all, if function parameter types shouldn't be redundant, that should have been taken care of by the redundancy_marking_visitor code in abg-comparison.cc as well as its associated category propagation code. But then consider what happens with a reproducer of the libc binaries above: $ cat test-PR29387-v0.c typedef int Integer; void f0(Integer i, char c) { i + c; } void f1(Integer i, unsigned char c) { i + c; } $ $ cat test-PR29387-v1.c typedef long int Integer; void f0(Integer i, char c) { i + c; } void f1(Integer i, unsigned char c) { i + c; } $ gcc -g test-PR29387-v0.c $ gcc -g test-PR29387-v1.c $ $ abidiff test-PR29387-v0.o test-PR29387-v1.o Functions changes summary: 0 Removed, 2 Changed, 0 Added functions Variables changes summary: 0 Removed, 0 Changed, 0 Added variable 2 functions with some indirect sub-type change: [C] 'function void f0(Integer, char)' at PR29387-test-v1.c:4:1 has some indirect sub-type changes: parameter 1 of type 'typedef Integer' changed: underlying type 'int' changed: type name changed from 'int' to 'long int' type size changed from 32 to 64 (in bits) [C] 'function void f1(Integer, unsigned char)' at PR29387-test-v1.c:10:1 has some indirect sub-type changes: $ $ So, the problem is this peace of report: [C] 'function void f1(Integer, unsigned char)' at PR29387-test-v1.c:10:1 has some indirect sub-type changes: You see that the report is empty; the reporter could not say what changed. What changed is the typedef "Integer" that changed from "int" to "long int". The redundancy_marking_visitor pass marked the change of the underlying type of the Integer typedef as being redundant. This is because that typedef change has already been reported on the f0 function interface. The problem is that by design, the 'int' to 'long int' change should not have been marked as being redundant by the redundancy_marking_visitor pass. This is because, we want to see all the "basic type changes" on function parameters types. They are deemed "local changes" of the function types, and we want to see all local changes to functions because it is almost 100% sure these are non-compatible changes. The root cause of the problem is that the function has_basic_type_change_only in abg-comparison.cc fails to detect that the parameter change carries a typedef-to-basic-type change, so the function parameter is wrongly marked as being redundant even though it ultimately carries a basic type change. This patch thus teaches has_basic_type_change_only to look through parameter changes to better detect basic type changes. * include/abg-comparison.h (peel_fn_parm_diff) (peel_typedef_qualified_type_or_parameter_diff): Declare ... * src/abg-comparison.cc (peel_fn_parm_diff) (peel_typedef_qualified_type_or_parameter_diff): ... new functions. (has_basic_type_change_only): Look through function parameters, typedefs and qualified types. * src/abg-default-reporter.cc (default_reporter::report): Remove the temporary removal of the redundant categorisation. Redundant-ness should have been handled by the redundancy_marking_visitor pass. * tests/data/test-diff-filter/test-PR29387-report.txt: Reference test output. * tests/data/test-diff-filter/test-PR29387-v{0,1}.c: Source of the input tests. * tests/data/test-diff-filter/test-PR29387-v{0,1}.o: Input test binaries. * tests/data/Makefile.am: Add the new test material above to the source distribution. * tests/test-diff-filter.cc (in_out_specs): Add the test binaries above to the test harness. Signed-off-by: Dodji Seketeli <dodji@redhat.com> |