]> sourceware.org Git - libabigail.git/log
libabigail.git
9 months agoBug 31279 - Acknowledge that opaque types are always decl-only
Dodji Seketeli [Thu, 25 Jan 2024 11:06:57 +0000 (12:06 +0100)]
Bug 31279 - Acknowledge that opaque types are always decl-only

When handling a decl-only base class, add_or_update_class_type asserts
that we need to try to resolve the decl-only base class to its
definition.  That makes sense in most cases.

However, in cases where the base class is actually an opaque class
resulting from the use of the --header-dir{1,2} option of abidiff, the
opaque type is by definition a decl-only class artificially created
from a fully defined class.

When the opaque class is anonymous (later named by a typedef),
maybe_schedule_declaration_only_class_for_resolution schedules a
decl-only class named by the empty string for resolution to its
definition.  Later when add_or_update_class_type handles the decl-only
base class (now named by a typedef),
reader::is_decl_only_class_scheduled_for_resolution looks for the
typedef name; as the class scheduled for resolution by
maybe_schedule_declaration_only_class_for_resolution was then
anonymous, reader::is_decl_only_class_scheduled_for_resolution returns
false and the assert in add_or_update_class_type fails.  It's the
problem reported in this issue.  Oops.

When the opaqued decl-only type is anonymous,
maybe_schedule_declaration_only_{class,enum}_for_resolution must NOT
schedule it for resolution to its definition because the scheduled
types for resolution are designated by name.  This patch now enforces
that.

It just doesn't make sense to schedule an anonymous type for
resolution to its definition.  When the type is later named by a
typedef however, then it's scheduled for resolution to its definition,
as it's no more anonymous at that point.  The patch enforces that as
well.

The patch ends up making sure that add_or_update_class_type does /not/
assert that an /anonymous/ decl-only base class is scheduled for
resolution to its definition.

These changes should fix the problem reported at
https://sourceware.org/bugzilla/show_bug.cgi?id=31279.

* src/abg-dwarf-reader.cc
(reader::maybe_schedule_declaration_only_{class,enum}_for_resolution):
Do not schedule anonymous decl-only types for resolution to their
definition.
(build_typedef_type): When an anonymous decl-only type has just
been named by a typedef, schedule it for resolution to its
definition.
(add_or_update_class_type): Do not assert that /anonymous/
decl-only types are scheduled for resolution to their definition.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
9 months agoBug 31236 - Fix removing a member declaration from its scope
Dodji Seketeli [Mon, 15 Jan 2024 10:10:42 +0000 (11:10 +0100)]
Bug 31236 - Fix removing a member declaration from its scope

In some C++ binaries, DWARF can represent a member variable using a
global variable /definition/ DIE not having a reference attribute
pointing back to the member variable declaration DIE.  The only way we
know that the global variable is a definition DIE for a member
variable is because its linkage name demangles to
"foo::bar::var_name", with foo::bar being a class name.

So, for each translation unit, when the DWARF reader reads a global
variable DIE, it builds a variable IR node for it and stashes it on
the side.

Then, when the translation unit is built, the DWARF reader looks at
all the stashed global variables, detects those that are actually
member variables and adds them to their class.  But then, before
adding a (former global) variable to its class, the reader has first
to remove it from its global scope.  This removal is done by the
function remove_decl_from_scope, which calls
scope_decl::remove_member_decl.

The issue here is that remove_decl_from_scope forgets to unset the
translation unit property of the global variable.

Then, in the particular case of this problem report, when
scope_decl::add_member_decl is called to add the variable to its
class, it detects that the variable belongs to /another/ translation
unit and (rightfully) aborts.  Ooops.

This patch fixes the issue by making remove_decl_from_scope remove the
variable from its translation unit too, not just from its scope.  The
patch actually delegates the scope & translation unit resetting to
scope_decl::remove_member_decl because it appears to me that this is
where these ought to be handled.

To ensure that the issue is fixed, one needs to unpack the package
webkit2gtk3-2.40.5-1.el9_3.1.x86_64.rpm and run abidw on the binary
$prefix/usr/lib64/libwebkit2gtk-4.0.so.37 like:

   $ abidw --noout $prefix/usr/lib64/libwebkit2gtk-4.0.so.37

Given the size of the library, this takes three hours and a half as
well as ~50GB of ram to complete on my system using a non-optimized
debug build of libabigail.  We definitely need to invest in more speed
optimizations to handle webkit.  That would be for another day, I
guess.

* src/abg-ir.cc (scope_decl::remove_member_decl): Reset the
translation unit and the scope of the removed decl.
(remove_decl_from_scope): Do not reset the scope of the removed
decl here as it's now done above.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
9 months agoRecognize EM_RISCV in e_machine_to_string
Mark Wielaard [Fri, 29 Dec 2023 00:40:50 +0000 (01:40 +0100)]
Recognize EM_RISCV in e_machine_to_string

Check that EM_RISCV is defined in elf.h and if it is then recognize
it in e_machine_to_string, producing "elf-riscv".

* configure.ac: Defining HAVE_EM_RISCV_MACRO if EM_RISCV
is defined in elf.h.
* src/abg-dwarf-reader.cc (e_machine_to_string): Handle
EM_RISCV if HAVE_EM_RISCV_MACRO is defined.

Signed-off-by: Mark Wielaard <mark@klomp.org>
9 months agoFix ABG_ASSERT in build_ir_node_from_die for DW_TAG_member
Mark Wielaard [Fri, 29 Dec 2023 00:40:51 +0000 (01:40 +0100)]
Fix ABG_ASSERT in build_ir_node_from_die for DW_TAG_member

When the die is a member, it is the CU of the die that should not be
in the C language, not the dwarf reader current translation unit.

* src/abg-dwarf-reader.cc (build_ir_node_from_die): ABG_ASSERT
!rdr.die_is_in_c(), not rdr.cur_transl_unit().

Signed-off-by: Mark Wielaard <mark@klomp.org>
9 months agowebsite: doxygen: set PROJECT_NAME to libabigail
Giuliano Procida [Thu, 4 Jan 2024 13:02:58 +0000 (13:02 +0000)]
website: doxygen: set PROJECT_NAME to libabigail

This changes the project name from the default "My Project" to
"libabigail".

* doc/website/libabigail-website.doxy: Set PROJECT_NAME to
libabigail.

Signed-off-by: Giuliano Procida <gprocida@google.com>
11 months agoBump LIBABIGAIL_SO_CURRENT version to 4
Dodji Seketeli [Wed, 29 Nov 2023 13:35:47 +0000 (14:35 +0100)]
Bump LIBABIGAIL_SO_CURRENT version to 4

Recent patches change the ABI of the library, namely, by adding
parameters to functions like is_pointer_type or adding virtual member
functions to classes in the IR.  Thus the LIBABIGAIL_SO_CURRENT
version has to be bumped from 3 to 4.

* configure.ac: Set LIBABIGAIL_SO_CURRENT to 4.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
11 months agoBump abixml version to 2.3
Dodji Seketeli [Fri, 1 Dec 2023 10:37:49 +0000 (11:37 +0100)]
Bump abixml version to 2.3

An older version of libabigail won't be able to grok new abixml files
containing the recently added support for pointer-to-member types.

It's thus needed to bump the minor version number of the abixml
format.  The new version is thus 2.3.  As a result, this patch also
updates the version numbers shown in the various abixml files of the
test suite.

* configure.ac: Bump ABIXML_VERSION_MINOR to 3.
* 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/test-pointer-to-member-1.o.annotated.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-pointer-to-member-1.o.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>
11 months agoBug 30260 - Support pointer-to-member type
Dodji Seketeli [Thu, 30 Nov 2023 15:54:30 +0000 (16:54 +0100)]
Bug 30260 - Support pointer-to-member type

This adds support for C++ pointer-to-member types.

Here is a screenshot of what this patch enables libabigail to do:

    $ cat -n test-ptr-to-mbr-v0.cc
 1 struct X
 2 {
 3   void f(int);
 4   int a;
 5 };
 6
 7 int X::* pmi = &X::a;
 8 void (X::* pmf)(int) = &X::f;
 9

    $ diff -u test-ptr-to-mbr-v0.cc test-ptr-to-mbr-v1.cc
    --- test-ptr-to-mbr-v0.cc 2023-11-22 15:22:04.258260701 +0100
    +++ test-ptr-to-mbr-v1.cc 2023-11-22 15:23:02.482621214 +0100
    @@ -1,9 +1,8 @@
     struct X
     {
    -  void f(int);
    -  int a;
    +  void f(int, char);
    +  char a;
     };

    -int X::* pmi = &X::a;
    -void (X::* pmf)(int) = &X::f;
    -
    +auto pmi = &X::a;
    +auto pmf = &X::f;

    $ abidiff test-ptr-to-mbr-v0.o test-ptr-to-mbr-v1.o
    Functions changes summary: 0 Removed, 0 Changed, 0 Added function
    Variables changes summary: 0 Removed, 2 Changed, 0 Added variables

    2 Changed variables:

      [C] 'void (X::* pmf)(int)' was changed to 'void (X::* pmf)(int, char)' at test-ptr-to-mbr-v1.cc:8:1:
type of variable changed:
  pointer-to-member type changed from: 'void (X::*)(int) to: 'void (X::*)(int, char)'
  in containing type 'struct X' of pointed-to-member type 'void (X::*)(int)' at test-ptr-to-mbr-v1.cc:1:1:
    type size changed from 32 to 8 (in bits)
    1 data member change:
      type of 'int a' changed:
type name changed from 'int' to 'char'
type size changed from 32 to 8 (in bits)

      [C] 'int X::* pmi' was changed to 'char X::* pmi' at test-ptr-to-mbr-v1.cc:7:1:
type of variable changed:
  pointer-to-member type changed from: 'int X::* to: 'char X::*'
  in data member type 'int' of pointed-to-member type 'int X::*':
    type name changed from 'int' to 'char'
    type size changed from 32 to 8 (in bits)
  containing type of pointer-to-member 'struct X' changed at test-ptr-to-mbr-v0.cc:1:1, as reported earlier

    $

* include/abg-comparison.h (class ptr_to_mbr_diff): Declare new
class.
(ptr_to_mbr_diff_sptr): Declare new typedef.
(compute_diff): Declare new overload for ptr_to_mbr_diff.
(ptr_to_mbr_type_sptr): Declare new typedef.
* src/abg-comparison-priv.h (struct ptr_to_mbr_diff::priv): Define
* src/abg-comparison.cc (compute_diff_for_types): Support new
ptr_to_mbr_type type.
(ptr_to_mbr_diff::{ptr_to_mbr_diff, first_ptr_to_mbr_type,
second_ptr_to_mbr_type, member_type_diff, containing_type_diff,
has_changes, has_local_changes, get_pretty_representation, report,
chain_into_hierarchy, ~ptr_to_mbr_diff}): Define member functions
of class ptr_to_mbr_diff.
(compute_diff): Define overload for ptr_to_mbr_type_sptr.
* include/abg-fwd.h (ptr_to_mbr_type_sptr): Declare new typedef.
(is_ptr_to_mbr_type, is_pointer_to_ptr_to_mbr_type)
(is_typedef_of_maybe_qualified_class_or_union_type): Declare new
functions.
* include/abg-ir.h (type_maps::ptr_to_mbr_types): Declare new
accessor.
(POINTER_TO_MEMBER_TYPE): Add new enumerator to enum
type_or_decl_base::type_or_decl_kind.
(class ptr_to_mbr_type): Declare new class.
(equals): Declare new overload for ptr_to_mbr_type.
(ir_node_visitor::visit_{begin,end}): Declare new member
functions.
* src/abg-ir.cc (ptr_to_mbr_declaration_name)
(ptr_to_mbr_declaration_name, add_outer_ptr_to_mbr_type_expr)
(add_outer_pointer_to_ptr_to_mbr_type_expr): Define new static
functions.
(type_maps::priv::ptr_to_mbr_types_): Define new
data member.
(type_maps::ptr_to_mbr_types): Define new accessor.
(is_ptr_to_mbr_type, is_pointer_to_ptr_to_mbr_type)
(is_typedef_of_maybe_qualified_class_or_union_type): Define new
functions.
(maybe_update_types_lookup_map, equals): Define new overloads for
ptr_to_mbr_type_sptr.
(is_npaf_type): Use is_ptr_to_mbr_type.
(maybe_update_types_lookup_map): In the overload for
decl_base_sptr, call the new overload for ptr_to_mbr_type_sptr
above.
(struct ptr_to_mbr_type::priv): Define new struct.
(ptr_to_mbr_type::{ptr_to_mbr_type, get_member_type,
get_containing_type, operator==, get_qualified_name, traverse,
~ptr_to_mbr_type}): Define member functions of ptr_to_mbr_type.
(types_have_similar_structure): Support the new ptr_to_mbr_type
type.
(ir_node_visitor::visit_{begin,end}): Add new member functions.
(var_decl::get_pretty_representation): Support pretty-printing
pointer-to-member types.
(pointer_declaration_name, array_declaration_name): Likewise.
* include/abg-reporter.h ({reporter_base, default_reporter,
leaf_reporter}::report): Add an overload for ptr_to_mbr_diff.
(default_reporter::report_local_ptr_to_mbr_type_changes): Declare
a member function.
private data class of ptr_to_mbr_diff.
* src/abg-default-reporter.cc
(default_reporter::report_local_ptr_to_mbr_type_changes): Define
member functions.
(default_reporter::report): Define an overload for
ptr_to_mbr_diff.
* src/abg-leaf-reporter.cc (leaf_reporter::report): Likewise.
* src/abg-dwarf-reader.cc (build_ptr_to_mbr_type): Define new
function.
(build_ir_node_from_die): Use the new build_ptr_to_mbr_type
function.
* src/abg-reader.cc (build_ptr_to_mbr_type): Define new function.
(build_type): Use the new build_ptr_to_mbr_type above.
* src/abg-writer.cc (write_ptr_to_mbr_type): Define new function.
(write_type, write_decl, write_member_type): Use the new
write_ptr_to_mbr_type above.
* tests/data/test-abidiff-exit/pointer-to-member/test-ptr-to-mbr1-output-1.txt:
Add new test material.
* tests/data/test-abidiff-exit/pointer-to-member/test-ptr-to-mbr1-v0.cc:
Likewise.
* tests/data/test-abidiff-exit/pointer-to-member/test-ptr-to-mbr1-v0.o:
Likewise.
* tests/data/test-abidiff-exit/pointer-to-member/test-ptr-to-mbr1-v1.cc:
Likewise.
* tests/data/test-abidiff-exit/pointer-to-member/test-ptr-to-mbr1-v1.o:
Likewise.
* tests/data/test-abidiff-exit/pointer-to-member/test-ptr-to-mbr2-output-1.txt:
Likewise.
* tests/data/test-abidiff-exit/pointer-to-member/test-ptr-to-mbr2-v0.cc:
Likewise.
* tests/data/test-abidiff-exit/pointer-to-member/test-ptr-to-mbr2-v0.o:
Likewise.
* tests/data/test-abidiff-exit/pointer-to-member/test-ptr-to-mbr2-v1.cc:
Likewise.
* tests/data/test-abidiff-exit/pointer-to-member/test-ptr-to-mbr2-v1.o:
Likewise.
* tests/data/test-abidiff-exit/pointer-to-member/test-ptr-to-mbr3-output-1.txt:
Likewise.
* tests/data/test-abidiff-exit/pointer-to-member/test-ptr-to-mbr3-v0.cc:
Likewise.
* tests/data/test-abidiff-exit/pointer-to-member/test-ptr-to-mbr3-v0.o:
Likewise.
* tests/data/test-abidiff-exit/pointer-to-member/test-ptr-to-mbr3-v1.cc:
Likewise.
* tests/data/test-abidiff-exit/pointer-to-member/test-ptr-to-mbr3-v1.o:
Likewise.
* tests/data/test-abidiff-exit/pointer-to-member/test-ptr-to-mbr4-output-1.txt:
Likewise.
* tests/data/test-abidiff-exit/pointer-to-member/test-ptr-to-mbr4-v0.cc:
Likewise.
* tests/data/test-abidiff-exit/pointer-to-member/test-ptr-to-mbr4-v0.o:
Likewise.
* tests/data/test-abidiff-exit/pointer-to-member/test-ptr-to-mbr4-v1.cc:
Likewise.
* tests/data/test-abidiff-exit/pointer-to-member/test-ptr-to-mbr4-v1.o:
Likewise.
* tests/data/test-abidiff-exit/pointer-to-member/test-ptr-to-mbr5-output-1.txt:
Likewise.
* tests/data/test-abidiff-exit/pointer-to-member/test-ptr-to-mbr5-v0.cc:
Likewise.
* tests/data/test-abidiff-exit/pointer-to-member/test-ptr-to-mbr5-v0.o:
Likewise.
* tests/data/test-abidiff-exit/pointer-to-member/test-ptr-to-mbr5-v1.cc:
Likewise.
* tests/data/test-abidiff-exit/pointer-to-member/test-ptr-to-mbr5-v1.o:
Likewise.
* tests/data/test-read-dwarf/test-pointer-to-member-1.cc:
Likewise.
* tests/data/test-read-dwarf/test-pointer-to-member-1.o: Likewise.
* tests/data/test-read-dwarf/test-pointer-to-member-1.o.abi:
Likewise.
* tests/data/Makefile.am: Add the new test material above to
source distribution.
* tests/test-abidiff-exit.cc (in_out_specs): Add the test material
above to this test harness.
* tests/test-annotate.cc (in_out_specs): Likewise.
* tests/test-read-dwarf.cc: Likewise.
* tests/data/test-read-dwarf/PR22015-libboost_iostreams.so.abi: Adjust.
* tests/data/test-read-dwarf/test12-pr18844.so.abi: Likewise.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
11 months agoImprove type naming
Dodji Seketeli [Thu, 30 Nov 2023 15:46:34 +0000 (16:46 +0100)]
Improve type naming

