Commit Graph

1970 Commits

Author SHA1 Message Date
Giuliano Procida
e8a2bb439d Eliminate redundant conditional operators.
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>
2020-05-11 14:23:20 +02:00
Giuliano Procida
8282d92304 Remove stray semicolons.
This patch removes various stray semicolons.

	* include/abg-diff-utils.h (display_edit_script): Remove
	redundant semicolon.
	* include/abg-fwd.h (lookup_basic_type): Ditto.
	* src/abg-comparison.cc (mark_diff_as_visited):
	Ditto.	(array_diff::has_local_changes): Ditto.
	(class_diff::ensure_lookup_tables_populated): Ditto.
	* src/abg-corpus.cc
	(corpus::priv::build_unreferenced_symbols_tables): Ditto.
	* src/abg-default-reporter.cc (default_reporter::report):
	Ditto.
	* src/abg-dwarf-reader.cc (finish_member_function_reading):
	Ditto.
	* src/abg-ir.cc (is_compatible_with_class_type): Ditto.
	(enum_type_decl::enumerator::set_name): Ditto.
	* src/abg-reader.cc (read_corpus_from_input): Ditto.
	(build_function_type): Ditto.
	* src/abg-suppression.cc (type_suppression::suppresses_type):
	Ditto.

Reviewed-by: Matthias Maennich <maennich@google.com>
Signed-off-by: Giuliano Procida <gprocida@google.com>
2020-05-11 14:13:20 +02:00
Giuliano Procida
de9682e5f7 Remove excess whitespace.
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>
2020-05-11 14:04:47 +02:00
Matthias Maennich
246ca20049 corpus/writer: sort emitted translation units by path name
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>
2020-05-05 13:09:34 +02:00
Matthias Maennich
0b9560c19b tests: reorder test execution to optimize 'make check' runtime
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>
2020-05-04 15:53:45 +02:00
Matthias Maennich
c8b0327e50 test-types-stability: parallelize test case alternatives
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>
2020-05-04 15:34:42 +02:00
Dodji Seketeli
f014f8c1f0 Fix compilation with g++ 4.8.5 on el7
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>
2020-05-04 13:07:24 +02:00
Giuliano Procida
186cc9ed3a Simplify generation of symbol whitelist regex.
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>
2020-05-04 11:17:49 +02:00
Giuliano Procida
0082ee529f Move libxml bits out of abg-sptr-utils.h.
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>
2020-05-04 11:17:30 +02:00
Giuliano Procida
ae30e5fa96 Move regex definitions to own files.
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>
2020-05-04 11:15:23 +02:00
Mark Wielaard
a9f5fb4089 Add --no-write-default-sizes option.
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>
2020-04-29 11:56:40 +02:00
Mark Wielaard
440fc7f4be Rename read_elf_symbol_binding to read_elf_symbol_visibility.
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>
2020-04-27 17:20:09 +02:00
Giuliano Procida
4e11174eae abidiff: Omit declaration-only type size 0 diffs.
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>
2020-04-27 13:12:48 +02:00
Giuliano Procida
39ab7e8b22 abidiff: Blank line after declaration-only diff.
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>
2020-04-27 13:02:02 +02:00
Giuliano Procida
bddb6b7d09 Add tests for declaration-only struct diffs.
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>
2020-04-27 12:48:58 +02:00
Mark Wielaard
b8860e1db3 Add --no-elf-needed option to drop DT_NEEDED list from corpus.
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>
2020-04-24 15:59:30 +02:00
Mark Wielaard
8da509aaa2 Add no-parameter-names to drop function parameter names.
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>
2020-04-24 15:34:10 +02:00
Dodji Seketeli
3036fdd832 abipkgdiff: Fix race condition while using private types suppr specs
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>
2020-04-24 14:51:54 +02:00
Giuliano Procida
037b5a1ca6 test24-soname-suppr*txt: Fix suppression syntax.
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>
2020-04-22 17:05:01 +02:00
Giuliano Procida
086083734e test35-leaf.suppr: fix regex typo.
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>
2020-04-22 15:53:19 +02:00
Matthias Maennich
7e4f60a6ea abg-elf-helpers: migrate maybe_adjust_et_rel_sym_addr_to_abs_addr
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>
2020-04-22 11:40:02 +02:00
Matthias Maennich
864ebbd94a abg-elf-helpers: migrate more elf helpers (architecture specific helpers)
This migrates more architecture specific helpers over to the
elf-helpers. No functional change intended.

	* src/abg-dwarf-reader.cc (elf_architecture_is_ppc64): Move
	function out and adjust callers to call the migrated
	functions.
	(elf_architecture_is_big_endian): Likewise.
	(architecture_word_size): Likewise.
	(current_elf_file_is_executable): Likewise.
	(current_elf_file_is_dso): Likewise.
	* src/abg-elf-helpers.cc (architecture_is_ppc64): Add new function.
	(architecture_is_big_endian): Likewise.
	(get_architecture_word_size): Likewise.
	(is_executable): Likewise.
	(is_dso): Likewise.
	* src/abg-elf-helpers.h (architecture_is_ppc64): Add new declaration.
	(architecture_is_big_endian): Likewise.
	(get_architecture_word_size): Likewise.
	(is_executable): Likewise.
	(is_dso): Likewise.

