Commit Graph

35 Commits

Author SHA1 Message Date
Dodji Seketeli
ee2b54ddd9 Make abidiff and abidw support several --headers-dir{1,2} options
When handling a binary with abidiff or abidw it can be useful to
provide several different header files directories, for the cases
where the header files of the binary are scathered in several
different directories.

It thus becomes possible to invoke abidiff like this:

    abidiff --headers-dir1 first-header-dir1   \
	    --headers-dir1 second-header-dir1  \
	    --headers-dir2 first-header-dir2   \
	    --headers-dir2 second-header-dir2  \
	    binary1 binary2

This patch adds support for that.  It also modifies the
tests/test-abidiff-exit.cc test harness to make it take header
directories.  With that modification done, a new test is added in that
harness to exercise this new feature.

This should close the feature request over at
https://sourceware.org/bugzilla/show_bug.cgi?id=26565.

	* doc/manuals/abidiff.rst: Update documentation for the
	--headers-dir{1,2} options.
	* doc/manuals/abidw.rst: Likewise for the --header-dir option.
	* include/abg-tools-utils.h (gen_suppr_spec_from_headers): Add new
	overload that takes a vector of headers root dirs.
	* src/abg-tools-utils.cc (gen_suppr_spec_from_headers_root_dir):
	Define new function.
	(gen_suppr_spec_from_headers): Define a new overload that takes a
	vector of head_root_dir strings; it uses the new
	gen_suppr_spec_from_headers function.  Use the new overload in the
	previous one that takes just one head_root_dir string.
	* tools/abidiff.cc (options::headers_dirs{1,2}): Rename
	option::headers_dir{1,2} into this one and make it be a vector of
	strings rather than just a string.
	(parse_command_line): Support several --headers-dir{1,2} on the
	command line.
	(set_diff_context_from_opts, set_suppressions): Adjust.
	* tools/abidw.cc (options::headers_dirs): Renamed
	options::headers_dir into this and make it be a vector of strings
	rather than just a string.
	(parse_command_line): Support several --headers-dir on the command
	line.
	(set_suppressions): Adjust.
	* tests/data/test-abidiff-exit/test-headers-dirs/headers-a/header-a-v{0,1}.h:
	Header files of new binary test input.
	* tests/data/test-abidiff-exit/test-headers-dirs/headers-b/header-b-v{0,1}.h:
	Likewise.
	* tests/data/test-abidiff-exit/test-headers-dirs/test-headers-dir-v{0,1}.c:
	Source code of new binary test input.
	* tests/data/test-abidiff-exit/test-headers-dirs/test-headers-dir-report-{1,2}.txt:
	Reference output of new binary test input.
	* tests/data/test-abidiff-exit/test-headers-dirs/test-headers-dir-v{0,1}.o:
	New binary test input.
	* tests/data/Makefile.am: Add the new files above to source
	distribution.
	* tests/test-abidiff-exit.cc (InOutSpec::in_elfv{0,1}_path): Add
	new data members.
	(in_out_specs): Adjust the content of this array as its type
	changed.  Also, add two new entries to run the test over the new
	binary test inputs above.
	(do_prefix_strings): Define new static function.
	(main): Use it the new do_prefix_strings here.  Make abidiff
	use the --header-dir{1,2} option whenever header directories are
	specified in an entry of the in_out_specs array.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2020-09-18 10:27:18 +02:00
Giuliano Procida
697347e402 Fix corpus_diff::has_net_changes for --leaf-changes-only mode
This function was not aware of --leaf-changes-only mode.

    - Stats counters for changed variables and types have
      different names in the different modes.
    - Net leaf type changes were not included in leaf mode.

For some inputs, this resulted in abidiff producing an empty report
but returning a non-zero exit status in --leaf-changes-only mode.

For other inputs the combination of both issues still resulted in the
correct return code. This included the following test-abidiff-exit
test cases:

    - test-leaf-peeling
    - test-leaf2
    - test-no-stray-comma

This patch makes corpus_diff::has_net_changes mirror emit_diff_stats,
modulo flags like --non-reachable-types which if absent can still
result in discrepancies between output and return code.

To achieve this in a more maintainable way, the patch introduces a new interface
reporter_base::diff_has_net_changes.  That interface is implemented by
all current reporters.  Each reporter focuses on its own
particularities to provide the required behavious. Then
corpus_diff:has_net_changes just has to invoke
reporter_base::diff_has_net_changes on the reporter that is currently
in used.