There are a number of glitches when pretty-printing type names.

This is particularly true for derived types like pointer to functions,
array of pointer to functions and the likes.

For instance, we can see in
tests/data/test-abidiff-exit/PR30048-test-2-report-1.txt that a
function N that takes no parameter and returns a pointer to an array
of 7 int is pretty-printed as:

    int[7]* N()

That obviously doesn't respect the type naming rules of C or C++.

With this patch, function N is declared as:

    int(*N(void))[7]

To learn more about the impact of the patch on how types are
pretty-printed, you can look at the parts of the patch that are
adjustments to the expected output of the regression tests.

For instance, here is how the expected output of type pretty-printing
in tests/data/test-abidiff-exit/PR30048-test-2 is modified by this
patch:

    diff --git a/tests/data/test-abidiff-exit/PR30048-test-2-report-1.txt b/tests/data/test-abidiff-exit/PR30048-test-2-report-1.txt
    index 2650b5a0..7bbbc2e2 100644
    --- a/tests/data/test-abidiff-exit/PR30048-test-2-report-1.txt
    +++ b/tests/data/test-abidiff-exit/PR30048-test-2-report-1.txt
    @@ -3,22 +3,22 @@ Variables changes summary: 0 Removed, 0 Changed, 0 Added variable

     7 functions with some indirect sub-type change:

    -  [C] 'function int[7]* N()' at PR30048-test-2-v0.cc:62:1 has some indirect sub-type changes:
    +  [C] 'function int(*N(void))[7]' at PR30048-test-2-v0.cc:62:1 has some indirect sub-type changes:
 return type changed:
    -      entity changed from 'int[7]*' to 'int'
    +      entity changed from 'int(*)[7]' to 'int'
   type size changed from 64 to 32 (in bits)

    -  [C] 'function int* O()' at PR30048-test-2-v0.cc:64:1 has some indirect sub-type changes:
    +  [C] 'function int* O(void)' at PR30048-test-2-v0.cc:64:1 has some indirect sub-type changes:
 return type changed:
   entity changed from 'int*' to 'int'
   type size changed from 64 to 32 (in bits)

    -  [C] 'function int ()* P()' at PR30048-test-2-v0.cc:67:1 has some indirect sub-type changes:
    +  [C] 'function int (*P(void))(void)' at PR30048-test-2-v0.cc:67:1 has some indirect sub-type changes:
 return type changed:
    -      entity changed from 'int ()*' to 'int'
    +      entity changed from 'int (*)(void)' to 'int'
   type size changed from 64 to 32 (in bits)

Note that the change to the CTF test
tests/data/test-read-ctf/test9.o.abi is triggered by a change in the
sorting of types because types are sorted alphabetically.

All in all, this is clearly an overdue improvement to the type name
pretty-printing.

* include/abg-fwd.h (is_npaf_type, is_pointer_to_function_type)
(is_pointer_to_array_type, is_pointer_to_npaf_type): Declare new
functions.
(is_pointer_type, is_reference_type, is_array_type): Take a
boolean parameter to look through qualifiers.
* include/abg-ir.h (is_pointer_type): Do not make this function a
friend of the type_or_decl_base class anymore.
* src/abg-ir.cc (pointer_declaration_name, array_declaration_name)
(stream_pretty_representation_of_fn_parms)
(add_outer_pointer_to_fn_type_expr)
(add_outer_pointer_to_array_type_expr): Define new static
functions.
(is_npaf_type, is_pointer_to_function_type)
(is_pointer_to_array_type, is_pointer_to_npaf_type): Define new
functions.
(get_type_representation): Remove the overload for array_type_def.
(get_function_type_name, get_method_type_name)
(function_decl::get_pretty_representation_of_declarator): Use the
new stream_pretty_representation_of_fn_parms.  This actually
factorizes parameters pretty-printing by reusing
stream_pretty_representation_of_fn_parms.
(is_pointer_type, is_reference_type, is_array_type): Take a
boolean parameter to look through qualifiers.
(is_void_pointer_type): Use const where it's due.
(pointer_type_def::get_qualified_name): Use the new
pointer_declaration_name in lieu of the old and removed
get_name_of_pointer_to_type.
(array_type_def::{get_pretty_representation, get_qualified_name}):
Use the new array_declaration_name instead of the old and removed
get_type_representation.
(var_decl::get_pretty_representation): Use the new
array_declaration_name and pointer_declaration_name.
(function_decl::get_pretty_representation): Use the new
add_outer_pointer_to_array_type_expr, and
add_outer_pointer_to_array_type_expr function to support the
proper syntax for function returning pointers and arrays.
(function_decl::parameter::get_pretty_representation): Fix the
pretty-printing of each function parameter.
* tests/data/test-abicompat/test0-fn-changed-report-0.txt: Adjust.
* tests/data/test-abicompat/test0-fn-changed-report-2.txt:
Likewise.
* tests/data/test-abicompat/test1-fn-removed-report-0.txt:
Likewise.
* tests/data/test-abicompat/test3-fn-removed-report-0.txt:
Likewise.
* tests/data/test-abidiff-exit/PR30048-test-2-report-1.txt: Likewise.
* tests/data/test-abidiff-exit/PR30048-test-report-0.txt: Likewise.
* tests/data/test-abidiff-exit/PR30329/PR30329-report-1.txt: Likewise.
* tests/data/test-abidiff-exit/PR30503/libsdl/libsdl-1.2.60-1.2.64-report.txt: Likewise.
* tests/data/test-abidiff-exit/ada-subrange/test1-ada-subrange/test1-ada-subrange-report-1.txt: Likewise.
* tests/data/test-abidiff-exit/ada-subrange/test1-ada-subrange/test1-ada-subrange-report-2.txt: Likewise.
* tests/data/test-abidiff-exit/qualifier-typedef-array-report-1.txt:
Likewise.
* tests/data/test-abidiff-exit/test-fun-param-report.txt:
Likewise.
* tests/data/test-abidiff-exit/test-ld-2.28-210.so--ld-2.28-211.so.txt:
Likewise.
* tests/data/test-abidiff-exit/test-leaf-fun-type-report.txt:
Likewise.
* tests/data/test-abidiff-exit/test-leaf-more-report.txt:
Likewise.
* tests/data/test-abidiff-exit/test-leaf-peeling-report.txt:
Likewise.
* tests/data/test-abidiff-exit/test-leaf-stats-report.txt:
Likewise.
* tests/data/test-abidiff-exit/test-net-change-report0.txt:
Likewise.
* tests/data/test-abidiff-exit/test-net-change-report2.txt:
Likewise.
* tests/data/test-abidiff-exit/test2-filtered-removed-fns-report0.txt:
Likewise.
* tests/data/test-abidiff/test-PR18791-report0.txt: Likewise.
* tests/data/test-abidiff/test-crc-report-0-1.txt: Likewise.
* tests/data/test-abidiff/test-crc-report-1-0.txt: Likewise.
* tests/data/test-abidiff/test-crc-report-1-2.txt: 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/PR25058-liblttng-ctl-report-1.txt:
Likewise.
* tests/data/test-diff-dwarf/test-23-diff-arch-report-0.txt:
Likewise.
* tests/data/test-diff-dwarf/test18-alias-sym-report-0.txt:
Likewise.
* tests/data/test-diff-dwarf/test19-soname-report-0.txt: Likewise.
* tests/data/test-diff-dwarf/test24-added-fn-parms-report-0.txt:
Likewise.
* tests/data/test-diff-dwarf/test32-fnptr-changes-report-0.txt:
Likewise.
* tests/data/test-diff-dwarf/test33-fnref-changes-report-0.txt:
Likewise.
* tests/data/test-diff-dwarf/test41-PR20476-hidden-report-0.txt:
Likewise.
* tests/data/test-diff-dwarf/test5-report.txt: Likewise.
* tests/data/test-diff-filter/test-PR26739-2-report-0.txt:
Likewise.
* tests/data/test-diff-filter/test26-qualified-redundant-node-report-0.txt:
Likewise.
* tests/data/test-diff-filter/test26-qualified-redundant-node-report-1.txt:
Likewise.
* tests/data/test-diff-filter/test30-pr18904-rvalueref-report0.txt:
Likewise.
* tests/data/test-diff-filter/test30-pr18904-rvalueref-report1.txt:
Likewise.
* tests/data/test-diff-filter/test30-pr18904-rvalueref-report2.txt:
Likewise.
* tests/data/test-diff-filter/test31-pr18535-libstdc++-report-0.txt:
Likewise.
* tests/data/test-diff-filter/test31-pr18535-libstdc++-report-1.txt:
Likewise.
* tests/data/test-diff-filter/test35-pr18754-no-added-syms-report-0.txt:
Likewise.
* tests/data/test-diff-filter/test35-pr18754-no-added-syms-report-1.txt:
Likewise.
* tests/data/test-diff-filter/test41-report-0.txt: Likewise.
* tests/data/test-diff-filter/test6-report.txt: Likewise.
* tests/data/test-diff-filter/test7-report.txt: Likewise.
* tests/data/test-diff-pkg/GtkAda-gl-2.24.2-29.fc29.x86_64--2.24.2-30.fc30.x86_64-report-0.txt:
Likewise.
* tests/data/test-diff-pkg/PR24690/PR24690-report-0.txt: Likewise.
* tests/data/test-diff-pkg/libsigc++-2.0-0c2a_2.4.0-1_amd64--libsigc++-2.0-0v5_2.4.1-1ubuntu2_amd64-report-0.txt:
Likewise.
* tests/data/test-diff-pkg/libxcrypt-4.1.1-6.el8.x86_64--libxcrypt-compat-4.4.18-3.el9.x86_64-report-1.txt:
Likewise.
* tests/data/test-diff-pkg/spice-server-0.12.4-19.el7.x86_64-0.12.8-1.el7.x86_64-report-2.txt:
Likewise.
* tests/data/test-diff-pkg/spice-server-0.12.4-19.el7.x86_64-0.12.8-1.el7.x86_64-report-3.txt:
Likewise.
* tests/data/test-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-pkg-ctf/gmp-6.x.x86_64-report-0.txt:
Likewise.
* tests/data/test-diff-pkg-ctf/test-rpm-report-0.txt: Likewise.
* tests/data/test-diff-suppr/test0-type-suppr-report-0.txt:
Likewise.
* tests/data/test-diff-suppr/test0-type-suppr-report-3.txt:
Likewise.
* tests/data/test-diff-suppr/test0-type-suppr-report-5.txt:
Likewise.
* tests/data/test-diff-suppr/test0-type-suppr-report-7.txt:
Likewise.
* tests/data/test-diff-suppr/test15-suppr-added-fn-report-0.txt:
Likewise.
* tests/data/test-diff-suppr/test15-suppr-added-fn-report-2.txt:
Likewise.
* tests/data/test-diff-suppr/test15-suppr-added-fn-report-5.txt:
Likewise.
* tests/data/test-diff-suppr/test16-suppr-removed-fn-report-0.txt:
Likewise.
* tests/data/test-diff-suppr/test16-suppr-removed-fn-report-3.txt:
Likewise.
* tests/data/test-diff-suppr/test16-suppr-removed-fn-report-5.txt:
Likewise.
* tests/data/test-diff-suppr/test27-add-aliased-function-report-0.txt:
Likewise.
* tests/data/test-diff-suppr/test27-add-aliased-function-report-3.txt:
Likewise.
* tests/data/test-diff-suppr/test27-add-aliased-function-report-4.txt:
Likewise.
* tests/data/test-diff-suppr/test28-add-aliased-function-report-0.txt:
Likewise.
* tests/data/test-diff-suppr/test28-add-aliased-function-report-1.txt:
Likewise.
* tests/data/test-diff-suppr/test28-add-aliased-function-report-2.txt:
Likewise.
* tests/data/test-diff-suppr/test28-add-aliased-function-report-4.txt:
Likewise.
* tests/data/test-diff-suppr/test28-add-aliased-function-report-5.txt:
Likewise.
* tests/data/test-diff-suppr/test30-report-0.txt: Likewise.
* tests/data/test-diff-suppr/test32-report-0.txt: Likewise.
* tests/data/test-diff-suppr/test32-report-1.txt: Likewise.
* tests/data/test-diff-suppr/test44-suppr-sym-name-not-regexp-report-1.txt:
Likewise.
* tests/data/test-fedabipkgdiff/vte291-0.39.1-1.fc22.x86_64--vte291-0.39.90-1.fc22.x86_64-report-0.txt:
Likewise.
* tests/data/test-read-ctf/test9.o.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/test-libaaudio.so.abi: Likewise.
* tests/data/test-read-dwarf/test-libandroid.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/test19-pr19023-libtcmalloc_and_profiler.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.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
11 months agoabilint: Alphabetically sort programs options
Dodji Seketeli [Thu, 30 Nov 2023 16:57:21 +0000 (17:57 +0100)]
abilint: Alphabetically sort programs options