Reviewed-by: Giuliano Procida <gprocida@google.com>
Signed-off-by: Matthias Maennich <maennich@google.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2020-04-22 11:40:02 +02:00
Matthias Maennich
ce9e8f2f5b abg-dwarf-reader: migrate more ELF helpers to elf-helpers
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>
2020-04-22 11:40:02 +02:00
Matthias Maennich
2b4710f82e abg-elf-helpers: consolidate the is_linux_kernel* helpers
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>
2020-04-22 11:40:02 +02:00
Matthias Maennich
d966d5cf78 abg-elf-helpers: move some kernel helpers from abg-dwarf-reader
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>
2020-04-22 11:40:01 +02:00
Matthias Maennich
9815efe7a5 abg-elf-helpers: move some versioning helpers from abg-dwarf-reader
Move some definitions from abg-dwarf-reader to abg-elf-helpers that are
strictly only related to ELF.

	* abg-dwarf-reader.cc (get_symbol_versionning_sections): Move function out.
	(get_version_definition_for_versym): Likewise.
	(get_version_needed_for_versym): Likewise.
	(get_version_for_symbol): Likewise.
	* abg-elf-helpers.cc (get_symbol_versionning_sections): Move function in.
	(get_version_definition_for_versym): Likewise.
	(get_version_needed_for_versym): Likewise.
	(get_version_for_symbol): Likewise.
	* abg-elf-helpers.h (get_symbol_versionning_sections): Add declaration.
	(get_version_definition_for_versym): Likewise.
	(get_version_needed_for_versym): Likewise.
	(get_version_for_symbol): Likewise.

