Commit Graph

2858 Commits

Author SHA1 Message Date
Dodji Seketeli
5c7749ea9b abidiff,reader: Fix compilation with --debug-self-comparison
While chasing self-comparison changes errors, I realized that
compilation is failing when the package is configured with
--debug-self-comparison.

Fixed thus.

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

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2023-04-13 15:32:22 +02:00
Dodji Seketeli
acb456a9c2 abi{dw,diff}: Better error messages when alternate debuginfo not found
When the alternate debug info referenced by the main debug info file
is missing, both abidw and abidiff fail to explain what is happening
to the user.  The patch adds explicit error messages to those two
programs in that case.

	* tools/abidiff.cc (handle_error): Handle cases where the
	fe_iface::STATUS[_ALT]_DEBUG_INFO_NOT_FOUND bits are set. Refer to
	the alternate debug info file in the error message.
	* tools/abidw.cc (load_corpus_and_write_abixml): Do not clear the
	reader before emitting the error message, rather clear it after.
	Also, refer to the alternate debug info file in the error message.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2023-04-11 11:36:15 +02:00
Dodji Seketeli
3b0069064e Bug 29339 - elf-helpers: Don't crash on unexpected ELF file
When get_soname_of_elf_file is given an unexpected ELF file (e.g, a
DWARF file that is at the wrong place in an RPM, for instance) it hits
an assert and aborts.  Ooops.

This patch removes the offending assert from get_soname_of_elf_file.

Note that to reproduce the initial issue one has to type:

  $ fedabipkgdiff --self-compare -a --from fc36 julia

	* src/abg-elf-helpers.cc (get_soname_of_elf_file): If the program
	header we are looking at is not what we expect, just skip it; do
	not abort.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2023-04-07 21:17:21 +02:00
Dodji Seketeli
197732e683 fedabipkgdiff: Remove busy loop when forking abipkgdiff
The function abipkgdiff() introduced a busy loop instead of using
subprocess.communicate() because it was randomly hanging back in the
python2 days.

This patch removes the busy loop altogether as I could not reproduce
the hanging anymore.

	* tools/fedabipkgdiff (abipkgdiff): Remove the busy looping and
	use subprocess.communicate() instead.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2023-04-07 15:42:35 +02:00
Dodji Seketeli
216e366696 fedabipkgdiff: Add timing data in debug logs
This patch adds elapsed timing data to the debug logs emitted by the
"log_call" decorator.

	* tools/fedabipkgdiff (log_call): Log the time taken by the
	decorated function.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2023-04-07 14:44:32 +02:00
Dodji Seketeli
ff8cba872e dwarf-reader: Support indirectly referenced subrange_type DIEs
This is about supporting an Ada-induced DWARF construct related to
ranged types.

To reproduce the issue this patch originated from, you can type:

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

From that gprbuild package from fc37, consider this subrange_type DIE
coming from the debuginfo file prtests/gprbuild-2020-11.fc37.aarch64:

     1	 [ 3c10d]        subrange_type        abbrev: 34
     2	                 type                 (ref_addr) [ 6191e]
     3	                 lower_bound          (sdata) 2
     4	                 upper_bound          (ref_udata) [ 3c0eb]

At line 4, look at how the DW_AT_upper_bound attribute is a reference
to another DIE, instead of being a (signed) constant value, like the
DW_AT_lower_bound attribute at line 3.  The referenced DIE is at
offset 0x3c0eb.

How do we get the actual value of the upper_bound of that subrange
type?

To answer that question, let's look at the DIE, at offset 0x3c0eb that
is referenced by the DW_AT_upper_bound attribute at line 4:

     1	 [ 3c0eb]      member               abbrev: 87
     2	               name                 (strp) "last"
     3	               decl_file            (data1) a-coinve.ads (35)
     4	               decl_line            (data2) 415
     5	               decl_column          (data1) 24
     6	               type                 (ref_udata) [ 3c0f7]

It's a data member which type is referenced at line 6.  Let's look at
that type, which offset is 0x3c0f7:

     1	 [ 3c0f7]      subrange_type        abbrev: 122
     2	               upper_bound          (sdata) 99999999
     3	               name                 (strp) "gpr__names__name_vectors__T449bXn"
     4	               type                 (ref_addr) [ 6191e]
     5	               artificial           (flag_present) yes

That type is a DW_TAG_subrange_type and its DW_AT_upper_bound value is
a constant.  Finally.

Actually, the value of DW_AT_upper_bound of this DIE at offset 0x3c0f7
is the value of the DW_AT_upper_bound of the subrange_type DIE at
offset 0x3c10d that we were initially looking for.

The DIE at 0x3c0f7 is said to be indirectly referenced by the DIE at
0x3c10d, through its DW_AT_upper_bound attribute.

This patch supports retrieving the value of the DW_AT_upper_bound of
0x3c10d through the 0x3c0f7 DIE that it indirectly references.

The package gprbuild from fc37 now passes self comparison with this patch.

	* src/abg-dwarf-reader.cc (subrange_die_indirect_bound_value)
	(subrange_die_indirectly_references_subrange_die): Define new
	static function.
	(build_subrange_type): If the value of DW_AT_upper_bound is not a
	constant, try to consider it as an indirect reference to a
	DW_TAG_subrange_type DIE, whose DW_AT_upper_bound might carry the
	constant value that we are looking for.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2023-04-07 13:27:57 +02:00
Dodji Seketeli
8180e4a0e7 dwarf-reader: Fix typo in comment
* src/abg-dwarf-reader.cc (reader::get_canonical_die): Fix typo in
	comment.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2023-04-05 17:12:48 +02:00
Dodji Seketeli
97d5ae80c0 dwarf-reader: Support DW_OP_GNU_variable_value
This solves a crash that happened with self-comparing the package
'aws' in Fedora by doing:

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

When evaluating a DWARF expression with
eval_last_constant_dwarf_sub_expr, indirectly called from
die_member_offset, the DW_OP_GNU_variable_value appears not being
supported.

This patch adds the support for that.

To help with figuring that kind of issue in the future, I
have added a few asserts in the code of op_is_arith_logic.

	* src/abg-dwarf-reader.cc (op_pushes_non_constant_value): Support
	DW_OP_GNU_variable_value.
	(op_is_arith_logic): Add a number of asserts and guards here.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2023-04-05 17:03:13 +02:00
Dodji Seketeli
eb272db9dc reader: Make reader::get_scope_for_node handle subranges at array scope.
Now that subranges can be standalone types, we need to teach
reader::get_scope_for_node about the fact that subranges can be at
array scope too.

	* src/abg-reader.cc (reader::get_scope_for_node): A subrange
	at array scope is meant to be in the scope of the array.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2023-04-05 17:01:48 +02:00
Dodji Seketeli
5a6c04c8bd abipkgdiff: Don't use user-specific filesystem info in error msg
The recent patch "Bug rhbz#2182807 --  abipkgdiff crashes on missing debuginfo package"
inadvertently introduced user-specific filesystem information in error
messages, making tests/runtestdiffpkg be non-deterministic.  Fixed
thus.

	* tools/abipkgdiff.cc (get_pretty_printed_list_of_packages): Emit
	base names of packages, not the absolute filesystem path.
	* tests/data/test-diff-pkg/libxfce4ui-devel-4.12.1-8.fc27.ppc64-self-report-0.txt:
	Adjust.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2023-04-05 17:01:48 +02:00
Dodji Seketeli
fee06608fc dwarf-reader: Support Ada subranges having upper_bound < lower_bound
If the subrange's upper_bound is lower than its lower_bound, that
means the subrange has a length of zero.  This is Ada lingo.  You can
learn more about this at
https://en.wikibooks.org/wiki/Ada_Programming/Types/array#Array_Attributes,
for instance.