It's a mess to find an option you are looking for both in the manual
or when doing abilint --help.  So how about sorting the options of the
various libabigail programs, starting from abilint?  Here we go.

* doc/manuals/abilint.rst: Alphabetically sort options in the
manual.
* tools/abilint.cc (display_usage): Likewise for the help strings.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
11 months agoabilint: Support --annotate
Dodji Seketeli [Tue, 31 Oct 2023 17:11:52 +0000 (18:11 +0100)]
abilint: Support --annotate

It turns out abilint doesn't support the "--annotate" option like
abidw does.  Annoying.  Added thus.

* tools/abilint.cc (options::annotate): Define new data member.
(options::options): Initialize.
(display_usage): Add help string.
(parse_command): Support the --annotate command options.
(main): Set the annotate option on the context.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
11 months agosuppression: Add "has_strict_flexible_array_data_member_conversion" property
Dodji Seketeli [Sat, 4 Nov 2023 00:47:57 +0000 (17:47 -0700)]
suppression: Add "has_strict_flexible_array_data_member_conversion" property

In the past, it was common to have a "fake flex array" at the end of a
structure. Like this:

Nowadays, with improved compiler support, it's more common to use a real
flex array. As this is a common change which changes ABI representation
in a compatible way, we should have a suppression for it.

For example, if you have a change like this:

struct foo
{
  int x;
  int flex[1];
};

...

struct foo
{
  int x;
  int flex[];
};

abidiff reports:

  [C] 'struct foo' changed:
    type size changed from 64 to 32 (in bits)
    1 data member change:
      type of 'int flex[1]' changed:
        type name changed from 'int[1]' to 'int[]'
        array type size changed from 32 to 'unknown'
        array type subrange 1 changed length from 1 to 'unknown'

With a new has_strict_flexible_array_data_member_conversion property,
users can specify a suppression which stops abidiff from emitting
this diff for any "fake" flex arrays being converted to real ones:

[suppress_type]
  type_kind = struct
  has_size_change = true
  has_strict_flexible_array_data_member_conversion = true

* include/abg-comp-filter.h (has_strict_fam_conversion): Declare
new functions.
* include/abg-fwd.h
(ir::has_fake_flexible_array_data_member): Declare new accessor
functions.
* include/abg-suppression.h
(type_suppression::{,set_}has_strict_fam_conversion): Declare new
accessor functions.
* src/abg-comp-filter.cc (has_strict_fam_conversion): Define new
functions.
* src/abg-ir.cc
(ir::has_fake_flexible_array_data_member): Define new accessor
functions.
* src/abg-suppression-priv.h
(type_suppression::priv::has_strict_fam_conv_): Define new
data member.
* src/abg-suppression.cc
(type_suppression::{,set_}has_strict_fam_conversion): Define new
accessor functions.
(type_suppression::suppresses_diff): For a type suppression to
match a fake flex array conversion, either the size of the type
hasn't change or has_size_change must be true and then the type
must change from a fake flex array to a real flex array.
(read_type_suppression): Parse the new
'has_strict_flexible_array_data_member_conversion' property to
set the type_suppression::set_has_strict_fam_conversion property.
* doc/manuals/libabigail-concepts.rst: Add an entry for the new
'has_strict_flexible_array_data_member_conversion' property.
* tests/data/test-diff-suppr/test-has-strict-flexible-array-data-member-conversion-{1,2}.suppr:
Add new test suppression files.
* tests/data/test-diff-suppr/test-has-strict-flexible-array-data-member-conversion-report-{1,2}.txt:
Add new test reference output files.
* tests/data/test-diff-suppr/test-has-strict-flexible-array-data-member-conversion-v{0,1}.c:
Add source code for new binary test input files.
* tests/data/test-diff-suppr/test-has-strict-flexible-array-data-member-conversion-v{0,1}.o:
Add new binary test input files.
* tests/data/Makefile.am: Add the new test files to the source
distribution.
* tests/test-diff-suppr.cc (in_out_specs): Add the new test input
files to this test harness.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Signed-off-by: John Moon <quic_johmoo@quicinc.com>
11 months agoBug 31045 - Don't try setting translation unit for unique types
Dodji Seketeli [Wed, 8 Nov 2023 13:46:04 +0000 (14:46 +0100)]
Bug 31045 - Don't try setting translation unit for unique types

Unique types (void, pointer to void and variadic parameter types)
should not have their translation unit set whenever they are being
added to a scope.  This is because they are supposed to be created
independently from any translation unit, even if technically, they are
set to the translation unit they are referenced from, for the first
time.

To handle this, a new function maybe_set_translation_unit is created
to handle the setting of the translation unit for decls added to a
scope by scope_decl::{add,insert}_member_decl.  That new function
asserts that unique types should have their translation unit be set.

* src/abg-ir.cc (maybe_set_translation_unit): Define new static
function.
(scope_decl::{add,insert}_member_decl): Use it.
* tests/data/test-abidiff-exit/PR31045/zfs-abigail-2.4/libnvpair.{abi,so,suppr}:
New test input files.
* tests/data/test-abidiff-exit/PR31045/zfs-abigail-2.4/test-PR31045-report-1.txt:
New reference test output.
* tests/data/Makefile.am: Add the new test material above to
source distribution.
* tests/test-abidiff-exit.cc (in_out_specs): Add the input above
to this test harness.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Tested-by: Paolo Pisati <paolo.pisati@canonical.com>
12 months agoconfigure: Bump development version to 2.5
Dodji Seketeli [Fri, 20 Oct 2023 22:33:58 +0000 (00:33 +0200)]
configure: Bump development version to 2.5

* configure.ac: Bump version to 2.5

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
12 months agoChangeLog: Update for 2.4 release libabigail-2.4
Dodji Seketeli [Fri, 20 Oct 2023 16:36:08 +0000 (18:36 +0200)]
ChangeLog: Update for 2.4 release

* ChangeLog: Update automatically with make update-changelog.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
12 months agoUpdate NEWS file for 2.4 release
Dodji Seketeli [Fri, 20 Oct 2023 16:07:16 +0000 (18:07 +0200)]
Update NEWS file for 2.4 release

* NEWS: Update for 2.4 release.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
12 months agodoc/website/mainpage.txt: Update for 2.4 release
Dodji Seketeli [Fri, 20 Oct 2023 16:39:26 +0000 (18:39 +0200)]
doc/website/mainpage.txt: Update for 2.4 release

* doc/website/mainpage.txt: Update download link for 2.4 release.
Use the .xz tarball.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
12 months agogen-changelog.py: Remove long standing debugging output
Dodji Seketeli [Fri, 20 Oct 2023 16:34:08 +0000 (18:34 +0200)]
gen-changelog.py: Remove long standing debugging output

* gen-changelog.py (gen-changelog.py): Remove debugging output.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
12 months agogen-changelog.py: Fix a long standing typo
Dodji Seketeli [Fri, 20 Oct 2023 16:19:48 +0000 (18:19 +0200)]
gen-changelog.py: Fix a long standing typo

While looking at something else, I stumbled upon a long standing
copy-paste typo where we refer to original GNET (from gstreamer) in
lieu of libabigail.  Fixed thus.

* gen-changelog.py (get_rel_tags): It's libabigail, not GNET.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
12 months agogen-changelog.py: Don't escaping '/' with '\' in regexp
Dodji Seketeli [Fri, 20 Oct 2023 16:16:12 +0000 (18:16 +0200)]
gen-changelog.py: Don't escaping '/' with '\' in regexp

Python 3.12 on Fedora 39 complains that we should not escape the '/' character with
a '\' character in a regular expression.  Fixed thus.

* gen-changelog.py (get_rel_tags): Do not escape '/' with '\' in
regexp.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
12 months agoir: Fix compilation error with GCC 4.8.5
Dodji Seketeli [Fri, 20 Oct 2023 15:15:57 +0000 (17:15 +0200)]
ir: Fix compilation error with GCC 4.8.5

* src/abg-ir.cc (enum_type_decl::get_sorted_enumerators): Add
const to parameters of the lambda function.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
12 months agosuppression: Make the "end" data member offset selector be named boundary
Dodji Seketeli [Wed, 18 Oct 2023 09:57:56 +0000 (11:57 +0200)]
suppression: Make the "end" data member offset selector be named boundary

Now that we have what is called a "named boundary", introduced by
commit [1], this patch re-writes the handling of the "end" data member
offset selector (used in expressions like: offset_of(end) in
suppression specifications) in terms of the new "named boundary"
infrastructure.  In other words, the "end" keyword is now a named
boundary constant, just like the
"offset_of_flexible_array_data_member" is a named boundary constant.

[1]: The patch that introduced the concept of "named boundary" is this
one:

    commit b12ba51e62de7c61526bd0a0cac6cc9bcf28fdee
    Author: Dodji Seketeli <dodji@redhat.com>
    Date:   Thu Oct 5 13:32:21 2023 +0200

Support suppressing data member insertion before a flexible array member

* src/abg-suppression.cc (END_STRING): Define new static string
constant accessor.
(type_suppression::insertion_range::eval_boundary): Eval the "end"
named boundary as having a numerical value of
std::numeric_limits<uint64_t>::max().
(read_type_suppression): Parse the "end" token as a named
boundary.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
12 months agoSupport suppressing data member insertion before a flexible array member
Dodji Seketeli [Thu, 5 Oct 2023 11:32:21 +0000 (13:32 +0200)]
Support suppressing data member insertion before a flexible array member

Consider this code example:

    $ cat test-v0.c
     1 struct foo
     2 {
     3   int member0;
     4   char pad[]; /* <-- flexible array member.  */
     5 };
     6
     7 void
     8 foo(struct foo * p __attribute__((unused)))
     9 {
    10 }
    $

Consider this new version of the code where a data member has been
added right before the flexible array member:

    $ cat -n test-v1.c
     1 struct foo
     2 {
     3   int member0;
     4   char member1; /*<-- added member.  */
     5   char pad[]; /* <-- flexible array member.  */
     6 };
     7
     8 void
     9 foo(struct foo * p __attribute__((unused)))
    10 {
    11 }
    $

Here is what abidiff reports about the change:

    $ abidiff test-v0.o test-v1.o || echo "returned value: $?"
    Functions changes summary: 0 Removed, 1 Changed, 0 Added function
    Variables changes summary: 0 Removed, 0 Changed, 0 Added variable

    1 function with some indirect sub-type change:

      [C] 'function void foo(foo*)' at test-v0.c:8:1 has some indirect sub-type changes:
parameter 1 of type 'foo*' has sub-type changes:
  in pointed to type 'struct foo' at test-v1.c:1:1:
    type size changed from 32 to 64 (in bits)
    1 data member insertion:
      'char member1', at offset 32 (in bits) at test-v1.c:4:1
    1 data member change:
      'char pad[]' offset changed from 32 to 40 (in bits) (by +8 bits)

    returned value: 4
    $

This patch allows users to suppress this change report using a new
property value to the "has_data_member_inserted_at" property of the
[suppress_type] directive.  The resulting suppression specification
reads:

    $ cat -n foo.suppr
 1 [suppress_type]
 2  type_kind = struct
         3       name = foo
 4  has_data_member_inserted_at = offset_of_flexible_array_data_member
 5  has_size_change = yes
    $

With this suppression specification the previous command now gives:

    $ abidiff --suppr foo.suppr test-v0.o test-v1.o && echo "returned value: $?"
    Functions changes summary: 0 Removed, 0 Changed (1 filtered out), 0 Added function
    Variables changes summary: 0 Removed, 0 Changed, 0 Added variable

    returned value: 0
    $

The patch adds new test cases and updates the documentation to add a
mention to the new offset_of_flexible_array_data_member named
boundary.