Reviewed-by: Giuliano Procida <gprocida@google.com>
Signed-off-by: Matthias Maennich <maennich@google.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2020-04-22 11:40:01 +02:00
Matthias Maennich
ee83a9e17a abg-elf-helpers: move some elf helpers from abg-dwarf-reader
Move some definitions from abg-dwarf-reader to abg-elf-helpers that are
strictly only related to ELF.

	* abg-dwarf-reader.cc (stt_to_elf_symbol_type): Move function out.
	(stb_to_elf_symbol_binding): Likewise.
	(stv_to_elf_symbol_visibility): Likewise.
	(e_machine_to_string): Likewise.
	(find_section): Likewise.
	(find_symbol_table_section): Likewise.
	(find_symbol_table_section_index): Likewise.
	(enum hash_table_kind): Likewise.
	(find_hash_table_section_index): Likewise.
	(get_symbol_versionning_sections): Likewise.
	(find_text_section): Likewise.
	(find_bss_section): Likewise.
	(find_rodata_section): Likewise.
	(find_data_section): Likewise.
	(find_data1_section): Likewise.
	* abg-elf-helpers.cc (stt_to_elf_symbol_type): Move function in.
	(stb_to_elf_symbol_binding): Likewise.
	(stv_to_elf_symbol_visibility): Likewise.
	(e_machine_to_string): Likewise.
	(find_section): Likewise.
	(find_symbol_table_section): Likewise.
	(find_symbol_table_section_index): Likewise.
	(enum hash_table_kind): Likewise.
	(find_hash_table_section_index): Likewise.
	(get_symbol_versionning_sections): Likewise.
	(find_text_section): Likewise.
	(find_bss_section): Likewise.
	(find_rodata_section): Likewise.
	(find_data_section): Likewise.
	(find_data1_section): Likewise.
	* abg-elf-helpers.h (stt_to_elf_symbol_type): Add declaration.
	(stb_to_elf_symbol_binding): Likewise.
	(stv_to_elf_symbol_visibility): Likewise.
	(e_machine_to_string): Likewise.
	(find_section): Likewise.
	(find_symbol_table_section): Likewise.
	(find_symbol_table_section_index): Likewise.
	(enum hash_table_kind): Likewise.
	(find_hash_table_section_index): Likewise.
	(get_symbol_versionning_sections): Likewise.
	(find_text_section): Likewise.
	(find_bss_section): Likewise.
	(find_rodata_section): Likewise.
	(find_data_section): Likewise.
	(find_data1_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>
2020-04-22 11:40:01 +02:00
Matthias Maennich
b4d97cdd0f abg-dwarf-reader split: create abg-elf-helpers.{h,cc} and test case
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>
2020-04-22 11:39:45 +02:00
Matthias Maennich
56302e9c52 tests: parallelize diff-suppr test
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>
2020-04-20 15:02:39 +02:00
Matthias Maennich
578d2fee76 abg-dwarf-reader: simplify symbol map update
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>
2020-04-20 14:52:34 +02:00
Matthias Maennich
d70079e955 make: add distcheck-fast target
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>
2020-04-20 14:38:32 +02:00
Giuliano Procida
9e5ca9c074 Fix variable suppression name_not_regex.
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>
2020-04-15 15:08:33 +02:00
Mark Wielaard
254cafb7d7 Add --drop-undefined-syms to abidw.
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>
2020-04-15 14:29:55 +02:00
Mark Wielaard
aef674711a Add --drop-private-types to abidw.
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>
2020-04-14 17:32:49 +02:00
Mark Wielaard
9fe85b370c Add --header-file option to add individual public header files.
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>
2020-04-14 17:17:28 +02:00
Giuliano Procida
b4f1a796bd abidiff: Document and refresh tests.
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>
2020-04-14 13:23:44 +02:00
Giuliano Procida
2cf9df73dc abg-reporter-priv.cc: Improve readability of represent helper function.
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>
2020-04-14 13:03:59 +02:00
Giuliano Procida
4bbe135690 abg-reporter-priv.cc: Fix anonymous member size change reports.
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>
2020-04-14 12:39:59 +02:00
Giuliano Procida
22b2ba96f5 abidiff: More compact references to prior diffs.
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>
2020-04-14 11:47:10 +02:00
Giuliano Procida
8d559fb639 test-abidiff-exit.cc: Drop redundant --redundant.
* 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>
2020-04-07 14:49:10 +02:00
Giuliano Procida
7e0d52834b Rename test-abidiff-exit/test-leaf[0-3] files.
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>
2020-04-07 14:48:58 +02:00
Dodji Seketeli
1a9c44e1a8 Update the mailing list registration form on the web page
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>
2020-04-07 11:11:37 +02:00
Giuliano Procida
2fbd0e18aa abg-dwarf-reader.cc: Avoid division by zero.
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>
2020-04-01 19:44:42 +02:00
Giuliano Procida
94844853fb abidiffpkg: Remove stray test report file.
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>
2020-04-01 19:24:11 +02:00
Giuliano Procida
609dc8813d test-diff-suppr.cc: Add missing tests.
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>
2020-04-01 18:38:23 +02:00
Giuliano Procida
ef90972a4a abidiff: Remove blank line after typedef changes.
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>
2020-04-01 15:54:02 +02:00
Giuliano Procida
2d5389f265 Fix size calculations for multidimensional arrays.
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>
2020-03-31 19:48:35 +02:00
Giuliano Procida
88c90d14d9 abidiff: Remove new lines after parameter diffs.
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>
2020-03-30 18:53:07 +02:00
Giuliano Procida
10b93d084c abidiff: Eliminate leaf mode double blank lines.
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>
2020-03-30 17:35:59 +02:00
Giuliano Procida
7070d3b65a abidiff: Fix variable declaration formatting.
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>
2020-03-30 16:56:22 +02:00