The tests below verify that the exit code is zero when all the changes
between the test files are suppressed.

	* include/abg-reporter.h ({reporter_base, default_reporter,
	leaf_reporter}::diff_has_net_changes): Add new virtual function.
	This breaks binary compatibility but should conserve source
	compatibility.
	* src/abg-default-reporter.cc
	(default_reporter::diff_has_net_changes): Define new member
	function.
	* src/abg-leaf-reporter.cc (leaf_reporter::diff_has_net_changes):
	Likewise.
	* src/abg-comparison.cc (corpus_diff::has_net_changes): Invoke
	reporter_base::diff_has_net_changes on the current reporter,
	rather than trying to handle all the different kinds of reporters
	here.
	(corpus_diff::priv::apply_filters_and_compute_diff_stats): Add a
	TODO to possibly delegate the implementation of this function to
	the reporters.
	* tests/data/Makefile.am: Add new test case files.
	* tests/data/test-abidiff-exit/test-net-change-report0.txt:
	Normal mode, nothing suppressed.
	* tests/data/test-abidiff-exit/test-net-change-report1.txt:
	Normal mode, everything suppressed.
	* tests/data/test-abidiff-exit/test-net-change-report2.txt:
	Leaf mode, nothing suppressed.
	* tests/data/test-abidiff-exit/test-net-change-report3.txt:
	Leaf mode, everything suppressions.
	* tests/data/test-abidiff-exit/test-net-change-v0.c: Test file
	* tests/data/test-abidiff-exit/test-net-change-v0.o: Test file
	* tests/data/test-abidiff-exit/test-net-change-v1.c: Test file
	* tests/data/test-abidiff-exit/test-net-change-v1.o: Test file
	* tests/data/test-abidiff-exit/test-net-change.abignore: This
	suppresses changes for all variables, functions and types in
	the test files, except for the 'victim' function.
	* tests/test-abidiff-exit.cc: Run new test cases.

Reviewed-by: Matthias Maennich <maennich@google.com>
Signed-off-by: Giuliano Procida <gprocida@google.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2020-07-21 08:53:19 +02:00
Giuliano Procida
b0f98180e0 Add tests for declaration-only enums.
* tests/data/test-abidiff-exit/test-decl-enum-report-2.txt: Add
	new test reference output.
	* tests/data/test-abidiff-exit/test-decl-enum-report-3.txt: Likewise.
	* tests/data/test-abidiff-exit/test-decl-enum-report.txt: Likewise.
	* tests/data/test-abidiff-exit/test-decl-enum-v{0,1}.c: Add source
	code for the binaries below.
	* tests/data/test-abidiff-exit/test-decl-enum-v{0,1}.o: Add new
	binary test inputs.
	* tests/data/Makefile.am: Add the new files above to source
	distribution.
	* tests/test-abidiff-exit.cc: Add the test inputs above to the
	test harness.

Signed-off-by: Giuliano Procida <gprocida@google.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2020-07-08 16:59:56 +02:00
Dodji Seketeli
88fcbfeced dwarf-reader: support several anonymous data members in a given class
At the moment, if a class has more than one anonymous data member, we
are just keeping the first one and dropping the others.

This patch fixes that.

Now that there is the possibility of having several anonymous data
members in a given class we need to be able to name them correctly, to
tell them apart.  That means we cannot use the name returned by
var_decl::get_name() as that name is empty for an anonymous data
member.  This patch thus introduces a new method
var_decl::get_anon_dm_reliable_name() which returns a name that is
reliable (non-empty) even when the var_decl designates an anonymous
data member.  Note that there are many situations where we still need
to have var_decl::get_name() behave like it used to, so we can't make
it invariably return what var_decl::get_anon_dm_reliable_name()
returns today.

	* include/abg-ir.h (class_or_union::find_anonymous_data_member):
	Declare a new member function.
	(class_or_union::find_data_member): Declare a new overload.
	(var_decl::get_anon_dm_reliable_name): Declare new member
	function.
	* src/abg-ir.cc (var_decl::get_pretty_representation): Make this
	work on a var_decl is going to be used to represent an anonymous
	data member even before the var_decl has been added to its finale
	scope.  This is useful to make class_or_union::find_data_member
	work on a var_decl that is to be used as an anonymous data member.
	(var_decl::get_anon_dm_reliable_name): Define new member function.
	(class_or_union::find_data_member): In the existing overload that
	takes a string, look for the named data member inside the
	anonymous data members.  Define a new overload that takes a
	var_decl_sptr, to look for anonymous data members.
	(class_or_union::find_anonymous_data_member): Define a new member
	function.
	(lookup_data_member): Use the existing
	class_or_union::find_data_member.
	* src/abg-reader.cc: (build_class_decl): Use the full anonymous
	variable for lookup, rather than its name which is empty and will
	thus give false positives.
	* src/abg-dwarf-reader.cc (add_or_update_class_type): Likewise.
	* src/abg-comparison.cc
	(class_or_union_diff::ensure_lookup_tables_populated): Name
	anonymous data members properly - as opposed to wrongly using
	their empty name.
	* src/abg-reporter-priv.cc (represent): In the overload for
	var_diff_sptr, make sure that changes to the /type/ of a variable
	declaration are always reported.
	* tests/data/test-abidiff-exit/test-member-size-report0.txt:
	Adjust as we now emit more detailed changes about anonymous data
	members.
	* tests/data/test-abidiff-exit/test-member-size-report1.txt:
	Likewise.
	* tests/data/test-annotate/test-anonymous-members-0.o.abi: Adjust
	to reflect the fact that a class can now have several anonymous
	data members.
	* tests/data/test-diff-dwarf-abixml/PR25409-librte_bus_dpaa.so.20.0.abi:
	Likewise.
	* tests/data/test-diff-filter/test30-pr18904-rvalueref-report0.txt:
	Likewise.
	* tests/data/test-diff-filter/test30-pr18904-rvalueref-report1.txt:
	Likewise.
	* tests/data/test-diff-filter/test35-pr18754-no-added-syms-report-0.txt:
	Likewise.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2020-05-18 13:42:50 +02:00
