Commit Graph

257 Commits

Author SHA1 Message Date
Frank Ch. Eigler
09338a2590 abidb: Introduce a tool to manage the ABI of a Linux distribution
This patch introduces a new tool named abidb.  It manages a Git
repository of the Application Binary Interfaces of a set of shared
libraries.  Those ABIs are stored in the Git repository in the form of
ABIXML files.

The tool then supports the verification of the ABI compatibility of a
given binary against the stored ABIs of shared libraries.

	* configure.ac: Condition building abidb on the presence of python
	and the required modules.
	* doc/manuals/Makefile.am: Add the abidb.rst documentation to
	source distribution.  Distribute the abidb.1 manpage file as well.
	* doc/manuals/abidb.rst: New documentation file.
	* doc/manuals/conf.py: Configure the generation of the abidb.1
	manage from the abidb.rst file above.
	* doc/manuals/libabigail-tools.rst: Add a reference to the new
	abidb tool.
	* tests/Makefile.am: Register runabidb1.sh and runabidb2.sh as
	tests for abidb.  Register runabidb1.sh.in and runabidb2.sh.in as
	input files for autoconf generated runabidb1.sh and runabidb2.sh.
	* tests/data/Makefile.am: Add abidb2client.c, abidb2so.c and
	abidb2soBAD.c to source distribution.
	* tests/data/abidb2client.c: New source file for test input binaries.
	* tests/data/abidb2so.c: Likewise.
	* tests/data/abidb2soBAD.c: Likewise.
	* tests/runtestabidb1.sh.in: New test script input for autoconf generation.
	* tests/runtestabidb2.sh.in: Likewise.
	* tools/Makefile.am: Add the new abidb tool to the set of tools.
	* tools/abidb: The New Tool, ladies and gentlemen!

Signed-off-by: Frank Ch. Eigler <fche@redhat.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2024-03-22 17:18:17 +01:00
Dodji Seketeli
15f2ff5d6c Emit & read undefined interfaces to & from ABIXML
This patch teaches the ABIXML writer to emit information about
undefined interfaces.  It also teaches the ABIXML reader to read
information about undefined interfaces.

It introduces two new ABIXML elements:
'undefined-elf-function-symbols' and 'undefined-elf-variable-symbols'
to represent undefined function and variable symbols.

Then, in the 'abi-instr' element functions and variables that
reference undefined elf symbols now have an 'elf-symbol-id' attribute
referencing the undefined symbol listed in the new
'undefined-elf-variable-symbols' or 'undefined-elf-function-symbols'
element.

The patch introduces tests that perform compatibility checks done on
ABIXML files.

	* include/abg-writer.h (set_write_undefined_symbols): Declare new
	function.
	(set_common_options): Use the new set_write_undefined_symbols in
	this function template.
	* src/abg-dwarf-reader.cc (reader::{get_die_language, die_is_in_c,
	die_is_in_cplus_plus, die_is_in_c_or_cplusplus}): Move these
	member functions into ...
	(get_die_language, die_is_in_c, die_is_in_cplus_plus)
	(die_is_in_c_or_cplusplus): ... these static non-member functions.
	(fn_die_equal_by_linkage_name): Adjust and remove the now useless
	reader parameter.
	(compare_dies, get_scope_die, function_is_suppressed)
	(variable_is_suppressed): Adjust.
	(build_translation_unit_and_add_to_ir): When we are asked to load
	undefined symbol, make sure to also analyze top-level class types
	and if we are in C++, also analyze top-level unions and structs as
	these might also have some undefined interfaces.
	* src/abg-reader.cc (build_elf_symbol_db): Let's not construct and
	return the symbol DB anymore.  Rather, let's let the caller
	construct it, so we can just update it with the input gathered.
	(read_symbol_db_from_input): Support getting undefined function
	and variable symbols from the new undefined-elf-function-symbols
	and undefined-elf-variable-symbols elements.  Note that undefined
	and defined function symbols go into the same symbol DB whereas
	undefined and defined variable symbols go into another symbol DB.
	Now, we suppose that the variable & symbol DBs are allocated by
	the caller.  We pass it down to build_elf_symbol_db that populates
	it.  Maybe we should rename build_elf_symbol_db into
	populate_elf_symbol_db.
	(reader::read_corpus): Allocate the function
	and variable symbol DB and let read_symbol_db_from_input populate
	it.  Sort functions and variables after reading the whole ABIXML.
	* src/abg-writer.cc (write_context::write_context): Define new
	data member.
	(write_context::write_context): Initialize it.
	(write_context::{get,set}::write_undefined_symbols): Define
	accessors.
	(set_write_undefined_symbols): Define a new function.
	(write_context::decl_is_emitted): Add a new overload.
	(write_elf_symbol_reference): Add a writer context and a corpus
	parameter.  If the symbol is not in the corpus or if the symbol is
	undefined and we were not asked to emit undefined symbols then do
	not emit any reference to it.
	(write_translation_unit): Emit the undefined functions and
	variables that belong to the current translation unit, along with
	their reference to the undefined ELF symbol they are associated
	to.
	(write_var_decl, write_function_decl): Let
	write_elf_symbol_reference decide whether it should emit the
	reference to ELF symbol or not, as it now know how to make that
	decision.
	(write_corpus): Write the undefined function & variable ELF symbol
	data bases.  These in the new 'undefined-elf-function-symbols' and
	'undefined-elf-variable-symbols' elements.
	* tools/abidw.cc (options::load_undefined_interfaces): Define new
	data member.
	(options:options): Initialize it.
	(display_usage): Add a help string for the
	--no-load-undefined-interfaces option.
	(parse_command_line): Parse the --no-load-undefined-interfaces
	option.
	(set_generic_options): Set the
	fe_iface::option_type::load_undefined_interfaces option.
	* doc/manuals/abidw.rst: Document the new
	--no-load-undefined-interfaces of abidw.
	* tests/data/test-abicompat/test10/libtest10-with-exported-symbols.so:
	New binary input file.
	* tests/data/test-abicompat/test10/libtest10-with-incompatible-exported-symbols.so:
	New binary input file.
	* tests/data/test-abicompat/test10/libtest10-with-incompatible-exported-symbols.so.abi:
	New abixml input file.
	* tests/data/test-abicompat/test10/test10-app-with-undefined-symbols:
	New binary input file.
	* tests/data/test-abicompat/test10/test10-app-with-undefined-symbols.abi:
	New abixml input file.
	* tests/data/test-abicompat/test10/test10-app-with-undefined-symbols.cc:
	New source file for binary test input
	* tests/data/test-abicompat/test10/test10-fn-changed-report-0.txt:
	New source file for binary test input
	* tests/data/test-abicompat/test10/test10-fn-changed-report-1.txt:
	New source file for binary test input
	* tests/data/test-abicompat/test10/test10-fn-changed-report-2.txt:
	New source file for binary test input
	* tests/data/test-abicompat/test10/test10-fn-changed-report-3.txt:
	New source file for binary test input
	* tests/data/test-abicompat/test10/test10-fn-changed-report-4.txt:
	New source file for binary test input
	* tests/data/test-abicompat/test10/test10-with-exported-symbols.cc:
	New source file for binary test input
	* tests/data/test-abicompat/test10/test10-with-exported-symbols.h:
	New source file for binary test input
	* tests/data/test-abicompat/test10/test10-with-incompatible-exported-symbols.cc:
	New source file for binary test input
	* tests/data/test-abicompat/test10/test10-with-incompatible-exported-symbols.h:
	New source file for binary test input.
	* tests/data/Makefile.am: Add new test input files to source
	distribution.
	* tests/test-abicompat.cc (in_out_specs): Add the new test inputs
	to this test harness.
	* tests/test-annotate.cc (main): Use the new
	--no-load-undefined-interfaces option of abidw to keep the old
	behavior.
	* tests/test-read-common.cc (test_task::serialize_corpus): Do not
	emit undefined symbols.
	* tests/test-read-dwarf.cc (test_task_dwarf::perform): Likewise.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2024-03-14 16:27:14 +01:00
Dodji Seketeli
897ecc9a49 Add support for undefined symbols in the BTF reader
This patch teaches the BTF reader how to construct an IR for undefined
interfaces.  The patch also updates the abicompat tool for BTF
support.

	* doc/manuals/abicompat.rst: Update documentation for the --btf
	option of abicompat.
	* include/abg-elf-reader.h
	(elf::reader::{function,variable}_symbol_is_undefined): Declare
	new member functions.
	* src/abg-btf-reader.cc
	(reader::read_debug_info_into_corpus): Sort functions &
	variables after canonicalization.
	(reader::build_ir_node_from_btf_type): Always call
	fe_iface::add_{fn,var}_to_exported_or_undefined_decls with the
	decl that was constructed.
	(reader::build_function_decl): Support setting an undefined symbol
	to the function decl.
	(reader::build_var_decl): Likewise, support setting undefined
	symbol the variable decl.
	* src/abg-elf-reader.cc
	((elf::reader::{function,variable}_symbol_is_undefined): Declare
	new member functions.): Define new member functions.
	* src/abg-symtab-reader.cc
	(symtab::{function,variable}_symbol_is_undefined): Return the
	undefined symbol that was found.
	* src/abg-symtab-reader.h
	(symtab::{function,variable}_symbol_is_undefined): Return an
	undefined symbol rather than just a boolean value.
	* tools/abicompat.cc: Add support for BTF here.
	(options::use_btf): Define new data member ...
	(options::options): ... and initialize it.
	(display_usage): Add a help string for the --btf option.
	(parse_command_line): Parse the --btf option.
	* tests/data/test-abicompat/test7-fn-changed-report-0.1.txt: New
	reference test output file.
	* tests/data/test-abicompat/test7-fn-changed-report-2.1.txt:
	Likewise.
	* tests/data/test-abicompat/libtest7-fn-changed-libapp-btf-v0.so:
	New binary input file.
	* tests/data/test-abicompat/libtest7-fn-changed-libapp-btf-v1.so:
	Likewise.
	* tests/data/test-abicompat/test7-fn-changed-app.btf: Likewise.
	* tests/data/Makefile.am: Add the new test material to source
	distribution.
	* tests/test-abicompat.cc (in_out_specs): Add the new test input
	to the test harness.
	* tests/data/test-abicompat/test7-fn-changed-app.c: Adjust.
	* tests/data/test-abicompat/test7-fn-changed-libapp-v0.c:
	Likewise.
	* tests/data/test-abicompat/test7-fn-changed-libapp-v1.c: Likewise

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2024-03-14 16:27:07 +01:00
Dodji Seketeli
11f37bf6b1 abidw: Add a -o short option for --out-file
* doc/manuals/abidw.rst: Document the -o option.
	* tools/abidw.cc (display_usage): Update doc string for the
	--out-file|-o option.
	(parse_command): Support the -o short option.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2024-03-08 15:38:01 +01:00
Giuliano Procida
fba8af7d70 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>
2024-01-08 09:31:34 -05:00
Dodji Seketeli
d02fa5ca6d 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>
2023-12-01 15:43:41 +01:00
Dodji Seketeli
ba094de49e 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>
2023-12-01 15:43:33 +01:00
Dodji Seketeli
89ab39de78 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>
2023-11-15 09:55:08 +01:00
Dodji Seketeli
86b8a24484 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>
2023-10-20 18:40:27 +02:00
Dodji Seketeli
b12ba51e62 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>
2023-10-18 11:08:58 +02:00
John Moon
b879ba8175 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>
2023-10-17 10:50:51 +02:00
Dodji Seketeli
f068f4a98f 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>
2023-10-05 17:09:45 +02:00
Dodji Seketeli
727452167e libabigail-concepts.rst: Remove trailing white spaces
* doc/manuals/libabigail-concepts.rst: Remove trailing white
	spaces.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2023-10-02 23:24:21 +02:00
Dodji Seketeli
d304f4d501 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>
2023-10-02 12:08:09 +02:00
Dodji Seketeli
0b338dfaf6 abidiff: Add --{follow,list}-dependencies & add-binaries{1,2} support
This patch implements comparing two sets of binaries constituted by the
binaries given in argument of the abidiff command, as well as their
respective dependencies (specified by the DT_NEEDED ELF property for
ELF binaries) or an arbitrary set of libraries found in the
directories determined by --added-binaries-dir{1,2}.

