Commit Graph

1958 Commits

Author SHA1 Message Date
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
Giuliano Procida
786fcba8ae abidiff: Remove member function diff blank lines.
Currently, lists of member function deletions, additions and changes
are each followed by a blank line in abidiff output.

While this formatting works reasonably well in leaf-changes-only mode
for top-level changes to types, it is inconsistent with everthing
else. In particular, when reporting member function diffs in default
mode, or more deeply nested in leaf mode, the blank lines are
jarring.

There was also no test coverage for leaf-changes-only mode.

This change removes these blank lines and associated state variables
and logic. It adds a test case for leaf-changes-only mode.

Note that the patch also modifies default mode reporting of member
types, template member functions and template member classes
analogously, but I wasn't able to exercise those code paths.

	* src/abg-default-reporter.cc (report): In the
	class_or_union_diff overload, don't emit a new line after each
	list of member function, member type, template member
	function and template member class changes.
	* src/abg-leaf-reporter.cc (report): : In the
	class_or_union_diff overload, don't emit a new line after each
	list of member function changes.
	* tests/data/Makefile.am: Add new test case files.
	* tests/data/test-abidiff-exit/test-leaf-cxx-members-v0.cc:
	New test case for --leaf-changes-only member function diffs.
	* tests/data/test-abidiff-exit/test-leaf-cxx-members-v0.o:
	Ditto.
	* tests/data/test-abidiff-exit/test-leaf-cxx-members-v1.cc:
	Ditto. Also add a TODO regarding a potentially bad diff.
	* tests/data/test-abidiff-exit/test-leaf-cxx-members-v1.o:
	Ditto.
	* tests/data/test-abidiff/test-struct1-report.txt: Remove
	blank lines after member function changes lists.
	* tests/data/test-diff-dwarf/test41-PR20476-hidden-report-0.txt:
	Ditto.
	* tests/data/test-diff-pkg/tbb-4.1-9.20130314.fc22.x86_64--tbb-4.3-3.20141204.fc23.x86_64-report-0.txt:
	Ditto.
	* tests/test-abidiff-exit.cc: Add new test case.

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:36:13 +02:00
Giuliano Procida
340b53300e abidiff: Fix enum impacted interfaces blank line.
There was a spurious new line at the end of reporting enum diffs,
before reporting impacted interfaces, if requested.

	* src/abg-default-reporter.cc (report): In the enum_diff
	overload, don't emit a blank line before a possible "impacted
	interfaces" stanza. In the class_or_union overload, change a
	stray conditional to use the emitted state variable for
	consistency.
	* tests/data/test*report*.txt: Remove blank lines after enum
	diffs in 17 files.

Reviewed-by: Matthias Maennich <maennich@google.com>
Signed-off-by: Giuliano Procida <gprocida@google.com>
2020-03-30 16:27:13 +02:00
Giuliano Procida
912c436250 abidiff: Remove blank line after base class diffs.
This patch removes the blank line emitted after base class diffs.
These are jarring, particularly when the diffs are nested.

	* src/abg-default-reporter.cc (report): In the class_diff
	overload, eliminate the extra blank line after base class
	changes and remove unneeded new line logic.
	* tests/data/test*report*.txt: Remove blank lines after base
	class diffs in 9 files.

Reviewed-by: Matthias Maennich <maennich@google.com>
Signed-off-by: Giuliano Procida <gprocida@google.com>
2020-03-30 16:26:45 +02:00
Giuliano Procida
a5a67c2ffd abidiff: Clean up new lines between sections.
Some blank lines were unintentionally removed with a recent patch. The
new line to remove should have been the one after all changed
functions not the one after each one. Changed functions (and
variables) tend to be reported as paragraphs, rather than single
lines, so the extra spacing is useful.

This patch removes the blank line emitted after all changed
functions, variables and unreachable types, and adds back the
missing blank lines between changed functions.

	* src/abg-default-reporter.cc (report): In the corpus_diff
	override, add back the extra blank line per changed function
	but remove the extra one after all changed changed functions
	and variables; comment these.
	* src/abg-leaf-reporter.cc (report): In the corpus_diff
	override, add back the extra blank line per changed function
	but remove the extra one after all changed changed functions
	and variables; comment these.
	* src/abg-reporter-priv.cc
	(maybe_report_unreachable_type_changes): Remove extra blank
	line emitted after all unreachable type changes; comment
	this.
	* tests/data/test*report*.txt: Remove/add blank lines.