Dodji Seketeli
e2341a939c Bug 25986 - Wrong name of function type used in change report
We have introduced type name caching long ago to speed up operations
involving type names.

Then last year, I was looking at some speed optimization in the
xml-writer and I started playing with the caching to quantify the
speed impact that early caching could have on emitting writting out
the abixml, independantly from the potential accuracy issues that
could have.

And somehow I accidentally committed one of those experimental
patches:
https://sourceware.org/git/?p=libabigail.git;a=commit;h=7699dfc921d248fa6d5cbdbeab9d501b17ef3f52.

This commit reverts that bogus patch.  There should be no speed impact
because the writter now de-duplicates types at writting time by
"simply" writting out the canonical types, as opposed to the naive
approach we were using then.

This fixes the bug reported at
https://sourceware.org/bugzilla/show_bug.cgi?id=25986 which shows the
impact of caching the wrong name of the type, which happens when
caching occurs before the type is canonicalized.

	* src/abg-ir.cc (function_type::get_cached_name): Don't cache
	names for non-canonicalized types.
	* tests/data/test-abidiff-exit/test-fun-param-report.txt: Add
	reference output for new test.
	* tests/data/test-abidiff-exit/test-fun-param-v{0,1}.abi: Add new test
	input files.
	* tests/data/test-abidiff-exit/test-fun-param-v{0,1}.c: Add source
	files for the above.
	* tests/data/test-abidiff-exit/test-fun-param-v{0,1}.o: Add
	binaries for the above.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2020-05-14 09:54:52 +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
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
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
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
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
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
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
dc5e2dd893 Tag add/remove/change lines unconditionally with [A], [D], [C].
These tags were previously only emitted by the default reporter if the
there were more than 100 (hard-coded constant) items in a a list. The
leaf reporter emitted them unconditionally. This change simplifies the
code, makes output more consistent and makes it easier to interpret
diffs of diff output.

Additionally, in the reporting of changed unreachable types, the
indentation and quoting for the deleted and added cases was missing.
This patch corrects these issues.

Finally, when doing package differences, there were no tags for
deleted/added binaries. This patch adds them.

	* src/abg-default-reporter.cc (report): In the corpus_diff
	override, remove calculations of number of changes (total) and
	comparisons against arbitrary threshold (large_num); emit [A],
	[D], [C] tags unconditionally.
	* src/abg-reporter-priv.cc
	(maybe_report_unreachable_type_changes): Remove comparisons of
	number of changes against arbitrary threshold (large_num);
	emit [A], [D], [C] tags unconditionally; fix quoting of
        deleted unreachable types; fix indentation of changed
	unreachable types.
	* tools/abipkgdiff.cc (compare_prepared_userspace_packages):
	Emit [D] and [A] tags for removed and added binaries.
	* tests/data/test-*/*report*.txt: In 109 report files, add
        tags [A], [D], [C] tags and correct some indentation and
        quoting.

Signed-off-by: Giuliano Procida <gprocida@google.com>
2020-03-18 14:45:26 +01:00
Giuliano Procida
09946c4aee Treat function type changes as local.
In leaf-changes-only mode, if the type of a struct's function pointer
member changes it currently gets categorised as a non-local change and
so is not reported. The change to any function passing such a struct
is considered non-local and also not reported.

This patch broadens the definition of local changes to include these
cases and so have them be reported in leaf-changes-only mode. It may
be the first of a sequence of such patches,

	* src/abg-ir.cc (types_have_similar_structure): Always compare
	function types (instead of just returning true) regardless of
        whether they are components of pointer-to-function or
        reference-to-function types.
	* tests/data/Makefile.am: Add new test case files.
	* tests/data/test-abidiff-exit/test-leaf2-report.txt: New test
	case.
	* tests/data/test-abidiff-exit/test-leaf2-v0.cc: Ditto.
	* tests/data/test-abidiff-exit/test-leaf2-v0.o: Ditto.
	* tests/data/test-abidiff-exit/test-leaf2-v1.cc: Ditto.
	* tests/data/test-abidiff-exit/test-leaf2-v1.o: Ditto.
	* tests/test-abidiff-exit.cc: Run new test case.

Signed-off-by: Giuliano Procida <gprocida@google.com>
2020-03-17 13:33:26 +01:00
Giuliano Procida
2eb592169b Output 2-space indentation consistently.
abidiff emits hierarchical difference information using 2-space
indentation, almost everywhere.

In a few places, long lines are split up and 1-space is used for
clarity. Otherwise 1-space indentation appears to be only used when
reporting:

    - data member changes (not additions or removals)
    - the change of the type of a variable

This patch resolves these inconsistencies in favour of 2-space
indentation.

	* src/abg-default-reporter.cc (report): In the
	class_or_union_diff override, use 2-space indentation when
        listing changed members. In the var_diff override, do the same
        for variable type changes.
	* src/abg-leaf-reporter.cc: Ditto.
        * tests/data/test-*/*report*.txt: Update many test cases.