* doc/manuals/libabigail-concepts.rst: Add documentation for the
new "offset_of_flexible_array_data_member" named boundary.
* include/abg-fwd.h (has_flexible_array_data_member): Declare new
function.
* src/abg-ir.cc (has_flexible_array_data_member): Define it.
* include/abg-suppression.h
(type_suppression::insertion_range::named_boundary_sptr): Define
new typedef.
(type_suppression::insertion_range::create_named_boundary): Declare
new static function member function.
(is_named_boundary): Declare new function.
(class type_suppression::insertion_range::named_boundary): Declare
new type.
* src/abg-suppression.cc
(struct type_suppression::insertion_range::named_boundary::priv):
Define new private type.
(OFFSET_OF_FLEXIBLE_ARRAY_DATA_MEMBER_STRING): Define new static
constant string getter function.
(type_suppression::insertion_range::create_named_boundary): Define
new static member function.
(is_named_boundary): Define new function.
(read_type_suppression): Parse the new
"offset_of_flexible_array_data_member" named boundary.
(type_suppression::insertion_range::eval_boundary): Evaluate the
new "offset_of_flexible_array_data_member" named boundary.
* tests/data/test-abidiff-exit/test-fam1-report-[1-5].txt: New
reference test output.
* tests/data/test-abidiff-exit/test-fam2-report-1.txt: Likewise.
* tests/data/test-abidiff-exit/test-fam1-suppr-[1-4].abignore: New test
suppression specification.
* tests/data/test-abidiff-exit/test-fam{1,2}-v{0,1}.o: New test input
binaries.
* tests/data/test-abidiff-exit/test-fam{1,2}-v{0,1}.c: Source code of
the test input binaries.
* tests/data/Makefile.am: Add the new test material to the source
distribution.
* tests/test-abidiff-exit.cc (in_out_specs): Add the new test
input to this harness.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
12 months agocomparison: Represent changed unreachable anonymous unions, structs & enums
Dodji Seketeli [Fri, 13 Oct 2023 09:06:08 +0000 (11:06 +0200)]
comparison: Represent changed unreachable anonymous unions, structs & enums

Following the changes to represent changed anonymous unreachable enums,
this patch does the same for anonymous unreachable unions, classes and
structs.

Basically, without this patch, this change:

    union
    {
      int a;
      int b;
    };

    ------

    union
    {
      int a;
      int b;
      int c;
    };

yields:

    1 removed type unreachable from any public interface:

      [D] 'union {int a; int b;}' at test_1.c:1:1

    1 added type unreachable from any public interface:

      [A] 'union {int a; int b; int c;}' at test_2.c:1:1

But with the patch, it does yield:

    1 changed type unreachable from any public interface:

      [C] 'union {int a; int b;}' changed:
type size hasn't changed
1 data member insertion:
  'int c' at test-anon-union-v1.c:5:1
type changed from:
  union {int a; int b;}
to:
  union {int a; int b; int c;}

* include/abg-fwd.h (class_or_union_types_of_same_kind)
(is_data_member_of_anonymous_class_or_union): Declare new
functions.
* include/abg-ir.h (lookup_data_member): Likewise, declare a new overload.
* src/abg-ir.cc (class_or_union_types_of_same_kind)
(lookup_data_member, is_data_member_of_anonymous_class_or_union):
Define news functions & overloads.
* src/abg-reporter-priv.cc (represent): When representing a change
in the name of a data member, if the context is an anonymous type,
use the non-qualified name of the data member, not its qualified
name.
* src/abg-comparison.cc
(corpus_diff::priv::ensure_lookup_tables_populated): Handle
deleted/added anonymous enums, unions, classes and structs
similarly.  That is, if an anonymous type was removed and another
one got added, if they both have data members (or enumerators) in
common, then we are probably looking at an anonymous type that was
changed.  This is because these anonymous types are named using
their flat representation.
* tests/data/test-abidiff-exit/test-anon-types-report-1.txt: New
reference test comparison output.
* tests/data/test-abidiff-exit/test-anon-types-v{0,1}.o: New
binary tests input files.
* tests/data/test-abidiff-exit/test-anon-types-v{0,1}.c: Source
code of new binary test input.
* tests/data/Makefile.am: Add the new test material above to
source distribution.
* tests/test-abidiff-exit.cc (in_out_specs): Add the test inputs
above to this test harness.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
12 months agoir,comparison: Represent changed anonymous enums
Dodji Seketeli [Sat, 23 Sep 2023 14:22:14 +0000 (16:22 +0200)]
ir,comparison: Represent changed anonymous enums

Now that added/removed non-reachable anonymous enums is supported, we
want to represent changing an anonymous enum.

Strictly speaking, adding or removing an enumerator from an anonymous
enum is represented as deleting of the anonymous enum in the old
state and the addition of an anonymous enum in the new state.

This patch analyses the added/removed anonymous enums and if the old
enum has enumerators contained in the new one, then it assumes we are
looking at anonymous enum change.

* include/abg-ir.h (is_enumerator_present_in_enum): Declare new
public function.
* src/abg-ir.cc (is_enumerator_present_in_enum): Turn this
static function into a public one.
* src/abg-comparison.cc
(corpus_diff::priv::ensure_lookup_tables_populated): Detect that
an removed/added anonymous enum is actually a changed anonymous
enum and represent it as such.
* tests/data/test-abidiff-exit/test-anonymous-enums-change-report-v{0,1}.txt:
New reference test output files.
* tests/data/test-abidiff-exit/test-anonymous-enums-change-v{0,1}.c:
Source code for the some input test binary.
* tests/data/test-abidiff-exit/test-anonymous-enums-change-v{0,1}.o:
New test input binaries.
* tests/data/Makefile.am: Add the new test materials above to
source distribution.
* tests/test-abidiff-exit.cc (in_out_specs): Add the new test
input to the harness.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
12 months agoir,comparison,corpus: Better support anonymous enums comparison
Dodji Seketeli [Fri, 22 Sep 2023 11:11:56 +0000 (13:11 +0200)]
ir,comparison,corpus: Better support anonymous enums comparison

Anonymous enums are designated using their internal names which are
automatically generated.  The problem however is that whenever a new
anonymous enum gets inserted in the translation unit, that can
randomly change the name of existing anonymous enums.  This makes
reporting of changes in anonymous enums essentially useless.

To address this issue, this patch uses flat representation for
anonymous enums, for the purpose of designating them outside of the
context of type canonicalization.  This is like what is done already
for anonymous classes and unions.

* include/abg-fwd.h (get_enum_flat_representation)
(get_class_or_enum_flat_representation): Declare new functions.
* include/abg-ir.h (enum_type_decl::get_sorted_enumerators):
Declare new member functions.
* src/abg-comparison.cc
(corpus_diff::priv::{ensure_lookup_tables_populated,
added_unreachable_type_is_suppressed,
deleted_unreachable_type_is_suppressed,
record_type_as_reachable_from_public_interfaces}): Use
non-internal pretty representation to designate ABI artifacts so
that anonymous enums get designated by their flat representation.
* src/abg-corpus.cc (corpus::type_is_reachable_from_public_interfaces):
Likewise.
* src/abg-ir.cc (get_type_name): The type name of an anonymous
enum or class should is now the flat representation if we are not
in the context of type canonicalization.
(enum_type_decl::get_pretty_representation): If we are not in the
context of type canonicalization, the pretty representation of an
enum is its flat representation.
(get_enum_flat_representation)
(get_class_or_enum_flat_representation): Define new functions.
(enum_type_decl::get_sorted_enumerators): Likewise.
* tests/data/test-annotate/libtest23.so.abi: Adjust.
* tests/data/test-annotate/test-anonymous-members-0.o.abi: Likewise.
* tests/data/test-annotate/test15-pr18892.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/test43-PR22913-report-0.txt:
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/test-libandroid.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/test22-pr19097-libstdc++.so.6.0.17.so.abi:
Likewise.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
12 months agodefault-reporter,reporter-priv: Do not report names of anonymous enums
Dodji Seketeli [Tue, 26 Sep 2023 07:23:57 +0000 (09:23 +0200)]
default-reporter,reporter-priv: Do not report names of anonymous enums

When reporting changes of anonymous enums, do not try to report their
qualified name as that doesn't make any sense -- they are anonymous.

Similarly, in report_name_size_and_alignment_changes do not try to
report about changes in the name of an anonymous enum.

* src/abg-default-reporter.cc (default_reporter::report): In the
overload for enum_diff, do not get the qualified name of anonymous
enums.
* src/abg-reporter-priv.cc
(report_name_size_and_alignment_changes): Do not report about name
changes for anonymous enums.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
12 months agosuppression: Add "changed_enumerators_regexp" property
John Moon [Thu, 28 Sep 2023 17:43:44 +0000 (10:43 -0700)]
suppression: Add "changed_enumerators_regexp" property

Currently, users are able to suppress changes to enumerator variants
matching names specified in "changed_enumerators", but can't specify
regular expressions.

A common pattern when using enums is to have the final enum variant
labeled as "*_MAX" or "*_LAST" so that users of the enum can have a
way to determine how many variants there are. In these cases, when
expanding an enum, the last variant will change, but that's an
expected result that users may not want to flag as an ABI-breaking
change.

For example, if you have a change like this:

enum foo {
        FOO,
        BAR,
        FOOBAR_MAX,
};

...

enum foo {
        FOO,
        BAR,
        BAZ,
        FOOBAR_MAX,
};

abidiff reports:

1 changed type unreachable from any public interface:

  [C] 'enum foo' changed:
    type size hasn't changed
    1 enumerator insertion:
      'foo::BAZ' value '2'
    1 enumerator change:
      'foo::FOOBAR_MAX' from value '2' to '3' at test_2.c:1:1

With a new changed_enumerators_regexp property, users can specify a
suppression which stops abidiff from emitting this diff for any
members which match the regular expressions in the list:

[suppress_type]
  type_kind = enum
  changed_enumerators_regexp = .*_MAX$, .*_LAST$, .*_NUM$, .*_NBITS$

* include/abg-suppression.h
(type_suppression::{g,s}et_changed_enumerators_regexp): Declare new
accessor functions.
* src/abg-suppression-priv.h
(type_suppression::priv::changed_enumerators_regexp_): Define new
data member.
* src/abg-suppression.cc
(type_suppression::{g,s}et_changed_enumerators_regexp): Define new
accessor function.
(type_suppression::suppresses_diff): For a type suppression to
match an enum_diff, the names of all changed enumerators must
match either the names returned by
type_suppression::get_changed_enumerator_names or one of the
regexps returned by the new member function
type_suppression::get_changed_enumerators_regexp.
(read_type_suppression): Parse the new
'changed_enumerators_regexp' property to set the
type_suppression::get_changed_enumerators_regexp property.
* doc/manuals/libabigail-concepts.rst: Add an entry for the new
'changed_enumerators_regexp' property.
* tests/data/test-diff-suppr/test40.1-enumerator-changes-enumerator-changes-[1-5].suppr:
Add new test suppression files.
* tests/data/test-diff-suppr/test40.1-enumerator-changes-enumerator-changes-report-[0-5].txt:
Add new test reference output files.
* tests/data/test-diff-suppr/test40.1-enumerator-changes-enumerator-changes-v{0,1}.c:
Add source code for new binary test input files.
* tests/data/test-diff-suppr/test40.1-enumerator-changes-enumerator-changes-v{0,1}.o:
Add new binary test input files.
* tests/data/Makefile.am: Add the new test files to the source
distribution.
* tests/test-diff-suppr.cc (in_out_specs): Add the new test input
files to this test harness.

Signed-off-by: John Moon <quic_johmoo@quicinc.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
12 months agoBug 30971 - Wrong interpretation of "has_data_member_inserted_at"
Dodji Seketeli [Mon, 16 Oct 2023 12:10:50 +0000 (14:10 +0200)]
Bug 30971 - Wrong interpretation of "has_data_member_inserted_at"

Consider the following construct:

    struct foo
    {
      long x;
      long y;
    };

Then change one of the types (but keep the size the same):

    struct foo
    {
      long x;
      unsigned long y;
    };

If I abidiff this with no suppressions, I get:

      [C] 'struct foo' changed:
type size hasn't changed
1 data member change:
  type of 'long int y' changed:
    type name changed from 'long int' to 'unsigned long int'
    type size hasn't changed

However, it seems like if I add any struct suppression involving data member
insertions, it filters out the change. For example:

    [suppress_type]
    type_kind = struct
    has_data_member_inserted_at = offset_of(not_present)

The "not_present" member isn't in "struct foo", so I would expect the diff to
still be emitted, but it is not:

    Functions changes summary: 0 Removed, 0 Changed, 0 Added function
    Variables changes summary: 0 Removed, 0 Changed, 0 Added variable
    Unreachable types summary: 0 removed, 0 changed (1 filtered out), 0 added type

This is because during the evaluation of the
"has_data_member_inserted_at" property, we fail to take into account
that if no data member got inserted, evaluation of the
"has_data_member_inserted_at" predicate is falsified, and thus, the
type suppression is falsified.

While looking at this, I also realized that when a data member
replaces another one, we fail to consider that change as a data member
insertion and so the evaluation of the "has_data_member_inserted_at"
predicate is wrongly falsified.

This patch fixes these two related issues.

* include/abg-comparison.h
(class_or_union_diff::changed_data_members): Declare new accessor.
function.
* src/abg-comparison.cc
(class_or_union_diff::changed_data_members): Define new accessor.
function.
* src/abg-suppression.cc (type_suppression::suppresses_diff): If
the type suppression specification contains a
has_data_member_inserted_* property and yet the class contains no
data member inserted or replacing an existing one, then the type
suppression is falsified in the context of the current change.
Also, when a data member replaces an existing one, consider that
as an insertion for which the has_data_member_inserted_* predicate
should be evaluated.  Stop considering deleted data members
because considering replaced data member is really what we meant.
* tests/data/test-diff-suppr/test-has-data-member-inserted-at-2-report.[1-3].txt:
New reference test output files.
* tests/data/test-diff-suppr/test-has-data-member-inserted-at-2-report.txt:
Likewise.
* tests/data/test-diff-suppr/test-has-data-member-inserted-at-{2,3}-v{0,1}.o:
New input test binaries.
* tests/data/test-diff-suppr/test-has-data-member-inserted-at-{2,3}-v{0,1}.c:
Source code of the new input test binaries.
* tests/data/test-diff-suppr/test-has-data-member-inserted-at-2.2.suppr:
New input test suppression specification.
* tests/data/test-diff-suppr/test-has-data-member-inserted-at-2.suppr: Likewise.
* tests/data/Makefile.am: Add the new test material above to
source distribution.
* tests/test-diff-suppr.cc (in_out_specs): Add the test input
above to this test harness.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Tested-by: John Moon <quic_johmoo@quicinc.com>
12 months agoir: Remove redundant virtual member functions
Dodji Seketeli [Thu, 12 Oct 2023 11:28:43 +0000 (13:28 +0200)]
ir: Remove redundant virtual member functions

G++ 13.2.1 complains that virtual member functions
{qualified_type_def,pointer_type_def,class_or_union}::operator!= are
redundant with type_base::operator!=, and rightfully so.  This patch
removes those useless virtual member functions.

* include/abg-ir.h
({qualified_type_def,pointer_type_def,class_or_union}::operator!=):
Remove these redundant virtual data members.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
12 months agoinit: Fix thinko in apidoc
Dodji Seketeli [Wed, 11 Oct 2023 11:19:48 +0000 (13:19 +0200)]
init: Fix thinko in apidoc