Reviewed-by: Matthias Maennich <maennich@google.com>
Signed-off-by: Giuliano Procida <gprocida@google.com>
2020-03-30 16:26:31 +02:00
Giuliano Procida
95868e0c42 abg-ir.cc: Add types_have_similar_structure tests.
This is a follow-up to a recent commit. This patch adds more tests, as
suggested by a reviewer.

	* src/abg-ir.cc (types_have_similar_structure): Update TODO
	regarding structure of arrays - multidimensional arrays are
	the issue.
	* tests/data/test-abidiff-exit/test-leaf-peeling-report.txt:
	Updated following changes.
	* tests/data/test-abidiff-exit/test-leaf-peeling-v0.cc: Add
	more cases (see below).
	* tests/data/test-abidiff-exit/test-leaf-peeling-v0.o:
	Updated.
	* tests/data/test-abidiff-exit/test-leaf-peeling-v1.cc: Add
	comment about a potential change to local-change semantics;
	add test cases to demonstrate that * and & and * and *** are
	structurally different; add a TODO regarding multidimensional
	arrays where changes are sometimes missed in leaf mode.
	* tests/data/test-abidiff-exit/test-leaf-peeling-v1.o

Signed-off-by: Giuliano Procida <gprocida@google.com>
2020-03-30 12:35:05 +02:00
Giuliano Procida
9cd79d0f41 abg-reader.cc: Fix code indentation and tabify.
* src/abg-reader.cc (build_elf_symbol_db): Fix code
	indentation.
	(build_array_type_def): Tabify.

Signed-off-by: Giuliano Procida <gprocida@google.com>
2020-03-30 11:51:51 +02:00
Dodji Seketeli
4d49e12833 Update tests/data/test-abidiff-exit/test-leaf-peeling-report.txt
Following commit 474ad38f, we need to update the test reference output
tests/data/test-abidiff-exit/test-leaf-peeling-report.txt.

	* tests/data/test-abidiff-exit/test-leaf-peeling-report.txt:
          Update output.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2020-03-26 15:22:53 +01:00