Signed-off-by: Giuliano Procida <gprocida@google.com>
2020-03-16 22:39:35 +01:00
Giuliano Procida
0fd7565d06 Eliminate some unnecessary blank lines in diff output.
v2: More code simplification. Tests unchanged.

There is distributed responsibility for horizontal and vertical
whitespace in the reporting code with indent and new line control
information being manipulated by and passed in and out of functions.
Occasionally, this information is ignored or incorrect and the code
tends to err on the side of more rather than fewer new lines.

The outcome is that abidiff output sometimes contains extra blank
lines which can be confusing.

This patch eliminates some of the more obvious cases:

   - after data member deletions
   - in enumerator change lists
   - after "type size hasn't changed"
   - before listing impacted interfaces

A lot of passing of "new line needed" booleans between functions has
been eliminated in the process.

The patch cleans up the reporting of data members. The code will
either emit indentation, a short description and a new line or do
nothing at all.

The patch also removes some stray location reporting code for array
diffs which would have produced some oddly placed output. I could not
get this code to trigger as loc = decl->get_location() was never
present on the array decls in question.

	* src/abg-default-reporter.cc (report): In the type_decl_diff,
	enum_diff, array_diff, class_diff, union_diff and var_diff
	overrides, simplify new line logic which no longer needs to be
	threaded through report_name_size_and_alignment_changes. In
	the distinct_diff override, simplify new line logic which no
	longer needs to be threaded through
	report_size_and_alignment_changes. In the enum_diff override,
	emit just one blank line after each enum. In the array_diff
	override, remove stray location reporting which doesn't appear
	to ever trigger; fix new line logic. In the
	class_or_union_diff override, simplify new line logic for
	deleted members; pass indentation to represent_data_member.
	* src/abg-leaf-reporter.cc (report): In the array_diff,
	class_diff, union_diff and var_diff overrides, simplify new
	line logic which no longer needs to be threaded through
	report_name_size_and_alignment_changes. In the distinct_diff
	override, simplify new line logic which no longer needs to be
	threaded through report_size_and_alignment_changes. In the
	array_diff override, remove stray location reporting which
	doesn't appear to ever trigger; fix new line handling. In the
	class_or_union_diff override, simplify new line logic for
	deleted members; pass indentation to represent_data_member.
	In the corpus_diff override, tabify source indentation.
	* src/abg-reporter-priv.cc (represent_data_member): Handle
	indentation; fix new line logic.
	(report_size_and_alignment_changes): Fix new line logic
	for "type size hasn't changed" message; simplify new line
	logic and replace local bool n with argument bool nl for
	clarity.
	(report_size_and_alignment_changes): Remove bool nl argument
	and associated code as it had become always false; take
	responsibility for emitting terminating new lines and change
	return type to void.
	(report_name_size_and_alignment_changes): Fix new line logic;
	remove bool nl argument and associated code as it had become
	always false; take responsibility for emitting terminating new
	lines and change return type to void.
	(maybe_report_interfaces_impacted_by_diff) In both overrides,
	remove new line prefix code and new_line_prefix argument.
	* src/abg-reporter-priv.h (represent_data_member): Add indent
	argument.
	(report_size_and_alignment_changes) Remove bool nl argument;
	change return type to void.
	(report_name_size_and_alignment_changes) Remove bool nl
	argument; change return type to void.
	(maybe_report_interfaces_impacted_by_diff) In both overrides,
	remove new_line_prefix argument.
	* tests/data/test-*/*report*.txt: Remove some blank lines.

Signed-off-by: Giuliano Procida <gprocida@google.com>
2020-03-16 16:15:09 +01:00
Giuliano Procida
28af7232c2 abg-leaf-reporter.cc: Fix indentation of function parameter diffs.
When reporting the details of changes to function parameter
differences in leaf-changes-only mode, the details are output at the
same level of indentation as the introductory text. In default mode
the usual 2-space indentation is used.

This patch fixes this discrepancy, making the output more readable.

	* src/abg-leaf-reporter.cc (report): In the fn_parm_diff
	override, indent the lines of detail by 2 spaces.
	* tests/data/test-abidiff-exit/test-leaf3-report.txt: Update
	report with correct indentation.

Signed-off-by: Giuliano Procida <gprocida@google.com>
2020-03-13 18:30:31 +01:00
Giuliano Procida
dcba808257 Fix interaction of --redundant and --leaf-changes-only options.
The --redundant (meaning show-redundant-changes) option is supposed to
be implied by --leaf-changes-only and this is currently implemented by
making diff_context's --leaf-changes-only setter also duplicate the
behaviour of its --redundant setter.

In both abidiff and abipkgdiff, the diff_context setters are called
unconditionally, but the relative order of the calls for these two
options is different in each case, resulting in two different issues.

In abidiff, the --redundant setter is called second, undoing the
intended side-effect of any --leaf-changes-only flag. So --redundant
is not actually turned on in --leaf-changes-only mode unless requested
explicitly.

In abipkgdiff, the leaf-changes-only setter is called second, undoing
(in non-leaf mode) the effect of any --redundant flag. So --redundant
has no effect in default reporting mode.

The fix is move to move the "--leaf-changes-only implies --redundant"
logic from the setter to the set_diff_context_from_opts functions.
This patch also documents the implied behaviour in the usage strings.

	* src/abg-comparison.cc (diff_context::show_leaf_changes_only):
	Remove "--leaf-changes-only implies --redundant" logic.
	* tools/abidiff.cc (display_usage): Mention that
	--leaf-changes-only implies --redundant.
	(set_diff_context_from_opts): Make --leaf-changes-only imply
	--redundant; document this behaviour in a comment.
	* tools/abipkgdiff.cc: Ditto.
	* tests/data/Makefile.am: Add new test case files.
	* tests/data/test-abidiff-exit/test-leaf3-report.txt: Add new
	test case, to show --leaf-changes-only implies --redundant.
	* tests/data/test-abidiff-exit/test-leaf3-v0.c: Ditto.
	* tests/data/test-abidiff-exit/test-leaf3-v0.o: Ditto.
	* tests/data/test-abidiff-exit/test-leaf3-v1.c: Ditto.
	* tests/data/test-abidiff-exit/test-leaf3-v1.o: Ditto.
	* tests/test-abidiff-exit.cc: Run new test case.
	* tests/data/test-diff-pkg/libcdio-0.94-1.fc26.x86_64--libcdio-0.94-2.fc26.x86_64-report.1.txt:
	Update abipkgdiff report with --redundant output.
	* tests/data/test-diff-pkg/spice-server-0.12.4-19.el7.x86_64-0.12.8-1.el7.x86_64-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.

Signed-off-by: Giuliano Procida <gprocida@google.com>
2020-03-13 18:06:14 +01:00
Giuliano Procida
3665c8ff44 Add more leaf change reporting.
The leaf-changes-only reporting path does not report on all the same
kinds of differences as the default reporting path does, such as
reporting about changes to variables, even though they can be
considered leaf changs.

    - The addition or removal of any symbol affects the ABI and is
      clearly a leaf change.
    - A change to a variable's declaration may be local rather than
      caused by a type change elsewhere.

This patch adds these missing pieces and reorders some of the existing
leaf reporting, bringing the default and leaf corpus_diff functions
closer to the point where they can be trivially merged or refactored.

This patch also corrects an error in reporting the total number of
leaf changes.

	* doc/manuals/abidiff.rst: Update the documentation for
	--leaf-changes-only.
	* doc/manuals/abipkgdiff.rst: Likewise.
	* src/abg-comparison.cc (emit_diff_stats): Exclude non-leaf
	changes to variables from the reported total of leaf changes.
	* src/abg-default-reporter.cc (report): In the corpus_diff
	override, move some code and comments for clarity.
	* src/abg-leaf-reporter.cc (report): In the corpus_diff
	override, additionally report removed/added/changed variables
	and removed/added symbols absent from debug info.
	* tests/data/Makefile.am: Add new test case files.
	* tests/data/test-abidiff-exit/test-leaf0-report.txt: Update
	to include reporting of variable diff (change of type).
	* tests/data/test-abidiff-exit/test-leaf1-report.txt: New test
	case with added/removed variables/functions and changed
	variables (both local and non-local type changes).
	* tests/data/test-abidiff-exit/test-leaf1-v0.cc: Ditto.
	* tests/data/test-abidiff-exit/test-leaf1-v0.o: Ditto.
	* tests/data/test-abidiff-exit/test-leaf1-v1.cc: Ditto.
	* tests/data/test-abidiff-exit/test-leaf1-v1.o: Ditto.
	* tests/test-abidiff-exit.cc: Run new test case. Supply
	--redundant otherwise the test isn't meaningful.

Signed-off-by: Giuliano Procida <gprocida@google.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2020-03-13 17:58:30 +01:00
Giuliano Procida
b602f46c00 Fix spurious new lines after diff sections.
The top-level corpus diff routines in abidiff have varied ways of
tracking whether or not to emit a new line after each section. Reuse
of state variables (which aren't always cleared) between sections
means that spurious new lines are sometimes output.

This patch replaces this new line logic in the functions with the same
simple pattern of using a local boolean state variable.

	* src/abg-default-reporter.cc (report): In the corpus_diff
	overload, just use a local boolean emitted state variable
	within each section to determine whether or not to follow the
	section with an extra new line.
	* src/abg-leaf-reporter.cc: Ditto.
	* tests/data/test-*/*report*.txt: Remove unwanted new lines
	from 27 files.