The detected dependencies can also be listed by the option
--list-dependencies.

	* tools/abidiff.cc (options::{follow_dependencies,
	list_dependencies, added_bins_dirs1, added_bins_dirs2,
	added_bins1, added_bins2}): Add new data members.
	(options::options): Initialize the new follow_dependencies and
	list_dependencies boolean data members.
	(display_usage): Add usage strings for --added-binaries-dir{1,2},
	--add-binaries{1,2}, --follow-dependencies, --list-dependencies.
	(parse_command_line): Parse the options --follow-dependencies,
	--list-dependencies, --added-binaries-dir{1,2},
	--add-binaries{1,2}.
	(display_dependencies): Add new static function.
	(main): Support the new --add-binaries{1,2},
	--follow-dependencies, --list-dependencies.
	* doc/manuals/abidiff.rst: Document the new options above.
	* tests/data/test-abidiff-exit/test-PR30034/libabigail.abignore: Add test input.
	* tests/data/test-abidiff-exit/test-PR30034/reference/include/rte_log.h:
	Likewise.
	* tests/data/test-abidiff-exit/test-PR30034/reference/lib64/librte_eal.so:
	Likewise.
	* tests/data/test-abidiff-exit/test-PR30034/reference/lib64/librte_eal.so.23:
	Likewise.
	* tests/data/test-abidiff-exit/test-PR30034/reference/lib64/librte_eal.so.23.1:
	Likewise.
	* tests/data/test-abidiff-exit/test-PR30034/reference/lib64/librte_kvargs.so:
	Likewise.
	* tests/data/test-abidiff-exit/test-PR30034/reference/lib64/librte_kvargs.so.23:
	Likewise.
	* tests/data/test-abidiff-exit/test-PR30034/reference/lib64/librte_kvargs.so.23.1:
	Likewise.
	* tests/data/test-abidiff-exit/test-PR30034/reference/lib64/librte_telemetry.so:
	Likewise.
	* tests/data/test-abidiff-exit/test-PR30034/reference/lib64/librte_telemetry.so.23:
	Likewise.
	* tests/data/test-abidiff-exit/test-PR30034/reference/lib64/librte_telemetry.so.23.1:
	Likewise.
	* tests/data/test-abidiff-exit/test-PR30034/split/include/rte_log.h:
	Likewise.
	* tests/data/test-abidiff-exit/test-PR30034/split/lib64/librte_eal.so:
	Likewise.
	* tests/data/test-abidiff-exit/test-PR30034/split/lib64/librte_eal.so.23:
	Likewise.
	* tests/data/test-abidiff-exit/test-PR30034/split/lib64/librte_eal.so.23.2:
	Likewise.
	* tests/data/test-abidiff-exit/test-PR30034/split/lib64/librte_kvargs.so:
	Likewise.
	* tests/data/test-abidiff-exit/test-PR30034/split/lib64/librte_kvargs.so.23:
	Likewise.
	* tests/data/test-abidiff-exit/test-PR30034/split/lib64/librte_kvargs.so.23.2:
	Likewise.
	* tests/data/test-abidiff-exit/test-PR30034/split/lib64/librte_log.so:
	Likewise.
	* tests/data/test-abidiff-exit/test-PR30034/split/lib64/librte_log.so.23:
	Likewise.
	* tests/data/test-abidiff-exit/test-PR30034/split/lib64/librte_log.so.23.2:
	Likewise.
	* tests/data/test-abidiff-exit/test-PR30034/split/lib64/librte_telemetry.so:
	Likewise.
	* tests/data/test-abidiff-exit/test-PR30034/split/lib64/librte_telemetry.so.23:
	Likewise.
	* tests/data/test-abidiff-exit/test-PR30034/split/lib64/librte_telemetry.so.23.2:
	Likewise.
	* tests/data/test-abidiff-exit/test-PR30034/test-PR30034-report-1.txt:
	Likewise.
	* tests/data/Makefile.am: Add the test inputs to source
	distribution.
	* tests/test-abidiff-exit.cc
	(InOutSpec::in_elfv{0,1}_added_bins_dir): Add new data member.
	(main): Add --added-binaries-dir{1,2} option to abidiff if the
	InOutSpec::in_elfv{0,1}_added_bins_dir data members are non-empty.
	(in_out_specs): Add test inputs to this test
	harness.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2023-07-07 13:34:51 +02:00
Dodji Seketeli
3e568fef6b 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>
2023-07-07 13:34:47 +02:00
Dodji Seketeli
51ff66f33d Update website for the 2.3 release
* doc/website/mainpage.txt: Update for 2.3.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2023-04-27 15:42:22 +02:00
Mark Wielaard
8437fd9b2c 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>
2023-04-21 19:32:46 +02:00
Dodji Seketeli
82f50f2093 comparison: Add a mode to not apply filters on interface sub-graphs
This patch allows to avoid applying filters on interface diff node
sub-graphs because those filters are useful for interface impact
analysis only, which is not needed in the leaf-node report, for
instance.  When using the leaf-node report, this capability speeds up
corpus_diff::apply_filters_and_suppressions_before_reporting, hence
the functions like corpus_diff::{has_incompatible_changes,
has_net_subtype_changes} are sped up too.

That patch thus adds a --no-change-categorization option to abidiff to
avoid doing that change categorization (A.K.A applying filters).

	* doc/manuals/abidiff.rst: Document the new
	--no-change-categorization option.
	* doc/manuals/kmidiff.rst: Likewise.
	* include/abg-comparison.h
	(diff_context::perform_change_categorization): Declare new
	accessor member functions.
	* src/abg-comparison-priv.h
	(diff_context::priv::perform_change_categorization_): Add new data
	member.
	(diff_context::priv::priv): Initialize the new data member.
	* src/abg-comparison.cc
	(diff_context::perform_change_categorization): Define new accessor
	member functions.
	(corpus_diff::priv::apply_filters_and_compute_diff_stats):
	Don't apply filters on the diff node sub-graphs of interfaces when
	the user requested "no change categorization".
	* tools/abidiff.cc (options::perform_change_categorization): New
	data member.
	(options::options): Initialize the new data member.
	(display_usage): Add a help string for the new
	--no-change-categorization.
	(parse_command_line): Parse the new --no-change-categorization
	option.
	(set_diff_context_from_opts): Set the option on the diff context
	here.
	* tools/kmidiff.cc(options::perform_change_categorization): New
	data member.
	(options::options): Initialize the new data member.
	(display_usage): Add a help string for the new
	--no-change-categorization.
	(parse_command_line): Parse the new --no-change-categorization
	option.
	(set_diff_context_from_opts): Set the option on the diff context
	here.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2023-03-02 18:31:43 +01:00
Dodji Seketeli
b4fb1fb539 suppression: Support offset_of_{first,last}_data_member_regexp offset selectors
This patch adds support for two data member offset selector
expressions for properties of the [suppress_type] directive:

offset_of_first_data_member_regexp() and offset_of_last_data_member_regexp().

These function-call expressions take a regular expression argument and
evaluate to the offset of the first (resp. last) data member matching
the regular expression argument.

An example of their use would be be:

    [suppress_type]
      type_kind = struct
      has_data_member_inserted_between =
	{
	  offset_of_first_data_member_regexp(^__special_padding_space),
	  offset_of_last_data_member_regexp(^__special_padding_space)
	}

This would be useful to suppress change reports involving a struct
which has "padding" data members added on-purpose like:

    struct S
    {
      int member0;
      char member1;
      unsigned __special_padding_space1;
      unsigned __special_padding_space2;
      unsigned __special_padding_space3;
    };

	* doc/manuals/libabigail-concepts.rst: Document the new
	properties.
	* include/abg-fwd.h: Forward declare comparison::{diff_context,
	diff_context_sptr, diff_context_wptr, diff, diff_wptr} and
	regex::regex_t_sptr.
	(find_first_data_member_matching_regexp)
	(find_last_data_member_matching_regexp): Declare new functions.
	* include/abg-suppression.h: Inject std::{string, shared_ptr,
	vector} and comparison::{diff, diff_context_sptr} into the suppr
	namespace.  Remove the "abg-comparison.h" header.
	* src/abg-elf-helpers.cc: Include sstream.
	* src/abg-ir.cc (find_first_data_member_matching_regexp)
	(find_last_data_member_matching_regexp): Define new functions.
	* src/abg-suppression.cc
	(type_suppression::insertion_range::eval_boundary): Support
	evaluating "offset_of_first_data_member_regexp" and
	"offset_of_first_data_member_regexp".
	* src/abg-ctf-reader.cc: Include sstream.
	* tests/data/test-diff-suppr/test-has-data-member-inserted-between-1-report-[1-4].txt:
	New test reference outputs.
	* tests/data/test-diff-suppr/test-has-data-member-inserted-between-1-v[0-4].c:
	Source code of new test input.
	* tests/data/test-diff-suppr/test-has-data-member-inserted-between-1-v[0-4].o:
	New binary test input.
	* tests/data/test-diff-suppr/test-has-data-member-inserted-between-1.suppr:
	New suppression specification.
	* tests/data/Makefile.am: Add the new test input files to source
	distribution.
	* tests/test-diff-suppr.cc (in_out_specs): Add the new test input
	to this test harness.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2023-03-02 18:18:37 +01:00
Dodji Seketeli
e68701e7ea suppression: Support the has_size_change property for suppress_type
The "has_data_member_inserted_between" and
"has_data_members_inserted_between" properties of the [suppress_type]
directive allows the suppression of type changes when a data member is
inserted in a given range.  It turns out that suppressing type changes
that incur a change in the size of the type might not be what the user
wants by default, because the type size in itself might actually be an
incompatible ABI change that would then fly under the radar because of
this suppression specification.

An arguably better default behavior in this case would be to NOT
suppress the type change if the data member insertion does incur a
change in the size of the type.

But then, there would be cases where the user would really want to
suppress the type change due to data member insertion in a given range
even if it incurs a change in the type size.  This is where this patch
enters into play.

The patch introduces the "has_size_change" property of the
[suppress_type] directive.  In the presence of
"has_data_members_inserted_between" or
"has_data_member_inserted_between" properties, if the
"has_size_change" property is set to "yes", then the type change would
be suppressed if data members are inserted in the given range even if
the insertion incurs a type size change.

Otherwise, with this patch, in the absence of the "has_size_change"
property, the "has_data_member_inserted_between" and
"has_data_members_inserted_between" properties won't trigger the type
change suppression if the data member insertion incurs a type size
change.

	* doc/manuals/libabigail-concepts.rst: Document the new
	has_size_change property.
	* include/abg-suppression.h
	(type_suppression::{g,s}et_has_size_change): Declare new accessors.
	* src/abg-suppression-priv.h
	(type_suppression::priv::has_size_change_): Define new data
	member.
	(type_suppression::priv::priv): Initialize the new data member.
	* src/abg-suppression.cc
	(type_suppression::{g,s}et_has_size_change): Define new accessors.
	(type_suppression::suppresses_diff): Make the
	has_data_member_inserted_* clauses have effect only if the class
	size hasn't changed, unless the class has as the "has_size_change"
	property.  Also, allow members to be deleted in the right
	insertion range if the resulting size stays the same or if the
	has_size_change property is present.  This allows some custom
	behaviours where "padding" data members would be removed while
	some new data members would be added, resulting in a type which
	size would not change.
	(read_type_suppression): Support parsing the "has_size_change"
	property.
	* tests/data/test-diff-suppr/test11-add-data-member-0.1.suppr: New
	test suppression specification.
	* tests/data/test-diff-suppr/test11-add-data-member-1.1.suppr:
	Likewise.
	* tests/data/test-diff-suppr/test11-add-data-member-2.1.suppr:
	Likewise.
	* tests/data/test-diff-suppr/test11-add-data-member-3.1.suppr:
	Likewise.
	* tests/data/test-diff-suppr/test11-add-data-member-4.1.suppr:
	Likewise.
	* tests/data/test-diff-suppr/test11-add-data-member-report-1.1.txt:
	Likewise.
	* tests/data/test-diff-suppr/test12-add-data-member-0.1.suppr:
	Likewise.
	* tests/data/test-diff-suppr/test12-add-data-member-report-1.1.txt:
	New test reference output.
	* tests/data/test-diff-suppr/test13-suppr-through-pointer-0.1.suppr:
	New test suppression specification.
	* tests/data/test-diff-suppr/test13-suppr-through-pointer-report-1.1.txt:
	New test reference output.
	* tests/data/test-diff-suppr/test35-leaf-report-0.1.txt: Likewise.
	* tests/data/test-diff-suppr/test35-leaf.1.suppr: New test
	suppression specification.
	* tests/data/Makefile.am: Add the new testing material to source
	distribution.
	* tests/data/test-diff-suppr/test11-add-data-member-1.suppr: Add
	the has_size_change property to explicitly allow suppressing type
	changes involving data member insertion even when the type size
	changes.
	* tests/data/test-diff-suppr/test11-add-data-member-0.suppr:
	Likewise.
	* tests/data/test-diff-suppr/test11-add-data-member-2.suppr:
	Likewise.
	* tests/data/test-diff-suppr/test11-add-data-member-3.suppr:
	Likewise.
	* tests/data/test-diff-suppr/test11-add-data-member-4.suppr:
	Likewise.
	* tests/data/test-diff-suppr/test12-add-data-member-0.suppr:
	Likewise.
	* tests/data/test-diff-suppr/test13-suppr-through-pointer-0.suppr:
	Likewise.
	* tests/data/test-diff-suppr/test35-leaf.suppr: Likewise.
	* tests/test-diff-suppr.cc (in_out_specs): Add the new test input
	to the test harness.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2023-03-02 10:29:15 +01:00
