Code of the form
bool x = expression ? true : false;
can be written more concisely as
bool x = expression;
This patch does this. There are no occurences of "? false : true".
* src/abg-corpus.cc (corpus::priv::build_unreferenced_symbols_tables):
Eliminate redundant conditional operator.
* src/abg-dwarf-reader.cc (build_reference_type): Ditto.
* src/abg-reader.cc (read_static): Ditto.
(read_is_artificial): Ditto. (build_function_parameter):
Ditto. (build_function_decl): Ditto.
(build_qualified_type_decl): Ditto.
(build_reference_type_def): Ditto.
Reviewed-by: Matthias Maennich <maennich@google.com>
Signed-off-by: Giuliano Procida <gprocida@google.com>
This patch removes some excess blank lines and a space after the
prefix ++ operator.
* src/abg-suppression.cc: Eliminate double blank lines.
(read_parameter_spec_from_string): Eliminate space between
++ operator and its operand.
Reviewed-by: Matthias Maennich <maennich@google.com>
Signed-off-by: Giuliano Procida <gprocida@google.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
By sorting the corpora output, we achieve determinism for the emitted
XML file across multiple runs of abidw.
For that to happen, change the collection of translation units to a
std::set (instead of std::vector), sorted by absolute path name.
Test data needed adjustments, but changes are fully compatible.
* include/abg-fwd.h: remove translation_units fwd declaration.
* include/abg-ir.h (struct shared_translation_unit_comparator):
Define new class.
(translation_units): Define new typedef.
* src/abg-corpus.cc (corpus::add): do checked insert into the
translation_units set (rather than vector::push_back)
* tests/data/test-annotate/test13-pr18894.so.abi: Adjust test data.
* tests/data/test-annotate/test14-pr18893.so.abi: Likewise.
* tests/data/test-annotate/test15-pr18892.so.abi: Likewise.
* tests/data/test-annotate/test17-pr19027.so.abi: Likewise.
* tests/data/test-annotate/test18-pr19037-libvtkRenderingLIC-6.1.so.abi: Likewise.
* tests/data/test-annotate/test19-pr19023-libtcmalloc_and_profiler.so.abi: Likewise.
* tests/data/test-annotate/test20-pr19025-libvtkParallelCore-6.1.so.abi: Likewise.
* tests/data/test-annotate/test21-pr19092.so.abi: Likewise.
Signed-off-by: Matthias Maennich <maennich@google.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Reorder the test definition to first start expensive tests and later on
start tests with short runtime. This optimizes the 'make check' runtime
by starting the tests on the critical path.
* tests/Makefile.am(TESTS): split up in expensive and non
expensive tests, sort the expensive ones by runime, the cheap
ones alphabetically
Signed-off-by: Matthias Maennich <maennich@google.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Commit a9f5fb4089 ("Add --no-write-default-sizes option.") introduced
a new test variant for test-types-stability that is actually independent
of the original test case in terms of execution. Hence it can be
expressed as a separate test case. So, do that by parametrizing the
test_task struct with a new no_default_sizes flag and schedule a
separate test case in the main loop.
That test runs now ~twice as fast dropping from roughly 20s on my
machine to 10s. That effectively removes it from the critical path of
make check, which is now back to about 15s on my machine with my
configuration.
* tests/test-types-stability.cc (test_task): add field no_default_sizes
(test_task::perform) Switch on the new flag to test a different
behaviour.
(main): Schedule an additional test case to test with the new flag.
Cc: Mark Wielaard <mark@klomp.org>
Signed-off-by: Matthias Maennich <maennich@google.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
G++ 4.8.5 doesn't allow a function template specialization to appear
in a namespace that is different from the namespace where the function
template was declared. Also, in that namespace, the name of the
specialized function template must be non-fully-qualified.
Fixed thus.
* include/abg-libxml-utils.h (build_sptr<xmlTextReader>): Wrap
this specialization in the namespace sptr_utils and do away with
the sptr_utils qualifier.
* include/abg-regex.h (build_sptr<regex_t>): Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
The code to build the symbol whitelist regex uses things like seekp
and tellp to generate regexes like "^foo$|^bar$".
This patch simplifies the code, for further enhancement, resulting in
generated regexes like "^(foo|bar)$".
There should be no change in behaviour, unless whitelisted symbol
names contain special regex characters.
* include/abg-regex.h (generate_from_strings): Declare new
function to build a regex from some strings, representing a
membership test.
* src/abg-regex.cc (generate_from_strings): Implement new
function to build a regex from some strings, representing a
membership test, in a straightfoward fashion.
* src/abg-tools-utils.cc
(gen_suppr_spec_from_kernel_abi_whitelists): Replace
regex-building code with a call to generate_from_strings.
* tests/test-kmi-whitelist.cc: Update regexes in test.
Signed-off-by: Giuliano Procida <gprocida@google.com>
The header file abg-sptr-utils.h contains generic things relating to
shared pointers. It also contains shared pointer typedefs (in the
sptr_utils namespace) and template specialisations for XML types.
The last of these more naturally belong in abg-libxml-utils.h (and in
the xml namespace). This patch moves them.
There are no behavioural changes.
* include/abg-sptr-utils.h: Remove reader_sptr and
xml_char_sptr typedefs, from namespace
sptr_utils. (build_sptr): Remove corresponding template
function specialisations for these types.
* include/abg-libxml-utils.h: Add reader_sptr and
xml_char_sptr typedefs, to namespace xml. (build_sptr): Add
corresponding template function specialisations for these
types.
Signed-off-by: Giuliano Procida <gprocida@google.com>
As a prelude to adding wrapper and helper functions for regex
functionality, it makes sense to move the existing regex code (the
shared pointer type and its specialised deleter) to their own files.
This patch does this and also moves various entities into a new
namespace, abigail::regex. It removes the file abg-sptr-utils.cc which
only contained regex things.
There are no behavioural changes.
* include/Makefile.am: Add abg-regex.h.
* src/Makefile.am: Remove abg-sptr-utils.h, add abg-regex.cc
* include/abg-sptr-utils.h (regex_t_sptr): Remove this
typedef, from namespace abigail::sptr_utils.
(regex_t_deleter): Remove this struct, from namespace
abigail::sptr_utils. (build_sptr): Remove these template
specialisations, in duplicate, for regex_t_sptr.
* include/abg-regex.h: New file, introduces namespace
abigail::regex. (regex_t_sptr): Add this typedef, to namespace
abigail::regex. (regex_t_deleter): Add this struct, to
namespace abigail::regex. (build_sptr): Add these template
specialisations for regex_t_sptr
* src/abg-sptr-utils.cc: Remove this file.
* src/abg-regex.cc: Add new file with contents effectively
the same as abg-sptr-utils.cc.
* src/abg-corpus-priv.h: Update regex_t_sptr namespace
qualification.
* src/abg-corpus.cc: Ditto.
* src/abg-suppression-priv.h: Ditto.
* src/abg-suppression.cc: Ditto.
Signed-off-by: Giuliano Procida <gprocida@google.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
abidw will write out the exact same size-in-bits address for every
pointer type, reference type, function declaration and function type
even though it is always the same as the translation unit address
size. When giving the --no-write-default-sizes option these aren't
written out anymore. The reader is updated to set the default size
when none is given in the XML description.
Even though size and alignment are handled together in the reader,
default alignment is still set to zero, following commit a05384675
Note that this isn't backward compatible with older libabigail
readers, which will set the size to zero when none is given. So this
option isn't the default.
* doc/manuals/abidw.rst: Document --no-write-default-sizes.
* include/abg-writer.h (set_write_default_sizes): New function
declaration.
(set_common_options): Call set_write_default_sizes.
* src/abg-reader.cc (build_function_decl): Get default size.
(build_pointer_type_def): Likewise.
(build_reference_type_def): Likewise.
(build_function_type): Likewise.
* src/abg-writer.cc (write_context): Add m_write_default_sizes
bool.
(get_write_default_sizes): New method.
(set_write_default_sizes): Likewise.
(write_size_and_alignment): Add default size and alignment
parameters.
(set_write_default_sizes): New function.
(write_type_decl): Set default size and alignment.
(write_pointer_type_def): Likewise.
(write_reference_type_def): Likewise.
(write_function_decl): Likewise.
(write_function_type): Likewise.
(write_class_decl_opening_tag): Likewise.
(write_union_decl_opening_tag): Likewise.
* tests/test-types-stability.cc (perform): Also test --abidiff
with --no-write-default-sizes.
* tools/abidw.cc (option): Add default_sizes bool.
(parse_command_line): Parse --no-write-default-sizes.
(display_usage): Add doc string for --no-write-default-sizes.
Signed-off-by: Mark Wielaard <mark@klomp.org>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
read_elf_symbol_binding was overloaded so that it could be called to
read either a binding or a visibility attribute. This is slightly
confusing, since another elf_symbol attribute, type, does have its own
read_elf_symbol_type. Rename the read_elf_symbol_binding that reads
the visibility to read_elf_symbol_visibility for claritiy.
* src/abg-reader.cc (read_elf_symbol_binding): Renamed to...
(read_elf_symbol_visibility): ...this.
Signed-off-by: Mark Wielaard <mark@klomp.org>
When reporting declaration-only type changes, the size is reported as
changing to or from 0, which is not correct. The declaration type is
of unknown size. This patch eliminates such size reports.
* src/abg-reporter-priv.cc (report_size_and_alignment_changes):
Filter out declaration-only / defined type size changes
unconditionally.
* tests/data/test-abidiff-exit/test-decl-struct-report.txt:
Update test.
Signed-off-by: Giuliano Procida <gprocida@google.com>
In the case where a type change is summarised as declaration-only to
defined or vice versa, the trailing new line was missing.
* src/abg-default-reporter.cc (default_reporter::report): In
the class_or_union_diff overload, emit a new line at the end
of the declaration-only reporting path.
* tests/data/test-abidiff-exit/test-decl-struct-report.txt:
Add missing blank lines.
Signed-off-by: Giuliano Procida <gprocida@google.com>
There were no tests exercising this reporting path. The new test is
run with --harmless as these changes are considered harmless.
* tests/data/Makefile.am: Add new test case files.
* tests/data/test-abidiff-exit/test-decl-struct-report.txt:
New test case generating "declaration-only" output.
* tests/data/test-abidiff-exit/test-decl-struct-v0.c: Ditto.
* tests/data/test-abidiff-exit/test-decl-struct-v0.o: Ditto.
* tests/data/test-abidiff-exit/test-decl-struct-v1.c: Ditto.
* tests/data/test-abidiff-exit/test-decl-struct-v1.o: Ditto.
* tests/test-abidiff-exit.cc: Run new test case.
Signed-off-by: Giuliano Procida <gprocida@google.com>
The elf-needed list is not relevant for the exported ABI of a library
so provide an option to drop it.
* doc/manuals/abidw.rst: Document --no-elf-needed.
* include/abg-writer.h (set_write_elf_needed): New function.
(set_common_options): Call it.
* src/abg-writer.cc (write_context::m_write_elf_needed): New data
member.
(write_context::{g,s}et_write_elf_needed): Add new accessors.
(set_write_elf_needed): New function.
(write_context::write_corpus): Check write_elf_needed.
* tools/abidw.cc (options): Add write_elf_needed bool.
(display_usage): Describe --no-elf-needed.
(parse_command_line): Parse --no-elf-needed.
Signed-off-by: Mark Wielaard <mark@klomp.org>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
The function parameter names are not relevant for the (exported)
ABI. So provide an option to simply drop them from the corpus.
* doc/manuals/abidw.rst: Add documentation for --no-parameter-names.
* include/abg-writer.h (set_write_parameter_names): New function.
(set_write_parameter_names): Call it.
* src/abg-writer.cc (write_context): Add m_write_parameter_names
bool, get_write_parameter_names and set_write_parameter_names
functions.
(write_context::write_function_decl): Check write_parameter_names.
* tools/abidw.cc (options): Add write_parameter_names.
(display_usage): Describe --no-parameter-names.
(parse_command_line): Parse --no-parameter-names.
Signed-off-by: Mark Wielaard <mark@klomp.org>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
When comparing two packages, abipkgdiff potentially spawns one thread
per pair of binaries to compare. The suppression specifications
generated for the private types of the package are shared among those
threads. As some internals of the suppression specifications are
constructed lazily, that can lead do some data races when more than
two threads access one of those internals.
One effective way to handle that is to make sure each thread has its
own copy of suppression specifications.
That's what this patch does.
* tools/abipkgdiff.cc (compare_args::private_types_suppr{1,2}):
Make these data member *not* be a reference anymore.
(maybe_create_private_types_suppressions): Rename this into ...
(create_private_types_suppressions): ... this. Also, make this
function return a copy of the vector of suppression specifications
for private types created.
(compare_prepared_userspace_packages): Use the new
create_private_types_suppressions to create a copy of private
types suppression specifications, rather than sharing it from
package::private_types_suppressions_.
(extract_package_and_map_its_content): Adjust to avoid creating
the shared suppression specifications for private types.
(package::private_types_suppressions_): Remove this data member
that was holding the shared suppressions for private types.
(package::private_types_suppressions): Remove these accessors.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
The property name "reached_through" should have been
"accessed_through" and the property value "reference_or_pointer"
should have been "reference-or-pointer".
This patch fixes these issues.
* tests/data/test-diff-suppr/test24-soname-suppr-0.txt: Fix
typo, change "reached_through" to "accessed_through".
* tests/data/test-diff-suppr/test24-soname-suppr-1.txt: Ditto.
* tests/data/test-diff-suppr/test24-soname-suppr-2.txt: Ditto.
* tests/data/test-diff-suppr/test24-soname-suppr-3.txt: Ditto.
* tests/data/test-diff-suppr/test24-soname-suppr-4.txt: Ditto.
Signed-off-by: Giuliano Procida <gprocida@google.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Bad regexes are silently ignored. This will be fixed in a later
commit.
* tests/data/test-diff-suppr/test35-leaf.suppr: Fix typo in
regex, "*." -> ".*".
Signed-off-by: Giuliano Procida <gprocida@google.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Move maybe_adjust_et_rel_sym_addr_to_abs_addr to the elf-helpers.
This function had two overloads
GElf_Addr
maybe_adjust_et_rel_sym_addr_to_abs_addr(GElf_Addr addr, Elf_Scn *section);
GElf_Addr
maybe_adjust_et_rel_sym_addr_to_abs_addr(GElf_Sym *sym);
The former one is only ever called by the latter. Hence consolidate them
into
GElf_Addr
maybe_adjust_et_rel_sym_addr_to_abs_addr(Elf* elf_handle, GElf_Sym* sym);
to combine their functionality and preserve the outer interface. We
just add the Elf* handle argument as usual as we are out of
read_context now.
* src/abg-dwarf-reader.cc
(maybe_adjust_et_rel_sym_addr_to_abs_addr)
(drop the wrapped overload completely): Move out functions.
* src/abg-elf-helpers.cc
(maybe_adjust_et_rel_sym_addr_to_abs_addr): New function.
* src/abg-elf-helpers.h
(maybe_adjust_et_rel_sym_addr_to_abs_addr): New function
declaration.
Reviewed-by: Giuliano Procida <gprocida@google.com>
Signed-off-by: Matthias Maennich <maennich@google.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
This change migrates all ELF helpers related to section lookup to
abg-elf-helpers.{cc,h}. It also homogenizes the interface of those to
always return Elf_Scn* and NULL in case that section can't be found.
Though this smells like a functional change, this latter change is
purely cosmetic.
* src/abg-dwarf-reader.cc (read_context::{opd_section_,
ksymtab_section_, ksymtab_reloc_section_, ksymtab_gpl_section_,
ksymtab_gpl_reloc_section_, ksymtab_strings_section_}): Make these
data members mutable as they are set by their getter member
functions, as an implementation detail.
(read_context::find_symbol_table_section):
adjust to new interface of elf_helpers::find_symbol_table_section.
(find_opd_section): use elf_helpers::find_opd_section for lookup.
(find_ksymtab_section): use elf_helpers::find_ksymtab_section.
(find_ksymtab_gpl_section): use elf_helpers::find_ksymtab_gpl_section.
(find_relocation_section): Move out function.
(get_binary_load_address): Move out function.
(find_ksymtab_reloc_section): use elf_helpers::find_relocation_section
(find_ksymtab_gpl_reloc_section): use
elf_helpers::find_relocation_section
* src/elf-helpers.cc (find_symbol_table_section): change
interface to match other find_*_section functions.
(find_symbol_table_section_index): Adjust for the new interface of
find_symbol_table_section.
(find_opd_section): New function.
(find_ksymtab_section): New function.
(find_ksymtab_gpl_section): New function.
(find_relocation_section): New function.
(get_binary_load_address): New function.
* src/elf-helpers.h (find_symbol_table_section): Change declaration.
(find_opd_section): New function declaration.
(find_ksymtab_section): New function declaration.
(find_ksymtab_gpl_section): New function declaration.
(find_relocation_section): New function declaration.
(get_binary_load_address): New function declaration.
Signed-off-by: Matthias Maennich <maennich@google.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
This consistently names the is_linux_kernel* helpers and keeps only the
copy in the elf-helpers. All users are adjusted.
* src/abg-dwarf-reader.cc
(read_context::function_symbol_is_exported): use is_linux_kernel
from elf_helpers.
(read_context::variable_is_exported): Likewise.
(read_context::get_symtab_format): Likewise.
(read_context::load_symbol_maps): Likewise.
(read_debug_info_into_corpus): Likewise.
(read_context::is_linux_kernel_binary): Drop function.
(read_context::is_linux_kernel_module): Drop function.
* src/abg-elf-helpers.cc (binary_is_linux_kernel): rename to
is_linux_kernel
(binary_is_linux_kernel_module): rename to is_linux_kernel_module
(find_ksymtab_strings_section): Adjust to function renames.
* src/abg-elf-helpers.h (binary_is_linux_kernel): rename to
is_linux_kernel
(binary_is_linux_kernel_module): rename to is_linux_kernel_module
Reviewed-by: Giuliano Procida <gprocida@google.com>
Signed-off-by: Matthias Maennich <maennich@google.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Move some definitions from abg-dwarf-reader to abg-elf-helpers that are
strictly only related to ELF.
* abg-dwarf-reader.cc (binary_is_linux_kernel): Move function out.
(binary_is_linux_kernel_module): Likewise.
(find_ksymtab_strings_section): Likewise.
* abg-elf-helpers.cc (binary_is_linux_kernel): Move function in.
(binary_is_linux_kernel_module): Likewise.
(find_ksymtab_strings_section): Likewise.
* abg-elf-helpers.h (binary_is_linux_kernel): Add declaration.
(binary_is_linux_kernel_module): Likewise.
(find_ksymtab_strings_section): Likewise.
Reviewed-by: Giuliano Procida <gprocida@google.com>
Signed-off-by: Matthias Maennich <maennich@google.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
abg-elf-helpers.{h,cc} shall contain the ELF related parts of the
abg-dwarf-reader. Create the stub files, an empty unit test and hook
everything up in the make system.
* src/Makefile.am: Add new source files abg-elf-helpers.{h,cc}.
* src/abg-elf-helpers.cc: New source file.
* src/abg-elf-helpers.h: New header file.
* tests/.gitignore: Exclude runtestelfhelpers from being committed.
* tests/Makefile.am: Add new test case runtestelfhelpers.
* tests/test-elf-helpers.cc: New test source file.
Reviewed-by: Giuliano Procida <gprocida@google.com>
Signed-off-by: Matthias Maennich <maennich@google.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Parallelize test execution for diff-suppr test by using abigail's multi
threaded worker queue. To accomplish that, follow a similar pattern like
other tests: Add a test_task struct with some precomputed values and
chunk up the work in main().
The test cases needed to be adjusted to allow parallel execution. In
particular the output files can't be shared anymore. To ensure this, a
small tests has been added that checks for unique output paths.
Finally, one redundant test case has been dropped.
This reduces the test time on my machine from ~31s to ~14s. There are
still two test cases that dominate the overall runtime. Since this test
is on the critical path for 'distcheck' (it is the test with the longest
runtime), this is effectively chopped off the overal make distcheck
time.
* tests/test-diff-suppr.cc(main): parallelize test execution.
(test_task) new abigail::workers::task implementation to run
test cases in this test as separate worker tasks.
Signed-off-by: Matthias Maennich <maennich@google.com>
For the update of fun_syms_, undefined_fun_syms_, var_syms_,
undefined_var_syms_, there is a pattern in
read_context::load_symbol_maps_from_symtab_section that can be
simplified: We try to find the correct entry and keep the iterator. If
we do not find it, we construct the value vector, find it again and
update the iterator. Eventually we push_back the symbol. That can be
simplified to looking up the value with operator[], which either returns
the existing value or default constructs it. The reference returned is
good for the push_back in any case.
* src/abg-dwarf-reader.cc
(read_context::load_symbol_maps_from_symtab_section): simplify
symbol map update for fun_syms_, undefined_fun_syms_, var_syms_,
undefined_var_syms_.
Signed-off-by: Matthias Maennich <maennich@google.com>
The default compression flag defined by automake via GZIP_ENV is --best.
That is pretty expensive for when you just want to make sure your change
is done properly to pass 'make distcheck'.
Hence add a convenience target 'make distcheck-fast' that sets GZIP_ENV
to --fast and runs distcheck with that.
On my machine, this almost cuts the 'make distcheck' time in half:
distcheck 4min 40s
distcheck-fast 2min 32s
This is not invasive as it does not change the existing distcheck
target.
* Makefile.am: add distcheck-fast make target
Signed-off-by: Matthias Maennich <maennich@google.com>
Kernel symbol whitelisting symbol is implemented using a regex to
suppress all function and variable names that don't match the given
list. This was completely broken for variables, resulting in all
variables being filtered out if a kernel whitelist was specified.
* src/abg-suppression-priv.h: In get_symbol_name_not_regex
method of variable_suppression::priv, fix typo causing
miscompilation of regex.
Signed-off-by: Giuliano Procida <gprocida@google.com>
Add a drop_undefined_syms properties to the read_context that
indicates the reader wants to drop any undefined symbols (which don't
have associated addresses in the corpus). Implement this for the
dwarf_reader and abidw (when using the --drop-undefined-syms option).
* include/abg-dwarf-reader.h (set_drop_undefined_syms):
New declaration.
* src/abg-dwarf-reader.cc (class read_context): Add private
bool drop_undefined_syms_.
(drop_undefined_syms): New getter and setter method.
(set_drop_undefined_syms): New function.
(function_is_suppressed): Check drop_undefined_syms on
read_context.
(variable_is_suppressed): Likewise.
* src/abg-reader.cc (read_context): Add private bool
m_drop_undefined_syms.
(drop_undefined_syms): New getter and setter method.
* tools/abidw.cc (struct options): Add drop_undefined_syms.
(display_usage): Print --drop-undefined-syms.
(parse_command_line): Parse --drop-undefined-syms.
(main): Call set_drop_undefined_syms.
Signed-off-by: Mark Wielaard <mark@klomp.org>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
To create smaller abi XML files it is useful to be able to drop
the private types from the representation.
* tools/abidw.cc (options): Add drop_private_types bool.
(display_usage): Add --drop-private-types.
(parse_command_line): Parse --drop-private-types, set opts.
(set_suppressions): Call set_drops_artifact_from_ir when
drop_private_types set.
* doc/manuals/abidw.rst: Document --drop-private-types.
Signed-off-by: Mark Wielaard <mark@klomp.org>
Sometimes public header files are in the same directory as private
header files. In such cases --headers-dir cannot be used. Add
--header-file to add individual public header files.
* include/abg-tools-utils.h (gen_suppr_spec_from_headers): Add
hdr_files string vector argument.
* src/abg-tools-utils.cc (handle_file_entry): New function that
adds one specific file to the type_suppression. Implementation
lifted from...
(handle_fts_entry): ...here. Call handle_file_entry for each file.
(gen_suppr_spec_from_headers): Also takes a header_files string
vector as argument. Call handle_file_entry for each file entry.
* tools/abidiff.cc (options): Add header_files1 and header_files2
string vectors.
(display_usage): Print --header-file1 and --header-file2 usage.
(parse_command_line): Handle --header-file1, --hf1 and
--header-file2, --hf2.
(set_diff_context_from_opts): Call gen_suppr_spec_from_headers
with header_files1 and header_files2.
(set_suppressions): Likewise.
* tools/abidw.cc (options): Add header_files string vector.
(display_usage): Print --header-file usage.
(parse_command_line): Handle --header-file1, --hf1.
(maybe_check_header_files): New function.
(set_suppressions): Call gen_suppr_spec_from_headers with
header_files.
(main): Call maybe_check_header_files.
* tools/abilint.cc (options): Add header_files string vector.
(display_usage): Print --header-file usage.
(parse_command_line): Handle --header-file1, --hf1.
(set_suppressions): Call gen_suppr_spec_from_headers with
header_files.
* doc/manuals/abidiff.rst: Document --header-file1, --hf1 and
--header-file2, --hf2. Add new options to documentation of
--drop-private-types.
* doc/manuals/abidw.rst: Document --header-file, --hf.
* doc/manuals/abilint.rst: Likewise.
Signed-off-by: Mark Wielaard <mark@klomp.org>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Following on from giving some test file more descriptive names, this
patch actually documents in brief the purpose of these recently added
tests.
It also improves the coverage of the test-leaf-cxx-members test to
include deletion and insertion report text as well.
* tests/data/test-abidiff-exit/test-leaf-cxx-members-v1.cc:
Comment test. Reorder members of ops to get better coverage.
* tests/data/test-abidiff-exit/test-leaf-fun-type-v1.cc:
Comment test.
* tests/data/test-abidiff-exit/test-leaf-more-v1.cc: Ditto.
* tests/data/test-abidiff-exit/test-leaf-peeling-v1.cc:
Comment test. Update comment on ops2.
* tests/data/test-abidiff-exit/test-leaf-redundant-v1.c:
Comment test.
* tests/data/test-abidiff-exit/test-leaf-stats-v1.cc: Ditto.
* tests/data/test-abidiff-exit/test-leaf-cxx-members-report.txt:
Update locations. Update report to reflect deletion,
insertion and changed members (was previously changed only).:
* tests/data/test-abidiff-exit/test-leaf-peeling-report.txt:
Update locations.
* tests/data/test-abidiff-exit/test-leaf-redundant-report.txt:
Ditto.:
* tests/data/test-abidiff-exit/test-leaf-cxx-members-v0.cc:
Added one line comment referring to -v1 source file.
* tests/data/test-abidiff-exit/test-leaf-fun-type-v0.cc: Ditto.
* tests/data/test-abidiff-exit/test-leaf-more-v0.cc: Ditto.
* tests/data/test-abidiff-exit/test-leaf-peeling-v0.cc: Ditto.
* tests/data/test-abidiff-exit/test-leaf-redundant-v0.c: Ditto.
* tests/data/test-abidiff-exit/test-leaf-stats-v0.cc: Ditto.
* tests/data/test-abidiff-exit/test-leaf-cxx-members-v0.o: Recompiled.
* tests/data/test-abidiff-exit/test-leaf-cxx-members-v1.o: Ditto.
* tests/data/test-abidiff-exit/test-leaf-fun-type-v0.o: Ditto.
* tests/data/test-abidiff-exit/test-leaf-fun-type-v1.o: Ditto.
* tests/data/test-abidiff-exit/test-leaf-more-v0.o: Ditto.
* tests/data/test-abidiff-exit/test-leaf-more-v1.o: Ditto.
* tests/data/test-abidiff-exit/test-leaf-peeling-v0.o: Ditto.
* tests/data/test-abidiff-exit/test-leaf-peeling-v1.o: Ditto.
* tests/data/test-abidiff-exit/test-leaf-redundant-v0.o: Ditto.
* tests/data/test-abidiff-exit/test-leaf-redundant-v1.o: Ditto.
* tests/data/test-abidiff-exit/test-leaf-stats-v0.o: Ditto.
* tests/data/test-abidiff-exit/test-leaf-stats-v1.o: Ditto.
Signed-off-by: Giuliano Procida <gprocida@google.com>
This change:
- makes local variables const where possible
- gives local variables more descriptive names
- factors out some more expressions as local variables
- simplifies the logic around anonymous data members
There are no behavioural changes.
* src/abg-reporter-priv.cc (represent): In the var_diff_sptr
overload, rename pretty_representation to o_pretty_representation,
introduce n_pretty_representation where needed and replace the
duplicate tr1 and tr2 with these; rename all other variables foo1
and foo2 to o_foo and n_foo respectively, using _type instead of
_t; introduce o_anon and n_anon and use them to make the local
variable is_strict_anonymous_data_member_change const, make
ABG_ASSERT in anonymous data member handling more obvious in the
case where anonymity has changed and allow simplification of
formatting in this case; move declarations of const local
variables above those of the non-const, state-tracking, variables.
Signed-off-by: Giuliano Procida <gprocida@google.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Data members have names (unless anonymous), types, sizes and
offsets (if a member of a class or struct). It is the responsibility
of the represent function to detail all differences of a changed
member. The size of a member is the same as the size of its type.
A recent change to the function focused on cleaning up the formatting
logic and added a catch-all case to the end of it in case no diff
information had been emitted by then.
This catch-all triggered for anonymous structs and union diffs under
certain circumstances when these anonymous members had changed in
size.
This patch ensures size change information for a member is emitted
exactly once (unless the type change has been or is being reported
already). It also ensures anonymous members are identified
appropriately and includes a test case would otherwise reach the
catch-all case in both default and --leaf-changes-only modes.
* src/abg-reporter-priv.cc (represent): In the var_diff_sptr
overload, factor out some expressions as local variables, rely
on diff_to_be_reported to decide whether to emit a change,
fold together local/non-local change reporting using
local_changes to preserve current name formatting differences,
keep track explicitly of whether size information has been
emitted and ensure it happens if needed, make offset and size
change reporting for anonymous data members more meaningful.
* tests/test-abidiff-exit.cc: Run new test cases.
* tests/data/Makefile.am: Add new test files.
* tests/data/test-abidiff-exit/test-member-size-v0.cc: New
test.
* tests/data/test-abidiff-exit/test-member-size-v0.o: Ditto.
* tests/data/test-abidiff-exit/test-member-size-v1.cc: Ditto.
* tests/data/test-abidiff-exit/test-member-size-v1.o: Ditto.
* tests/data/test-abidiff-exit/test-member-size-report0.txt:
New test, default mode.
* tests/data/test-abidiff-exit/test-member-size-report1.txt:
New test, --leaf-changes-only mode.
* tests/data/test-abidiff-exit/test-leaf-cxx-members-report.txt:
Eliminate duplicate reporting of member sizes.
* tests/data/test-abidiff-exit/test-leaf-more-report.txt: Ditto.
* tests/data/test-abidiff-exit/test-leaf-peeling-report.txt:
Ditto.
* tests/data/test-abidiff-exit/test-no-stray-comma-report.txt:
Ditto.
* tests/data/test-diff-dwarf/test45-anon-dm-change-report-0.txt:
Add size report for anonymous data member.
* tests/data/test-diff-filter/test44-anonymous-data-member-report-0.txt:
Ditto.
* tests/data/test-diff-pkg/libsigc++-2.0-0c2a_2.4.0-1_amd64--libsigc++-2.0-0v5_2.4.1-1ubuntu2_amd64-report-0.txt:
Add missing size change report.
* tests/data/test-diff-suppr/test36-leaf-report-0.txt: Remove
size change report for previously reported type.
* tests/data/test-diff-suppr/test46-PR25128-report-1.txt:
Eliminate duplicate reporting of member size change.
* tests/data/test-diff-suppr/test46-PR25128-report-2.txt:
Ditto.
Signed-off-by: Giuliano Procida <gprocida@google.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
In both the default and leaf reporting modes, when there is a repeated
or circular reference to a type difference of a member variable, some
placeholder text is emitted instead.
In the leaf reporter:
type 'struct S' of 'foo::bar' changed as reported earlier
In the default reporter, this spans two lines:
type of 'S foo::bar' changed:
details were reported earlier
This patch changes the latter to the more compact:
type of 'S foo::bar' changed, as reported earlier
More generally, this patch makes the punctuation of such placeholder
text more consistent with a comma separating the phrases in all cases.
It doesn't attempt to reconcile the different formatting of member
variable declarations between the two modes.
* src/abg-reporter-priv.cc (represent): In the var_diff_sptr
overload, use consistent punctuation and keep to a single line
of output when referring back to an existing type diff report.
Remove unnecessary braces around single line conditional
blocks.
* src/abg-reporter-priv.h: In the macro
RETURN_IF_BEING_REPORTED_OR_WAS_REPORTED_EARLIER, use
consistent punctuation when referring back to an existing type
diff report.
* tests/data/test-abidiff/test-PR18791-report0.txt: Adjust
formatting of back references to existing type diff reports.
* tests/data/test-diff-dwarf/PR25058-liblttng-ctl-report-1.txt:
Ditto.
* tests/data/test-diff-filter/test16-report-2.txt: Ditto.
* tests/data/test-diff-filter/test17-1-report.txt: Ditto.
* tests/data/test-diff-filter/test25-cyclic-type-report-1.txt:
Ditto.
* tests/data/test-diff-pkg/spice-server-0.12.4-19.el7.x86_64-0.12.8-1.el7.x86_64-report-2.txt:
Ditto.
* tests/data/test-diff-suppr/test36-leaf-report-0.txt: Ditto.
Signed-off-by: Giuliano Procida <gprocida@google.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* tests/test-abidiff-exit.cc: Drop obsolete --redundant flag
and comment as --redundant is now implied by
--leaf-changes-only.
Signed-off-by: Giuliano Procida <gprocida@google.com>
The files tests/data/test-abidiff-exit/test-leaf[0-3]-* were
introduced in a series of changes. Numbering rather than naming the
tests turned out to be a bad choice: it caused confusion when
dealing with merge conflicts due to reordering of commits.
This patch renames the tests to give them more descriptive names,
which is good practice anyway.
* tests/data/Makefile.am: Rename test files.
* tests/test-abidiff-exit.cc: Rename test files.
* tests/data/test-abidiff-exit/test-leaf-fun-type-report.txt:
Renamed from test-leaf2-report.txt.
* tests/data/test-abidiff-exit/test-leaf-fun-type-v0.cc:
Renamed from test-leaf2-v0.cc.
* tests/data/test-abidiff-exit/test-leaf-fun-type-v0.o:
Renamed from test-leaf2-v0.o.
* tests/data/test-abidiff-exit/test-leaf-fun-type-v1.cc:
Renamed from test-leaf2-v1.cc.
* tests/data/test-abidiff-exit/test-leaf-fun-type-v1.o:
Renamed from test-leaf2-v1.o.
* tests/data/test-abidiff-exit/test-leaf-more-report.txt:
Renamed from test-leaf1-report.txt.
* tests/data/test-abidiff-exit/test-leaf-more-v0.cc: Renamed
from test-leaf1-v0.cc.
* tests/data/test-abidiff-exit/test-leaf-more-v0.o: Renamed
from test-leaf1-v0.o.
* tests/data/test-abidiff-exit/test-leaf-more-v1.cc: Renamed
from test-leaf1-v1.cc.
* tests/data/test-abidiff-exit/test-leaf-more-v1.o: Renamed
from test-leaf1-v1.o.
* tests/data/test-abidiff-exit/test-leaf-redundant-report.txt:
Renamed from test-leaf3-report.txt.
* tests/data/test-abidiff-exit/test-leaf-redundant-v0.c:
Renamed from test-leaf3-v0.c.
* tests/data/test-abidiff-exit/test-leaf-redundant-v0.o:
Renamed from test-leaf3-v0.o.
* tests/data/test-abidiff-exit/test-leaf-redundant-v1.c:
Renamed from test-leaf3-v1.c.
* tests/data/test-abidiff-exit/test-leaf-redundant-v1.o:
Renamed from test-leaf3-v1.o.
* tests/data/test-abidiff-exit/test-leaf-stats-report.txt:
Renamed from test-leaf0-report.txt.
* tests/data/test-abidiff-exit/test-leaf-stats-v0.cc: Renamed
from test-leaf0-v0.cc.
* tests/data/test-abidiff-exit/test-leaf-stats-v0.o: Renamed
from test-leaf0-v0.o.
* tests/data/test-abidiff-exit/test-leaf-stats-v1.cc: Renamed
from test-leaf0-v1.cc.
* tests/data/test-abidiff-exit/test-leaf-stats-v1.o: Renamed
from test-leaf0-v1.o.
Signed-off-by: Giuliano Procida <gprocida@google.com>
Since the recent sourceware infrastructure refresh the management of
the mailing list moved to mailman. So the form we use to register to
the mailing list changed as well. I have updated the information on
the web page to reflect that.
* doc/website/mainpage.txt: Use the form at
https://sourceware.org/mailman/listinfo/libabigail to register to
the mailing list.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
The DWARF reader could divide by zero when emitting statistics about
late canonicalisation of types. This is undefined behaviour but
typically results in process termination.
* src/abg-dwarf-reader.cc (perform_late_type_canonicalizing):
If total is zero, don't try to output percentages using it as
a divisor.
Signed-off-by: Giuliano Procida <gprocida@google.com>
The file tests/data/test-diff-pkg/dirpkg-2-report-1.txt looks like it
was committed in error. It's not used, its contents don't match the
implied directories being compared and there are other tests that
cover the same functionality, with or without --no-abignore, anyway.
* tests/data/Makefile.am: Removed
tests/data/test-diff-pkg/dirpkg-2-report-1.txt.
* tests/data/test-diff-pkg/dirpkg-2-report-1.txt: Removed.
Signed-off-by: Giuliano Procida <gprocida@google.com>
Commit 79383f937c added many tests but
didn't actually execute three of them.
Commit fe9fa7a05f added many tests but
didn't actually execute one of them.
This patch corrects these issues.
* tests/test-diff-suppr.cc: Add stanzas for
test6-fn-suppr-report-4, test16-suppr-removed-fn-report-5 and
test22-suppr-removed-var-sym-report-5 and
test23-alias-filter-report-4 tests.
* tests/data/test-diff-suppr/test6-fn-suppr-report-4.txt:
Number parameters from 1 and update expected output to current
formatting.
* tests/data/test-diff-suppr/test16-suppr-removed-fn-report-5.txt:
Update expected output to current formatting.
* tests/data/test-diff-suppr/test22-suppr-removed-var-sym-report-5.txt:
Update expected output to current formatting.
Signed-off-by: Giuliano Procida <gprocida@google.com>
This patch removes perhaps the last remaining cause of double blank
lines in output.
The state variable emit_nl was being set to true just after emitting a
new line which resulted in a blank line after every local typedef
change report.
* include/abg-reporter.h
(default_reporter::report_local_typedef_changes): Change
return type to void.
* src/abg-default-reporter.cc:
(default_reporter::report_local_typedef_changes): Change
return type to void, remove emit_nl state variable and logic.
* tests/data/test-abidiff/test-PR18791-report0.txt: Remove
blank lines.
* tests/data/test-diff-dwarf/test42-PR21296-clanggcc-report0.txt:
Ditto.
* tests/data/test-diff-suppr/test39-opaque-type-report-0.txt:
Ditto.
Signed-off-by: Giuliano Procida <gprocida@google.com>
The code in abg-ir.cc that calculated the memory size of an array
summed, rather than multiplied, the dimensions. It also did duplicate
work for each dimension after the first.
Existing code in abg-reader.cc asserted that array size information
read from XML match freshly calculated values.
This patch corrects the calculation, eliminates the duplicate work and
updates the XML reader validation to just emit a warning if old bad
array size information is found.
* include/abg-ir.h (array_type_def::append_subrange): Remove
this function.
* src/abg-ir.cc (array_type_def::set_element_type): Add a note
about safe usage.
(array_type_def::append_subrange): Inline this function into
its only caller append_subranges and remove it.
(array_type_def::append_subranges): Do correct multiplicative
calculation of multidimensional array sizes.
* src/abg-reader.cc (build_array_type_def): When checking
calculated against read array sizes, warn once if value
matches old behaviour rather than raising an assertion.
Otherwise, before raising an assertion, emit an informative
error message.
* tests/data/test-annotate/test14-pr18893.so.abi: Correct
array sizes.
* tests/data/test-annotate/test17-pr19027.so.abi: Ditto.
* tests/data/test-annotate/test19-pr19023-libtcmalloc_and_profiler.so.abi:
Ditto.
* tests/data/test-annotate/test7.so.abi: Ditto.
* tests/data/test-diff-dwarf/test10-report.txt: Ditto.
* tests/data/test-diff-dwarf/test11-report.txt: Ditto.
* tests/data/test-read-write/test25.xml: Ditto.
Reviewed-by: Matthias Maennich <maennich@google.com>
Signed-off-by: Giuliano Procida <gprocida@google.com>
These blank lines break up the output unexpectedly and often cause
double blank lines after reporting of function changes.
* src/abg-default-reporter.cc: (report_local_function_type_changes):
Remove unnecessary blank lines after lists of parameter changes.
* tests/data/test-*/test*report*.txt: Remove blank lines after
parameter change lists in 12 files.
Reviewed-by: Matthias Maennich <maennich@google.com>
Signed-off-by: Giuliano Procida <gprocida@google.com>
In --leaf-changes-only mode, the report currently has 2 blank lines
after each type-diff section. This patches changes this to 1.
* src/abg-leaf-reporter.cc: (report_diffs) Emit 1 instead of 2
new lines between sections.
* tests/data/test-abidiff-exit/test-leaf-peeling-report.txt:
Replace double blank lines with single ones.
* tests/data/test-diff-filter/libtest45-basic-type-change-report-1.txt:
Ditto.
* tests/data/test-diff-suppr/test36-leaf-report-0.txt: Ditto.
* tests/data/test-*/test*report*.txt:: Ditto.
Reviewed-by: Matthias Maennich <maennich@google.com>
Signed-off-by: Giuliano Procida <gprocida@google.com>
The represent(var_diff_sptr) function tracks vertical "\n" and
horizontal ", " spacing using two state variables:
- emitted - the main diff text has been emitted
- begin_with_and - main text emitted && new line started, so
any further description must be indented and prefixed "and ".
- if emitted is true and begin_with_and is false, then further
description is prefixed with ", " instead.
There was some inconsistent emission of new lines and maintenance of
the state variables. This patch documents the variables and makes sure
new lines and state variables are kept in sync.
Finally, it is theoretically possible to reach the end of the function
without emitted becoming true. This patch adds a TODO and makes sure
at least something is output should that ever happen.
* src/abg-reporter-priv.cc: (represent) In the var_diff_sptr
overload, make sure the state variables begin_with_and and
emitted are updated consistently; add a TODO for one case
which may result in the end of the function being reached
without having emitted a report; add missing new lines
following reporting of anonymous member changes; only emit a
final new line if begin_with_and hasn't tracked one already;
document state variables.
* tests/data/test-diff-dwarf/test45-anon-dm-change-report-0.txt:
Add missing blank line after anonymous member change text.
* tests/data/test-diff-filter/test44-anonymous-data-member-report-1.txt:
Add missing "and " continuation.
Reviewed-by: Matthias Maennich <maennich@google.com>
Signed-off-by: Giuliano Procida <gprocida@google.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>