Giuliano Procida
474ad38f37 abidiff: Remove some more unnecessary blank lines.
This is another round of moving responsibility for generation of new
lines into functions  and getting rid of redundant new lines.

	* src/abg-default-reporter.cc (report) In the
	class_or_union_diff overload, don't emit a new line after
	calls to represent. In the union_diff overload, emit a new
	line after a from/to change; fix indentation. In the
	corpus_diff overload, don't emit an extra new line after
	reporting a diff.
	* src/abg-leaf-reporter.cc (report_diffs) Don't emit a new
	line after reporting a canonical diff. In the
	class_or_union_diff overload, don't emit a new line after
	calls to represent. In the corpus_diff overload, don't emit an
	extra new line after reporting a diff.
	* src/abg-reporter-priv.cc (represent): Emit a final new line,
	but only if needed.
	(maybe_report_interfaces_impacted_by_diff): Emit a new line
	after the last impacted interface.
	* tests/data/test-*/*report*.txt: Remove blank lines (and add
	a missing one) to 77 test cases.
2020-03-26 14:39:35 +01:00
Giuliano Procida
9cf76b1175 abg-ir.cc: Improve types_have_similar_structure.
This function is used to determine whether or not type differences are
"local" and is primarily used in --leaf-changes-only mode. The logic
has some issues which are addressed by this patch:

    - Any number of points-to (*) and refers-to (& and &&) components
      are peeled off the types being compared, rather than checking
      these match in number and kind.
    - This peeling is done with peel_typedef_pointer_or_reference_type
      which also peels any number of CV qualifiers (OK) and
      array-of ([N]) type components (not OK).
    - The function sets a state variable (was_indirect_type) to modify
      the behaviour of downstream comparisons, but this cannot be
      passed through recursive calls.

The effect of the indirect_type flag is to switch to comparisons by
name: identically named structs don't get introspected. Arguably, a
more useful behaviour for --leaf-changes-only mode would be to treat
any change to a named type as non-local, except in the context of the
definition of that type itself. This would be a more significant
change in behaviour.

	* include/abg-fwd.h (types_have_similar_structure): In both
	overloads, add an indirect_type argument, defaulting to
	false.
	* src/abg-ir.cc (reference_type_def constructor): Tabify.
	(types_have_similar_structure): In both overloads, add an
	indirect_type argument and update documentation text. In the
	type_base_sptr overload, pass indirect_type in the tail
	call. In the type_base* overload, replace was_indirect_type
	with indirect_type; peel CV qualifiers and typedefs without
	testing as the peel function does this; replace the
	indiscriminate peeling of qualifier/pointer/reference/array
	type components with code that checks the same
	pointer/reference/array type component is used on each side
	and makes recursive calls with indirect_type set to true; pass
	the indirect_type argument recursively when comparing other
	subtypes; move the typeid check earlier, document its purpose
	and remove unneccessary checks after later dynamic casts;
	remove an always-true conditional; add a TODO for comparing
	array types more accurately.
	* tests/data/Makefile.am: Add new test case files.
	* tests/data/test-abidiff-exit/test-leaf-peeling-v0.cc: New
	test case.
	* tests/data/test-abidiff-exit/test-leaf-peeling-v1.cc: Ditto.
	* tests/data/test-abidiff-exit/test-leaf-peeling-report.txt:
	Ditto.
	* tests/test-abidiff-exit.cc: Run new test case.

Signed-off-by: Giuliano Procida <gprocida@google.com>
2020-03-26 11:45:03 +01:00
Giuliano Procida
7b485c8271 abg-ir.cc: Remove always-true check.
There is an instance of a if-statement testing the same variable as
its containing if-statement. The inner test always evaluates to true,
if it is reached.

	* src/abg-ir.cc (types_have_similar_structure): Remove
	identical nested conditional.
	(reference_type_def::reference_type_def): Tabify.

Reviewed-by: Matthias Maennich <maennich@google.com>
Signed-off-by: Giuliano Procida <gprocida@google.com>
2020-03-21 00:30:23 +01:00
Giuliano Procida
7791714334 abg-ir.cc: Fix peel_typedef_type(const type_base*).
The various peel_*_type functions are supposed to return either an
underlying type (when something can be "peeled") or the original
type (when not).

This overload of peel_typedef_type currently returns null if the type
isn't a typedef. This patch corrects this.

The bug hasn't bitten as all existing calls are protected by an
is_typedef check. Note that the recursive calls within the function
are to the other (const type_base_sptr&) overload.

	* src/abg-ir.cc (peel_typedef_type): In the const type_base*
        overload, return the original argument rather than null if the
        type isn't actually a typedef.

Signed-off-by: Giuliano Procida <gprocida@google.com>
2020-03-20 23:49:43 +01:00
Giuliano Procida
b0ce702088 Eliminate redundancy in representation of local change kinds.
* include/abg-ir.h (change_kind): Remove redundant
	LOCAL_CHANGE_KIND member, renumber members and update
        comments.
	* src/abg-comparison.cc (distinct_diff::has_local_changes):
	Remove redundant LOCAL_CHANGE_KIND.
	(var_diff::has_local_changes
	* src/abg-ir.cc (equals): In the type_base,
	qualified_type_def, pointer_type_def, reference_type_def,
	array_type_def::subrange_type, array_type_def, enum_type_decl,
	typedef_decl, var_decl, function_type, function_decl,
	function_decl::parameter, class_or_union,
	class_decl::base_spec, class_decl, decl_base and scope_decl
	overloads, remove redundant LOCAL_CHANGE_KIND.
	(enum_has_non_name_change): Remove redundant
	LOCAL_CHANGE_KIND.

Signed-off-by: Giuliano Procida <gprocida@google.com>
2020-03-20 23:25:10 +01:00