Dodji Seketeli
153b37a164 suppr: Support has_data_member and has_data_member_regexp properties
In the [supress_type] directive, this patch adds support for two new
properties:

* has_data_data_member = {foo, bar, blah}
  Suppresses change reports involving a type which has data members
  with names specified by the value of this property.

* has_data_member_regexp = some-regexp
  Suppresses change reports involving a type which has data members
  with names specified by the regular expression given as a value of
  this property.

	* include/abg-fwd.h (string_set_type): Define new typedef.
	* src/abg-suppression-priv.h
	* include/abg-suppression.h
	(type_suppression::{get,set}_potential_data_member_names[_regex_str]):
	Declare new data member.
	(type_suppression::priv::{potential_data_members_,
	potential_data_members_regex_str_,
	potential_data_members_regex_}): Define new data members.
	(type_suppression::priv::{get,set}_potential_data_member_names_regex):
	Define new member functions.
	* src/abg-suppression.cc
	(type_suppression::{get,set}_potential_data_member_names): Define new
	member functions.
	(type_suppression::{get,set}_potential_data_member_names_regex_str):
	Likewise.
	(type_suppression::suppresses_diff): Implement suppression using
	the new "has_data_member" and "has_data_member_regexp" properties.
	(read_type_suppression): Support parsing the new "has_data_member"
	and "has_data_member_regexp" properties of the type suppression
	directive.
	* tests/data/test-diff-suppr/has-data-member-[1-7].suppr: New
	suppression specifications for test purposes.
	* tests/data/test-diff-suppr/test-has-data-member-output-{1,2}.txt:
	New reference test outputs.
	* tests/data/test-diff-suppr/test-has-data-member-v{0,1}.cc:
	Source code of new input binary tests.
	* tests/data/test-diff-suppr/test-has-data-member-v{0,1}.o: New
	binary test inputs.
	* tests/data/Makefile.am: Add the test inputs below to source
	distribution.
	* tests/test-diff-suppr.cc (in_out_specs): Add the new test inputs
	above to this test harness.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2023-03-01 13:46:41 +01:00
Dodji Seketeli
12641b1130 Add support for BTF
This adds support for the BTF debug information format.  It provides a
new BTF front-end which can be instantiated by the function
tools::create_best_elf_based_reader().

For now, the BTF front-end supports the basic types (integers,
pointers, qualified types, typedefs, struct and unions and function
pointers) for functions and variables as emitted for the C language by
GCC.  It seems to be able to support the BTF debug information emitted
for the vmlinux kernel by the pahole tool as well.

When configured with the --enable-btf option, the WITH_BTF
pre-processor macro is defined, enabling the BTF support.  That option
is turned on by default if the /usr/include/bpf/btf.h header is found
on the system.  To disable this, one can use the --disable-btf option.

The abidw and abidiff programs have been adapted to use the BTF
front-end when provided with the '--btf' option, or if BTF debug
information is the only one present in the binary.

	* configure.ac: If the header /usr/include/bpf/btf.h exists, then
	define the WITH_BTF pre-processor macro, unless --disable-btf was
	provided.
	* doc/manuals/abidiff.rst: Document the new --btf option.
	* doc/manuals/abidw.rst: Likewise.
	* doc/manuals/kmidiff.rst: Likewise.
	* doc/manuals/abipkgdiff.rst: Likewise.
	* include/abg-btf-reader.h: New header file.  Contains the
	declaration of the new btf::reader class.
	* src/abg-btf-reader.cc: New source file.  Contains the
	definitions of the new btf::reader class.
	* include/Makefile.am: Add the new include/abg-btf-reader.h header
	file to source distribution.
	* include/abg-corpus.h (enum origin): Add a new BTF_ORIGIN
	enumerator.
	* include/abg-tools-utils.h (file_has_btf_debug_info): Declare new
	function.
	* src/abg-tools-utils.cc (file_has_btf_debug_info): Define new
	function.
	(create_best_elf_based_reader): Adapt to support BTF input.  If
	the user requested the BTF front-end, instantiate it.  Otherwise,
	if the input file has only BTF debug info, instantiate the BTF
	front end.
	* include/abg-elf-reader.h (elf::reader::find_btf_section):
	Declare new member function.
	(elf::reader::{function, variable}_symbol_is_exported): Add new
	overloads.
	* src/abg-elf-reader.cc (reader::priv::btf_section): New data
	member.
	(reader::find_btf_section): Define new member function.
	* src/Makefile.am: Add the new abg-ctf-reader.cc file to source
	distribution.
	* tools/abidw.cc (options::use_btf): New data member.
	(display_usage): Add a help string for the new --btf option.
	(parse_command_line): Support the new --btf option.
	(load_corpus_and_write_abixml):  If the user asked to use the btf
	front-end then use that one.
	* tools/abidiff.cc (options::use_btf): New data member.
	(options::options): Initialize it.
	(display_usage):: Add a help string to the new --btf options.
	(parse_command_line): Support the new --btf options.
	(main): If the user asked to use the btf front-end, then use that
	one.
	* tools/abidw.cc (options::use_btf): New data member.
	(options::options): Initialize it.
	(parse_command_line): Add a help string to the new --btf options.
	(load_corpus_and_write_abixml): If the user asked to use the btf
	front-end, then use that one.
	* tools/kmidiff.cc (options::use_btf): New data member.
	(options::options): Initialize it.
	(display_usage): Add a help string to the new --btf options.
	(parse_command_line): Add a help string to the new --btf options.
	(main): If the user asked to use the btf front-end, then use that
	one.
	* tools/abipkgdiff.cc (options::use_btf): New data member.
	(options::options): Initialize it.
	(display_usage): Add a help string to the new --btf options.
	(parse_command_line): Add a help string to the new --btf options.
	(compare, compare_to_self)
	(compare_prepared_linux_kernel_packages): If the user asked to use
	the btf front-end, then use that one.
	* tests/data/test-read-btf/test{0,1}.o: New binary test input
	file.
	* tests/data/test-read-btf/test{0,1}.c: Source code of the binary
	input file above.
	* tests/data/test-read-btf/test{0,1}.o.abi: Reference ABIXML
	output.
	* tests/data/test-abidiff-exit/btf/test0-report-{1,2}.txt: New
	test reference output.
	* tests/data/test-abidiff-exit/btf/test0-v{0,1}.o: New binary test
	input.
	* tests/data/test-abidiff-exit/btf/test0-v{0,1}.c: The source
	files of the binary inputs above.
	* tests/test-read-btf.cc: New test file to run the btf/abixml
	tests.
	* tests/Makefile.am: Add the new test files to the source
	distribution.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2023-01-06 21:05:53 +01:00
Dodji Seketeli
3c6a461bc0 Update website documentation for 2.2
* mainpage.txt: Update for 2.2.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2022-12-19 18:46:45 +01:00
Dodji Seketeli
d222b44733 dwarf-reader: Leverage ODR & DWZ
When DWARF debug info has been preprocessed with the DWZ tool, I think
we can assume that if two DIEs originating from the .gnu_debugaltlink
section have different offset, it means they are different, even if
they represent two types of the same nature and of the same name.
This is the whole point of DWZ.

When we process two DIEs originating from C++, it's possible "in
general" to assume that the One Definition Rule is in effect, meaning
that if two types of the same nature have the same name, they ought to
represent the same entity, meaning, they are the same type.

These two observations can lead to faster comparison of two aggregate
types of the same nature and of the same name.

This patch implements these two optimizations and use them by
default.

The first one is used by default on binaries that contains a
.gnu_debugaltlink section, which is the hint we use to detect that DWZ
was used to factorize DWARF DIEs.

The second of is used by default on DWARF DIEs originating from C++.

These optimizations can be de-activated on abidw and abidiff using the
--no-leverage-dwarf-factorization and --no-assume-odr-for-cplusplus.

	* doc/manuals/abidiff.rst: Add documentation for
	--no-leverage-dwarf-factorization and
	--no-assume-odr-for-cplusplus
	* doc/manuals/abidw.rst: Likewise.
	* doc/manuals/abipkgdiff.rst: Likewise.
	* include/abg-fe-iface.h (options::{leverage_dwarf_factorization,
	assume_odr_for_cplusplus}): New data members.
	* src/abg-dwarf-reader.cc (reader::leverage_dwarf_factorization_):
	New data member.
	(reader::leverage_dwarf_factorization): New accessor.
	(compare_dies): If we are allowed to leverage the DWARF
	factorization and if two type DIEs coming from the
	.gnu_debugaltlink DWARF section have different offset, then they
	are different.  Also, if we are allowed to assume ODR, use it to
	speed up class/struct/unions comparisons.
	* tools/abidiff.cc (options::{assume_odr_for_cplusplus,
	leverage_dwarf_factorization}): Define new data members.
	(options::options): Initialize them.
	(display_usage): Add new help strings for
	--no-leverage-dwarf-factorization and
	--no-assume-odr-for-cplusplus.
	(parse_command_line): Parse these new options.
	(set_generic_options): New function.
	(main): Use the new set_generic_options function.
	* tools/abidw.cc (options::{assume_odr_for_cplusplus,
	leverage_dwarf_factorization}): Define new data members.
	(options::options): Initialize them.
	(display_usage): Add new help strings for
	--no-leverage-dwarf-factorization and
	--no-assume-odr-for-cplusplus.
	(parse_command_line): Parse these new options.
	(set_generic_options): New function.
	(load_corpus_and_write_abixml): Use the new set_generic_options
	function.
	* tools/abipkgdiff.cc (options::{assume_odr_for_cplusplus,
	leverage_dwarf_factorization}): Define new data members.
	(options::options): Initialize them.
	(display_usage): Add new help strings for
	--no-leverage-dwarf-factorization and
	--no-assume-odr-for-cplusplus.
	(parse_command_line): Parse these new options.
	(set_generic_options): New function.
	(compare): Use it.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2022-11-30 17:17:15 +01:00
Guillermo E. Martinez
8fd02e0a10 Use the CTF reader by default when applicable
At the moment, the tools abidw, abidiff, abipkgdiff and kmidiff all
use the DWARF front-end by default.  When the "--ctf" option is added
to the command line, they use the CTF front-end.

This patch changes that behaviour in the way described below.

If the "--ctf" command line option is passed to the tool and if the
binary to analyze contains CTF debug info, then the CTF front-end is
used.

If the binary contains ONLY CTF debug info, then the CTF front-end is
used, even if no "--ctf" option was provided.

In all the other cases, the DWARF front-end is used.

Of course, the CTF front-end is not used at all if the CTF
functionality hasn't been enabled at configure time.

