Make applying supp specs through pointer access look through typedefs
Consider the declaration of the exported function bar() below:
struct _OpaqueType {int member;};
typedef struct _OpaqueType Type;
void bar(Type*);
Once the *definition of struct _OpaqueType and bar() are compiled into
a shared library, if a layout change happens to struct _OpaqueType,
then abidiff rightfully reports that bar() is impacted by the layout
change to struct _OpaqueType.
But then, the following suppression specification won't silence the
ABI change report:
[suppress_type]
name = _OpaqueType
type_kind = struct
accessed_through = pointer
This is because strictly speaking, it's not struct _OpaqueType that is
accessed through a pointer, from function bar(); it's the type 'Type',
(which is a typedef of struct _OpaqueType) that is accessed though a
pointer.
But then, as 'Type' and 'struct _OpaqueType' are the same type (modulo
the typedef), this behaviour is not super useful. It would be more
interesting if the suppression specification could silence the ABI
change report.
And this is what this patch does.
* include/abg-comparison.h (type_suppression::suppresses_type):
Declare new member function.
(get_typedef_diff_underlying_type_diff): Declare new function.
* include/abg-fwd.h (get_typedef_underlying_type): Likewise.
* src/abg-comparison.cc (type_suppression::suppresses_type):
Define new member function.
(get_typedef_diff_underlying_type_diff): Define new function.
(type_suppression::suppresses_diff): After looking through the
different kind of access methods, use the new
type_suppression::suppresses_type(), rather than doing lots of
stuff ourselves here. But then, if the suppression doesn't apply
to the subjects of the diff, look through typedefs and try to
apply the suppression again.
* src/abg-ir.cc (get_typedef_underlying_type): Define new
function.
* tests/data/test-diff-suppr/libtest25-typedef-v{0,1}.so: New
binary test input files.
* tests/data/test-diff-suppr/test25-typedef-v{0,1}.c: Source code
for the binary test input files above.
* tests/data/test-diff-suppr/test25-typedef-report-{0, 1}.txt: New test
input files.
* tests/data/test-diff-suppr/test25-typedef-suppr-0.txt: New test
input file.
* tests/data/Makefile.am: Add the new test material to the source
distribution.
* tests/test-diff-suppr.cc (in_out_specs): Add the test inputs
above to the set of test inputs this harness has to run over.
Make abipkgdiff erase the *parent* directory of temporary files
abipkgdiff was erasing the temporary files created by it wasn't
erasing the parent directory containing them. Fixed thus.
* tools/abipkgdiff.cc
(erase_created_temporary_directories_parent): New static function.
(compare): After comparison, erase the temporary parent directory
as well.
Make the name of the removed variable section be consistent
The removed functions section is introduced by the string "Removed
functions", whereas the removed variables section is introduced by the
string "Deleted variables". This patch makes the latter be "Removed
variables" just like for the functions.
* src/abg-comparison.cc (corpus_diff::report): Introduce the
section of removed variables with the string "Removed variable",
rather than with the string "Deleted variable".
* tests/data/test-abicompat/test2-var-removed-report-0.txt: Adjust.
* tests/data/test-diff-suppr/test18-suppr-removed-var-report-0.txt: Likewise.
* tests/data/test-diff-suppr/test18-suppr-removed-var-report-3.txt: Likewise.
* tests/data/test-diff-suppr/test18-suppr-removed-var-report-5.txt: Likewise.
Consider default symbol versions when computing added/removed fns/vars
When computing the set of added function or variable symbols, if a
symbol S with no version symbol was present in a given corpus and that
symbol gained a *DEFAULT* version V in the second corpus, we should
not consider that a new symbol S was added (and that the former S was
removed) because:
1/ S was already present in the first corpus
2/ applications linked to the first corpus and that were using S
(with no version) there, will automatically use the S with version V
in the second corpus, without needing any re-linking; the
power of symbol versioning!
Rather, it's just that S gained a default symbol version.
This patch implements that.
* include/abg-corpus.h (corpus::{lookup_function_symbol,
lookup_variable_symbol}): Take a elf_symbol::version object,
rather than a string representing the version. Add an overload
that takes an elf_symbol.
* src/abg-corpus.cc (find_symbol_by_version): New static function.
(corpus::{lookup_function_symbol, lookup_variable_symbol}): Take a
elf_symbol::version object, rather than a string representing the
version. Add an overload that takes an elf_symbol. If the looked
up symbol has no version and if the corpus contains a symbol with
the same name and with a default version, then return that latter
symbol if the corpus doesn't contain a symbol with the same name
and empty version.
* src/abg-comparison.cc
(class_diff::ensure_lookup_tables_populated): Adjust.
(corpus_diff::priv::ensure_lookup_tables_populated): Before
deciding that a symbol has been added, if the symbol has a default
version, make sure no symbol with the same name and without
version was present in the former corpus. Similarly, before
deciding that a symbol has been removed, if the symbol has no
version, make sure the latter corpus has no symbol with the same
name and with a default version.
* tests/data/test-diff-dwarf/test12-report.txt: Adjust. The
function should not be considered as added, because its symbol
(and version) was already present in the former DSO.
It appears the comparison engine was counting more deleted variables
than necessary, due to a thinko. Fixed thus.
* src/abg-comparison.cc
(corpus_diff::priv::ensure_lookup_tables_populated): Once we have
computed a set of potentially deleted variables that turned out to
contain variables that were actually *NOT* deleted, really take
these into account by removing these false positives from the set
of deleted *variables*. We were trying to delete these from the
set deleted *functions*; woops, I guess this was a copy & paste
error.
* src/abg-ir.cc (type_has_non_canonicalized_subtype): Once the
type has been traversed, just test if the visitor has accumulated
the 'has_non_canonical_type' property.
* include/abg-ir.h (struct ir_node_visitor): Fix the wording of
the comment of this type.
* src/abg-dwarf-reader.cc (build_ir_node_from_die): Fix the
filling of the text of the comment of the code that chooses to
perform early canonicalizing.
Adding member type doesn't reset declaration-only-ness of a class
When reading DWARF, a declaration-only class was loosing its
declaration-only-ness just because a member type was being added. Bad
things was then happening next because that (normally
declaration-only) class was then considered as being suitable for
early canonicalizing, while it wasn't (yet), in reality. Its
canonicalizing should have been deferred.
This issue was spotted when comparing
kdebase-workspace-4.3.4-29.el6_6.x86_64.rpm and,
kdebase-workspace-4.3.4-30.el6_6.x86_64.rpm, using their associated
debug info. The issue was happening precisely when comparing their
usr/lib64/kde4/kwin4_effect_builtins.so DSOs, precisely; it was
leading to a crash.
* src/abg-dwarf-reader.cc (build_class_type_and_add_to_ir):
Adding a new member type shouldn't remove the
declaration-only-ness of the class.
Extract all packages for a given run of abipkgdiff under the same temp dir
This patch extracts all packages for a given run of abipkgdiff under
the same temporary directory, cluttering /tmp less.
To do this, the patch makes accesses of data members of the 'package'
type go through accessor functions only. Then the accessor for the
parent directory of all extracted package does the job of computing
the path to that parent directory in a way that makes it unique, per
thread.
* tools/abipkgdiff.cc (package::{<all data members>}): Make the
data members be private. Make their names end with an underscore.
(package::extracted_package_parent_dir_path): Remove.
(package::extracted_package_dir_path): Rename into
package::extracted_dir_path_.
(package::extracted_packages_parent_dir): New static member
function, accessor.
(package::package): Adjust to the new names of the data members.
Call the new package::extracted_package_parent_dir() static member
function to initial the package::extracted_dir_path_ data member.
(package::{path, extracted_dir_path, type, is_debug,
path_elf_file_sptr_map, debug_info_package}): New accessors for
the data members.
(package::{erase_extraction_directory,
erase_extraction_directories}): Adjust.
(erase_created_temporary_directories)
(create_maps_of_package_content)
(extract_package_and_map_its_content, prepare_packages, compare)
(main): Adjust.
Sometimes, for debugging purposes it can be very handy to inspect the
content of the packages as seen by the tool. This patch thus adds a
new --keep-tmp-files options so that users can inspect the content of
packages that were extracted.
* tools/abipkgdiff.cc (options::keep_tmp_files): New data member.
(options::options): Initialize it.
(display_usage): Display a usage string for the new
--keep-tmp-files option.
(parse_command_line): Parse the new --keep-tmp-files option.
(compare): Do not erase temporary directories if the users asked so.
* doc/manuals/abipkgdiff.rst: Document the new --keep-tmp-files
options.
With this patch abipkgdiff now shows the linkage names of
added/removed functions and variables. In addition, there now is a
--no-linkage-name option to avoid seeing linkage names.
* doc/manuals/abipkgdiff.rst: Document the new --no-linkage-name
options.
* tools/abipkgdiff.cc (options::show_linkage_names): New data
member.
(options::options): Initialize it.
(display_usage): Display a usage string for --no-linkage-name.
(parse_command_line): Parse the --no-linkage-name option.
(set_diff_context_from_opts): Set the diff context accordingly.
* tests/data/test-diff-pkg/test-rpm-report-0.txt: Adjust.
* tools/abipkgdiff.cc (options::show_added_binaries): New data
member.
(options::options): Initialize it.
(display_usage): Add a help string for --no-added-binaries.
(parse_command_line): Parse the new --no-added-binaries option.
(compare): Do not show added binaries if the user doesn't want to.
* doc/manuals/abipkgdiff.rst: Document the new --no-added-binaries
option.
With this patch, abipkgdiff returns the same exit code as abidiff.
It's zero if there is no ABI change, and non-zero if there are ABI
changes. The exact value depends on the kind of changes that is
detected.
* tools/abipkgdiff.cc (compare): Return an instance
abigail::tools_utils::abidiff_status, just like what we do in
abidiff.
* doc/manuals/abipkgdiff.rst: Document the new exit code.
Fix logic of determining if changes happened in abidiff
Now that we can easily check if the diff between two corpora carries
net changes (i.e, changes after applying suppression specifications)
we can simplify the logic of determining if the corpora have
"worthwhile" changes, in abidiff.
* tools/abidiff.cc (main): Simplify the logic when determining if
the comparison between two corpora yields worthwhile changes.
Add a new corpus_diff::has_net_changes() entry point
This entry point is to test if there are still ABI changes between two
corpora after applying suppression specifications.
* include/abg-comparison.h (corpus_diff::has_net_changes): Declare
new member function.
* src/abg-comparison.cc (corpus_diff::has_net_changes): Define it.
While looking further in the issue Sinny Kumari reported, I realized
that the weak mode wasn't working in that example either.
It turned out that synthesizing qualified types was not working
because we were just looking them up in the binary, rather than
looking up the un-qualified underlying type and then synthezing the
resulting qualified type.
This patch just does that.
* include/abg-fwd.h
(synthesize_type_from_translation_unit): Declare new function.
(synthesize_function_type_from_translation_unit): Make the
translation_unit parameter non-const because the function needs to
bind the life time of the synthesized function to the life time of
the translation unit. Make this function be a friend of
abigail::ir::translation_unit.
(synthesize_function_type_from_translation_unit):
* src/abg-ir.cc (translation_unit::priv::synthesized_types_): New
data member.
(synthesize_type_from_translation_unit): Define new function.
(synthesize_function_type_from_translation_unit): Make the
translation_unit parameter non-const. If the return is void, then
take that in account carefuly. Rather than just looking up the
type of parameters and return value, synthesize them too,
especially when they are qualified types. Bind the life time of
the synthesized function type to the lifetime of the translation
unit.
* tests/data/test-abicompat/test7-fn-changed-report-1.txt: New
test reference output.
* tests/test-abicompat.cc (in_out_spec): Run the harness on the
exisiting test7-fn-changed-app and libtest7-fn-changed-libapp-v1
but in weak mode this time.
Fix computing the set of exported functions and varible symbols
Sinny Kumari reported that abicompat is failing to report ABI changes
on a library linked to a small test program. It turned out that the
code that compute if a given exported function is to be kept by
looking at the white list of symbols to keep has a bug in which the
versions of the symbols of the white list were not being reset as they
should. Fixed thus.
* src/abg-ir.cc (elf_symbol::get_name_and_version_from_id): Always
set the version and name of the symbol.
* src/abg-corpus.cc
(corpus::exported_decls_builder::{keep_wrt_id_of_fns_to_keep,
keep_wrt_id_of_vars_to_keep}): Reset the symbol name *and* version
before passing it. This is redundant with the fix in
elf_symbol::get_name_and_version_from_id() that always set the
symbol name and version now, but I felt it makes it easier to
understand the fix overall.
* tests/data/test-abicompat/libtest7-fn-changed-libapp-v{0,1}.so:
New test input binaries.
* tests/data/test-abicompat/test7-fn-changed-app: Likewise.
* tests/data/test-abicompat/test7-fn-changed-{app, libapp-v0,
libapp-v1}.c: Source code of the binary test inputs above.
* * tests/data/test-abicompat/test7-fn-changed-{libapp-v0,
libapp-v1}.h: Likewise.
* tests/data/test-abicompat/test7-fn-changed-report-0.txt: Test
input.
* tests/data/Makefile.am: Add the new test material above to
source distribution.
* tests/test-abicompat.cc (int_out_specs): Add the test inputs
above to the set of inputs this test harness has to run over.
We were using the unsafe tmpnam function in abilint. This patch
creates a helper type abigail::tools_utils::temp_file that does away
with the use tmpnam in abilint.
* include/abg-tools-utils.h (abigail::tools_utils::temp_file):
Declare new type.
(abigail::tools_utils::temp_file_sptr): New typedef.
* src/abg-tools-utils.cc (temp_file::priv): Define new type.
(temp_file::{temp_file, is_good, get_path, get_stream, create}):
Define new member functions.
* tools/abilint.cc (main): Do not use tmpnam anymore. Use the new
abigail::tools_utils::temp_file type instead.
Try to avoid a race condition when abipkgdiff extracts packages.
abipkgdiff extracts the content of the first package in a directory
named <tmpdir>/package1 and the content second package in
<tmpdir>/package2. If two independant instances of abipkgdiff are
launched at the same time, they are going to walk on each others'
toes, to say the least.
This patch extracts the content of each package in directory named
<tmpdir>/<randomname>/package1, where randomname is supposed to be a
random number, and so should be unique, most of the time.
I guess we should try harder to generate a randomname that is unique
when we see that the directory <tmpdir>/<randomname> exists already,
but for now, what we have is good enough, or at least better than what
we have had so far.
* include/abg-tools-utils.h (get_random_number)
(get_random_number_as_string): Declare new functions.
* src/abg-tools-utils.cc (get_random_number)
(get_random_number_as_string): Define them.
* tools/abipkgdiff.cc
(package::extracted_package_parent_dir_path): New data member.
(package::package): Initialize
package::extracted_package_parent_dir_path to
<tmpdir>/<randomname>, with randomname being a random number
represented as a string.
(extract_rpm): Make sure to create a hierarchy of directories, not
just a directory.
On changed fn, show symbol info when name is different from linkage name in C
In change reports for function sub-type changes, for the C language,
when the name of the function is different from its linkage name, even
when the function symbol has no aliases, show the symbol information
of the function.
* include/abg-ir.h (translation_unit::language): New enum type.
(translation_unit::{get_language, set_language}): Declare new
accessors.
(translation_unit_language_to_string)
(string_to_translation_unit_language, is_c_language)
(is_cplus_plus_language): Declare new functions.
* src/abg-ir.cc (translation_unit::priv::language_): New data
member.
(translation_unit::priv::language_): Initialize it.
(translation_unit::{set_language, get_language}): Define new
member functions.
(translation_unit_language_to_string)
(string_to_translation_unit_language, is_c_language)
(is_cplus_plus_language): Define new functions.
* src/abg-dwarf-reader.cc (dwarf_language_to_tu_language): New
static function.
(build_translation_unit_and_add_to_ir): Read the language of the
translation unit.
* src/abg-comparison.cc (corpus_diff::report): When reporting a
change in a function sub-type, if we are in C language translation
unit, if the function name is different from its linkage name,
even if the symbol doesn't have any alias, show symbol
information.
* src/abg-reader.cc (read_translation_unit_from_input): Read the
'language' property of the translation unit, if present.
* src/abg-writer.cc (write_translation_unit): Write the 'language'
property to the translation unit, if present.
* tests/data/test-read-dwarf/test0.abi: Adjust for the new
'language' property of the 'abi-instr' element.
* tests/data/test-read-dwarf/test1.abi: Likewise.
* tests/data/test-read-dwarf/test2.so.abi: Likewise.
* tests/data/test-read-dwarf/test3.so.abi: Likewise.
* tests/data/test-read-dwarf/test4.so.abi: Likewise.
* tests/data/test-read-dwarf/test5.o.abi: Likewise.
* tests/data/test-read-dwarf/test6.so.abi: Likewise.
* tests/data/test-read-dwarf/test7.so.abi: Likewise.
* tests/data/test-read-dwarf/test8-qualified-this-pointer.so.abi:
Likewise.
* tools/abipkgdiff.cc (options::suppressions): New data member.
(set_diff_context_from_opts): Set the suppression specifications
provided by the user to the diff context.
(parse_command_line): Parse the --suppressions and --suppr command
line options.
* doc/manuals/abipkgdiff.rst: Document the --suppressions and
--suppr options.
Support file_name_regexp and soname_regexp in supp-specs
With this patch it's now possible to express the soname or name of the binary
file that contains the ABI artifacts the suppression specifications
should apply to.
* include/abg-comparison.h (suppression_base::priv_): Make this
pimpl member protected.
(suppression_base::set_file_name_regex_str)
(get_file_name_regex_str, get_soname_regex_str)
(set_soname_regex_str): Declare new accessors.
(function_suppression::{suppresses_function,
suppresses_function_symbol}): Take a diff_context_sptr.
(variable_suppression::{suppresses_variable,
suppresses_variable_symbol}): Take a diff_context_sptr.
* src/abg-comparison.cc
(suppression_base::priv::{file_name_regex_str_, file_name_regex_,
soname_regex_str_, soname_regex_}): Define new data members.
(suppression_base::priv::get_file_name_regex_str)
(get_soname_regex_str): Define new member functions.
(suppression_base::set_file_name_regex_str)
(get_file_name_regex_str, get_soname_regex_str)
(set_soname_regex_str): Define new accessors.
(type_suppression::suppresses_diff): Evaluate file_name_regexp and
soname_regexp.
(read_type_suppression): Fix the reading of the "label" property.
Read the file_name_regexp and soname_regexp properties.
(function_suppression::{suppresses_function,
suppresses_function_symbol): Take a diff_context_sptr parameter.
Evaluate file_name_regexp and soname_regexp properties.
(function_suppression::suppresses_diff): Adjust for the api change
of function_suppression::suppresses_function().
(read_function_suppression): Read the file_name_regexp and
soname_regexp properties.
(variable_suppression::suppresses_variable): Take a
diff_context_sptr parameter and evaluate file_name_regexp and
soname_regexp properties.
(variable_suppression::suppresses_variable_symbol): Likewise.
(variable_suppression::suppresses_diff): Adjust for the api change
of variable_suppression::suppresses_variable().
(read_variable_suppression): Read the file_name_regexp and
soname_regexp properties.
(function_is_suppressed, variable_is_suppressed): Take a
diff_context_sptr parameter.
(corpus_diff::priv::apply_suppressions_to_added_removed_fns_vars):
Adjust.
* doc/manuals/libabigail-concepts.rst: Document file_name_regexp
and soname_regexp in the manual.
* tests/data/test-diff-suppr/libtest24-soname-v{0,1}.so: New test
binary input files.
* tests/data/test-diff-suppr/test24-soname-report-{0,4}.txt: New
test input files.
* tests/data/test-diff-suppr/test24-soname-suppr-{0,4}.txt:
Likewise.
* tests/data/test-diff-suppr/test24-soname-v{0,1}.cc: Source code
of the binary test input files above.
* tests/data/Makefile.am: Add the new test material above to
source distribution.
* tests/test-diff-suppr.cc (in_out_spec): Add the new test inputs
to the set of tests this harness has to run over.
When evaluating the way the diff node has been reached, do not crash
on diff nodes that are pointer_diff to something else but a type diff,
because there can be pointers to distinct_diff nodes, for instance.
* src/abg-comparison.cc (type_suppression::suppresses_diff): When
evaluating the reach_kind property, do not crash on diff nodes
that are pointer_diff or reference_diff to something else but a
type diff.
When a binary cannot be analyzed by abipkgdiff, silently skip it
unless --verbose is used, in which case, display a message saying
that it couldn't be analyzed.
* tools/abipkgdiff.cc (compare): In the elf_file overload, do not
emit an error message when a binary could not be analyzed unless
--verbose was provided.
Just like what abidiff does, this patch avoids emitting redundant diff
report messages unless the user provides the --redundant switch.
* tools/abipkgdiff.cc (options::show_redundant_changes): New data
member.
(options::options): Initialize it.
(display_usage): Add a help string for the --redundant command
Line option.
(set_diff_context_from_opts): New static function.
(compare): Take the options variable. Set the diff context from
the options, especially if we should show redundant changes or
not. Use that diff context when comparing ABIs.
(parse_command_line): Parse the new --redundant command line
switch.
* doc/manuals/abipkgdiff.rst: Document the new --redundant option.
It turned out on some packages we are interested on comparing shared
libraries only. This patch adds that functionality by adding a new
--dso-only command line option to abipkgdiff.
* tools/abipkgdiff.cc (options::compare_dso_only): New data
member.
(options::options): Initialize it.
(display_usage): Display a little help string for it.
(create_maps_of_package_content): Take the option variable. Do
not compare non-dso files if the --dso-only option was provided.
(extract_package_and_map_its_content, prepare_packages, compare):
Take the option variable.
(parse_command_line): Parse the new --dso-only option.
* doc/manuals/abipkgdiff.rst: Add documentation for the new
--dso-only option.
* src/abg-dwarf-reader.cc (get_soname_of_elf_file): Better wording
of the apidoc of this function.
* tools/abipkgdiff.cc (verbose, elf_file_paths): Add apidoc for
these global variables.
(struct options, ): Add apidoc for these types.
(options::{erase_extraction_directory,
erase_extraction_directories}, display_usage, extract_rpm)
(erase_created_temporary_directories, extract_package)
(file_tree_walker_callback_fn, compare)
(create_maps_of_package_content)
(extract_package_and_map_its_content, prepare_packages, compare)
(parse_command_line): Add apidoc for these functions.
Add tests for the abipkgdiff tool. The tests runs abipkgdiff on RPM
packages. RPMs for test data are taken from Fedora koji build with
build id - 106158 and 648058
* tests/Makefile.am: Build new runtestdiffpkg regression test
* tests/data/Makefile.am: Add new test files to source
* tests/data/test-diff-pkg/dbus-glib-0.104-3.fc23.x86_64.rpm:
Test data for abipkgdiff tool
* tests/data/test-diff-pkg/dbus-glib-0.80-3.fc12.x86_64.rpm: Likewise
* tests/data/test-diff-pkg/dbus-glib-debuginfo-0.104-3.fc23.x86_64.rpm:
Likewise
* tests/data/test-diff-pkg/dbus-glib-debuginfo-0.80-3.fc12.x86_64.rpm:
Likewise
* tests/data/test-diff-pkg/test-rpm-report-0.txt: Expected test output
* tests/data/test-diff-pkg/test-rpm-report-1.txt: Likewise
* tests/data/test-diff-pkg/test-rpm-report-2.txt: Likewise
* tests/data/test-diff-pkg/test-rpm-report-3.txt: Likewise
* tests/data/test-diff-pkg/test-rpm-report-4.txt: Likewise
* tests/test-diff-pkg.cc: New file
* doc/manuals/abipkgdiff.rst: New manual file.
* doc/manuals/libabigail-tools.rst: Refer to the manual for
abipkgdiff.
* doc/manuals/Makefile.am: Add the new manual file to source
distribution.
* doc/manuals/conf.py: Add the manual for abipkgdiff to section 1.
* src/abg-dwarf-reader.cc (get_soname_of_elf_file): Better wording
of the apidoc of this function.
* tools/abipkgdiff.cc (verbose, elf_file_paths): Add apidoc for
these global variables.
(struct options, ): Add apidoc for these types.
(options::{erase_extraction_directory,
erase_extraction_directories}, display_usage, extract_rpm)
(erase_created_temporary_directories, extract_package)
(file_tree_walker_callback_fn, compare)
(create_maps_of_package_content)
(extract_package_and_map_its_content, prepare_packages, compare)
(parse_command_line): Add apidoc for these functions.
* abipkgdiff.cc (get_soname_of_elf_file): Fix spacing.
* tools/abipkgdiff.cc (elf_file_paths): Make this global variable
static.
(extract_rpm): Rename parameter pkg_path name into package_path.
Remove the last direct fiddling with ELF from abipkgdiff.cc
Directly using elfutils from abipkgdiff.cc feels like a taping into
the wrong abstraction layer from this level. So this patch moves the
determination of the type of elf file into abg-dwarf-reader.cc and
uses it from there. The patch also simplifies the instantiation of
types elf_file and package, from abipkgdiff.cc.
* abg-dwarf-reader.h (enum elf_type): Move this declaration here
from abipkgdiff.cc to here.
(get_type_of_elf_file): Declare this new function.
(get_soname_from_elf): Change this to take a path to the elf file
rather than a Elf* handler. So now to use this, the user doesn't
have to get her hand dirty with elfutils.
* src/abg-dwarf-reader.cc (get_soname_from_elf): Change this to
take a path to the elf file rather than a Elf* handler.
(elf_file_type): Move this static function here, from
abipkgdiff.cc.
(get_type_of_elf_file): New function. This has been factorized
out of create_maps_of_package_content() in abipkgdiff.cc.
* tools/abipkgdiff.cc (class elf_file): Changed struct elf_file
into this. Make the default constructor private.
(elf_file::elf_file): Change the constructor to just take the path
to the elf_file. The base name, soname and elf file type are now
computed from the path file, in the constructor. This makes
instantiation much much easier from the point of view of the user
of the type.
(struct abi_diff): Renamed struct abi_changes into this.
(abi_diff::has_changes): Define new member function.
(abi_diffs): Remove this global variable.
(package::package): Remove the elf file type from the set of
parameters of this constructor. Rather, compute that elf file
type from the path to the elf file, in the constructor. Again,
this eases the use of the type.
(elf_file_type): Remove this from here, as it got moved to
abg-dwarf-reader.cc.
(compare): In the elf_file overload, return true if the comparison
yields ABI changes.
(create_maps_of_package_content): Do not fiddle with elfutils
stuff here. Rather, just instantiate elf_file and the analyzing
of the file magically happens.
(compare): Make the package overload take an abi_diff as output
parameter, rather than populating a global variable in return.
(compare): Add an other overload for package that doesn't take the
abi_diff as output parameter and write it in terms of the previous
one.
(main): Adjust as the instantiation of package is now simpler.
It turned out it's important to be able to see what abipkgdiff is
actually doing. This patch adds a --verbose option that emits many
useful information about the tool's progress.
* tools/abipkgdiff.cc (verbose): Add a new global variable.
(package::erase_extraction_directory, extract_rpm, compare)
(create_maps_of_package_content): Emit verbose information.
(parse_command_line): Parse the --verbose option.
Use the library to implement ABI comparison in abipkgdiff
Until now, abipkgdiff was spawning a process running the 'abidiff'
command line tool to perform ABI comparison on binaries. This helped
in sketching what was possible with this tool. However, it's
sub-optimal in a final setup so this patch uses the libabigail library
to perform that comparison.
* tools/abipkgdiff.cc (compare): In the overload for elf_file, use
abigail::comparison::compute_diff() to compare the ABI of two
corpora. The corpora themselves is read using
abigail::dwarf_reader::read_corpus_from_elf(). This cleans up the
output of the tool because nothing is emitted to standard output
if the two ABI corpora compares equal.
Fix several string passing issues in abipkgdiff.cc
A number of functions have string parameters passed by value. Ooops.
They must be passed by reference.
Fixed thus.
* tools/abipkgdiff.cc (elf_file::elf_file): Pass the strings by
reference. Also, change the order of the parameters; all the
strings are passed first, then the elf_type is passed last.
(package::package): Likewise, pass the strings by reference, not
by value.
(create_maps_of_package_content): Adjust for the change in
parameters order of elf_file::elf_file.
Move get_soname() function to abg-dwarf-reader.h/cc
Initially, fetching SONAME from a given DSO file was done in
abipkgdiff.cc. But, this function fits better when defined in
abg-dwarf-reader.cc in order to make it usable by other tools if
needed. For consistancy, get_soname() function has been renamed to
get_soname_from_elf().
* include/abg-dwarf-reader.h (get_soname_from_elf): Declare
new function
* src/abg-dwarf-reader.cc (get_soname_from_elf): Define new
function
* tools/abipkgdiff.cc (get_soname): Remove function
(pkg_diff): Call get_soname_from_elf() instead of get_soname()
This patch introduces many changes that should hopefully improve
legibility and ease of maintenance. Here is a list of the topic of
the changes:
* Avoid using shortened names when the line is not too long.
* Use shared_ptr when possible.
* When a function parameter is not meant to be nil, do not pass it
as a pointer; rather, pass it as a reference.
* Avoid doing things that can "fail" in a destructor; e.g, spawning
a process. Also, it's not common practise to cleanup a resource in a
type destructor, when that resource has not been created in one of the
member functions of the type. It eases maintenance when resource
creation and cleanup is performed at the same logical level.
* tools/abipkgdiff.cc (option::package{1,2}): Rename
option::pkg{1,2} into this, to increase legibility.
(option::debug_package{1,2}): Likewise, rename
option::debug_pkg{1,2} into this.
(elf_file::~elf_file): Do not "delete this" in a destructor. This
leads to double free. It's when someone invokes the "delete"
operator on a pointer to the object that the destructor of the
object is executed automatically; so if in the destructor the
delete operator is called again, bad things are going to happen.
As the destructor is now empty, remove it altogether.
(elf_file_sptr): New typedef for shared_ptr<elf_file>.
(package::path): Rename package::pkg_path into this, for better
legibility.
(package::extracted_package_dir_path): Rename
package::extracted_pkg_dir_path into this.
(package::type): Rename package::pkg_type into this.
(package::is_debug_info): Rename package::is_debuginfo_pkg into
this.
(package::path_elf_file_sptr_map): Rename
package::dir_elf_files_map into this because this is a map of
path -> elf_file_sptr. Also, now the value of the map element is
a elf_file_sptr, no more an elf_file*.
(package::debug_info_package): Rename package::debuginfo_pkg into
this.
(package::package): Adjust for the changes above.
(package::{erase_extraction_directory,
erase_extraction_directories}): New member functions.
(elf_file_paths): Renamed dir_elf_files_path into this.
(erase_created_temporary_directories)
(create_maps_of_package_content)
(extract_package_and_map_its_content, prepare_packages): New
static functions.
(get_soname, elf_file_type, extract_rpm): Make this static.
(extract_package): Take a const package& rather than a
package_sptr to express that the function really expects a non-nil
object by reference (not by copy) and that the object won't be
modified. Using a reference removes the possibility that the
pointer could be nil, causing crashes in the code where
parameter->something was used. Now only parameter.something can
be used, so no crash possible there. This is more solid code.
(file_tree_walker_callback_fn): Rename callback() into this. It
makes the code more legible and kind of 'self-documented'. At
least you get the hint that this is a callback function for some
file tree walking (ftw) function. Adjust for the relevant names
renaming above.
(compare): Rename compute_abidiff into this; again, this increases
legibility; at least at the point of use of this function. Rename
compare_package() into a an overload of compare() as well.
compare_package() used to take a vector of packages. It was hard
to guess by reading the signature of the function, which element
of the vector is expected to be the first vector of the
comparison, which one is to be the second, etc. Now, this
function takes two packages, named first_package and
second_package. That is more "typed"; that is, the signature is
more meaningful. Greater legibility, hopefully. And in the body
of the function, the debug information packages are now accessed
using the package::debug_info_package data member. Again, this is
less surprising, I believe. Also, explicitly erase the temporary
files that were created during this comparison. All this
simplifies the logic of this function, hopefully.
(parse_command_line): Make this static. Add new --d1 and --d2
command line switches that are shortcuts of --debug-info-pkg1 and
--debug-info-pkg2. Adjust this function for the relevant name
changes above. Make lines be shorter than 80 characters.
(main): Do not create any vector of parameters anymore as the
compare_packages() function don't take any vector of parameter
anymore. Just instantiate first_package and second_package now.
Adjust for the relevant name changes above. This hopefully
simplifies the logic of this function.
Through the libabigail project, we try to:
1/ make function names start with a verb
2/ avoid shortening function names, *unless* longer names make the
current line exceed 80 characters per line.
We believe these rules improve legibility for people reading the code.
This patch slightly changes abipkgdiff.cc file to comply with the
above.
* tools/abipkgdiff.cc (extract_package): Renamed extract_pkg into
this because shortening 'package' into 'pkg' provides no
legibility improvement.
(compare_packages): Renamed pkg_diff() into this, so that the name
of the function starts with a verb, and the shortened 'pkg' word
is renamed back to the 'package' word. This way, the code almost
reads like normal English sentences with verbs and complement,
thus enhancing legibility and easing latter maintenance.
(main): Adjust for the changes above.
* tools/abipkgdiff.cc (display_usage): Fixed the typo in
'bi-pacakge.' Also, refer to 'package', not to 'bi-package' that
is surprising to the user at first.
(compute_abidiff): Shorten the size of the introductory line.
The compiler complains that in function callback(), parameters st and
flag are unused. In that case, C++ allows the name of the parameter
to be omitted; that makes the compiler complaint go away.
* tools/abipkgdiff.cc (callback): Remove the name of parameters st
and flag.
the compiler rightfully complains that the const qualifier on the
return type is useless. This is because the value is returned by copy
so the const-ness is not relevant.
End all branches of get_soname() finish with a return statement
The compiler complains that there are some branches in the
get_soname() function that don't end up with a return statement. For
instance, there is no return statement right before the end of the
function, in case the outermost for loop is not taken.
This patch fixes that by having just one return statement at the end
of the function.
* tools/abipkgdiff.cc (get_soname): Have just one return statement
at the end of this function.
Sinny Kumari [Fri, 19 Jun 2015 11:27:05 +0000 (16:57 +0530)]
Exclude processing symlink, display removed/added binaries between two packages
Removed binaries can also lead to ABI breakage if an applicating was using
it previously. So, display it in ABI change report. Also, looking for
ABI change in symbolic link files doesn't make sense. Now, we are not
looking into ABI changes in symlink binaries.
* tools/abipkgdiff.cc (abi_changes): Declare new struct
(callback): Exclude symbloic link file for durther processing
(compute_abidiff): Consider SONAME if exists as key in map instead
of binary name, else binary as key. Also, print if removed/added
binaries exist between packages
Sinny Kumari [Tue, 9 Jun 2015 08:25:19 +0000 (13:55 +0530)]
Stdout ABI changes if same binary found in both package
Now, abipkgdiff can take two rpm packages and optional corresponding
debug-info pacakges. It look for same binary in both rpm directory and
if found calls abdiff along with debug-info options to get ABI changes
between them.
* tools/abipkgdiff.cc (compute_abidiff): New function
tools/abipkgdiff.cc (pkg_diff): Iterate through list of binaries
in both package directory and call compute_diff function if
same binary found in both file.
tools/abipkgdiff.cc (main): Also consider debug-info directories
avilable in debu-info packages.
Sinny Kumari [Tue, 2 Jun 2015 07:03:54 +0000 (12:33 +0530)]
Save ELF files, their type and SONAME if exist for extracted packages
An RPM package may conatins binaries, source/header files, config files,
etc. For abi check we are interested only in ELF binary files. This commit
stores binary files from extracted RPM in a map whose key is
binary file basename and value is struct elf_file with memeber variable
name, path, soname, type
* tools/abipkgdiff.cc (elf_type): Declare new enum
(elf_file): Declare new struct
(package): Add member variable dir_elf_files_map
(get_soname): Define new function
(elf_file_type): Define new function
(extract_rpm): Iterate over extracted directory files
and filter ELF binary files along with their information
like name, soname, elf_type and save in dir_elf_files_map
Sinny Kumari [Tue, 26 May 2015 07:29:26 +0000 (12:59 +0530)]
Extract packages(RPMs) into temporary directories for further processing
Input pacakges need to extracted for further processing which includes
fecthing all files in extracted rpms and look for ELF files aginst
which abi diff is required. Pacakges will be extracted in system tmp
directory.
* tools/abipkgdiff.cc (struct package): Declare new struct
(package_sptr): Declare shared_ptr for struct package
(extract_rpm): Define new fuction to extract rpm package
(extract_pkg): Define new function to extract pacakge
(pkg_diff): Define new function to get ABI diff between
two packages
(main): Create new object of type pacakge for each binary
and debuginfo pacakge passed in commandline options
Sinny Kumari [Thu, 21 May 2015 07:38:32 +0000 (13:08 +0530)]
Guess RPM file type
To run abipkgdiff between two pacakges, it should know whether
input files are valid pacakge file or not. This patch detects RPM and SRPM
pacakge file type. abipkgdiff uses it to know whether input files are
valid RPM pacakge file or not.
* include/abg-tools-utils.h (file_type): Added member
FILE_TYPE_RPM and FILE_TYPE_SRPM
(operator<<): New function declaration.
* src/abg-tools-utils.cc (file_type): Detect RPM and
SRPM file type
(operator<<): New function definition
* tools/abidiff.cc (main): Check for RPM and SRPM
file type as well.
* tools/abilint.cci (main): Check for RPM and SRPM file
type as well.
* tools/abipkgdiff.cc (main): Check whether input files
to abipkgdiff are valid RPM files or not.
Sinny Kumari [Tue, 19 May 2015 12:10:06 +0000 (17:40 +0530)]
Initial skeleton of abipkgdiff tool
Motive of abipkgdiff tool is to provide abi changes between two
pacakges. Packages can be .rpm, .deb or archives. It also takes
optional debug-info package to support pacakges shipping separate
debug-info.
This commit set-up initial skeleton of abipkgdif tool consisting of
help and usage otions. It ensures pkgdiff tool compiles and run when
libabigail gets compiled as whole. Initially, we will add support for
ABI changes for two rpm packages. Further, support for other pacakging
format can be added.
* tools/Makefile.am: Include abipkgdiff.cc in compilation and
generate abipkgdiff binary.
* tools/abipkgdiff.cc: New file
Support reading binaries that do not have a symbol table
* src/abg-dwarf-reader.cc
(read_context::find_symbol_table_section): Allow returning a nil
pointer to symbol table.
(read_context::lookup_elf_symbol_from_index): Return an empty elf
symbol if we got a nil pointer to symbol table.
(read_context::load_symbol_maps): If no symbol table is found then
consider that the symbol maps loading failed.
* src/abg-comparison.cc (class_diff::report): Do not emit new line
unless the diff is to be reported.
* tests/data/test-diff-filter/test25-cyclic-type-report-0.txt: Adjust.
* tests/data/test-diff-filter/test26-qualified-redundant-node-report-0.txt: Adjust.
* tests/data/test-diff-filter/test27-redundant-and-filtered-children-nodes-report-1.txt:
: Adjust.
It turned out we need to read all XML ABI files that were still
emitting empty types (nothing) to represent void types, e.g, for
function returning void. So the type comparison code needs to accept
nil types again.
* src/abg-comparison.cc (compute_diff): In the overload of
type_base_sptr accept nil types.
Handle the life time of the map of canonical types
While working on something else, it turned out that we need to cleanup
(de-allocate) the map of canonical types when all the translation
units that own types are de-allocated. Otherwise, when new
translation units are created later, the types in the canonical types
map become unrelated to the types in these new translation units,
leading to memory management issues.
This patch introduces a "usage watchdog" which detects when no
translation unit uses the type system anymore. That usage watchdog is
then used in the destructor of the translation_unit type to
de-allocate the global data that is logically owned by by the type
system.
The patch also changes the API to read translation units and corpora
in a way that forces users to get a handle on the resulting shared
pointer.
* include/abg-ir.h (type_base::canonical_types_map_type): Move
this typedef into abg-ir.cc and out of the type_base namespace.
(type_base::get_canonical_types_map): Likewise.
* src/abg-ir.cc (canonical_types_map_type): New typedef that got
moved here from type_base::canonical_types_map_type.
(get_canonical_types_map): Likewise got moved here from
type_base::get_canonical_types_map. Made static in the process.
(class usage_watchdog): New type.
(usage_watchdog_sptr, usage_watchdog_wptr): New typedefs.
(get_usage_watchdog, get_usage_watchdog_wptr, ref_usage_watchdog)
(maybe_cleanup_type_system_data): New static functions.
(translation_unit::priv::usage_watchdog_): Add new data member.
(translation_unit::priv::priv): Get a reference on the usage
watchdog.
(translation_unit::priv::~priv): If the usage watchdog says that
the type system is not used, then cleanup the global data
logically owned by the type system.
* include/abg-dwarf-reader.h (read_corpus_from_elf): Make this
return a corpus and set the status by reference using a parameter.
* src/abg-dwarf-reader.cc (read_corpus_from_elf): Implement the
above.
* include/abg-reader.h (read_translation_unit_from_file)
(read_translation_unit_from_buffer)
(read_translation_unit_from_istream): Remove the overloads that do
not return a translation_unit_sptr and that pass it as a
parameter. Only keep the overloads that return a
translation_unit_sptr, forcing users of the API to own a proper
reference on the resulting translation_unit pointer. That is
important to handle the life time of the global data of the type
system that need to be cleared when the last translation unit is
de-allocated.
* src/abg-reader.cc (read_translation_unit_from_input): Make this
return a translation_unit_sptr.
(read_translation_unit_from_file)
(read_translation_unit_from_buffer)
(read_translation_unit_from_istream): Remove the overloads that do
not return a translation_unit_sptr and that pass it as a
parameter. Only keep the overloads that return a
translation_unit_sptr.
(read_to_translation_unit): Make this return a
translation_unit_sptr.
* tests/print-diff-tree.cc (main): Adjust.
* tests/test-diff-dwarf.cc (main): Likewise.
* tests/test-ir-walker.cc (main): Likewise.
* tests/test-read-dwarf.cc (main): Likewise.
* tests/test-read-write.cc (main): Likewise.
* tools/abicompat.cc (main): Likewise.
* tools/abidiff.cc (main): Likewise.
* tools/abidw.cc (main): Likewise.
* tools/abilint.cc (main): Likewise.
Factorize incompatible and subtype changes detection
In abg-comparison.h, there is no function to test if a given
corpus_diff carries incompatible or subtype (after having applied
suppression specifications) ABI changes. So this patch factorizes the
code of abidiff.cc to provide these features to corpus_diff.
* include/abg-comparison.h (corpus_diff::{has_incompatible_changes,
has_net_subtype_changes}): Declare new member functions.
* src/abg-comparison.cc (corpus_diff::{has_incompatible_changes,
has_net_subtype_changes}): Define them.
* abidiff.cc (main): Use the new member functions above.
It appears there are some missing new lines in the diff report.
Fixed thus.
* src/abg-comparison.cc (class_diff::report): The overload of
represent() for instances of var_decl does not emit new lines. So
the caller must ensure a new line is emitted.
Support filtering out just one alias of a function
Suppose a function private_foo() has a symbol private_foo and also a
another one (an alias) named public_foo. Then suppose we want to
filter out sub-type changes to private_foo(). But then we still want
to see changes to public_foo.
This patch does add this feature. The [suppress_function] directive
now has a new (hidden) boolean 'allow_other_aliases' property. When
set to 'yes' or 'true', if the function being looked at has an alias
symbol that does *NOT* match the other properties of the directive,
then the directive doesn't suppress reports for the function. This
new property is set to yes by default.
This means that when a function has got multiple aliases, to suppress
the function, one needs to write a regular expression that matches the
names of aliases. Otherwise the function will not be suppressed.
* include/abg-comparison.h (function_suppression::{get,
set}_allow_other_aliases): Declare new member functions.
* src/abg-comparison.cc
(function_suppression::priv::allow_other_aliases_): New data
member.
(function_suppression::priv::priv): Initialize it to 'true'.
(function_suppression::{get, set}_allow_other_aliases): Define new
member functions.
(read_function_suppression): Parse the new "allow_other_aliases"
property.
(function_suppression::suppresses_function): Update to evaluate
the new 'allow_other_aliases' property when there is a property to
match against some a symbol name of the function.
(corpus_diff::report): Fix the printing of function aliases when
printing sub-type changes to properly emit the plural of the word
'symbol' when the function has several aliases.
* include/abg-ir.h (elf_symbol::get_number_of_aliases): Declare
new member function.
* src/abg-ir.cc (elf_symbol::get_number_of_aliases): Define new
member function.
* doc/manuals/libabigail-concepts.rst: Update manual.
* tests/data/test-diff-dwarf/test5-report.txt: Adjust.
* tests/data/test-diff-suppr/libtest23-alias-filter-v0.so: New
test input.
* tests/data/test-diff-suppr/libtest23-alias-filter-v1.so: Likewise.
* tests/data/test-diff-suppr/test23-alias-filter-0.suppr: Likewise.
* tests/data/test-diff-suppr/test23-alias-filter-1.suppr: Likewise.
* tests/data/test-diff-suppr/test23-alias-filter-2.suppr: Likewise.
* tests/data/test-diff-suppr/test23-alias-filter-3.suppr: Likewise.
* tests/data/test-diff-suppr/test23-alias-filter-4.suppr: Likewise.
* tests/data/test-diff-suppr/test23-alias-filter-report-0.txt: Likewise.
* tests/data/test-diff-suppr/test23-alias-filter-report-1.txt: Likewise.
* tests/data/test-diff-suppr/test23-alias-filter-report-2.txt: Likewise.
* tests/data/test-diff-suppr/test23-alias-filter-report-3.txt: Likewise.
* tests/data/test-diff-suppr/test23-alias-filter-report-4.txt: Likewise.
* tests/data/test-diff-suppr/test23-alias-filter-report-5.txt: Likewise.
* tests/data/test-diff-suppr/test23-alias-filter-v0.c: Likewise.
* tests/data/test-diff-suppr/test23-alias-filter-v1.c: Likewise.
* tests/data/test-diff-suppr/test23-alias-filter-version-script: Likewise.
* tests/data/Makefile.am: Add the new test stuff to source
distribution.
* tests/test-diff-suppr.cc (in_out_spec): Add the tests inputs
above to the list of input to run over.
The report emitted by abidiff now tells the user about the aliases of
the current function, when that function has some sub-type changes.
* include/abg-ir.h (elf_symbol::get_aliases_id_string): Declare
new overload.
* src/abg-ir.cc (elf_symbol::get_aliases_id_string): Define new
overload.
* src/abg-comparison.cc (corpus_diff::report): For functions with
sub-type changes report their aliases. Do not do this if the
function is a constructor or destructor because these almost
always have aliases, at least with GCC and the developer most
certainly has not done anything special for that; she would thus
be uselessly surprised by that remote implementation detail.
* tests/data/test-diff-dwarf/test5-report.txt: Adjust test.
Dodji Seketeli [Mon, 22 Jun 2015 22:16:44 +0000 (00:16 +0200)]
Misc typo fixes
* src/abg-comparison.cc
(corpus_diff::priv::{deleted, added}n_variable_is_suppressed): Fix
a typo.
* tests/data/test-diff-dwarf/test16-syms-only-v0.cc: Fix a typo in
the comments.
* tests/data/test-diff-dwarf/test16-syms-only-v1.cc: Likewise.
Dodji Seketeli [Mon, 22 Jun 2015 09:13:17 +0000 (11:13 +0200)]
Apply suppression specifications to added and removed functions and variables
Until now, specifications for suppressing change reports were applied
only to functions and variables that have sub-type changes. Change
reports about function and variables that were added or removed could
not be suppressed.
This patch makes suppression specifications to apply to added and
removed functions and variables too. They can also apply to function
and variable symbols that are not referenced by any debug info.
The patch also fixes some typo and formatting glitches and updates
some existing tests accordingly.
* include/abg-comparison.h (is_type_suppression)
(is_function_suppression): Declare new functions.
({function, variable}_suppression::change_kind): Declare new enum.
(function_suppression::{parse_change_kind, get_change_kind,
set_change_kind, suppresses_function,
suppresses_function_symbol}): Declare new member functions.
(variable_suppression::{parse_change_kind, get_change_kind,
set_change_kind, suppresses_variable, suppresses_variable,
suppresses_variable_symbol}): Declare new member functions.
(operator{&,|}): Declare new operators for
function_suppression::change_kind and
variable_suppression::change_kind enums.
(corpus_diff::diff_stats::{num_removed_func_filtered_out,
net_num_func_removed, num_added_func_filtered_out,
net_num_func_added, num_removed_vars_filtered_out,
net_num_vars_removed, num_added_vars_filtered_out,
net_num_vars_added, num_removed_func_syms_filtered_out,
num_added_func_syms_filtered_out, net_num_removed_func_syms,
net_num_added_func_syms, num_added_var_syms_filtered_out,
num_removed_vars_filtered_out, net_num_removed_var_syms,
net_num_added_var_syms}): Declare new member functions.
(corpus_diff::diff_stats::num_changed_vars_filtered_out): Renamed
corpus_diff::diff_stats::num_vars_filtered_out into this.
(corpus_diff::diff_stats::num_changed_func_filtered_out): Renamed
corpus_diff::diff_stats::num_func_filtered_out into this.
* src/abg-comparison.cc (is_type_suppression)
(is_function_suppression): Define new
function.
(function_suppression::priv::change_kind): New data member.
(function_suppression::priv): Initialize it.
(function_suppression::{parse_change_kind, get_change_kind,
set_change_kind, suppresses_function,
suppresses_function_symbol}): Define new member functions.
(operator{&,|}): Define new operators for the new
function_suppression::change_kind enum.
(function_suppression::suppresses_diff): Re-write this in terms of
the new function_suppression::suppresses_function() function.
(read_function_suppression): Support reading the new "change_kind"
property.
(variable_suppression::priv::change_kind_): New data member.
(variable_suppression::priv::priv): Initialize it.
(variable_suppression::{parse_change_kind, get_change_kind,
set_change_kind, suppresses_variable,
suppresses_variable_symbol}): Define new member functions.
(is_variable_suppression): Define new function.
(operator{&,|}): Define new operators for
variable_suppression::change_kind enum.
(variable_suppression::suppresses_diff): Re-write in terms of the
new variable_suppression::suppresses_variable function.
(read_variable_suppression): Support reading the new "change_kind"
property.
(corpus_diff::diff_stats::priv::{num_removed_func_filtered_out,
num_added_func_filtered_out, num_removed_vars_filtered_out,
num_added_vars_filtered_out, num_removed_func_syms_filtered_out,
num_added_func_syms_filtered_out,
num_removed_var_syms_filtered_out,
num_added_var_syms_filtered_out}): New data members.
(corpus_diff::diff_stats::priv::num_changed_func_filtered_out):
Renamed the data member num_func_filtered_out into this.
(corpus_diff::diff_stats::priv::num_changed_vars_filtered_out):
Renamed data member num_vars_filtered_out into this.
(corpus_diff::diff_stats::priv::priv): Initialize the new data
members.
(corpus_diff::diff_stats::{num_removed_func_filtered_out,
num_removed_func_filtered_out, net_num_func_removed,
net_num_func_added, num_added_func_filtered_out,
net_num_func_added, num_removed_vars_filtered_out,
num_removed_vars_filtered_out, net_num_vars_removed,
num_added_vars_filtered_out, net_num_vars_added,
num_removed_func_syms_filtered_out,
num_added_func_syms_filtered_out, net_num_removed_func_syms,
net_num_added_func_syms, num_added_var_syms_filtered_out,
num_removed_vars_filtered_out, net_num_removed_var_syms,
net_num_added_var_syms}): Define new member functions.
(corpus_diff::diff_stats::num_changed_func_filtered_out): Renamed
corpus_diff::diff_stats::num_func_filtered_out into this.
(corpus_diff::diff_stats::num_changed_vars_filtered_out): Renamed
corpus_diff::diff_stats::num_vars_filtered_out into this.
(corpus_diff::diff_stats::{net_num_func_changed,
net_num_vars_changed}): Adjust.
(corpus_diff::priv::{suppressed_deleted_fns_,
suppressed_added_fns_, suppressed_deleted_vars_,
suppressed_added_vars_, suppressed_added_unrefed_fn_syms_,
suppressed_deleted_unrefed_fn_syms_,
suppressed_added_unrefed_var_syms_,
suppressed_deleted_unrefed_fn_syms_}): New data members.
(corpus_diff::priv::{apply_suppressions_to_added_removed_fns_vars,
deleted_function_is_suppressed, added_function_is_suppressed,
deleted_variable_is_suppressed, added_variable_is_suppressed,
added_unrefed_fn_sym_is_suppressed,
deleted_unrefed_fn_sym_is_suppressed,
added_unrefed_var_sym_is_suppressed,
deleted_unrefed_var_sym_is_suppressed}): Define member functions.
(function_is_suppressed, variable_is_suppressed): Define new
functions.
(corpus_diff::priv::apply_filters_and_compute_diff_stats): Compute
stats for filtered added or removed functions, variables and their
symbols.
(corpus_diff::priv::emit_diff_stats): Emit diff stats for filtered
added or removed functions, variables and symbols.
(corpus_diff::report): Support suppressed reports about added or
removed functions, variables and symbols. Fixed a typo that was
in there for a while. Note that that fix requires updating some
regression tests, and the part of this patch that touches
regression tests does that.
(apply_suppressions): In the overload for corpus_diff, apply the
suppression to added or removed functions and variables.
* doc/manuals/libabigail-concepts.rst: Update this manual to
reflect the changes above. Also, perform an extensive cleanup of
the manual to introduce more section titles to make it easier to
navigate the document using the table of content.
* tests/data/test-abicompat/test2-var-removed-report-0.txt:
Adjust.
* tests/data/test-diff-dwarf/test0-report.txt: Likewise.
* tests/data/test-diff-dwarf/test12-report.txt: Likewise.
* tests/data/test-diff-dwarf/test18-alias-sym-report-0.txt:
Likewise.
* tests/data/test-diff-dwarf/test19-soname-report-0.txt: Likewise.
* tests/data/test-diff-dwarf/test7-report.txt: Likewise.
* tests/data/test-diff-dwarf/test8-report.txt: Likewise.
* tests/data/test-diff-dwarf/test9-report.txt: Likewise.
* tests/data/test-diff-dwarf/test16-syms-only-report.txt: Likewise.
* tests/data/test-diff-dwarf/test17-non-refed-syms-report-0.txt:
Likewise.
* tests/data/test-diff-dwarf/test28-vtable-changes-report-0.txt:
Likewise.
* tests/data/test-diff-filter/test0-report.txt: Likewise.
* tests/data/test-diff-filter/test01-report.txt: Likewise.
* tests/data/test-diff-filter/test13-report.txt: Likewise.
* test-diff-suppr/test15-suppr-added-fn-v0.o: Add new test
material.
* tests/data/test-diff-filter/test15-0-report.txt: Likewise.
* tests/data/test-diff-filter/test2-report.txt: Likewise.
* tests/data/test-diff-filter/test21-compatible-vars-report-0.txt:
Likewise.
* tests/data/test-diff-filter/test24-compatible-vars-report-1.txt:
Likewise.
* test-diff-suppr/test15-suppr-added-fn-v1.o: Likewise.
* test-diff-suppr/test15-suppr-added-fn-0.suppr: Likewise.
* test-diff-suppr/test15-suppr-added-fn-1.suppr: Likewise.
* test-diff-suppr/test15-suppr-added-fn-2.suppr: Likewise.
* test-diff-suppr/test15-suppr-added-fn-3.suppr: Likewise.
* test-diff-suppr/test15-suppr-added-fn-4.suppr: Likewise.
* test-diff-suppr/test15-suppr-added-fn-report-0.txt: Likewise.
* test-diff-suppr/test15-suppr-added-fn-report-1.txt: Likewise.
* test-diff-suppr/test15-suppr-added-fn-report-2.txt: Likewise.
* test-diff-suppr/test15-suppr-added-fn-report-3.txt: Likewise.
* test-diff-suppr/test15-suppr-added-fn-report-4.txt: Likewise.
* test-diff-suppr/test15-suppr-added-fn-report-5.txt: Likewise.
* test-diff-suppr/test15-suppr-added-fn-v0.cc: Likewise.
* test-diff-suppr/test15-suppr-added-fn-v1.cc: Likewise.
* test-diff-suppr/test16-suppr-removed-fn-v0.o: Likewise.
* test-diff-suppr/test16-suppr-removed-fn-v1.o: Likewise.
* test-diff-suppr/test16-suppr-removed-fn-0.suppr: Likewise.
* test-diff-suppr/test16-suppr-removed-fn-1.suppr: Likewise.
* test-diff-suppr/test16-suppr-removed-fn-2.suppr: Likewise.
* test-diff-suppr/test16-suppr-removed-fn-3.suppr: Likewise.
* test-diff-suppr/test16-suppr-removed-fn-4.suppr: Likewise.
* test-diff-suppr/test16-suppr-removed-fn-report-0.txt: Likewise.
* test-diff-suppr/test16-suppr-removed-fn-report-1.txt: Likewise.
* test-diff-suppr/test16-suppr-removed-fn-report-2.txt: Likewise.
* test-diff-suppr/test16-suppr-removed-fn-report-3.txt: Likewise.
* test-diff-suppr/test16-suppr-removed-fn-report-4.txt: Likewise.
* test-diff-suppr/test16-suppr-removed-fn-report-5.txt: Likewise.
* test-diff-suppr/test16-suppr-removed-fn-v0.cc: Likewise.
* test-diff-suppr/test16-suppr-removed-fn-v1.cc: Likewise.
* test-diff-suppr/test17-suppr-added-var-v0.o: Likewise.
* test-diff-suppr/test17-suppr-added-var-v1.o: Likewise.
* test-diff-suppr/test17-suppr-added-var-0.suppr: Likewise.
* test-diff-suppr/test17-suppr-added-var-1.suppr: Likewise.
* test-diff-suppr/test17-suppr-added-var-2.suppr: Likewise.
* test-diff-suppr/test17-suppr-added-var-3.suppr: Likewise.
* test-diff-suppr/test17-suppr-added-var-4.suppr: Likewise.
* test-diff-suppr/test17-suppr-added-var-report-0.txt: Likewise.
* test-diff-suppr/test17-suppr-added-var-report-1.txt: Likewise.
* test-diff-suppr/test17-suppr-added-var-report-2.txt: Likewise.
* test-diff-suppr/test17-suppr-added-var-report-3.txt: Likewise.
* test-diff-suppr/test17-suppr-added-var-report-4.txt: Likewise.
* test-diff-suppr/test17-suppr-added-var-report-5.txt: Likewise.
* test-diff-suppr/test17-suppr-added-var-v0.cc: Likewise.
* test-diff-suppr/test17-suppr-added-var-v1.cc: Likewise.
* test-diff-suppr/test18-suppr-removed-var-v0.o: Likewise.
* test-diff-suppr/test18-suppr-removed-var-v1.o: Likewise.
* test-diff-suppr/test18-suppr-removed-var-0.suppr: Likewise.
* test-diff-suppr/test18-suppr-removed-var-1.suppr: Likewise.
* test-diff-suppr/test18-suppr-removed-var-2.suppr: Likewise.
* test-diff-suppr/test18-suppr-removed-var-3.suppr: Likewise.
* test-diff-suppr/test18-suppr-removed-var-4.suppr: Likewise.
* test-diff-suppr/test18-suppr-removed-var-report-0.txt: Likewise.
* test-diff-suppr/test18-suppr-removed-var-report-1.txt: Likewise.
* test-diff-suppr/test18-suppr-removed-var-report-2.txt: Likewise.
* test-diff-suppr/test18-suppr-removed-var-report-3.txt: Likewise.
* test-diff-suppr/test18-suppr-removed-var-report-4.txt: Likewise.
* test-diff-suppr/test18-suppr-removed-var-report-5.txt: Likewise.
* test-diff-suppr/test18-suppr-removed-var-v0.cc: Likewise.
* test-diff-suppr/test18-suppr-removed-var-v1.cc: Likewise.
* tests/data/test-diff-suppr/test19-suppr-added-fn-sym-v0.o: New
test input.
* tests/data/test-diff-suppr/test19-suppr-added-fn-sym-v1.o:
Likewise.
* tests/data/test-diff-suppr/test19-suppr-added-fn-sym-0.suppr:
Likewise.
* tests/data/test-diff-suppr/test19-suppr-added-fn-sym-1.suppr:
Likewise.
* tests/data/test-diff-suppr/test19-suppr-added-fn-sym-2.suppr:
Likewise.
* tests/data/test-diff-suppr/test19-suppr-added-fn-sym-3.suppr:
Likewise.
* tests/data/test-diff-suppr/test19-suppr-added-fn-sym-4.suppr:
Likewise.
* tests/data/test-diff-suppr/test19-suppr-added-fn-sym-report-0.txt:
Likewise.
* tests/data/test-diff-suppr/test19-suppr-added-fn-sym-report-1.txt:
Likewise.
* tests/data/test-diff-suppr/test19-suppr-added-fn-sym-report-2.txt:
Likewise.
* tests/data/test-diff-suppr/test19-suppr-added-fn-sym-report-3.txt:
Likewise.
* tests/data/test-diff-suppr/test19-suppr-added-fn-sym-report-4.txt:
Likewise.
* tests/data/test-diff-suppr/test19-suppr-added-fn-sym-report-5.txt:
Likewise.
* tests/data/test-diff-suppr/test19-suppr-added-fn-sym-v0.cc:
Likewise.
* tests/data/test-diff-suppr/test19-suppr-added-fn-sym-v1.cc:
Likewise.
* tests/data/test-diff-suppr/test20-suppr-removed-fn-sym-v0.o:
Likewise.
* tests/data/test-diff-suppr/test20-suppr-removed-fn-sym-v1.o:
Likewise.
* tests/data/test-diff-suppr/test20-suppr-removed-fn-sym-0.suppr:
Likewise.
* tests/data/test-diff-suppr/test20-suppr-removed-fn-sym-1.suppr:
Likewise.
* tests/data/test-diff-suppr/test20-suppr-removed-fn-sym-2.suppr:
Likewise.
* tests/data/test-diff-suppr/test20-suppr-removed-fn-sym-3.suppr:
Likewise.
* tests/data/test-diff-suppr/test20-suppr-removed-fn-sym-4.suppr:
Likewise.
* tests/data/test-diff-suppr/test20-suppr-removed-fn-sym-report-0.txt:
Likewise.
* tests/data/test-diff-suppr/test20-suppr-removed-fn-sym-report-1.txt:
Likewise.
* tests/data/test-diff-suppr/test20-suppr-removed-fn-sym-report-2.txt:
Likewise.
* tests/data/test-diff-suppr/test20-suppr-removed-fn-sym-report-3.txt:
Likewise.
* tests/data/test-diff-suppr/test20-suppr-removed-fn-sym-report-4.txt:
Likewise.
* tests/data/test-diff-suppr/test20-suppr-removed-fn-sym-report-5.txt:
Likewise.
* tests/data/test-diff-suppr/test20-suppr-removed-fn-sym-v0.cc:
Likewise.
* tests/data/test-diff-suppr/test20-suppr-removed-fn-sym-v1.cc:
Likewise.
* tests/data/test-diff-suppr/test21-suppr-added-var-sym-v0.o:
Likewise.
* tests/data/test-diff-suppr/test21-suppr-added-var-sym-v1.o:
Likewise.
* tests/data/test-diff-suppr/test21-suppr-added-var-sym-0.suppr:
Likewise.
* tests/data/test-diff-suppr/test21-suppr-added-var-sym-1.suppr:
Likewise.
* tests/data/test-diff-suppr/test21-suppr-added-var-sym-2.suppr:
Likewise.
* tests/data/test-diff-suppr/test21-suppr-added-var-sym-3.suppr:
Likewise.
* tests/data/test-diff-suppr/test21-suppr-added-var-sym-4.suppr:
Likewise.
* tests/data/test-diff-suppr/test21-suppr-added-var-sym-report-0.txt:
Likewise.
* tests/data/test-diff-suppr/test21-suppr-added-var-sym-report-1.txt:
Likewise.
* tests/data/test-diff-suppr/test21-suppr-added-var-sym-report-2.txt:
Likewise.
* tests/data/test-diff-suppr/test21-suppr-added-var-sym-report-3.txt:
Likewise.
* tests/data/test-diff-suppr/test21-suppr-added-var-sym-report-4.txt:
Likewise.
* tests/data/test-diff-suppr/test21-suppr-added-var-sym-report-5.txt:
Likewise.
* tests/data/test-diff-suppr/test21-suppr-added-var-sym-v0.cc:
Likewise.
* tests/data/test-diff-suppr/test21-suppr-added-var-sym-v1.cc:
Likewise.
* tests/data/test-diff-suppr/test22-suppr-removed-var-sym-v0.o:
Likewise.
* tests/data/test-diff-suppr/test22-suppr-removed-var-sym-v1.o:
Likewise.
* tests/data/test-diff-suppr/test22-suppr-removed-var-sym-0.suppr:
Likewise.
* tests/data/test-diff-suppr/test22-suppr-removed-var-sym-1.suppr:
Likewise.
* tests/data/test-diff-suppr/test22-suppr-removed-var-sym-2.suppr:
Likewise.
* tests/data/test-diff-suppr/test22-suppr-removed-var-sym-3.suppr:
Likewise.
* tests/data/test-diff-suppr/test22-suppr-removed-var-sym-4.suppr:
Likewise.
* tests/data/test-diff-suppr/test22-suppr-removed-var-sym-report-0.txt:
Likewise.
* tests/data/test-diff-suppr/test22-suppr-removed-var-sym-report-1.txt:
Likewise.
* tests/data/test-diff-suppr/test22-suppr-removed-var-sym-report-2.txt:
Likewise.
* tests/data/test-diff-suppr/test22-suppr-removed-var-sym-report-3.txt:
Likewise.
* tests/data/test-diff-suppr/test22-suppr-removed-var-sym-report-4.txt:
Likewise.
* tests/data/test-diff-suppr/test22-suppr-removed-var-sym-report-5.txt:
Likewise.
* tests/data/test-diff-suppr/test22-suppr-removed-var-sym-v0.cc:
Likewise.
* tests/data/test-diff-suppr/test22-suppr-removed-var-sym-v1.cc:
Likewise.
* tests/data/Makefile.am: Add the new test materials above to source
distribution.
* tests/test-diff-suppr.cc (in_out_specs): Add the new tests
material above to the list of test inputs this harness has to run
over.
Dodji Seketeli [Mon, 22 Jun 2015 09:17:38 +0000 (11:17 +0200)]
Do not compare static data members when comparing types
The comparison code was too eager in comparing class types because it
was comparing static data members in the process. This was causing
some spurious false positives about functions or variables sub-type
changes. This patch fixes that by not comparing static data members
when comparing class types.
* include/abg-ir.h (class_decl::get_non_static_data_members):
Declare new data members.
* src/abg-comparison.cc
(class_diff::ensure_lookup_tables_populated): Only look at
non-static data members.
(compute_diff): In the overload for class_decl, only compare
non-static data members.
* src/abg-hash.cc (class_decl::hash::operator()): Do not hash
static data members members hashing a class_decl.
* src/abg-ir.cc (class_decl::priv::data_members_): New data
member.
(class_decl::priv::priv): When initializing data members, store
the non-static data members on the side, in the new
class_decl::priv::non_static_data_members_ data member.
(class_decl::get_non_static_data_members): Define member function.
(class_decl::add_data_member): Store the non-static data members
on the side in class_decl::priv::non_static_data_members_.
(equals): In the overload for class_decl, do not take in account
static data members when running the comparison.
* tests/data/test-diff-dwarf/test7-report.txt: Adjust.
* tests/data/test-diff-filter/test12-report.txt: Adjust.
Dodji Seketeli [Mon, 22 Jun 2015 22:18:48 +0000 (00:18 +0200)]
Add a --suppr short alias to the --suppressions option of abidiff
* tools/abidiff.cc (display_usage): Add a help string for the new
--suppr option.
(parse_command_line): Support the --suppr option which is an alias
for --suppressions.
Dodji Seketeli [Tue, 23 Jun 2015 10:30:27 +0000 (12:30 +0200)]
Enable large file support
Mattias Klose reported that building libabigail in the Debian build
system raised an error because the libabigail binaries were built
without the Large File Support (LFS), as described by
https://lintian.debian.org/tags/binary-file-built-without-LFS-support.html.
This just calls the configure macro AC_SYS_LARGEFILE for that.
* configure.ac: Call the AC_SYS_LARGEFILE autoconf macro.
* config.h.in: Update.
Dodji Seketeli [Tue, 23 Jun 2015 10:21:30 +0000 (12:21 +0200)]
Do not build zip archive support by default
Until now, the zip archive support was automatically built if the
libzip dependent library was installed on the system at configure
time. As we are planning to remove the zip support, let's first
disable the support by default, even if libzip is installed at
configure time.
* configure.ac: By default, unconditionally disable the
zip-archive support.
Dodji Seketeli [Tue, 23 Jun 2015 10:06:54 +0000 (12:06 +0200)]
Put the man pages of the binaries in section 1
I was clueless about the right sections for the man pages of the parts
of the libabigail. But then Matthias Klose of Debian and Ubuntu fame
rightfully suggested that the man pages of the binaries should be in
section 1 (user commands) and the man page of the library should be in
section 7 (Miscellaneous).
This patch does that.
* doc/manuals/Makefile.am(section1_manpages, section7_manpages):
Two new variables to contain the man page names per section.
(manpages): Set this variable to $section1_manpages and $section7_manpages.
(install-man-and-info-doc): In this rule, create the destination
directories for section 1 and 7 and copy the right man pages in
their right directory.
* doc/manuals/conf.py (man_pages): Generate the binary man pages
into section 1 and the libabigail man page into section 7.
Dodji Seketeli [Tue, 23 Jun 2015 09:36:01 +0000 (11:36 +0200)]
Sort deleted/added variables and symbols before emitting report
Reports about added/deleted variables and symbols changes were still
not sorted, causing differences in output for abidiff depending on the
platform it's run on.
This patch fixes that.
* src/abg-comparison.cc (sort_string_var_ptr_map)
(sort_string_elf_symbol_map): Define new static functions.
(var_comp, elf_symbol_comp): Define new comparison functors.
(corpus_diff::report): Sort the deleted variables, added
variables, deleted function symbols, added function symbols,
deleted variable symbols, and added variable symbols before
walking them to emit reports.
Dodji Seketeli [Mon, 22 Jun 2015 23:09:53 +0000 (01:09 +0200)]
Fix a thinko in the comparison code
When a member function is wrongly considered as being added, then
either the new member function doesn't have a symbol name (linkage
name) or it has one, and it was already present in the first version
of the binary.
What was I thinking ... so I hope this shot is better.
* src/abg-comparison.cc
(class_diff::ensure_lookup_tables_populated): Ensure that when a
member function is wrongly considered as being added, then either
the new member function doesn't have a symbol name (linkage name)
or it has one, and it was already present in the first version of
the binary.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
# Veuillez saisir le message de validation pour vos
modifications. Les lignes # commençant par '#' seront ignorées, et
un message vide abandonne la validation. # Sur la branche
fix-master # Votre branche est à jour avec 'origin/master'. # #
Modifications qui seront validées : # modified:
src/abg-comparison.cc # # Modifications qui ne seront pas validées
: # modified: tools/abidw.cc # # Fichiers non suivis: # abidw.abi
# build/ # depcomp # missing # patch-edited.txt # patch.txt #
prtests/ # test-driver # # ------------------------ >8
------------------------ # Ne touchez pas à la ligne ci-dessus #
Tout se qui suit sera éliminé.
diff --git a/src/abg-comparison.cc b/src/abg-comparison.cc
index 14208f5..ef7c6c9 100644
--- a/src/abg-comparison.cc
+++ b/src/abg-comparison.cc
@@ -7419,8 +7419,8 @@ class_diff::ensure_lookup_tables_populated(void) const
inserted_member_fns().begin();
i != inserted_member_fns().end();
++i)
- if (i->second->get_symbol()
- && f->lookup_function_symbol(i->second->get_symbol()->get_name(),
+ if (!i->second->get_symbol()
+ || f->lookup_function_symbol(i->second->get_symbol()->get_name(),
i->second->get_symbol()->get_version().str()))
to_delete.push_back(i->first);
Dodji Seketeli [Sun, 7 Jun 2015 14:55:29 +0000 (16:55 +0200)]
Build libabigail tools as position-independent code
It turned out the hardened Rawhide build is failing if I don't this.
* tools/Makefile.am: Compile the binaries here with -fPIC. Note
that the library libabigail.la is built with libtool which already
takes care of this, so no need to worry about this for
libabigail.la.
Dodji Seketeli [Sun, 7 Jun 2015 12:24:13 +0000 (14:24 +0200)]
Avoid infinite loop in elf_symbol::get_alias_from_name()
It turns out we forget to test for the right exit condition while looping
over symbol aliases, leading to an infinite loop.
* src/abg-ir.cc (elf_symbol::get_alias_from_name)
(elf_symbol::get_alias_which_equals): Test for the next alias
pointing to the main symbol, in the loop exit condition.
Dodji Seketeli [Thu, 4 Jun 2015 09:51:27 +0000 (11:51 +0200)]
Change the linkage name only when necessary
Up to now the linkage name of a declaration was set to the name of
it's underlying symbol. This patch changes that to instead honour
what the DW_AT_linkage_name DWARF property says, unless the value of
that property is either missing or wrong.
* include/abg-ir.h (elf_symbol::get_alias_from_name): Declare new
member function.
* src/abg-ir.cc (elf_symbol::get_alias_from_name): Define it.
* src/abg-dwarf-reader.cc (build_var_decl, build_function_decl):
Once the linkage name is supposed to contain the value of the
DW_AT_linkage_name attribute, set it the name of the underlying
symbol only if value of DW_At_linkage_name is missing or different
from the names of all the aliases of the underlying symbol.
* tests/data/test-read-dwarf/test2.so.abi: Adjust.
Dodji Seketeli [Thu, 4 Jun 2015 08:22:48 +0000 (10:22 +0200)]
Cleanup logic in class_diff::ensure_lookup_tables_populated()
At some point, it appeared that some bogus DWARF wouldn't tie a
function decl with its underlying symbol, but subsequent version of
the DWARF emitter (in the second subject of the diff) would correctly
link the function decl with its underlying symbol.
Comparing the two versions of function decl could then wrongly make
the class_diff code think that the function decl was added to the
binary. I later added code that checks that for every supposedly
added function, its symbol must *NOT* have been present in the first
version of the binary. I added some similar code for the removed
symbols case. And that added code seems to work OK.
But then there is an even more ancient hacky attempt at handling the
same case that is no more warranted. This patch removes it.
* src/abg-comparison.cc
(class_diff::ensure_lookup_tables_populated): Remove the code that
tries to lookup allegedly added functions from the set of deleted
ones, by using the pretty printed name of the function. Handling
the case of a function decl not correctly tied to it symbol is
handled my generically a bit later in this function.
Dodji Seketeli [Thu, 4 Jun 2015 08:20:13 +0000 (10:20 +0200)]
Report possible changes in the set of aliases of a symbol.
* src/abg-comparison.cc (function_decl_diff::report): Report
a change in the aliases of the symbols of a function; note that
everything else but have stayed equal in the function.
Dodji Seketeli [Thu, 4 Jun 2015 07:22:02 +0000 (09:22 +0200)]
Report vtable changes in top-level function change reports
Up to know we were not reporting vtable changes on top-level function
change reports. This patch adds that feature.
* src/abg-comparison.cc (function_decl_diff::report): Report about
virtual-ness and vtable offset changes.
* tests/data/test-diff-dwarf/test28-vtable-changes-report-0.txt:
New test input file.
* tests/data/test-diff-dwarf/test28-vtable-changes-v{0,1}.o: New
test input binaries.
* tests/data/test-diff-dwarf/test28-vtable-changes-v{0,1}.cc:
Source code of the input binaries above.
* tests/data/Makefile.am: Add the new test input above to source
distribution.
* tests/test-diff-dwarf.cc (in_out_specs): Add the new test input
above to the list of input this test harness has to run over.
Dodji Seketeli [Wed, 3 Jun 2015 17:02:13 +0000 (19:02 +0200)]
Support new 'accessed_through' suppression property
It turned out it's important to be able to suppress changes about
types that are reachable from a function parameter only through e.g, a
pointer or a reference, so that only changes types that are reachable
directly from a function parameter are emitted.
This patch adds that feature.
While doing this, I noticed this: Suppose a diff node D2 is marked as
being redundant with a diff node D1 seen previously. So only D1 is
reported; D2 is not, because it's been filtered out, because it's
redundant with D1. But then suppose D1 is filtered out, due to a
suppression specification. At that point, D2 should not be marked
redundant anymore, and should be reported.
Of course, the code before this patch was wrongly filtering D2 *and*
D1 out. So this patch fixes that.
* include/abg-comparison.h (enum type_suppression::reach_kind):
Define new enum.
(type_suppression::{get_consider_reach_kind,
set_consider_reach_kind, get_reach_kind,
mark_last_diff_visited_per_class_of_equivalence,
clear_last_diffs_visited_per_class_of_equivalence,
get_last_visited_diff_of_class_of_equivalence}): Declare new
member functions.
* src/abg-comparison.cc (diff_has_ancestor_filtered_out)
(read_suppression_reach_kind): Define static function.
(type_suppression::priv::{consider_reach_kind_, reach_kind_}):
Define new data members.
(type_suppression::priv::priv): Take a new reach_kind parameter.
(type_suppression::type_suppression): Adjust to new prototype of
priv constructor.
(type_suppression::{get_consider_reach_kind,
set_consider_reach_kind, get_reach_kind, set_reach_kind}): Define
new member functions.
(type_suppression::suppresses_diff): Interpret the result of
type_suppression::get_reach_kind() to determine if the suppression
specification suppresses a given diff node.
(read_type_suppression): Support reading the content of the
"accessed_through" property.
(diff_context::priv::last_visited_diff_node_): New data member.
(diff_context::{mark_last_diff_visited_per_class_of_equivalence,
clear_last_diffs_visited_per_class_of_equivalence,
get_last_visited_diff_of_class_of_equivalence}): Define new data
members.
(redundancy_marking_visitor::visit_begin): So if the current diff
node has already been visited, but if the previously visited node
has been filtered out, then do not mark this node as being
redundant. And mark the current diff node as being the last
visited one in its class of equivalence.
(categorize_redundancy): Clear the map of diff nodes visited per
class of equivalence.
* doc/manuals/libabigail-concepts.rst: Document the new
'accessed_through' property.
* tests/data/test-diff-suppr/test13-suppr-through-pointer-0.suppr:
New test input data.
* tests/data/test-diff-suppr/test13-suppr-through-pointer-report-{0,1}.txt:
Likewise.
* tests/data/test-diff-suppr/libtest13-suppr-through-pointer-v{0,1}.so:
New test input binaries.
* tests/data/test-diff-suppr/test13-suppr-through-pointer-v{0,1}.cc:
Source code of the test input binaries above.
* tests/data/test-diff-suppr/test14-suppr-non-redundant-0.suppr:
New test input data.
* tests/data/test-diff-suppr/test14-suppr-non-redundant-report-0.txt:
Likewise.
* tests/data/test-diff-suppr/test14-suppr-non-redundant-v{0,1}.o:
New test input binaries.
* tests/data/test-diff-suppr/test14-suppr-non-redundant-v{0,1}.cc:
Source code of the binaries above.
Dodji Seketeli [Wed, 3 Jun 2015 08:44:07 +0000 (10:44 +0200)]
Fix redundancy marking for change of types used directly
If a type T is used directly (i.e, not through a pointer or reference)
as a function parameter or as a base class, a change in T should never
be marked as redundant in that context. Otherwise, the change in that
context might be filtered out, possibly hiding real ABI incompatible
changes.
This patch implements this policy.
Also, it turned out in some circumstances, we where marking the first
visited diff node of a given class of equivalence of nodes as being
redundant, while we should only mark the *subsequently* visited nodes
of that class of equivalence as visited. The patch also fixes that.
* include/abg-comparison.h (pointer_map): Make this be a map of
{size_t, size_t} pairs, rather than {size_t, bool}, so that each
pointer in the map can be associated to another one.
(diff_context::diff_has_been_visited): Return the pointer to the
first diff node of the equivalence class that has been visited.
* src/abg-comparison.cc (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):
Define new static functions.
(diff_context::diff_has_been_visited): Return the pointer to the
first diff node of the equivalence class that has been visited.
(diff_context::mark_diff_as_visited): Save the pointer to the
first diff node of a given class of equivalence that has been
visited.
(redundancy_marking_visitor::visit_begin): If a diff node is a
child node of a function parameter diff or base diff node and if
it's not a pointer or reference diff node, then do not mark it as
redundant. Also, make sure to not mark the first diff node of a
given class of equivalence that has been visited, as redundant;
only the other subsequent nodes should be marked redundant; we
were hitting this case because of an optimization that makes
equivalent class diff nodes to share their private (pimpl) data.
* tests/data/test-diff-filter/test29-finer-redundancy-marking-v{0,1}.o:
New test input binaries.
* tests/data/test-diff-filter/test29-finer-redundancy-marking-v{0,1}.cc:
Source code of the new test input binaries above.
* tests/data/test-diff-filter/test29-finer-redundancy-marking-report-0.txt:
New test input.
* tests/data/Makefile.am: Add the new test material above to the
source distribution.
* tests/test-diff-filter.cc (in_out_specs): Make this test harness
run over the additional test input above.
* tests/data/test-diff-suppr/test5-fn-suppr-report-0.txt: Adjust.
Dodji Seketeli [Tue, 2 Jun 2015 10:26:11 +0000 (12:26 +0200)]
Fix detection of local changes in base classes
It appears we were flagging too many base class changes as local.
That was preventing some change category propagation through base
class diff nodes. This patch fixes that.
* abg-ir.cc (equals): In the overload of class_decl::base_spec, if
the underlying class carries changes, then do not flag these
changes as local for the class_decl::base_spec.
* tests/data/test-diff-dwarf/test27-local-base-diff-v{0,1}.o: New
test input binaries.
* tests/data/test-diff-dwarf/test27-local-base-diff-v{0,1}.cc: Source
code for the test input binaries above.
* tests/data/test-diff-dwarf/test27-local-base-diff-report.txt:
New test input.
* tests/data/Makefile.am: Add the test inputs above to source
distribution.
Dodji Seketeli [Mon, 1 Jun 2015 22:07:02 +0000 (00:07 +0200)]
Fix symbols comparison
While working on something else, I noticed that the code for handling
copying symbols (and their aliases) was broken, and so comparing two
symbols which main name were different by which had aliases that were
equal was wrongly resulting in the two symbol being different. I think
we shouldn't actually copy symbols and their aliases. Once a symbol
is allocated, interested code should just manipulate that symbol by
address rather than by value an thus do away with the copying.
The patch does that, essentially. In the implementation of a symbol,
the aliases as well as the main symbol are now weak pointers, rather
than naked pointers. Numerous API entry points that were taking
containers of elf_symbol (and were copying elf_symbols over) are not
taking containers of smart pointers to elf_symbol. Copying of
instances of elf_symbol is now thus disabled.
As a result many tests that were exercising elf_symbols (with alias)
comparison have been updated.
As a result, many empty sub-result of PR libabigail/PR17948 are now
fixed.
* include/abg-ir.h (elf_symbol_wptr): New typedef.
(elf_symbol): Make the constructors and assignment operator
private. The type can neither be copied nor created with the new
operator.
(elf_symbol::create): New static member function.
(elf_symbol::{get_main_symbol, get_next_alias, add_alias}):
Adjust.
( compute_aliases_for_elf_symbol): Likewise.
(elf_symbol::operator=): Make this private.
(elf_symbol::get_alias_which_equals): Declare new member function.
* src/abg-comp-filter.cc (function_name_changed_but_not_symbol):
Adjust.
* src/abg-comparison.cc
(class_diff::ensure_lookup_tables_populated): Adjust.
* src/abg-corpus.cc
(corpus::priv::build_unreferenced_symbols_tables): Likewise.
* include/abg-dwarf-reader.h (lookup_symbol_from_elf)
(lookup_public_function_symbol_from_elf): Adjust.
* src/abg-dwarf-reader.cc (lookup_symbol_from_sysv_hash_tab)
(lookup_symbol_from_gnu_hash_tab, lookup_symbol_from_elf_hash_tab)
(lookup_symbol_from_symtab, lookup_symbol_from_elf)
(lookup_public_function_symbol_from_elf)
(lookup_public_variable_symbol_from_elf): Adjust.
(read_context::lookup_elf_symbol_from_index): Likewise.
(read_context::lookup_elf_fn_symbol_from_address): Likewise.
(read_context::lookup_elf_var_symbol_from_address): Likewise.
(read_context::lookup_public_function_symbol_from_elf): Likewise.
(read_context::lookup_public_variable_symbol_from_elf): Likewise.
(read_context::load_symbol_maps): Likewise.
(build_var_decl, build_function_decl): Likewise.
* src/abg-ir.cc (elf_symbol::priv::{main_symbol_, next_alias_}):
Change the type of these from elf_symbol* to elf_symbol_wptr.
(elf_symbol::priv::priv): Adjust.
(elf_symbol::{create, get_alias_which_equals}): Define new functions.
(textually_equals): Likewise.
(elf_symbol::{get_main_symbol, is_main_symbol, get_next_alias,
add_alias}): Adjust to return or take elf_symbol_sptr type, rather
than a elf_symbol* one.
(elf_symbol::{get_aliases_id_string, does_alias}): Adjust.
(compute_alias_for_elf_symbol): Likewise.
(elf_symbol::operator==): Two symbols A and B are now equal if A
has at least one alias that is textually equal to B.
(equals): In the overload for function_decls, in the part where we
compare the decl_base part of the functions without considering
their decl names, we now also omit considering their linkage
names, because we compared they symbols before.
* tools/abisym.cc (main): Adjust.
* tests/data/test-diff-dwarf/test12-report.txt: Adjust.
* tests/data/test-diff-dwarf/test12-report.txt: Adjust.
* tests/data/test-diff-dwarf/test18-alias-sym-report-0.txt: Adjust.
* tests/data/test-diff-dwarf/test8-report.txt: Adjust.
* tests/data/test-diff-filter/test10-report.txt: Adjust.
* tests/data/test-diff-filter/test13-report.txt: Adjust.
* tests/data/test-diff-filter/test2-report.txt: Adjust.
* tests/data/test-diff-filter/test20-inline-report-0.txt: Adjust.
* tests/data/test-diff-filter/test20-inline-report-1.txt: Adjust.
* tests/data/test-diff-filter/test9-report.txt: Adjust.
Support specifying data member insertion in suppressions
This patch is for supporting this kind of things:
[suppress_type]
name = S
has_data_member_inserted_between = {8, end}
or:
[suppress_type]
name = S
has_data_members_inserted_between = {{8, 31}, {64, end}}
or:
[suppress_type]
name = S
has_data_members_inserted_at = offset_after(member0)
How cool is that, heh?
Anyway, to do this, the patch adds support for tuple values (i.e,
lists of values) in INI files.
Then on top of that the patch adds support for the specific
has_data_member_inserted_between, has_data_members_inserted_between
and has_data_members_inserted_at properties.
* include/abg-comparison.h (type_suppression::insertion_range):
Declare new type.
(type_suppression::insertion_ranges): Declare new typedef.
(type_suppression::{s,g}et_data_member_insertion_ranges): Declare
new member functions.
(is_integer_boundary, is_fn_call_expr_boundary): Declare new
functions.
(type_suppression::insertion_range::{boundary, integer_boundary,
fn_call_expr_boundary}): Define new types.
* src/abg-comparison.cc:
(struct type_suppression::insertion_range::priv): New type.
(type_suppression::insertion_range::{insertion_range, begin,
end}): Define new member functions.
(type_suppression::priv::insertion_ranges_): Add data member.
(type_suppression::{s,g}et_data_member_insertion_ranges): Define
new member functions.
(type_suppression::insertion_range::boundary::priv): Define new
type.
(type_suppression::insertion_range::boundary::{boundary,
~boundary}): Define new member functions.
(type_suppression::insertion_range::integer_boundary::priv):
Define new type.
(type_suppression::insertion_range::integer_boundary::{integer_boundary,
as_integer, operator int, ~integer_boundary}): Define member
functions.
(type_suppression::insertion_range::fn_call_expr_boundary::priv):
Define new type.
(type_suppression::insertion_range::fn_call_expr_boundary::{fn_call_expr_boundary,
as_function_call_expr, operator ini::function_call_expr_sptr}):
Define new member functions.
(type_suppression::insertion_range::{create_integer_boundary,
type_suppression::insertion_range::create_fn_call_expr_boundary,
type_suppression::insertion_range::eval_boundary}): Define new
member functions.
(is_integer_boundary, is_fn_call_expr_boundary): Define new
functions.
(read_type_suppression, read_function_suppression)
(read_variable_suppression): Support the new kinds of
property-related types. Aslo, in read_type_suppression, support
the new properties has_data_member_inserted_at,
has_data_member_inserted_between and
has_data_members_inserted_between.
(type_suppression::suppresses_diff): If we are looking at a type
diff node that has inserted data members, evaluate the insertion
ranges of the current type_suppression and see if they match the
inserted data members.
* include/abg-ini.h (property, simple_property, property_value)
(string_property_value, tuple_property_value, function_call_expr):
Declare new types.
(property_sptr, property_value_sptr, string_property_value_sptr)
(tuple_property_value_sptr): Declare new typedefs.
(is_string_property_value, is_tuple_property_value)
(is_simple_property, is_tuple_property, read_function_call_expr):
Declare new functions.
* src/abg-ini.cc (char_is_white_space, char_is_comment_start)
(char_is_delimiter, char_is_property_value_char)
(char_is_section_name_char, char_is_property_name_char)
(char_is_comment_start, char_is_white_space)
(remove_trailing_white_spaces, is_string_property_value)
(is_tuple_property_value, is_simple_property, is_tuple_property)
(write_property_value, char_is_function_name_char)
(char_is_function_argument_char): Define new functions.
(property::priv, tuple_property_value::priv)
(simple_property::priv, tuple_property::priv): Define new types.
(property::{property, get_name, set_name, ~property}): Define new
member functions.
(struct property_value::priv): Define new type.
(property_value::{property_value, get_kind, operator const
string&(), ~property_value}): Define new member functions.
(struct string_property_value::priv): Define new type.
(string_property_value::{string_property_value, set_content,
as_string, operator string()}, ~string_property_value): Define new
member functions.
(tuple_property_value::{tuple_property_value, get_value_items,
~tuple_property_value, as_string}): Likewise.
(simple_property::{simple_property, get_value, set_value,
~simple_property}): Likewise.
(tuple_property::{tuple_property, set_value, get_value}):
Likewise.
(config::section::find_property): Adjust return type.
(read_context::{char_is_delimiter, char_is_property_value_char,
char_is_section_name_char, char_is_property_name_char,
char_is_comment_start, char_is_white_space}): Remove these from
here as they got moved them to be non-member functions above.
(read_context::read_property_value): Return a property_value_sptr
and do not take any parameter anymore.
(read_context::{read_string_property_value,
read_tuple_property_value, read_function_name,
read_function_argument, read_function_call_expr}): Define new
member functions.
(read_context::read_property): Adjust return type. Also, change to read
the different new kinds of properties values.
(function_call_expr::priv): Define new type.
(function_call_expr::{function_call_expr, get_name,
get_arguments}): New member functions.
(read_context::read_section): Adjust.
(write_property, write_section): Adjust.
* tests/data/test-diff-suppr/libtest{11,12}-add-data-member-v{0,1}.so:
New test input binaries.
* tests/data/test-diff-suppr/test{11,12}-add-data-member-{0,1}.suppr:
New input suppression files.
* tests/data/test-diff-suppr/test11-add-data-member-{2,3,4}.suppr:
Add new test input files.
* tests/data/test-diff-suppr/test{11,12}-add-data-member-report-{0,1}.txt:
New reference output files.
* tests/data/test-diff-suppr/test12-add-data-member-report-2.txt:
Likewise.
* tests/data/test-diff-suppr/test{11,12}-add-data-member-v{0,1}.cc:
Source code for the new binaries above.
* tests/test-diff-suppr.cc (in_out_specs): Add new test inputs.
* tests/data/Makefile.am: Add the new test related files above to
source distribution.
* doc/manuals/libabigail-concepts.rst: Document the new properties
has_data_member_inserted_at, has_data_member_inserted_between and
has_data_members_inserted_between.
Dodji Seketeli [Sun, 24 May 2015 21:17:54 +0000 (23:17 +0200)]
Make indexes of function parameters start at 1
This patch make indexes of a function parameters start at 1, rather at
0 like they used to be. Actually, for member functions, the
artificial implicit 'this' pointer parameter starts at 0. In that
case, the first non-implicit parameter starts at 1 too, then.
The biggest part of the patch adjusts the numerous test cases that are
impacted.