VBS [Mon, 19 Jun 2023 08:27:25 +0000 (13:57 +0530)]
Added gettext-tools and config
patch fix below issues
1-> Can't exec "autopoint": No such file or directory at" issue can add
in libabigail.spec
2->configure: error: dependencies not found, use --disable-libdebuginfod
to disable or --enable-libdebuginfod=dummy to build a (bootstrap) dummy
library.
Change-Id: I3563acbaed9b7faafe85057633b4457c9c5b0f7a
Signed-off-by: Akhilesh Kumar <akhilesh.k@samsung.com>
Signed-off-by: Dongkyun Son <dongkyun.s@samsung.com>
Dongkyun Son [Wed, 14 Jun 2023 10:59:56 +0000 (19:59 +0900)]
packaing: bump-up version with elfutils 0.189
Change-Id: I7c022311876e4f1a0cb184e360006cd2e25b5d89
Signed-off-by: Dongkyun Son <dongkyun.s@samsung.com>
Slava Barinov [Wed, 25 Mar 2020 11:45:55 +0000 (14:45 +0300)]
Elfutils updated
Signed-off-by: Slava Barinov <v.barinov@samsung.com>
Slava Barinov [Wed, 25 Mar 2020 11:20:42 +0000 (14:20 +0300)]
Version bump
Signed-off-by: Slava Barinov <v.barinov@samsung.com>
Slava Barinov [Thu, 29 Sep 2016 06:52:00 +0000 (09:52 +0300)]
Add .spec file and elfutils.
Static internal build of elfutils is needed since it's GPLv3 now and Tizen
package can't be upgraded due to license issues. The build is performed with
static archives only, no shared objects are produced to prevent possibility of
GPLv3 software introduction to platform.
Signed-off-by: Slava Barinov <v.barinov@samsung.com>
Dodji Seketeli [Thu, 27 Apr 2023 09:55:38 +0000 (11:55 +0200)]
NEWS: Update for 2.3 release
* NEWS: Update using "git shortlog libabigail-2.2..HEAD".
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Dodji Seketeli [Thu, 27 Apr 2023 09:53:10 +0000 (11:53 +0200)]
Update ChangeLog for 2.3 release
* ChangeLog: Update using the 'make update-changelog' command.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Dodji Seketeli [Thu, 27 Apr 2023 08:40:10 +0000 (10:40 +0200)]
test-ini: Fix a typo
* tests/test-ini.cc (in_out_specs): Fix a typo near the last
record of the array.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Dodji Seketeli [Wed, 26 Apr 2023 20:19:35 +0000 (22:19 +0200)]
ini: Do not crash on incorrect property value
When the value of the 'name_regexp' property is incorrect, the ini
parser can crash.
Pancake, of Radare2 fame, reported this one by email.
Fixed thus.
* src/abg-ini.cc (read_context::read_property_value): Do not
dereference a null pointer to list property value.
* tests/data/test-ini/test02-buggy-property-value.abignore: New
test input.
* tests/data/test-ini/test02-buggy-property-value.abignore.expected:
Likewise.
* tests/data/Makefile.am: Add the two new test inputs to source
distribution.
* tests/test-ini.cc (in_out_spec): Add the new test input pair to
this test harness.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Dodji Seketeli [Wed, 26 Apr 2023 10:37:30 +0000 (12:37 +0200)]
test-abidiff-exit: Fix the command line passed to abidiff
I noticed that the command line passed to abidiff in the
test-abidiff-exit.cc is getting bigger and bigger as the test runs.
This is because in the main loop that calls abidiff on each test, we
forget to reset the "headers directories" part of the command line
passed to abidiff.
Fixed thus.
* tests/test-abidiff-exit.cc (main): Reset the headers directories
passed to abidiff at each iteration.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Dodji Seketeli [Wed, 26 Apr 2023 10:34:27 +0000 (12:34 +0200)]
Fix the test of the patch for Bug 30309
It turns out I forgot to add a test file to the source distribution.
Fixed thus.
* tests/data/Makefile.am: Add
test-abidiff-exit/PR30329/PR30329-report-1.txt to source
distribution.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Dodji Seketeli [Tue, 25 Apr 2023 10:17:12 +0000 (12:17 +0200)]
Bug 30309 - Support absolute path to alt debug info file in DWARF
Until now, the path to the alternate DWARF file, given by the content
of the .gnu_debugaltlink section has generally been a relative path.
That is what the elf reader has grown to expect.
In bug https://sourceware.org/bugzilla/show_bug.cgi?id=30329 the
.gnu_debugaltlink section seems an absolute path:
'/usr/lib/debug/dwz/components/sqlite.bst/x86_64-unknown-linux-gnu'.
The elf-reader thus fails to find the alternate DWARF file as it's
looking for a relative path under the debug info root directory.
This path teaches the elf-reader to handle absolute alternate
debuginfo files too.
* src/abg-elf-reader.cc (find_alt_dwarf_debug_info_path): Trim the
"/usr/lib/debug" prefix from the alt dwarf file path, if it was
provided. The function is going to look for the alt dwarf file
under the debug info root file instead.
* src/abg-tools-utils.cc (entry_of_file_with_name): Add a
parameter for the path to the root directory under which the files
visit is taking place. Then, consider the file path being looked
for as being relative to the root directory under which the files
visit is taking place.
* tests/data/test-abidiff-exit/PR30329/new-image/usr/lib/debug/dwz/components/sqlite.bst/x86_64-unknown-linux-gnu:
New test input.
* tests/data/test-abidiff-exit/PR30329/new-image/usr/lib/debug/usr/lib/x86_64-linux-gnu/libsqlite3.so.0.8.6.debug:
Likewise.
* tests/data/test-abidiff-exit/PR30329/new-image/usr/lib/x86_64-linux-gnu/libsqlite3.so.0.8.6:
Likewise.
* tests/data/test-abidiff-exit/PR30329/old-image/usr/lib/debug/dwz/components/sqlite.bst/x86_64-unknown-linux-gnu:
Likewise.
* tests/data/test-abidiff-exit/PR30329/old-image/usr/lib/debug/usr/lib/x86_64-linux-gnu/libsqlite3.so.0.8.6.debug:
Likewise.
* tests/data/test-abidiff-exit/PR30329/old-image/usr/lib/x86_64-linux-gnu/libsqlite3.so.0.8.6:
Likewise.
* tests/data/test-abidiff-exit/PR30329/PR30329-report-1.txt:
Likewise.
* tests/data/Makefile.am: Add the new test material above to
source distribution.
* tests/test-abidiff-exit.cc (InOutSpec::in_elfv{0,1}_debug_dir):
New data members. Carry the debuginfo root dirs for the input
binaries.
(in_out_specs): Update the existing to adjust for the new
InOutSpec::in_elfv{0,1}_debug_dir data members. Also, add a new
entry for this new test case.
(main): Pass the root debug info dirs to abidiff.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Dodji Seketeli [Fri, 21 Apr 2023 12:37:54 +0000 (14:37 +0200)]
reader: Recognize variadic parameter type from abixml
When reading a variadic parameter type from the ABIXML, the reader
forget to recognize it as THE unique variadic parameter type as
returned by abigail::ir::environment::get_variadic_parameter_type().
That makes abigil::ir::environment::is_variadic_parameter_type() to
fail on the variadic type that is build from ABIXML.
Fixed thus.
* include/abg-ir.h (environment::get_variadic_parameter_type_name)
Declare ...
* src/abg-ir.cc (environment::get_variadic_parameter_type_name):
... a new static member function.
(environment::get_variadic_parameter_type): Use
the new environment::get_variadic_parameter_type_name rather than
using an open coded constant here.
* src/abg-dwarf-reader.cc
(die_return_and_parm_names_from_fn_type_die): Likewise.
* src/abg-reader.cc (build_type_decl): For a variadic parameter
type, return
abigail::ir::environment::get_variadic_parameter_type() rather
than building a new type.
* tests/data/test-read-ctf/test2.so.abi: Adjust.
* tests/data/test-read-ctf/test2.so.hash.abi: Likewise.
* tests/data/test-read-ctf/test8.o.abi: Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Dodji Seketeli [Wed, 19 Apr 2023 15:45:27 +0000 (17:45 +0200)]
ir: fix canonical type propagation canceling error
This patch (with the help of the 9 patches that precede it) fixes the
self-comparison error that is seen when running the command line:
$ fedabipkgdiff --self-compare -a --from fc37 bpftrace
It turns out the root cause of the self-comparison error seen here is
that sometimes, when the speculatively computed canonical type (that
is called propagated canonical type) is known to be wrong, the code
forgets to cancel that speculation. And that leads to wrong
comparisons during subsequent type canonicalizations and later during
type comparisons.
This patch fixes the logic the of the cancellation of propagated
canonical type that must happen when it is known that the propagated
canonical type is invalid.
* src/abg-ir-priv.h
(environment::priv::{confirm_ct_propagation_for_types_dependant_on,
confirm_ct_propagation_for_types_dependant_on}): Asserting that
the type should be recursive is wrong because the recursive-ness
flag is set to false upon confirmation of the canonical type
propagation. So there can be some types that would make this
assertion fail before we reach the end of the set of types to
confirm the propagation for.
(environment::priv::cancel_ct_propagation): Cancel the canonical
type propagation for all types we are instructed to cancel, not
just for types that are recursive or depends on recursive types.
This is because the the recursive-ness flag is set to false upon
cancellation of the canonical type propagation. So there can be
some types that would make this condition fail before we reach the
end of the set of types to cancel the propagation for.
(environment::priv::cancel_all_non_confirmed_propagated_canonical_types):
Define new member function.
* src/abg-ir.cc (return_comparison_result): Confirm the
speculative canonical type propagation result when we are done
comparing the current type and the result of the comparison is
true. Let's not try to be smart here. Just be safe. This
optimization is fast enough as is. Otherwise, if the result of
the comparison is false, then all the speculatively propagated
canonical types of all the non-confirmed types should be canceled.
All of them. Again, let's not try to be smart. This is smart &
fast enough as is. And thing are going to be correct this way.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Dodji Seketeli [Wed, 19 Apr 2023 14:24:05 +0000 (16:24 +0200)]
comparison: Fix index error when interpreting scope comparison
While looking at something else, I noticed a thinko in the
code in scope_diff::ensure_lookup_tables_populated that interprets the
result of the diffing algorithm on the decls of a given scope. Fixed
thus.
* src/abg-comparison.cc
(scope_diff::ensure_lookup_tables_populated): Use the proper index
to address the deleted decl. Also, use the range-based for syntax
in the enclosing for-loop for more clarity.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Dodji Seketeli [Wed, 19 Apr 2023 14:01:15 +0000 (16:01 +0200)]
writer: Annotate pointer representation
When starring at abixml I noticed that abixml --annotate would not
annotate pointer-type-def XML elements. This patch fixes that and
makes the code of write_pointer_type_def easier to debug.
* src/abg-writer.cc (write_pointer_type_def): Invoke annotate.
Add a temporary for the output of write_context::get_id_for_type.
It makes it easier to inspect in the debugger.
* tests/data/test-annotate/libtest23.so.abi: Adjust.
* tests/data/test-annotate/libtest24-drop-fns-2.so.abi: Adjust.
* tests/data/test-annotate/libtest24-drop-fns.so.abi: Adjust.
* tests/data/test-annotate/test1.abi: Adjust.
* tests/data/test-annotate/test13-pr18894.so.abi: Adjust.
* tests/data/test-annotate/test14-pr18893.so.abi: Adjust.
* tests/data/test-annotate/test15-pr18892.so.abi: Adjust.
* tests/data/test-annotate/test17-pr19027.so.abi: Adjust.
* tests/data/test-annotate/test18-pr19037-libvtkRenderingLIC-6.1.so.abi:
Adjust.
* tests/data/test-annotate/test19-pr19023-libtcmalloc_and_profiler.so.abi:
Adjust.
* tests/data/test-annotate/test20-pr19025-libvtkParallelCore-6.1.so.abi:
Adjust.
* tests/data/test-annotate/test21-pr19092.so.abi: Adjust.
* tests/data/test-annotate/test5.o.abi: Adjust.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Dodji Seketeli [Wed, 19 Apr 2023 13:07:37 +0000 (15:07 +0200)]
ir: Improve debugging type_base::get_canonical_type_for
This patch factorizes an interesting part of
type_base::get_canonical_type_for into a new function called
compare_canonical_type_against_candidate. The user can now invoke it
from the prompt of the debugger to compare a candidate canonical type
against an actual canonical to study why the comparison fails (by
setting a breakpoint in notify_equality_failed when the pre-processor
macro WITH_DEBUG_SELF_COMPARISON is defined.
This is priceless to debug why canonical type comparison that should
succeed actually fails.
* src/abg-ir.cc (compare_types_during_canonicalization): Adjust
this to make it take const type_base& rather than const
type_base_sptr.
(compare_canonical_type_against_candidate): Factorize this out of
...
(type_base::get_canonical_type_for): ... here.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Dodji Seketeli [Wed, 19 Apr 2023 12:29:13 +0000 (14:29 +0200)]
Improve self-comparison debug mode
When looking at debugging some self-comparison difference errors, I
felt the need to improve the debugging support for self-comparison
(triggered by 'abidw --debug-abidiff <binary>').
This patch fixes some typos in the existing diagnostics emitted by the
self-comparison debugging mode and improves the detection of a change
in a canonical type value between a type that is serialized to abixml,
and the same type that is de-serialized from abixml. This later check
is now performed during the process of handling canonical type
propagation when confirming/canceling (speculatively) propagated
canonical types. It's useful to find problems in that process of
confirming/canceling.
* include/abg-ir.h
(environment::{get_type_id_canonical_type_map}): Const-ify the
existing member function and add non-const overloads.
(environment::{get_type_id_from_pointer,
get_canonical_type_from_type_id}): Const-ify.
(environment::get_pointer_type_id_map): Add new member function.
* src/abg-ir-priv.h
(environment::priv::{confirm_ct_propagation_for_types_dependant_on,
confirm_ct_propagation}): Call
check_abixml_canonical_type_propagation_during_self_comp() here.
(environment::priv::{get_type_id_canonical_type_map,
get_pointer_type_id_map, get_type_id_from_pointer,
get_type_id_from_type, get_canonical_type_from_type_id,
check_abixml_canonical_type_propagation_during_self_comp}): Add
new member functions.
* src/abg-ir.cc (return_comparison_result): Call
check_abixml_canonical_type_propagation_during_self_comp on every
single type with non confirmed propagated canonical type.
(environment::{get_type_id_canonical_type_map,
get_pointer_type_id_map, get_type_id_from_pointer,
get_type_id_from_type, get_canonical_type_from_type_id}): Delegate
to the new implementations that are now member functions of
environment::priv.
(type_base::get_canonical_type_for): Fix typo in diagnostics when
debugging self-comparison. Add more context.
* src/abg-reader.cc
(abixml::reader::maybe_check_abixml_canonical_type_stability):
Likewise.
* src/abg-writer.cc (write_type_record): Do not try to get abixml
type-id for a type (originating from the DWARF) that has no
canonical type, otherwise, that /can/ introduce a gap in the
type-ids as those can turn out not being emitted in the abixml
after all.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Dodji Seketeli [Fri, 21 Apr 2023 17:55:49 +0000 (19:55 +0200)]
tests/update-test-output.py: Adapt to some broken test output
Sometimes, the output of runtestreaddwarf or runtestannotate are
broken due the fact that they execute test units in parallel and each
unit might emit output that watch on each other toes.
This fixes tests/update-test-output.py to take that into account.
As this is a helper tool used to update updates, it won't have any
impact on libabigail's output.
* tests/update-test-output.py (process): Don't expect the start
pattern of the main diff hunk to begin at the end of a line
because that can be broken for runtestreaddwarf and co.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Mark Wielaard [Fri, 14 Apr 2023 14:52:09 +0000 (16:52 +0200)]
doc: Fix some typos and add some missing references
Building the docs point out a few issues:
abidiff.rst:238: WARNING: Unknown target name: "linux kernel".
abidiff.rst:249: WARNING: Unknown target name: "linux kernel".
abidiff.rst:263: WARNING: Unknown target name: "linux kernel".
abidiff.rst:274: WARNING: Unknown target name: "linux kernel".
abidw.rst:23: WARNING: Unknown target name: "btf`_formats, if present. finally, if no debug info in these formats is found, it only considers `elf".
abidw.rst:34: WARNING: duplicate label abidiff_invocation_label, other instance in doc/manuals/abidiff.rst
abipkgdiff.rst:298: WARNING: Unknown target name: "linux kernel".
abipkgdiff.rst:309: WARNING: Unknown target name: "linux kernel".
abipkgdiff.rst:323: WARNING: Unknown target name: "linux kernel".
abipkgdiff.rst:334: WARNING: Unknown target name: "linux kernel".
libabigail-concepts.rst:620: WARNING: Block quote ends without a blank line; unexpected unindent.
libabigail-overview.rst:1: WARNING: Title overline too short.
Fix those as follows:
* doc/manuals/abidiff.rst: Add Linux Kernel reference.
* doc/manuals/abipkgdiff.rst: Likewise.
* doc/manuals/abidw.rst: Add space between `BTF`_ and formats.
Rename _abidiff_invocation_label to _abidw_invocation_label.
* doc/manuals/libabigail-concepts.rst: Add empty line between
_suppr_has_size_change_property_label and has_size_change.
* doc/manuals/libabigail-overview.rst: Extend title overlines.
Signed-off-by: Mark Wielaard <mark@klomp.org>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Dodji Seketeli [Thu, 13 Apr 2023 14:48:52 +0000 (16:48 +0200)]
ir: Recognize "void* as being equal to all other pointers in C
Today, the pointer-to-void type is naively considered as being
different to all other pointers by Libabigail. This indirectly leads
to spurious changes in code bases where we have this kind of pattern:
/* in foo.h */
typedef void* some_pointer_type;
struct foo
{
some_pointer_type member;
};
bool
test_some_pointer_type(some_pointer_type);
/* This header file is included by client code */
/*in foo.c */
typedef int* some_pointer_type;
struct foo
{
some_pointer_type member;
};
bool
test_some_pointer_type(some_pointer_type f)
{
/* The actual implementation. */
}
Another way to reproduce that spurious change is to run this command:
$ fedabipkgdiff --self-compare -a --from fc37 glibc
* include/abg-fwd.h (is_void_pointer_type): Declare new function.
* src/abg-ir.cc (is_void_pointer_type): Define new function.
(equals): In the overload for pointer_type_def, handle the special
case pointer to void, making it equal to all other pointer, for
the C language.
(is_non_canonicalized_type): pointer to void is no more
canonicalized as it can be equal to all other types.
* tests/data/test-annotate/libtest23.so.abi: Adjust
* tests/data/test-annotate/libtest24-drop-fns-2.so.abi: Likewise.
* tests/data/test-annotate/libtest24-drop-fns.so.abi: Likewise.
* tests/data/test-annotate/test1.abi: Likewise.
* tests/data/test-annotate/test13-pr18894.so.abi: Likewise.
* tests/data/test-annotate/test14-pr18893.so.abi: Likewise.
* tests/data/test-annotate/test15-pr18892.so.abi: Likewise.
* tests/data/test-annotate/test17-pr19027.so.abi: Likewise.
* tests/data/test-annotate/test18-pr19037-libvtkRenderingLIC-6.1.so.abi:
Likewise.
* tests/data/test-annotate/test19-pr19023-libtcmalloc_and_profiler.so.abi:
Likewise.
* tests/data/test-annotate/test20-pr19025-libvtkParallelCore-6.1.so.abi:
Likewise.
* tests/data/test-annotate/test21-pr19092.so.abi: Likewise.
* tests/data/test-annotate/test5.o.abi: Likewise.
* tests/data/test-diff-filter/test31-pr18535-libstdc++-report-1.txt:
Likewise.
* tests/data/test-diff-filter/test47-filter-void-ptr-change-report-0.txt:
Likewise.
* tests/data/test-read-dwarf/PR22015-libboost_iostreams.so.abi:
Likewise.
* tests/data/test-read-dwarf/PR22122-libftdc.so.abi: Likewise.
* tests/data/test-read-dwarf/PR25007-sdhci.ko.abi: Likewise.
* tests/data/test-read-dwarf/PR25042-libgdbm-clang-dwarf5.so.6.0.0.abi:
Likewise.
* tests/data/test-read-dwarf/libtest23.so.abi: Likewise.
* tests/data/test-read-dwarf/libtest24-drop-fns-2.so.abi: Likewise.
* tests/data/test-read-dwarf/libtest24-drop-fns.so.abi: Likewise.
* tests/data/test-read-dwarf/test-libaaudio.so.abi: Likewise.
* tests/data/test-read-dwarf/test-libandroid.so.abi: Likewise.
* tests/data/test-read-dwarf/test1.abi: Likewise.
* tests/data/test-read-dwarf/test1.hash.abi: Likewise.
* tests/data/test-read-dwarf/test10-pr18818-gcc.so.abi: Likewise.
* tests/data/test-read-dwarf/test11-pr18828.so.abi: Likewise.
* tests/data/test-read-dwarf/test12-pr18844.so.abi: Likewise.
* tests/data/test-read-dwarf/test13-pr18894.so.abi: Likewise.
* tests/data/test-read-dwarf/test14-pr18893.so.abi: Likewise.
* tests/data/test-read-dwarf/test15-pr18892.so.abi: Likewise.
* tests/data/test-read-dwarf/test16-pr18904.so.abi: Likewise.
* tests/data/test-read-dwarf/test17-pr19027.so.abi: Likewise.
* tests/data/test-read-dwarf/test18-pr19037-libvtkRenderingLIC-6.1.so.abi: Likewise.
* tests/data/test-read-dwarf/test19-pr19023-libtcmalloc_and_profiler.so.abi: Likewise.
* tests/data/test-read-dwarf/test20-pr19025-libvtkParallelCore-6.1.so.abi:
Likewise.
* tests/data/test-read-dwarf/test21-pr19092.so.abi: Likewise.
* tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi:
Likewise.
* tests/data/test-read-dwarf/test5.o.abi: Likewise.
* tests/data/test-read-dwarf/test5.o.hash.abi: Likewise.
* tests/data/test-read-dwarf/test9-pr18818-clang.so.abi: Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Dodji Seketeli [Thu, 13 Apr 2023 14:03:04 +0000 (16:03 +0200)]
ir: Add new environment::get_type_id_from_type
While debugging some issues, I felt the need to easily get the type-id
from a given ir::type_base* from within the debugger.
I have thus added this new environment::get_type_id_from_type member
function.
* include/abg-ir.h (environment::get_pointer_type_id_map): Declare
...
* src/abg-ir.cc (environment::get_pointer_type_id_map): ... this
new member function.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Dodji Seketeli [Thu, 13 Apr 2023 13:32:22 +0000 (15:32 +0200)]
abidiff,reader: Fix compilation with --debug-self-comparison
While chasing self-comparison changes errors, I realized that
compilation is failing when the package is configured with
--debug-self-comparison.
Fixed thus.
* src/abg-reader.cc
(reader::{maybe_check_abixml_canonical_type_stability, read_corpus}):
get_environment() doesn't returns a pointer anymore. So adapt the
code.
(maybe_map_type_with_type_id): Adjust because the environment is
const.
(load_canonical_type_ids): The xml_reader namespace doesn't exist
anymore. It's now abixml.
* tools/abidiff.cc (options::options): Initialize the
do_debug_self_comparison data member before the use_btf one, as it
should be.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Dodji Seketeli [Tue, 11 Apr 2023 09:36:15 +0000 (11:36 +0200)]
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>
Dodji Seketeli [Fri, 7 Apr 2023 19:11:44 +0000 (21:11 +0200)]
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>
Dodji Seketeli [Fri, 7 Apr 2023 13:42:35 +0000 (15:42 +0200)]
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>
Dodji Seketeli [Fri, 7 Apr 2023 12:44:32 +0000 (14:44 +0200)]
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>
Dodji Seketeli [Fri, 7 Apr 2023 10:25:58 +0000 (12:25 +0200)]
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>
Dodji Seketeli [Tue, 4 Apr 2023 11:14:42 +0000 (13:14 +0200)]
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>
Dodji Seketeli [Wed, 5 Apr 2023 12:03:06 +0000 (14:03 +0200)]
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>
Dodji Seketeli [Tue, 4 Apr 2023 09:58:35 +0000 (11:58 +0200)]
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>
Dodji Seketeli [Tue, 4 Apr 2023 13:27:22 +0000 (15:27 +0200)]
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>
Dodji Seketeli [Tue, 4 Apr 2023 09:36:24 +0000 (11:36 +0200)]
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>
Dodji Seketeli [Mon, 3 Apr 2023 09:58:14 +0000 (11:58 +0200)]
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>
Dodji Seketeli [Fri, 31 Mar 2023 12:03:53 +0000 (14:03 +0200)]
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>
Dodji Seketeli [Thu, 30 Mar 2023 16:24:01 +0000 (18:24 +0200)]
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>
Ben Woodard [Tue, 28 Mar 2023 19:52:28 +0000 (12:52 -0700)]
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>
Dodji Seketeli [Sun, 26 Mar 2023 22:10:21 +0000 (00:10 +0200)]
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>
Dodji Seketeli [Fri, 24 Mar 2023 22:37:03 +0000 (23:37 +0100)]
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>
Dodji Seketeli [Fri, 24 Mar 2023 10:18:22 +0000 (11:18 +0100)]
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>
Dodji Seketeli [Fri, 24 Mar 2023 13:31:15 +0000 (14:31 +0100)]
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>
Dodji Seketeli [Wed, 22 Mar 2023 14:42:43 +0000 (15:42 +0100)]
abipkgdiff: Fix a typo
* tools/abipkgdiff.cc (compare_to_self): Fix a typo.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Dodji Seketeli [Wed, 22 Mar 2023 12:50:20 +0000 (13:50 +0100)]
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>
Dodji Seketeli [Tue, 21 Mar 2023 17:18:19 +0000 (18:18 +0100)]
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>
Dodji Seketeli [Fri, 17 Mar 2023 15:38:41 +0000 (16:38 +0100)]
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>
Dodji Seketeli [Mon, 13 Mar 2023 15:57:53 +0000 (16:57 +0100)]
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>
Dodji Seketeli [Mon, 13 Mar 2023 15:11:40 +0000 (16:11 +0100)]
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>
Dodji Seketeli [Thu, 9 Mar 2023 16:50:13 +0000 (17:50 +0100)]
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
4bc513a8ae4436625e8641125e0dd0d75d398af2
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>
Dodji Seketeli [Wed, 8 Mar 2023 12:35:37 +0000 (13:35 +0100)]
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>
Guillermo E. Martinez [Mon, 6 Mar 2023 15:50:38 +0000 (09:50 -0600)]
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>
Dodji Seketeli [Thu, 16 Feb 2023 17:06:44 +0000 (18:06 +0100)]
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>
Dodji Seketeli [Thu, 16 Feb 2023 11:33:02 +0000 (12:33 +0100)]
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>
Dodji Seketeli [Thu, 16 Feb 2023 11:19:21 +0000 (12:19 +0100)]
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>
Dodji Seketeli [Wed, 15 Feb 2023 14:53:02 +0000 (15:53 +0100)]
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>
Dodji Seketeli [Wed, 15 Feb 2023 15:26:20 +0000 (16:26 +0100)]
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>
Dodji Seketeli [Wed, 15 Feb 2023 12:18:07 +0000 (13:18 +0100)]
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>
Dodji Seketeli [Sun, 29 Jan 2023 18:58:21 +0000 (19:58 +0100)]
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>
Dodji Seketeli [Sun, 29 Jan 2023 18:57:33 +0000 (19:57 +0100)]
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>
Dodji Seketeli [Fri, 27 Jan 2023 16:00:42 +0000 (17:00 +0100)]
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>
Dodji Seketeli [Fri, 27 Jan 2023 16:30:35 +0000 (17:30 +0100)]
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>
Dodji Seketeli [Fri, 27 Jan 2023 14:58:37 +0000 (15:58 +0100)]
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>
Dodji Seketeli [Thu, 26 Jan 2023 16:49:41 +0000 (17:49 +0100)]
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>
Dodji Seketeli [Thu, 26 Jan 2023 14:39:14 +0000 (15:39 +0100)]
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>
Guillermo E. Martinez [Mon, 27 Feb 2023 18:45:11 +0000 (19:45 +0100)]
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>
Dodji Seketeli [Mon, 27 Feb 2023 17:38:26 +0000 (18:38 +0100)]
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>
Dodji Seketeli [Mon, 27 Feb 2023 18:37:00 +0000 (19:37 +0100)]
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>
Dodji Seketeli [Tue, 21 Feb 2023 15:22:19 +0000 (16:22 +0100)]
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>
Dodji Seketeli [Tue, 21 Feb 2023 13:57:20 +0000 (14:57 +0100)]
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>
Dodji Seketeli [Fri, 10 Feb 2023 12:18:19 +0000 (13:18 +0100)]
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>
Dodji Seketeli [Fri, 3 Feb 2023 00:15:41 +0000 (01:15 +0100)]
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>
Dodji Seketeli [Fri, 10 Feb 2023 09:50:27 +0000 (10:50 +0100)]
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>
Dodji Seketeli [Tue, 31 Jan 2023 17:17:08 +0000 (18:17 +0100)]
{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>
Dodji Seketeli [Thu, 2 Feb 2023 10:30:16 +0000 (11:30 +0100)]
corpus: Handle empty symbol table cases
There can be cases where the symbol table associated with a given
corpus is empty. This patch handles those cases to avoid crashes.
* src/abg-corpus.cc (corpus::priv::{get_sorted_fun_symbols,
get_sorted_undefined_fun_symbols, get_sorted_var_symbols,
get_sorted_undefined_var_symbols}): If the symbol is null, then
return an empty vector of symbols.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Dodji Seketeli [Wed, 1 Feb 2023 16:46:53 +0000 (17:46 +0100)]
dwarf-reader: Remove unused code
* src/abg-dwarf-reader.cc (reader::{find_symbol_table_section,
lookup_native_elf_symbol_from_index}): Remove these dead
functions.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Dodji Seketeli [Wed, 1 Feb 2023 16:18:16 +0000 (17:18 +0100)]
fe-iface: Add missing virtual destructor
* include/abg-fe-iface.cc (fe_iface::~fe_iface): Make this
virtual.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Aleksei Vetrov [Sat, 28 Jan 2023 00:08:18 +0000 (00:08 +0000)]
symtab: fix getting CRC in relocatable modules
In ELF with ET_REL type symbol value holds not absolute but relative to
section value. This patch applies adjustment to the address, used in CRC
value extraction.
* src/abg-elf-helpers.cc (get_crc_for_symbol): Rename
crc_symbol_value to crc_symbol_address and adjust it for
relocatable ELF types.
Signed-off-by: Aleksei Vetrov <vvvvvv@google.com>
Dodji Seketeli [Fri, 13 Jan 2023 15:29:19 +0000 (16:29 +0100)]
Update CTF's ctf_dict_t detection
As ctf_dict_t can be an opaque type depending on the version of
ctf-api.h, using AC_CHECK_TYPE won't work to detect it because that
macro invokes sizeof(ctf_dict_t).
With this change, we don't require that ctf_dict_t be fully defined.
* configure.ac: Use AC_COMPILE_IFELSE to try and compile a code
snippet that doesn't need that ctf_dict_t be fully defined.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Dodji Seketeli [Mon, 9 Jan 2023 17:01:32 +0000 (18:01 +0100)]
Better detect suitable libctf version
On some el9 distros, the version of libctf installed might not have
all the necessary features for the libabigail CTF reader, leading to
compilation errors due to missing types from the ctf-api.h header
file. For instance, the ctf-api.h on some of those distros lacks the
definition of the type struct ctf_dict_t.
This patch adds a configure test for that struct and disables the CTF
support if that type is absent.
* configure.ac: If the "struct ctf_dict_t" type is not present in
the version of ctf-api.h that is present, then switch the support
of CTF off.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Giuliano Procida [Mon, 9 Jan 2023 09:20:44 +0000 (09:20 +0000)]
DWARF reader: avoid C++20 operator!= overload ambiguity
C++20 automatically generates overloads for certain comparison
operators based on others and this can create ambiguity with older
code. The type expr_result has various operators defined and comparing
expr_result != int becomes ambiguous.
This change just avoids this comparison by extracting the underlying
value, rather than making changes to the type itself. There should be
no change in behaviour and no tests are affected.
* (src/abg-dwarf-reader.cc) op_is_control_flow: In the
DW_OP_bra case, when testing the popped value, use the
expr_result's const_value explicitly.
Signed-off-by: Giuliano Procida <gprocida@google.com>
Dodji Seketeli [Sat, 7 Jan 2023 00:15:28 +0000 (01:15 +0100)]
btf-reader: Use abigail::ir::canonicalize_types to canonicalize types
In the btf::reader::canonicalize_types function, this patch now uses
the abigail::ir::canonicalize_types() function to canonicalize types,
just like the other front-ends. The advantage of this function is
that it can perform some sanity checking for type canonicalization
that might be useful for later debugging purposes.
* src/abg-btf-reader.cc (btf::reader::canonicalize_types): Use the
abigail::ir::canonicalize_types function from abg-ir-priv.h
file to canonicalize types.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Dodji Seketeli [Fri, 6 Jan 2023 20:40:44 +0000 (21:40 +0100)]
Update the copyright notice for the BTF reader
* include/abg-btf-reader.h: Update the copyright notice for 2023.
* src/abg-btf-reader.cc: Likewise.
* tests/test-read-btf.cc: Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Dodji Seketeli [Mon, 31 Oct 2022 09:10:52 +0000 (10:10 +0100)]
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>
Dodji Seketeli [Thu, 5 Jan 2023 13:04:16 +0000 (14:04 +0100)]
configure: Enable the CTF front-end by default
The patch enables the CTF front-end by default, if the
ctf.h header file and its associated libctf.so shared library are
detected at configure time. That front-end can of course still be
disabled by using the --disable-ctf option.
* configure.ac: If --disable-ctf hasn't been passed, test for the
presence of ctf.h and then for libctf.so. If both are found then
enable the CTF front end.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Petr Pavlu [Tue, 3 Jan 2023 10:28:55 +0000 (11:28 +0100)]
abidiff: Fix handling of linux-kernel-mode
This fixes
08e76022 ("Support Linux Kernel ABI whitelist files") and
8fd02e0a ("Use the CTF reader by default when applicable").
The first commit removed handling of option --no-linux-kernel-mode. The
second one stopped passing opts.linux_kernel_mode down to the library
which also caused changing the default linux-kernel-mode of abidiff from
true to false. Both changes look unintentional as they are not mentioned
in either commit message.
Restore handling of the linux-kernel-mode in abidiff to match what is
described in doc/manuals/abidiff.rst and make it again consistent with
abidw.
* tools/abidiff.cc (parse_command_line): Recognize
--no-linux-kernel-mode.
(main): Pass opts.linux_kernel_mode down to the library.
Signed-off-by: Petr Pavlu <petr.pavlu@suse.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Dodji Seketeli [Fri, 30 Dec 2022 23:43:51 +0000 (00:43 +0100)]
fix comparing array subrange DIEs
When looking at something else in the DWARF reader, I noticed that the
DIE comparison algorithm for DW_TAG_subprogram DIEs was not taking
into account non-set DW_AT_upper_bound attributes.
Fixed thus.
* src/abg-dwarf-reader.cc (compare_dies): For DW_TAG_subprogram,
non-set DW_AT_{lower,upper}_bound is not the same as when they are
set to zero.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Dodji Seketeli [Fri, 30 Dec 2022 23:58:51 +0000 (00:58 +0100)]
Bug 29811 - Better categorize harmless unknown array size changes
Let's compile the code snippet:
$ echo "unsigned int is_basic_table[];" | gcc -g -c -o test-v0.o -x c -
Let's see what abidw sees from it:
$ abidw test-v0.o | cat -n
1 <abi-corpus version='2.1' path='test-v0.o' architecture='elf-amd-x86_64'>
2 <elf-variable-symbols>
3 <elf-symbol name='is_basic_table' size='4' type='object-type' binding='global-binding' visibility='default-visibility' is-defined='yes'/>
4 </elf-variable-symbols>
5 <abi-instr address-size='64' path='<stdin>' comp-dir-path='/home/dodji/git/libabigail/PR29811/prtests' language='LANG_C11'>
6 <type-decl name='unsigned int' size-in-bits='32' id='type-id-1'/>
7 <array-type-def dimensions='1' type-id='type-id-1' size-in-bits='infinite' id='type-id-2'>
8 <subrange length='infinite' id='type-id-3'/>
9 </array-type-def>
10 <var-decl name='is_basic_table' type-id='type-id-2' mangled-name='is_basic_table' visibility='default' filepath='/home/dodji/git/libabigail/PR29811/prtests/<stdin>' line='1' column='1' elf-symbol-id='is_basic_table'/>
11 </abi-instr>
12 </abi-corpus>
See how the at line 7, the array type of ID 'type-id-2' has an unknown
size. This is the type of the 'is_basic_table' variable defined at
line 10. Note however that the symbol size of the is_basic_table
symbol is 4 bytes (32 bits).
Now, let's compile a similar code where the is_basic_table variable is
now initialized:
$ echo "unsigned int is_basic_table[] = {0};" | gcc -g -c -o test-v1.o -x c -
$ $ abidw test-v1.o | cat -n
1 <abi-corpus version='2.1' path='test-v1.o' architecture='elf-amd-x86_64'>
2 <elf-variable-symbols>
3 <elf-symbol name='is_basic_table' size='4' type='object-type' binding='global-binding' visibility='default-visibility' is-defined='yes'/>
4 </elf-variable-symbols>
5 <abi-instr address-size='64' path='<stdin>' comp-dir-path='/home/dodji/git/libabigail/PR29811/prtests' language='LANG_C11'>
6 <type-decl name='unsigned int' size-in-bits='32' id='type-id-1'/>
7 <array-type-def dimensions='1' type-id='type-id-1' size-in-bits='32' id='type-id-2'>
8 <subrange length='1' type-id='type-id-3' id='type-id-4'/>
9 </array-type-def>
10 <type-decl name='unsigned long int' size-in-bits='64' id='type-id-3'/>
11 <var-decl name='is_basic_table' type-id='type-id-2' mangled-name='is_basic_table' visibility='default' filepath='/home/dodji/git/libabigail/PR29811/prtests/<stdin>' line='1' column='1' elf-symbol-id='is_basic_table'/>
12 </abi-instr>
13 </abi-corpus>
Now, see like at line 7, the array type is now of 4 bytes (32 bits).
Note that the size of is_basic_table is still 32 bits.
Normally, abidiff-ing test-v0 and test-v1 should tell us that the two
versions of the is_basic_table variable are compatible because
fundamentally the structure and the size of the ELF symbol
is_basic_table hasn't changed, even if in the first case, it's an
array of unknown size. It's ELF symbol size was already 32 bits.
Here is what abidiff says:
$ abidiff test-v0.o test-v1.o
Functions changes summary: 0 Removed, 0 Changed, 0 Added function
Variables changes summary: 0 Removed, 1 Changed, 0 Added variable
1 Changed variable:
[C] 'unsigned int is_basic_table[]' was changed to 'unsigned int is_basic_table[1]' at <stdin>:1:1:
type of variable changed:
type name changed from 'unsigned int[]' to 'unsigned int[1]'
array type size changed from infinity to 32
array type subrange 1 changed length from infinity to 1
$
This is because the comparison engine doesn't recognize we are looking
at a type change that is harmless because the ELF size hasn't changed
and because this is an array of one dimension so fundamentally, the
"meaning" of the type of the array hasn't fundamentally changed for
ABI-related purposes.
This patch teaches the diff node categorizer to recognise that we are
in a case where the (one dimension) array of unknown size actually is
the type of an array which symbol size is 4 bytes. In the second
case, the one dimension array has a size of 4 bytes, just as its ELF
symbol size. The diff node categorizer then categorizes the diff node
into the existing category BENIGN_INFINITE_ARRAY_CHANGE_CATEGORY,
which is a harmless diff node category. Everything then falls into
place to filter the change out. Also, the patch adapts the diff
reporter to better describe this type of harmless array variable type
changes.
The output then becomes:
$ abidiff test-v0.o test-v1.o
Functions changes summary: 0 Removed, 0 Changed, 0 Added function
Variables changes summary: 0 Removed, 0 Changed (1 filtered out), 0 Added variable
$
The change is filtered out.
To have details about the change that has been filtered out, one has
to use "--harmless" option:
$ abidiff --harmless test-v0.o test-v1.o
Functions changes summary: 0 Removed, 0 Changed, 0 Added function
Variables changes summary: 0 Removed, 1 Changed, 0 Added variable
1 Changed variable:
[C] 'unsigned int is_basic_table[]' was changed to 'unsigned int is_basic_table[1]' at <stdin>:1:1:
size of variable symbol ( 32 (in bits)) hasn't changed
but it does have a harmless type change
type of variable changed:
type name changed from 'unsigned int[]' to 'unsigned int[1]'
array type size changed from 'unknown' to 32
array type subrange 1 changed length from 'unknown' to 1
$
* include/abg-comp-filter.h
(is_var_1_dim_unknown_size_array_change): Declare new function.
* src/abg-comp-filter.cc (is_var_1_dim_unknown_size_array_change):
Define new function.
(has_benign_array_of_unknown_size_change): Rename
has_benign_infinite_array_change into this. Make this call the
new is_var_1_dim_unknown_size_array_change.
(categorize_harmless_diff_node): Adjust the call to
has_benign_infinite_array_change into the new
has_benign_array_of_unknown_size_change.
* include/abg-ir.h (var_equals_modulo_types): Declare new
function. Make it friend of class decl_base.
* src/abg-default-reporter.cc (default_reporter::report): In the
overload for var_diff, call the new
maybe_report_diff_for_variable.
* src/abg-ir.cc (var_equals_modulo_types): Factorize this out of
the equals() function for var_decl.
(equals): In the overload for var_decl, call the new
var_equals_modulo_types.
* src/abg-reporter-priv.h (maybe_report_diff_for_variable):
Declare new function.
* src/abg-reporter-priv.cc (maybe_report_diff_for_variable):
Define new function.
* tests/data/test-diff-filter/test-PR29811-0-report-0.txt: Add
new reference test output.
* tests/data/test-diff-filter/test-PR29811-0-report-1.txt:
Likewise.
* tests/data/test-diff-filter/test-PR29811-0-v{0,1}.o: Add new
binary test inputs.
* tests/data/test-diff-filter/test-PR29811-0-v{0,1}.c: Add source
code of the binary test inputs.
* tests/data/Makefile.am: Add new test input files above to source
distribution.
* tests/test-diff-filter.cc (in_out_specs): Add new tests to
harness.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Dodji Seketeli [Fri, 30 Dec 2022 21:15:46 +0000 (22:15 +0100)]
dwarf-reader: Bug 29811 - Support updating of variable type
Let's look at the source code reported at
https://sourceware.org/bugzilla/show_bug.cgi?id=29811:
extern unsigned int is_basic_table[];
unsigned int is_basic_table[] = {0};
Let's look at the DWARF output from GCC. The variable is_basic_table
is described by the DIE at offset 0x51:
[ 51] variable abbrev: 7
specification (ref4) [ 2f]
decl_line (data1) 3
decl_column (data1) 14
type (ref4) [ 3b]
location (exprloc)
[ 0] addr .bss+0 <is_basic_table>
The type of the variable is defined at the offset 0x3b:
[ 3b] array_type abbrev: 1
type (ref4) [ 29]
sibling (ref4) [ 4b]
[ 44] subrange_type abbrev: 6
type (ref4) [ 4b]
upper_bound (data1) 0
But then, we see that the DIE at 0x51 has a DW_AT_specification
attribute that refers to the DIE at offset 0x2f:
[ 2f] variable abbrev: 5
name (strp) "is_basic_table"
decl_file (data1) test-v2.c (1)
decl_line (data1) 1
decl_column (data1) 21
type (ref4) [ 1e]
external (flag_present) yes
declaration (flag_present) yes
That DIE at offset 0x2f represents the first external variable
declared in the source code. It's type is an array defined at offset
0x1e:
[ 1e] array_type abbrev: 1
type (ref4) [ 29]
sibling (ref4) [ 29]
[ 27] subrange_type abbrev: 4
This array has one dimension of 'unknown' size; this is because the
dimension is described by the DIE at offset 0x27 of kind
DW_TAG_subrange_type and has no DW_AT_upper_bound DIE.
But then, I said earlier, the real type of the is_basic_table variable
is the DIE at offset 0x3b, which is an array which single dimension
described by the DIE at offset 0x44 of kind DW_TAG_subrange_type with
a DW_AT_upper_bound attribute of value 0.
Let's see the output of abidw on this program, from the DWARF debug info:
1 <abi-corpus version='2.1' path='test-PR29811-unknown-size-array-dwarf-ctf-DWARF.o' architecture='elf-amd-x86_64'>
2 <elf-variable-symbols>
3 <elf-symbol name='is_basic_table' size='4' type='object-type' binding='global-binding' visibility='default-visibility' is-defined='yes'/>
4 </elf-variable-symbols>
5 <abi-instr address-size='64' path='test-PR29811-unknown-size-array-dwarf-ctf.c' comp-dir-path='/home/dodji/git/libabigail/PR29811/prtests' language='LANG_C11'>
6 <type-decl name='unsigned int' size-in-bits='32' id='type-id-1'/>
7 <array-type-def dimensions='1' type-id='type-id-1' size-in-bits='32' id='type-id-2'>
8 <subrange length='1' type-id='type-id-3' id='type-id-4'/>
9 </array-type-def>
10 <array-type-def dimensions='1' type-id='type-id-1' size-in-bits='infinite' id='type-id-5'>
11 <subrange length='infinite' id='type-id-6'/>
12 </array-type-def>
13 <type-decl name='unsigned long int' size-in-bits='64' id='type-id-3'/>
14 <var-decl name='is_basic_table' type-id='type-id-5' mangled-name='is_basic_table' visibility='default' filepath='/home/dodji/git/libabigail/PR29811/prtests/test-PR29811-unknown-size-array-dwarf-ctf.c' line='10' column='1' elf-symbol-id='is_basic_table'/>
15 </abi-instr>
16 </abi-corpus>
The variable is_basic_table is described by the element at line 14:
14 <var-decl name='is_basic_table' type-id='type-id-5' mangled-name='is_basic_table' visibility='default' filepath='/home/dodji/git/libabigail/PR29811/prtests/test-PR29811-unknown-size-array-dwarf-ctf.c' line='10' column='1' elf-symbol-id='is_basic_table'/>
Its type has the ID 'type-id-5' which is defined at line 10:
10 <array-type-def dimensions='1' type-id='type-id-1' size-in-bits='infinite' id='type-id-5'>
11 <subrange length='infinite' id='type-id-6'/>
12 </array-type-def>
Which has an unknown size.
But the, at line 7, there is another array type defined with a size of
32 bits:
7 <array-type-def dimensions='1' type-id='type-id-1' size-in-bits='32' id='type-id-2'>
8 <subrange length='1' type-id='type-id-3' id='type-id-4'/>
9 </array-type-def>
So, libabigail links the is_basic_table variable to the wrong array
type.
This is because when the DWARF reader builds the internal
representation for the DW_TAG_variable DIE at offset 0x51, it first
builds it with the type (and the other properties such as the name for
instance) of the "declaration" DIE specified by the
DW_AT_specification attribute. But then, this DW_TAG_variable DIE has
its own type at offset 0x3b ; libabigail should update the internal
representation it just built to set the type to the one referred to at
offset 0x3b. It's that updating that is not being done. So the
variable wrongly points to the type of the "declaration" DIE at offset
0x2f.
This patch fixes build_var_decl to make it update the type of the
variable when necessary.
* include/abg-ir.h (var_decl::set_type): Declare new member
function.
* src/abg-ir.cc (var_decl::priv::set_type): Define new member
function.
(var_decl::set_type): Likewise.
* src/abg-dwarf-reader.cc (build_var_decl): In "updating mode",
update the type of the variable as well.
* tests/data/test-diff-filter/test-PR29811-unknown-size-array-dwarf-ctf-CTF.o:
Add new test binary input.
* tests/data/test-diff-filter/test-PR29811-unknown-size-array-dwarf-ctf-DWARF.o:
Likewise.
* tests/data/test-diff-filter/test-PR29811-unknown-size-array-dwarf-ctf-report.txt:
Add test reference output.
* tests/data/test-diff-filter/test-PR29811-unknown-size-array-dwarf-ctf.c:
Add source code of the new test binary input.
* tests/data/Makefile.am: Add the new files above to source
distribution.
* tests/test-diff-filter.cc (in_out_specs): Add the input binaries
to the test harness.
* tests/data/test-annotate/test19-pr19023-libtcmalloc_and_profiler.so.abi:
Adjust.
* tests/data/test-read-dwarf/test19-pr19023-libtcmalloc_and_profiler.so.abi:
Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Dodji Seketeli [Fri, 30 Dec 2022 22:25:06 +0000 (23:25 +0100)]
Don't use the "infinite" keyword for arrays of unknown size
In the ABIXML format and in diff reports, array dimensions of unknown
size are described with the "infinite" keyword. This is not explicit
enough. This patch uses the keyword "unknown" instead. Note that the
keyword "infinite" is still recognized by the ABIXML reader.
* src/abg-reader.cc (build_subrange_type, build_array_type_def):
Support the "unknown" keyword, as well as the "infinite" keyword.
* src/abg-reporter-priv.cc (report_size_and_alignment_changes):
Emit the "unknown" keyword, not the "infinity" one.
* src/abg-writer.cc (write_array_size_and_alignment): Likewise.
* tests/data/test-annotate/libtest24-drop-fns-2.so.abi: Adjust.
* tests/data/test-annotate/libtest24-drop-fns.so.abi: Likewise.
* tests/data/test-annotate/test14-pr18893.so.abi: Likewise.
* tests/data/test-annotate/test19-pr19023-libtcmalloc_and_profiler.so.abi:
Likewise.
* tests/data/test-annotate/test7.so.abi: Likewise.
* tests/data/test-read-ctf/test-array-size.abi: Likewise.
* tests/data/test-read-ctf/test-dynamic-array.o.abi: Likewise.
* tests/data/test-read-dwarf/PR25007-sdhci.ko.abi: Likewise.
* tests/data/test-read-dwarf/libtest24-drop-fns-2.so.abi:
Likewise.
* tests/data/test-read-dwarf/libtest24-drop-fns.so.abi: Likewise.
* tests/data/test-read-dwarf/test-libandroid.so.abi: Likewise.
* tests/data/test-read-dwarf/test10-pr18818-gcc.so.abi: Likewise.
* tests/data/test-read-dwarf/test11-pr18828.so.abi: Likewise.
* tests/data/test-read-dwarf/test14-pr18893.so.abi: Likewise.
* tests/data/test-read-dwarf/test16-pr18904.so.abi: Likewise.
* tests/data/test-read-dwarf/test19-pr19023-libtcmalloc_and_profiler.so.abi:
Likewise.
* tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi:
Likewise.
* tests/data/test-read-dwarf/test7.so.abi: Likewise.
* tests/data/test-read-dwarf/test7.so.hash.abi: Likewise.
* tests/data/test-read-dwarf/test9-pr18818-clang.so.abi: Likewise.
* tests/data/test-read-write/test25.xml: Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Dodji Seketeli [Sun, 1 Jan 2023 17:14:26 +0000 (18:14 +0100)]
Update copyright year for 2023
Update the copyright years for 2023, using the script update-copyright.sh.
* update-copyright.sh: Update the copyright years in this script.
* include/abg-comp-filter.h: Update copyright year for 2023.
* include/abg-comparison.h: Likewise.
* include/abg-config.h: Likewise.
* include/abg-corpus.h: Likewise.
* include/abg-ctf-reader.h: Likewise.
* include/abg-cxx-compat.h: Likewise.
* include/abg-diff-utils.h: Likewise.
* include/abg-dwarf-reader.h: Likewise.
* include/abg-elf-based-reader.h: Likewise.
* include/abg-elf-reader.h: Likewise.
* include/abg-fe-iface.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-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-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.
* 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-ctf-reader.cc: Likewise.
* src/abg-default-reporter.cc: Likewise.
* src/abg-diff-utils.cc: Likewise.
* src/abg-dwarf-reader.cc: Likewise.
* src/abg-elf-based-reader.cc: Likewise.
* src/abg-elf-helpers.cc: Likewise.
* src/abg-elf-helpers.h: Likewise.
* src/abg-elf-reader.cc: Likewise.
* src/abg-fe-iface.cc: 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-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-symtab-reader.cc: Likewise.
* src/abg-symtab-reader.h: 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/print-diff-tree.cc: 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-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: Likewise.
* tests/test-elf-helpers.cc: Likewise.
* 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-ctf.cc: Likewise.
* tests/test-read-dwarf.cc: Likewise.
* tests/test-read-write.cc: Likewise.
* tests/test-svg.cc: Likewise.
* tests/test-symtab-reader.cc: Likewise.
* tests/test-symtab.cc: Likewise.
* tests/test-tools-utils.cc: Likewise.
* tests/test-types-stability.cc: Likewise.
* tests/test-utils.cc: Likewise.
* tests/test-utils.h: 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/kmidiff.cc: Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Dodji Seketeli [Wed, 28 Dec 2022 11:44:15 +0000 (12:44 +0100)]
ir: Add sanity checking to canonical type propagation confirmation
To understand the problem reported at
https://sourceware.org/bugzilla/show_bug.cgi?id=29934 where a type was
left non-canonicalized when analysing the binary
/usr/lib64/dovecot/libdovecot-sieve.so.0.0.0 from
https://vault.centos.org/7.6.1810/os/x86_64/Packages/dovecot-2.2.36-3.el7.x86_64.rpm
and
http://debuginfo.centos.org/7/x86_64/dovecot-debuginfo-2.2.36-3.el7.x86_64.rpm,
I had to add some sanity checking code to ensure that types that have
seen their propagated canonical cleared during the canonicalization
process are fully canonicalized at the end of the canonicalization
process.
In order to performg that sanity checking this patch tracks the set of
types which propagated canonical type has been cleared during the
canonicalization of a particular type. When a type with such a
cleared propagated canonical type is finally canonicalized, it is
removed from the set of tracked types. At the end of the
canonicalization process, the set of tracked types must be empty.
This sanity check is compiled in only if the WITH_DEBUG_CT_PROPAGATION
preprocessor macro is defined. That macro is defined if the
--enable-debug-ct-propagation configure switch is used.
* configure.ac: Add a new --enable-debug-ct-propagation configure
flag that defines the WITH_DEBUG_CT_PROPAGATION preprocessor
macro.
* src/abg-ir-priv.h
(environment::priv::types_with_cleared_propagated_ct_): Define new
data member for tracking types with cleared propagated canonical
type.
(environment::priv::types_with_cleared_propagated_ct): Add getter
and setter for the new data member above.
(environment::priv::{record_type_with_cleared_propagated_canonical_type,
erase_type_with_cleared_propagated_canonical_type}): Add
book-keeping functions for the set of types with cleared
propagated canonical type.
(type_base::priv::clear_propagated_canonical_type): Make this
return true if the propagated canonical type is cleared.
(environment::priv::clear_propagated_canonical_type): Define a new
function that takes a type_base* and clears its propagated
canonical type. This also adds the type to the set of tracked
types returned by
environment::priv::types_with_cleared_propagated_ct().
(environment::priv::{cancel_ct_propagation_for_types_dependant_on,
cancel_ct_propagation}): Call the new
environment::priv::clear_propagated_canonical_type() rather than
calling the now low-level
type_base::priv::clear_propagated_canonical_type().
(environment::priv::propagate_ct): Remove the type which just
gained a propagated canonical type from the set of tracked types
returned by environment::priv::types_with_cleared_propagated_ct.
(canonicalize_types): Define new function that canonicalizes all
the types of the system (passed in parameter) and performs sanity
checking to make sure all types with cleared propagated canonical
types have been canonicalized.
* include/abg-ir.h (string_type_base_sptr_map_type): Define new
typedef for an unordered_map<string, type_base_sptr>.
* src/abg-ir.cc (canonicalize): Remove the type which has just
been canonicalized from the set of tracked types returned by
environment::priv::types_with_cleared_propagated_ct.
* src/abg-ctf-reader.cc (reader::types_map): Use the new
string_type_base_sptr_map_type typedef for the type of this map.
(reader::canonicalize_all_types): Use the new function
abigail::ir::canonicalize_types to canonicalize the types of the
system and perform necessary sanity checking.
* src/abg-dwarf-reader.cc (reader::canonicalize_types_scheduled):
Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Dodji Seketeli [Tue, 27 Dec 2022 16:14:16 +0000 (17:14 +0100)]
ir: Bug 29934 - Fix propagated canonical type confirmation
When canonicalization a type T, it can happen that one subtype S of T
compares equal to a type S' where S' is already canonicalized. In
that case, we can deduce that the canonical type of S equals the
canonical type of S', even if we are currently in the process of
canonicalizing T.
In other words, the canonical type of S' is "propagated to S", in the
process of canonicalizing T.
This optimization is called "canonical type propagation" and is meant
to spead up the overall canonicalization process.
However, in some cases, the propagated canonical type can be
"cancelled" for the optimization to be correct. In those cases, the
propagated canonical type is set to nil.
When analysing the binary libdovecot-sieve.so from the problem
reported at https://sourceware.org/bugzilla/show_bug.cgi?id=29934, we
encounter a case where a function type's propagated type is
erroneously cancelled. That leaves the canonical type of that
function type not set and that later violates the assert
ABG_ASSERT(is_non_canonicalized_type(t)) in
abigail::ir::hash_as_canonical_type_or_constant.
I tracked this down to return_comparison_result which fails to confirm
a case of propagated canonical type and thus, some of them can end up
being erroneously cancelled.
Fixed thus.
* src/abg-ir.cc (return_comparison_result): A type whose canonical
type has been propagated must have its canonical type confirmed if
that type is not recursive and is not dependant on any recursive
type. In that case, the canonical type will never be cancelled.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Dodji Seketeli [Wed, 28 Dec 2022 11:51:38 +0000 (12:51 +0100)]
ir: misc cleanups
When looking at something else, I noticed some useless friend function
declaration. Namely, the "canonicalize()" function is declared friend
to the decl_base and scope_decl clases, which is now useless.
This patch removes those declarations.
* include/abg-ir.h (decl_base, scope_decl): Remove the declaration
of canonicalize() as friend to these classes.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Dodji Seketeli [Wed, 28 Dec 2022 17:15:09 +0000 (18:15 +0100)]
elf-reader: Don't free CTF resources too early
elf::reader::locate_alt_ctf_debug_info frees the memory for the
alternate CTF debug info too early, leading to some segmentation
violation down the road, when the rest of the code tries to access the
CTF section afterwards. Many thanks to the Valgrind tool and its
hackers for showing me this.
This patch thus keeps the file descriptor and ELF data structure of
the alternate CTF debug info around for the lifetime of the reader.
* src/abg-elf-reader.cc (reader::priv::{alt_ctf_fd,
alt_ctf_handle}): Add new data members.
(reader::priv::clear_alt_ctf_debug_info_data): Define new member
function.
(reader::priv::~priv): Call the new
priv::clear_alt_ctf_debug_info_data
(reader::priv::initialize): Likewise. Initialize the new
alt_ctf_handle and alt_ctf_fd data members.
(reader::priv::locate_alt_ctf_debug_info): Do not free the fd and
ELF resources early here. Store them in the new
reader::priv::alt_ctf_{fd,handle} instead.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Dodji Seketeli [Sat, 24 Dec 2022 14:29:15 +0000 (15:29 +0100)]
dwarf-reader: Bug 29932 - Handle function DIE as type as needed
When building the IR for a function type, the DWARF reader considers
the function DIE we are looking at as a type DIE.
In dwarf::reader::lookup_fn_type_from_die_repr_per_tu, the call to
get_die_pretty_representation doesn't enforce the fact that the DIE we
are looking at must be considered as a type. This is usually not a
problem because even if get_die_pretty_representation considers the
function DIE as a decl, the representation of a function and a
function type are almost the same.
In this particular case, we run into a function DIE that has an empty
name:
[ 51e54] subprogram abbrev: 18
external (flag_present) yes
name (strp) ""
decl_file (data1) catgets.c (1)
decl_line (data1) 89
prototyped (flag_present) yes
type (ref4) [ 51ac5]
low_pc (addr) +0x0000000000034cc0
high_pc (data8) 133 (+0x0000000000034d45)
frame_base (exprloc)
[ 0] call_frame_cfa
GNU_all_call_sites (flag_present) yes
sibling (ref4) [ 51edb]
Note that this is from the /lib64/libc-2.17.so from the
https://vault.centos.org/7.6.1810/os/x86_64/Packages/glibc-2.17-260.el7.x86_64.rpm
package, associated with the debuginfo package at http://debuginfo.centos.org/7/x86_64/glibc-debuginfo-2.17-260.el7.x86_64.rpm.
In that case, get_die_pretty_representation returns an empty string
because it doesn't expects a function decl with an empty name.
If we make dwarf::reader::lookup_fn_type_from_die_repr_per_tu
explicitly be in the context of a type by invoking
get_die_pretty_type_representation instead, the problem disapears as
the latter function treats the DIE as a function type DIE, so it
doesn't need its name.
Thus, this patch makes
dwarf::reader::lookup_fn_type_from_die_repr_per_tu invoke
get_die_pretty_type_representation instead.
* src/abg-dwarf-reader.cc
(reader::lookup_fn_type_from_die_repr_per_tu): Invoke
get_die_pretty_type_representation instead of
get_die_pretty_representation when looking at a function DIE
without a name.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Dodji Seketeli [Sat, 24 Dec 2022 13:21:06 +0000 (14:21 +0100)]
Bug 29934 - Handle buggy data members with empty names
When handling the changes between two ABI corpora, the diff graph
building pass chokes on a data member which seems to erroneously have
an empty name.
The steps to reproduce the issue are explained in the problem report
at https://sourceware.org/bugzilla/show_bug.cgi?id=29934.
The root cause of the problem is that the "struct mailbox" data
structure from the binary /usr/lib64/dovecot/libdovecot-storage.so.0
coming from the dovecot-2.2.36-3.el7.x86_64.rpm package contains a
data member that has an empty name. The source code of that data
structure can be browsed at
https://github.com/dovecot/core/blob/release-2.2.36/src/lib-storage/mail-storage-private.h
We see that the mailbox::storage data structure at line 352 ends up in
the DWARF debug info with an empty name. Let's look at the DWARF
dump as emitted by "eu-readelf --debug-dump=info" on the
/usr/lib/debug//usr/lib64/dovecot/libdovecot-storage.so.0.debug file
from the dovecot-debuginfo-2.2.36-3.el7.x86_64.rpm package.
A relevant DIE for the "struct mailbox" is the following:
[ 3e3e] structure_type abbrev: 9
name (strp) "mailbox"
byte_size (data2) 768
decl_file (data1) mail-storage-private.h (24)
decl_line (data2) 348
sibling (ref_udata) [ 41f9]
[ 3e4a] member abbrev: 59
name (strp) "name"
decl_file (data1) mail-storage-private.h (24)
decl_line (data2) 349
type (ref_addr) [ 84]
data_member_location (data1) 0
[ 3e57] member abbrev: 59
name (strp) "vname"
decl_file (data1) mail-storage-private.h (24)
decl_line (data2) 351
type (ref_addr) [ 84]
data_member_location (data1) 8
[ 3e64] member abbrev: 47
name (strp) ""
decl_file (data1) mail-storage-private.h (24)
decl_line (data2) 352
type (ref_udata) [ 3bee]
data_member_location (data1) 16
[...]
You can see here that the DW_TAG_member DIE at offset 0x3e64 has an
empty name. Its DW_AT_type attribute references the DIE at offset
0x3bee.
The DIE at offset 0x3bee is this one:
[ 3bee] pointer_type abbrev: 95
byte_size (data1) 8
type (ref_udata) [ 3a90]
[...]
It's a pointer to the type which DIE is at offset 0x3a90, which is:
[ 3a90] structure_type abbrev: 48
name (strp) "mail_storage"
byte_size (data2) 352
decl_file (data1) mail-storage-private.h (24)
decl_line (data1) 132
sibling (ref_udata) [ 3bee]
So, the data member of "struct mailbox" which has an empty name has a
type "pointer to struct mail_storage", aka "struct mail_storage*".
That indeed corresponds to the "storage" data member that we see at
line 352 of the mail-storage-private.h file, browsable at
https://github.com/dovecot/core/blob/release-2.2.36/src/lib-storage/mail-storage-private.h.
The fact that this data member has an empty name seems to me as a bug
of the DWARF emitter.
Libabigail ought to gently handle this bug instead of choking.
This patch assigns an artificial name to that empty data member to
handle this kind of cases in the future. The names looks like
"unnamed-@-<location>" where "location" is the location of the data
member.
Please note that there can be normal cases of anonymous data members
where the data member has an empty name. In those cases, the data
member must be of type union or struct. This is to describe the
"unnamed fields" C feature described at
https://gcc.gnu.org/onlinedocs/gcc/Unnamed-Fields.html.
The buggy case we are seeing here is different from the "unnamed
field" case because the type of the anonymous data member is neither
struct nor union.
* src/abg-dwarf-reader.cc (die_is_anonymous_data_member): Define
new static function.
(die_member_offset): Move the declaration of this up so that it
can be used more generally.
(reader::build_name_for_buggy_anonymous_data_member): Define new
member function.
(add_or_update_class_type): Generate an artificial name for buggy
data members with empty names.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Guillermo E. Martinez [Thu, 22 Dec 2022 15:49:49 +0000 (09:49 -0600)]
ctf-reader: Fix missing initializer for member in test suite
With -Werror=missing-field-initializers on, the compiler chokes on CTF
test suite. Fixed thus.
* tests/test-read-ctf.cc (in_out_specs): Add initializer for
`option' field in test entry.
* tests/data/test-read-ctf/test-alias.o.abi: Adjust.
Signed-off-by: Guillermo E. Martinez <guillermo.e.martinez@oracle.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Guillermo E. Martinez [Wed, 21 Dec 2022 20:12:33 +0000 (14:12 -0600)]
ctf-front-end: Add test for alias symbols
This patch adds a new test case in the ctf-front-end test suite to
to test for alias symbols support.
* tests/data/test-read-ctf/test-alias.o: New binary test input file.
* tests/data/test-read-ctf/test-alias.o.abi: New exported abixml file.
* tests/data/Makefile.am: Add the new test input above
* tests/test-read-ctf.cc: Add the new test input above to the test
harness.
Signed-off-by: Guillermo E. Martinez <guillermo.e.martinez@oracle.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Xiaole He [Tue, 20 Dec 2022 13:06:34 +0000 (21:06 +0800)]
elf-reader: reclaim fd and mem before break
In elf::reader::priv::locate_alt_ctf_debug_info from
src/abg-elf-reader.cc, the resources held by the hdl and fd variables
aren't necessary released because the control-flow gets out of the
loop too early. This patch fixes the problem.
* src/abg-elf-reader.cc
(elf::reader::priv::locate_alt_ctf_debug_info): Reclaim fd and mem
before break. Also, do not try to locate the debug info it's
already been located.
Signed-off-by: Xiaole He <hexiaole@kylinos.cn>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Dodji Seketeli [Tue, 20 Dec 2022 15:06:33 +0000 (16:06 +0100)]
Bug 29901 - abidiff hangs when comparing libgs.so.10 with itself
This is a follow-up patch to this one:
88c6e080 Bug 29857 - Better detect comparison cycles in type graph
When looking at the type comparison stack, it looks like a type that
is on the left-hand side of the comparison can appear on the
right-hand side later, in the comparison stack. The cycle detection
algorithm doesn't take that scenario into account and so that cycle in
the graph of types being compared is not detected.
This patch takes that case into account.
* src/abg-ir-priv.h (environment::priv::comparison_started): Look
for each operand of the comparison in both the right-hand and
left-hand operand stacks.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Dodji Seketeli [Mon, 5 Dec 2022 15:32:24 +0000 (16:32 +0100)]
Update website documentation for 2.2
* mainpage.txt: Update for 2.2.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>