This new behaviour is effective for user space and Linux kernel
binaries.

	* doc/manuals/abidiff.rst: Adjust.
	* doc/manuals/abidw.rst: Likewise.
	* doc/manuals/abipkgdiff.rst: Likewise.
	* doc/manuals/kmidiff.rst: Likewise.
	* include/abg-elf-based-reader.h (initialize): Add member function.
	* include/abg-elf-reader.h (has_{dwarf,ctf}_debug_info): Add predicate
	functions.
	* include/abg-tools-utils.h (create_best_elf_based_reader): Add arguments.
	* src/abg-ctf-reader.cc (process_ctf_typedef, process_ctf_base_type)
	(process_ctf_function_type, process_ctf_sou_members, process_ctf_forward_type)
	(process_ctf_struct_type, process_ctf_union_type, process_ctf_array_type)
	(process_ctf_qualified_type, process_ctf_pointer_type, process_ctf_enum_type):
	Remove arguments. Using getters to access required information instead.
	(reader::cur_tu_): Add data member.
	(initialize): Add arguments.
	(cur_transl_unit): Add {get,set)ter.
	(slurp_elf_info): Clear `STATUS_DEBUG_INFO_NOT_FOUND' if corpus is
	`LINUX_KERNEL_BINARY_ORIGIN'.
	(reader::lookup_type): Remove.
	(reader::build_type): New member function.
	* src/abg-elf-reader.cc (reader::reader): Locate ctf debug info
	from binary file.
	(reader::reader): Reset base `fe_iface' constructor.
	(reader::has_{dwarf,ctf}_debug_info): New definitions.
	(reader::read_corpus): Set `STATUS_DEBUG_INFO_NOT_FOUND' according
	to corpus::origin.
	* src/abg-tools-utils.cc (dir_contains_ctf_archive): Define new member.
	(file_has_ctf_debug_info): Looks for kernel ctf debug information archive.
	(maybe_load_vmlinux_{dwarf,ctf}_corpus): Remove.
	(load_vmlinux_corpus): Define function to load IR from kernel
	regardless of the corpus::origin.
	(build_corpus_group_from_kernel_dist_under): Use
	create_best_elf_based_reader to select the front-end.
	(create_best_elf_based_reader): Adjust to allow fallback behaviour
	for different front-ends.
	* tests/data/Makefile.am: Add tests.
	* tests/data/test-diff-pkg-ctf/dirpkg-3-report-2.txt: Adjust.
	* tests/data/test-read-ctf/test-fallback.abi: New test case.
	* tests/data/test-read-ctf/test-fallback.c: Likewise.
	* tests/data/test-read-ctf/test-fallback.o: Likewise.
	* tests/data/test-read-dwarf/test-fallback.abi: Likewise.
	* tests/data/test-read-dwarf/test-fallback.c: Likewise.
	* tests/data/test-read-dwarf/test-fallback.o: Likewise.
	* tests/test-diff-pkg.cc: Adjust.
	* tests/test-read-common.cc (test_task::run_abidw): Use the
	`options:option' field.
	* tests/test-read-common.h (InOutSpec): Add new member.
	* tests/test-read-ctf.cc (in_out_specs): Add option field to test
	suite.  Add new test case.
	* tests/test-read-dwarf.cc: Likewise.
	* tools/abidiff.cc (main): Use create_best_elf_based_reader.
	* tools/abidw.cc: Likewise.
	* tools/abipkgdiff.cc: Likewise.

Signed-off-by: Guillermo E. Martinez <guillermo.e.martinez@oracle.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2022-11-28 16:52:33 +01:00
Dodji Seketeli
5eaeddc943 abidiff: add a --debug-tc option
Like what was done for abidw, this patch adds a --debug-tc option to
abidiff to debug type canonicalization issues.

With this option, just like for abidw, during type canonicalization,
each type comparison is done twice: once using structural comparison
and once using canonical comparison.  Both comparisons should yield
the same result otherwise, an abort signal is emitted, asking for
in-depth debugging to understand reason of the difference.

This option is enabled by the configure option
--enable-debug-type-canonicalization.

It proved useful in debugging some comparison errors I was looking at
recently.

	* doc/manuals/abidiff.rst: Add documentation for the new
	--debug-tc option.  Fix the existing documentation for
	--debug-self-comparison.
	* tools/abidiff.cc (options::do_debug_self_comparison): Renamed
	options::do_debug into this.
	(options::do_debug_type_canonicalization): Add new data member.
	(display_usage): Fix help string for the --debug option that is
	now --debug-self-comparison.  Also, add a help string for the new
	option --debug-tc option.
	(main): Adjust use options::do_debug into
	options::do_debug_self_comparison.  Call
	environment::debug_type_canonicalization() if the user provided
	the --debug-tc option.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2022-10-07 22:50:14 +02:00
Dodji Seketeli
43287b0319 Update website for 2.1 release.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2022-10-02 18:29:53 +02:00
Dodji Seketeli
755dfdb21c Allow restricting analyzed decls to exported symbols
Profiling showed that the DWARF reader scans too much data.

Basically, in build_translation_unit_and_add_to_ir,
build_ir_node_from_die is called on every single DIE that is seen, for
a given translation unit.

There are interfaces (function and variable decls) that are not
associated with exported ELF symbols and that are analyzed by
build_ir_node_from_die nonetheless.  For instance, interfaces that are
visible outside of their translation units are analyzed and the types
that are reachable from those interfaces are analyzed as well.

Once that is done, an ABI corpus is built with the subset of
interfaces that have exported ELF symbol (strictly those that are part
of the ABI), but types that are not necessarily reachable from those
ABI interfaces can also be put into the ABI corpus.

Some tools make use of this "lose" behaviour of libabigail.  For
instance, abicompat precisely wants to analyze interfaces with
undefined symbols.  For an application, those interfaces represents
the interfaces that the application expects to be provided by some
shared library.

When analyzing the exported interface of the Linux Kernel (or any
other huge application) however, analyzing more types than necessary
appears to incur a huge time penalty.

So, this patch introduces an optional behaviour whereby
build_translation_unit_and_add_to_ir is restricted to analyzing
interfaces that have exported ELF symbols only.  So only the types
reachable from those interfaces are analyzed.  This more than halves
the time spent by "abidw --noout vmlinux".

Strictly speaking, this new behaviour is triggered by a new option named
--exported-interfaces-only, supported by the tools abidw, abidiff,
abipkgdiff and kmidiff.

When looking at the Linux Kernel however, this option is enabled by
default.

Note that an option --allow-non-exported-interfaces is also introduce
to function under the previous model of operations.  This option is
enabled by default on all the tools when they are not looking at the
Linux Kernel.

With this enabled, analyzing the Linux Kernel is back to taking less
than a minute on a reasonable machine.

	* doc/manuals/tools-use-libabigail.txt: New doc text.
	* doc/manuals/Makefile.am: Add the new tools-use-libabigail.rst
	tool to the source distribution.
	* doc/manuals/abidiff.rst: Include the new
	tools-use-libabigail.rst.  Document the --exported-interfaces-only
	and --allow-non-exported-interfaces.
	* doc/manuals/abidw.rst: Likewise.
	* doc/manuals/abipkgdiff.rst: Likewise.
	* doc/manuals/kmidiff.rst: Likewise.
	* include/abg-ir.h
	(environment::{user_set_analyze_exported_interfaces_only,
	analyze_exported_interfaces_only}): Declare new accessors.
	* src/abg-ir.cc
	(environment::{user_set_analyze_exported_interfaces_only,
	analyze_exported_interfaces_only}): Define new accessors.
	* src/abg-dwarf-reader.cc (die_is_variable_decl)
	(die_is_function_decl): Define new static functions.
	(read_context::is_decl_die_with_exported_symbol): Define new
	member function.
	(read_context::get_{function,variable}_address): Const-ify the
	Dwarf_Die* parameter.
	(build_translation_unit_and_add_to_ir): If the user asks to
	analyze exported interfaces only,  the analyze only interfaces
	that have exported ELF symbols.
	(read_debug_info_into_corpus): If we are looking at the Linux
	Kernel, then only analyze exported interfaces unless the user asks
	otherwise.
	* src/abg-ir-priv.h
	(environment::priv::analyze_exported_interfaces_only_): Define new
	data member.
	* tools/abidiff.cc (options::exported_interfaces_only): Define new
	data member.
	(display_usage): Add new help strings for
	--exported-interfaces-only and --allow-non-exported-interfaces.
	(parse_command_line): Parse the new options
	--exported-interfaces-only and --allow-non-exported-interfaces.
	(main): Pass the value of opts.exported_interfaces_only to the
	environment.
	* tools/abidw.cc (options::exported_interfaces_only): Define new
	data member.
	(display_usage): Add new help strings for
	--exported-interfaces-only and --allow-non-exported-interfaces.
	(parse_command_line): Parse the new options
	(load_corpus_and_write_abixml)
	(load_kernel_corpus_group_and_write_abixml): Pass the value of
	opts.exported_interfaces_only onto the environment.
	* tools/abipkgdiff.cc (options::exported_interfaces_only): Define new
	data member.
	(display_usage): Add new help strings for
	--exported-interfaces-only and --allow-non-exported-interfaces.
	(parse_command_line): Parse the new options
	(compare_task::perform, self_compare_task::perform): Pass the
	value of opts.exported_interfaces_only onto the environment.
	(compare_prepared_linux_kernel_packages): Likewise.
	* tools/kmidiff.cc(options::exported_interfaces_only): Define new
	data member.
	(display_usage): Add new help strings for
	--exported-interfaces-only and --allow-non-exported-interfaces.
	(parse_command_line): Parse the new options
	(main): Pass the value of opts.exported_interfaces_only onto the
	environment.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2022-09-20 11:43:32 +02:00
Guillermo E. Martinez via Libabigail
5a36bb779d Add regression tests for abipkgdiff using ctf info
This patch is meant to execute the testsuite for abipkgdiff tool using
sources with CTF debug info.

	* doc/manuals/abipkgdiff.rst: Document the fact that abipkgdiff
	now supports the CTF format.
	* tests/data/test-diff-pkg-ctf/cracklib-2.9.6-15-ol8.x86_64-report-0.txt:
	New test input.
	* tests/data/test-diff-pkg-ctf/cracklib-2.9.6-15-ol8u0.x86_64.rpm:
	Likewise.
	* tests/data/test-diff-pkg-ctf/cracklib-2.9.6-15-ol8u6.x86_64.rpm:
	Likewise.
	* tests/data/test-diff-pkg-ctf/dirpkg-0-dir1/dir.abignore:
	Likewise.
	* tests/data/test-diff-pkg-ctf/dirpkg-0-dir1/libobj-v0.so:
	Likewise.
	* tests/data/test-diff-pkg-ctf/dirpkg-0-dir1/obj-v0.c: Likewise.
	* tests/data/test-diff-pkg-ctf/dirpkg-0-dir2/libobj-v0.so:
	Likewise.
	* tests/data/test-diff-pkg-ctf/dirpkg-0-dir2/obj-v0.c: Likewise.
	* tests/data/test-diff-pkg-ctf/dirpkg-0-report-0.txt: Likewise.
	* tests/data/test-diff-pkg-ctf/dirpkg-1-dir1/libobj-v0.so:
	Likewise.
	* tests/data/test-diff-pkg-ctf/dirpkg-1-dir1/obj-v0.c: Likewise.
	* tests/data/test-diff-pkg-ctf/dirpkg-1-dir2/dir.abignore:
	Likewise.
	* tests/data/test-diff-pkg-ctf/dirpkg-1-dir2/libobj-v0.so:
	Likewise.
	* tests/data/test-diff-pkg-ctf/dirpkg-1-dir2/obj-v0.c: Likewise.
	* tests/data/test-diff-pkg-ctf/dirpkg-1-report-0.txt: Likewise.
	* tests/data/test-diff-pkg-ctf/dirpkg-1-report-1.txt: Likewise.
	* tests/data/test-diff-pkg-ctf/dirpkg-2-dir1/libobj-v0.so:
	Likewise.
	* tests/data/test-diff-pkg-ctf/dirpkg-2-dir1/obj-v0.c: Likewise.
	* tests/data/test-diff-pkg-ctf/dirpkg-2-dir2/.abignore: Likewise.
	* tests/data/test-diff-pkg-ctf/dirpkg-2-dir2/dir.abignore:
	Likewise.
	* tests/data/test-diff-pkg-ctf/dirpkg-2-dir2/libobj-v0.so:
	Likewise.
	* tests/data/test-diff-pkg-ctf/dirpkg-2-dir2/obj-v0.c: Likewise.
	* tests/data/test-diff-pkg-ctf/dirpkg-2-report-0.txt: Likewise.
	* tests/data/test-diff-pkg-ctf/dirpkg-3-dir1/libobj-v0.so:
	Likewise.
	* tests/data/test-diff-pkg-ctf/dirpkg-3-dir1/obj-v0.c: Likewise.
	* tests/data/test-diff-pkg-ctf/dirpkg-3-dir2/.abignore: Likewise.
	* tests/data/test-diff-pkg-ctf/dirpkg-3-dir2/libobj-v0.so:
	Likewise.
	* tests/data/test-diff-pkg-ctf/dirpkg-3-dir2/obj-v0.c: Likewise.
	* tests/data/test-diff-pkg-ctf/dirpkg-3-report-0.txt: Likewise.
	* tests/data/test-diff-pkg-ctf/dirpkg-3-report-1.txt: Likewise.
	* tests/data/test-diff-pkg-ctf/dirpkg-3-report-2.txt: Likewise.
	* tests/data/test-diff-pkg-ctf/dirpkg-3.suppr: Likewise.
	* tests/data/test-diff-pkg-ctf/elfutils-libelf-0.186-1.x86_64.rpm:
	Likewise.
	* tests/data/test-diff-pkg-ctf/elfutils-libelf-0.186-2.x86_64.rpm:
	Likewise.
	* tests/data/test-diff-pkg-ctf/elfutils-libelf-0.186-report-0.txt:
	Likewise.
	* tests/data/test-diff-pkg-ctf/elfutils-libelf-0.186-report-1.txt:
	Likewise.
	* tests/data/test-diff-pkg-ctf/gmp-6.1.2-8-ol8u0.x86_64.rpm:
	Likewise.
	* tests/data/test-diff-pkg-ctf/gmp-6.2.0-10-ol9u0.x86_64.rpm:
	Likewise.
	* tests/data/test-diff-pkg-ctf/gmp-6.x.x86_64-report-0.txt:
	Likewise.
	* tests/data/test-diff-pkg-ctf/isl-0.16.1-6.x86_64.rpm: Likewise.
	* tests/data/test-diff-pkg-ctf/isl-0.16.1-7.x86_64.rpm: Likewise.
	* tests/data/test-diff-pkg-ctf/isl-0.16.1-report-0.txt: Likewise.
	* tests/data/test-diff-pkg-ctf/isl-debuginfo-0.16.1-6.x86_64.rpm:
	Likewise.
	* tests/data/test-diff-pkg-ctf/isl-debuginfo-0.16.1-7.x86_64.rpm:
	Likewise.
	* tests/data/test-diff-pkg-ctf/libdwarf-20180129-4-no-ctf.x86_64.rpm:
	Likewise.
	* tests/data/test-diff-pkg-ctf/libdwarf-20180129-4.x86_64.rpm:
	Likewise.
	* tests/data/test-diff-pkg-ctf/libdwarf-20180129-5-no-ctf.x86_64.rpm:
	Likewise.
	* tests/data/test-diff-pkg-ctf/libdwarf-20180129-5.x86_64.rpm:
	Likewise.
	* tests/data/test-diff-pkg-ctf/symlink-dir-test1-report0.txt:
	Likewise.
	* tests/data/test-diff-pkg-ctf/symlink-dir-test1/dir1/symlinks/foo.o:
	Likewise.
	* tests/data/test-diff-pkg-ctf/symlink-dir-test1/dir1/symlinks/libfoo.so:
	Likewise.
	* tests/data/test-diff-pkg-ctf/symlink-dir-test1/dir1/targets/foo.c:
	Likewise.
	* tests/data/test-diff-pkg-ctf/symlink-dir-test1/dir1/targets/foo.o:
	Likewise.
	* tests/data/test-diff-pkg-ctf/symlink-dir-test1/dir1/targets/libfoo.so:
	Likewise.
	* tests/data/test-diff-pkg-ctf/symlink-dir-test1/dir2/symlinks/foo.o:
	Likewise.
	* tests/data/test-diff-pkg-ctf/symlink-dir-test1/dir2/symlinks/libfoo.so:
	Likewise.
	* tests/data/test-diff-pkg-ctf/symlink-dir-test1/dir2/targets/foo.c:
	Likewise.
	* tests/data/test-diff-pkg-ctf/symlink-dir-test1/dir2/targets/foo.o:
	Likewise.
	* tests/data/test-diff-pkg-ctf/symlink-dir-test1/dir2/targets/libfoo.so:
	Likewise.
	* tests/data/test-diff-pkg-ctf/tarpkg-0-dir1.ta: Likewise.
	* tests/data/test-diff-pkg-ctf/tarpkg-0-dir1.tar: Likewise.
	* tests/data/test-diff-pkg-ctf/tarpkg-0-dir1.tar.bz2: Likewise.
	* tests/data/test-diff-pkg-ctf/tarpkg-0-dir1.tar.gz: Likewise.
	* tests/data/test-diff-pkg-ctf/tarpkg-0-dir2.ta: Likewise.
	* tests/data/test-diff-pkg-ctf/tarpkg-0-dir2.tar: Likewise.
	* tests/data/test-diff-pkg-ctf/tarpkg-0-dir2.tar.bz2: Likewise.
	* tests/data/test-diff-pkg-ctf/tarpkg-0-dir2.tar.gz: Likewise.
	* tests/data/test-diff-pkg-ctf/tarpkg-0-report-0.txt: Likewise.
	* tests/data/test-diff-pkg-ctf/tarpkg-1-dir1.tar.gz: Likewise.
	* tests/data/test-diff-pkg-ctf/tarpkg-1-dir2.tar.gz: Likewise.
	* tests/data/test-diff-pkg-ctf/tarpkg-1-report-0.txt: Likewise.
	* tests/data/test-diff-pkg-ctf/test-rpm-report-0.txt: Likewise.
	* tests/data/test-diff-pkg-ctf/test-rpm-report-1.txt: Likewise.
	* tests/data/test-diff-pkg-ctf/test-rpm-report-2.txt: Likewise.
	* tests/data/test-diff-pkg-ctf/test-rpm-report-3.txt: Likewise.
	* tests/data/test-diff-pkg-ctf/test-rpm-report-4.txt: Likewise.
	* tests/data/test-diff-pkg-ctf/test-rpm-report-5.txt: Likewise.
	* tests/data/Makefile.am: Add the test material above to source
	distribution.
	* tests/test-diff-pkg.cc (in_out_spec): Add the test inputs above
	to this harness.

Signed-off-by: Guillermo E. Martinez <guillermo.e.martinez@oracle.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2022-07-11 12:20:05 +02:00
Guillermo E. Martinez via Libabigail
68f369f218 kmidiff: Add CTF support to comparing Kernel trees
This patch adds a new --ctf option to kmidiff to make it support CTF
type information when analysing Linux Kernel trees.

	* doc/manuals/kmidiff.rst: Add documentation for the new --ctf option.
	* tools/kmidiff.cc (options::use_ctf): Define new data member.
	(display_usage): Add a help string for the --ctf option.
	(main): Adjust call to pass
	build_corpus_group_from_kernel_dist_under with origin being
	corpus::CTF_ORIGIN when the user provides the --ctf option.

Signed-off-by: Guillermo E. Martinez <guillermo.e.martinez@oracle.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2022-07-08 10:20:34 +02:00
Ben Woodard via Libabigail
57a5ce73cf abicompat: Support reading CTF and abixml
While abidw generates abidw and abidiff can consume that abidw
abicompat could only read from ELF objects with DWARF. To bring it in
line with the capabilities of abidiff, this patch adds the ability for
abicompat to read both abixml and CTF. The reason why being able to
handle abixml as well as an ELF file with DWARF is that it allows
someone to archive the abixml for an object and use it in place of
having to keep the entire object when doing abi compatibility studies.

The ability to handle CTF was also in the code that I copied over from
abidiff and so I brought it over at the same time. This should be
tested more extensively. The make check works and a trivial test using
the same object seems to work but I do not have any CTF other binaries
around to test against.

Also a feature that I asked for a long time ago was to fail if the
binaries don't have debug infomation which is needed for proper
comparison. This was added to abidiff but it didn't get added to
abicompat. Since the code was in the same area, I copied it over from
abidiff at the same time.

I do not think it makes sense to try to split these three features
apart because they are just replicating pre-existing code in a
different tool.

	* tools/abicompat.cc (options::{fail_no_debug_info, use_ctf}): New
	data members.
	(options::options): Initialize them.
	(display_usage): Add a help string for the new options
	--fail-no-debug-info and --ctf.
	(parse_command_line): Support parsing the new options
	--fail-no-debug-info and --ctf.
	(read_corpus): New static function.
	(main): Use the new read_corpus in lieu of using
	dwarf_reader::read_corpus_from_elf and/or  ctf_reader::read_corpus
	and/or xml::reader::read_corpus_from_input.
	* doc/manuals/abicompat.rst: add documentation for new options.

Signed-off-by: Ben Woodard <woodard@redhat.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2022-06-08 17:13:14 +02:00
Guillermo E. Martinez
28a629347f abipkgdiff: Add support to compare packages with CTF debug format
This patch add support in `abipkgdiff' to compare binaries with CTF
debug information inside of packages, when `--ctf' option is provided.

	* tools/abipkgdiff.cc: Include `abg-ctf-reader.h'.
	(options::use_ctf): Add new data member.
	(display_usage): Add `--ctf' usage.
	(compare): Add condition to use ctf-reader to extract
	(parse_command_line): Set `options::use_ctf' when --ctf
	option is provided.
	and build CTF corpora when `options::use_ctf' is set.
	(compare_to_self): Likewise.

Signed-off-by: Guillermo E. Martinez <guillermo.e.martinez@oracle.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2022-05-16 18:07:40 +02:00
Frederic Cambus
c70dfec08f Fix numbering error in the abidiff manual.
* doc/manuals/abidiff.rst: Fix numbering error for the
	--headers-dir2 option.

Signed-off-by: Frederic Cambus <fred@statdns.com>
2022-05-13 13:54:31 +02:00
Ben Woodard
c7a71ba2d1 Add an option ignore SONAME differences in libraries
There are rare use cases where we do not want to compare the SONAME when
testing libraries for compatiblity or diffing libraries. This adds an
option to ignore the SONAME when doing the comparison. In these cases,
we will edit the application's DT_NEEDED to point to the other library.

This reuses the show_soname_change() function and slightly changes its
meaning to not only control if the sonames are printed but also if
they are compared. There didn't seem to be any other users of this
function and slight semantic change seemed harmless.

	* doc/manuals/abicompat.rst - added new option
	* doc/manuals/abidiff.rst - added new option to manpage
	* src/abg-comparison.cc (compute_diff): don't bother comparing the
	sonames if you aren't going to print them.
	* tools/abicompat.cc (options::ignore_soname): Add new data
	member.
	(parse_command_line): Support the new --ignore-soname command line
	option.
	(display_usage): Add a description string for the new
	--ignore-soname command line option.
	(create_diff_context): Set the diff_context::show_soname_change
	from the new options::ignore_soname data member.
	* tools/abidiff.cc (options::ignore_soname): Add new data member.
	(display_usage): Add a description string for the new
	--ignore-soname command line option.
	(parse_command_line): Support the new --ignore-soname command line
	option.
	(set_diff_context_from_opts): Set the
	diff_context::show_soname_change from the new
	options::ignore_soname.

Signed-off-by: Ben Woodard <woodard@redhat.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2022-05-12 11:58:18 +02:00
Ben Woodard
f52c0ba416 Fix typo in abipkgdiff manpage
Add double dash to option name in man page. A minor typo.

        * doc/manuals/abipkgdiff.rst: add missing `--`

Signed-off-by: Ben Woodard <woodard@redhat.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2022-05-02 17:19:02 +02:00
George Rawlinson
eb3e549794 Bug 28663 - generate man page for kmidiff
This patch is based on a patch submitted to this bug report by George
Rawlinson <grawlinson@archlinux.org>.

It generates a man page for the kmidiff tool.

	* doc/manuals/conf.py: Update copyright year.  Generate man page
	for the kmidiff tool.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2022-01-19 12:29:12 +01:00
Guillermo E. Martinez via Libabigail
f76484cc9d Add regression tests for ctf reading
This patch implements some regression tests for ctf reading.
Since the code shares a lot of functionalities already used
in the readi-dwarf test, a library was built and test common
harness were moved to a common location. So input files for
test-read-{dwarf,ctf}.cc now are located in:
tests/data/test-read-common directory, ABIs description are
stored in the same location but in a separate file, one for
each binary debugging information: (e.g, test4-ctf.so.abi
and test4-dwarf.so.abi)

	* tests/test-read-ctf.cc: New ctf reading regression test.
	* tests/test-read-common.cc: New library to be used with
	test-read-{ctf,dwarf}.cc.
	* tests/test-read-common.h: Likewise.
	* tests/test-annotate.cc (in_out_specs): Adjust path for input files.
	* tests/Makefile.am: Build new tests/test-read-ctf.cc file.
	* tests/data/Makefile.am: Add test inputs and expected files.
	Add libtestreadcommon.a test library and use it for test-read-{ctf,dwarf}.
	* tests/test-read-dwarf.cc: Adapt test to use libtestreadcommon.a in
	test-read-common.{cc,h}.
	* tests/data/test-annotate/test3.so.abi: Adjust ELF input path file
	location to ./tests/data/test-read-common.
	* tests/data/test-annotate/test4.so.abi: Likewise.
	* tests/data/test-read-common/PR26261: Move test harness to
	test-read-common directory.
	* tests/data/test-read-common/PR27700: Likewise.
	* tests/data/test-read-common/test-PR26568-*: Likewise.
	* tests/data/test-read-common/test3.{c,so}: Likewise.
	* tests/data/test-read-common/test4.{c,so}: Likewise.
	* tests/data/test-read-common/crti*: Helper object to export
	_init and _fini sysmbols.
	* tests/data/test-read-ctf/test-ambiguous-struct-A.c: New testcase.
	* tests/data/test-read-ctf/test-ambiguous-struct-B.c: Likewise.
	* tests/data/test-read-ctf/test-conflicting-type-syms-a.c: Likewise.
	* tests/data/test-read-ctf/test-conflicting-type-syms-b.c: Likewise.
	* tests/data/test-read-ctf/test-enum.c: Likewise.
	* tests/data/test-read-ctf/test-enum-many.c: Likewise.
	* tests/data/test-read-ctf/test-enum-symbol.c: Likewise.
	* tests/data/test-read-ctf/test-struct-iteration.c: Likewise.
	* tests/data/test-read-ctf/test-dynamic-array.c: Likewise.
	* tests/data/test-read-ctf/test0.c: Likewise.
	* tests/data/test-read-ctf/test1.c: Likewise.
	* tests/data/test-read-ctf/test2.c: Likewise.
	* tests/data/test-read-ctf/test5.c: Likewise.
	* tests/data/test-read-ctf/test7.{c,h}: Likewise.
	* tests/data/test-read-ctf/test8.c: Likewise.
	* tests/data/test-read-ctf/test9.c: Likewise.
	* tests/data/test-read-ctf/test-ambiguous-struct-A.o.hash.abi: Testcase
	expected result.
	* tests/data/test-read-ctf/PR26261/PR26261-exe.abi: Likewise.
	* tests/data/test-read-ctf/PR27700/test-PR27700.abi: Likewise.
	* tests/data/test-read-ctf/test-ambiguous-struct-A.o.hash.abi: Likewise.
	* tests/data/test-read-ctf/test-ambiguous-struct-B.o.hash.abi: Likewise.
	* tests/data/test-read-ctf/test-conflicting-type-syms-a.o.hash.abi: Likewise.
	* tests/data/test-read-ctf/test-conflicting-type-syms-b.o.hash.abi: Likewise.
	* tests/data/test-read-ctf/test-enum.o.abi: Likewise.
	* tests/data/test-read-ctf/test-enum-many.o.hash.abi: Likewise.
	* tests/data/test-read-ctf/test-enum-symbol.o.hash.abi: Likewise.
	* tests/data/test-read-ctf/test-struct-iteration.o.abi: Likewise.
	* tests/data/test-read-ctf/test-dynamic-array.o.abi: Likewise.
	* tests/data/test-read-ctf/test0: Likewise.
	* tests/data/test-read-ctf/test0*.abi: Likewise.
	* tests/data/test-read-ctf/test1.so: Likewise.
	* tests/data/test-read-ctf/test1*.abi: Likewise.
	* tests/data/test-read-ctf/test2.so: Likewise.
	* tests/data/test-read-ctf/test2*.abi: Likewise.
	* tests/data/test-read-ctf/test3.so.abi: Likewise.
	* tests/data/test-read-ctf/test4*.abi: Likewise.
	* tests/data/test-read-ctf/test5.o.abi: Likewise.
	* tests/data/test-read-ctf/test7.o.abi: Likewise.
	* tests/data/test-read-ctf/test8.o.abi: Likewise.
	* tests/data/test-read-ctf/test9.o.abi: Likewise.
	* tests/data/test-read-dwarf/PR26261/PR26261-exe.abi: Update
	expected abixml file.
	* tests/data/test-read-dwarf/PR27700/test-PR27700.abi: Likewise.
	* tests/data/test-read-dwarf/test-PR26568-1.*.abi: Likewise.
	* tests/data/test-read-dwarf/test3*.abi: Likewise.
	* tests/data/test-read-dwarf/test4*.abi: Likewise.
	* doc/api/libabigail.doxy: Add tests/test-read-common.{cc,h} to
	doxygen.

Signed-off-by: Guillermo E. Martinez <guillermo.e.martinez@oracle.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2021-12-14 16:45:58 +01:00
Dodji Seketeli
3e0eeb9f98 suppression: Fix has_data_member_inserted_between = {offset_of(), offset_of()}
This should fix bug https://sourceware.org/bugzilla/show_bug.cgi?id=28073

There is at least a case where the evaluation of the suppression
specification rule incarnated by the property
has_data_member_inserted_between doesn't work.  This is in the context
of the following suppression specification:

    [suppress_type]
     name = struct_foo
     has_data_member_inserted_between = {offset_of(dm1), offset_of(dm2)}

The evaluation of the rule incarnated by
has_data_member_inserted_between fails in the context of a type change
where the data member "dm1" is removed from the type struct_foo.  In
that case, the evaluation of the suppression should ALWAYS yield to
the suppression specification NOT suppressing the change.  But in some
cases the change is suppressed nonetheless.

This patch fixes that.

The idea of the patch is that if the class has a removed data member
or if its size shrinks then no type change on that class can be
suppressed.  This is because those two kinds of change are
incompatible ABI (or at least API) changes.  So they should be
reported.

The patch also fixes the evaluation of the boundaries of the insertion
range expressed as an "offset_after" expression.

	* doc/manuals/libabigail-concepts.rst: Update the documentation to
	reflect that has_data_member* properties will never suppress any
	type change if the change carries a data member suppression or a
	type size reduction.
	* include/abg-fwd.h (get_last_data_member)
	(get_next_data_member_offset): Declare new functions.
	* include/abg-suppression.h
	(insertion_range::boundary_value_is_end): Declare new static
	member function.
	(type_supression::insertion_range::eval_boundary): Make this
	static function take an uint64_t rather than ssize_t.
	(type_suppression::insertion_range::integer_boundary::{integer_boundary,
	as_integer, operator int}): Make these member functions and
	operator take or return uint64_t rather than int.
	* src/abg-ir.cc (get_last_data_member)
	(get_next_data_member_offset): Define new functions.
	* src/abg-suppression.cc
	(type_suppression::suppresses_diff): Rework logic to better handle
	"has_data_member_inserted_*" properties in the context of class
	diffs.  If the diff object carries data member removal or size
	reduction, the diff object is not suppressed by the current type
	suppression.  Also, the property "has_data_member_inserted_at =
	end", is now represented by an insertion range where the beginning
	and the end of the range are both the max possible value of
	insertion range boundaries; the code is made to recognize that.
	(type_suppression::insertion_range::eval_boundary): Make this
	static function take an uint64_t rather than ssize_t.  If the
	boundary is expressed as a "offset_after" expression, make sure
	the offset of the next data member is considered if it's present.
	(type_suppression::insertion_range::integer_boundary::{integer_boundary,
	as_integer, operator int}): Make these take or return uint64_t
	rather than int.
	(type_suppression::insertion_range::boundary_value_is_end): Define
	new member function.
	(type_suppression::insertion_range::integer_boundary::priv::value_):
	Turn the type of this into uint64_t, from int.
	(type_suppression::insertion_range::integer_boundary::priv::priv):
	The parameter of this is now uint64_t, from int.
	* tests/data/test-diff-suppr/PR28073/PR28073-bitfield-removed.c:
	New test source code.
	* tests/data/test-diff-suppr/PR28073/PR28073-bitfield-removed.o:
	New test binary.
	* tests/data/test-diff-suppr/PR28073/PR28073-bitfield-removed.o.abi:
	New test input.
	* tests/data/test-diff-suppr/PR28073/PR28073-output-{1,2}.txt: New
	test reference output.
	* tests/data/test-diff-suppr/PR28073/PR28073.after.o: New test
	binary.
	* tests/data/test-diff-suppr/PR28073/PR28073.after.o.abi: New test
	input.
	* tests/data/test-diff-suppr/PR28073/PR28073.before.o: New test
	binary.
	* tests/data/test-diff-suppr/PR28073/PR28073.before.o.abi: New
	test input.
	* tests/data/test-diff-suppr/PR28073/PR28073.c: New test source
	code.
	* tests/data/test-diff-suppr/PR28073/bitfield.suppr: New test
	input.
	* tests/data/Makefile.am: Add the new test material to source
	distribution.
	* tests/test-diff-suppr.cc: Add the new test input to this test
	harness.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2021-12-06 14:39:32 +01:00
Jose E. Marchesi via Libabigail
18569fc154 abidw: add support for CTF
This patch adds support for CTF to the abidw utility.  It depends on
the previous patch that makes abigail::ctf_reader::read_corpus to
return a status code.

	* tools/abidw.cc: Conditionally include abg-ctf-reader.h.
	(load_corpus_and_write_abixml): Do not get a
	dwarf_reader::read_context as an argument.
	(main): Adjust call to load_corpus_and_write_abixml accordingly.
	(struct options): New option use_ctf.
	(options): ... and initialize it.
	(display_usage): Document --ctf.
	(parse_command_line): Handle --ctf.
	* doc/manuals/abidw.rst: Document --ctf.

Signed-off-by: Jose E. Marchesi <jose.marchesi@oracle.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2021-11-18 09:51:06 +01:00
Dodji Seketeli
522cc62b9b abidw: Add --abixml-version
Add a command line option to display the version number of the ABIXML
output format.

	* doc/manuals/abidw.rst: Document the --abixml-version command
	line option.
	* configure.ac (ABIXML_VERSION_MAJOR, ABIXML_VERSION_MINOR):
	Define these two new autoconf variables.
	* include/abg-config.h (abigail_get_abixml_version): Declare new
	function.
	* include/abg-tools-utils.h (get_abixml_version_string): Declare
	new function.
	* include/abg-version.h.in (ABIGAIL_ABIXML_VERSION_MAJOR)
	(ABIGAIL_ABIXML_VERSION_MINOR): Define new preprocessor macros.
	* src/abg-config.cc (config::config): Initialize
	config::m_format_{minor,major} using the newly defined
	preprocessor macros ABIGAIL_ABIXML_VERSION_M{IN,AJ}OR.
	* src/abg-tools-utils.cc (get_abixml_version_string): Define new
	function.
	* tools/abidw.cc (options::display_abixml_version): Define new
	data member.
	(options::options): Initialize it.
	(display_usage): Emit a help string for the new --abixml-version
	option.
	(parse_command_line): Parse the --abixml-version string.
	(main): Emit the abixml version when asked.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2021-11-12 18:31:28 +01:00
Jose E. Marchesi via Libabigail
8c22f5fdc9 Add support for the CTF debug format to libabigail.
CTF (C Type Format) is a lightweight debugging format that provides
information about C types and the association between functions and
data symbols and types.  It is designed to be very compact and
simple.  More can be learned about it at https://ctfstd.org.

This patch introduces support in libabigail to extract ABI information
from CTF stored in ELF files.

A few notes on this implementation:

- The implementation is complete in terms of CTF support.  Every CTF
  feature is processed and handled to generate libabigail IR.  This
  includes basic types, typedefs, pointer, array and struct types.
  The CTF record of data objects (variables) and functions are also
  used in order to generate the corresponding libabigail IR artifacts.

- The decoding of CTF data is done using the libctf library which is
  part of binutils.  In order to link with it, binutils shall be built
  with --enable-shared for libctf.so to become available.

- This initial implementation is aimed to simplicity.  We have not
  tried to resolve any and every corner case that may require special
  handling.  We have observed that the DWARF front-end (which is
  naturally way more complex as the scope is way bigger) is plagued
  with hacks to handle such situations.  However, for the CTF support
  we prefer to proceed in a simpler and more modest way: we will
  handle these problems if/when we find them.  The fact that CTF only
  supports C (currently) certainly helps there.

- Likewise, in this basic support we are not handling symbol
  suppressions or other goodies that libabigail provides.  We are new
  to libabigail and ABI analysis, and at this point we simply don't
  have a clear picture about what is most useful/relevant to support
  or not.  With the maintainer's blesssing, we will tackle that
  functionaly after this basic support is applied upstream.

- The implementation in abg-ctf-reader.{cc,h} is pretty much
  self-contained.  As a result there is some duplication in terms of
  ELF handling with the DWARF reader, but since that logic is very
  simple and can be easily implemented, we don't consider this to be a
  big deal (for now.)  Hopefully the maintainers agree.

- The libabigail tools assume that ELF means to always use DWARF to
  generate the ABI IR.  We added a new command-line option --ctf to
  the tools in order to make them to use the CTF debug info instead.
  We are definitely not sure whether this is the best user interface.
  In fact I would be suprised if it was ;)

- We added support for --ctf to both abilint and abidiff.   We are not
  sure whether it would make sense to add support for CTF to the other
  tools.  Feedback welcome.

- We are pondering about what to do in terms of testing.  We have
  cursory tested this implementation using abilint and abidiff.  We
  know we are generating IR corpus that seem to be ok.  It would be
  good however to be able to run the libabigail testsuites using CTF.
  However the testsuites may need some non-trivial changes in order to
  make this possible.  Let's talk about that :)

	* configure.ac: Check for libctf.
	* src/abg-ctf-reader.cc: New file.
	* include/abg-ctf-reader.h: Likewise.
	* src/Makefile.am (libabigail_la_SOURCES): Add abg-ctf-reader.cc
	conditionally.
	* include/Makefile.am (pkginclude_HEADERS): Add abg-ctf-reader.h
	conditionally.
	* tools/abilint.cc (struct options): New option `use_ctf'.
	(display_usage): Documentation for --ctf.
	(parse_command_line): Handle --ctf.
	(main): Honour --ctf.
	* tools/abidiff.cc (struct options): New option `use_ctf'.
	(display_usage): Documentation for --ctf.
	(parse_command_line): Handle --ctf.
	(main): Honour --ctf.
	* doc/manuals/abidiff.rst: Document --ctf.
	* doc/manuals/abilint.rst: Likewise.

Signed-off-by: Jose E. Marchesi <jose.marchesi@oracle.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2021-11-02 12:43:14 +01:00
Dodji Seketeli
faba5ababb Update licensing information on the web page after 2.0
* doc/website/mainpage.txt: Libabigail is now Apache V2 + LLVM
	exception.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2021-10-18 17:08:14 +02:00
Dodji Seketeli
623391a040 Add --enable-debug-type-canonicalization to configure
This configure option adds the possibility to debug the type
canonicalization process specifically.

When this new configure option is turned on, in
ir::get_canonical_type_for, when the type T, candidate for
canonicalization is compared to a given canonical type C, the
comparison is done twice; once using structural equality and once
using canonical equality whenever it's possible.  For all the
sub-types of T and C, structural equality and canonical equality must
yield the same result.  Otherwise, an error message is emitted and the
process aborts.

This all happens when using the abidw program with the --enable-tc or
--enable-type-canonicalization option.

This has proven to be very helpful to detect type canonicalization issues.

For instance, here is a trace of canonicalization issue that was
detected thanks to this patch:

    $ build/tools/abidw --debug-tc /usr/lib64/libwiretap.so.11.0.8
    structural & canonical equality different for type: function type void (wtap*)
    in compare_types_during_canonicalization at: /home/dodji/git/libabigail/PR28364/src/abg-ir.cc:13575: execution should not have reached this point!
    Abandon (core dumped)

This means that right after canonicalizing the type "void (wtap*)",
structural and canonical equality yield different results.  So it
means there is a problem with that type specifically that makes its
canonicalization "go wrong".  This requires further debugging to
understand, but at least, we are super close to the root cause of the
canonicalization problem.

	* configure.ac: Support the new
	--enable-debug-type-canonicalization option.  Define macro
	WITH_DEBUG_TYPE_CANONICALIZATION accordingly.
	* doc/manuals/abidw.rst: Update documentation.
	* include/abg-ir.h
	(environment::debug_type_canonicalization_is_on): Declare new
	member function if WITH_DEBUG_TYPE_CANONICALIZATION is defined.
	* src/abg-ir-priv.h
	(environment::priv::{use_canonical_type_comparison_,
	debug_type_canonicalization_}): Define new data members if
	WITH_DEBUG_TYPE_CANONICALIZATION is defined.
	(environment::priv::priv): Initialize them.
	* src/abg-ir.cc (try_canonical_compare): When
	WITH_DEBUG_TYPE_CANONICALIZATION is defined, perform comparison
	using either structural or canonical equality depending on the
	environment::priv::use_canonical_type_comparison_ flag.
	(environment::debug_type_canonicalization_is_on): Define member
	function when WITH_DEBUG_TYPE_CANONICALIZATION is defined.
	(compare_types_during_canonicalization): Define new function.
	(type_base::get_canonical_type_for): Use the new function
	compare_types_during_canonicalization.
	* tools/abidw.cc (options::debug_type_canonicalization): Define
	new data member.
	(option::option): Initialize it.
	(display_usage): Add help string for --debug-tc.
	(parse_command_line): Support new option --debug-tc or
	--debug-type-canonicalization.
	(load_corpus_and_write_abixml): Turn type canonicalization
	debugging on if --enable-tc is provided.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2021-10-18 09:40:15 +02:00
Dodji Seketeli
438015b774 Update libabigail web page for 2.0 release
* doc/website/mainpage.txt: Update.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2021-10-04 16:07:37 +02:00
Dodji Seketeli
46b1ab08b0 Bug 27995 - Self comparison error from abixml file
There are several self comparison issues uncovered by comparing the
file test-PR27995.abi (provided in the bug report) against itself.
This patch address them all as well as the regressions induced on some
of the test suite and then and updates the other reference test suite
output that need it.

In the equals overload for decl_base, we compare the non-internal
versions of qualified decl names.  For var_decls of anonymous class or
union types, the non-internal version is the flat-representation of
the type.  Thus a benign change in a data member name of the anonymous
type might cause the equals function to consider the var_decls to be
wrongly different.  The internal version of the qualified decl name
should return a name that is stable for types, irrespective of these
benign variations.  The patch thus makes the equals overload for
decl_base to compare internal versions of qualified decl names instead.

The patch ensures that enum_type_decl::get_pretty_representation
return and internal pretty representation that is "stable" for
anonymous types.  Basically, all anonymous enums will have the same of
name that looks like "__anonymous_enum__".  This is to ensure two
things: first, that all anonymous enums are compared against each
other during type canonicalization, ensuring that when two anonymous
enums are canonically different, it really is because of changes in
their enumerators or basic type, not because of anything having to do
with their artificial names.  Second, that in the equals overload for
decl_base, their internal qualified name always compare equal.  This
nullifies the risk of having anonymous types compare different because
of their (non existent) name.  This is because libabigail's dwarf
reader assigns artificial unique names to anonymous types, so we don't
want to use these during actual type comparison.

We do something similar for class_decl::get_pretty_representation and
union_decl::get_pretty_representation where the pretty internal
representation for class/union decl would now be
__anonymous_{struct,union}__.

The patch scouts the uses of get_pretty_representation() to make sure
to use avoid using the internal-form of the pretty representations
when it's not warranted.  It also updates the doxygen comments of the
overloads of that function.

In the abixml reader, we were wrongly canonicalizing array types
early, even before they were fully created.  The was leading to
spurious type chances down the road.

The patch also fixes the caching of the name of function types by
making it consistent with caching of the names of the other types of
the system.  The idea is that we don't cache the name of a function
type until it's canonicalize.  This is because the type might be
edited during its pre-canonicalization life time; and that editing
might change its name.  However once the type is canonicalized, it
becomes immutable.  At that point we can cache its name, for
performance purposes.  Note that we need to do that both for the
"internal version" of the type name (used for canonilization purposes)
and the "non-internal version" one, which is used for other purposes.

This caching scheme wasn't respected for function types, so we were
caching a potentially wrong name for the type after its
canonicalization.

Last but not least, there is a problem that makes canonical type
comparison different from structural type comparison.
Let's consider these two declarations:

    typedef int FirstInt;
    typedef int SecondInt;

Now, consider these two pointer types: FirstInt* and SecondInt*;
These two pointer types are canonically different because they have
different type names.  This is because during type canonicalization,
types with the same "pretty representation" are compared against each
other.  So types with different type names will certainly have
different pretty representations and won't be compared; they are thus
going to have different canonical types.

However, FirstInt* and SecondInt* do compare equal, structurally,
because the equals overload for pointer_type_def compares the
pointed-to types of pointers by peeling off typedefs.  So, here, as
both pointed-to types are 'int' when the typedefs are peeled off, the
two pointers structurally compare equal.  This discrepancy between
structural and canonical equality introduces subtle and spurious type
changes depending on the order in which types are canonicalized.  For
instance:

    struct {FirstInt* m0;};   /* First type.  */

    struct {SecondInt* m0;};  /* Second type. */

If FirstInt* and SecondInt* are canonicalized before their containing
anonymous types, then the two anonymous types will compare different
(because FirstInt* and SecondInt* compare different) and have
different canonical types.  If, however, the anonymous types are
canonicalized before FirstInt* and SecondInt*, then will compare equal
because FirstInt* and SecondInt* are structurally equivalent.
FirstInt* and SecondInt* will be canonicalized latter and have
different canonical types (because they have different type names)
despite being structurally equivalent.

The change in the order of canonicalization can happen when
canonicalizing types from a corpus coming from DWARF as opposed to
canonicalizing types from a corpus coming from abixml.

The patch fixes this discrepancy by not peeling off typedefs from the
pointed-to types when comparing pointers.  Note that this makes us
regress on bug https://sourceware.org/bugzilla/show_bug.cgi?id=27236,
where the typedef peeling was introduced.  In hindsight, introducing
that typedef peeling was a mistake.  I'll try to address that bug
again in a subsequent patch.

	* doc/manuals/abidiff.rst: Add documentation for the --debug
	option.
	* src/abg-ir.cc (equals): In the overload for decl_base consider
	the internal version of qualified decl name.  In the overload for
	pointer_type_def do not peel typedefs off from the compared
	pointed-to types.  In the overload for typedef_decl compare the
	typedef as a decl as well.  In the overload for var_decl, compare
	variables that have the same ELF symbols without taking into
	account their qualified name, rather than their name.  Stop
	comparing data member without considering their names.
	In the overload for class_or_union, when a decl-only class that is
	ODR-relevant is compared against another type, assume that
	equality if names are equal.  This is useful in environments where
	some TUs are ODR-relevant and others aren't.
	(*::get_pretty_representation): Update doxygen comments.
	(enum_type_decl::get_pretty_representation): Return an internal
	pretty representation that is stable across all anonymous enums.
	(var_decl::get_anon_dm_reliable_name): Use the non-internal pretty
	representation for anonymous data members.
	(function_type::priv::temp_internal_cached_name_): New data
	member.
	(function_type::get_cached_name): Cache the internal name after
	the function type is canonicalized.  Make sure internal name and
	non-internal name are cached separately.
	(class_or_union::find_anonymous_data_member): Look for the anonymous
	data member by looking at its non-internal name.
	({class, union}_decl::get_pretty_representation): Use something like "class
	__anonymous_{union,struct}__" for all anonymous classes, so that they can
	all be compared against each other during type canonicalization.
	(type_has_sub_type_changes): Use non-internal pretty
	representation.
	(hash_type_or_decl, function_decl_is_less_than:): Use internal
	pretty representation for comparison here.
	* src/abg-reader.cc (read_context::maybe_canonicalize_type): Don't
	early canonicalize array types.
	* src/abg-writer.cc (annotate): Use non-internal pretty
	representation.
	* tests/data/test-diff-filter/test-PR27995-report-0.txt: New
	reference report.
	* tests/data/test-diff-filter/test-PR27995.abi: New test input
	abixml file.
	* tests/data/Makefile.am: Add test-PR27995.abi,
	test-PR27995-report-0.txt to the source distribution.
	* tests/data/test-annotate/libtest23.so.abi: Adjust.
	* tests/data/test-diff-dwarf/test6-report.txt: Adjust.
	* tests/data/test-diff-filter/test31-pr18535-libstdc++-report-0.txt: Adjust.
	* tests/data/test-diff-filter/test31-pr18535-libstdc++-report-1.txt: Adjust.
	* tests/data/test-diff-filter/test41-report-0.txt: Adjust.
	* tests/data/test-diff-filter/test43-decl-only-def-change-leaf-report-0.txt: Adjust.
	* tests/data/test-diff-filter/test8-report.txt: Adjust.
	* tests/data/test-diff-pkg/libICE-1.0.6-1.el6.x86_64.rpm--libICE-1.0.9-2.el7.x86_64.rpm-report-0.txt:
	Adjust.
	* tests/data/test-diff-pkg/spice-server-0.12.4-19.el7.x86_64-0.12.8-1.el7.x86_64-report-0.txt:
	Adjust.
	* tests/data/test-diff-pkg/spice-server-0.12.4-19.el7.x86_64-0.12.8-1.el7.x86_64-report-2.txt:
	Adjust.
	* tests/data/test-diff-pkg/spice-server-0.12.4-19.el7.x86_64-0.12.8-1.el7.x86_64-report-3.txt:
	Adjust.
	* tests/data/test-diff-pkg/tbb-4.1-9.20130314.fc22.x86_64--tbb-4.3-3.20141204.fc23.x86_64-report-0.txt:
	Adjust.
	* tests/data/test-diff-pkg/tbb-4.1-9.20130314.fc22.x86_64--tbb-4.3-3.20141204.fc23.x86_64-report-1.txt:
	Adjust.
	* tests/data/test-diff-suppr/test39-opaque-type-report-0.txt: Adjust.
	* tests/data/test-read-dwarf/PR22015-libboost_iostreams.so.abi: Adjust.
	* tests/data/test-read-dwarf/PR22122-libftdc.so.abi: Adjust.
	* tests/data/test-read-dwarf/libtest23.so.abi: Adjust.
	* tests/data/test-read-dwarf/test-libandroid.so.abi: Adjust.
	* tests/data/test-read-dwarf/test11-pr18828.so.abi: Adjust.
	* tests/data/test-read-dwarf/test12-pr18844.so.abi: Adjust.
	* tests/data/test-read-dwarf/test9-pr18818-clang.so.abi: Adjust.
	* tests/test-diff-filter.cc (in_out_specs): Add the
	test-PR27995.abi to the test harness.
	* tools/abidiff.cc (options::do_debug): New data member.
	(options::options): Initialize it.
	(parse_command_line): Parse --debug.
	(main): Activate self comparison debug if the user provided
	--debug.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2021-08-11 17:38:14 +02:00
Dodji Seketeli
e330b57a6a doc: Fix typo
David Marchand <dmarchand@redhat.com> found this typo.  Fixed thus.

	* doc/manuals/libabigail-concepts.rst: Fix typo.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2021-06-10 15:14:41 +02:00
Dodji Seketeli
104468d1a4 Detect failed self comparison in type canonicalization of abixml
During the self comparison triggered by "abidw --abidiff <binary>",
some comparison errors can happen when canonicalizing types that are
"de-serialized" from the abixml that was serialized from the input
binary.

This patch adds some debugging checks and messaging to emit a message
when a type from the abixml appears to not "match" the original type
from the initial corpus it originated from.

This is the more detailed description:

Let's consider a type T coming from the corpus of the input binary.

That input corpus is serialized into abixml and de-serialized again
into a second corpus that we shall name the abixml corpus.  From that
second corpus, let's consider the type T' that is the result of
serializing T into abixml and de-serializing it again.  T is said to
be the original type of T'.  If T is a canonical type, then T' should
equal T.  Otherwise, if T is not a canonical type, its canonical type
should equal the canonical type of T'.

For the sake of simplicity, let's consider that T is a canonical
type.  During the canonicalization of T', T' should equal T.  Each and
every canonical type coming from the abixml corpus should be equal to its
original type from the binary corpus.

If a T' is different from its original type T, then there is an
"equality problem" between T and T'.  In other words, there is a
mismatch between T and T'.  We want to be notified of that problem so
that we can debug it further and fix it.

So this patch introduces the option "abidw --debug-abidiff <binary>"
to trigger the "debug self comparison mode".  At canonicalization
time, we detect that we are in that debug self comparison mode and
during canonicalization of types from the abixml corpus, it detects
when they compare different from their counterpart from the original
corpus.

This debugging capability can be enabled at configure time with a new
--enable-debug-self-comparison configure option.  That option defines
a new WITH_DEBUG_SELF_COMPARISON compile time macro that is used to
conditionally compile the implementation of this debugging feature.

So, one example of this might look like this:

    abidw  --debug-abidiff bin:
    error: problem detected with type 'typedef Vmalloc_t' from second corpus
    error: problem detected with type 'Vmalloc_t*' from second corpus
    [...]

So that means the "typedef Vmalloc_t" read from the abixml compares
different from its original type where it should not.

So armed with this new insight, I know I need to debug that comparison
in particular to see why it wrongly results in two different types.

	* doc/manuals/abidw.rst: Add documentation for the --debug-abidiff
	option.
	* include/abg-ir.h (environment::{set_self_comparison_debug_input,
	get_self_comparison_debug_inputs, self_comparison_debug_is_on}):
	Declare new methods.
	* configure.ac: Define a new --enable-debug-self-comparison option
	that is disabled by default.  That option defines a new
	WITH_DEBUG_SELF_COMPARISON preprocessor macro.
	* src/abg-ir.cc
	(environment::priv::{first_self_comparison_corpus_,
	second_self_comparison_corpus_, self_comparison_debug_on_}): New
	data members.  Also, re-indent the data members.
	(environment::{set_self_comparison_debug_input,
	get_self_comparison_debug_inputs, self_comparison_debug_is_on}):
	Define new method.
	(type_base::get_canonical_type_for): In the "debug self comparison
	mode", if a type coming from the second corpus compares different
	from its counterpart coming from the first corpus then log a debug
	message.
	* src/abg-dwarf-reader.cc (read_debug_info_into_corpus): When
	loading the first corpus, if the debug self comparison mode is on,
	then save that corpus on the side in the environment.
	* src/abg-reader.cc (read_corpus_from_input): When loading the
	second corpus, if the debug self comparison mode is on, then save
	that corpus on the side in the environment.
	* tools/abidw.cc: Include the config.h file for preprocessor
	macros defined at configure
	(options::debug_abidiff): New data member.
	(parse_command_line): Parse the --debug-abidiff option.
	(load_corpus_and_write_abixml): Switch the self debug mode on when
	the --debug-abidiff option is provided.  Use a read_context for
	the abixml loading.  That is going to be useful for subsequent
	patches.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2021-05-25 12:16:25 +02:00
Dodji Seketeli
6e5b4471f9 mainpage: Update web page for 1.8 release
* doc/website/mainpage.txt: Update web page for 1.8 release

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2021-01-11 15:10:19 +01:00
Dodji Seketeli
c80f79271a Re-license the project to Apache v2 With LLVM Exception
Thanks to the previous work done, changing the license is just a
matter of changing the SPDX identifer from "LGPL-3.0-or-later" to
"Apache-2.0 WITH LLVM-exception".  Note that for the abigail.m4,
tests/test-dot.cc and tests/test-svg.cc the change was from
"GPL-3.0-or-later WITH GCC-exception-3.1" to "Apache-2.0 WITH
LLVM-exception".  include/abg-cxx-compat.h was changed from
"LGPL-2.0-or-later" to "Apache-2.0 WITH LLVM-exception".  Source code
of programs (as opposed to source code of the library) where generally
licensed under GPL-3.0-or-later; they are also now licensed
"Apache-2.0 WITH LLVM-exception".

This is what this patch does.

	* abigail.m4: Change the SPDX identifier from "GPL-3.0-or-later
	WITH GCC-exception-3.1" to "Apache-2.0 WITH LLVM-exception"
	* include/abg-cxx-compat.h: Change the SPDX identifier from
	"LGPL-2.0-or-later" to "Apache-2.0 WITH LLVM-exception".
	* .clang-format: Change the SPDX identifier from
	  "LGPL-3.0-or-later" to "Apache-2.0 WITH LLVM-exception".
	* Makefile.am: Likewise.
	* bash-completion/Makefile.am: Likewise.
	* bash-completion/abicompat: Likewise.
	* bash-completion/abidiff: Likewise.
	* bash-completion/abidw: Likewise.
	* bash-completion/abilint: Likewise.
	* bash-completion/abinilint: Likewise.
	* bash-completion/abipkgdiff: Likewise.
	* bash-completion/abisym: Likewise.
	* bash-completion/fedabipkgdiff: Likewise.
	* configure.ac: Likewise.
	* default.abignore: Likewise.
	* doc/Makefile.am: Likewise.
	* doc/api/libabigail.doxy: Likewise.
	* doc/manuals/Makefile.am: Likewise.
	* doc/website/libabigail-website.doxy: Likewise.
	* include/Makefile.am: Likewise.
	* include/abg-comp-filter.h: Likewise.
	* include/abg-comparison.h: Likewise.
	* include/abg-config.h: Likewise.
	* include/abg-corpus.h: Likewise.
	* include/abg-diff-utils.h: Likewise.
	* include/abg-dwarf-reader.h: Likewise.
	* include/abg-fwd.h: Likewise.
	* include/abg-hash.h: Likewise.
	* include/abg-ini.h: Likewise.
	* include/abg-interned-str.h: Likewise.
	* include/abg-ir.h: Likewise.
	* include/abg-libxml-utils.h: Likewise.
	* include/abg-libzip-utils.h: Likewise.
	* include/abg-reader.h: Likewise.
	* include/abg-regex.h: Likewise.
	* include/abg-reporter.h: Likewise.
	* include/abg-sptr-utils.h: Likewise.
	* include/abg-suppression.h: Likewise.
	* include/abg-tools-utils.h: Likewise.
	* include/abg-traverse.h: Likewise.
	* include/abg-version.h.in: Likewise.
	* include/abg-viz-common.h: Likewise.
	* include/abg-viz-dot.h: Likewise.
	* include/abg-viz-svg.h: Likewise.
	* include/abg-workers.h: Likewise.
	* include/abg-writer.h: Likewise.
	* scripts/dot_to_png.sh: Likewise.
	* scripts/dot_to_svg.sh: Likewise.
	* scripts/make-verbose.sh: Likewise.
	* scripts/svg_to_plain_svg.sh: Likewise.
	* scripts/svg_to_png_and_pdf.sh: Likewise.
	* src/Makefile.am: Likewise.
	* src/abg-comp-filter.cc: Likewise.
	* src/abg-comparison-priv.h: Likewise.
	* src/abg-comparison.cc: Likewise.
	* src/abg-config.cc: Likewise.
	* src/abg-corpus-priv.h: Likewise.
	* src/abg-corpus.cc: Likewise.
	* src/abg-default-reporter.cc: Likewise.
	* src/abg-diff-utils.cc: Likewise.
	* src/abg-dwarf-reader.cc: Likewise.
	* src/abg-elf-helpers.cc: Likewise.
	* src/abg-elf-helpers.h: Likewise.
	* src/abg-hash.cc: Likewise.
	* src/abg-ini.cc: Likewise.
	* src/abg-internal.h: Likewise.
	* src/abg-ir-priv.h: Likewise.
	* src/abg-ir.cc: Likewise.
	* src/abg-leaf-reporter.cc: Likewise.
	* src/abg-libxml-utils.cc: Likewise.
	* src/abg-libzip-utils.cc: Likewise.
	* src/abg-reader.cc: Likewise.
	* src/abg-regex.cc: Likewise.
	* src/abg-reporter-priv.cc: Likewise.
	* src/abg-reporter-priv.h: Likewise.
	* src/abg-suppression-priv.h: Likewise.
	* src/abg-suppression.cc: Likewise.
	* src/abg-tools-utils.cc: Likewise.
	* src/abg-traverse.cc: Likewise.
	* src/abg-viz-common.cc: Likewise.
	* src/abg-viz-dot.cc: Likewise.
	* src/abg-viz-svg.cc: Likewise.
	* src/abg-workers.cc: Likewise.
	* src/abg-writer.cc: Likewise.
	* tests/Makefile.am: Likewise.
	* tests/data/Makefile.am: Likewise.
	* tests/lib/catch.cc: Likewise.
	* tests/mockfedabipkgdiff.in: Likewise.
	* tests/print-diff-tree.cc: Likewise.
	* tests/runtestcanonicalizetypes.sh.in: Likewise.
	* tests/runtestdefaultsupprs.py.in: Likewise.
	* tests/runtestdefaultsupprspy3.sh.in: Likewise.
	* tests/runtestfedabipkgdiff.py.in: Likewise.
	* tests/runtestfedabipkgdiffpy3.sh.in: Likewise.
	* tests/test-abicompat.cc: Likewise.
	* tests/test-abidiff-exit.cc: Likewise.
	* tests/test-abidiff.cc: Likewise.
	* tests/test-alt-dwarf-file.cc: Likewise.
	* tests/test-annotate.cc: Likewise.
	* tests/test-core-diff.cc: Likewise.
	* tests/test-cxx-compat.cc: Likewise.
	* tests/test-diff-dwarf-abixml.cc: Likewise.
	* tests/test-diff-dwarf.cc: Likewise.
	* tests/test-diff-filter.cc: Likewise.
	* tests/test-diff-pkg.cc: Likewise.
	* tests/test-diff-suppr.cc: Likewise.
	* tests/test-diff2.cc: Likewise.
	* tests/test-dot.cc: Change the SPDX identifier from
	"GPL-3.0-or-later WITH GCC-exception-3.1" to "Apache-2.0 WITH
	LLVM-exception"
	* tests/test-elf-helpers.cc: Change the SPDX identifier from
	"LGPL-3.0-or-later" to "Apache-2.0 WITH LLVM-exception"
	* tests/test-ini.cc: Likewise.
	* tests/test-ir-walker.cc: Likewise.
	* tests/test-kmi-whitelist.cc: Likewise.
	* tests/test-lookup-syms.cc: Likewise.
	* tests/test-read-dwarf.cc: Likewise.
	* tests/test-read-write.cc: Likewise.
	* tests/test-svg.cc: Change the SPDX identifier from
	"GPL-3.0-or-later WITH GCC-exception-3.1" to "Apache-2.0 WITH
	LLVM-exception".
	* tests/test-symtab.cc: Change the SPDX identifier from
	"LGPL-3.0-or-later" to "Apache-2.0 WITH LLVM-exception"
	* tests/test-tools-utils.cc: Likewise.
	* tests/test-types-stability.cc: Likewise.
	* tests/test-utils.cc: Likewise.
	* tests/test-utils.h: Likewise.
	* tests/test-write-read-archive.cc: Likewise.
	* tests/update-test-output.py: Likewise.
	* tools/Makefile.am: Likewise.
	* tools/abiar.cc: Likewise.
	* tools/abicompat.cc: Likewise.
	* tools/abidiff.cc: Likewise.
	* tools/abidw.cc: Likewise.
	* tools/abilint.cc: Likewise.
	* tools/abipkgdiff.cc: Likewise.
	* tools/abisym.cc: Likewise.
	* tools/binilint.cc: Likewise.
	* tools/fedabipkgdiff: Likewise.
	* tools/kmidiff.cc: Likewise.
	* update-copyright.sh: Likewise.

Signed-off-by: Benjamin De Kosnik <bkoz@gnu.org>
Signed-off-by: Ben Woodard <woodard@redhat.com>
Signed-off-by: Chenxiong Qi <cqi@redhat.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Signed-off-by: Giuliano Procida <gprocida@google.com>
Signed-off-by: Jan Engelhardt <jengelh@inai.de>
Signed-off-by: Jessica Yu <jeyu@kernel.org>
Signed-off-by: Jonathan Wakely <jwakely@redhat.com>
Signed-off-by: Mark Wielaard <mark@klomp.org>
Signed-off-by: Matthias Klose <doko@ubuntu.com>
Signed-off-by: Matthias Maennich <maennich@google.com>
Signed-off-by: Ondrej Oprala <ondrej.oprala@gmail.com>
Signed-off-by: Roland McGrath <roland@hack.frob.com>
Signed-off-by: Sinny Kumari <ksinny@gmail.com>
Signed-off-by: Slava Barinov <v.barinov@samsung.com>
2020-12-02 11:49:13 +01:00