* src/abg-ini.cc (read_context::read_string): A string is a
contiguous vector of "property value" characters.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
12 months agoini: Support '[' and ']' in arguments of function call expressions
Dodji Seketeli [Wed, 11 Oct 2023 11:12:55 +0000 (13:12 +0200)]
ini: Support '[' and ']' in arguments of function call expressions

Consider the suppression specification below:

    [suppress_type]
      type_kind = struct
      has_data_member_inserted_at = offset_of_first_data_member_regexp(.*p[0-9]?$)

The parser wrongly considers that in the regular expression
".*p[0-9]?$", the characters '[' and ']' should be escaped.  Fixed
thus.

* src/abg-ini.cc (char_is_function_name_char): The only delimiters
should be the '(' and ')' characters.
* tests/data/test-diff-suppr/test-has-data-member-inserted-at-1-report-2.txt:
New reference test output.
* tests/data/test-diff-suppr/test-has-data-member-inserted-at-1.2.suppr:
New suppression specification.
* tests/data/Makefile.am: Add the new test material above to
source distribution.
* tests/test-diff-suppr.cc (in_out_specs): Add the new test
material above to this test harness.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
12 months agoBug 30959 - Crash on malformed fn call expression
Dodji Seketeli [Wed, 11 Oct 2023 10:51:47 +0000 (12:51 +0200)]
Bug 30959 - Crash on malformed fn call expression

The code fails to ignore a function call expression that is considered
malformed by the type suppression parser.  Fixed thus.

* src/abg-suppression.cc
(type_suppression::insertion_range::eval_boundary): If the
function call expression is considered malformed, then do not
crash.
* tests/data/test-diff-suppr/test-has-data-member-inserted-at-1-report-1.txt:
New reference test output.
* tests/data/test-diff-suppr/test-has-data-member-inserted-at-1-v{0,1}.c:
Source code of the new input binaries.
* tests/data/test-diff-suppr/test-has-data-member-inserted-at-1-v{0,1}.o:
New input binaries.
* tests/data/test-diff-suppr/test-has-data-member-inserted-at-1.1.suppr:
New test suppression specification.
* tests/data/Makefile.am: Add the new test material above to the
source distribution.
* tests/test-diff-suppr.cc (in_out_specs): Add the new tests to
this harness.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
13 months agosuppression: Fix a typo in apidoc
Dodji Seketeli [Thu, 5 Oct 2023 15:07:25 +0000 (17:07 +0200)]
suppression: Fix a typo in apidoc

* src/abg-suppression.cc (is_fn_call_expr_boundary): Fix a typo in
the apidoc.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
13 months agosuppression: Fix indentation
Dodji Seketeli [Thu, 5 Oct 2023 15:04:44 +0000 (17:04 +0200)]
suppression: Fix indentation

* include/abg-suppression.h: Fix indentation of the
type_suppression::insertion_range::end() accessor.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
13 months agodoc/manuals/libabigail-concepts.rst: Fix typo
Dodji Seketeli [Thu, 5 Oct 2023 15:03:32 +0000 (17:03 +0200)]
doc/manuals/libabigail-concepts.rst: Fix typo

* doc/manuals/libabigail-concepts.rst: Fix a typo in the doc for
the "end" named boundary.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
13 months agoabg-comparison[-priv]: Better detection of incompatible unreachable type changes
Dodji Seketeli [Tue, 26 Sep 2023 07:44:28 +0000 (09:44 +0200)]
abg-comparison[-priv]: Better detection of incompatible unreachable type changes

Whenever there is a change in unreachable type,
corpus_diff::has_incompatible_changes always reports that the
corresponding diff node carries an incompatible change.  It does this
even if the change is known to be compatible.

To be able to say if a diff node for a unreachable type carries a
compatible (not incompatible) change,
corpus_diff::has_incompatible_changes must look at the change category
of that diff node, instead of saying that any change to an unreachable
type is incompatible.

While looking at this, I noted that
corpus_diff::priv::apply_filters_and_compute_diff_stats doesn't
categorize the diffs in
corpus_diff::priv::changed_unreachable_types_, so it's not possible to
look at the categories of the changes held by that data member to see
if they are incompatible or not.

This patch thus categorizes the diff nodes held by
corpus_diff::priv::changed_unreachable_types_ and makes
corpus_diff::has_incompatible_changes look at those diff nodes to
detect if they are incompatible.

Let's see the result of this patch.

Consider the change in the input test source code from included in
this patch, from test-enumerator-changes1-v0.c to test-enumerator-changes1-v1.c:

    $ diff -u test-enumerator-changes1-v0.c test-enumerator-changes1-v1.c
    --- test-enumerator-changes1-v0.c 2023-10-04 11:25:30.722989530 +0200
    +++ test-enumerator-changes1-v1.c 2023-10-04 11:25:30.722989530 +0200
    @@ -1,13 +1,14 @@
     /*
      *
      * Compile this with:
    - *    gcc -g -c -fno-eliminate-unused-debug-types test-enumerator-changes1-v0.c
    + *    gcc -g -c -fno-eliminate-unused-debug-types test-enumerator-changes1-v1.c
      */

     enum foo
       {
 E1_O,
    -    E1_1
    +    E1_1,
    +    E1_2
       };

     void
    $

The enumerator E1_2 has been added to the 'foo' enum.

Now, let's see what abidiff prior to this patch would say about the
change between the two result binaries test-enumerator-changes1-v0.o
and test-enumerator-changes1-v1.o:

    $ abidiff --non-reachable-types --harmless test-enumerator-changes1-v0.o test-enumerator-changes1-v1.o || echo "return value: $?"
    Functions changes summary: 0 Removed, 0 Changed, 0 Added function
    Variables changes summary: 0 Removed, 0 Changed, 0 Added variable
    Unreachable types summary: 0 removed, 1 changed, 0 added type

    1 changed type unreachable from any public interface:

      [C] 'enum foo' changed:
type size hasn't changed
1 enumerator insertion:
  'foo::E1_2' value '2'

    return value: 12
    $

See the return value of 12, that is actually the bits
abigail::tools_utils::ABIDIFF_ABI_CHANGE (of value 4) and
abigail::tools_utils::ABIDIFF_ABI_INCOMPATIBLE_CHANGE (of value 8) being set.

Normally, only the bit abigail::tools_utils::ABIDIFF_ABI_CHANGE (of
value 4) should be set.

Now, let's look at what abidiff says with this patch:

    $ abidiff --non-reachable-types --harmless test-enumerator-changes1-v0.o test-enumerator-changes1-v1.o || echo "return value: $?"
    Functions changes summary: 0 Removed, 0 Changed, 0 Added function
    Variables changes summary: 0 Removed, 0 Changed, 0 Added variable
    Unreachable types summary: 0 removed, 1 changed, 0 added type

    1 changed type unreachable from any public interface:

      [C] 'enum foo' changed:
type size hasn't changed
1 enumerator insertion:
  'foo::E1_2' value '2'

    return value: 4
    $

Now the return value is 4, which is the bit
abigail::tools_utils::ABIDIFF_ABI_CHANGE being set, as we would expect
because that change is known to be not incompatible.

* Src/abg-comparison-priv.h
(corpus_diff::priv::changed_unreachable_types): Declare ...
* src/abg-comparison.cc
(corpus_diff::priv::changed_unreachable_types): ... new function.
(corpus_diff::priv::apply_filters_and_compute_diff_stats): Walk
the nodes returned by corpus_diff:priv::changed_unreachable_types
and apply the filters (including categorization filters) to them.
Also make the loop similarly applying filters to the nodes
returned by corpus_diff::priv::changed_unreachable_types_sorted be
a ranged-based one, for the sake of consistency.
(corpus_diff::has_incompatible_changes): Now that diff nodes
returned by corpus_diff::priv::changed_unreachable_types are
categorized, look at their change categories to see if they are
incompatible or not.
* tests/data/test-abidiff-exit/test-enumerator-changes1-report-1.txt:
New test output reference.
* tests/data/test-abidiff-exit/test-enumerator-changes1-v{0,1}.o:
New test input binaries.
* tests/data/test-abidiff-exit/test-enumerator-changes1-v{0,1}.c:
New source code for the new test input binaries.
* tests/data/Makefile.am: Add the new test material above to
source distribution.
* tests/test-abidiff-exit.cc (in_out_specs): Add the new test
input binaries to the test harness.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
13 months agocomparison: Always apply filters on the diff graph
Dodji Seketeli [Thu, 28 Sep 2023 15:47:25 +0000 (17:47 +0200)]
comparison: Always apply filters on the diff graph

When looking at something else, I noticed that
diff_context::maybe_apply_filters doesn't apply the filters (i.e, the
various passes) on the diff graph if all the categories of changes are
allowed, typically when --harmless is passed to abidiff.

This is wrong because even if all the categories are allowed, the
changes carried by nodes of the diff graph should still be
categorized.  This was an early optimization dating back from the
times where the filtering was slow.

* src/abg-comparison.cc (diff_context::maybe_apply_filters): Do
not get out when all the categories of diff changes are allowed.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
13 months agoir: Fix output of 'debug(enum-type)'
Dodji Seketeli [Fri, 22 Sep 2023 11:14:39 +0000 (13:14 +0200)]
ir: Fix output of 'debug(enum-type)'

The output of calling the debug function on an enum type wrongly says
that we are looking at a union.  Ooops.  Fixed thus.

* src/abg-ir.cc (get_debug_representation): Don't say 'union' when
we are looking at an enum.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
13 months agotest-abidiff-exit: Do not use debuginfo dir when its empty
Dodji Seketeli [Tue, 26 Sep 2023 07:35:53 +0000 (09:35 +0200)]
test-abidiff-exit: Do not use debuginfo dir when its empty

If the debug info dir is empty in the input test specifier, the abidiff
command should not add any --debug-info-dir{1,2} option.  Fixed thus.

* tests/test-abidiff-exit.cc (main): If debug info dir is empty in
the input test specifier, do not try to use it in the abidiff
command.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
13 months agolibabigail-concepts.rst: Remove trailing white spaces
Dodji Seketeli [Mon, 2 Oct 2023 21:23:26 +0000 (23:23 +0200)]
libabigail-concepts.rst: Remove trailing white spaces

* doc/manuals/libabigail-concepts.rst: Remove trailing white
spaces.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
13 months agolibabigail-concepts.rst: Sort the properties of the directives
Dodji Seketeli [Mon, 2 Oct 2023 10:00:59 +0000 (12:00 +0200)]
libabigail-concepts.rst:  Sort the properties of the directives

In documentation for the suppression directives, the properties of the
directives were not sorted, making it hard to look
for a particular one.

This patch sorts the properties in the lexicographic order.

* doc/manuals/libabigail-concepts.rst: Sort the properties in the
lexicographic order.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
13 months agoconfigure,test-diff-pkg.cc: Handle symlinks presence in dist tarball
Dodji Seketeli [Wed, 20 Sep 2023 09:25:17 +0000 (11:25 +0200)]
configure,test-diff-pkg.cc: Handle symlinks presence in dist tarball

Since the commit below, there are tests that require symbolic links.

