Changing a void* pointer into another pointer of the same size is a
change that is harmless in terms of data layout.
This commit thus categorizes such a change as harmless.
* include/abg-comparison.h (VOID_PTR_TO_PTR_CHANGE_CATEGORY): New
enumerator in the diff_category enum. Also, adjust the
EVERYTHING_CATEGORY enumerator.
* include/abg-fwd.h (is_void_pointer_type): Declare new function.
* src/abg-comp-filter.cc (has_void_ptr_to_ptr_change): Define new
static function and ...
(categorize_harmless_diff_node): ... use it here.
* src/abg-comparison.cc (get_default_harmless_categories_bitmap):
Add the new abigail::comparison::VOID_PTR_TO_PTR_CHANGE_CATEGORY
category in here.
(operator<<(ostream& o, diff_category c)): Add support for the new
VOID_PTR_TO_PTR_CHANGE_CATEGORY.
* src/abg-ir.cc (is_void_pointer_type): Define new function.
* tests/data/Makefile.am: Add the new test material below to source distribution.
* tests/data/test-diff-filter/test47-filter-void-ptr-change-report-0.txt:
New test reference output.
* tests/data/test-diff-filter/test47-filter-void-ptr-change-v{0,1}.c:
Source code of the new binary test input below.
* tests/data/test-diff-filter/test47-filter-void-ptr-change-v{0,1}.o:
New binary test input.
* tests/test-diff-filter.cc: Add the test input/output above to
test harness.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
This partially fixes PR23700.
A change in the CV qualifiers of a function return value type should
be categorized as harmless. And this is what this patch does.
* include/abg-comparison.h (FN_RETURN_TYPE_CV_CHANGE_CATEGORY):
New enumerator for diff_category.
(EVERYTHING_CATEGORY): Update.
* src/abg-comp-filter.cc (type_diff_has_cv_qual_change_only):
Factorize this function out of ...
(has_fn_parm_type_cv_qual_change): ... this one.
(has_fn_return_type_cv_qual_change): Define new static function.
(categorize_harmless_diff_node): Use the new
has_fn_return_type_cv_qual_change.
* src/abg-comparison.cc (get_default_harmless_categories_bitmap):
Adjust to add the new FN_RETURN_TYPE_CV_CHANGE_CATEGORY category.
(operator<<(ostream& o, diff_category c)): Support the new
FN_RETURN_TYPE_CV_CHANGE_CATEGORY.
* tests/data/Makefile.am: Add the new test material below to
source distribution.
* tests/data/test-diff-filter/test46-fn-return-qual-change-report-0.txt:
New reference output for the new input test.
* tests/data/test-diff-filter/test46-fn-return-qual-change-v{0,1}.c:
New source code for the new binary test input.
* tests/data/test-diff-filter/test46-fn-return-qual-change-v{0,1}.o:
New binary test input files.
* tests/test-diff-filter.cc: Add the new test input above to test
harness.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
This is a partial fix of PR23700.
Conceptually, there are two kinds of type suppression specifications:
1/ a generic user-provided suppression specification that is meant to
suppress changes on types specified by the user
2/ a private type suppression specification that is automatically
generated from the path to public header files provided by the user.
Technically, one difference between 1 and 2 lays in the way we
propagate categories of changes matched by those suppression
specifications.
If a class type change of category SUPPRESSED_CATEGORY is referenced
in a typedef change, then the typedef change is also considered to be
of category SUPPRESSED_CATEGORY. In other words, the
SUPPRESSED_CATEGORY category is propagated to the typedef change.
That means that if a change to a class type is suppressed, a (changed)
typedef to that class is considered to be suppressed too.
But then that is not true if the class type was changed because it's
private. In that, a typedef to that class can be *public*, because
the said typedef is defined in a public header. In that case the
typedef change should *NOT* be considered suppressed just because the
class type change was suppressed.
The problem we have here is that we don't make any difference between
1/ and 2/. So we need to introduce different propagation rules for 1/
and 2/.
So this patch introduces a new PRIVATE_TYPE_CATEGORY category for
types suppression specification that are automatically generated for
private types. That new category has its own propagation rule which
is basically "no propagation"; every type must be matched by the
private type suppression specification to be considered as private.
* include/abg-comp-filter.h (has_harmful_name_change): Declare new
function overloads.
* include/abg-comparison.h (PRIVATE_TYPE_CATEGORY): New enumerator
for diff_category;
(EVERYTHING_CATEGORY): Adjust this enumerator in diff_category;
(is_suppressed): Take an output parameter to say if the
suppression is a private type suppression.
* include/abg-suppression.h (is_private_type_suppr_spec): Take a
const reference parameter and add an overload for a shared
pointer.
* src/abg-comp-filter.cc (has_harmful_name_change): Define new
function.
* src/abg-comparison-priv.h (diff::priv::is_filtered_out): Diffs
of category PRIVATE_TYPE_CATEGORY are also considered filtered
out.
* src/abg-comparison.cc (diff::is_filtered_out): Adjust to account
for canonical diffs of category PRIVATE_TYPE_CATEGORY.
(diff::is_suppressed): Add an overload that takes a
is_private_type output parameter. Re-write the old overload in
terms of the new one.
(operator<<(ostream& o, diff_category c)): Handle
PRIVATE_TYPE_CATEGORY.
(category_propagation_visitor::visit_end): Do not propagate
PRIVATE_TYPE_CATEGORY here. Do not propagate
HARMLESS_DECL_NAME_CHANGE_CATEGORY either, when the class does
have a harmful decl name change.
(suppression_categorization_visitor::visit_begin): Set the new
PRIVATE_TYPE_CATEGORY category but do not propagate it.
(suppression_categorization_visitor::visit_end): Add some
comments.
* src/abg-default-reporter.cc (default_reporter::report): Avoid
reporting typedef underlying types that are in the
PRIVATE_TYPE_CATEGORY category.
* src/abg-suppression.cc (type_suppression::suppresses_diff): Do
not peel typedefs if we are a private type suppression.
(is_private_type_suppr_spec): Take a const reference.
* tests/data/Makefile.am: Add the new test material below to
source distribution.
* tests/test-diff-suppr.cc: Use new test binary input.
* tests/data/test-diff-filter/test7-report.txt: Adjust.
* tests/data/test-diff-suppr/test39-opaque-type-report-0.txt: New
test reference output.
* tests/data/test-diff-suppr/test39-opaque-type-v{0,1}.c: Source
code of new test binary input.
* tests/data/test-diff-suppr/test39-opaque-type-v{0,1}.o: New test
binary input.
* tests/data/test-diff-suppr/test39-public-headers-dir/test39-header-v{0,1}.h:
Source code of new test binary input.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
This is a followup of the patch with commit hash 90b4e76.
It turns out that in some cases, when we see a suppressed private
class definition, we haven't *previously* seen any declaration-only
instance of it. So we cannot use any pre-existing declaration-only
instance as an opaque type for the private type that is suppressed.
In that case, this patch creates (and uses) a declaration-only
instance for the suppressed private type definition.
* src/abg-dwarf-reader.cc (get_opaque_version_of_type): If no
pre-existing opaque version was found, a new one is created and
returned. Take a needed "where_offset" parameter.
(build_ir_node_from_die): Adjust the call to
get_opaque_version_of_type.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Suppose we have two versions of a library which are almost identical.
Suppose the difference between the two binaries is a slight difference of
ordering in how the linker put together what the DWARF describes.
Then, while processing the debug info of the first library, libabigail
first comes across the forward declaration of a type T. Suppose that
declaration is not matched by any private type suppression
specification. Libabigail is going to keep the declaration of T and
build an internal representation (IR) for it. It's also going to
build an IR for types and decls using T like "T*" or "T* var".
Now suppose that while processing the debug info of the second
library, libabigail first comes across the *definition* of T --
because in this second library, that definition comes first. Suppose
that the definition is matched by a private type suppression
specification, unlike the declaration in the first library. In this
case, T is going to be dropped, and no IR is going to be built for it.
If other types or decl like 'T*' or 'T *var" refer to this
*definition* of T, they will be dropped too.
We'll end up with those two libraries that are identical (modulo the
order in which libabigail sees type declarations and their
definitions) and are considered different when a suppression
specification makes us drop T: the second library appears to
libabigail as if T was removed from it.
This is the problem addressed by this patch.
When the definition of a type T is suppressed because it's considered
private then we look if there was a forward declaration for it
elsewhere, that is not matched by the private type suppression
specification. If we encountered such a type declaration then it
means that declaration is in effect an "opaque" version of T. So
rather than just dropping T altogether, we keep (and build an IR) for
its opaque version only. And we drop the definition of T.
This seems to fix the issue.
I can't seem to reproduce the slight re-ordering of DIEs descriptions that
uncover the issue so I'll rely on integration tests to catch future
regressions on this issue, rather than on unit tests. Sigh.
* include/abg-tools-utils.h (PRIVATE_TYPES_SUPPR_SPEC_NAME):
Remove this extern constant definition.
* src/abg-dwarf-reader.cc (type_is_suppressed): Add an overload
that takes an additional type_is_private output parameter.
(get_opaque_version_of_type): New static function.
(build_ir_node_from_die): For class types, get the opaque version
for suppressed private types rather than dropping them altogether.
* src/abg-reader.cc (type_is_suppressed): Adjust.
* src/abg-suppression-priv.h (type_is_suppressed): Add an overload
that takes a type_is_private output parameter.
* include/abg-suppression.h (get_private_types_suppr_spec_label)
(is_private_type_suppr_spec): Declare new functions.
* src/abg-suppression.cc
(get_private_types_suppr_spec_label, is_private_type_suppr_spec):
Define new functions.
(suppression_matches_type_name_or_location): Use the new
get_private_types_suppr_spec_label rather than a global extern
variable.
* src/abg-tools-utils.cc (handle_fts_entry): Adjust to use the new
get_private_types_suppr_spec_label.
(gen_suppr_spec_from_headers): Handle the case or an empty headers
root dir.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
When the ir_traversable_base::traverse() walks the IR graph, it
happens that it can visit a type node that was already visited before.
For instance, it visits the 'struct S' once and later, as part of its
visit of struct S*, it can visit struct S again.
There are use cases where we want the walker to avoid visiting a given
type node again. This patch adds the option to do so.
Basically the ir_node_visitor class can now be configured to tell the
walker to avoid re-visiting a node.
The test-ir-walker.cc example is amended to avoid re-visiting type nodes
as well.
* include/abg-ir.h (struct ir_node_visitor): Make this be a class.
Add a private data member to it, following the 'pimpl' idiom.
(ir_node_visitor::{allow_visiting_already_visited_type_node,
mark_type_node_as_visited, forget_visited_type_nodes,
type_node_has_been_visited}): Declare new member functions.
* src/abg-ir.cc ({type_base, type_decl, scope_type_decl,
qualified_type_decl, pointer_type_def, reference_type_def,
array_type_def, enum_type_decl, typedef_decl, class_or_union,
class_decl, union_decl}::traverse): Avoid re-visiting the type
node if the visitor was configured as such.
(struct ir_node_visitor::priv): Define new struct.
(ir_node_visitor::{allow_visiting_already_visited_type_node,
mark_type_node_as_visited, forget_visited_type_nodes,
type_node_has_been_visited}): Define new member functions.
* tests/test-ir-walker.cc
(name_printing_visitor::name_printing_visitor): Avoid visiting a
type node twice.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
It turned out the first parameter of
abigail::dwarf_reader::get_soname_of_elf_file was not documented.
Fixed thus.
* src/abg-dwarf-reader.cc (get_soname_of_elf_file): Document the
first parameter. Remove bogus documentation of the previous 'elf'
parameter.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
It appears that it's not possible to write a suppression specification
like the below at the moment:
[suppress_file]
label = Libabigail can't handle libgfortran.so (https://sourceware.org/bugzilla/show_bug.cgi?id=23492)
file_name_regexp = libgfortran\\.so.*
This is because the ini parser won't accept the '=' character in the
URL as a valid character for ini property values.
So the entire [suppress_file] section is ignored by the suppression
specification engine.
This patch fixes that by making the equal character valid in property
values.
* src/abg-ini.cc (char_is_delimiter): Take a new include_equal
flag to control is the equal character should be considered as a
delimiter or not.
(char_is_property_value_char): Accept the equal character as a
valid property value character.
* tests/Makefile.am: Build a new runtestini test from the new
tests/test-ini.cc source file.
* tests/data/Makefile.am: Add the two new test inputs below to
source distribution.
* tests/data/test-ini/test01-equal-in-property-string.{abignore,
abignore.expected}: New test inputs.
* tests/test-ini.cc: New test harness.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
The tests/test-ir-walker.cc example was working on abixml files
resulting from abidw. This commit changes that to make it work on
ELF input files directly. The commit also adds some comments to make
it easier to understand the concepts.
* test-ir-walker.cc (main): Load an ABI corpus from an elf file
and walk its translation units.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
It turns out that when we disable fedabipkgdiff, we also disable
detection of python and the setting of the proper environment
variables that are expected by some makefiles down the road. The
leads to the runtestdefaultsupprs.py test to be blocked at runtime
because the environement variable PYTHON is not defined. This patch
fixes that.
* configure.ac: Detect the presence and version of python even
when fedabipkgdiff is disabled.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
While adding test materials for
test-diff-suppr/test38-char-class-in-ini* to source distribution, I
got the paths wrong. Fixing thus.
* tests/data/Makefile.am: Add proper path for
test-diff-suppr/test38-char-class-in-ini*.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Sometimes, one wants to be able to write suppression specifications
like:
[suppress_function]
filename_regexp = ^test38-char-class-in-ini-v[[:digit:]].*
symbol_name_regexp = bar
change_kind = added-function
without having to escape the square brackets in the regexp. Normally,
one has to escape the '[' and the ']' because these characters are
used to define ini section names (e.g, [suppress_function]).
This patch allows the presence of the square bracket characters in a
property value, making the suppression specification above valid.
* src/abg-ini.cc (char_is_delimiter): Possibly disallow square
bracket characters into the set of delimiters.
* tests/data/test-diff-suppr/test38-char-class-in-ini-report-0.txt:
New reference output.
* tests/data/test-diff-suppr/test38-char-class-in-ini-v{0,1}.c:
Source code new test binaries.
* tests/data/test-diff-suppr/test38-char-class-in-ini-v{0,1}.o:
New test binaries.
* tests/data/test-diff-suppr/test38-char-class-in-ini.abignore:
New test abi suppression file.
* tests/data/Makefile.am: Add the new test materials above to
source distribution.
* tests/test-diff-suppr.cc: Add the test materials above to the
set of tests to run.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
runtestdefaultsupprspy3.sh just runs runtestdefaultsupprs.py using
python3. So when both run in parallel, it can happen that they step
on their toes as they emit content into some files.
This patch commits makes it so that runtestdefaultsupprspy3.sh is
executed only if we are in the python3 mode, otherwise we just run
runtestdefaultsupprs.py, fixing the occasional failure that we see on
either runtestdefaultsupprs.py or runtestdefaultsupprspy3.sh.
* tests/Makefile.am: Run runtestdefaultsupprspy3.sh if we are in
python3 mode otherwise run runtestdefaultsupprs.py.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
When die_function_type_is_method returns true, it meanins that the
function die it's looking at is a member function. In that case,
die_function_type_is_method must also return the class of which the
function is a member. It appears that there are cases where this
die_function_type_is_method returns a *typedef* DIE (to a class DIE),
rather than a class DIE.
This results in the assertion violation below when loading the file
/usr/lib/libreoffice/program/libanalysislo.so from, e.g, the
libreoffice-calc-5.3.6.1-10.el7.i686 package:
/home/dodji/git/libabigail/master/src/abg-dwarf-reader.cc:13846: abigail::ir::function_type_sptr abigail::dwarf_reader::build_function_type(abigail::dwarf_reader::read_context&, Dwarf_Die*, abigail::ir::class_or_union_sptr, size_t): Assertion `klass_type' failed.
This patch fixes that by peeling off the potential typedefs that might
be there.
* src/abg-dwarf-reader.cc (die_peel_typedef): Define new static
function.
(die_function_type_is_method_type): Use the function above to peel
the class die from potential typedefs wrapping it.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
For too long now changes to parameter types like "const char*" to
"char*" have been reported by libabigail by default. Those are not
really meaningful ABI changes, at least not in C. This patch makes
filters out those changes by default.
* include/abg-comparison.h (FN_PARM_TYPE_CV_CHANGE_CATEGORY): Add
this new enumerator to the diff_category enum. Also, OR this to
the value of the EVERYTHING_CATEGORY enumerator.
* src/abg-comp-filter.cc (has_fn_parm_type_top_cv_qual_change):
Rename has_fn_parm_type_cv_qual_change into this.
(has_fn_parm_type_cv_qual_change): New function.
(categorize_harmless_diff_node): Categorize cv qual changes as
being of category FN_PARM_TYPE_CV_CHANGE_CATEGORY.
* src/abg-comparison.cc (get_default_harmless_categories_bitmap):
Add FN_PARM_TYPE_CV_CHANGE_CATEGORY to the default harmless
categories.
* tests/data/test-diff-pkg/libICE-1.0.6-1.el6.x86_64.rpm--libICE-1.0.9-2.el7.x86_64.rpm-report-0.txt: Adjust.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
When analyzing the libfreetype.so binary, it appears that
libabigail's diff node redundancy marking pass is failing to detect a
redundant diff node in cases were the node is recursively referencing
itself through a path that involves function type and typedef diff
nodes.
So it is only at reporting time that we'd detect that the node is
redundant so we emit messages like "this change was reported
earlier". But When the earlier change in question is suppressed due
to, e.g, a suppression specification resulting from the user providing
abidiff with the --headers-dir{1,2} command line option, then the
change report becomes confusing, at best.
The right behaviour is to detect the node is redundant and mark it as
such, so that the reporting pass can avoid reporting it altogether.
This is what this patch does.
This patch changes the output of the runtestdiffpkg regression test.
To update the reference output, we need an additional patch to handle
a separate (but somewhat related) issue. That is going to be done in
the subsequent commit which title is:
"Filter out changes like type to const type"
* include/abg-comparison.h
(is_function_type_diff_with_local_changes)
(is_reference_or_pointer_diff_to_non_basic_distinct_types)
(peel_typedef_diff): Declare new functions.
* src/abg-comparison.cc
(is_function_type_diff_with_local_changes)
(is_reference_or_ptr_diff_to_non_basic_nor_distinct_types)
(peel_typedef_diff): Define new functions.
(is_reference_or_pointer_diff): Peel typedefs before operating.
(redundancy_marking_visitor::visit_begin): Only sibbling parameter
diff node that carry basic type changes (or distinct type changes)
are *not* marked as redundant. All other kinds of sibbling
parameter diff nodes are markes redundant. Also, rather than
never marking function type diffs as redundant by fear of missing
local changes on these, just avoid marking function type diff
nodes with local changes. It's possible to be that precise now
that we can detect that a diff node carries local changes.
* tests/data/test-diff-suppr/test37-opaque-type-v{0,1}.o: New
binary tests input.
* tests/data/test-diff-suppr/test37-opaque-type-v{0,1}.c: Source
code of the binary tests input above.
* tests/data/test-diff-suppr/test37-opaque-type-header-dir/test37-opaque-type-header-v{0,1}.h:
Headers of the binary tests input above.
* tests/data/test-diff-suppr/test37-opaque-type-report-0.txt:
Reference output for this new test.
* tests/data/Makefile.am: Add the new test material above to
source distribution.
* tests/test-diff-suppr.cc (in_out_specs): Add the new test input
above to the test harness.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
When a function symbol S has several versions and several different
functions with different names have those different versions of S as
underlying symbols, libabigail could mistakenly take one function for
another. This is because there are cases where libabigail identifies
the function using its symbol name without taking the version name
into account.
This patch fixes that.
* src/abg-default-reporter.cc (default_reporter::report): In C,
tell the user about the underlying function symbol name only if
said symbol name is different from the name of the function.
* src/abg-ir.cc (function_decl::get_id): If the function has an
underlying symbol, use the symbol name and version as the function
ID. But if the function symbol has an alias then use the linkage
name as the ID.
* tests/data/test-diff-pkg/elfutils-debuginfo-0.170-4.el7.x86_64.rpm:
New binary test input.
* tests/data/test-diff-pkg/elfutils-debuginfo-0.171-1.el7.x86_64.rpm: Likewise.
* tests/data/test-diff-pkg/elfutils-devel-0.170-4.el7.x86_64.rpm: Likewise.
* tests/data/test-diff-pkg/elfutils-devel-0.171-1.el7.x86_64.rpm: Likewise.
* tests/data/test-diff-pkg/elfutils-libs-0.170-4.el7.x86_64.rpm: Likewise.
* tests/data/test-diff-pkg/elfutils-libs-0.171-1.el7.x86_64.rpm: Likewise.
* tests/data/test-diff-pkg/elfutils-libs-0.170-4.el7.x86_64-multiple-sym-vers-report-0.txt:
New reference test output.
* tests/data/Makefile.am: Add the new test material above to
source distribution.
* tests/test-diff-pkg.cc (in_out_specs): Integrate the new test
inputs above into the harness.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
This patch detects when a data member becomes anonymous or when an
anonymous data member becomes non anonymous and emits an explicit
message.
* include/abg-comp-filter.h (has_anonymous_data_member_change):
Add new function declaration.
* include/abg-fwd.h (is_data_member, is_anonymous_data_member):
declare new overloads.
* src/abg-comp-filter.cc (has_anonymous_data_member_change):
Define new overloads.
* src/abg-ir.cc (is_data_member, is_anonymous_data_member): Define
new overloads.
* src/abg-reporter-priv.cc (represent): In the var_diff overload,
detect when we have anonymous data member changes and emit
explicit error messages then.
* tests/data/test-diff-dwarf/test45-anon-dm-change-report-0.txt:
New test material.
* tests/data/test-diff-dwarf/test45-anon-dm-change-v0.cc: Likewise.
* tests/data/test-diff-dwarf/test45-anon-dm-change-v0.o: Likewise.
* tests/data/test-diff-dwarf/test45-anon-dm-change-v1.cc: Likewise.
* tests/data/test-diff-dwarf/test45-anon-dm-change-v1.o: Likewise.
* tests/data/Makefile.am: Add the new test material above to source
distribution.
* tests/test-diff-dwarf.cc (in_out_specs): Add the new test
material above to the test harness.
* tests/data/test-diff-filter/test30-pr18904-rvalueref-report0.txt: Adjust.
* 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/test35-pr18754-no-added-syms-report-0.txt: Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
In the previous commit, I forgot to add the files
test-diff-dwarf/test44-anon-struct-union-v{0,1}.o to source
distribution. This commit fixes that.
* tests/data/Makefile.am: Add
test-diff-dwarf/test44-anon-struct-union-v{0,1}.o files to source
distribution.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
When referring to an anonymous struct or union, libabigail used to
name it __anonymous_struct__ or __anonymous_union__.
Now, with this patch, libabigail rather uses the flat representation
of the struct/union, e.g, struct {int foo; char bar;}.
* src/abg-ir.cc (get_class_or_union_flat_representation): Take a
const class_or_union* (like what the declaration in the header
file says), rather than just a class_or_union*.
({class,union}_decl::get_pretty_representation): For anonymous
classes and unions, use the flat representation.
* 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/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-diff-dwarf/test43-PR22913-report-0.txt: Likewise.
* tests/data/test-diff-dwarf/test44-anon-struct-union-report-0.txt:
New test reference output.
* tests/data/test-diff-dwarf/test44-anon-struct-union-v{0,1}.cc:
Source code of new test binary outputs.
* tests/data/test-diff-dwarf/test44-anon-struct-union-v{0,1}.o:
New test binary outputs.
* tests/data/Makefile.am: Add the new test materials above to
source districution.
* tests/test-diff-dwarf.cc (in_out_specs): Add the new test
material above to the test harness here.
* tests/data/test-diff-filter/test30-pr18904-rvalueref-report0.txt: Adjust.
* 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/test35-pr18754-no-added-syms-report-0.txt: Likewise.
* tests/data/test-diff-pkg/libcdio-0.94-1.fc26.x86_64--libcdio-0.94-2.fc26.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-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi: Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
This is a fixup of the previous commit entitled:
"Better detect when diff nodes only carry local type changes"
In that previous commit, I missed some things about pointer, reference
and qualified types, as far as local changes detection and management
is concerned.
This commit handles those points.
* src/abg-comparison.cc
(leaf_diff_node_marker_visitor::visit_begin): Do not mark
qualified types as leaf diff nodes.
(redundancy_marking_visitor::visit_end): Changes to qualified type
are never considered local. This is just as for pointer and
reference types.
* src/abg-default-reporter.cc
(default_reporter::report_local_reference_type_changes): Display
structural changes of the pointed-to type.
(default_reporter::report): In the overload for reference_diff,
better detect and handle when we have local changes, or not.
* src/abg-ir.cc (equals): In the overload for qualified_type_def
and reference_type_de, report local type changes of the underlying
type as local changes. Add comments in the overload for pointer
type, and make it look like the the overload for reference_type.
* src/abg-leaf-reporter.cc (leaf_reporter::report): In the
overload for pointer_diff, remove end of line.
* tests/data/test-diff-filter/libtest45-basic-type-change-report-1.txt: Adjust.
* tests/data/test-diff-filter/test30-pr18904-rvalueref-report0.txt: Likewise.
* tests/data/test-diff-filter/test30-pr18904-rvalueref-report1.txt: Likewise.
* tests/data/test-diff-filter/test30-pr18904-rvalueref-report2.txt: Likewise.
* tests/data/test-diff-filter/test35-pr18754-no-added-syms-report-0.txt: Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
For some fine grain redundancy filtering, we need to know when a diff
node carries *only* a basic type change. This is because basic type
changes should not be marked as redundant; we want to see all of them
-- unlike for class or union (user defined) type changes.
And so to know if a diff node carries only a basic type change, we
need to know if a diff node only carries a local type change. If it
carries only a type change, we can safely just look at that type
change and see if it's a basic type change or not.
So, we then need to know what kind of local changes a diff node
carries: type change or non-type change. That way, we can analyze the
local changes a node carries and infer that it only carries a local
type change or if it also carries a non-type change.
This patch thus changes the diff::has_local_changes() pure virtual member
function to make it return the enum change_kind bitmask, which
describes the different kinds of local changes the diff node has.
Note that two new bit values were added to that enum:
LOCAL_TYPE_CHANGE_KIND and LOCAL_NON_TYPE_CHANGE_KIND. The first one
says that the diff node carries a local type change, while the second
one says that the diff node carries a local non-type change kind.
The various implementations of that interface are thus amended to make
them return the right bitmask. To do this, the patch updates the
various 'equals' overloads to make them return the proper enum
change_kind bitmap with the LOCAL_TYPE_CHANGE_KIND and
LOCAL_NON_TYPE_CHANGE_KIND set, if need be.
* include/abg-comparison.h ({diff, type_diff_base, decl_diff_base,
distinct_diff, var_diff, pointer_diff, reference_diff, array_diff,
qualified_type, enum_diff, class_or_union_diff, class_diff,
base_diff, scope_diff, fn_parm_diff, function_type_diff,
function_decl_diff, typedef_diff,
translation_unit_diff}::has_local_changes): Return an enum
change_kind, rather than just a bool.
(is_diff_of_basic_type): Declare an overload that takes a boolean
flag.
(is_qualified_type_diff, peel_pointer_diff, peel_reference_diff)
(peel_qualified_type, peel_pointer_or_qualified_type): Declare new
functions
* include/abg-fwd.h (peel_qualified_type):
* include/abg-ir.h (enum change_kind::{LOCAL_TYPE_CHANGE_KIND,
LOCAL_NON_TYPE_CHANGE_KIND, ALL_LOCAL_CHANGES_MASK}): Add these
three new enumerators.
* src/abg-comparison.cc ({distinct_diff, var_diff, pointer_diff,
array_diff, reference_diff, qualified_type_diff, enum_diff,
class_or_union_diff, class_diff, base_diff, scope_diff,
fn_parm_diff, function_type_diff, function_decl_diff,
type_decl_diff, typedef_diff,
translation_unit_diff}::has_local_changes): Adjust to return an
enum change_kind, rather than just a bool.
(has_local_type_change_only): Define new functions.
(has_basic_type_change_only): Use the new
has_local_type_change_only function and the new overload for
is_diff_of_basic_type.
(is_diff_of_basic_type): Define an overload that takes a boolean
flag.
(is_qualified_type_diff, peel_pointer_diff, peel_reference_diff)
(peel_qualified_type, peel_pointer_or_qualified_type): Define new
functions.
* src/abg-ir.cc (equals): In the overloads for decl_base,
scope_decl, type_base, qualified_type_diff, pointer_type_def,
reference_type_def, array_type_def, enum_type_decl, typedef_decl,
var_decl, function_type, function_decl, function_decl::parameter,
class_or_union, class_decl::base_spec and class_decl, properly set
the new abigail::ir::{LOCAL_CHANGE_KIND,
LOCAL_NON_TYPE_CHANGE_KIND, LOCAL_TYPE_CHANGE_KIND} bits.
(types_have_similar_structure): Peel qualified types and typedefs
off, first thing.
(peel_qualified_or_typedef_type): Define new function.
* tests/data/test-diff-pkg/spice-server-0.12.4-19.el7.x86_64-0.12.8-1.el7.x86_64-report-3.txt:
Adjust.
* tests/data/test-diff-filter/libtest45-basic-type-change-report-{0,1}.txt:
New reference test reports.
* tests/data/test-diff-filter/libtest45-basic-type-change-v{0,1}.so:
New input test binaries.
* tests/data/test-diff-filter/test45-basic-type-change-v{0,1}.cc:
Source code of the input test binaries above.
* tests/data/Makefile.am: Add the new test file above to source
distribution.
* tests/test-diff-filter.cc: Add the test input above to the test
harness.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
For variables and data member, we are quite gross in the way we detect
a local type change. Basically, if a textual representation of the
variable (and thus of its type) changes, then we consider that the
variable has a local (possibly type) change.
This leads us to (wrongly) report changes like this:
'struct S1 at test-44-anonymous-data-member-v0.c:1:1' changed:
type size hasn't changed
there are data member changes:
anonymous data member at offset 32 (in bits) changed from:
union {int b; float c;}
to:
union {int b; float c; char e;}
Here, you see that the textual representation of the anonymous data
member (of union type) changed from:
union {int b; float c;}
to:
union {int b; float c; char e;}
You see that although the textual representation of the type changed,
the *structure* of the type hasn't really changed. I am using the
"vague" term structure, on purpose. Here, in the case of a union, the
structure hasn't change because the size of the union hasn't changed.
This patch thus introduces the concept of "similarity of type
structures". That is, even if two types are different, if "their
structure is similar", then the type change is not a local type
change.
More precisely, here is what we mean by type similarity:
Two indirect types (pointers, references) have similar structure
if their underlying types are of the same kind and have the same
name. In this indirect types case, the size of the underlying
type does not matter.
Two direct types (i.e, non indirect) have a similar structure if
they have the same kind, name and size. Two class types have
similar structure if they have the same name, size, and if their
data members have similar types.
This patch then uses that similarity concept to detect local type
changes.
* include/abg-fwd.h (is_type_decl): Declare new overload for
type_base*.
(types_have_similar_structure): Declare new function.
* src/abg-comparison.cc
(class_or_union_diff::priv::count_filtered_changed_dm): Even when
looking at local changes only, do not forget to count nodes that
were filtered out.
* src/abg-ir.cc (types_have_similar_structure): Define new
function.
(is_type_decl): Define new overload for
type_base*.
(is_enum_type):
(equals): In the overload for var_decl, use the new
types_have_similar_structure function to detect local (type)
changes.
* src/abg-reporter-priv.cc (represent): In the overload for
var_decl, use the diff::has_local_changes function to detect local
changes, now that we can better detect local changes.
* tests/data/test-diff-filter/test44-anonymous-data-member-report-1.txt:
Adjust.
* tests/data/test-diff-suppr/test36-leaf-report-0.txt: Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
It doesn't make sense to report about I leaf diff nodes that are
either references, arrays of function parameters. It makes more sense
to have these be reported as part of their containing diff nodes.
This patch fixes that.
* src/abg-comparison.cc
(leaf_diff_node_marker_visitor::visit_begin): Do not mark
references, array and fn parms diff nodes as leaf nodes.
* tests/data/test-diff-pkg/spice-server-0.12.4-19.el7.x86_64-0.12.8-1.el7.x86_64-report-3.txt:
Adjust.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
It turns out that the "rpm -qp --provides <rpm>" can issue an error on
el6 (on the RPMs that we feed it) and still provide us with the output
we want. So we shouldn't just fail in that case.
This patch handles that case.
* src/abg-tools-utils.cc (get_dsos_provided_by_rpm): Do not fail
when the rpm command issues an error. Rather rely on the presence
of a valid output or not. Also, make sure to filter out error
outputs so that they don't appear in the general output of tools
using this function.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
If no python2 interpreter is found and only a python3 one is found,
then use that one rather than just bailing.
* configure.ac: When no python2 is found and only python3 is
found, then use python3.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* configure.ac: Make the PYTHON environemnt variable usable in
auto-generated files.
* tests/runtestdefaultsupprs.py.in: Use the python interpreter
detected by configure.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
When doing the Koji version tests at configure time, use the version
of the python interpreter that was selected by configure, not the one
first (randomly) found in the current PATH.
* configure.ac: Use the python interpreter that was selected by
the configure script for the Koji version test.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
It turned out we were not sorting the output of the leaf report. This
patch fixes that.
* include/abg-comparison.h (diff_ptrs_type): Define new typedef.
* src/abg-comparison-priv.h (sort_string_diff_ptr_map): Declare
new function.
* src/abg-comparison.cc (sort_string_diff_sptr_map): Update
comment.
(sort_string_diff_ptr_map): Define new function.
* src/abg-leaf-reporter.cc (report_diffs): Sort the diff nodes
before reporting about them.
* tests/data/test-diff-suppr/test36-leaf-report-0.txt: Adjust.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
I forgot to express data members in bytes (if the user wants it) when
the feature got initially baked. This patch fixes it.
* src/abg-reporter-priv.cc (represent): In the overload for
var_diff_sptr, use the function show_offset_or_size, rather than
emit_num_value.
* tests/data/test-diff-filter/test31-pr18535-libstdc++-report-0.txt: Adjust.
* tests/data/test-diff-filter/test31-pr18535-libstdc++-report-1.txt: Adjust.
* tests/data/test-diff-filter/test44-anonymous-data-member-report-0.txt: Adjust.
* tests/data/test-diff-filter/test44-anonymous-data-member-report-1.txt: Adjust.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
An anonymous data member is a data member of a struct or a union which
has no name. The type of such data member is either a struct or a
union. For instance:
struct foo {
int a;
struct { // <-- this is an anonymous data member
char a;
char b;
};
int c;
};
In DWARF (as emitted by GCC at least), an anonymous data member is
represented as a data member with an empty name. Libabigail sees it
just fine, but then when representing *changes* to that kind of data
member, it needs special treatment, otherwise users cannot make sense
of the reports.
This patch adds initial support to represent changes to anonymous data
members.
* include/abg-comparison.h (is_class_or_union_diff)
(is_anonymous_class_or_union_diff): Declare new functions.
* include/abg-fwd.h (is_class_type): Declare new overload for
type_or_decl_base&.
(is_data_member): Declare new overload for decl_base*.
(is_anonymous_data_member)
(anonymous_data_member_to_class_or_union)
(get_class_or_union_flat_representation)
(data_member_has_anonymous_type): Declare new functions.
(is_at_class_scope): Return the class or union scope.
* include/abg-ir.h (var_decl::get_qualified_name): New virtual
data member which overloads decl_base::get_qualified_name.
* src/abg-comparison.cc (is_class_or_union_diff)
(is_anonymous_class_or_union_diff): Define new functions
(leaf_diff_node_marker_visitor::visit_begin): Don't mark anonymous
class or union diff nodes as diff nodes.
* src/abg-ir.cc (is_data_member): Define new overload for
decl_base*.
(is_class_type, is_union_type): Define new overload for type_or_decl_base&.
(is_anonymous_data_member)
(anonymous_data_member_to_class_or_union)
(get_class_or_union_flat_representation)
(data_member_has_anonymous_type): Define new function overloads.
(var_decl::get_qualified_name): Define new virtual member
function.
(is_at_class_scope): Return the class or union scope.
(var_decl::get_pretty_representation): Support anonymous data
members.
(equals): In the overload for class_or_union_diff, mark data
member textual representation changes as local changes.
* src/abg-reporter-priv.cc (represent): In the overload for
var_diff, support changes to anonymous data members.
* src/abg-leaf-reporter.cc (leaf_reporter::report): Report sorted
-- by offset -- data member changes before the ones that are
sorted by other things.
* tests/data/test-diff-filter/libtest44-anonymous-data-member-v{0,1}.so:
New binary test input
* tests/data/test-diff-filter/test44-anonymous-data-member-report-{0,1}.txt:
New reference test outputs.
* tests/data/test-diff-filter/test44-anonymous-data-member-v{0,1}.c:
Source code of the new binary test output above.
* tests/data/Makefile.am: Add the new test files above to the
source distribution.
* tests/data/test-annotate/libtest23.so.abi: Adjust test reference
output.
* 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/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-diff-dwarf/test43-PR22913-report-0.txt: Likewise.
* tests/data/test-diff-filter/test30-pr18904-rvalueref-report0.txt: Likewise.
* tests/data/test-diff-filter/test30-pr18904-rvalueref-report1.txt: Likewise.
* tests/data/test-diff-filter/test30-pr18904-rvalueref-report2.txt: Likewise.
* tests/data/test-diff-filter/test31-pr18535-libstdc++-report-0.txt: Likewise.
* tests/data/test-diff-filter/test31-pr18535-libstdc++-report-1.txt: Likewise.
* tests/data/test-diff-filter/test35-pr18754-no-added-syms-report-0.txt: Likewise.
* tests/data/test-diff-pkg/libcdio-0.94-1.fc26.x86_64--libcdio-0.94-2.fc26.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.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
When switching to a more recent automake version on EL7, I realized
that @top_builddir@ wasn't being resolved to an absolute path anymore,
leading to errors when tests/runtestdefaultsupprs.py wasn't being run
in the "right" directory. This is annoying.
So this patches uses the absolute build path, explicitely.
* tests/runtestdefaultsupprs.py.in: Use abs_top_builddir rather
than top_builddir.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* src/abg-ini.cc (trim_white_space): Use std::string::substr
instead of appending single chars.
Signed-off-by: Jonathan Wakely <jwakely@redhat.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Trailing implies only whitespace at the end is removed, but these
functions also remove leading whitespace.
* include/abg-tools-utils.h (trim_white_space): Renamed
remove_trailing_white_spaces into this.
* src/abg-ini.cc (trim_white_space): Likewise.
* src/abg-tools-utils.cc (get_dsos_provided_by_rpm): Adjust.
Signed-off-by: Jonathan Wakely <jwakely@redhat.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Calling assert(split_string(...)) won't do anything when NDEBUG is
defined, but the split_string call can be avoided anyway.
Since only the first result from the split string is needed, and
remove_trailing_white_spaces will trim white space anyway, the overhead
of parsing it into a vector can be avoided by using std::string::substr
directly. Additionally, calling std::string::find with a single char is
more efficient than with a string.
* src/abg-tools-utils.cc (get_dsos_provided_by_rpm): Fix
std::string::sbustr and remove assert with side effect.
Signed-off-by: Jonathan Wakely <jwakely@redhat.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
In leaf mode we always show redundant changes, by construction. So
this program should not mess with that.
This patch is part of the set of patches whose titles are:
Do not show decl-only-to-def changes in the leaf reporter
Overhaul of the report diff stats summary
Do not mark "distinct" diff nodes as being redundant
Fix meaning of "harmless name change" to avoid overfiltering
Better handle category propagation of pointer changes
Improve function changes reporting in leaf and default mode
Don't filter out typedef changes with redundant underlying type changes
Only show leaf type changes in the leaf type changes section
Fix leaf report of class data member changes
Always show redundant changes in leaf mode
Avoid reporting an enum change if it has already been reported
When we say an a change was reported earlier give its source location
[abipkgdiff]: in leaf mode we always show redundant changes
Update tests for the "better leaf mode redundancy management" patchset
* tools/abipkgdiff.cc (set_diff_context_from_opts):
diff_context::show_leaf_changes_only automatically makes us show
redundant changes. So do not try to show redundant changes in
that case.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>