This patch teaches the DWARF reader about this.

	* src/abg-dwarf-reader.cc (build_subrange_type): Be aware that
	the upper_bound can be lower than lower_bound..  This most
	likely means the length of the subrange is zero.
	* src/abg-ir.cc (array_type_def::subrange_type::get_length): If
	lower_bound > upper_bound, then length is zero.  This is Ada
	lingo.
	* src/abg-writer.cc (write_array_subrange_type): Always emit
	lower_bound and upper_bound.  Acknowledge that if lower_bound >
	upper_bound, it means length is zero.
	* tests/data/test-annotate/libtest24-drop-fns-2.so.abi: Adjust.
	* tests/data/test-annotate/libtest24-drop-fns.so.abi: Likewise.
	* tests/data/test-annotate/test13-pr18894.so.abi: Likewise.
	* tests/data/test-annotate/test14-pr18893.so.abi: Likewise.
	* tests/data/test-annotate/test15-pr18892.so.abi: Likewise.
	* tests/data/test-annotate/test17-pr19027.so.abi: Likewise.
	* tests/data/test-annotate/test18-pr19037-libvtkRenderingLIC-6.1.so.abi:
	Likewise.
	* tests/data/test-annotate/test19-pr19023-libtcmalloc_and_profiler.so.abi:
	Likewise.
	* tests/data/test-annotate/test20-pr19025-libvtkParallelCore-6.1.so.abi:
	Likewise.
	* tests/data/test-annotate/test21-pr19092.so.abi: Likewise.
	* tests/data/test-annotate/test7.so.abi: Likewise.
	* tests/data/test-diff-dwarf-abixml/PR25409-librte_bus_dpaa.so.20.0.abi:
	Likewise.
	* tests/data/test-diff-dwarf-abixml/test0-pr19026-libvtkIOSQL-6.1.so.1-report-0.txt:
	Likewise.
	* tests/data/test-diff-dwarf-abixml/test0-pr19026-libvtkIOSQL-6.1.so.1.abi:
	Likewise.
	* tests/data/test-read-btf/test0.o.abi: Likewise.
	* tests/data/test-read-ctf/test-ambiguous-struct-A.o.hash.abi:
	Likewise.
	* tests/data/test-read-ctf/test-array-mdimension.abi: Likewise.
	* tests/data/test-read-ctf/test-array-of-pointers.abi: Likewise.
	* tests/data/test-read-ctf/test-array-size.abi: Likewise.
	* tests/data/test-read-ctf/test-const-array.abi: Likewise.
	* tests/data/test-read-ctf/test-dynamic-array.o.abi: Likewise.
	* tests/data/test-read-ctf/test0.abi: Likewise.
	* tests/data/test-read-ctf/test0.hash.abi: Likewise.
	* tests/data/test-read-ctf/test9.o.abi: Likewise.
	* tests/data/test-read-dwarf/PR22015-libboost_iostreams.so.abi:
	Likewise.
	* tests/data/test-read-dwarf/PR22122-libftdc.so.abi: Likewise.
	* tests/data/test-read-dwarf/PR25007-sdhci.ko.abi: Likewise.
	* tests/data/test-read-dwarf/PR25042-libgdbm-clang-dwarf5.so.6.0.0.abi:
	Likewise.
	* tests/data/test-read-dwarf/libtest24-drop-fns-2.so.abi:
	Likewise.
	* tests/data/test-read-dwarf/libtest24-drop-fns.so.abi: Likewise.
	* tests/data/test-read-dwarf/test-libaaudio.so.abi: Likewise.
	* tests/data/test-read-dwarf/test-libandroid.so.abi: Likewise.
	* tests/data/test-read-dwarf/test10-pr18818-gcc.so.abi: Likewise.
	* tests/data/test-read-dwarf/test11-pr18828.so.abi: Likewise.
	* tests/data/test-read-dwarf/test12-pr18844.so.abi: Likewise.
	* tests/data/test-read-dwarf/test13-pr18894.so.abi: Likewise.
	* tests/data/test-read-dwarf/test14-pr18893.so.abi: Likewise.
	* tests/data/test-read-dwarf/test15-pr18892.so.abi: Likewise.
	* tests/data/test-read-dwarf/test16-pr18904.so.abi: Likewise.
	* tests/data/test-read-dwarf/test17-pr19027.so.abi: Likewise.
	* tests/data/test-read-dwarf/test18-pr19037-libvtkRenderingLIC-6.1.so.abi:
	Likewise.
	* tests/data/test-read-dwarf/test19-pr19023-libtcmalloc_and_profiler.so.abi:
	Likewise.
	* tests/data/test-read-dwarf/test20-pr19025-libvtkParallelCore-6.1.so.abi:
	Likewise.
	* tests/data/test-read-dwarf/test21-pr19092.so.abi: Likewise.
	* tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi:
	Likewise.
	* tests/data/test-read-dwarf/test7.so.abi: Likewise.
	* tests/data/test-read-dwarf/test7.so.hash.abi: Likewise.
	* tests/data/test-read-dwarf/test9-pr18818-clang.so.abi: Likewise.
	* tests/data/test-read-write/test25.xml: Likewise.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2023-04-05 16:54:32 +02:00
Dodji Seketeli
ed205e0e79 Bug rhbz#2182807 -- abipkgdiff crashes on missing debuginfo package
When abipkgdiff is called with a debug info package that references an
alternate debug info file that is not found -- because debug info
package is missing from the command line -- the program aborts.  This
is because the libabigail library is further invoked by the tool with
debuginfo in an inconsistent state (missing alternate debug info).

Note however that abipkgdiff only emits an explanatory message when
invoked with the --verbose option.

This patch teaches abipkgdiff to emit explanatory messages when an
alternate debug info file is not found.  The message suggests that the
user adds the missing RPM package (which contains the alternate
missing debuginfo file) to the command line using the --d1/--d2
switches.

	* src/abg-fe-iface.cc (status_to_diagnostic_string): Remove the
	newline from the end of the returned diagnostic string.
	* tools/abipkgdiff.cc (get_pretty_printed_list_of_packages)
	(emit_alt_debug_info_not_found_error): Define new static
	functions.
	(compare, compare_to_self): Add an ostream& parameter as a
	destination of diagnostic messages.  If the
	abigail::fe_iface::STATUS_ALT_DEBUG_INFO_NOT_FOUND bit is set in
	the status code, emit the explanatory message to output stream
	associated to the current comparison task.  Remove the previous
	handling of this case.
	(compare_task::maybe_emit_pretty_error_message_to_output): Define
	new member function to get the output stream associated to the
	current task massage it and stick to result into the pretty output
	string to be emitted to the user in the end, namely the
	compare_task::pretty_output string data member.
	({compares, self_compare}_task::perform): Adjust this to call the
	new maybe_emit_pretty_error_message_to_output in case of error.
	* tests/data/test-diff-pkg/libxfce4ui-devel-4.12.1-8.fc27.ppc64-self-report-0.txt:
	Adjust.
	* tests/data/test-diff-pkg/test-dbus-glib-0.80-3.fc12.x86_64-report-0.txt:
	Likewise.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2023-04-03 17:01:44 +02:00
Dodji Seketeli
ddb6abd2d3 Fix redundancy filtering of range types
After the support for Ada range types was added, it appeared that
redundancy propagation was not being correctly handled for range
types, especially when those are sub-types of a function parameter
type, like a const range.

This patch goes through the various problematic spots and addresses
the issues.

	* src/abg-comparison.cc (redundancy_marking_visitor::visit_end):
	Propagate redundancy category to function parameter diff nodes if
	they don't carry any local non-type change.
	* src/abg-default-reporter.cc
	(default_reporter::report_underlying_changes_of_qualified_type):
	Define new member function.
	(default_reporter::report): In the qualified_type_diff overload,
	use the new report_underlying_changes_of_qualified_type above.
	* src/abg-ir.cc (types_have_similar_structure): If two arrays are
	accessed indirectly and if they have size and dimension changes,
	then the two arrays are considered having a similar structure.
	Otherwise, if they are accessed directly, having size or dimension
	change make them considered as having non similar structure.  This
	has an impact on if a change between two array types is considered
	local or not.
	* src/abg-leaf-reporter.cc (leaf_reporter::report): Local changes
	to underlying types of a qualified type are considered local to
	the qualified type.  This change reflects that in the overload for
	qualified type diff nodes.  Otherwise, we won't report what would
	otherwise be a leaf change to the a qualified type, just because
	it's actually a leaf change to the underlying type of the
	qualified type.
	* tests/data/test-abidiff-exit/ada-subrange/test2-ada-subrange-redundant/test2-ada-subrange-redundant-report-{1,2}.txt:
	New reference output files.
	* tests/data/test-abidiff-exit/ada-subrange/test2-ada-subrange-redundant/v0/test.ad{b,s}:
	Source code for the new binary input below.
	* tests/data/test-abidiff-exit/ada-subrange/test2-ada-subrange-redundant/v0/test.o:
	New binary input file.
	* tests/data/test-abidiff-exit/ada-subrange/test2-ada-subrange-redundant/v1/test.ad{b,s}:
	Source code for the new binary input below.
	* tests/data/test-abidiff-exit/ada-subrange/test2-ada-subrange-redundant/v1/test.o:
	New binary input file.
	* tests/data/Makefile.am: Add the new test input files above to
	source distribution.
	* tests/test-abidiff-exit.cc (in_out_specs): Add the new input
	tests above to this test harness.
	* tests/data/test-diff-filter/libtest45-basic-type-change-report-1.txt:
	Adjust.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2023-03-31 23:14:01 +02:00
Dodji Seketeli
7535d74c3c Bug 29340 - Add support for Ada range types
Libabigail doesn't yet support generic range types like in Ada.
Ranges are supported as a kind of implementation detail of array
types.  But then its use like in the construct below is not supported:

    type My_Int is range 0 .. 5;
    function My_Function return My_Int;

Here, the integer type "My_Int" can take the discrete values that go
from 0 to 5.  It's represented in the DWARF debug info as being a
range type of length 6 and whose underlying type has a size of 8 bits.

This patch adds support for a range type to be (de-)serialized from
and to abixml, diffed, diff-analyzed and diff-reported.