Signed-off-by: Giuliano Procida <gprocida@google.com>
2020-03-12 10:19:45 +01:00
Giuliano Procida
b7755d092a Fix the reporting of leaf change statistics.
Leaf changes (as reported with --leaf-changes-only) to variables were
miscounted as changes to functions.

	* src/abg-comparison.cc
	(apply_filters_and_compute_diff_stats):	Increment the correct
	counter for leaf variable changes.
	* tests/data/Makefile.am: Add new test case files.
	* tests/data/test-abidiff-exit/test-leaf0-report.txt: New test
	case.
	* tests/data/test-abidiff-exit/test-leaf0-v0.cc: Ditto.
	* tests/data/test-abidiff-exit/test-leaf0-v0.o: Ditto.
	* tests/data/test-abidiff-exit/test-leaf0-v1.cc: Ditto.
	* tests/data/test-abidiff-exit/test-leaf0-v1.o: Ditto.
	* tests/test-abidiff-exit.cc: Run 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-10 17:41:22 +01:00
Giuliano Procida
6dfccee786 Add space missing between "[C]" tag and description of changed item.
All such tags are now followed by a space and are more readable.

	* src/abg-default-reporter.cc (report): In the overload for
	corpus_diff, output space after "[C]".
	* src/abg-leaf-reporter.cc (report): Likewise.
	* tests/data/test-*/*report*.txt: Update all the test
	reports.

Signed-off-by: Giuliano Procida <gprocida@google.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2020-03-06 15:23:22 +01:00
Giuliano Procida
272817b253 Fix stray comma in leaf-changes-only mode.
This change replaces the "\n," sometimes seen in output (such as for
the PR25128 test cases) with a correctly indented "and".

	* src/abg-reporter-priv.cc (represent): Don't try to follow
        output of indented pretty representation with a comma, just
        emit "and" unconditionally; remove unnecessary intermediate
        ostringstream.
	* tests/data/Makefile.am: Add new test case files.
	* tests/data/test-abidiff-exit/test-no-stray-comma-*: New test
        cases.
        * tests/data/test-diff-suppr/test46-PR25128-report-?.txt:
        Replace unindented comma with indented "and".
	* tests/test-abidiff-exit.cc: Add no-stray-comma test case.

Signed-off-by: Giuliano Procida <gprocida@google.com>
Reviewed-by: Matthias Maennich <maennich@google.com>
2020-02-19 14:00:23 +01:00
Giuliano Procida
95535d8f6f Don't ignore options when diffing translation units (.bi files).
There was an inconsistency in the way the diff context was used for
different file types. This change eliminates this and so .bi files now
have all the command line options applied to their diffs.

	* tests/data/Makefile.am: Add test case files.
	* tests/data/test-abidiff-exit/test-loc-*: New test cases.
	* tests/test-abidiff-exit.cc (in_out_specs): Add new test cases.
	* tools/abidiff.cc (main): Use populated ctxt for translation unit
	diff.

Signed-off-by: Giuliano Procida <gprocida@google.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2020-02-03 14:08:26 +01:00
Dodji Seketeli
b2608d9ccb Update tests for the "better leaf mode redundancy management" patchset
This commit is the last of the set whose commit titles are:

    Do not show decl-only-to-def changes in the leaf reporter
    Overhaul of the report diff stats summary
    Do not mark "distinct" diff nodes as being redundant
    Fix meaning of "harmless name change" to avoid overfiltering
    Better handle category propagation of pointer changes
    Improve function changes reporting in leaf and default mode
    Don't filter out typedef changes with redundant underlying type changes
    Only show leaf type changes in the leaf type changes section
    Fix leaf report of class data member changes
    Always show redundant changes in leaf mode
    Avoid reporting an enum change if it has already been reported
    When we say an a change was reported earlier give its source location
    [abipkgdiff]: in leaf mode we always show redundant changes
    Update tests for the "better leaf mode redundancy management" patchset

This commit updates the tests reference output files for that
patchset.

	* tests/data/test-abidiff-exit/test1-voffset-change-report1.txt: Adjust.
	* tests/data/test-abidiff/test-PR18791-report0.txt: Likewise.
	* tests/data/test-abidiff/test-enum0-report.txt: Likewise.
	* tests/data/test-abidiff/test-enum1-report.txt: Likewise.
	* tests/data/test-diff-filter/test1-report.txt: Likewise.
	* tests/data/test-diff-filter/test14-0-report.txt: Likewise.
	* tests/data/test-diff-filter/test15-0-report.txt: Likewise.
	* tests/data/test-diff-filter/test17-0-report.txt: Likewise.
	* tests/data/test-diff-filter/test27-redundant-and-filtered-children-nodes-report-0.txt: Likewise.
	* tests/data/test-diff-filter/test28-redundant-and-filtered-children-nodes-report-0.txt: Likewise.
	* tests/data/test-diff-filter/test3-report.txt: Likewise.
	* tests/data/test-diff-filter/test30-pr18904-rvalueref-report0.txt: Likewise.
	* tests/data/test-diff-filter/test30-pr18904-rvalueref-report1.txt: Likewise.
	* tests/data/test-diff-filter/test32-ppc64le-struct-change-report0.txt: Likewise.
	* tests/data/test-diff-filter/test35-pr18754-no-added-syms-report-0.txt: Likewise.
	* tests/data/test-diff-filter/test35-pr18754-no-added-syms-report-1.txt: Likewise.
	* tests/data/test-diff-filter/test4-report.txt: Likewise.
	* tests/data/test-diff-filter/test41-report-0.txt: Likewise.
	* tests/data/test-diff-filter/test42-leaf-report-output-0.txt: Likewise.
	* tests/data/test-diff-pkg/dirpkg-3-report-1.txt: Likewise.
	* tests/data/test-diff-pkg/dirpkg-3-report-2.txt: Likewise.
	* tests/data/test-diff-pkg/libICE-1.0.6-1.el6.x86_64.rpm--libICE-1.0.9-2.el7.x86_64.rpm-report-0.txt: Likewise.
	* tests/data/test-diff-pkg/libcdio-0.94-1.fc26.x86_64--libcdio-0.94-2.fc26.x86_64-report.1.txt: Likewise.
	* tests/data/test-diff-pkg/spice-server-0.12.4-19.el7.x86_64-0.12.8-1.el7.x86_64-report-0.txt: Likewise.
	* tests/data/test-diff-pkg/spice-server-0.12.4-19.el7.x86_64-0.12.8-1.el7.x86_64-report-1.txt: Likewise.
	* tests/data/test-diff-pkg/spice-server-0.12.4-19.el7.x86_64-0.12.8-1.el7.x86_64-report-2.txt: Likewise.
	* tests/data/test-diff-pkg/spice-server-0.12.4-19.el7.x86_64-0.12.8-1.el7.x86_64-report-3.txt: Likewise.
	* tests/data/test-diff-pkg/tbb-4.1-9.20130314.fc22.x86_64--tbb-4.3-3.20141204.fc23.x86_64-report-0.txt: Likewise.
	* tests/data/test-diff-suppr/test1-typedef-suppr-report-1.txt: Likewise.
	* tests/data/test-diff-suppr/test1-typedef-suppr-report-2.txt: Likewise.
	* tests/data/test-diff-suppr/test13-suppr-through-pointer-report-1.txt: Likewise.
	* tests/data/test-diff-suppr/test14-suppr-non-redundant-report-0.txt: Likewise.
	* tests/data/test-diff-suppr/test14-suppr-non-redundant-report-1.txt: Likewise.
	* tests/data/test-diff-suppr/test15-suppr-added-fn-report-1.txt: Likewise.
	* tests/data/test-diff-suppr/test15-suppr-added-fn-report-2.txt: Likewise.
	* tests/data/test-diff-suppr/test15-suppr-added-fn-report-3.txt: Likewise.
	* tests/data/test-diff-suppr/test15-suppr-added-fn-report-4.txt: Likewise.
	* tests/data/test-diff-suppr/test16-suppr-removed-fn-report-1.txt: Likewise.
	* tests/data/test-diff-suppr/test16-suppr-removed-fn-report-2.txt: Likewise.
	* tests/data/test-diff-suppr/test16-suppr-removed-fn-report-3.txt: Likewise.
	* tests/data/test-diff-suppr/test16-suppr-removed-fn-report-4.txt: Likewise.
	* tests/data/test-diff-suppr/test17-suppr-added-var-report-1.txt: Likewise.
	* tests/data/test-diff-suppr/test17-suppr-added-var-report-2.txt: Likewise.
	* tests/data/test-diff-suppr/test17-suppr-added-var-report-3.txt: Likewise.
	* tests/data/test-diff-suppr/test17-suppr-added-var-report-4.txt: Likewise.
	* tests/data/test-diff-suppr/test18-suppr-removed-var-report-1.txt: Likewise.
	* tests/data/test-diff-suppr/test18-suppr-removed-var-report-3.txt: Likewise.
	* tests/data/test-diff-suppr/test18-suppr-removed-var-report-4.txt: Likewise.
	* tests/data/test-diff-suppr/test2-struct-suppr-report-0.txt: Likewise.
	* tests/data/test-diff-suppr/test2-struct-suppr-report-1.txt: Likewise.
	* tests/data/test-diff-suppr/test25-typedef-report-1.txt: Likewise.
	* tests/data/test-diff-suppr/test27-add-aliased-function-report-1.txt: Likewise.
	* tests/data/test-diff-suppr/test27-add-aliased-function-report-2.txt: Likewise.
	* tests/data/test-diff-suppr/test27-add-aliased-function-report-5.txt: Likewise.
	* tests/data/test-diff-suppr/test28-add-aliased-function-report-3.txt: Likewise.
	* tests/data/test-diff-suppr/test28-add-aliased-function-report-6.txt: Likewise.
	* tests/data/test-diff-suppr/test30-report-1.txt: Likewise.
	* tests/data/test-diff-suppr/test34-report-0.txt: Likewise.
	* tests/data/test-diff-suppr/test35-leaf-report-0.txt: Likewise.
	* tests/data/test-diff-suppr/test36-leaf-report-0.txt: Likewise.
	* tests/data/test-diff-suppr/test5-fn-suppr-report-1.txt: Likewise.
	* tests/data/test-diff-suppr/test5-fn-suppr-report-2.txt: Likewise.
	* tests/data/test-diff-suppr/test5-fn-suppr-report-3.txt: Likewise.
	* tests/data/test-diff-suppr/test5-fn-suppr-report-4.txt: Likewise.
	* tests/data/test-diff-suppr/test5-fn-suppr-report-5.txt: Likewise.
	* tests/data/test-diff-suppr/test7-var-suppr-report-1.txt: Likewise.
	* tests/data/test-diff-suppr/test7-var-suppr-report-2.txt: Likewise.
	* tests/data/test-diff-suppr/test7-var-suppr-report-3.txt: Likewise.
	* tests/data/test-diff-suppr/test7-var-suppr-report-4.txt: Likewise.
	* tests/data/test-diff-suppr/test7-var-suppr-report-5.txt: Likewise.
	* tests/data/test-diff-suppr/test7-var-suppr-report-6.txt: Likewise.
	* tests/data/test-diff-suppr/test7-var-suppr-report-7.txt: Likewise.
	* tests/data/test-diff-suppr/test7-var-suppr-report-9.txt: Likewise.
	* tests/data/test-diff-suppr/test8-redundant-fn-report-0.txt: Likewise.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2018-04-13 11:13:09 +02:00
Dodji Seketeli
ba1b9916ac Forgot to add test2-filtered-removed-fns-v{0,1}.o
I forgot to add these files as part of my previous commit

	* test2-filtered-removed-fns-v{0,1}.o: Add these test input files.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-03-07 12:29:54 +01:00
Dodji Seketeli
ddc21ed73e Bug 19596 - Suppressed removed symbol changes still considered incompatible
Libabigail considers a removed function (or global variable) as being
an incompatible change, whether it has been suppressed or not.
Likewise, even if all function sub-type changes have been suppressed,
changed virtual offset on functions are still considered incompatible.

Thus, abidiff still returns an exit code that reflects an incompatible
change even if the removed symbol change was suppressed.

The rule should rather be that if incompatible changes have been
suppressed, abidiff (and the other tools) should take that into
account and not return an exit code that reflects incompatible
changes.

This patch implements that rule, at least for the incompatible changes
that are detected so far.

	* src/abg-comparison.cc (corpus_diff::has_incompatible_changes):
	Consider the *net* number of removed function and variable
	symbols.  Also, if all function sub-type changes have been
	suppressed, then no virtual offset change should be considered
	incompatible.
	* tests/data/test-abidiff-exit/test1-voffset-change-report1.txt
	* tests/data/test-abidiff-exit/test1-voffset-change.abignore
	* tests/data/test-abidiff-exit/test2-filtered-removed-fns-report0.txt
	* tests/data/test-abidiff-exit/test2-filtered-removed-fns-report1.txt
	* tests/data/test-abidiff-exit/test2-filtered-removed-fns-v0.c
	* tests/data/test-abidiff-exit/test2-filtered-removed-fns-v1.c
	* tests/data/test-abidiff-exit/test2-filtered-removed-fns.abignore
	* tests/data/Makefile.am: Add the new test material above to
	source distribution.
	* tests/test-abidiff-exit.cc (InOutSpec::in_suppr_path): New data
	member.
	(in_out_specs): Adjust. Add new test inputs.
	(main): Adjust.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-03-04 01:02:46 +01:00
Dodji Seketeli
4b7e295b20 Bug 19596 - Incorrect exit status for incompatible ABI change
The comparison engine doesn't take virtual offset changes into account
when deciding if a diff node carries an incompatible change.  This is
obviously an oversight.

Fixed thus.

	* include/abg-comparison.h (enum diff_category): Adjust the
	comment for enumerator VIRTUAL_MEMBER_CHANGE_CATEGORY; changes of
	this category are incompatible ABI changes.
	(corpus_diff::diff_stats::num_func_with_virtual_offset_changes):
	Declare new accessors.
	* src/abg-comparison.cc
	(corpus_diff::diff_stats::priv::num_func_with_virt_offset_changes):
	New data member.
	(corpus_diff::diff_stats::priv::priv): Initialize the new data
	member.
	(corpus_diff::diff_stats::num_func_with_virtual_offset_changes):
	Define new accessors.
	(corpus_diff::priv::apply_filters_and_compute_diff_stats): Use the
	new accessor to set the number of functions with virtual offset
	changes onto the stats data structure.
	(corpus_diff::has_incompatible_changes): Take functions with
	virtual offset changes into account.
 	* tests/test-abidiff-exit.cc: New test harness to test for exit
	codes of abidiff.
	* tests/Makefile.am: Build the new test harness runtestabidiff
	from the test-abidiff-exit.cc source file.
	* tests/data/test-abidiff-exit/test1-voffset-change-report0.txt:
	New reference test output.
	* tests/data/test-abidiff-exit/test1-voffset-change-v0.cc: New
	test input source code.
	* tests/data/test-abidiff-exit/test1-voffset-change-v0.o: New test input.
	* tests/data/test-abidiff-exit/test1-voffset-change-v1.cc: New
	test input source code.
	* tests/data/test-abidiff-exit/test1-voffset-change-v1.o: New test input.
	* tests/data/Makefile.am: tests/data/Makefile.am: Add the new test
	inputs above to the source distribution.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-02-10 21:31:53 +01:00