Unfortunately, the tar command used to construct tarballs copies the
target of a symbolic link (and thus doesn't keep the symlink) for the
purpose of greater portability, as some platforms don't support
symbolic links.

This patch uses a tar command that keeps the symlinks in place for the
tests introduced by the commit below to keep working.  On some
platforms however, symlinks are removed from the tarball no matter
what.  In those case, the test that needs symlinks is disabled.

Here is the commit in question:

    bad389f abipkgdiff: Avoid comparing binaries that are outside of the package

* configure.ac: Use "tar -cf" instead of "tar -chf" to construct
the tarball.  Detect if the presence of the symlink in the
distribution and define the WITH_SYMLINKS_KEPT_IN_DIST
preprocessor macro accordingly.
* tests/test-diff-pkg.cc (in_out_specs): If symlinks are not
present in the tarball then the test that requires symlinks is
deactivated.  Also, fix the
data/test-diff-pkg/symlink-dir-test1/dir1 test to make it point to
the target of the symlinks directly, to avoid considering a binary
twice, in cases where symlink targets are copied.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
13 months agoelf-reader, ir: Fix compilation on GCC 4.8.5
Dodji Seketeli [Wed, 20 Sep 2023 08:57:39 +0000 (10:57 +0200)]
elf-reader, ir: Fix compilation on GCC 4.8.5

* src/abg-elf-reader.cc (reader::initialize): Use older-style
initialization to keep the old lady happy.
* src/abg-ir-priv.h (canonicalize_types): Avoid using type
deduction in this context to keep the old lady happy.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
14 months agodwarf-reader: Do not re-use typedefs in a scope
Dodji Seketeli [Tue, 15 Aug 2023 11:26:19 +0000 (13:26 +0200)]
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>
14 months agoir: Fix qualification as non-confirmed propagated canonical types
Dodji Seketeli [Tue, 15 Aug 2023 11:52:34 +0000 (13:52 +0200)]
ir: Fix qualification as non-confirmed propagated canonical types

While looking at something else, there are some types considered
having "non-confirmed propagated canonical type", even though those
types are not even canonical-type-propagated.  This patch fixes that.

That doesn't have any visible impact, but it's definitely more
correct.

* src/abg-ir.cc (return_comparison_result): A type that doesn't
have propagated canonical type can't be considered having
"non-confirmed propagated canonical type".

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
14 months agoir: Use non qualified typedef name for type canonicalization
Dodji Seketeli [Thu, 17 Aug 2023 13:37:02 +0000 (15:37 +0200)]
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>
14 months agoir: Really avoid canonicalizing decl-only classes
Dodji Seketeli [Thu, 17 Aug 2023 14:51:35 +0000 (16:51 +0200)]
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>
14 months agoir: Avoid forgetting potential seemingly duplicated member functions
Dodji Seketeli [Tue, 15 Aug 2023 11:59:40 +0000 (13:59 +0200)]
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>
14 months agoir: Fix forgetting canonicalizing some function types
Dodji Seketeli [Tue, 15 Aug 2023 11:56:47 +0000 (13:56 +0200)]
ir: Fix forgetting canonicalizing some function types

It appears some function types are not canonicalized. Fixed thus.

* src/abg-ir.cc (maybe_adjust_canonical_type): Once a missing
member function has been copied from it's destination to the
freshly canonicalized type, make sure the type of the member
function is canonicalized as well.
(copy_member_function): Bind the lifetime of the new function type
to the lifetime of the current translation unit.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
14 months agoir: Add fn types to type lookup maps
Dodji Seketeli [Mon, 24 Jul 2023 10:08:32 +0000 (12:08 +0200)]
ir: Add fn types to type lookup maps

This is a fix to an inconsistency I stumbled upon while looking at
something else.

So, function types were not being added to the type lookup maps.
Fixed this.

* src/abg-ir.cc (maybe_update_types_lookup_map): Handle function
types.
(translation_unit::bind_function_type_life_time): Update types
lookup map.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
14 months agoir: Add missing ABG_RETURN in the comparison engine
Dodji Seketeli [Tue, 15 Aug 2023 11:34:16 +0000 (13:34 +0200)]
ir: Add missing ABG_RETURN in the comparison engine

During structural type comparison, we want to be able to break on the
first occurrence of two sub-types comparing different.  This is done
by setting a breakpoint into the notify_equality_failed function that
is called by the ABG_RETURN macro in the comparison functions.

The problem is that I stumbled upon some code paths that are missing
the ABG_RETURN macro.  Fixed thus.  This will help in debugging
sessions.

* src/abg-ir.cc (equals): In the overload for function_type,
class_decl and union_decl, add a missing ABG_RETURN.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
14 months agoabipkgdiff: Avoid comparing binaries that are outside of the package
Dodji Seketeli [Tue, 5 Sep 2023 16:28:27 +0000 (18:28 +0200)]
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>
14 months ago{dwarf,elf}reader: Don't consider no symbol table as an error
Dodji Seketeli [Mon, 4 Sep 2023 16:46:49 +0000 (18:46 +0200)]
{dwarf,elf}reader: Don't consider no symbol table as an error

Some binaries don't have any symbol table.  Libabigail's ELF and DWARF
readers error out on those binaries, making fedabipkgdiff emitting an
error when performing the self-comparison of the package containing
those binaries.

This patch handles a binary having no symbol table almost as a binary
that has an empty symbol table, making abipkgdiff and fedabipkgdiff
not error out on those binaries anymore.

This makes the command below succeed:

    $ fedabipkgdiff --self-compare -a --from fc34 glibc

* src/abg-dwarf-reader.cc (reader::read_corpus): Return an empty
corpus if no symbol was found. Do not crash when no symbol table
is found.
* src/abg-elf-reader.cc (reader::read_corpus): Consider a corpus
with no symbol table as being OK.
* src/abg-reader.cc (build_elf_symbol_from_reference): Do not
crash when no symbol table is present.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
14 months agotools-utils: Avoid endless loop
Dodji Seketeli [Tue, 5 Sep 2023 16:27:29 +0000 (18:27 +0200)]
tools-utils: Avoid endless loop

* src/abg-tools-utils.cc (is_dir): Avoid endless loop.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
14 months agoabipkgdiff: Initialize libxml2 to use it in a multi-thread context
Dodji Seketeli [Wed, 30 Aug 2023 11:10:02 +0000 (13:10 +0200)]
abipkgdiff: Initialize libxml2 to use it in a multi-thread context

While running some test, I stumbled upon a transient deadlock
happening when using libxml2's text reader to create a reader from a
buffer.  After reading the documentation at
https://gitlab.gnome.org/GNOME/libxml2/-/wikis/Thread-safety, I
realized that users of the library need to initialize libxml2 before
using it in a multi-thread setting.

So this patch is providing the abigail::tools_utils::initialize()
function to be called prior to using the library.  This is going to be
the place where to perform this kind of one-time initialization.

* include/abg-tools-utils.h (initialize): Declare ...
* src/abg-tools-utils.cc (initialize): ... new function.
* tools/abipkgdiff.cc (main): Invoke the new
abigail::tools_utils::initialize() here.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
14 months agodwarf-reader: Fix some logging
Dodji Seketeli [Mon, 24 Jul 2023 09:47:16 +0000 (11:47 +0200)]
dwarf-reader: Fix some logging

* src/abg-dwarf-reader.cc
(reader::{read_debug_info_into_corpus,
canonicalize_types_scheduled}): Add missing new lines and spaces.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
14 months agodwarf-reader,ir: Make logging a property of the middle end
Dodji Seketeli [Mon, 24 Jul 2023 09:39:19 +0000 (11:39 +0200)]
dwarf-reader,ir: Make logging a property of the middle end

Add a "do-log" property to the abigail::ir::environment::priv.  That
way, we can log finer grain time stamps during type canonicalization.
This is useful for debugging.

* src/abg-dwarf-reader.cc (reader::read_debug_info_into_corpus):
Set the do_log property on the environment from the do_log
property of the reader.
* src/abg-ir-priv.h (environment::priv::do_log_): New data member.
(environment::priv::priv): Initialize it.
(environment::priv::do_log): Define new accessor method.
(canonicalize_types): Add logging.
* src/abg-ir.cc (canonicalize): Add logging to time the
canonicalization of each type.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
14 months agotools-utils: Fix indentation
Dodji Seketeli [Tue, 5 Sep 2023 16:25:22 +0000 (18:25 +0200)]
tools-utils: Fix indentation

* src/abg-tools-utils.cc (string_suffix): Fix indentation.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
14 months agoreader: fix indentation
Dodji Seketeli [Tue, 15 Aug 2023 12:11:58 +0000 (14:11 +0200)]
reader: fix indentation

* src/abg-reader.cc (build_function_type): Fix indentation.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
14 months agooperator!= fixes for C++-20
Giuliano Procida [Thu, 31 Aug 2023 15:59:15 +0000 (16:59 +0100)]
operator!= fixes for C++-20

Without these changes, more recent versions of Clang will start to
emit diagnostics:

src/abg-ir.cc:15407:13: error: member 'operator!=' found in multiple base classes of different types
 15407 |   return *l == *r;
       |             ^
src/abg-ir.cc:14123:12: note: member found by ambiguous name lookup
 14123 | type_base::operator!=(const type_base& other) const
       |            ^
src/abg-ir.cc:5162:12: note: member found by ambiguous name lookup
 5162 | decl_base::operator!=(const decl_base& other) const
      |            ^

This fix was contributed by Ilya Biryukov.

* include/abg-ir.h
(qualified_typedef): Add definition of operator!=.
(pointer_type_def): Likewise.
(reference_type_def): Likewise.
(class_or_union): Likewise.

Reported-by: Ilya Biryukov <ibiryukov@google.com>
Signed-off-by: Giuliano Procida <gprocida@google.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
15 months agoir: Remove an unnecessary comparison
Dodji Seketeli [Mon, 10 Jul 2023 14:22:45 +0000 (16:22 +0200)]
ir: Remove an unnecessary comparison

When looking at something else, I noticed that in
method_decl::set_linkage_name, we are unnecessarily testing if the
'this' pointer was equal to the pointer to the member function decl of
a member function looked up from the parent class.

This patch replaces that condition by an assert.  If the 'this'
pointer is different from the pointer to any member function decl
looked up from the parent class, then something is terribly wrong
about the integrity of the IR.

* src/abg-ir.cc (method_decl::set_linkage_name): Assert that the
'this' pointer always equals the pointer to any member function
decl looked up from the parent class.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
15 months agoreader: Fix a long standing Thinko
Dodji Seketeli [Mon, 10 Jul 2023 14:10:40 +0000 (16:10 +0200)]
reader: Fix a long standing Thinko

While looking at something else, I realized that member functions XML nodes
were not necessarily mapped to the right function declaration at
ABIXML parsing time.  Woops.

Fixed thus.

* src/abg-reader.cc (build_class_decl): Map the XML node for the
member function to the member function decl, not to the class
decl.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
15 months agoFix fedabipkgdiff configure check for Python 3.12
Yaakov Selkowitz [Fri, 7 Jul 2023 18:01:12 +0000 (14:01 -0400)]
Fix fedabipkgdiff configure check for Python 3.12

importlib is the Python 3 replacement to imp, which was deprecated in
Python 3.4 and removed in 3.12.

* configure.ac (REQUIRED_PYTHON_MODULES_FOR_FEDABIPKGDIFF):
Test for importlib.machinery instead of imp with python3.

Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
16 months agoabidiff: Add --{follow,list}-dependencies & add-binaries{1,2} support
Dodji Seketeli [Sat, 24 Jun 2023 13:51:34 +0000 (15:51 +0200)]
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>
16 months agoabidw: Add --{follow,list}-dependencies & --add-binaries support
Dodji Seketeli [Sat, 24 Jun 2023 14:10:40 +0000 (16:10 +0200)]
abidw: Add --{follow,list}-dependencies & --add-binaries support

This implements the --follow-dependencies , --list-dependencies,
--add-binaries <foo,bar,...> and --added-binaries-dir options for the
abidw command, as documented in the
README-ABIDIFF-BINARIES-SET-SUPPORT.md file.

* tools/abidw.cc (options::{added_bins_dirs, added_bins,
follow_dependencies, list_dependencies}): Add new data members.
(options::options): Initialize follow_dependencies and
list_dependencies.
(display_usage): Add usage strings for --add-binaries,
--follow-dependencies, --list-dependencies, --added-binaries-dir.
(parse_command_line): Parse options --add-binaries,
--follow-dependencies, --list-dependencies, --added-binaries-dir.
(load_corpus_and_write_abixml): Implement the --list-dependencies,
--follow-dependencies and --add-binaries sub-commands.
* doc/manuals/abidw.rst: Document the --add-binaries,
--follow-dependencies, --list-dependencies, --added-binaries-dir
options.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
16 months agocorpus,tools-utils: Support loading a corpus, its deps & other binaries
Dodji Seketeli [Sat, 24 Jun 2023 14:04:47 +0000 (16:04 +0200)]
corpus,tools-utils: Support loading a corpus, its deps & other binaries

In preparation of implementing the support for "Handling split
libraries", this patch implements the functions
tools_utils::{get_comma_separated_args_of_option,
find_file_under_dirs, add_binaries_into_corpus_group,
add_dependencies_into_corpus_group,
stick_corpus_and_binaries_into_corpus_group,
stick_corpus_and_dependencies_into_corpus_group, get_dependencies}.

Given an ABI corpus, these functions enable adding arbitrary binaries
and dependencies found in a set of directories to form a corpus group.

* include/abg-corpus.h (corpus_group::has_corpus): Declare new
member function.
* include/abg-tools-utils.h (get_comma_separated_args_of_option)
(find_file_under_dirs, get_dependencies)
(add_binaries_into_corpus_group)
(add_dependencies_into_corpus_group)
(stick_corpus_and_binaries_into_corpus_group)
(stick_corpus_and_dependencies_into_corpus_group): Declare new
functions.
* src/abg-corpus.cc (corpus_group::priv::corpora_path): Add new
data member.
(corpus_group::add_corpus):  Do not add a corpus that was already
added to the group.  Update the set of paths of added corpora so
that we can detect if a corpus has already been added.
* src/abg-tools-utils.cc (find_file_under_dir): If the file found
is a symbolic link, return it.  Otherwise if the symbolic link is
not the file we were looking for, then skip it, rather than
following it, in case it's a directory.
(get_comma_separated_args_of_option, find_file_under_dirs)
(get_dependencies, add_binaries_into_corpus_group)
(add_dependencies_into_corpus_group)
(stick_corpus_and_binaries_into_corpus_group)
(stick_corpus_and_dependencies_into_corpus_group): New functions.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
16 months agoMake fe_iface::initialize independent from the kind of interface
Dodji Seketeli [Sat, 24 Jun 2023 13:34:36 +0000 (15:34 +0200)]
Make fe_iface::initialize independent from the kind of interface

In the use case laid out by the "Library Splitting support" at
https://sourceware.org/bugzilla/show_bug.cgi?id=30034, tools might
want to be able to re-initialize a given front-end to load several
corpora in a row, independently from the kind of front-end (elf-based,
ABIXML, etc).  So we need a fe_iface::initialize() interface that is
similar to the elf_based_reader::initialize() interface but, unlike
that one, it should not depend on parameters that only make sense in a
elf-based context.  For instance, the fe_iface::initialize() interface
should not contain paths to debug-info as that information does not
make sense in an ABIXML context.

This patch thus renames fe_iface::reset() into fe_iface::initialize()
and makes it virtual.  It adjusts the plumbing accordingly, basically
making the other ::initialize() methods of classes that inherit
fe_iface use fe_iface::initialize() when appropriate.

The patch also provides an elf_based_reader::initialize()
implementation of the fe_iface::initialize() interface, so that
invoking ::initialize on elf_based_reader through the fe_iface
interface does the right thing so that the initial use case presented
at the beginning of this comment is supported.

* include/abg-elf-based-reader.h (elf_based_reader::initialize):
Rename elf_based_reader::reset into this.  Add a new virtual
overload that implements fe_iface::initialize.
* include/abg-elf-reader.h (reader::initialize): Rename
elf_reader::reset into this.  Add a new virtual overload that
implements fe_iface::initialize.
* include/abg-fe-iface.h (fe_iface::initialize): Rename
fe_iface::reset into this and make it virtual.
* src/abg-btf-reader.cc (btf::reader::initialize): Adjust call to
elf_based_reader::reset to elf_based_reader::initialize.
* src/abg-ctf-reader.cc (ctf::reader::initialize): Likewise.
* src/abg-dwarf-reader.cc (dwarf::reader::initialize): Likewise.
* src/abg-elf-based-reader.cc (elf_based_reader::initialize):
Rename elf_based_reader::reset into this.  Adjust call to
elf::reader::reset into elf::reader::initialize.  Add a new
virtual overload that implements fe_iface::initialize.
* src/abg-elf-reader.cc (reader::initialize): Rename
elf::reader::reset into this. Adjust call to fe_iface::reset into
fe_iface::initialize.  Add a new virtual overload that implements
fe_iface::initialize.
* src/abg-fe-iface.cc (fe_iface::priv::initialize): Reset the
corpus too.
(fe_iface::initialize): Rename fe_iface::reset into this.  Invoke
priv::initialize and set the new corpus_path.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
16 months agofedabipkgdiff: Fix previous commit
Dodji Seketeli [Thu, 6 Jul 2023 14:03:22 +0000 (16:03 +0200)]
fedabipkgdiff: Fix previous commit

In the previous commit, I wrongly assumed that all Brew koji session objects
have a an "opts" attribute.  Fixed thus.

 * tools/fedabipkgdiff (Brew::__init__): Do not try to access the
'opts' attribute on sessions that don't have any.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
16 months agofedabipkgdiff: Don't choke Koji servers with self-signed SSL certs
Dodji Seketeli [Thu, 6 Jul 2023 10:37:40 +0000 (12:37 +0200)]
fedabipkgdiff: Don't choke Koji servers with self-signed SSL certs

When doing some tests on particular Koji instances, the
Brew::getPackage function was choking because its underlying http
client would could not verify the self-signed SSL certificate used by
the server.

This patch sets the default option of the client so that it avoids
verifying SSL certificates altogether.

* fedabipkgdiff (Brew::__init__): Se the "no_ssl_verify" option to
false by default.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
16 months agoBug 30461 - insight fails self-compare
Dodji Seketeli [Wed, 21 Jun 2023 07:53:01 +0000 (09:53 +0200)]
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>
17 months agosymtab reader: fix symtab iterator to support C++20
Matthias Maennich [Tue, 6 Jun 2023 08:51:34 +0000 (09:51 +0100)]
symtab reader: fix symtab iterator to support C++20

Inheriting from std::vector::iterator causes the type to advertise
itself as a contiguous iterator. This causes a compilation error in
newer versions of libc++ that try to use contiguous-iterator-specific
optimizations in those situations. Fixed thus by explicitly specifying
the interator_concept tag.

* abg-symtab-reader.h (symtab_iterator): Specify
  iterator_concept as forward_iterator to support C++20 compilation.

Signed-off-by: Matthias Maennich <maennich@google.com>
17 months agosymtab reader: use C++11 `using` syntax instead of typedefs
Matthias Maennich [Tue, 6 Jun 2023 08:51:33 +0000 (09:51 +0100)]
symtab reader: use C++11 `using` syntax instead of typedefs

That is to increase readability and to incrementally modernize the code base.

* abg-symtab-reader.h: replace typedefs by corresponding using
  declarations.

Signed-off-by: Matthias Maennich <maennich@google.com>
17 months agoBug 30503 - Fail to compare non-anonymous struct vs named struct data members
Dodji Seketeli [Wed, 7 Jun 2023 09:47:20 +0000 (11:47 +0200)]
Bug 30503 - Fail to compare non-anonymous struct vs named struct data members

Since this commit

    commit 321da6667884ddd13f30d21a9ed0c92d42f302fe
    Author: Dodji Seketeli <dodji@redhat.com>
    Date:   Tue Sep 14 18:11:39 2021 +0200

Bug 28316 - Failure to represent typedef named anonymous enums

It seems like comparing a data member of a non-anonymous struct foo
against the same data member of an anonymous struct named by a typedef
foo wrongly leads yields a spurious difference.

This is because when looking at the data member,
get_decl_name_for_comparison doesn't return the same value in the two
cases (non anonymous struct foo vs anonymous struct named by a typedef
foo).  Looking deeper, it's because get_decl_name_for_comparison
wronly uses scope_anonymous_or_typedef_named.  Fixed thus.

* src/abg-ir.cc (get_decl_name_for_comparison): Do not use
scope_anonymous_or_typedef_named.  Rather, use
decl_base::get_has_anonymous_parent instead.
(scope_anonymous_or_typedef_named): Remove this as it's not used
anymore.
* include/abg-fwd.h (scope_anonymous_or_typedef_named): Remove
this declaration as the definition has been removed.
* tests/data/test-abidiff-exit/PR30503/libsdl/1.2.60/lib64/libSDL-1.2.so.1.2.60:
New test input file.
* tests/data/test-abidiff-exit/PR30503/libsdl/1.2.60/lib64/libSDL-1.2.so.1.2.60.debug:
Likewise.
* tests/data/test-abidiff-exit/PR30503/libsdl/1.2.64/lib64/libSDL-1.2.so.1.2.64:
Likewise.
* tests/data/test-abidiff-exit/PR30503/libsdl/1.2.64/lib64/libSDL-1.2.so.1.2.64.debug:
Likewise.
* tests/data/test-abidiff-exit/PR30503/libsdl/libsdl-1.2.60-1.2.64-report.txt:
Likewise.
* tests/data/Makefile.am: Add the new test inputs above to source
distribution.
* tests/test-abidiff-exit.cc (in_out_specs): Add the new test
inputs above to this test harness.
* tests/data/test-annotate/test14-pr18893.so.abi: Adjust.
* tests/data/test-read-dwarf/test14-pr18893.so.abi: Adjust.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
17 months agoconfigure.ac: Bump to 2.4 version
Dodji Seketeli [Mon, 5 Jun 2023 12:06:44 +0000 (14:06 +0200)]
configure.ac: Bump to 2.4 version

Bump the version number to 2.4.  Also, as some interfaces have
changed, bump the SONAME's current number.

* configure.ac: Bump library version number to 2.4.  Bump SONAME's
current number to 3.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
17 months agoBug 30467 - enlightenment fails self check on f38
Dodji Seketeli [Mon, 5 Jun 2023 08:28:53 +0000 (10:28 +0200)]
Bug 30467 - enlightenment fails self check on f38

This is yet another instance of a latent canonical type propagation
issue.  Basically, when reading back a type from ABIXML,
canonicalizing it (in an order that is different from the initial
order in which it has been canonicalized by the DWARF front-end)
yields a different canonical type from the original one computed by
the DWARF front-end, yielding spurious self-comparison changes.

By looking at it a bit closer, I realized the cache of the comparison
results wasn't being cleared upon canceling canonical type
propagation, whenever that canceling occurs.  That leads to some
subsequent comparisons being wrong (albeit fast, heh) because they
rely on cached results that should have been invalidated.

This patch thus clears the type comparison result cache whenever
canonical type propagation canceling occurs.

* src/abg-ir-priv.h (environment::priv::cancel_ct_propagation):
Clear the type comparison results cache.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
17 months agoBug 30466 - harfbuzz fails self-check on f38
Dodji Seketeli [Thu, 25 May 2023 12:15:56 +0000 (14:15 +0200)]
Bug 30466 - harfbuzz fails self-check on f38

Since this commit:

    commit 43cbdd1501bab7d65ef08c79f0b07ebbdb2e4118
    Author: Dodji Seketeli <dodji@redhat.com>
    Date:   Thu Apr 13 16:48:52 2023 +0200

ir: Recognize "void* as being equal to all other pointers in C

a pointer to void is considered equal to all other pointers to avoid
emitting some spurious changes while self-comparing glibc from fc37.

As a void pointer can now equal several kinds of types, it could no
longer be canonicalized.  But then, the 'exemplar pointer' based
optimization in the ABIXML writer (cf get_exemplar_type) makes it so
that two different void pointer IR nodes (that are structurally
equivalent) would result in two different nodes (with different
type-ids) being serialized out in ABIXML.  Later at ABIXML reading
time, aggregates types using these two different void pointer nodes
might yield canonical types that are different from the original ones,
depending on the order in which ABIXML types are canonicalized as that
order might differ from the order in which they were initially
canonicalized.  This difference leads to spurious self-comparison
errors.

To handle this, I am proposing that the void pointer type be a unique
IR type node in the system.  That way, the exemplar type optimization
would still work and we get rid of the spurious self-comparison error
change.  While doing this, I realized that the void type and the
variadic parameter type that are also unique types were not properly
enforced in all the front-ends as such.  So this patch fixes that.

The patch also make typedefs and pointer to decl-only classes be
non-canonicalized types because decl-only classes are non-canonicalized
already.  Pointers and typedefs to those types being canonicalized can
lead to different canonicalized type depending on the order of
canonicalization.

The rest of the patch is basically adjusting the other moving parts to
these core changes.

* 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)
(is_void_pointer_type_equivalent, is_unique_type): Declare new
functions.
(is_typedef, is_void_pointer_type): Declare new overloads.
(is_declaration_only_class_or_union_type): Add a new
look_through_decl_only flag as parameter.
* include/abg-ir.h (environment::{get_void_pointer_type,
is_void_pointer_type}): Define new member functions.
* src/abg-ir-priv.h (environment::priv::{void_pointer_type}): Add
new data member.
* src/abg-ir.cc (decl_topo_comp::operator()): For unique types,
use lexicographic sorting.
(environment::{get_void_pointer_type, is_void_pointer_type}):
Define new member function.
(is_typedef, 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, is_unique_type):
Define new functions.
(is_declaration_only_class_or_union_type): Add a new
look_through_decl_only parameter.  Some decl-only class or union
do have an associated definition; this function return false for
these types if look_through_decl_only is set to true.
(is_void_pointer_type_equivalent): Rename is_void_pointer_type
into this.
(is_void_pointer_type): Now that is_void_pointer_type equals is
old version of this is_void_poitner, make the new version test if
the type equals the unique void pointer type, or if it a pointer
to void type.  It doesn't take typedefs into account, like what
is_void_pointer_type_equivalent does.
(equals): In the overload for pointer_type_def, use the new
is_void_pointer_type_equivalent instead of
is_void_pointer_type_equivalent.
(is_non_canonicalized_type): Re-organize this.  Now, all unique
types are non-canonicalized.  This was sort-of the case already
but was not clearly stated as such.  The decl-only class-or-union
types were already non-canonicalized, but pointers and typedefs to
class-or-unions should also be non-canonicalized for the system to
work because a decl-only class-or-unions equals all defined types
in C++.
* src/abg-btf-reader.cc
(reader::build_ir_node_for_void_pointer_type): Define new member
function that return a unique type for void pointer types.
(reader::build_pointer_type): Use
build_ir_node_for_void_pointer_type to build void pointer types.
(reader::{build_ir_node_for_void_type,
build_ir_node_for_variadic_parameter_type}): Simplify.
* src/abg-ctf-reader.cc (build_ir_node_for_void_type)
(build_ir_node_for_void_pointer_type): Define new functions.
(process_ctf_function_type): Use build_ir_node_for_void_type for
void types.
(process_ctf_pointer_type): Use
build_ir_node_for_void_pointer_type for void pointer types.
* src/abg-dwarf-reader.cc (build_ir_node_for_void_pointer_type):
Define a new function that returns a unique type for void pointer
types.
(build_pointer_type_def): Use the new
build_ir_node_for_void_pointer_type to build void pointers.
(build_ir_node_for_variadic_parameter_type): Simplify.
* src/abg-reader.cc (read_type_id_string): Define this even
not debugging self-comparison.
(build_ir_node_for_void_type)
(build_ir_node_for_void_pointer_type): Define new functions.
(reader::{get_scope_for_node, get_scope_ptr_for_node}): New member
functions.
(reader::push_decl_to_current_scope): Remove this member function.
This was using the scope of the last IR node built as the current
scope.  The problem is that the scope of a unique IR node is the
scope where it was used the first time; that has nothing to do
with the current scope.  So this function is obsolete now that we
are using unique IR nodes for real.
(reader::push_decl_to_scope): New member function.  This is the
one to use, now that push_decl_to_current_scope is no more.
(reader::push_and_key_type_decl): Pass the scope_decl to use.
Make this push the decl to the scope passed in parameter.  Add an
overload that has the XML node to use to determine the scope to
push the decl to.
(reader::get_scope_for_node): Support template parameter type
composition nodes.  Also, add an overload that takes just an XML
node.
(reader::get_scope_ptr_for_node): Define new member function.
(build_namespace_decl, build_function_decl, build_var_decl): Use
to reader::push_decl_to_scope, now that
reader::push_decl_to_current_scope is gone.
(build_type_decl): Use build_ir_node_for_void_type to build a void
type.  Adjust the call to reader::push_and_key_type_decl.
(build_qualified_type_decl, build_reference_type_def)
(build_subrange_type, build_array_type_def, build_enum_type_decl)
(build_typedef_decl, build_class_decl, build_union_decl)
(build_function_tdecl, build_function_tdecl, build_class_tdecl)
(build_type_tparameter, build_type_composition)
(build_non_type_tparameter, build_template_tparameter): Adjust the
call to reader::push_and_key_type_decl.
(build_pointer_type_def): Likewise.  Use
build_ir_node_for_void_pointer_type to build a void pointer IR
node.  Also, build the pointed-to-type before the pointer type
itself; this is required to catch a void pointer type early and
use build_ir_node_for_void_pointer_type to build it.
* src/abg-comp-filter.cc (has_void_ptr_to_ptr_change): Use the new
is_void_pointer_type_equivalent in lieu of is_void_pointer_type.
This is because the former takes typedefs into account and so is
more accurate.
* src/abg-comparison.cc
(scope_diff::ensure_lookup_tables_populated): Do not consider
unique types when accounting for added/removed 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/test-anonymous-members-0.o.abi: Likewise.
* tests/data/test-annotate/test0.abi: Likewise.
* tests/data/test-annotate/test1.abi: Likewise.
* tests/data/test-annotate/test13-pr18894.so.abi: Likewise.
* tests/data/test-annotate/test14-pr18893.so.abi: Likewise.
* tests/data/test-annotate/test15-pr18892.so.abi: Likewise.
* tests/data/test-annotate/test17-pr19027.so.abi: Likewise.
* tests/data/test-annotate/test18-pr19037-libvtkRenderingLIC-6.1.so.abi:
Likewise.
* tests/data/test-annotate/test19-pr19023-libtcmalloc_and_profiler.so.abi:
Likewise.
* tests/data/test-annotate/test2.so.abi: Likewise.
* tests/data/test-annotate/test20-pr19025-libvtkParallelCore-6.1.so.abi:
Likewise.
* tests/data/test-annotate/test21-pr19092.so.abi: Likewise.
* tests/data/test-annotate/test3.so.abi: Likewise.
* tests/data/test-annotate/test5.o.abi: Likewise.
* tests/data/test-read-btf/test1.o.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/test8.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/PR27700/test-PR27700.abi: Likewise.
* tests/data/test-read-dwarf/libtest23.so.abi: Likewise.
* tests/data/test-read-dwarf/libtest24-drop-fns-2.so.abi:
Likewise.
* tests/data/test-read-dwarf/libtest24-drop-fns.so.abi: Likewise.
* tests/data/test-read-dwarf/test-PR26568-1.o.abi: Likewise.
* tests/data/test-read-dwarf/test-PR26568-2.o.abi: Likewise.
* tests/data/test-read-dwarf/test-libaaudio.so.abi: Likewise.
* tests/data/test-read-dwarf/test-libandroid.so.abi: Likewise.
* tests/data/test-read-dwarf/test-suppressed-alias.o.abi:
Likewise.
* tests/data/test-read-dwarf/test0.abi: Likewise.
* tests/data/test-read-dwarf/test0.hash.abi: Likewise.
* tests/data/test-read-dwarf/test1.abi: Likewise.
* tests/data/test-read-dwarf/test1.hash.abi: Likewise.
* tests/data/test-read-dwarf/test10-pr18818-gcc.so.abi: Likewise.
* tests/data/test-read-dwarf/test11-pr18828.so.abi: Likewise.
* tests/data/test-read-dwarf/test12-pr18844.so.abi: Likewise.
* tests/data/test-read-dwarf/test13-pr18894.so.abi: Likewise.
* tests/data/test-read-dwarf/test14-pr18893.so.abi: Likewise.
* tests/data/test-read-dwarf/test15-pr18892.so.abi: Likewise.
* tests/data/test-read-dwarf/test16-pr18904.so.abi: Likewise.
* tests/data/test-read-dwarf/test17-pr19027.so.abi: Likewise.
* tests/data/test-read-dwarf/test18-pr19037-libvtkRenderingLIC-6.1.so.abi:
Likewise.
* tests/data/test-read-dwarf/test19-pr19023-libtcmalloc_and_profiler.so.abi:
Likewise.
* tests/data/test-read-dwarf/test2.so.abi: Likewise.
* tests/data/test-read-dwarf/test2.so.hash.abi: Likewise.
* tests/data/test-read-dwarf/test20-pr19025-libvtkParallelCore-6.1.so.abi:
Likewise.
* tests/data/test-read-dwarf/test21-pr19092.so.abi: Likewise.
* tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi:
Likewise.
* tests/data/test-read-dwarf/test3-alias-1.so.hash.abi: Likewise.
* tests/data/test-read-dwarf/test3-alias-2.so.hash.abi: Likewise.
* tests/data/test-read-dwarf/test3-alias-3.so.hash.abi: Likewise.
* tests/data/test-read-dwarf/test3-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/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.
* tests/data/test-read-write/test17.xml: Likewise.
* tests/data/test-read-write/test18.xml: Likewise.
* tests/data/test-read-write/test19.xml: Likewise.
* tests/data/test-read-write/test20.xml: Likewise.
* tests/data/test-read-write/test21.xml: Likewise.
* tests/data/test-read-write/test22.xml: Likewise.
* tests/data/test-read-write/test23.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>
17 months agoBug 29693 - clang-libs from f37 fails self test
Dodji Seketeli [Wed, 17 May 2023 11:44:58 +0000 (13:44 +0200)]
Bug 29693 - clang-libs from f37 fails self test