The ABIXML version number has been bumped from 2.1 to 2.2 accordingly.

	* configure.ac: Bump the abixml version to 2.2 from 2.1
	* include/abg-comparison.h (diff_maps::get_subrange_diff_map):
	Declare new member functions.
	(class subrange_diff): Define new class.
	(subrange_diff_sptr): Define new typedef.
	(compute_diff): New overload for subrange_diff.
	(is_subrange_diff): Declare new function.
	* include/abg-ir.h (equals): Declare an overload for
	subrange_type.
	* include/abg-reporter.h (reporter_base::report): Declare an
	overload for subrange_diff.
	(default_reporter::report_underlying_changes_of_qualified_type):
	Declare member function.
	(leaf_reporter::report): Declare and overload for subrange_diff.
	Declare new member function.
	* include/abg-tools-utils.h
	(get_anonymous_subrange_internal_name_prefix): Declare new function.
	* src/abg-comparison-priv.h (struct subrange_diff::priv): Define
	new type.
	* src/abg-comparison.cc (diff_maps::priv::subrange_diff_map_):
	Define data member.
	(diff_maps::get_subrange_diff_map): Define member function.
	(is_subrange_diff, compute_diff): Define new functions.
	(compute_diff_for_types): Handle array_type::subrange_type types.
	(subrange_diff::{subrange_diff, first_subrange, second_subrange,
	get_pretty_representation, has_changes, has_local_changes, report,
	chain_into_hierarchy}): Define member functions.
	(diff_maps::insert_diff_node): Handle subrange diff nodes.
	(corpus_diff::priv::count_leaf_type_changes): Count subranges diff
	nodes.
	* src/abg-default-reporter.cc (default_reporter::report): Define
	an overload for subrange_diff.
	* src/abg-ir.cc (has_generic_anonymous_internal_type_name):
	Support subrange types.
	* src/abg-leaf-reporter.cc (report_type_changes_from_diff_maps):
	Report about subrange types.
	(leaf_reporter::report): Define and overload for subrange_diff
	nodes.
	* src/abg-reader.cc (build_subrange_type): Add a boolean to add
	the subrange type to the current scope.
	(build_array_type_def): Adjust when calling build_subrange_type.
	(build_type): Support building subrange types.
	* src/abg-reporter-priv.cc (represent): Define a new overload for
	the subrange_diff type.
	* src/abg-reporter-priv.h (represent): Declare a new overload for
	the subrange_diff type.
	* src/abg-tools-utils.cc (ANONYMOUS_SUBRANGE_INTERNAL_NAME)
	(ANONYMOUS_SUBRANGE_INTERNAL_NAME_LEN): Define new static const
	variables.
	(get_anonymous_subrange_internal_name_prefix): Define new
	function.
	* src/abg-writer.cc (write_array_subrange_type): Define new static
	function.
	(write_decl): Support emitting subrange_types.
	* tests/data/test-abidiff-exit/ada-subrange/test1-ada-subrange/test1-ada-subrange-report-1.txt:
	New reference output.
	* tests/data/test-abidiff-exit/ada-subrange/test1-ada-subrange/test1-ada-subrange-report-2.txt:
	Likewise.
	* tests/data/test-abidiff-exit/ada-subrange/test1-ada-subrange/v0/test1.ad{b,s}:
	Source code of the input binary below.
	* tests/data/test-abidiff-exit/ada-subrange/test1-ada-subrange/v0/test1.o:
	New input test.
	* tests/data/test-abidiff-exit/ada-subrange/test1-ada-subrange/v1/test1.ad{b,s}:
	Source code of the input binary below.
	* tests/data/test-abidiff-exit/ada-subrange/test1-ada-subrange/v1/test1.o:
	New input test.
	* tests/data/Makefile.am: Add the new test files to source
	distributions.
	* tests/test-abidiff-exit.cc (in_out_specs): Add the new tests
	input above to this test harness.
	* tests/data/test-annotate/PR29443-missing-xx.o.annotated.abi:
	Adjust.
	* tests/data/test-annotate/libtest23.so.abi: Likewise.
	* tests/data/test-annotate/libtest24-drop-fns-2.so.abi: Likewise.
	* tests/data/test-annotate/libtest24-drop-fns.so.abi: Likewise.
	* tests/data/test-annotate/test-anonymous-members-0.o.abi:
	Likewise.
	* tests/data/test-annotate/test0.abi: Likewise.
	* tests/data/test-annotate/test1.abi: Likewise.
	* tests/data/test-annotate/test13-pr18894.so.abi: Likewise.
	* tests/data/test-annotate/test14-pr18893.so.abi: Likewise.
	* tests/data/test-annotate/test15-pr18892.so.abi: Likewise.
	* tests/data/test-annotate/test17-pr19027.so.abi: Likewise.
	* tests/data/test-annotate/test18-pr19037-libvtkRenderingLIC-6.1.so.abi:
	Likewise.
	* tests/data/test-annotate/test19-pr19023-libtcmalloc_and_profiler.so.abi:
	Likewise.
	* tests/data/test-annotate/test2.so.abi: Likewise.
	* tests/data/test-annotate/test20-pr19025-libvtkParallelCore-6.1.so.abi:
	Likewise.
	* tests/data/test-annotate/test21-pr19092.so.abi: Likewise.
	* tests/data/test-annotate/test3.so.abi: Likewise.
	* tests/data/test-annotate/test4.so.abi: Likewise.
	* tests/data/test-annotate/test5.o.abi: Likewise.
	* tests/data/test-annotate/test6.so.abi: Likewise.
	* tests/data/test-annotate/test7.so.abi: Likewise.
	* tests/data/test-annotate/test8-qualified-this-pointer.so.abi:
	Likewise.
	* tests/data/test-read-btf/test0.o.abi: Likewise.
	* tests/data/test-read-btf/test1.o.abi: Likewise.
	* tests/data/test-read-ctf/PR27700/test-PR27700.abi: Likewise.
	* tests/data/test-read-ctf/test-PR26568-1.o.abi: Likewise.
	* tests/data/test-read-ctf/test-PR26568-2.o.abi: Likewise.
	* tests/data/test-read-ctf/test-alias.o.abi: Likewise.
	* tests/data/test-read-ctf/test-ambiguous-struct-A.o.hash.abi:
	Likewise.
	* tests/data/test-read-ctf/test-ambiguous-struct-B.o.hash.abi:
	Likewise.
	* tests/data/test-read-ctf/test-anonymous-fields.o.abi: Likewise.
	* tests/data/test-read-ctf/test-array-mdimension.abi: Likewise.
	* tests/data/test-read-ctf/test-array-of-pointers.abi: Likewise.
	* tests/data/test-read-ctf/test-array-size.abi: Likewise.
	* tests/data/test-read-ctf/test-bitfield-enum.abi: Likewise.
	* tests/data/test-read-ctf/test-bitfield.abi: Likewise.
	* tests/data/test-read-ctf/test-callback.abi: Likewise.
	* tests/data/test-read-ctf/test-callback2.abi: Likewise.
	* tests/data/test-read-ctf/test-conflicting-type-syms-a.o.hash.abi:
	Likewise.
	* tests/data/test-read-ctf/test-conflicting-type-syms-b.o.hash.abi:
	Likewise.
	* tests/data/test-read-ctf/test-const-array.abi: Likewise.
	* tests/data/test-read-ctf/test-dynamic-array.o.abi: Likewise.
	* tests/data/test-read-ctf/test-enum-many.o.hash.abi: Likewise.
	* tests/data/test-read-ctf/test-enum-symbol.o.hash.abi: Likewise.
	* tests/data/test-read-ctf/test-enum.o.abi: Likewise.
	* tests/data/test-read-ctf/test-fallback.abi: Likewise.
	* tests/data/test-read-ctf/test-forward-type-decl.abi: Likewise.
	* tests/data/test-read-ctf/test-functions-declaration.abi:
	Likewise.
	* tests/data/test-read-ctf/test-linux-module.abi: Likewise.
	* tests/data/test-read-ctf/test-list-struct.abi: Likewise.
	* tests/data/test-read-ctf/test0.abi: Likewise.
	* tests/data/test-read-ctf/test0.hash.abi: Likewise.
	* tests/data/test-read-ctf/test1.so.abi: Likewise.
	* tests/data/test-read-ctf/test1.so.hash.abi: Likewise.
	* tests/data/test-read-ctf/test2.so.abi: Likewise.
	* tests/data/test-read-ctf/test2.so.hash.abi: Likewise.
	* tests/data/test-read-ctf/test3.so.abi: Likewise.
	* tests/data/test-read-ctf/test3.so.hash.abi: Likewise.
	* tests/data/test-read-ctf/test4.so.abi: Likewise.
	* tests/data/test-read-ctf/test4.so.hash.abi: Likewise.
	* tests/data/test-read-ctf/test5.o.abi: Likewise.
	* tests/data/test-read-ctf/test7.o.abi: Likewise.
	* tests/data/test-read-ctf/test8.o.abi: Likewise.
	* tests/data/test-read-ctf/test9.o.abi: Likewise.
	* tests/data/test-read-dwarf/PR22015-libboost_iostreams.so.abi:
	Likewise.
	* tests/data/test-read-dwarf/PR22122-libftdc.so.abi: Likewise.
	* tests/data/test-read-dwarf/PR24378-fn-is-not-scope.abi:
	Likewise.
	* tests/data/test-read-dwarf/PR25007-sdhci.ko.abi: Likewise.
	* tests/data/test-read-dwarf/PR25042-libgdbm-clang-dwarf5.so.6.0.0.abi:
	Likewise.
	* tests/data/test-read-dwarf/PR26261/PR26261-exe.abi: Likewise.
	* tests/data/test-read-dwarf/PR27700/test-PR27700.abi: Likewise.
	* tests/data/test-read-dwarf/PR28584/PR28584-smv.clang.o.abi:
	Likewise.
	* tests/data/test-read-dwarf/PR29443-missing-xx.o.abi: Likewise.
	* tests/data/test-read-dwarf/PR29692-kdelibs3-libkjava.so.1.0.0.abi:
	Likewise.
	* tests/data/test-read-dwarf/libtest23.so.abi: Likewise.
	* tests/data/test-read-dwarf/libtest24-drop-fns-2.so.abi:
	Likewise.
	* tests/data/test-read-dwarf/libtest24-drop-fns.so.abi: Likewise.
	* tests/data/test-read-dwarf/test-PR26568-1.o.abi: Likewise.
	* tests/data/test-read-dwarf/test-PR26568-2.o.abi: Likewise.
	* tests/data/test-read-dwarf/test-fallback.abi: Likewise.
	* tests/data/test-read-dwarf/test-libaaudio.so.abi: Likewise.
	* tests/data/test-read-dwarf/test-libandroid.so.abi: Likewise.
	* tests/data/test-read-dwarf/test-suppressed-alias.o.abi:
	Likewise.
	* tests/data/test-read-dwarf/test0.abi: Likewise.
	* tests/data/test-read-dwarf/test0.hash.abi: Likewise.
	* tests/data/test-read-dwarf/test1.abi: Likewise.
	* tests/data/test-read-dwarf/test1.hash.abi: Likewise.
	* tests/data/test-read-dwarf/test10-pr18818-gcc.so.abi: Likewise.
	* tests/data/test-read-dwarf/test11-pr18828.so.abi: Likewise.
	* tests/data/test-read-dwarf/test12-pr18844.so.abi: Likewise.
	* tests/data/test-read-dwarf/test13-pr18894.so.abi: Likewise.
	* tests/data/test-read-dwarf/test14-pr18893.so.abi: Likewise.
	* tests/data/test-read-dwarf/test15-pr18892.so.abi: Likewise.
	* tests/data/test-read-dwarf/test16-pr18904.so.abi: Likewise.
	* tests/data/test-read-dwarf/test17-pr19027.so.abi: Likewise.
	* tests/data/test-read-dwarf/test18-pr19037-libvtkRenderingLIC-6.1.so.abi:
	Likewise.
	* tests/data/test-read-dwarf/test19-pr19023-libtcmalloc_and_profiler.so.abi:
	Likewise.
	* tests/data/test-read-dwarf/test2.so.abi: Likewise.
	* tests/data/test-read-dwarf/test2.so.hash.abi: Likewise.
	* tests/data/test-read-dwarf/test20-pr19025-libvtkParallelCore-6.1.so.abi:
	Likewise.
	* tests/data/test-read-dwarf/test21-pr19092.so.abi: Likewise.
	* tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi:
	Likewise.
	* tests/data/test-read-dwarf/test3-alias-1.so.hash.abi: Likewise.
	* tests/data/test-read-dwarf/test3-alias-2.so.hash.abi: Likewise.
	* tests/data/test-read-dwarf/test3-alias-3.so.hash.abi: Likewise.
	* tests/data/test-read-dwarf/test3-alias-4.so.hash.abi: Likewise.
	* tests/data/test-read-dwarf/test3.so.abi: Likewise.
	* tests/data/test-read-dwarf/test3.so.hash.abi: Likewise.
	* tests/data/test-read-dwarf/test4.so.abi: Likewise.
	* tests/data/test-read-dwarf/test4.so.hash.abi: Likewise.
	* tests/data/test-read-dwarf/test5.o.abi: Likewise.
	* tests/data/test-read-dwarf/test5.o.hash.abi: Likewise.
	* tests/data/test-read-dwarf/test6.so.abi: Likewise.
	* tests/data/test-read-dwarf/test6.so.hash.abi: Likewise.
	* tests/data/test-read-dwarf/test7.so.abi: Likewise.
	* tests/data/test-read-dwarf/test7.so.hash.abi: Likewise.
	* tests/data/test-read-dwarf/test8-qualified-this-pointer.so.abi: Likewise.
	* tests/data/test-read-dwarf/test8-qualified-this-pointer.so.hash.abi: Likewise.
	* tests/data/test-read-dwarf/test9-pr18818-clang.so.abi: Likewise.
	* tests/data/test-read-write/test-crc.xml: Likewise.
	* tests/data/test-read-write/test26.xml: Likewise.
	* tests/data/test-read-write/test27.xml: Likewise.
	* tests/data/test-read-write/test28-without-std-fns-ref.xml: Likewise.
	* tests/data/test-read-write/test28-without-std-vars-ref.xml:
	Likewise.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2023-03-31 23:14:01 +02:00
