GCC can generate several DW_TAG_unspecified_parameters for a given
function. Abigail's DWARF reader is recklessly creating a variadic
function parameter in its internal representation (IR) each time it
sees a DW_TAG_unspecified_parameters. This leads to functions having
several variadic parameters in the final IR. And this is wrong.
This patch fixes the problem by creating a variadic parameter only for
the first DW_TAG_unspecified_parameters encountered for a given
function DIE.
* src/abg-dwarf-reader.cc (build_function_type): Create a variadic
parameter just for the first DW_TAG_unspecified_parameters seen.
* tests/data/test-diff-filter/test30-pr18904-rvalueref-report0.txt: Adjust.
* tests/data/test-diff-filter/test30-pr18904-rvalueref-report1.txt: Adjust.
* tests/data/test-read-dwarf/test16-pr18904.so.abi: Adjust.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
This fixes Bug 20329 - DW_TAG_const_type with no DW_AT_type not recognized as "const void".
It appears that GCC sometimes emits "const void" types by emitting a
const type DIE with no type attribute. The DWARF reader didn't
recognize that construct as a qualified void type.
This patch teaches the DWARF reader to recognize that construct.
It also appears that "const void" and "void" are equivalent and can be
emitted interchangeably by compilers (Intel and GCC) in their debug
info. That can lead to spurious ABI change reports saying that a type
"const void" was changed into a "void" type.
This patch transforms an occurrence of "const void" type into a "void"
type in the internal representation when reading DWARF. This does
away with the spurious change that appears when comparing selected
binaries emitted with the intel against binaries emitted with GCC.
* include/abg-ir.h (environment::is_void_type): Declare new member
function.
* src/abg-ir.cc (environment::is_void_type): Define new member
function.
* src/abg-dwarf-reader.cc (maybe_strip_qualification): Strip const
qualifier from const void.
* tests/data/test-diff-filter/test34-libjemalloc.so.2-gcc-6.1.0:
New test input.
* tests/data/test-diff-filter/test34-libjemalloc.so.2-intel-16.0.3: Likewise.
* tests/data/test-diff-filter/test34-report-0.txt: New reference output.
* tests/data/Makefile.am: Add the new files above to the source
distribution.
* tests/test-diff-filter.cc (in_out_specs): Compare the two new
binaries above.
* tests/data/test-diff-filter/test30-pr18904-rvalueref-report0.txt: Adjust.
* tests/data/test-diff-filter/test30-pr18904-rvalueref-report1.txt: Adjust.
* tests/data/test-diff-pkg/tbb-4.1-9.20130314.fc22.x86_64--tbb-4.3-3.20141204.fc23.x86_64-report-0.txt: Adjust.
* tests/data/test-diff-pkg/tbb-4.1-9.20130314.fc22.x86_64--tbb-4.3-3.20141204.fc23.x86_64-report-1.txt: Adjust.
* tests/data/test-read-dwarf/test1.abi: Adjust.
* tests/data/test-read-dwarf/test10-pr18818-gcc.so.abi: Adjust.
* tests/data/test-read-dwarf/test11-pr18828.so.abi: Adjust.
* tests/data/test-read-dwarf/test12-pr18844.so.abi: Adjust.
* tests/data/test-read-dwarf/test13-pr18894.so.abi: Adjust.
* tests/data/test-read-dwarf/test14-pr18893.so.abi: Adjust.
* tests/data/test-read-dwarf/test15-pr18892.so.abi: Adjust.
* tests/data/test-read-dwarf/test16-pr18904.so.abi: Adjust.
* tests/data/test-read-dwarf/test17-pr19027.so.abi: Adjust.
* tests/data/test-read-dwarf/test18-pr19037-libvtkRenderingLIC-6.1.so.abi: Adjust.
* tests/data/test-read-dwarf/test19-pr19023-libtcmalloc_and_profiler.so.abi: Adjust.
* tests/data/test-read-dwarf/test20-pr19025-libvtkParallelCore-6.1.so.abi: Adjust.
* tests/data/test-read-dwarf/test21-pr19092.so.abi: Adjust.
* tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi: Adjust.
* tests/data/test-read-dwarf/test9-pr18818-clang.so.abi: Adjust.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
This patch makes the DWARF reader recognize a "void" type expressed as
a DW_TAG_base_type of size zero and named "void".
* src/abg-dwarf-reader.cc (build_type_decl): Recognize a
DW_TAG_base_type of size zero and of name "void" as a void
type.
* tests/data/test-diff-filter/test33-libelf.so.0.8.13-gcc: New
binary test input.
* tests/data/test-diff-filter/test33-libelf.so.0.8.13-intel16.0.3: Likewise.
* tests/data/test-diff-filter/test33-report-0.txt: New reference output.
* tests/data/Makefile.am: Add the new files above to source
distribution.
* tests/test-diff-filter.cc (in_out_specs): Make this test harness
run over the new test inputs above.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
While working on something else, it appeared that I needed an overload
for is_type_decl that takes a shared pointer to decl_base. The
current is_type_decl takes a shared opinter to type_base.
This patch also updates some code that unnecessarily calls
is_type_decl.
* include/abg-fwd.h (is_type_decl): Declare a new overload
* src/abg-ir.cc (is_type_decl): Define a new overload.
(function_decl::parameter::get_pretty_representation): Adjust.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
While looking at something else, I figured we should pass a smart
pointer parameter by reference in
read_context::push_decl_to_current_scope in the abixml reader.
* src/abg-reader.cc (read_context::push_decl_to_current_scope):
Pass the decl smart pointer by value.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Looking at the debug info of the libgo library (written in Go) it
appears that there can be for instance a public type "int" which is a
4 bytes long in a translation unit, and another type named "int" as
well, and which is 8 bytes long. Having this in C++ is illegal as per
the One Definition Rule (ODR). And generally, in C, we don't have
this either even if C doesn't have an ODR.
Abigail uses the ODR to speed-up type canonicalization. So in cases
where two "int" types (of different sizes) are considered equal
because they have the same name and are in the same binary we end up
with inconsistencies that make comparison tools emit wrong reports.
This patch thus performs the ODR-based optimization only for C and C++
translation units.
Note that while working on this, I noticed that we were not setting
the translation unit of a certain number of ABI artifacts correctly.
This patch fixes that too. We need to set the translation unit of all
ABI artifacts because to get the language of the translation union of
an ABI artifact, we need to get its translation unit first.
* src/abg-ir.cc (strip_typedef): Set the translation unit of the
new ABI artifact.
(type_base::get_canonical_type_for): Perform the ODR-based
optimization only for ABI artifact in C and C++ language
translation units.
* src/abg-dwarf-reader.cc (build_ir_node_from_die): Assert that
the new ABI artifact has its translation unit set.
* src/abg-reader.cc (read_context::{push_decl_to_current_scope,
push_and_key_type_decl}): Set the translation unit of the current
decl, irrespective of if it was added to the current scope or not.
Assert that the decl that was newly pushed to the current scope is
added to the current translation unit.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
While looking at something else, I noticed some spots that need
cleanup with respect to white space or comments. This patch does just
that. No big deal.
* include/abg-ir.h (typedef type_or_decl_base): Cleanup comment.
* src/abg-ir.cc (struct type_or_decl_base::priv): Fix comment.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Simplify the logic of function_decl::parameter::get_pretty_representation.
* src/abg-ir.cc
(function_decl::parameter::get_pretty_representation): Assert that
the environment is always non-nil. Then no needs to check for it
being non-nil anymore. Use is_type_decl instead of
dynamic_pointer_cast.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
It turns out that when parsing foo = bar\[a-z\], the '[' and ']'
characters where not being escaped while parsing the string
"bar\[a-z\]".
This patch fixes that.
* src/abg-ini.cc (read_context::peek): Take an output parameter to
tell the caller when this function escaped the returned
character. Added an overload without this new parameter.
(read_context::read_string): Accept all characters as part of the
string.
* tests/data/test-diff-suppr/test7-var-suppr-9.suppr: New test
input.
* tests/data/test-diff-suppr/test7-var-suppr-report-9.txt: New
test reference output.
* tests/data/Makefile.am: Add the files above to source
distribution.
* tests/test-diff-suppr.cc (in_out_spec): Run a new comparison of
libtest7-var-suppr-v{0,1}.so this time using the new
test7-var-suppr-9.suppr specification that exercices a string with
the escaped characters that we were having difficulty with.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
When we need to get the version of a defined symbol, only the
SHT_GNU_versym and SHT_GNU_verdef sections are necessary.
SHT_GNU_verneed is not necessary, for instance.
So do not require that all of the three version-related sections to be
present when we want to get some symbol version information.
Otherwise, we just don't get the version of a defined symbol when the
SHT_GNU_verneed section is not present. I stumbled upon this while
looking the abidw's output of ld-2.17.so from
glibc-2.17-79.el7_1.x86_64. The _rtld_global_ro variable's symbol was
being seen as having no symbol version. In reality it has the
GLIBC_PRIVATE version, but because the binary lacks a SHT_GNU_verneed
section, we were not getting the symbols version information.
I am not adding that library to the test suite because it's too big.
But at least this change doesn't break the existing regression test
suite.
* src/abg-dwarf-reader.cc (get_symbol_versionning_sections): Allow
returning just some of the three version-related section, not
necessarily all of them. Adjust comment.
(get_version_for_symbol): Be ready to not necessarily having the
three version-related sections available.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
This patch adds support for loading system and user level suppression
specifications for libabigail tools.
At launch time, relevant libabigail tools (abidiff, abipkgdiff
fedabipkgdiff for now) read the default system suppression
specification file, if it's present, from a file which path is the
value of the environment variable
LIBABIGAIL_DEFAULT_SYSTEM_SUPPRESSION_FILE, if set, or from the file
$libdir/libabigail/default.abignore.
Then it reads the user system suppression specification file, if it's
present, from a file which path is the value of the environment
variable LIBABIGAIL_DEFAULT_USER_SUPPRESSION_FILE, if set, or from the
file $HOME/.abignore.
The content of the user system suppression file is merged with the
content of default system suppression file.
That content is also merged with the content of the suppression
specification files that might be provided by the --suppressions
command line option of the invoked tools.
The resulting set of all these suppression specifications is thus used
to filter the ABI change reports that are emitted.
abidiff, abipkgdiff and abipkgdiff gain a --no-default-suppression
option to avoid loading any of these default suppression specification
files.
The patch also installs a default.abignore file into $(pkglibdir).
Note that on x86_64, that directory is /usr/lib64/libabigail. Now we
just need to think about the content of that default.abignore file.
* doc/manuals/abidiff.rst: Document the default suppression
scheme, its interaction with the --supprs option and the new
--no-default option.
* doc/manuals/abipkgdiff.rst: Likewise.
* doc/manuals/fedabipkgdiff.rst: Likewise.
* configure.ac: Generate the tests/runtestdefaultsupprs.py file
from the new tests/runtestdefaultsupprs.py.in template.
* default.abignore: New file.
* Makefile.am: Add it to source distribution.
* src/Makefile.am: Define the ABIGAIL_ROOT_SYSTEM_LIBDIR
preprocessor macro that is set the value of the $libdir autotools
macro.
* include/abg-tools-utils.h: Update copyright years.
(get_system_libdir, get_default_system_suppression_file_path)
(get_default_user_suppression_file_path)
(load_default_system_suppressions)
(load_default_user_suppressions): Declare new functions
* src/abg-tools-utils.cc (get_system_libdir)
(get_default_system_suppression_file_path)
(get_default_user_suppression_file_path)
(load_default_system_suppressions)
(load_default_user_suppressions): Define new functions.
(is_regular_file): Amend this so that it return true for symlinks
to regular files too.
(is_dir): Amend this so that it returns true for symlinks to
directories too.
* tools/abidiff.cc (options::no_default_supprs): New data member.
(options::options): Initialize the new data member.
(display_usage): Display a new help string for the new
--no-default-suppression command line option.
(parse_command_line): Parse this new command line option.
(set_diff_context_from_opts): Load the default suppression
specifications, unless --no-default-suppression or --supprs was
provided.
* tools/abipkgdiff.cc (options::no_default_supprs): New data
member.
(options::options): Initialize the new data member.
(parse_command_line): Parse the new --no-default-suppression
command line option.
(main): Load the default suppression specifications, unless
--no-default-suppression or --supprs was provided.
* tools/fedabipkgdiff (abipkgdiff): Add --no-default-suppression
to the invocation of abipkgdiff if it was provided on the command
line.
(build_commandline_args_parser): Parse the new
--no-default-suppression command line option.
* tests/runtestdefaultsupprs.py.in: New test harness template.
* tests/Makefile.am: Add the new runtestdefaultsupprs.py to the
set of tests.
* tests/data/test-default-supprs/test0-type-suppr-0.suppr: New
test input.
* tests/data/test-default-supprs/test0-type-suppr-report-0.txt: Likewise.
* tests/data/test-default-supprs/test0-type-suppr-v0.o: Likewise.
* tests/data/test-default-supprs/test0-type-suppr-v1.o: Likewise.
* tests/data/test-default-supprs/dirpkg-1-dir-report-0.txt:
Likewise.
* tests/data/test-default-supprs/dirpkg-1-dir1: Likewise.
* tests/data/test-default-supprs/dirpkg-1-dir2: Likewise.
* tests/data/Makefile.am: Add new the new tests input above to
Makefile.am.
* tests/runtestcanonicalizetypes.sh.in: Pass
--no-default-suppression to abidiff invocations.
* tests/runtestdefaultsupprs.py.in: Likewise.
* tests/test-abidiff-exit.cc: Likewise.
* tests/test-diff-dwarf-abixml.cc: Likewise.
* tests/test-diff-filter.cc: Likewise.
* tests/test-diff-suppr.cc: Likewise.
* tools/abidiff.cc: Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
This is to address the following enhancement requests:
#19588 - Add a --headers-dir1 and --headers-dir2 option to abidiff
#19948 - Add --devel-pkg1 and --devel-pkg2 options to abipkgdiff
When the user specifies where to find header files for two binaries
(or packages) being compared, this patch generates a type suppression
specification that filters out change reports about types that are
defined in files that are not in the set of header files specified.
The type suppression specification also suppresses change reports
about changed/added/removed virtual member functions which enclosing
class type matches the type suppression specification.
There is a corner case that the patch handles too, and that is
exhibited by the accompanying test case for abidiff. There can be a
class defined by DWARF as having no source location and as being a
pure declaration. This can be a class declaration that has inline
virtual members only, and one or several non-defined virtual methods
too. When that declaration is included in a source file, GCC
generates debug info that describes that class as being a
declaration-only class with no source declaration. This patch
considers such a class as being non defined; you know, like a true
opaque type. So it's considered being not defined in any public
header file. Changes to this kind of class are thus filtered out.
* include/abg-comp-filter.h: Update copyright year.
* src/abg-comp-filter.cc (has_virtual_mem_fn_change): Make this
static function become exported.
(has_virtual_mem_fn_change): Declare new function.
* include/abg-suppression.h
(suppression_base::{get,set}_is_artificial): Declare new
accessors.
(type_suppression::get_source_locations_to_keep): Return an
unordered set of strings, not a vector. Add a non-const overload.
(type_suppression::set_source_locations_to_keep): Set an unordered
set of strings, not a vector.
* src/abg-suppression.cc (suppression_base::priv::is_artificial_):
New data member.
(suppression_base::priv::priv): Initialize the new data member.
(suppression_base::{get,set}_is_artificial): Define new accessors.
(type_suppression::priv::source_locations_to_keep_): Change the
vector of strings representing source file names into unordered
set of string.
(type_suppression::get_source_locations_to_keep): Return an
unordered set of strings, not a vector. Define a non-const
overload.
(type_suppression::set_source_locations_to_keep): Set an unordered
set of strings, not a vector.
(type_suppression::suppresses_diff): Make this suppress virtual
member function diffs if the enclosing type of the changed virtual
member is suppressed by the current type_suppression.
(read_type_suppression): Adjust to use the fact that the source
locations are not stored in an unordered set, not in a vector
anymore. Otherwise, using a vector here make things too slow.
(type_suppression::suppresses_type): Likewise. Also, If the type
we are looking at has no location because it's a true opaque type
and if the current suppression is an artificial suppression that
is meant to suppress change reports about non-public types, then
suppress the type.
* include/abg-tools-utils.h (gen_suppr_spec_from_headers): Declare
new public function.
* src/abg-tools-utils.cc (PRIVATE_TYPES_SUPPR_SPEC_NAME): Define a
new constant variable.
(handle_fts_entry): Define new static function.
(gen_suppr_spec_from_headers): Define new public function.
* src/abg-comparison.cc
(corpus_diff::priv::apply_suppressions_to_added_removed_fns_vars):
If a type suppression suppresses a given class C, make it change
added/removed virtual functions whose enclosing type is C.
* tools/abidiff.cc (options::{headers_dir1, headers_dir2}): New
data members.
(display_usage): Add help strings for --headers-dir1 and
--headers-dir2.
(parse_command_line): Parse the new --headers-dir1 and
--headers-dir2 options.
(set_diff_context_from_opts): Generate suppression specifications
to filter out changes on private types, if --headers-dir1 or
--headers-dir2 is given.
* tools/abipkgdiff.cc (options::{devel_package1, devel_package2}):
New data members.
(typedef package_sptr): New typedef.
(enum package::kind): New enum.
(package::kind_): New data member. This replaces ...
(package::is_debug_info_): ... this data member.
(package::{devel_package_, private_types_suppressions_}): New data
members.
(package::package): Adjust.
(package::get_kind): Define new member function. This replaces
...
(package::is_debug_info): ... this member function overload.
(package::set_kind): Define new member functin. It replaces ...
(package::is_debug_info): ... this member function overload.
(package::{devel_package, private_types_suppressions}): Define new
accessors.
(package::erase_extraction_directies): Erase the sub-directory
where development packages are extracted to.
(compare_args::private_types_suppr{1,2}): New data members.
(compare_args::compare_args): Adjust.
(display_usage): Add help strings for --devel-pkg1/--devel-pkg2.
(compare): Make the overload that compares elf files take private
types suppressions. Add the private types suppressions to the
diff context.
(pthread_routine_compare): Adjust the call to compare.
(maybe_create_private_types_suppressions): Define new static
function.
(pthread_routine_extract_pkg_and_map_its_content): If a devel
package was specified for the main package then extract it in
parallel with the other package extraction. When the extraction
is done, create private types suppressions by visiting the
directories that contain the header files.
(compare): In the overload that compares packages by scheduling
comparison of individual elf files that are in the packages, pass
in the private type suppressions too.
(parse_command_line): Parse the new --devel-pkg{1,2} command line
options.
(main): Associate the devel package to the main package, if the
--devel-pkg{1,2}.
* doc/manuals/abidiff.rst: Add documentation about the new
--headers-dir1 and --headers-dir2 options.
* doc/manuals/abipkgdiff.rst: Likewise, add documentation about
the new --devel-pkg1 and --devel-pkg2 libraries.
* tests/data/test-diff-pkg/tbb-4.1-9.20130314.fc22.x86_64--tbb-4.3-3.20141204.fc23.x86_64-report-1.txt:
New test reference output.
* tests/data/test-diff-pkg/tbb-devel-4.1-9.20130314.fc22.x86_64.rpm:
New test input package.
* tests/data/test-diff-pkg/tbb-devel-4.3-3.20141204.fc23.x86_64.rpm: Likewise.
* tests/test-diff-pkg.cc b/tests/test-diff-pkg.cc
(InOutSpec::{first,second}_in_devel_package_path): New data
members.
(in_out_specs): Adjust. Also, add a new entry describing the new
test inputs above.
(test_task::perform): When the new test entry contains devel
packages, pass them to abipkgdiff using the --devel1 and --devel2
options.
* tests/data/test-diff-suppr/test30-include-dir-v0/test30-pub-lib-v0.h:
A new test input source code.
* tests/data/test-diff-suppr/test30-include-dir-v1/test30-pub-lib-v1.h: Likewise.
* tests/data/test-diff-suppr/test30-priv-lib-v0.cc: Likewise.
* tests/data/test-diff-suppr/test30-priv-lib-v0.h: Likewise.
* tests/data/test-diff-suppr/test30-priv-lib-v1.cc: Likewise.
* tests/data/test-diff-suppr/test30-priv-lib-v1.h: Likewise.
* tests/data/test-diff-suppr/test30-pub-lib-v0.cc: Likewise.
* tests/data/test-diff-suppr/test30-pub-lib-v0.so: Add new test
binary input.
* tests/data/test-diff-suppr/test30-pub-lib-v1.cc: Add new test
input source code.
* tests/data/test-diff-suppr/test30-pub-lib-v1.so: Add new test
binary input.
* tests/data/test-diff-suppr/test30-report-0.txt: Add new test
reference output.
* tests/data/test-diff-suppr/test30-report-1.txt: Add new test
reference output.
* tests/test-diff-suppr.cc (InOutSpec::headers_dir{1,2}): New data
members.
(InOutSpec::abidiff_options): Renamed the bidiff_options data
member into this.
(in_out_specs): Adjust. Also, added the new test input above to
this.
(main): Adjust to invoke abidiff with the new --hd1 and --hd2
options if the input specs for the tests has the new
InOutSpec::headers_dir{1,2} data member set. Renamed bidiff into
abidiff.
* tests/data/Makefile.am: Add the new test inputs to the source
distribution.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Right now, the number of removed functions that is shown in the change
report is the total number of removed functions.
But it should be the *net* number of removed functions. That is, the
total number of removed functions minus the number of removed
functions that were filtered out.
This patch fixes that. A one liner.
* src/abg-suppression.cc (corpus_diff::report): Show the net
number of removed functions, not the total number of the removed
functions.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Profiling showed that getting the pointed-to type of a pointer type is
on the hot spot when comparing corpora with a lot of entry points with
a lot of pointer types reachable from the entry points of the corpora.
So avoid handling the shared_ptr to the pointed-to type for that case
can save us a few CPU cycles in a noticeable way.
This patch does this by creating a new
pointer_type_def::get_naked_pointed_to_type() (that returns a naked
pointer) to supplement the classic
pointer_type_def::get_pointer_to_type() function, and uses that in a
code spot that profiling revealed to be a critical path.
* include/abg-ir.h (pointer_type_def::get_naked_pointed_to_type):
Declare new member function.
* src/abg-ir.cc (pointer_type_def::priv::naked_pointed_to_type_):
New data member.
(pointer_type_def::priv::priv): Adjust to initialize the new data
member.
(pointer_type_def::pointer_type_def): Adjust to use the
constructor pointer_type_def::priv::priv to initialize the
pointed-to type (including its new naked pointer variant). So we
do not have to initialize the priv_->pointed_to_type_ explicitely
in the constructor anymore.
(pointer_type_def::get_naked_pointed_to_type): Define new data
member.
(pointer_type_def::get_qualified_name): Use a naked pointer to the
pointed-to type, rather than a smart pointer.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Profiling shows that some smart pointers were unnecessarily created
here and there, and that had a noticeable effect on performance, when
comparing two gtk3 packages.
This patch passes references to smart pointers in those cases.
* include/abg-fwd.h (get_type_name): Take a reference to type_sptr.
* src/abg-ir.cc (get_type_name): Take a reference to type_sptr.
(suppression_base::priv::{get_file_name_regex,
get_file_name_not_regex, get_soname_regex, get_soname_not_regex}):
Return a reference to regex_t_sptr.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Profiling showed that abigail::tools_utils::string_ends_with can be
quite a hot spot when evaluating suppression specifications that
involve file names in the source location of definition of files.
In that function, it appears that we were calling string::length
several times on the same strings. Calling it just once does make a
noticeable difference when type suppressions involving source
locations are evaluated against a lot of types.
This patch thus calls string::length in
abigail::tools_utils::string_ends_with just once.
* src/abg-tools-utils.cc (string_ends_with): Call string::length
just once on each instance of string that matters.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
When evaluating type suppression specifications, looking at the name
of the type can take a noticeable time, at least when the name of that
type is being queried for the first time.
Now that every single type involved in a change that might be reported
is involved in a type suppression evaluation (at least when operating
in the mode where the comparison tool is asked to filter out private
types), the evaluation of type suppression becomes a hot spot, at
least on relatively big diff graphs.
Luckily, private type suppression specifications don't involve the
name of the type, so we don't have to query the name of the type in
this case.
This patch makes it so that the type name is queried only when the
suppression specification requires it. It makes us save a few
noticeable CPU cycles when evaluating suppression specifications that
don't involve looking at the type name.
* src/abg-suppression.cc (type_suppression::suppresses_type): If
neither the type suppression "name" or "name_regex" properties
where provided in the suppression specification, then do not try
to look at the type name.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
On certain work loads, cycles in the tree of diffs of member variables
can appear. This because:
1/ each diff tree nodes holds a reference on each of its children
nodes
2/ each var_diff tree node holds a reference on the diff tree node
representing its type changes.
There can thus be reference cycles in involving diff the tree --> child
node relationship and the var_diff tree --> type diff tree
relationship.
This patch fixes the issue be make sure that a diff tree node does not
hold a reference on its children nodes. That is, rather than having a
vector of shared pointers to its children diff nodes, it has a vector
of naked pointers to those. The patch goes further by making sure
that a var_diff node does not hold a reference to its type diff node
either. It holds a weak pointer to the type diff node, rather than a
shared pointer.
The patch should be followed by a patch make sure that all kinds of
diff nodes follow this pattern; that is, if a diff node needs to carry
a sub-type diff node, it should do so by either using a naked pointer
to the sub-type diff node, or a weak pointer.
For now, the patch fixes the leaks reported by running all the tests
of the suite under Valgrind.
* include/abg-comparison.h (diff_wptr, unordered_diff_sptr_set): New typedefs.
(struct diff_sptr_hasher): Define new type.
(diff_context::keep_diff_alive): Declare new member function.
(diff::children_nodes): Return a vector of diff*, rather than a
vector of diff_sptr.
* src/abg-comparison.cc (diff_context::priv::live_diffs_): New
data member.
(diff_context::keep_diff_alive): Define new data member.
(diff::priv::children_): Make this be a vector of diff*, rather
than a vector of diff_sptr.
(diff_less_than_functor::operator()): Add a new overload for
diff*. Make the existing overload of diff_sptr use the new one.
(diff::children_nodes): Adjust;
(diff::append_child_node): Make sure the child node is kept
alive. Only add the naked pointer to the child node to the vector
of children.
(diff::traverse): Adjust.
(var_diff::priv::type_diff_): Make this be a weak pointer, rather
than a shared pointer.
(var_diff::type_diff): The var_diff::priv::type_diff_ data member
is now a weak pointer, so make this accessor convert it to a
shared pointer.
(corpus_diff::priv::children_): Turn this into a vector of diff*,
rather than a vector of diff_sptr.
(corpus_diff::children_nodes): Adjust.
(corpus_diff::append_child_node): Make sure the child node is kept
alive. Only add the naked pointer to the child node to the vector
of children.
(category_propagation_visitor::visit_end): Adjust.
(suppression_categorization_visitor::visit_end): Adjust.
(redundancy_marking_visitor::{visit_begin, visit_end}): Adjust.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Diff not chilrend nodes must remain sorted. Before this patch, this
was achieved by sorting the vector of children each time a new member
was inserted.
But profiling showed that doing that for corpus_diff nodes was
relatively slow on corpora with lots function/variable changes. At
least enough to become a hot spot.
This patch addresses that by inserting the new child at the right
point in the vector of children, for the vector to remain sorted.
* src/abg-comparison.cc (corpus_diff::append_child_node): Insert
the new child at the right point in the vector of children, so
that it remains sorted.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
On recent elfutils where the libdw's function dwarf_getalt exists, we
don't need to try and find the alternate debug info file ourselves by
using the function dwfl_standard_find_debuginfo. Furthermore, when we
use that function on those recent elfutils versions, we leak the elf
resources allocated in the debug info resources; we also leak the file
descriptor to access the alternate debug info sections.
More generally, we also leak debug info handles used to access debug
info when using get_soname_of_elf_file and get_type_of_elf_file.
This patch plugs those leaks.
In the first case, if the function dwarf_getalt exists, the patch just
uses it to get the alternate debug info. Otherwise, the patch uses
the dwfl_standard_find_debuginfo function like we used to, but then it
tries hard to free the file descriptor and debuginfo memory of the
alternate debug info.
* configure.ac: Check the presence of dwarf_getalt in libdw. If
it's present, define the preprocessor macro
LIBDW_HAS_DWARF_GETALT. Update the autoconf configuration
summary.
* src/abg-dwarf-reader.cc: Add config.h.
(find_alt_debug_info_location): Factorize this out of ...
(find_alt_debug_info): ... this function. Use dwarf_getalt if
present, otherwise, keep using dwfl_standard_find_debuginfo. In
the later case, return the file descriptor opened to access the
alternate debug info, by parameter, so that the caller can fclose
it.
(read_context::alt_fd_): New data member.
(read_context::read_context): Initialize the new alt_fd_ data
member.
(read_context::load_debug_info): Store the file descriptor used to
access the alternate debug info into the new alt_fd_ data member.
(read_context::~read_context): New desctructor.
(get_soname_of_elf_file, get_type_of_elf_file): Free the elf
handle.
(read_context::load_debug_info): Be paranoid in making sure we
never override alt_dwarf_.
* tests/data/test-alt-dwarf-file/test0-report.txt: Adjust.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Some time ago, a memory optimization was put in place to reduce the
memory usage of the IR used to represent the result of a comparison
between two corpora.
The principle of that optimization was to share the data of the
class_diff::priv member among instances of class_diff that are in the
same class of equivalence.
In practice, the class_diff::priv member of an instance that has a non
empty class of equivalence was set to the class_diff::priv of its
canonical type.
Because clas_diff::priv is a shared pointer, setting it to the
class_diff::priv of another instance was creating cycles in the graph
of class_diff, sometimes. And those cycles lead to memory leaks as
the reference count of shared pointers to class_diff would not go down
to zero anymore.
This patch fixes the problem of those cycles by not setting the
class_diff::priv data member. Rather, when a class_diff is part of a
non-empty class of equivalence, its class_diff::priv is left nil. A
new class_diff::get_priv() accessor is provided; it returns the shared
class_diff::priv of the canonical type when the current
class_diff::priv is nil; otherwise it just returns the current
class_diff::priv.
* include/abg-comparison.h (class_diff::get_priv): Declare new
member function.
(class_diff::get_priv): Define new member function.
(class_diff::{chain_into_hierarchy, base_changes, deleted_bases,
inserted_bases, changed_bases, base_changes, member_types_changes,
member_types_changes, data_members_changes, inserted_data_members,
deleted_data_members, member_fns_changes, changed_member_fns,
member_fns_changes, deleted_member_fns, inserted_member_fns,
member_fn_tmpls_changes, member_class_tmpls_changes,
member_class_tmpls_changes, report}): Rather than accessing
class_diff::priv directly, use the new class_diff::get_priv.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
It appears that there are cases where the data member
class_decl::priv::definition_of_declaration_ can point to the current
instance of class_decl, leading to a circular reference and thus a
leak because the reference count of the current instance of class_decl
will never reach zero.
This patch fixes that by making
class_decl::priv::definition_of_declaration_ be a weak pointer, rather
than a smart pointer.
* include/abg-ir.cc (class_decl::get_definition_of_declaration):
Return a shared pointer, rather than a reference to a shared pointer.
* src/abg-ir.cc (class_decl::priv::definition_of_declaration_):
Make this be a weak pointer.
(class_decl::get_definition_of_declaration):
Likewise. And return the shared pointer built out of the weak
pointer we have in there now.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
The suppression engine was not creating the shared pointer to
regex_t in the proper way that would correctly free the memory
allocated by the glibc's regcomp function.
This patch fixes that.
* include/abg-sptr-utils.h (build_sptr<T>): Declare an overload that
allocates a T* and wraps it into a shared_ptr<T>.
(build_sptr<regex_t>): Declare a specialization for regex_t.
* src/abg-corpus.cc (build_sptr<regex_t>()): Define the
specialization here.
* src/abg-suppression.ccp
(suppression_base::priv::{get_file_[not]_name_regex,
get_soname_[not]_regex}): Use the new build_sptr<regex_t>().
(type_suppression::priv::{get_type_name_regex,
get_source_location_to_keep_regex}): Likewise.
(function_suppression::parameter_spec::priv::get_type_name_regex):
Likewise.
(function_suppression::priv::{get_name_regex,
get_return_type_regex, get_symbol_name_regex,
get_symbol_version_regex}): Likewise.
(variable_suppression::priv::{get_name_regex,
get_symbol_name_regex, get_symbol_version_regex,
get_type_name_regex}): Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
After the function compute_diff is invoked to compute the diff against
to corpora, the reference count of the diff_context_sptr that it takes
get incremented several times.
So the diff_context_sptr is not automatically released (freed) when
its scope is left.
The reason why the reference count of diff_context_sptr is incremented
is because several diff types (the diff type itself or types extending
it) actually holds a reference to the diff_context_sptr they get
created with. So the lifetime of the diff_context_sptr becomes tied
to the lifetime the different diff objects in a hard-to-predict way.
It actually creates some cyclic references that, in this case, creates
a leak. The diff_context_sptr never gets released.
This patch fixes that by making the diff types hold a weak reference
to the diff_context_sptr they are created with.
* src/abg-comparison.cc (diff::priv::ctxt_): Make this a weak_ptr.
(diff::priv::get_context): Convert the weak pointer to the context
into a shared_ptr and return it.
(diff::priv::is_filtered_out): Adjust to use
diff::priv::get_context() to access the context.
(diff::context): Likewise.
(corpus_diff::priv::ctxt_): Make this a weak_ptr.
(corpus_diff::priv::priv): Add a new overload that takes two
corpora and a diff context.
(corpus_diff::priv::get_context): Convert the weak pointer to the
context into a shared_ptr and return it.
(corpus_diff::priv::ensure_lookup_tables_populated): Adjust to use
the new corpus_diff::priv::get_context to get the context.
(variable_is_suppressed): Likewise.
(corpus_diff::priv::{apply_suppressions_to_added_removed_fns_vars,
apply_filters_and_compute_diff_stats, emit_diff_stats,
categorize_redundant_changed_sub_nodes,
clear_redundancy_categorization}): Likewise.
(corpus_diff::{corpus_diff, context,
apply_filters_and_suppressions_before_reporting}): Adjust.
* tools/abipkgdiff.cc (compare): Make the overload that compares
elf binaries take a diff context output parameter. After the
context is created by this function, it's return to the caller, so
that it's life time is bound to the scope this function was
called from.
(pthread_routine_compare): Create a shared pointer to hold a
reference on a diff context. Pass that shared pointer by
reference to the compare function that compares elf binaries.
Rather than storing corpora in the reports_map, (as those corpora
would then out-live the diff context and thus create memory
corruption issues), emit the report directly into an ostringstream
and store that stream in reports_map.
(compare): In the overoad that compares packages, rather than
trying to get corpora from the report_map, just emit the content
of the ostringstream that is now there.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
When reading in an array of the GNU ELF hash table, we read one
integer right after the end of the array.
This patch fixes that.
* src/abg-dwarf-reader.cc (lookup_symbol_from_gnu_hash_tab): Do
not read passed the end of the array.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
abidiff, abipkgdiff and abicompat now recognize a [suppress_file]
directive in suppression specifications. That directive instructs the
tool to avoid loading some binaries altogether.
This is the first directive that won't act on the result of the
comparison of two binaries. It actually acts earlier and prevents the
tool from loading some binaries altogether.
The directive looks like:
[suppress_file]
# Don't load any library named lib_private*.so
file_name_regexp = lib_private.*\\.so
This prevents the tool from loading (and thus comparing) any library
which name matches the pattern "lib_private*.so".
[suppress_file]
# Only load libraries name lib_public*.so
file_name_not_regexp = lib_public.*\\.so
This instructs the tool to only load (and compare) files which name
match the pattern "lib_public*.so".
* doc/manuals/libabigail-concepts.rst: Document the new
'suppress_file' directive.
* include/abg-suppression.h (file_suppression): Define new class.
(file_suppression_sptr): Define new typedef.
(is_file_suppression, file_is_suppressed): Declare new functions.
* src/abg-suppression.cc ():
(read_file_suppression, is_file_suppression, file_is_suppressed):
Define new functions.
(file_suppression::{file_suppression, suppresses_file,
~file_suppression}): Define new member functions.
* tools/abidiff.cc (main): If a suppression specification
suppresses one of the input files, then do not perform the
comparison.
* tools/abipkgdiff.cc (compare): If a suppression specification
suppresses a file that is to be compared, then do not perform the
comparison.
* tools/abicompat.cc (create_diff_context): New static function.
(perform_compat_check_in_normal_mode)
(perform_compat_check_in_weak_mode): Adjust to take a context in
parameter. Do not create a diff context here anymore, do not load
suppression files here either.
(main): Use the new create_diff_context to create a diff context
and initialize it, including loading suppression specifications.
If any suppression specification suppresses a file to load, then
do not load perform any compatibility checking. Adjust
invocations of perform_compat_check_in_weak_mode and
perform_compat_check_in_normal_mode to pass the diff context.
* tests/data/test-diff-suppr/test0-type-suppr-3.suppr: New test
input.
* tests/data/test-diff-suppr/test0-type-suppr-4.suppr: Likewise.
* tests/data/test-diff-suppr/test0-type-suppr-report-4.txt: Likewise.
* tests/data/test-diff-suppr/test0-type-suppr-5.suppr: Likewise.
* tests/data/test-diff-suppr/test0-type-suppr-report-5.txt:
Likewise.
* tests/data/test-diff-suppr/test0-type-suppr-6.suppr: Likewise.
* tests/data/test-diff-suppr/test0-type-suppr-report-6.txt:
Likewise.
* tests/data/test-diff-suppr/test0-type-suppr-report-7.txt:
Likewise.
* tests/test-diff-suppr.cc (in_out_specs): Use the new test
inputs.
* tests/data/test-abicompat/test0-fn-changed-1.suppr: New test
input.
* tests/data/test-abicompat/test0-fn-changed-report-3.txt:
Likewise.
* tests/test-abicompat.cc (in_out_specs):: Use the new test
inputs.
* tests/data/Makefile.am: Add the new test material to source
distribution.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Until now, the suppression engine was part of the comparison engine.
The code of both was in the abg-comparison.{cc,h} files.
For the sake of greater modularity, this patch separates the suppression
engine from the comparison engine. The suppression engine now lives
in include/abg-suppression.h and src/abg-suppression.cc. The patch
also updates logical consumers of the suppression engine to adapt them
to the change.
* include/Makefile.am: Add abg-suppression.h to source
distribution.
* include/abg-comparison.h: Remove abg-ini.h include directive.
(suppression_sptr, suppressions_type): Move these typedefs to
abg-fwd.h.
(class suppression_base, type_suppression)
(type_suppression::insertion_range)
(type_suppression::insertion_range::boundary)
(type_suppression::insertion_range::integer_boundary)
(type_suppression::insertion_range::fn_call_expr_boundary)
(function_suppression, function_suppression::parameter_spec)
(variable_suppression): Move these type definitions to the new
abg-suppression.h.
(read_suppressions, is_type_suppression, is_integer_boundary)
(is_fn_call_expr_boundary, is_function_suppression)
(is_variable_suppression, operator&)
(operator|): Move these function declarations to the new
abg-suppression.h.
(type_suppression, type_suppression_sptr, type_suppression_type)
(function_suppression, function_suppression_sptr)
(function_suppressions_type, variable_suppression)
(variable_suppression_sptr, variable_suppressions_type): Move
these forward declaration and typedefs to the new
abg-suppression.h.
(diff_context::suppressions): Adjust return type to
suppr::suppressions_type&.
(diff_context::add_suppression): Adjust parameter type to
suppr::suppressions_sptr.
(diff_context::add_suppressions): Adjust parameter type
suppr::suppressions_type&.
(is_type_diff, is_decl_diff, is_var_diff, is_function_decl_diff)
(is_pointer_diff, is_reference_diff, is_fn_parm_diff)
(is_base_diff, is_child_node_of_function_parm_diff)
(is_child_node_of_base_diff): Declare these new functions. They
were previously static, local to abg-comparison.cc only. Now they
need to be exported because they are used by the suppression
engine's code that now lives in its one files.
* include/abg-fwd.h (suppr::{suppression_base, suppression_sptr,
suppressions_type}): Forward declare these here.
* include/abg-suppression.h (class suppression_base)
(type_suppression, type_suppression::insertion_range)
(type_suppression::insertion_range::boundary)
(type_suppression::insertion_range::integer_boundary)
(type_suppression::insertion_range::fn_call_expr_boundary)
(function_suppression, function_suppression::parameter_spec)
(variable_suppression): Move these type definitions here, in the
namespace suppr.
(read_suppressions, is_type_suppression, is_integer_boundary)
(is_fn_call_expr_boundary, is_function_suppression)
(is_variable_suppression, operator&)
(operator|): Move these function decalration here, in the
namespace suppr.
(type_suppression_sptr, type_suppressions_type)
(function_suppression_sptr, function_suppressions_type)
(variable_suppression_sptr, variable_suppressions_type): Move
these typedefs here, in the namespace suppr.
* src/Makefile.am: add src/abg-suppression.cc to source
distribution.
* src/abg-comparison.cc (is_type_diff, is_decl_diff, is_var_diff)
(is_function_decl_diff, is_pointer_diff, is_reference_diff)
(is_reference_or_pointer_diff, is_fn_parm_diff, is_base_diff)
(is_child_node_of_function_parm_diff, is_child_node_of_base_diff):
Export these functions.
(*suppression*): Move all the suppression-related definitions to
the new abg-suppression.cc.
* src/abg-suppression.cc: New file. Contains all the *suppression*
definitions from src/abg-comparison.cc, that are put in the suppr
namespace.
* tools/abicompat.cc: Adjust.
* tools/abidiff.cc: Likewise.
* tools/abipkgdiff.cc: Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
When a suppression specification file was not found, from the command line
of abidiff, the error message fails to mention the name of the tool.
This patch fixes that.
* src/abg-tools-utils.cc (emit_prefix): Try to emit the prefix
only if the program name was provided.
* abidiff.cc (maybe_check_suppression_files): Pass the name of the
tool to the check_file function.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* include/abg-dwarf-reader.h (namespace dwarf_reader): Add apidoc.
(enum elf_type): Add an apidoc for each enumerator.
* src/abg-dwarf-reader.cc (get_type_of_elf_file): Add an apidoc
for the 'type' parameter.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
The supression directives suppress_type, suppress_function and
suppress_variable support the two properties below, among others:
file_name_regexp = <some-regexp>
soname_regexp = <some-regexp>
When the regular expression matches either the file name or the
soname, then the suppression directive is activated.
This patch adds the support for these two additional properties for
these suppression directives:
file_name_not_regexp = <some-regexp>
soname_not_regexp = <some-regexp>
These activate the current suppression directive if the regular
expression does *NOT* match the file name or soname.
This is very helpful to express change report suppressions like:
"suppress all ABI change reports for all libraries but those with
file names (or sonames) with the pattern libfoobar.*"
* include/abg-comparison.h
(suppression_base::{get,set}_file_name_not_regex_str): Declare new
member functions.
(suppression_base::{get,set}_soname_not_regex_str): Likewise.
(suppression_base::{names,sonames}_of_binaries_match): Likewise.
* src/abg-comparison.cc
(suppression_base::priv::get_file_name_regex): Fix comment.
(suppression_base::priv::get_file_name_not_regex): New member
function.
(suppression_base::priv::get_soname_regex): Fix comment.
(suppression_base::priv::get_soname_not_regex): New member
function.
(suppression_base::{get,set}_file_name_not_regex_str): Define new
member functions.
(suppression_base::{get,set}_soname_not_regex_str): Likewise.
(suppression_base::{names,sonames}_of_binaries_match): Likewise.
These got factorized out of type_suppression::suppresses_type,
function_suppression::suppresses_function,
function_suppression::suppresses_function_symbol,
variable_suppression::suppresses_variable,
variable_suppression::suppresses_variable_symbol.
(type_suppression::suppresses_type): Use the new
suppression_base::{names,sonames}_of_binaries_match.
(read_type_suppression): Read the new file_name_not_regexp and
soname_not_regexp properties.
(function_suppression::{suppresses_function,
suppresses_function_symbol}): Use the new
suppression_base::{names,sonames}_of_binaries_match.
(read_function_suppression): Read the new file_name_not_regexp and
soname_not_regexp properties.
(variable_suppression::{suppresses_variable,
variable_suppression::suppresses_variable_symbol}): Use the new
suppression_base::{names,sonames}_of_binaries_match.
(read_variable_suppression): Use the new
suppression_base::{names,sonames}_of_binaries_match.
* doc/manuals/libabigail-concepts.rst: Document the new
file_name_not_regexp and soname_not_regexp suppression properties.
* tests/data/test-diff-suppr/test24-soname-report-10.txt: New test
reference output.
* tests/data/test-diff-suppr/test24-soname-report-11.txt: Likewise.
* tests/data/test-diff-suppr/test24-soname-report-12.txt: Likewise.
* tests/data/test-diff-suppr/test24-soname-report-13.txt: Likewise.
* tests/data/test-diff-suppr/test24-soname-report-14.txt: Likewise.
* tests/data/test-diff-suppr/test24-soname-report-15.txt: Likewise.
* tests/data/test-diff-suppr/test24-soname-report-16.txt: Likewise.
* tests/data/test-diff-suppr/test24-soname-report-9.txt: Likewise.
* tests/data/test-diff-suppr/test24-soname-suppr-10.txt: New test input.
* tests/data/test-diff-suppr/test24-soname-suppr-11.txt: Likewise.
* tests/data/test-diff-suppr/test24-soname-suppr-12.txt: Likewise.
* tests/data/test-diff-suppr/test24-soname-suppr-13.txt: Likewise.
* tests/data/test-diff-suppr/test24-soname-suppr-14.txt: Likewise.
* tests/data/test-diff-suppr/test24-soname-suppr-15.txt: Likewise.
* tests/data/test-diff-suppr/test24-soname-suppr-16.txt: Likewise.
* tests/data/test-diff-suppr/test24-soname-suppr-9.txt: Likewise.
* tests/data/test-diff-suppr/test29-soname-report-2.txt: New test
reference output.
* tests/data/test-diff-suppr/test29-soname-report-3.txt: Likewise.
* tests/data/test-diff-suppr/test29-soname-report-4.txt: Likewise.
* tests/data/test-diff-suppr/test29-soname-report-5.txt: Likewise.
* tests/data/test-diff-suppr/test29-soname-report-6.txt: Likewise.
* tests/data/test-diff-suppr/test29-soname-report-7.txt: Likewise.
* tests/data/test-diff-suppr/test29-soname-report-8.txt: Likewise.
* tests/data/test-diff-suppr/test29-suppr-2.txt: New test input.
* tests/data/test-diff-suppr/test29-suppr-3.txt: Likewise.
* tests/data/test-diff-suppr/test29-suppr-4.txt: Likewise.
* tests/data/test-diff-suppr/test29-suppr-5.txt: Likewise.
* tests/data/test-diff-suppr/test29-suppr-6.txt: Likewise.
* tests/data/test-diff-suppr/test29-suppr-7.txt: Likewise.
* tests/data/test-diff-suppr/test29-suppr-8.txt: Likewise.
* tests/data/Makefile.am: Add the new test material to source
distribution.
* tests/test-diff-suppr.cc (in_out_specs): Make this test harness
run over the new test inputs.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* include/abg-workers.h: Document the workers namespace, the task,
queue and queue::task_done_notify types.
* src/abg-workers.cc: Move the documentation of the thread_pool
module inside the abigail::worker namespace, so that references to
task and queue types (which are also in the abigail::worker
namespace) can be resolved in the apidoc.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Registering alias of functions on ppc64 seems to be broken since this
commit:
11f5dba Bug 19885 - Cannot associates a function DIE to a symbol on powerpc64
This is because the ppc64-specific code tries to register a symbol
alias that was already registered as an alias by the arch-agnostic
code.
This patch fixes that.
* src/abg-dwarf-reader.cc (read_context::load_symbol_maps): While
filling the ppc64-specific "function-entry-address => symbol" map,
if we stumble accross a function-entry-address that belongs to an
alias of 'symbol', then assume the alias must have been registered
as an alias already, by the platform-agnostic code. Do not try to
register the alias again.
* tests/data/Makefile.am: Add the new test input binaries to the
source distribution.
* tests/data/test-diff-dwarf/libtest36-ppc64-aliases-v0.so: New
binary test input.
* tests/data/test-diff-dwarf/libtest36-ppc64-aliases-v1.so: Likewise.
* tests/data/test-diff-dwarf/test36-ppc64-aliases-report-0.txt:
New test reference output.
* tests/data/test-diff-dwarf/test36-ppc64-aliases-v0.cc: Source
code for the new binary test input above.
* tests/data/test-diff-dwarf/test36-ppc64-aliases-v1.cc: Likewise.
* tests/test-diff-dwarf.cc: Add the new test input to the list of
test inputs considered by this test harness.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
In the ELF format, Position Independent Executables (aka PIE) and
shared libraries are marked as being of type ET_DYN. So just looking
at the type of the ELF file is not enough to discriminate a position
independent executable from a shared library.
And this is the problem. Libabigail just looks at the type of the ELF
file to discriminate PIE binaries from shared libraries binaries.
So it treats both kinds of binaries as being shared libraries. When
we run abipkgdiff with the --dso-only option, the tool considers both
PIEs and shared libraries, even though the intent of the --dso-only
option is have the tool consider shared libraries only.
With this patch, we introduce a new enumerator ELF_TYPE_PI_EXEC (to
the elf_type enum) for PIE binaries. From now on, a file will be
properly recognized as being of the ELF_TYPE_DSO kind only if it is a
shared library.
* include/abg-dwarf-reader.h (elf_type): Add new enumerator
ELF_TYPE_PI_EXEC.
* src/abg-dwarf-reader.cc
(lookup_data_tag_from_dynamic_segment): New function for
data tag lookup in dynamic segment of an elf
(elf_file_type): Return ELF_TYPE_PI_EXEC file type for
a PI executable.
(get_elf_file_type): Change this to take an elf handle.
(get_type_of_elf_file): New function that got factorized out of ...
(load_dt_soname_and_needed): ... this one.
* tools/abipkgdiff.cc (create_maps_of_package_content): Also
consider ELF_TYPE_PI_EXEC file type.
(compare): Likewise.
* tests/test-diff-pkg.cc (in_out_specs): Test case additions
* tests/data/Makefile.am: Include test files
* tests/data/test-diff-pkg/tarpkg-1-dir1.tar.gz: New test data
* tests/data/test-diff-pkg/tarpkg-1-dir2.tar.gz: New test data
* tests/data/test-diff-pkg/tarpkg-1-report-0.txt: New test result
Signed-off-by: Sinny Kumari <sinny@redhat.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
In a suppression specification, soname_regexp or file_name_regexp
cannot be the only property of a suppression directive. For instance,
the suppression specification below won't work:
[suppress_type]
# suppress all change reports about *any type* from the library
# libtestfoo.so
file_name_regexp = libtestfoo.so
This is because as documented in the manual, the suppression directive
'suppress_type' requires that some other properties be specified. For
instance, the below would work:
[suppress_type]
name_regexp = .*
file_name_regexp
This was done on purpose to prevent folks from inadvertently
suppressing too much of change report bits.
But experience is showing that this is surprising some users. And in
hindsight, I kind of agree it's surprising.
So this patch allows the first example to work, as seems to be
expected.
The patch allows the first example to work for the suppress_function
and suppress_variable directive too.
* doc/manuals/libabigail-concepts.rst: Update the manual to
reflect the changes in the suppression_type, suppress_function and
suppress_variable directives.
* src/abg-comparison.cc (read_type_suppression): Accept that
the suppress_type directive contains only file_name_regexp
or the soname_regexp property.
(read_function_suppression): Likewise for the suppress_function
directive.
(read_variable_suppression): Likewise for the suppress_variable
directive.
* tests/data/test-diff-suppr/libtest29-soname-v0.so: New binary
test input.
* tests/data/test-diff-suppr/libtest29-soname-v1.so: Likewise.
* tests/data/test-diff-suppr/test24-soname-report-5.txt: New
reference test output.
* tests/data/test-diff-suppr/test24-soname-report-6.txt: Likewise.
* tests/data/test-diff-suppr/test24-soname-report-7.txt: Likewise.
* tests/data/test-diff-suppr/test24-soname-report-8.txt: Likewise.
* tests/data/test-diff-suppr/test24-soname-suppr-5.txt: New test
suppression file.
* tests/data/test-diff-suppr/test24-soname-suppr-6.txt: Likewise.
* tests/data/test-diff-suppr/test24-soname-suppr-7.txt: Likewise.
* tests/data/test-diff-suppr/test24-soname-suppr-8.txt: Likewise.
* tests/data/test-diff-suppr/test29-soname-report-0.txt: New
reference test output.
* tests/data/test-diff-suppr/test29-soname-report-1.txt: Likewise.
* tests/data/test-diff-suppr/test29-soname-v0.cc: Source code for
the new binary output above.
* tests/data/test-diff-suppr/test29-soname-v1.cc: Likewise.
* tests/data/test-diff-suppr/test29-suppr-0.txt: New test
suppression file.
* tests/data/test-diff-suppr/test29-suppr-1.txt: Likewise.
* tests/data/Makefile.am: Add the new test material above to
source distribution.
* tests/test-diff-suppr.cc (in_out_specs): Make this test harness
run over the new test input above.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
On powerpc 64 ELFv1, the address of a function is different from the
address of the entry point of that function. The value of a en ELF
symbol represents the address of the function, whereas the
DW_AT_low_pc DWARF attribute of a function DIE points to the entry
point address of the function. So to get the symbol a function's
DW_AT_low_pc points to, one needs to get the address of the function
*from* the address of its entry point.
More precisely, on ppc64, the address of a function is the address of
a function descriptor. The function descriptor is a set of three 64
bits addresses. The first element of the triplet is the function
entry pointer address. So to get the symbol a given function entry
point address belongs to, one must get to the function descriptor
which contains said function entry point address. And function
descriptors are in the ".opd" special section.
Unfortunately, Libabigail's ELF/DWARF reader has no knowledge of all
this. So it cannot get the symbol of a given function DWARF
description. So it considers all functions as having no ELF symbols.
So it shows no ABI change pertaining to function sub-types on ppc64.
This patch makes Libabigail support function descriptors on ppc64 so
it can detect changes on function sub-types there.
* src/abg-dwarf-reader.cc (read_context::{opd_section_,
fun_entry_addr_sym_map_}): New data members.
(read_context::read_context): Initialize the new opd_section_ data
member.
(read_context::{find_opd_section,
lookup_ppc64_elf_fn_entry_pointer_address,
fun_entry_addr_sym_map_sptr, fun_entry_addr_sym_map,
elf_architecture_is_ppc64, elf_architecture_is_big_endian}): New
member functions.
(read_context::lookup_elf_fn_symbol_from_address): Adjust to use
the new read_context::fun_entry_addr_sym_map() function.
(read_context::load_symbol_maps): Populate the function entry
addresses -> symbol map, for ppc64 ELFv1.
(read_context::load_elf_properties): Renamed
read_context::load_remaining_elf_data into this.
(read_corpus_from_elf): Load elf properties before trying to load
elf symbols information.
* tests/data/test-diff-filter/libtest32-struct-change-v0.so: New
binary test input, compiled for ppc64le.
* tests/data/test-diff-filter/libtest32-struct-change-v1.so: Likewise.
* tests/data/test-diff-filter/test32-ppc64le-struct-change-report0.txt:
New test reference output.
* tests/data/test-diff-filter/test32-ppc64le-struct-change-v0.c:
Source code of the new binary test input above.
* tests/data/test-diff-filter/test32-ppc64le-struct-change-v1.c:
Likewise.
* tests/data/Makefile.am: Add the new test material above to
source distribution.
* tests/test-diff-filter.cc (in_out_spec): Make this test harness
run over the new test input binaries above.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
When comparing two directories, abipkgdiff skips symbolic links
pointing to ELF binaries altogether. It only consider regular files.
This is a problem when abipkgdiff is given two directories that only
contain symbolic links. In that case, abipkgdiff just performs no
comparison.
This patch makes abipkgdiff resolve the symbolic link to its target
file.
* include/abg-tools-utils.h (maybe_get_symlink_target_file_path):
Declare new function.
* src/abg-tools-utils.cc (get_stat): Use lstat here, not stat.
Update comment.
* tools/abipkgdiff.cc (first_package_tree_walker_callback_fn)
(second_package_tree_walker_callback_fn): Follow symbolic links to
elf files to get their target paths, and only work with that
target path.
(maybe_get_symlink_target_file_path): Define new function.
* test-diff-pkg/symlink-dir-test1-report0.txt New test material.
* test-diff-pkg/symlink-dir-test1/dir1/symlinks/foo.o: Likewise.
* test-diff-pkg/symlink-dir-test1/dir1/symlinks/libfoo.so: Likewise.
* test-diff-pkg/symlink-dir-test1/dir1/targets/foo.c: Likewise.
* test-diff-pkg/symlink-dir-test1/dir1/targets/foo.o: Likewise.
* test-diff-pkg/symlink-dir-test1/dir1/targets/libfoo.so: Likewise.
* test-diff-pkg/symlink-dir-test1/dir2/symlinks/foo.o: Likewise.
* test-diff-pkg/symlink-dir-test1/dir2/symlinks/libfoo.so: Likewise.
* test-diff-pkg/symlink-dir-test1/dir2/targets/foo.c: Likewise.
* test-diff-pkg/symlink-dir-test1/dir2/targets/foo.o: Likewise.
* test-diff-pkg/symlink-dir-test1/dir2/targets/libfoo.so: Likewise.
* tests/data/Makefile.am: Add the new test material to source
distribution.
* tests/test-diff-pkg.cc (in_out_spec): Run this test harness
over the new test material above.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
The decl of a member variable which DIE is in the main debug info
section is being associated with the alternate debug info section,
just because the specification DIE of the variable is in the alternate
debug info section.
This patch associates the decl of a member variable with the same
debug info section as its DIE, not with the debug info section of its
specification DIE.
Note that I am not adding a regression test for this because the
reproducer RPMs given in the bug for this issue are too big and slow
to analyze.
* src/abg-dwarf-reader.cc (build_ir_node_from_die): Associate the
decl of the variable to the same debug info file (alternate or
not) as the DIE, not as its specification DIE.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
maybe_canonicalize_type aborts because the assertion that
read_context::lookup_type_from_die_offset should always return a type
is violated. read_context::lookup_type_from_die_offset is called on
the offset of a DIE of a type that is being constructed. The problem
is that that fonction only looks in the map of types that are fully
constructed.
This patch addresses the issue by making
read_context::lookup_type_from_die_offset look up class and function
types being constructed as well.
While doing that I had to add maps for class and function types being
constructed and that are in the alternate debug info section. I
adjusted the accessors for class and function types accordingly. The
code using those accessors was adjusted accordingly as well.
The patch also prevents maybe_canonicalize_type for DIEs which no type
was built for, in buid_ir_node_from_die. This is particularly for
DW_TAG_class_type and DW_TAG_structure_type DIEs.
* src/abg-dwarf-reader.cc
(read_context::{alternate_die_wip_classes_map_,
alternate_die_wip_function_types_map_}): New data members.
(read_context::lookup_type_from_die_offset): Lookup WIP class and
function types too.
(read_context::{die_wip_classes_map, die_wip_function_types_map}):
Take a flag saying if we should get the map for the alternate
debug info section or not.
(read_context::{is_wip_class_die_offset,
is_wip_function_type_die_offset}): Take a flagy saying if the DIE
is in the alternate debug info section or not.
(build_class_type_and_add_to_ir, build_function_type)
(maybe_canonicalize_type): Adjust.
(build_ir_node_from_die): Do not call maybe_canonicalize_type on
type DIEs which no type has been constructed for.
* tests/data/test-diff-pkg/gtk2-debuginfo-2.24.22-5.el7.i686.rpm:
New test input.
* tests/data/test-diff-pkg/gtk2-debuginfo-2.24.28-8.el7.i686.rpm:
Likewise.
* tests/data/test-diff-pkg/gtk2-immodule-xim-2.24.22-5.el7.i686.rpm:
Likewise.
* tests/data/test-diff-pkg/gtk2-immodule-xim-2.24.28-8.el7.i686.rpm:
Likewise.
* tests/data/test-diff-pkg/gtk2-immodule-xim-2.24.22-5.el7.i686--gtk2-immodule-xim-2.24.28-8.el7.i686-report-0.txt:
New test reference output.
* tests/data/Makefile.am: Add the new test material to the source
distribution.
* tests/test-diff-pkg.cc (in_out_spec): Make this test harness run
on the new test input above.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Some children nodes of function_type_diff are traversed in a
non-deterministic order depending on the ordering of elements in an
unordered_map. This can lead to spurious reporting differences
between e.g the x86_64 an i686 platforms.
This patch sorts the parameter diff children nodes of
function_type_diff using the parameter index.
* src/abg-comparison.cc
(function_type_diff::priv::{sorted_subtype_changed_parms_,
sorted_changed_parms_by_id_}): Add two data members.
(function_type_diff::ensure_lookup_tables_populated): Sort the
changed parameters here ...
(function_type_diff::report): ... not here.
(function_type_diff::chain_into_hierarchy): Chain the *sorted*
changed parameters.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
It appears that there can be cycles in the path made of ancestors. In
that case, diff_has_ancestors_filtered_out() just loops forever.
Oops.
This patch addresses that issue by making
diff_has_ancestors_filtered_out() detect cycles.
* src/abg-comparison.cc (diff_has_ancestor_filtered_out): Add an
overload that takes an additional map of pointer values. Make the
older overload call the new one.
* tests/data/test-diff-pkg/libICE-1.0.6-1.el6.x86_64.rpm: New test material.
* 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:
New reference output.
* tests/data/test-diff-pkg/libICE-1.0.9-2.el7.x86_64.rpm: New test material.
* tests/data/test-diff-pkg/libICE-debuginfo-1.0.6-1.el6.x86_64.rpm: New test material.
* tests/data/test-diff-pkg/libICE-debuginfo-1.0.9-2.el7.x86_64.rpm:
New test material.
* tests/data/Makefile.am: Add the new test material to source distribution.
* tests/test-diff-pkg.cc (in_out_specs): Run this test harness
over the new tests material above.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Libabigail considers a removed function (or global variable) as being
an incompatible change, whether it has been suppressed or not.
Likewise, even if all function sub-type changes have been suppressed,
changed virtual offset on functions are still considered incompatible.
Thus, abidiff still returns an exit code that reflects an incompatible
change even if the removed symbol change was suppressed.
The rule should rather be that if incompatible changes have been
suppressed, abidiff (and the other tools) should take that into
account and not return an exit code that reflects incompatible
changes.
This patch implements that rule, at least for the incompatible changes
that are detected so far.
* src/abg-comparison.cc (corpus_diff::has_incompatible_changes):
Consider the *net* number of removed function and variable
symbols. Also, if all function sub-type changes have been
suppressed, then no virtual offset change should be considered
incompatible.
* tests/data/test-abidiff-exit/test1-voffset-change-report1.txt
* tests/data/test-abidiff-exit/test1-voffset-change.abignore
* tests/data/test-abidiff-exit/test2-filtered-removed-fns-report0.txt
* tests/data/test-abidiff-exit/test2-filtered-removed-fns-report1.txt
* tests/data/test-abidiff-exit/test2-filtered-removed-fns-v0.c
* tests/data/test-abidiff-exit/test2-filtered-removed-fns-v1.c
* tests/data/test-abidiff-exit/test2-filtered-removed-fns.abignore
* tests/data/Makefile.am: Add the new test material above to
source distribution.
* tests/test-abidiff-exit.cc (InOutSpec::in_suppr_path): New data
member.
(in_out_specs): Adjust. Add new test inputs.
(main): Adjust.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
This is from the problem report at
https://sourceware.org/bugzilla/show_bug.cgi?id=19707.
GCC 5.3.1, when invoked with -g -O2 emits some debug info where some
virtual member functions with linkage name have no reference to any
underlying symbol. When that binary is compared to its counterpart
compiled with -g, the member function in question does have an
underlying symbol and thus the comparison of the enclosing types yield
a spurious change report like:
method virtual void unity::scopes::ScopeBase::stop() didn't have any
linkage name, and it now has: '_ZN5unity6scopes9ScopeBase4stopEv'
This patch introduces a pass in the DWARF reader which fixes up
virtual member function with linkage and no underlying symbol. If
there is a symbol with a name equals to the linkage name, the virtual
member function has its underlying symbol set to that symbol.
This fixes the spurious change report.
* src/abg-dwarf-reader.cc (die_function_decl_map_type): New
typedef.
(read_context::die_function_with_no_symbol_map_): New data member.
(read_context::die_function_decl_with_no_symbol_map): New
accessor.
(read_context::fixup_functions_with_no_symbols): New member
function.
(finish_member_function_reading): Take a read_context. Schedule
virtual member functions with linkage and no underlying symbol to
be fixed up after all the debug info is read.
(build_function_decl): After a virtual member function_decl has
been updated, if it has its underlying symbol and was scheduled
for fixup, then de-schedule it.
(build_class_type_and_add_to_ir, build_ir_node_from_die): Adjust
call to finish_member_function_reading.
(read_corpus_from_elf): Move the pure ELF (symbol and other mundane
information) information reading ...
(read_debug_info_into_corpus): ... here. Make it happen *before*
actual reading of DWARF information. We need symbol information
to be present and fully set before we start reading debug info.
This is so that we can know when a virtual member function doesn't
need to be fixed up. Also, perform the fixup after the debug
information was read.
* tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi: Adjust.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Since libabigail now uses pthreads via the abigail::workers namespace,
the libabigail shared library should link with pthreads. Many to
Michi Henning for raising this.
* src/Makefile.am: Add -pthread to libabigail_la_LDFLAGS.
* tools/Makefile.am: Do not use abinilint_LDFLAGS when it should
be abinilint_LDADD. This one was fixed by Michi Henning.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
I forgot that functions that have no elf symbol can still make it to
the internal diff representation, so we always need to take that into
account.
* src/abg-comparison.cc
(function_suppression::suppresses_function): Make sure a function
has a symbol before (de)referencing it.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* include/abg-ir.h (var_decl::get_naked_type): Declare new member function.
* src/abg-ir.cc (var_decl::get_naked_type): Define it.
(equals): For the var_decl overload, avoid copying symbol
smart pointers. Likewise for variable type smart pointers.
(hash_type_or_decl): Avoid accessing canonical type smart pointer.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Various style cleanups and comment additions here and there.
* include/abg-ir.h: Add missing comments. Space cleanups. Use
shorter typedefs rather than long template instantiation names.
Use string rather than the longer std::string.
* src/abg-ir.cc: Space cleanups. Add missing comments. User
shorter typedefs.
* src/abg-reader.cc: Likewise.
* src/abg-writer.cc: Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>