To reproduce the issue reported in the bug above, here is the relevant
command line:

    $ tools/fedabipkgdiff --self-compare -a --from fc37 clang-libs

When the abixml reader encounters a decl-only class, it wrongly avoids
trying to read its members.  This is wrong because a decl-only class
can still have member types.  By doing so, the abixml might "forget"
some member types, leading to self comparison errors as the original
class from DWARF (for instance) might have those member types.

Fixed thus.

* src/abg-reader.cc (build_class_decl): Read member types even
when we are looking at a decl-only class.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
17 months agodwarf-reader: Don't compute canonical type while propagating one
Dodji Seketeli [Thu, 11 May 2023 16:00:46 +0000 (18:00 +0200)]
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>
17 months agoelf-helpers: make sure config.h is included first
Dmitry V. Levin [Mon, 1 May 2023 20:20:07 +0000 (23:20 +0300)]
elf-helpers: make sure config.h is included first

Before this change, verify-elf used to complain on x86 and armv7:
verify-elf: ERROR: ./usr/lib/libabigail.so.2.0.0: uses non-LFS functions: open

Include config.h in abg-elf-helpers.cc before other headers so that
AC_SYS_LARGEFILE applies to this file.  This fully enables LFS
in those of 32-bit systems that do not enable it by default.