Ben Woodard
1174a9f0c4 Have fedabipkgdiff sleep while waiting for abipkgdiff
While running tests, I noticed that python was consuming a huge amount
of CPU. Frank Eigler located the problem and pointed
out that python was continiously polling for abipkgdiff's
completion. For small packages, the time to completion can be less
than a second but some packages can take literally hours to
analyze. Having python spinning in such a tight loop is unnecessary. I
added a small sleep to this loop with a bit of backoff. Vanessa Sochat
helped with examples of how to fix the python code.

	* tools/fedabipkgdiff (abipkgdiff): add sleep while waiting for
	subprocess completion. Also, update copyright year notice to 2023.

Signed-off-by: Ben Woodard <woodard@redhat.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2023-03-31 22:48:18 +02:00
Dodji Seketeli
7952a748de Bug 29345 - abipkgdiff is confused by symlinked binaries in RPMs
Note that this issue can be reproduced by doing:

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

When a binary is a symlink to another one,
create_maps_of_package_content doesn't realize it and considers the
two binaries to be different.

Later, when comes time to self compare both binaries, their abixml
files (which are the same, by virtue of symlinks) might be written at
the same time in different threads, creating a race condition, leading
to corruption of the abixml.

This patch fixes this by teaching create_maps_of_package_content to
resolve symlinks so that it can detect when two files actually point
to the same file.

	* tools/abipkgdiff.cc (create_maps_of_package_content): Resolve
	symlinks when mapping binaries.  Don't map a binary that has
	already been seen.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2023-03-27 01:15:56 +02:00
Dodji Seketeli
e2040f2838 Bug 29686 - Fix testing the presence of anonymous data member in a struct
* include/abg-fwd.h (anonymous_data_member_to_class_or_union): Add
	a new overload.
	(anonymous_data_member_exists_in_class): Declare new function.
	* src/abg-dwarf-reader.cc (add_or_update_class_type): Use the new
	anonymous_data_member_exists_in_class function.
	* src/abg-ir.cc (anonymous_data_member_to_class_or_union): Define
	new function.
	* tests/data/test-read-dwarf/test-libandroid.so.abi: Adjust.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2023-03-24 23:37:03 +01:00
Dodji Seketeli
0ddd051c27 Bug 29690 - Out of range exception in add_or_update_class_type
This was triggered by doing:

    $ fedabipkgdiff  --self-compare -a --from fc37 amg4psblas-mpich

	* src/abg-dwarf-reader.cc (add_or_update_class_type): Make sure
	the array is big enough.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2023-03-24 18:34:20 +01:00
Dodji Seketeli
efbc2a3e49 test-symtab: Update after support for empty symtabs
Now that we support empty symtabs test-symtab needs to be updated so
that it expects to have a corpus now, upon a binary with no exported
symbols, albeit an empty one.

	* tests/test-symtab.cc (TEST_CASE("Symtab::Empty", "[symtab,
	basic]")): Adjust.
	(TEST_CASE("Symtab::NoDebugInfo", "[symtab, basic]")): Likewise.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2023-03-24 14:31:15 +01:00
Dodji Seketeli
a8a4ca8862 abipkgdiff: Fix a typo
* tools/abipkgdiff.cc (compare_to_self): Fix a typo.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2023-03-22 15:42:43 +01:00
Dodji Seketeli
6641e71a03 Bug 29692 - Support binaries with empty symbol table
Some binaries can have a symbol table in which no symbol is actually
defined and exported.  That binary would thus have an empty ABI
corpus.

Interestingly, Libabigail's DWARF reader is emits an error when
it encounters such binaries.

This patch adds the support for those binaries.

	* src/abg-dwarf-reader.cc (reader::read_debug_info_into_corpus):
	Get out early also upon having an empty symbol table.
	* src/abg-elf-reader.cc (reader::read_corpus): Error out only if
	there is no symbol table for the binary.  If an empty symbol table
	is found however, that is not an error.
	* tests/data/test-read-dwarf/PR29692-kdelibs3-libkjava.so.1.0.0:
	New binary test input.
	* tests/data/test-read-dwarf/PR29692-kdelibs3-libkjava.so.1.0.0.abi:
	New expected abixml file.
	* tests/data/Makefile.am: Add the new input test files to source
	distribution.
	* tests/test-read-dwarf.cc (in_out_specs): Add the new test inputs
	above to this test harness.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2023-03-22 15:32:10 +01:00
Dodji Seketeli
889f05f935 Bug 29911 - fedabipkgdiff forgets to provide some debuginfo RPMs to abipkgdiff
Some packages like foo-utils.rpm can be associated with two debuginfo
RPMs: One foo-utils-debuginfo.rpm and foo-debuginfo.rpm.  This is
because the foo-debuginfo.rpm contains debug info that has been
factorized out of all the sub-packages of foo, foo-utils being one of
those sub-packages.  In those cases, fedabipkgdiff needs to provide
foo-debuginfo.rpm and foo-utils-debuginfo.rpm to abipkgdiff so that it
can find all the necessary debuginfo.

This patch fixes fedabipkgdiff accordingly and adds some more logging
to abipkgdiff to make it emit an explicit message for cases like this.

	* tools/abipkgdiff.cc (compare_to_self): Emit an error message
	when in verbose mode, for cases where we fail to find the
	alternate debug info.
	* tools/fedabipkgdiff (generate_comparison_halves): Always provide
	all associated debuginfo packages to abipkgdiff.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2023-03-21 18:18:19 +01:00
Dodji Seketeli
b987db9bcb Bug 29912 - Better support an ELF symbol alias that designates several functions
When an ELF symbol alias designates two different functions,
Libabigail can be confused as to which function to consider.

This confusion indirectly leads to showing spurious changes in the
return type of some functions when an ELF symbol designates more than
one function.

In other words, when an ELF symbol designates two (or more) functions,
the comparison engine needs a way to tell the two functions apart.  It
needs an other way to identify the functions.

This patch fixes the confusion by using the pretty representation of
the functions in those cases.

Please note that to replicate the issue reported in this bug, here is
the command I used:

    $ fedabipkgdiff --debug --self-compare -a --from fc37 smesh

	* include/abg-corpus.h (corpus::lookup_functions): Return a set of
	functions rather than a vector of functions where a function can
	be present more than once.  This allows to determine if a symbol
	designates more than one function.
	(corpus::exported_decls_builder::priv_): Make this public so that
	some outside code can access it.
	(corpus::exported_decls_builder::fn_id_maps_to_several_fns):
	Declare new function.
	(corpus::exported_decls_builder::maybe_add_fn_to_exported_fns):
	Remove useless const here.
	* include/abg-fwd.h (get_function_id_or_pretty_representation):
	Declare new function.
	* include/abg-ir.h
	(elf_symbol::get_alias_with_default_symbol_version): Declare new
	member function.
	* src/abg-comparison.cc
	(corpus_diff::priv::ensure_lookup_tables_populated): Use the new
	get_function_id_or_pretty_representation rather than
	function_decl::get_id() to identify a function.
	* src/abg-corpus-priv.h (str_fn_ptr_set_map_type): Define this new
	typedef of unordered_map<string, std::unordered_set<function_decl*> >.
	(corpus::exported_decls_builder::priv::id_fns_map_): Change the
	type of this to the new str_fn_ptr_set_map_type.
	(corpus::exported_decls_builder::priv::{id_fns_map, fn_id_is_in_id_fns_map,
	fn_is_in_fns, fn_is_in_id_fns_map}): Adjust to using a set of
	functions rather than a vector.
	(corpus::exported_decls_builder::fn_is_in_fns_by_repr): Define new
	static function.
	(corpus::exported_decls_builder::add_fn_to_exported): Remove
	useless const.
	* src/abg-corpus.cc
	(corpus::exported_decls_builder::fn_id_maps_to_several_fns):
	Define new function.
	(corpus::exported_decls_builder::maybe_add_fn_to_exported_fns):
	Remove useless const.
	(corpus::lookup_functions): Return a set of functions rather than
	a vector of functions where a function can be present more than
	once.  This allows to determine if a symbol designates more than
	one function.
	* src/abg-dwarf-reader.cc
	(reader::symbol_already_belongs_to_a_function): Adjust.
	* src/abg-fe-iface.cc (fe_iface::maybe_add_fn_to_exported_decls):
	Adjust.
	* src/abg-ir.cc (get_function_id_or_pretty_representation): Define
	new function.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2023-03-20 15:16:57 +01:00
Dodji Seketeli
9eebee2823 dwarf-reader,abidiff: Fix compilation with --enable-debug-type-canonicalization
When looking at something else, I configured the package with
--enable-debug-type-canonicalization and surprise, there were some
compilation errors.  Fixed thus.

	* src/abg-dwarf-reader.cc (reader::initialize): Use env(). rather
	than environment->.
	* tools/abidiff.cc (options::options): Initialize
	do_debug_type_canonicalization() before use_btf.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2023-03-13 16:57:53 +01:00
Dodji Seketeli
37a1018ac6 Bug 29977 - dwarf-reader: Fix canonical DIE propagation canceling
When canceling canonical DIE propagation, we wrongly assume that the
pair of DIEs being compared yield a COMPARE_RESULT_UNKNOWN result.
The reality is that it can also yield a COMPARE_RESULT_DIFFERENT
result, especially when we are looking at the first sub-type that
compares different and that triggered the canonical DIE propagation
canceling to begin with.

This can be reproduced by the command:

$ fedabipkgdiff --self-compare -a --from fc37 xorg-x11-server-Xvfb

Fixed thus.

	* src/abg-dwarf-reader.cc
	(offset_pairs_stack_type::cancel_canonical_propagated_type): The
	result of comparing the canonical-propagated types being canceled
	is either COMPARISON_RESULT_UNKNOWN or
	COMPARISON_RESULT_DIFFERENT.  Also, do not forget to update the
	cached value for the comparison of the depend types too.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2023-03-13 16:56:28 +01:00
Dodji Seketeli
e9e38dc1b8 ir: Fix cycle detection for union types
It seems the commit below (in libabigail 2.1) broke the cycle
detection during union types comparison.

commit 4bc513a8ae
Author: Dodji Seketeli <dodji@redhat.com>
Date:   Thu Sep 8 19:09:33 2022 +0200

    Fix IR comparison result caching and canonical type propagation tracking

This patch fixes that.

	* src/abg-ir.cc (CACHE_COMPARISON_RESULT_AND_RETURN): Define new
	macro.
	(equals): In the overload for unions, detect cycles right
	away. Also, do not use mark_types_as_being_compared and
	return_comparison_result as that would indirectly call
	environment::priv::unmark_as_being_compared one too many, thus
	breaking the cycle detection machinery.  Rather, just cache the
	result of comparing the type as a class_or_union and return, using
	CACHE_COMPARISON_RESULT_AND_RETURN.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2023-03-10 09:41:56 +01:00
Dodji Seketeli
d107ed2195 tools-utils: Improve logging in build_corpus_group_from_kernel_dist_under
* src/abg-tools-utils.cc
	(build_corpus_group_from_kernel_dist_under): Improve logging.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2023-03-08 15:21:16 +01:00
Guillermo E. Martinez
dc375bd1b7 tools-utils: Fix looking for vmlinux binary in debuginfo package
When abipkgdiff is invoked on a `kernel' package,
compare_prepared_linux_kernel_packages fails to look for the `vmlinux'
file from the debuginfo package, because of a thinko.

Then, build_corpus_group_from_kernel_dist_under, also fails to find
`vmlinux' from the debuginfo package because of another thinko.

This patch fixes the two thinkos.

	* src/abg-tools-utils.cc
	(get_binary_paths_from_kernel_dist): Fix a thinko and really use
	the kernel_modules_root variable.  Look for modules under
	kernel_modules_root and look for vmlinux (if necessary) under
	debug_info_root. Add comments.
	(compare_prepared_linux_kernel_packages): Fix another thinko.  Now
	we do have the path to vmlinux, from debuginfo packages before
	getting into get_binary_paths_from_kernel_dist.

Signed-off-by: Guillermo E. Martinez <guillermo.e.martinez@oracle.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2023-03-08 15:21:16 +01:00
Dodji Seketeli
acfa51d52d comp-filter: Speed up harmless/harmful categorization
Categorizing a diff graph with a thousands of function diff nodes takes a
lot of time.  At that point, categorizing each node has
harmful/harmless is showing up in the profile, particularly because
has_var_type_cv_qual_change and to a lesser extend
class_diff_has_harmless_odr_violation_change perform some structural
comparison still, oops.  This patch avoids doing that.  On my machine,
the categorizing of each node goes from around 130ms to 92 ms.

	* src/abg-comp-filter.cc
	(class_diff_has_harmless_odr_violation_change)
	(has_var_type_cv_qual_change): Avoid doing structural comparison
	here.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2023-03-02 18:31:43 +01:00
Dodji Seketeli
4e58cdaba6 comparison: When marking leaf nodes don't do unnecessary impact analysis
When marking leaf nodes, if interface impact analysis is not required,
then avoid visiting the same diff node twice when walking the diff
graph.  Allowing to visit the same diff node twice would be useful so
that the sub-graph of each interface diff node would be walked in full
to determine the impact of each leaf diff node on each interface.  But
if such impact analysis is not required, then we can just visit each
diff graph node once and speed up things greatly in leaf node
reporting mode.

	* src/abg-comparison.cc (corpus_diff::mark_leaf_diff_nodes): If
	impact analysis is not required, visit each node just once.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2023-03-02 18:31:43 +01: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
945f23a693 comp-filter: Don't re-visit node while applying filters to diff nodes
When applying a filter to a corpus_diff node, visit each diff node
only once.  This can have some serious performance impact when there
are a lot of diff nodes to visit.

	* src/abg-comp-filter.cc (apply_filter): In the overload for
	corpus_diff, visit each diff node only once.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2023-03-02 18:31:43 +01:00
Dodji Seketeli
0c1936eecc tools-utils: Support kernel stablelist
Up until now, a kernel whitelist was expected to be a ini file with a
section having a name ending with the word "whitelist".  Nowadays,
they are called "stablelist", so the name of the section ends up with
"stablelist".  This patch makes
gen_suppr_spec_from_kernel_abi_whitelists support that.

	* src/abg-tools-utils.cc
	(gen_suppr_spec_from_kernel_abi_whitelists): Support section name
	that ends with the word 'stablelist'.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2023-03-02 18:31:43 +01:00
Dodji Seketeli
b5ab4d2009 abidiff: Add extensive logging
While looking at something else I felt the need for having
"abidiff --verbose" emit more timing information.  I have thus added
a lot more logging around.

	* include/abg-comparison.h ({diff, corpus_diff,
	diff_context}::do_log): Declare member functions.
	* include/abg-corpus.h (corpus::do_log): Likewise.
	* src/abg-comparison-priv.h (diff_context::priv::do_log_): Add new
	data member.
	(diff_context::priv::priv): Initialize the new data member.
	* src/abg-comparison.cc ({diff, corpus_diff,
	diff_context}::do_log): Define member functions.
	(diff_context::maybe_apply_filters): Add timing logs to applying
	filters and propagating categories.
	(corpus_diff::priv::apply_filters_and_compute_diff_stats): Add
	timing logs to applying and propagating filters to changed
	functions, variables, unreachable & leaf type changes,
	suppressions application.
	* src/abg-corpus-priv.h (corpus::priv::do_log): Add new data
	member.
	(corpus::priv::priv): Initialize it.
	* src/abg-corpus.cc (corpus::do_log): Define member functions.
	* src/abg-reader.cc (reader::do_log): Likewise.
	(reader::read_corpus): Add timing log around the invocation of
	perform_late_type_canonicalizing.
	* tools/abidiff.cc (set_diff_context_from_opts): Set logging.
	(main): Add timing logging for diff computing, changes analysis &
	report generation.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2023-03-02 18:31:43 +01:00
Dodji Seketeli
5e9d876b4d Misc white space fixes
* include/abg-suppression.h (class
	type_suppression::insertion_range::end): Fix indentation.
	* src/abg-default-reporter.cc (default_reporter::report): Fix
	indentation in the overload for corpus_diff.
	* src/abg-suppression-priv.h
	(type_suppression::priv::source_locations_to_keep_): Fix alignment.
	* src/abg-suppression.cc (read_type_suppression): Fix alignment of
	comment.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2023-03-02 18:31:43 +01:00
Dodji Seketeli
aab0bc10bc comparison, suppression: Support [allow_type] directive
This patch adds support for a new 'allow_type' suppression directive.
It suppresses all the changes that are NOT matched by the directive.
In other words, this directive determines the set of type changes that
are NOT suppressed.  Any other change is suppressed.  This thus called
a "negated suppression directive".

The way these negated suppression directives interact with the direct
suppression directives that already exist is the following.

The suppression evaluation pass visits every single diff node
(carrying a type change) of the diff graph.  Negated suppressions are
evaluated first, in order of occurrence.

There are thus, two alternatives:

    1/ At least one negated suppression matches the current diff node.
or
    2/ No negated suppression matches the current diff node.

In case of 1/ then direct suppression specifications are
considered. There are two alternatives:

    1.1/ At least one direct suppression matches the current diff node.
         The diff node is suppressed: categorized as being in the
         SUPPRESSED_CATEGORY category)
or
    1.2/ No direct suppression matches the current diff node.
         The diff node is not suppressed: categorized as being in the
         HAS_ALLOWED_CHANGE_CATEGORY category.

In case of 2/ then direct suppression specifications are
considered. There are two alternatives:

    2.1 At least one direct suppression matches the current diff node.
	The diff node is categorized as being in the
	SUPPRESSED_CATEGORY category, just like in 1.1.

    2.2 No direct suppression matches the current diff node.
	The diff node is not suppressed and not categorized.

As a result of the category propagation pass, a node which has a
parent node categorized as HAS_ALLOWED_CHANGE_CATEGORY is itself
categorized as HAS_PARENT_WITH_ALLOWED_CHANGE_CATEGORY.  A node which
has a descendant categorized as HAS_ALLOWED_CHANGE_CATEGORY will
itself be categorized as HAS_DESCENDANT_WITH_ALLOWED_CHANGE_CATEGORY.

Nodes that are categorized as HAS_ALLOWED_CHANGE_CATEGORY,
HAS_DESCENDANT_WITH_ALLOWED_CHANGE_CATEGORY and
HAS_PARENT_WITH_ALLOWED_CHANGE_CATEGORY are not suppressed by the
reporting passes.  This is needed for the reporting passes to emit the
impact sub-tree up to the diff node which carry the change that was
actually categorized as HAS_ALLOWED_CHANGE_CATEGORY.

	* include/abg-comparison.h: Include abg-suppression.h
	(diff, diff_context, diff_sptr, diff_context_sptr): Remove these
	forward decls from here.
	(enum diff_category::{HAS_ALLOWED_CHANGE_CATEGORY,
	HAS_DESCENDANT_WITH_ALLOWED_CHANGE_CATEGORY,
	HAS_PARENT_WITH_ALLOWED_CHANGE_CATEGORY}): Add new enumerators.
	(enum diff_category::EVERYTHING_CATEGORY): Update enumerator.
	(diff_context::{negated_suppressions, direct_suppressions}): Declare
	new member functions.
	(diff_context::suppressions): Add overload.
	(diff::{is_filtered_out_without_looking_at_allowed_changes,
	is_allowed_by_specific_negated_suppression,
	has_descendant_allowed_by_specific_negated_suppression,
	has_parent_allowed_by_specific_negated_suppression}): Declare new
	member functions.
	* include/abg-suppression.h (class negated_suppression_base, class
	negated_type_suppression): Declare new classes.
	(negated_suppression_sptr, negated_suppression_type): Define new
	typedefs.
	(is_negated_suppression): Declare new functions.
	* src/abg-suppression.cc
	(negated_suppression_base::{negated_suppression_base,
	~negated_suppression_base}): Define member functions.
	(negated_type_suppression::{negated_type_suppression,
	suppresses_diff, ~negated_type_suppression}): Likewise.
	(is_negated_suppression): Define functions.
	(read_type_suppression): Allow parsing the "allow_type" directive
	and instantiate a negated_type_suppression.
	* src/abg-comparison-priv.h
	(diff_context::priv::{negated_suppression_type_,
	direct_suppressions}): Define new data members.
	(diff::priv::is_filtered_out): A node categorized as
	HAS_DESCENDANT_ALLOWED_BY_SPECIFIC_NEGATED_SUPPRESSION,
	HAS_PARENT_ALLOWED_BY_SPECIFIC_NEGATED_SUPPRESSION and
	HAS_ALLOWED_CHANGE_CATEGORY is not filtered out.
	* src/abg-comparison.cc (diff_context::suppressions): Add a
	non-const overload.
	(diff_context::{negated,direct}_suppressions): Define new member
	function.
	(diff_context::add_suppression): Invalidate the cache data members
	diff_context::priv::{negated,direct}_suppressions_.
	(diff::is_filtered_out): A node categorized as
	HAS_DESCENDANT_ALLOWED_BY_SPECIFIC_NEGATED_SUPPRESSION,
	HAS_PARENT_ALLOWED_BY_SPECIFIC_NEGATED_SUPPRESSION and
	HAS_ALLOWED_CHANGE_CATEGORY is not filtered out.
	(diff::is_filtered_out_without_looking_at_allowed_changes): Define
	new member function.
	(diff::is_suppressed): If there is at least one negated
	suppression that match the diff node, then it's not suppressed,
	unless it's matched by a direct suppression.
	(diff::{is_allowed_by_specific_negated_suppression,
	has_descendant_allowed_by_specific_negated_suppression,
	has_parent_allowed_by_specific_negated_suppression}): Define new
	member functions.
	(operator<<(ostream& o, diff_category c)): Serialize
	HAS_{DESCENDANT_WITH,PARENT_WITH}_ALLOWED_CHANGE_CATEGORY
	enumerators.
	(category_propagation_visitor::visit_end): Do not propagate
	HAS_ALLOWED_CHANGE_CATEGORY,
	HAS_DESCENDANT_WITH_ALLOWED_CHANGE_CATEGORY and
	HAS_PARENT_WITH_ALLOWED_CHANGE_CATEGORY categories.
	(suppression_categorization_visitor::visit_begin): Categorize a
	node that is not suppressed by a direct suppression and is
	suppressed by a negated one as
	HAS_ALLOWED_CHANGE_CATEGORY. Propagate it to descendant nodes as
	HAS_PARENT_WITH_ALLOWED_CHANGE_CATEGORY ...
	(suppression_categorization_visitor::visit_end): ... and to parent
	node as HAS_DESCENDANT_WITH_ALLOWED_CHANGE_CATEGORY.
	* src/abg-default-reporter.cc (default::reporter): In the overload
	for typedef_diff, qualified_type_diff, reference_diff,
	fn_parm_diff, function_type_diff, array_diff, base_diff,
	function_decl_diff, report local changes only
	on node that are not filtered out wrt allowed changed.
	* tests/data/test-abidiff-exit/test-allow-type-array-suppr.txt:
	New test input.
	* tests/data/test-abidiff-exit/test-allow-type-array-v0--v1-report-{1,2}.txt:
	Likewise.
	* tests/data/test-abidiff-exit/test-allow-type-array-v0--v2-report-{1,2}.txt:
	Likewise.
	* tests/data/test-abidiff-exit/test-allow-type-array-v0--v3-report-{1,2}.txt:
	Likewise.
	* tests/data/test-abidiff-exit/test-allow-type-array-v{0,1,2,3}.c:
	Source code of new binary test inputs.
	* tests/data/test-abidiff-exit/test-allow-type-array-v{0,1,2,3}.o:
	New binary test inputs.
	* tests/data/test-abidiff-exit/test-allow-type-region-suppr.txt:
	New test input.
	* tests/data/test-abidiff-exit/test-allow-type-region-v0--v1-report-{1,2}.txt:
	* tests/data/test-abidiff-exit/test-allow-type-region-v0--v2-report-{1,2}.txt:
	Likewise.
	* tests/data/test-abidiff-exit/test-allow-type-region-v0--v3-report-{1,2}.txt:
	Likewise.
	* tests/data/test-abidiff-exit/test-allow-type-region-v0--v4-report-{1,2}.txt:
	Likewise.
	* tests/data/test-abidiff-exit/test-allow-type-region-v0--v5-report-{1,2}.txt:
	Likewise.
	* tests/data/test-abidiff-exit/test-allow-type-region-v{0,1,2,3,4,5}.c:
	Source code of new binary test input.
	* tests/data/test-abidiff-exit/test-allow-type-region-v{0,1,2,3,4,5}.o:
	New binary test inputs.
	* tests/data/test-abidiff-exit/test-allow-type-suppr{1,2}.txt: New
	test inputs.
	* tests/data/Makefile.am: Add the new testing files above to
	source distribution.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
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
b1b69abd79 suppression: Factorize out is_data_member_offset_in_range
In preparation of subsequent changes, this patch factorizes a function
is_data_member_offset_in_range() out of
type_suppression::suppression().  This is useful to determine if a
data member offset is within an "offset range" expressed by the
type_suppression::insertion_range type.

This function is useful to implement the
offset_of_first_data_member_regexp and
offset_of_last_data_member_regexp properties to come in subsequent
patches.

Please note that is_data_member_offset_in_range works on data members
of unions and classes, not just on classes like what the original code
of inside type_suppression::suppresses_diff was doing.

This patch should not have any functional impact on the code.

	* include/abg-fwd.h (get_last_data_member)
	(get_next_data_member_offset): Declare functions.
	* src/abg-ir.cc (get_next_data_member): Add an overload for
	class_or_union and write the overload for class_or_union_sptr in
	term of the former.
	(get_last_data_member): Add overloads form class_or_union& and
	class_or_union*.  Write the overload for class_or_union_sptr in
	terms of the one for class_or_union*.
	(get_next_data_member_offset): Add an overload for
	class_or_union* and write the overload for class_or_union_sptr in
	terms of the former.
	* include/abg-suppression.h
	(type_suppression::insertion_range::eval_boundary): Take a
	class_or_union* for the context, as opposed to a class_decl_sptr.
	This makes this static function work for unions as well.
	(is_data_member_offset_in_range): Declare new function.
	* src/abg-suppression.cc (type_suppression::suppression_diff):
	Factorize ...
	(is_data_member_offset_in_range): ... this function out.
	(type_suppression::insertion_range::eval_boundary): Adjust this to
	make it take a class_or_union* rather than a class_decl_sptr.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2023-03-01 13:49:51 +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
2ead575e76 ini: Fix parsing list property values
While looking at something else, I came across an issue in
read_context::read_list_property_value.  This function requires
elements of a list property value (separated by a comma) to be on a
single line, for instance.  This is because the code forgets to parse
white spaces after the comma.

Fixed thus.

	* src/abg-ini.cc (read_context::read_list_property_value): Expect
	white spaces after the comma.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2023-03-01 13:20:03 +01:00
Guillermo E. Martinez
ca4f4d894c abipkgdiff: Fix kernel package detection when comparing kABIs
Using abipkgdiff to analyze kABIs from Oracle Linux packages with CTF
debug format, abipkgdiff is not able to identify kernel packages
because the naming of OL kernel packages differs from the naming used
on other RPM-based distributions.

As abipkgdiff fails to see that it's looking at a Linux kernel
package, the binaries are analyzed as user space binaries and that is
not what we want.

This patch addresses the issue by looking for the "vmlinuz" binary
inside the package to determine that it's a kernel package.  In other
words, tools_utils::file_is_kernel_package is changed to look for
"vmlinuz" inside the package, rather than look for a particular
pattern in the package name of the package.

Additionally, when the kernel package contains CTF debug information,
the `vmlinux.ctfa' file is not necessarily shipped the debuginfo
package.  This patch thus adjusts the search path of that file in that
case.

        * include/abg-tools-utils.h (rpm_contains_file): Declare new
        function.
        * src/abg-ctf-reader.cc (ctf::reader::find_ctfa_file): Use
        `find_file_under_dir' utility function to locate `vmlinux.ctfa'
        file.
        (ctf::reader::process_ctf_archive): Adjust dictionary name
        according to module name, removing characters after dot.
        * src/abg-tools-utils.cc (file_has_ctf_debug_info): Use
        `find_file_under_dir' utility function to locate `vmlinux.ctfa'
        file.
        (rpm_contains_file): Define new function.
        (file_is_kernel_package): Use the new `rpm_contains_file' to look
	for the `vmlinuz' file inside the RPM package.  For Debian
	packages however, we don't keep looking at the naming pattern as
	we don't yet have a deb_contains_file function.  Also, this
	function now takes the full path to the RPM.
        (build_corpus_group_from_kernel_dist_under): for CTF, add the
        `root' directory of the extracted package to the set of
        directories under which we should look for debug info.
	* tools/abipkgdiff.cc (maybe_handle_kabi_whitelist_pkg)
	(create_maps_of_package_content, compare_prepared_package, main):
	Adjust call to file_is_kernel_package as it now takes the full
	path to the package.

Signed-off-by: Guillermo E. Martinez <guillermo.e.martinez@oracle.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2023-02-28 12:42:05 +01:00
Dodji Seketeli
416b85333b abipkgdiff: Emit error when no vmlinux is found in debug package
When given linux kernel packages to analyze using DWARF, the tool
expects the (uncompressed) vmlinux binary to be found in the debug
info package.

This patch emits an error message when no vmlinux binary is found in
the debug info package in that case.

	* tools/abipkgdiff.cc (compare_prepared_linux_kernel_packages):
	When no vmlinux binary is found in the debug info package, emit an
	error message.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2023-02-28 11:33:42 +01:00
Dodji Seketeli
320037805c abipkgdiff: Emit better logs in verbose mode
When invoked with --verbose, abipkgdiff emits some logs that could use
better clarity.  Fixed thus.

	* tools/abipkgdiff.cc (package::erase_extraction_directory): Say
	explicitly what's DONE.
	(extract_rpm): Add newline to log.  Say explicitly what's DONE on
	which package.
	(extract_deb, extract_tar)
	(erase_created_temporary_directories_parent, compare_to_self)
	(create_maps_of_package_content): Say explicitly what's DONE on
	which package.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2023-02-28 11:01:16 +01:00
Dodji Seketeli
af63ae8328 ctf-reader: Fix GCC 13 warnings
GCC 13 was recently introduced to Fedora Rawhide and it's complaining
(and rightly so) about some missing parenthesis.  Fixed thus.

	* src/abg-ctf-reader.cc (process_ctf_typedef)
	(process_ctf_base_type, process_ctf_forward_type)
	(process_ctf_struct_type, process_ctf_union_type)
	(process_ctf_enum_type): Add missing parenthesis.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2023-02-21 16:22:19 +01:00
Dodji Seketeli
b4a8a820b9 ir: Add missing virtual methods overloads
Fedora Rawhide recently moved to GCC 13 and so its emitting new
warnings about libabigail's code base, and rightly so.

This patch thus adds some missing virtual method overloads that are
spotted by GCC 13.

	* include/abg-ir.h (type_decl::operator!=): Declare missing
	virtual overloads.
	(array_type_def::subrange_type::operator!=): Likewise.
	(template_decl::operator==): Likewise.
	(type_tparameter::operator==): Likewise.
	(class_decl::operator==): Likewise.
	(union_decl::operator==): Likewise.
	(member_class_template::operator==): Likewise.
	* src/abg-ir.cc (type_decl::operator!=)
	(array_type_def::subrange_type::operator!=)
	(class_decl::operator==, member_class_template::operator==)
	(union_decl::operator==, template_decl::operator==)
	(type_tparameter::operator==, type_tparameter::operator==)
	(template_tparameter::operator==): Define new virtual overloads.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2023-02-21 14:57:20 +01:00
Dodji Seketeli
a92a2b9bc7 configure: Bump the CURRENT library number
The interface has changed in an incompatible way since the last
release as the vtable of fe_iface has changed in an incompatible, at
very least.  So bump the LIBABIGAIL_SO_CURRENT version number to
reflect that.

	* configure.ac: Bump LIBABIGAIL_SO_CURRENT to 2.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2023-02-10 13:18:19 +01:00
Dodji Seketeli
03d8b52fc7 PR30048 - wrong pretty representation of qualified pointers
A qualified type is textually represented as the following:

    <qualifier> <underlying-type>

were "qualifier" is the qualifier carried by the qualified type and
"underlying-type" is the type being qualified.

In this case, the qualifier prefixes the textual representation of the
qualified type.

This is true if the underlying type of the qualified type is a
non-const, non-reference type.  For instance:

    const int;

But when the underlying type is a pointer, then the qualified type is
represented as:

    int* const;

In that later case, the qualifier comes /after/ the textual
representation of the underlying type.

Now suppose the underlying type is itself a qualified type.  In that
case, for a non-const underlying type, we'd have, e.g:

    const volatile int;

where the qualifier precedes the qualified type (which is itself a
qualified type) /IF/ the ultimate underlying type (a.k.a the leaf
underlying type) is itself a non-const, non-reference type.

But if the ultimate underlying type is a pointer, a qualified type
with an underlying qualified type would be textually represented as,
e.g:

    int* const volatile;

In other words, if the leaf type is a pointer, the qualifier suffixes
the textual representation the underlying qualified type.

Libabigail is failing to apply this later rule.

As the type name is used as a key to cache IR nodes of DIEs (among
other things), getting it wrong can lead to a bumpy ride down the
road.

Fixed thus.

	* src/abg-dwarf-reader.cc
	(die_is_pointer_array_or_reference_type): Rename
	die_is_pointer_or_reference_type into this.  This new name
	reflects more what the function does as it tests if a DIE is for
	pointer, an array or a reference.
	(pointer_or_qual_die_of_anonymous_class_type): Adjust to use the
	newly (and better) named die_is_pointer_array_or_reference_type.
	(die_is_pointer_or_reference_type): Make this really test if a DIE
	is for a pointer or a reference.  Now the name matches what the
	function does.
	(die_peel_qualified): Define new function.
	(die_qualified_type_name): When a qualified name Q has another
	qualified name as its underlying type, it's important to know if
	the leaf type is a pointer type or not to know how to construct
	the name of Q.  This change now peels the potential qualifiers
	from the underlying type of the qualified type to see if the leaf
	type is a pointer or not.
	* src/abg-ir.cc (get_name_of_qualified_type): Likewise.  Also, the
	name of array types doesn't follow the same rule as for pointers
	and references.
	* tests/data/test-abidiff-exit/PR30048-test-report-0.txt: Add new
	reference test output.
	* tests/data/test-abidiff-exit/PR30048-test-2-report-1.txt:
	Likewise.
	* tests/data/test-abidiff-exit/PR30048-test-v{0,1}.c: Add source
	code of binary input data.
	* tests/data/test-abidiff-exit/PR30048-test-2-v{0,1}.cc: Likewise.
	* tests/data/test-abidiff-exit/PR30048-test-v{0,1}.o: Add binary
	input data.
	* tests/data/test-abidiff-exit/PR30048-test-2-v{0,1}.o: Likewise.
	* tests/data/Makefile.am: Add the new test material above to
	source distribution.
	* tests/test-abidiff-exit.cc (in_out_specs): Add the input
	binaries to this test harness.
	* tests/data/test-abidiff-exit/qualifier-typedef-array-report-1.txt:
	Adjust.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2023-02-10 13:15:27 +01:00
Dodji Seketeli
82973c898a default-reporter: Fix source location in functions change report
While looking at something else, I realized that the default-reporter
mentions the source location of the new function in lieu of the old function
when reporting about a function change.  Fixed thus.

	* src/abg-default-reporter.cc (default_reporter::report): In the
	overload of function_decl, use the source location of the old
	function.
	* tests/data/test-abicompat/test0-fn-changed-report-2.txt: Adjust.
	* tests/data/test-abidiff-exit/qualifier-typedef-array-report-1.txt:
	Likewise.
	* tests/data/test-abidiff-exit/test-PR28316-report.txt: Likewise.
	* tests/data/test-abidiff-exit/test-decl-enum-report.txt:
	Likewise.
	* tests/data/test-abidiff-exit/test-decl-struct-report.txt:
	Likewise.
	* tests/data/test-abidiff-exit/test-fun-param-report.txt:
	Likewise.
	* tests/data/test-abidiff-exit/test-headers-dirs/test-headers-dir-report-2.txt:
	Likewise.
	* tests/data/test-abidiff-exit/test-loc-with-locs-report.txt:
	Likewise.
	* tests/data/test-abidiff-exit/test-member-size-report0.txt:
	Likewise.
	* tests/data/test-abidiff-exit/test-rhbz2114909-report-1.txt:
	Likewise.
	* tests/data/test-diff-filter/libtest45-basic-type-change-report-0.txt:
	Likewise.
	* tests/data/test-diff-filter/test-PR24731-report-1.txt: Likewise.
	* tests/data/test-diff-filter/test-PR25661-1-report-2.txt:
	Likewise.
	* tests/data/test-diff-filter/test-PR25661-2-report-2.txt:
	Likewise.
	* tests/data/test-diff-filter/test-PR25661-3-report-2.txt:
	Likewise.
	* tests/data/test-diff-filter/test-PR25661-4-report-2.txt:
	Likewise.
	* tests/data/test-diff-filter/test-PR25661-5-report-2.txt:
	Likewise.
	* tests/data/test-diff-filter/test-PR25661-6-report-3.txt:
	Likewise.
	* tests/data/test-diff-filter/test-PR25661-7-report-3.txt:
	Likewise.
	* tests/data/test-diff-filter/test-PR26739-2-report-0.txt:
	Likewise.
	* tests/data/test-diff-filter/test-PR29387-report.txt: Likewise.
	* tests/data/test-diff-filter/test30-pr18904-rvalueref-report1.txt:
	Likewise.
	* tests/data/test-diff-filter/test30-pr18904-rvalueref-report2.txt:
	Likewise.
	* tests/data/test-diff-filter/test31-pr18535-libstdc++-report-1.txt:
	Likewise.
	* tests/data/test-diff-filter/test36-report-0.txt: Likewise.
	* tests/data/test-diff-filter/test37-report-0.txt: Likewise.
	* tests/data/test-diff-filter/test39/test39-report-0.txt:
	Likewise.
	* tests/data/test-diff-filter/test41-report-0.txt: Likewise.
	* tests/data/test-diff-filter/test44-anonymous-data-member-report-0.txt:
	Likewise.
	* tests/data/test-diff-pkg/dirpkg-3-report-2.txt: Likewise.
	* tests/data/test-diff-pkg/libICE-1.0.6-1.el6.x86_64.rpm--libICE-1.0.9-2.el7.x86_64.rpm-report-0.txt:
	Likewise.
	* tests/data/test-diff-pkg/nss-3.23.0-1.0.fc23.x86_64-report-0.txt:
	Likewise.
	* tests/data/test-diff-pkg/spice-server-0.12.4-19.el7.x86_64-0.12.8-1.el7.x86_64-report-0.txt:
	Likewise.
	* tests/data/test-diff-pkg/spice-server-0.12.4-19.el7.x86_64-0.12.8-1.el7.x86_64-report-1.txt:
	Likewise.
	* tests/data/test-diff-pkg/spice-server-0.12.4-19.el7.x86_64-0.12.8-1.el7.x86_64-report-2.txt:
	Likewise.
	* tests/data/test-diff-pkg/symlink-dir-test1-report0.txt:
	Likewise.
	* tests/data/test-diff-pkg/tarpkg-1-report-0.txt: Likewise.
	* tests/data/test-diff-pkg/tbb-4.1-9.20130314.fc22.x86_64--tbb-4.3-3.20141204.fc23.x86_64-report-0.txt:
	Likewise.
	* tests/data/test-diff-pkg/tbb-4.1-9.20130314.fc22.x86_64--tbb-4.3-3.20141204.fc23.x86_64-report-1.txt:
	Likewise.
	* tests/data/test-diff-suppr/PR28073/PR28073-output-2.txt:
	Likewise.
	* tests/data/test-diff-suppr/libtest48-soname-abixml-report-1.txt:
	Likewise.
	* tests/data/test-diff-suppr/test30-report-0.txt: Likewise.
	* tests/data/test-diff-suppr/test41-enumerator-changes-report-0.txt:
	Likewise.
	* tests/data/test-diff-suppr/test42-negative-suppr-type-report-0.txt:
	Likewise.
	* tests/data/test-diff-suppr/test42-negative-suppr-type-report-1.txt:
	Likewise.
	* tests/data/test-diff-suppr/test6-fn-suppr-report-0-1.txt:
	Likewise.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2023-02-10 13:15:27 +01:00
Dodji Seketeli
d1af600491 {dwarf,elf_based}-reader,writer: Avoid duplicating corpora in corpus_group
It's been brought to my attention on IRC that running

    abidw --linux-tree <kernel-build-tree>

would result in a corpus group that duplicates every single corpus in
the resulting abixml.  Oops.

This is because both dwarf::reader::read_corpus() and
elf_based_reader::read_and_add_corpus_to_group() add the corpus to the
corpus_group, and yet, the later function calls the former.  So the
corpus is added to the corpus_group twice.

This patch ensures that
elf_based_reader::read_and_add_corpus_to_group() is the only one to
add the corpus to the group.  It also ensures that this happens before
the corpus is constructed from the debug info because that is useful
for sharing types among the various corpora.  Otherwise, those types
are potentially duplicated in the IR of each corpus.

The patch also ensures the abixml writer enforces the fact that each
corpus is emitted only once.

	* src/abg-dwarf-reader.cc (reader::read_debug_info_into_corpus):
	Do not add the corpus to the group here ...
	* src/abg-elf-based-reader.cc
	(elf_based_reader::read_and_add_corpus_to_group): ... because it's
	already added here.  But then, let's add it here /before/ reading
	type & symbols information into the corpus.
	* src/abg-writer.cc (write_context::m_emitted_corpora_set): Add
	new data member.
	(write_context::{corpus_is_emitted, record_corpus_as_emitted}):
	Define new member functions.
	(write_corpus): Invoke the new
	write_context::record_corpus_as_emitted here.
	(write_corpus_group): Ensure that each corpus is emitted only
	once.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2023-02-02 12:08:02 +01:00