* src/abg-elf-helpers.cc: Include "config.h" first.

Fixes: 7bd69830520f ("Make Front Ends first class citizens")
Signed-off-by: Dmitry V. Levin <ldv@strace.io>
17 months agorelease-text-template.txt: Modernize a little bit.
Dodji Seketeli [Wed, 10 May 2023 14:29:55 +0000 (16:29 +0200)]
release-text-template.txt: Modernize a little bit.

Modernize the release-text-template a little bit.

* release-text-template.txt: Update this for the new xz tarball
format and add highlights.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
18 months agoUpdate website for the 2.3 release
Dodji Seketeli [Thu, 27 Apr 2023 13:42:22 +0000 (15:42 +0200)]
Update website for the 2.3 release

* doc/website/mainpage.txt: Update for 2.3.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
18 months agoNEWS: Update for 2.3 release libabigail-2.3
Dodji Seketeli [Thu, 27 Apr 2023 09:55:38 +0000 (11:55 +0200)]
NEWS: Update for 2.3 release

* NEWS: Update using "git shortlog libabigail-2.2..HEAD".

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
18 months agoUpdate ChangeLog for 2.3 release
Dodji Seketeli [Thu, 27 Apr 2023 09:53:10 +0000 (11:53 +0200)]
Update ChangeLog for 2.3 release

* ChangeLog: Update using the 'make update-changelog' command.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
18 months agotest-ini: Fix a typo
Dodji Seketeli [Thu, 27 Apr 2023 08:40:10 +0000 (10:40 +0200)]
test-ini: Fix a typo

* tests/test-ini.cc (in_out_specs): Fix a typo near the last
record of the array.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
18 months agoini: Do not crash on incorrect property value
Dodji Seketeli [Wed, 26 Apr 2023 20:19:35 +0000 (22:19 +0200)]
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>
18 months agotest-abidiff-exit: Fix the command line passed to abidiff
Dodji Seketeli [Wed, 26 Apr 2023 10:37:30 +0000 (12:37 +0200)]
test-abidiff-exit: Fix the command line passed to abidiff

I noticed that the command line passed to abidiff in the
test-abidiff-exit.cc is getting bigger and bigger as the test runs.
This is because in the main loop that calls abidiff on each test, we
forget to reset the "headers directories" part of the command line
passed to abidiff.

Fixed thus.

* tests/test-abidiff-exit.cc (main): Reset the headers directories
passed to abidiff at each iteration.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
18 months agoFix the test of the patch for Bug 30309
Dodji Seketeli [Wed, 26 Apr 2023 10:34:27 +0000 (12:34 +0200)]
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>
18 months agoBug 30309 - Support absolute path to alt debug info file in DWARF
Dodji Seketeli [Tue, 25 Apr 2023 10:17:12 +0000 (12:17 +0200)]
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>
18 months agoreader: Recognize variadic parameter type from abixml
Dodji Seketeli [Fri, 21 Apr 2023 12:37:54 +0000 (14:37 +0200)]
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>
18 months agoir: fix canonical type propagation canceling error
Dodji Seketeli [Wed, 19 Apr 2023 15:45:27 +0000 (17:45 +0200)]
ir: fix canonical type propagation canceling error

This patch (with the help of the 9 patches that precede it) fixes the
self-comparison error that is seen when running the command line:

    $ fedabipkgdiff --self-compare -a --from fc37 bpftrace

It turns out the root cause of the self-comparison error seen here is
that sometimes, when the speculatively computed canonical type (that
is called propagated canonical type) is known to be wrong, the code
forgets to cancel that speculation.  And that leads to wrong
comparisons during subsequent type canonicalizations and later during
type comparisons.

This patch fixes the logic the of the cancellation of propagated
canonical type that must happen when it is known that the propagated
canonical type is invalid.

* src/abg-ir-priv.h
(environment::priv::{confirm_ct_propagation_for_types_dependant_on,
confirm_ct_propagation_for_types_dependant_on}): Asserting that
the type should be recursive is wrong because the recursive-ness
flag is set to false upon confirmation of the canonical type
propagation.  So there can be some types that would make this
assertion fail before we reach the end of the set of types to
confirm the propagation for.
(environment::priv::cancel_ct_propagation): Cancel the canonical
type propagation for all types we are instructed to cancel, not
just for types that are recursive or depends on recursive types.
This is because the the recursive-ness flag is set to false upon
cancellation of the canonical type propagation.  So there can be
some types that would make this condition fail before we reach the
end of the set of types to cancel the propagation for.
(environment::priv::cancel_all_non_confirmed_propagated_canonical_types):
Define new member function.
* src/abg-ir.cc (return_comparison_result): Confirm the
speculative canonical type propagation result when we are done
comparing the current type and the result of the comparison is
true.  Let's not try to be smart here.  Just be safe.  This
optimization is fast enough as is.  Otherwise, if the result of
the comparison is false, then all the speculatively propagated
canonical types of all the non-confirmed types should be canceled.
All of them.  Again, let's not try to be smart.  This is smart &
fast enough as is.  And thing are going to be correct this way.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
18 months agocomparison: Fix index error when interpreting scope comparison
Dodji Seketeli [Wed, 19 Apr 2023 14:24:05 +0000 (16:24 +0200)]
comparison: Fix index error when interpreting scope comparison

While looking at something else, I noticed a thinko in the
code in scope_diff::ensure_lookup_tables_populated that interprets the
result of the diffing algorithm on the decls of a given scope.  Fixed
thus.

* src/abg-comparison.cc
(scope_diff::ensure_lookup_tables_populated): Use the proper index
to address the deleted decl.  Also, use the range-based for syntax
in the enclosing for-loop for more clarity.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
18 months agowriter: Annotate pointer representation
Dodji Seketeli [Wed, 19 Apr 2023 14:01:15 +0000 (16:01 +0200)]
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>
18 months agoir: Improve debugging type_base::get_canonical_type_for
Dodji Seketeli [Wed, 19 Apr 2023 13:07:37 +0000 (15:07 +0200)]
ir: Improve debugging type_base::get_canonical_type_for

This patch factorizes an interesting part of
type_base::get_canonical_type_for into a new function called
compare_canonical_type_against_candidate.  The user can now invoke it
from the prompt of the debugger to compare a candidate canonical type
against an actual canonical to study why the comparison fails (by
setting a breakpoint in notify_equality_failed when the pre-processor
macro WITH_DEBUG_SELF_COMPARISON is defined.

This is priceless to debug why canonical type comparison that should
succeed actually fails.

* src/abg-ir.cc (compare_types_during_canonicalization): Adjust
this to make it take const type_base& rather than const
type_base_sptr.
(compare_canonical_type_against_candidate): Factorize this out of
...
(type_base::get_canonical_type_for): ... here.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
18 months agoImprove self-comparison debug mode
Dodji Seketeli [Wed, 19 Apr 2023 12:29:13 +0000 (14:29 +0200)]
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>
18 months agotests/update-test-output.py: Adapt to some broken test output
Dodji Seketeli [Fri, 21 Apr 2023 17:55:49 +0000 (19:55 +0200)]
tests/update-test-output.py: Adapt to some broken test output

Sometimes, the output of runtestreaddwarf or runtestannotate are
broken due the fact that they execute test units in parallel and each
unit might emit output that watch on each other toes.

This fixes tests/update-test-output.py to take that into account.

As this is a helper tool used to update updates, it won't have any
impact on libabigail's output.

* tests/update-test-output.py (process): Don't expect the start
pattern of the main diff hunk to begin at the end of a line
because that can be broken for runtestreaddwarf and co.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
18 months agodoc: Fix some typos and add some missing references
Mark Wielaard [Fri, 14 Apr 2023 14:52:09 +0000 (16:52 +0200)]
doc: Fix some typos and add some missing references

Building the docs point out a few issues:

abidiff.rst:238: WARNING: Unknown target name: "linux kernel".
abidiff.rst:249: WARNING: Unknown target name: "linux kernel".
abidiff.rst:263: WARNING: Unknown target name: "linux kernel".
abidiff.rst:274: WARNING: Unknown target name: "linux kernel".
abidw.rst:23: WARNING: Unknown target name: "btf`_formats, if present. finally, if no debug info in these formats is found, it only considers `elf".
abidw.rst:34: WARNING: duplicate label abidiff_invocation_label, other instance in doc/manuals/abidiff.rst
abipkgdiff.rst:298: WARNING: Unknown target name: "linux kernel".
abipkgdiff.rst:309: WARNING: Unknown target name: "linux kernel".
abipkgdiff.rst:323: WARNING: Unknown target name: "linux kernel".
abipkgdiff.rst:334: WARNING: Unknown target name: "linux kernel".
libabigail-concepts.rst:620: WARNING: Block quote ends without a blank line; unexpected unindent.
libabigail-overview.rst:1: WARNING: Title overline too short.

Fix those as follows:

    * doc/manuals/abidiff.rst: Add Linux Kernel reference.
    * doc/manuals/abipkgdiff.rst: Likewise.
    * doc/manuals/abidw.rst: Add space between `BTF`_ and formats.
    Rename _abidiff_invocation_label to _abidw_invocation_label.
    * doc/manuals/libabigail-concepts.rst: Add empty line between
    _suppr_has_size_change_property_label and has_size_change.
    * doc/manuals/libabigail-overview.rst: Extend title overlines.

Signed-off-by: Mark Wielaard <mark@klomp.org>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
18 months agoir: Recognize "void* as being equal to all other pointers in C
Dodji Seketeli [Thu, 13 Apr 2023 14:48:52 +0000 (16:48 +0200)]
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>
18 months agoir: Add new environment::get_type_id_from_type
Dodji Seketeli [Thu, 13 Apr 2023 14:03:04 +0000 (16:03 +0200)]
ir: Add new environment::get_type_id_from_type

While debugging some issues, I felt the need to easily get the type-id
from a given ir::type_base* from within the debugger.

I have thus added this new environment::get_type_id_from_type member
function.

* include/abg-ir.h (environment::get_pointer_type_id_map): Declare
...
* src/abg-ir.cc (environment::get_pointer_type_id_map): ... this
new member function.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
18 months agoabidiff,reader: Fix compilation with --debug-self-comparison
Dodji Seketeli [Thu, 13 Apr 2023 13:32:22 +0000 (15:32 +0200)]
abidiff,reader: Fix compilation with --debug-self-comparison

While chasing self-comparison changes errors, I realized that
compilation is failing when the package is configured with
--debug-self-comparison.

Fixed thus.

* src/abg-reader.cc
(reader::{maybe_check_abixml_canonical_type_stability, read_corpus}):
get_environment() doesn't returns a pointer anymore.  So adapt the
code.
(maybe_map_type_with_type_id): Adjust because the environment is
const.
(load_canonical_type_ids): The xml_reader namespace doesn't exist
anymore.  It's now abixml.
* tools/abidiff.cc (options::options): Initialize the
do_debug_self_comparison data member before the use_btf one, as it
should be.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
This page took 0.186343 seconds and 5 git commands to generate.