Commit Graph

332 Commits

Author SHA1 Message Date
Giuliano Procida
29de666641 abg-writer: Add support for stable hash type ids.
The type ids currently emitted by the XML writer are simply type-id-1,
type-id-2 etc. Additions or removals of types early in this sequence
result in cascading changes to many other XML elements.

This commit adds support for stable type ids in the form of hashes of
libabigail's internal type names. On fairly rare occasions (typically
involving unnamed types), the names of two distinct types can be the
same. In any case, if there is a hash collision the XML writer will
find the next unused id and so preserve uniqueness.

Diffs between large XML files produced using --type-id-style hash will
be much smaller and easier to review.

This also commit adds some test cases to verify that the hashing is
actually stable across architectures.

	* doc/manuals/abidw.rst: Replace stray documentation of
	--named-type-ids with documention of new --type-id-style
	option.
	* include/abg-writer.h (type_id_style_kind): Add new enum.
	(set_type_id_style): Add new write_context setter.
	(set_common_options): Set type id style in write context.
	* include/abg-hash.h (fnv_hash): Declare new 32-bit FNV-1a
        hash function in abigail::hashing namespace.
	* src/abg-hash.h (fnv_hash): Define new 32-bit FNV-1a hash
        function in abigail::hashing namespace.
	* src/abg-writer.cc (write_context): Add m_type_id_style
        member to record type style to use, defaulting to
        SEQUENCE_TYPE_ID_STYLE; add m_used_type_id_hashes to record
        already-used hashes.
	(write_context::get_type_id_style): Add new getter.
	(write_context::set_type_id_style): Add new setter.
	(get_id_for_type): Add support for HASH_TYPE_ID_STYLE style.
	(set_type_id_style): Add new helper function.
	* tools/abidw.cc (options): Add type_id_style member.
	(display_usage): Add description of --type-id-style option.
	(parse_command_line): Parse --type-id-style option.
	* tests/data/Makefile.am: Add new hash type id ABI files.
	* tests/test-read-dwarf.cc: (InOutSpec): Add type_id_style
	member.
	(in_out_specs): Set type_id_style to SEQUENCE_TYPE_ID_STYLE in
        existing test specifications. Duplicate first 9 test cases
        with type_id_style set to HASH_TYPE_ID_STYLE.
	* tests/data/test-read-dwarf/test0.hash.abi: New ABI XML file
	with hash type ids.
	* tests/data/test-read-dwarf/test1.hash.abi: Ditto.
	* tests/data/test-read-dwarf/test2.so.hash.abi: Ditto.
	* tests/data/test-read-dwarf/test3.so.hash.abi: Ditto.
	* tests/data/test-read-dwarf/test4.so.hash.abi: Ditto.
	* tests/data/test-read-dwarf/test5.o.hash.abi: Ditto.
	* tests/data/test-read-dwarf/test6.so.hash.abi: Ditto.
	* tests/data/test-read-dwarf/test7.so.hash.abi: Ditto.
	* tests/data/test-read-dwarf/test8-qualified-this-pointer.so.hash.abi:
	Ditto.

Signed-off-by: Giuliano Procida <gprocida@google.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2020-06-16 10:13:01 +02:00
Matthias Maennich
4ef7e8c976 abipkgdiff: remove unused includes of elfutils/libdw.h and elf.h
Definitions from those headers are not actually used. Yet the includes
create unnecessary dependencies.

	* tools/abipkgdiff.cc: Drop unused includes.

Signed-off-by: Matthias Maennich <maennich@google.com>
2020-06-15 09:08:05 +02:00
Giuliano Procida
2b4ff3c6cf Fix HARMLESS_SYMBOL_ALIAS_CHANGE_CATEGORY spelling
The enumerator HARMLESS_SYMBOL_ALIAS_CHANGE_CATEORY has a spelling
mistake in it. This changes fixes this and also corrects the spelling
of both this and HARMLESS_UNION_CHANGE_CATEORY when output.

	* include/abg-comparison.h (enum diff_category): Rename
	HARMLESS_SYMBOL_ALIAS_CHANGE_CATEORY enumerator to
	HARMLESS_SYMBOL_ALIAS_CHANGE_CATEGORY.
	* src/abg-comp-filter.cc (categorize_harmless_diff_node): Replace
	use of HARMLESS_SYMBOL_ALIAS_CHANGE_CATEORY enumerator with
	HARMLESS_SYMBOL_ALIAS_CHANGE_CATEGORY.
	* src/abg-comparison.cc (get_default_harmless_categories_bitmap):
	Replace use of HARMLESS_SYMBOL_ALIAS_CHANGE_CATEORY enumerator
	with HARMLESS_SYMBOL_ALIAS_CHANGE_CATEGORY.
	(operator<<): In the diff_category overload, replace use of
	HARMLESS_SYMBOL_ALIAS_CHANGE_CATEORY enumerator with
	HARMLESS_SYMBOL_ALIAS_CHANGE_CATEGORY and output correct
	spelling for both this and HARMLESS_UNION_CHANGE_CATEGORY.
	* tools/abicompat.cc (create_diff_context): Replace use of
	HARMLESS_SYMBOL_ALIAS_CHANGE_CATEORY enumerator with
	HARMLESS_SYMBOL_ALIAS_CHANGE_CATEGORY.

Signed-off-by: Giuliano Procida <gprocida@google.com>
2020-06-11 10:06:04 +02:00
Mark Wielaard
a9f5fb4089 Add --no-write-default-sizes option.
abidw will write out the exact same size-in-bits address for every
pointer type, reference type, function declaration and function type
even though it is always the same as the translation unit address
size. When giving the --no-write-default-sizes option these aren't
written out anymore. The reader is updated to set the default size
when none is given in the XML description.

Even though size and alignment are handled together in the reader,
default alignment is still set to zero, following commit a05384675

Note that this isn't backward compatible with older libabigail
readers, which will set the size to zero when none is given. So this
option isn't the default.

	* doc/manuals/abidw.rst: Document --no-write-default-sizes.
	* include/abg-writer.h (set_write_default_sizes): New function
	declaration.
	(set_common_options): Call set_write_default_sizes.
	* src/abg-reader.cc (build_function_decl): Get default size.
	(build_pointer_type_def): Likewise.
	(build_reference_type_def): Likewise.
	(build_function_type): Likewise.
	* src/abg-writer.cc (write_context): Add m_write_default_sizes
	bool.
	(get_write_default_sizes): New method.
	(set_write_default_sizes): Likewise.
	(write_size_and_alignment): Add default size and alignment
	parameters.
	(set_write_default_sizes): New function.
	(write_type_decl): Set default size and alignment.
	(write_pointer_type_def): Likewise.
	(write_reference_type_def): Likewise.
	(write_function_decl): Likewise.
	(write_function_type): Likewise.
	(write_class_decl_opening_tag): Likewise.
	(write_union_decl_opening_tag): Likewise.
	* tests/test-types-stability.cc (perform): Also test --abidiff
	with --no-write-default-sizes.
	* tools/abidw.cc (option): Add default_sizes bool.
	(parse_command_line): Parse --no-write-default-sizes.
	(display_usage): Add doc string for --no-write-default-sizes.

Signed-off-by: Mark Wielaard <mark@klomp.org>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2020-04-29 11:56:40 +02:00
Mark Wielaard
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
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
Dodji Seketeli
2cda77235c abipkgdiff: fix documentation of --impacted-interface
Update the help string of the --impacted-interface option to make it
match the one from the abidiff tool.

	* tools/abipkgdiff.cc (display_usage): Use the same help string
	for the --impacted-interface option as abidiff does.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2020-03-18 17:33:03 +01:00
Matthias Maennich
82d84afd5b abidiff: fix documentation of --impacted-interfaces
abidiff --impacted-interfaces is supposed to show the impacted
interfaces. Hence fix the documentation to reflect that.

	* tools/abidiff.cc(display_usage): Fix doc string for
	--impacted-interfaces.

Reported-by: Saravana Kannan <saravanak@google.com>
Signed-off-by: Matthias Maennich <maennich@google.com>
2020-03-18 15:29:44 +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
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
aadbd8cdbf abisym: Remove leading space in output.
When abisym reports a symbol as found, it currently emits a leading
space. It does not do this when reporting a symbol as not found.

This patch removes the leading space.

	* tools/abisym.cc (main): Remove leading space from output.
	* tests/data/test-lookup-syms/test0-report.txt: Remove leading
	space from expected output.
	* tests/data/test-lookup-syms/test01-report.txt: Ditto.
	* tests/data/test-lookup-syms/test02-report.txt: Ditto.
	* tests/data/test-lookup-syms/test1-1-report.txt: Ditto.

Signed-off-by: Giuliano Procida <gprocida@google.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2020-03-10 18:03:03 +01:00
Dodji Seketeli
1d6731c438 Update copyright year to 2020
We are in February 2020 so this is long overdue.

	* include/abg-comp-filter.h: Update copyright year to 2020.
	* include/abg-comparison.h: Likewise.
	* include/abg-config.h: Likewise.
	* include/abg-corpus.h: Likewise.
	* include/abg-cxx-compat.h: Likewise.
	* include/abg-diff-utils.h: Likewise.
	* include/abg-dwarf-reader.h: Likewise.
	* include/abg-fwd.h: Likewise.
	* include/abg-hash.h: Likewise.
	* include/abg-ini.h: Likewise.
	* include/abg-interned-str.h: Likewise.
	* include/abg-ir.h: Likewise.
	* include/abg-libxml-utils.h: Likewise.
	* include/abg-libzip-utils.h: Likewise.
	* include/abg-reader.h: Likewise.
	* include/abg-reporter.h: Likewise.
	* include/abg-sptr-utils.h: Likewise.
	* include/abg-suppression.h: Likewise.
	* include/abg-tools-utils.h: Likewise.
	* include/abg-traverse.h: Likewise.
	* include/abg-viz-common.h: Likewise.
	* include/abg-viz-dot.h: Likewise.
	* include/abg-viz-svg.h: Likewise.
	* include/abg-workers.h: Likewise.
	* include/abg-writer.h: Likewise.
	* src/abg-comp-filter.cc: Likewise.
	* src/abg-comparison-priv.h: Likewise.
	* src/abg-comparison.cc: Likewise.
	* src/abg-config.cc: Likewise.
	* src/abg-corpus-priv.h: Likewise.
	* src/abg-corpus.cc: Likewise.
	* src/abg-default-reporter.cc: Likewise.
	* src/abg-diff-utils.cc: Likewise.
	* src/abg-dwarf-reader.cc: Likewise.
	* src/abg-hash.cc: Likewise.
	* src/abg-ini.cc: Likewise.
	* src/abg-internal.h: Likewise.
	* src/abg-ir-priv.h: Likewise.
	* src/abg-ir.cc: Likewise.
	* src/abg-leaf-reporter.cc: Likewise.
	* src/abg-libxml-utils.cc: Likewise.
	* src/abg-libzip-utils.cc: Likewise.
	* src/abg-reader.cc: Likewise.
	* src/abg-reporter-priv.cc: Likewise.
	* src/abg-reporter-priv.h: Likewise.
	* src/abg-sptr-utils.cc: Likewise.
	* src/abg-suppression-priv.h: Likewise.
	* src/abg-suppression.cc: Likewise.
	* src/abg-tools-utils.cc: Likewise.
	* src/abg-traverse.cc: Likewise.
	* src/abg-viz-common.cc: Likewise.
	* src/abg-viz-dot.cc: Likewise.
	* src/abg-viz-svg.cc: Likewise.
	* src/abg-workers.cc: Likewise.
	* src/abg-writer.cc: Likewise.
	* tests/print-diff-tree.cc: Likewise.
	* tests/test-abicompat.cc: Likewise.
	* tests/test-abidiff-exit.cc: Likewise.
	* tests/test-abidiff.cc: Likewise.
	* tests/test-alt-dwarf-file.cc: Likewise.
	* tests/test-core-diff.cc: Likewise.
	* tests/test-diff-dwarf-abixml.cc: Likewise.
	* tests/test-diff-dwarf.cc: Likewise.
	* tests/test-diff-filter.cc: Likewise.
	* tests/test-diff-pkg.cc: Likewise.
	* tests/test-diff-suppr.cc: Likewise.
	* tests/test-diff2.cc: Likewise.
	* tests/test-dot.cc: Likewise.
	* tests/test-ini.cc: Likewise.
	* tests/test-ir-walker.cc: Likewise.
	* tests/test-lookup-syms.cc: Likewise.
	* tests/test-read-dwarf.cc: Likewise.
	* tests/test-read-write.cc: Likewise.
	* tests/test-svg.cc: Likewise.
	* tests/test-tools-utils.cc: Likewise.
	* tests/test-types-stability.cc: Likewise.
	* tests/test-utils.cc: Likewise.
	* tests/test-utils.h: Likewise.
	* tests/test-write-read-archive.cc: Likewise.
	* tools/abiar.cc: Likewise.
	* tools/abicompat.cc: Likewise.
	* tools/abidiff.cc: Likewise.
	* tools/abidw.cc: Likewise.
	* tools/abilint.cc: Likewise.
	* tools/abipkgdiff.cc: Likewise.
	* tools/abisym.cc: Likewise.
	* tools/binilint.cc: Likewise.
	* tools/kmidiff.cc: Likewise.
	* update-copyright.sh: Fix the updating script to handle not just
	"Red Hat, Inc."

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2020-02-21 17:05:01 +01:00
Matthias Maennich
e0088cff76 Fix some parameter name inconsistencies
Clang-tidy flags those name inconsistencies and they are trivial to fix,
hence just do it. No functional change.

	* src/abg-comparison-priv.h
	(corpus_diff::priv::count_unreachable_types): use consistent
	parameter naming.
	* tools/abidiff.cc(main): Likewise.

Reviewed-by: Dodji Seketeli <dodji@seketeli.org>
Signed-off-by: Matthias Maennich <maennich@google.com>
2020-02-03 14:39:18 +00: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
Matthias Maennich
9ab71105eb KMI Whitelists: Drop old whitelist extraction methods
The previous commit introduces a new (tested) way of creating function
and variable suppressions from multiple whitelist definitions. Migrate
to this new way of processing KMI whitelists.

	* include/abg-tools-utils.h
	(gen_suppr_spec_from_kernel_abi_whitelist): Delete declaration.
	* src/abg-tools-utils.cc
	(gen_suppr_spec_from_kernel_abi_whitelist): Delete definition
	and migrate users to gen_suppr_spec_from_kernel_abi_whitelists.
	* tools/abidiff.cc (set_suppressions): Migrate from using
	gen_suppr_spec_from_kernel_abi_whitelist to
	gen_suppr_spec_from_kernel_abi_whitelists.
	* tools/abidw.cc (set_suppressions): Likewise.
	* tools/abipkgdiff.cc: Drop unused using definition.
	* tools/kmidiff.cc: Likewise.

Reviewed-by: Dodji Seketeli <dodji@seketeli.org>
Signed-off-by: Matthias Maennich <maennich@google.com>
2020-01-21 18:38:00 +00:00
Matthias Maennich
e84537afea abidiff/kmidiff: do not default-suppress added symbols
kmidiff and abidiff do filter out added symbols (vars, functions and
symbols without debug info) by default when dealing with kernel
binaries. The reason for this is that the ABI could be considered
compatible and not broken when adding symbols. In practice, this is
confusing as there is no possibility for a symmetric comparison (i.e. a
deleted function when comparing left to right is an added function when
comparing right to left). Furthermore, there is no option available to
actually report these added symbols. I thought of adding an option to
report added symbols, but in the end came to the conclusion that we
should behave consistent across the various ways you can diff an ABI
with abidiff and kmidiff and should not change default behaviour for a
particular type of binary. Hence, remove the default behaviour of
filtering out added symbols when comparing kernel binaries. To restore
the current behaviour, the user needs to parametrize with the tools with
--no-added-syms --no-unreferenced-symbols.

Adjusted test cases accordingly and add a new test that covers the old
behaviour new available with additional flags to abidiff.

	* tools/abidiff.cc (adjust_diff_context_for_kmidiff): Drop
	default suppression of added symbols.
	* tools/kmidiff.cc (set_diff_context): Likewise.
	* tests/data/test-diff-suppr/test46-PR25128-report-1.txt: Adjust
	test expectation.
	* tests/data/test-diff-suppr/test46-PR25128-report-2.txt: Add
	test case for abidiff with flag --no-added-syms.
	* tests/data/Makefile.am: add new testcase.

Reviewed-by: Dodji Seketeli <dodji@seketeli.org>
Signed-off-by: Matthias Maennich <maennich@google.com>
2020-01-17 12:40:27 +00:00
Dodji Seketeli
c32b8ec9f3 Bug 24690 - Support comparing non-reachable types of a binary
This patch adds the ability to compare all types of a binary,
including those types that are not reachable from global functions and
variables.

This implies that for types that are not reachable from public
interfaces, we want compare them against each others directly, without
first comparing global functions/variables and walking the graph of
reachable types from there.

The patch adds the --non-reachable-types option to abidiff and
abipkgdiff, instructing them to also compare types that are
non-reachable from global variables and functions.

Using that option, for instance, here is what the summary of
abipkgdiff now looks like, in the test case attached added by this
patch:

================ changes of 'libflatpak.so.0.10204.0'===============
  Functions changes summary: 0 Removed, 0 Changed (16 filtered out), 16 Added functions
  Variables changes summary: 0 Removed, 0 Changed, 0 Added variable
  Unreachable types summary: 3 removed (2 filtered out), 1 changed (15 filtered out), 3 added (1 filtered out) types

You can see that there is a new summary line which starts with the
string: "Unreachable types summary:"

Then in the body of the report, those unreachable types are reported
separately.

In practise, we want to limit the unreachable types to compare
somehow, otherwise we'll end up comparing all the types of the types
of the binary and that can be huge.  So we want to limit the
unreachable type analysis to types that are defined in public headers.

So, for abipkgdiff, one can limit the analysis of non-reachable types
to those defined in public headers by supplying the --devel{1,2}
options that specifies the development packages that contain said
public headers.  For abidiff however, you'll want to use the
--headers-dir{1,2} options for that.

The patch comes with appropriate regression tests.

	* include/abg-comparison.h (string_type_base_sptr_map): Define new
	typedef.
	(diff_context::show_unreachable_types): Declare new member
	functions.
	(corpus_diff::{deleted_unreachable_types,
	deleted_unreachable_types_sorted, added_unreachable_types,
	added_unreachable_types_sorted, changed_unreachable_types,
	changed_unreachable_types_sorted}): Likewise.
	(maybe_report_unreachable_type_changes): Declare this function a
	friend of class corpus_diff.
	(corpus_diff::diff_stats::{num_added_unreachable_types,
	num_added_unreachable_types_filtered_out,
	net_num_added_unreachable_types, num_removed_unreachable_types,
	num_removed_unreachable_types_filtered_out,
	net_num_removed_unreachable_types, num_changed_unreachable_types,
	num_changed_unreachable_types_filtered_out,
	net_num_changed_unreachable_types}): Likewise.
	* src/abg-comparison-priv.h
	(diff_context::priv::show_unreachable_types_): Define new data
	member.
	(diff_context::priv::priv): Initialize the new data member.
	(diff_comp::operator()): Use pretty representation of diff
	subjects to sort them, rather than just their name.  Also, add
	comment to the other member functions of diff_comp.
	(corpus_diff::{unreachable_types_edit_script_,
	deleted_unreachable_types_, deleted_unreachable_types_sorted_,
	suppressed_deleted_unreachable_types_, added_unreachable_types_,
	added_unreachable_types_sorted_,
	suppressed_added_unreachable_types_, changed_unreachable_types_,
	changed_unreachable_types_sorted_}): Define new data members.
	(corpus_diff::priv::apply_supprs_to_added_removed_fns_vars_unreachable_types):
	Changed the name of
	corpus_diff::priv::apply_suppressions_to_added_removed_fns_vars into
	this.
	(corpus_diff::priv::{added_unreachable_type_is_suppressed,
	deleted_unreachable_type_is_suppressed,
	changed_unreachable_types_sorted, count_unreachable_types}):
	Declare new member functions.
	(corpus_diff::diff_stats::priv::{num_added_unreachable_types,
	num_added_unreachable_types_filtered_out,
	num_removed_unreachable_types,
	num_removed_unreachable_types_filtered_out,
	num_changed_unreachable_types,
	num_changed_unreachable_types_filtered_out}): Define new data
	members.
	(sort_string_type_base_sptr_map): Declare new function.
	* src/abg-comparison.cc (sort_string_type_base_sptr_map)
	(diff_context::show_unreachable_types): Define new functions.
	(corpus_diff::diff_stats::{num_added_unreachable_types,
	num_added_unreachable_types_filtered_out,
	net_num_added_unreachable_types,
	net_num_removed_unreachable_types,
	num_removed_unreachable_types_filtered_out,
	num_removed_unreachable_types}): Define new member functions.
	(diff_maps::insert_diff_node): Do not update the map "diff ->
	impacted interfaces" if the current impacted interface is nil.
	This happens if we are looking at a diff node for a change on a
	type that is not reachable from any interfaces.
	(corpus_diff::priv::ensure_lookup_tables_populated): Handle the
	edit script for unreachable types.
	(corpus_diff::priv::apply_supprs_to_added_removed_fns_vars_unreachable_types):
	Rename
	corpus_diff::priv::apply_suppressions_to_added_removed_fns_vars
	into this.  Apply suppression specifications to added and removed
	unreachable types as well.
	(corpus_diff::priv::{added,deleted}_unreachable_type_is_suppressed):
	Define new member functions.
	(corpus_diff::priv::{count_unreachable_types,
	changed_unreachable_types_sorted}): Likewise.
	(corpus_diff::priv::apply_filters_and_compute_diff_stats): Update
	statistics (including walking changed unreachable types to apply
	categorization and redundancy filters to them) related to
	unreachable types.
	(corpus_diff::priv::emit_diff_stats): Emit diff stats related to
	unreachable types.
	(corpus_diff::priv::maybe_dump_diff_tree): Dump diff tree nodes
	related to unreachable types.
	(corpus_diff::{deleted_unreachable_types,
	deleted_unreachable_types_sorted, added_unreachable_types,
	added_unreachable_types_sorted, changed_unreachable_types,
	changed_unreachable_types_sorted): Define new member functions.
	(corpus_diff::has_changes): Take deleted/added/changed unreachable
	types into account.
	(corpus_diff::has_incompatible_changes): Take net removed/changed
	unreachable types into account.
	(corpus_diff::has_net_subtype_changes): Take net removed and
	changed unreachable types into account.
	(corpus_diff::has_net_changes): Take net removed/added/changed
	unreachable types into account.
	(corpus_diff::traverse): When traversing the components of a
	corpus_diff node, make sure to traverse the changed unreachable
	types of the corpus.
	(leaf_diff_node_marker_visitor::visit_begin): Arrange for the fact
	that the current topmost interface can be nil if we are looking at
	types not reachable from global functions/variables.  Also, make
	sure that only leaf nodes that are reachable from a global
	function/variable are recorded as leaf nodes.
	(compute_diff): In the overload for corpus_sptr, compute the
	changes between types not reachable from global functions and
	variables, if the user wishes that we do so.  Also, add more
	comments.
	(apply_suppressions): Update for the name change of the function
	apply_suppressions_to_added_removed_fns_vars to
	apply_supprs_to_added_removed_fns_vars_unreachable_types.
	* include/abg-corpus.h
	(corpus::{record_type_as_reachable_from_public_interfaces,
	type_is_reachable_from_public_interfaces,
	get_types_not_reachable_from_public_interfaces}): Declare new
	member functions.
	(corpus::recording_types_reachable_from_public_interface_supported):
	Declare new virtual member function.
	(corpus_group::get_public_types_pretty_representations): Declare
	new member functons.
	(corpus_group::recording_types_reachable_from_public_interface_supported):
	Declare new virtual member function.
	* src/abg-corpus-priv.h
	(corpus::priv::{types_not_reachable_from_pub_ifaces_,
	pub_type_pretty_reprs_}): Define new data members.
	(corpus::priv::priv): Initialize the pub_type_pretty_reprs_ data
	member because it's a pointer.
	(corpus::priv::get_public_types_pretty_representations): Declare
	new member function.
	(corpus::priv::~priv): Declare a destructor.
	* src/abg-corpus.cc
	(corpus::priv::get_public_types_pretty_representations): Define
	new member function.
	(corpus::priv::~priv): Define new destructor to delete the new
	pub_type_pretty_reprs_ member pointer.
	(corpus::{record_type_as_reachable_from_public_interfaces,
	type_is_reachable_from_public_interfaces,
	get_types_not_reachable_from_public_interfaces,
	recording_types_reachable_from_public_interface_supported}):
	Define new member functions
	(corpus_group::get_public_types_pretty_representations): Likewise.
	* include/abg-diff-utils.h (struct deep_ptr_eq_functor): Document
	the equality operator.  Also, add an overload to the equality
	operator, for weak_ptr<T>.  The existing equality operator
	overload was just for shared_ptr<T>.
	* include/abg-fwd.h (is_user_defined_type): Declare function.
	* include/abg-ir.h (operator!=(const decl_base_sptr&, const
	decl_base_sptr&)): Declare new operator.
	(type_maps::get_types_sorted_by_name): Declare
	new member function.
	(decl_base::{g,s}et_is_artificial): Declare new member function.
	(function_decl::parameter::{g,s}et_artificial): Remove these
	member functions.
	* src/abg-ir.cc (operator!=(const decl_base_sptr&, const
	decl_base_sptr&)): Define new operator.
	(decl_base::priv::is_artificial_): Define new data
	member.
	(type_maps::priv::sorted_types_): Define new data member.
	(struct type_name_comp): Define new comparison functor to sort
	types based on their pretty representations.
	(decl_base::priv::priv): Initialize it.
	(decl_base::{g,s}et_is_artificial): Define new member functions.
	(type_maps::get_types_sorted_by_name): Define new member function.
	(is_user_defined_type): Define new function overloads.
	(strip_typedef, function_type::{function_type, set_parameters}):
	Adjust using decl_base::get_is_artificial rather than
	function_decl::parameter::get_artificial.
	(function_decl::parameter::priv::artificial_): Remove this data
	member.
	(function_decl::parameter::priv::priv): Adjust to the removal of
	function_decl::parameter::priv::artificial_.  This constructor
	does not take an "is_artificial" flag anymore.
	(function_decl::parameter::parameter): Adjust to the removal of
	the is_artificial flag from the arguments of the constructor of
	function_decl::parameter::parameter::priv.
	(function_decl::parameter::get_artificial): Remove this member
	function.
	* src/abg-reporter-priv.h (maybe_report_unreachable_type_changes):
	Declare new function.
	* src/abg-reporter-priv.cc
	(maybe_report_unreachable_type_changes): Define new function.
	* src/abg-default-reporter.cc (default_reporter::report): In the
	overload for corpus_diff&, report added/removed/changed types that
	are not reachable from global functions and variables using the
	new function maybe_report_unreachable_type_changes.
	* src/abg-leaf-reporter.cc (leaf_reporter::report): In the
	overload for corpus_diff, report changes to types unreachable from
	global functions or variables, using the new function
	maybe_report_unreachable_type_changes.
	* src/abg-dwarf-reader.cc (build_ir_node_from_die): When the user
	requests that all types be loaded, record relevant types as
	reachable from global functions and variables.
	(build_enum_type, add_or_update_class_type)
	(add_or_update_union_type): Read the 'is-artificial' DWARF
	attribute and set the corresponding decl_base property
	accordingly.
	(finish_member_function_reading, strip_typedef)
	(function_type::function_type): Adjust using
	decl_base::get_is_artificial, rather than
	function_decl::parameter::get_artificial.
	* include/abg-reader.h
	(consider_types_not_reachable_from_public_interfaces): Declare new
	function.
	* src/abg-reader.cc
	(read_context::m_tracking_non_reachable_types): Add new data
	member.
	(read_context::read_context): Initialize it.
	(read_context::tracking_non_reachable_types): Define accessors for
	the new data member above.
	(read_is_declaration_only): Re-indent.
	(read_is_artificial): Define new helper function.
	(build_function_parameter): Use the new read_is_artificial
	function here, rather than open-coding it.
	(build_enum_type_decl, build_class_decl, build_union_decl):
	Support reading the 'is-artificial' property by using the new
	read_is_artificial function.
	(read_corpus_from_input): If the user wants us to take
	non-reachable types into account, then make sure we do so.
	(read_tracking_non_reachable_types, read_is_non_reachable_type):
	Define new static functions.
	(handle_element_node, build_type): Read the "is-non-reachable"
	attribute on type element nodes if the user wants us to track
	non-reachable types.
	(consider_types_not_reachable_from_public_interfaces): Define new
	function.
	* src/abg-writer.cc (write_is_artificial): Define new static
	helper function.
	(annotate): Adjust using decl_base::get_is_artificial rather than
	function_decl::parameter::get_artificial.
	(write_enum_type_decl, write_class_decl_opening_tag)
	(write_union_decl_opening_tag): Support writing the
	"is-artificial" property, using the new write_is_artificial
	function.
	(write_function_type): Adjust this to use the new
	write_is_artificial rather than open-coding writing the
	'is-artificial' attribute.
	(write_is_non_reachable)
	(write_tracking_non_reachable_types): Define new static functions.
	(write_enum_type_decl, write_class_decl_opening_tag)
	(write_union_decl_opening_tag): Write the 'is-no-reachable'
	attribute when applicable.
	(write_corpus, write_corpus_group): Write the
	'tracking-non-reachable-types' attribute when applicable.
	* tools/abidiff.cc (options::options): Initialize ...
	(options::show_all_types): ... new data member.
	(display_usage): Add help string from the new
	--non-reachable-types option.
	(parse_command_line): Parse the new --non-reachable-types option.
	(set_diff_context_from_opts): Set the
	dwarf_reader::read_context::show_unreachable_types property.
	(set_native_xml_reader_options): Define new
	static function.
	(main): Load all types when analyzing the DWARF or the ABIXML
	files, if the user wants us to do so.
	* tools/abipkgdiff.cc (options::show_all_types): Define new data
	member.
	(options::options): Initialize it.
	(parse_command_line): Parse the --non-reachable-types option to
	set the options::show_all_types data member.
	(display_usage): Add a help string for the new
	--non-reachable-types option.
	(set_diff_context_from_opts): Set the
	dwarf_reader::read_context::show_unreachable_types property based
	on the options::show_all_type data member.
	(compare): Configure the read context to load all types while
	analyzing the DWARF info, depending on the options::show_all_type
	data member.
	* doc/manuals/abidiff.rst: Document the new --non-reachable-types
	option added to abidiff above.
	* doc/manuals/abipkgdiff.rst: Add documentation for the
	--non-reachable-types option.
	* tests/data/test-diff-suppr/test47-non-reachable-types-v{0,1}.c:
	Source code files of test binary input.
	* tests/data/test-diff-suppr/test47-non-reachable-types-suppr-{1,2,3,4,5}.txt:
	New test input files.
	* tests/data/test-diff-suppr/test47-non-reachable-types-report-{1,2,3,4,5,6,7,8,9,10}.txt:
	New test reference output files.
	* tests/data/test-diff-suppr/test47-non-reachable-types-v{0,1}.o.alltypes.abixml:
	New test input abixml.
	* tests/data/Makefile.am: Add the new test material to source
	distribution.
	* tests/test-diff-suppr.cc (in_out_specs): Add the new tests above
	to this test harness.
	* tests/data/test-abidiff/test-struct1-report.txt: Adjust.
	* tests/data/test-diff-pkg/PR24690/flatpak-debuginfo-1.2.4-3.fc30.x86_64.rpm:
	New input binary RPM.
	* tests/data/test-diff-pkg/PR24690/flatpak-debuginfo-1.4.0-1.fc30.x86_64.rpm:
	Likewise.
	* tests/data/test-diff-pkg/PR24690/flatpak-devel-1.2.4-3.fc30.x86_64.rpm:
	Likewise.
	* tests/data/test-diff-pkg/PR24690/flatpak-devel-1.4.0-1.fc30.x86_64.rpm:
	Likewise.
	* tests/data/test-diff-pkg/PR24690/flatpak-libs-1.2.4-3.fc30.x86_64.rpm:
	Likewise.
	* tests/data/test-diff-pkg/PR24690/flatpak-libs-1.4.0-1.fc30.x86_64.rpm:
	Likewise.
	* tests/data/test-diff-pkg/PR24690/flatpak-libs-debuginfo-1.2.4-3.fc30.x86_64.rpm:
	Likewise.
	* tests/data/test-diff-pkg/PR24690/flatpak-libs-debuginfo-1.4.0-1.fc30.x86_64.rpm:
	Likewise.
	* tests/data/test-diff-pkg/PR24690/PR24690-report-0.txt: New test
	reference output.
	* tests/data/Makefile.am: Add the new test material above to
	source distribution.
	* tests/test-diff-pkg.cc (in_out_specs): Add the new test material
	above to this test harness.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2020-01-06 14:26:00 +01:00
Matthias Maennich
4665752256 kmidiff: fix help message
Add the missing line breaks.

	* tools/kmidiff.c (display_usage): add missing line breaks to
	help text

Signed-off-by: Matthias Maennich <maennich@google.com>
2019-10-07 11:06:30 +02:00
Dodji Seketeli
bc2d2ce660 Serialize canonical types to avoid testing if types have been emitted
When emitting abixml, profiling shows that we spend a great deal of
time testing if a given type has been emitted already, to avoid
emitting a given type more than once.  This makes the serialization
phase take more time than the binary analysis phase!

This patch leverages the fact that we already have the set of
canonical types in the system.  While emitting that set entirely, we
don't need to test if a type has been emitted already because we know
by definition that every type is present just once in that set, more
or less.  OK, because there are also types that don't have canonical
types (for instance, declaration-only class/structs), we'll still have
to check of those types have already been emitted, but this is a very
small set to handle.

The patch thus organizes the canonical types per scope, so that when
emitting a scope and the canonical types within it, the type is
emitted in its correct namespace.

Then, when emitting a translation unit and each namespaces in it, the
patch emits the canonical types of those namespaces.

The patch arranges for some ancillary things that are needed to make
the whole picture be coherent enough for things to keep working.

Testing shows that we gained ~ 30% of performance by doing this, while
analysing the whole linux kernel 5.1 version.  We went from ~ 3m30s
minutes to less than 2m30s.

With this patch, the serialization phase now takes less time than the
analysis time.

	* include/abg-fwd.h (is_decl_slow)
	(peel_pointer_or_reference_type): Declare new functions.
	* include/abg-ir.h (struct canonical_type_hash): Define new type.
	(type_base_ptr_set_type, type_base_ptrs_type)
	(type_base_sptrs_type, canonical_type_sptr_set_type): Define new
	typedefs.
	(environment::get_canonical_types_map): Declare new member
	function.
	(scope_decl::{get_canonical_types, get_sorted_canonical_types}):
	Declare new member functions.
	* src/abg-ir.cc (is_ptr_ref_or_qual_type)
	(peel_pointer_or_reference_type, is_decl_slow): Define new
	functions.
	(environment::{get_canonical_types_map}): Define new member
	functions.
	(canonical_type_hash::operator()): Likewise.
	(scope_decl::{get_canonical_types, get_sorted_canonical_types}):
	Likewise.
	(struct type_topo_comp): Define new comparison functor type.
	(environment::{sorted_canonical_types_}): Define new data member.
	(scope_decl::priv::{canonical_types_, sorted_canonical_types_}):
	Likewise.
	(scope_decl::is_empty): Take the presence of canonical types into
	account when determining if a scope is empty or not.
	(is_decl): Make this work for cases where the artifact at hand is
	a type which has a declaration, as opposed to being a pure
	declaration like a variable or a function.
	(canonicalize): Add the canonical type the list of canonical types
	of its scope.
	* src/abg-dwarf-reader.cc (read_context::die_is_in_cplus_plus):
	Define new member function.
	* src/abg-writer.cc (write_type, write_canonical_types_of_scope):
	Define new static functions.
	(fn_type_ptr_set_type): Define new typedef.
	(write_context::{m_referenced_fn_types_set,
	m_referenced_non_canonical_types_set}): Add new data members.
	(write_context::m_referenced_types_set): Renamed
	m_referenced_types_map into this.
	(write_context::get_referenced_types): Adjust.
	(write_context::get_referenced_{function_types,
	non_canonical_types}):
	(write_context::record_type_as_referenced): Adjust to add the
	referenced type in the proper set which would be one of the three
	following: write_context::{get_referenced_types,
	get_referenced_function_types,
	get_referenced_non_canonical_types}.
	(write_context::{type_is_referenced, clear_referenced}): Adjust.
	(write_translation_unit): Use the new
	write_canonical_types_of_scope.  Also emit declaration-only
	classes that have member types.  Do not test if a given type of a
	given scope has been emitted, in general, as this was super slow
	given the number of types.  Emit referenced function types (as
	these don't belong to any scope).  Rather than using the expensive
	"is_function_type" on *all* the referenced types, just walk the
	set write_context::get_referenced_function_types.  Likewise,
	rather than using type_base::get_naked_canonical_type on
	*all* the referenced types, just walk the set
	write_context::get_referenced_non_canonical_types
	(write_class): Use write_canonical_types_of_scope here.
	* tools/abilint.cc (main): Support linting corpus group abixml
	files.
	* tests/data/test-annotate/libtest23.so.abi: Adjust.
	* tests/data/test-annotate/libtest24-drop-fns-2.so.abi: Likewise.
	* tests/data/test-annotate/libtest24-drop-fns.so.abi: Likewise.
	* tests/data/test-annotate/test-anonymous-members-0.o.abi: Likewise.
	* tests/data/test-annotate/test0.abi: Likewise.
	* tests/data/test-annotate/test1.abi: Likewise.
	* tests/data/test-annotate/test13-pr18894.so.abi: Likewise.
	* tests/data/test-annotate/test14-pr18893.so.abi: Likewise.
	* tests/data/test-annotate/test15-pr18892.so.abi: Likewise.
	* tests/data/test-annotate/test17-pr19027.so.abi: Likewise.
	* tests/data/test-annotate/test18-pr19037-libvtkRenderingLIC-6.1.so.abi: Likewise.
	* tests/data/test-annotate/test19-pr19023-libtcmalloc_and_profiler.so.abi: Likewise.
	* tests/data/test-annotate/test2.so.abi: Likewise.
	* tests/data/test-annotate/test20-pr19025-libvtkParallelCore-6.1.so.abi: Likewise.
	* tests/data/test-annotate/test21-pr19092.so.abi: Likewise.
	* tests/data/test-annotate/test4.so.abi: Likewise.
	* tests/data/test-annotate/test6.so.abi: Likewise.
	* tests/data/test-annotate/test7.so.abi: Likewise.
	* tests/data/test-annotate/test8-qualified-this-pointer.so.abi: Likewise.
	* tests/data/test-read-dwarf/PR22015-libboost_iostreams.so.abi: Likewise.
	* tests/data/test-read-dwarf/PR22122-libftdc.so.abi: Likewise.
	* tests/data/test-read-dwarf/PR24378-fn-is-not-scope.abi: Likewise.
	* tests/data/test-read-dwarf/libtest23.so.abi: Likewise.
	* tests/data/test-read-dwarf/libtest24-drop-fns-2.so.abi: Likewise.
	* tests/data/test-read-dwarf/libtest24-drop-fns.so.abi: Likewise.
	* tests/data/test-read-dwarf/test0.abi: Likewise.
	* tests/data/test-read-dwarf/test1.abi: Likewise.
	* tests/data/test-read-dwarf/test10-pr18818-gcc.so.abi: Likewise.
	* tests/data/test-read-dwarf/test11-pr18828.so.abi: Likewise.
	* tests/data/test-read-dwarf/test12-pr18844.so.abi: Likewise.
	* tests/data/test-read-dwarf/test13-pr18894.so.abi: Likewise.
	* tests/data/test-read-dwarf/test14-pr18893.so.abi: Likewise.
	* tests/data/test-read-dwarf/test15-pr18892.so.abi: Likewise.
	* tests/data/test-read-dwarf/test16-pr18904.so.abi: Likewise.
	* tests/data/test-read-dwarf/test17-pr19027.so.abi: Likewise.
	* tests/data/test-read-dwarf/test18-pr19037-libvtkRenderingLIC-6.1.so.abi: Likewise.
	* tests/data/test-read-dwarf/test19-pr19023-libtcmalloc_and_profiler.so.abi: Likewise.
	* tests/data/test-read-dwarf/test2.so.abi: Likewise.
	* tests/data/test-read-dwarf/test20-pr19025-libvtkParallelCore-6.1.so.abi: Likewise.
	* tests/data/test-read-dwarf/test21-pr19092.so.abi: Likewise.
	* tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi: Likewise.
	* tests/data/test-read-dwarf/test4.so.abi: Likewise.
	* tests/data/test-read-dwarf/test6.so.abi: Likewise.
	* tests/data/test-read-dwarf/test7.so.abi: Likewise.
	* tests/data/test-read-dwarf/test8-qualified-this-pointer.so.abi: Likewise.
	* tests/data/test-read-dwarf/test9-pr18818-clang.so.abi: Likewise.
	* tests/data/test-read-write/test10.xml: Likewise.
	* tests/data/test-read-write/test14.xml: Likewise.
	* tests/data/test-read-write/test15.xml: Likewise.
	* tests/data/test-read-write/test17.xml: Likewise.
	* tests/data/test-read-write/test18.xml: Likewise.
	* tests/data/test-read-write/test19.xml: Likewise.
	* tests/data/test-read-write/test2.xml: Likewise.
	* tests/data/test-read-write/test20.xml: Likewise.
	* tests/data/test-read-write/test21.xml: Likewise.
	* tests/data/test-read-write/test22.xml: Likewise.
	* tests/data/test-read-write/test23.xml: Likewise.
	* tests/data/test-read-write/test24.xml: Likewise.
	* tests/data/test-read-write/test25.xml: Likewise.
	* tests/data/test-read-write/test26.xml: Likewise.
	* tests/data/test-read-write/test27.xml: Likewise.
	* tests/data/test-read-write/test28-without-std-fns-ref.xml: Likewise.
	* tests/data/test-read-write/test28-without-std-vars-ref.xml: Likewise.
	* tests/data/test-read-write/test3.xml: Likewise.
	* tests/data/test-read-write/test6.xml: Likewise.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2019-09-17 17:52:26 +02:00
Dodji Seketeli
3df54522b8 Add timing to the verbose logs of abidw
While doing my recent optimization work, it became useful to have an
idea of the time different parts of the processing pipeline are
taking.

This patch introduces an abigail::tools_utils::timer type that is easy
to use to time a given part of the code and emit the elapsed time to
an output stream.

This abigail::tools_utils::timer type is thus used to time various
parts of the processing pipeline involved in abidw.  Just using the
existing --verbose option now yields timing information.

	* include/abg-tools-utils.h (class timer): Declare new type.
	(operator<<(ostream&, const timer&)): Declare new streaming
	operator for the new timer type.
	* src/abg-tools-utils.cc (struct timer::priv): Define new type.
	(timer::{timer, start, stop, value_in_seconds, value,
	value_as_string, ~timer}): Define member functions.
	(operator<<(ostream& o, const timer& t)): Define streaming
	operator.
	(build_corpus_group_from_kernel_dist_under): Add timing logs to
	the linux kernel reading process.
	* src/abg-dwarf-reader.cc
	(read_context::canonicalize_types_scheduled): Add timing logs to
	type canonicalization.
	(read_debug_info_into_corpus): Add timing logs for the whole debug
	info loading and internal representation building process.
	* tools/abidw.cc (load_corpus_and_write_abixml): Add timing logs
	for the binary loading and serizalization process.
	(load_kernel_corpus_group_and_write_abixml): Add timing logs the
	Linux Kernel binary loading and writing process.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2019-07-19 10:46:42 +02:00
Matthias Maennich
beededda29 Add compatibility layer for C++11 mode
Introduce a compatibility layer for C++11 code by adding
include/abg-cxx-compat.h. abg-cxx-compat defines a new namespace
abg_compat and defines
	abg_compat::hash
	abg_compat::shared_ptr
	abg_compat::weak_ptr
	abg_compat::dynamic_pointer_cast
	abg_compat::static_pointer_cast
	abg_compat::unordered_map
	abg_compat::unordered_set
based on definitions from std::tr1 (std=gnu++98) or std:: (std=gnu++11).

I decided for introducing abg_compat:: rather than polluting abigail::
to allow an easier transition to C++11 at a later time and to not subtly
break existing code.

As the shared_ptr in C++11 defines shared_ptr::operator bool() explicit,
some locations where a shared_ptr is assigned to boolean, needed to be
adjusted to explicitly cast to bool.

	* include/abg-cxx-compat.h: new file introducing the abg_compat
	  namespace to provide C++11 functionality from either std::tr1
	  or std::
	* include/Makefile.am: Add the new abg-cxx-compat.h to source
	  distribution.
	* include/abg-comparison.h: replace std::tr1 usage by abg_compat
	  and adjust includes accordingly: likewise
	* include/abg-diff-utils.h: likewise
	* include/abg-fwd.h: likewise
	* include/abg-ini.h: likewise
	* include/abg-interned-str.h: likewise
	* include/abg-ir.h: likewise
	* include/abg-libxml-utils.h: likewise
	* include/abg-libzip-utils.h: likewise
	* include/abg-reporter.h: likewise
	* include/abg-sptr-utils.h: likewise
	* include/abg-suppression.h: likewise
	* include/abg-tools-utils.h: likewise
	* include/abg-workers.h: likewise
	* src/abg-comp-filter.cc: likewise
	* src/abg-comparison-priv.h: likewise
	* src/abg-corpus.cc: likewise
	* src/abg-dwarf-reader.cc: likewise
	* src/abg-hash.cc: likewise
	* src/abg-ir.cc: likewise
	* src/abg-reader.cc: likewise
	* src/abg-suppression.cc: likewise
	* src/abg-tools-utils.cc: likewise
	* src/abg-writer.cc: likewise
	* tests/test-diff-filter.cc: likewise
	* tests/test-diff-pkg.cc: likewise
	* tests/test-read-dwarf.cc: likewise
	* tests/test-read-write.cc: likewise
	* tests/test-types-stability.cc: likewise
	* tests/test-write-read-archive.cc: likewise
	* tools/abicompat.cc: likewise
	* tools/abidiff.cc: likewise
	* tools/abidw.cc: likewise
	* tools/abilint.cc: likewise
	* tools/abipkgdiff.cc: likewise

Signed-off-by: Matthias Maennich <maennich@google.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2019-07-09 18:05:28 +02:00
Matthias Maennich
f3f7537b6e abidw: add option to only emit file names (--short-locs)
Various emitted directories contain machine specific information and
therefore break reproducibility of abidw's output across different
build paths.

Hence introduce --short-locs to only emit file names.

Thanks to earlier changes, adding an option boils down to adding it to
set_opts and to the write_context along with some auxiliary functions
for setting and getting.

	* include/abg-writer.h (set_short_locs): Declare new function.
	(set_common_options): Use it.
	set_opts
	* src/abg-writer.cc (write_context::m_short_locs): New data
	member.
	(write_context::write_context): Initialize it.
	(write_context::{g,s}et_short_locs): Define new accessors.
	(write_location, write_translation_unit, write_corpus): Honour the
	new write_context::get_short_locs property.
	(set_short_locs): Define new function.
	* tools/abidw.cc (options::short_locs): New data member.
	(display_usage): Help string for the new --no-show-locs option.
	(parse_command_line): Parse the new --no-show-locs option.

Signed-off-by: Matthias Maennich <maennich@google.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2019-05-22 14:33:45 +02:00
Matthias Maennich
bf9e8b9448 abidw: add option to omit the compilation directory
The compilation directory contains machine specific information
therefore breaks reproducibility of abidw's output across different
build paths. Hence introduce --no-comp-dir-path (as in the xml
attribute). Internally I decided to not carry on the duplication of
'dir' and 'path' and used 'comp_dir'.

Thanks to earlier changes, adding an option boils down to adding it to
set_common_options and to the write_context along with some auxiliary
functions for setting and getting.

write_translation_unit uses the flag in the write_context and omits the
comp-dir-path if asked for.

	* include/abg-writer.h (set_write_comp_dir): Declare new function.
	(set_common_options): Use it.
	* src/abg-writer.cc (write_context::m_write_comp_dir): Define new
	data member.
	(write_context::write_context): Initialize it.
	(write_context::{g,s}et_write_comp_dir): Define new member
	accessors.
	(set_write_comp_dir): Define new free-form getter.
	(write_translation_unit): Teach to respect write_comp_dir flag of
	write_context.
	* tools/abidw.cc (options::write_corpus_path): Define new data
	member.
	(options::options): Initialize it.
	(display_usage): Add doc string for a new command line option: --no-comp-dir-path.
	(parse_command_line): Parse the new command line option --no-comp-dir-path.

Signed-off-by: Matthias Maennich <maennich@google.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2019-05-22 14:33:45 +02:00
Matthias Maennich
fca2661581 Make write_architecture and write_corpus_path flags in the write_context
Having write_context carry corresponding flags for output sensitive
command line options, is useful to ensure these options are not lost in
chains for write_* calls. In particular, these options can have various
meanings depending on the context (corpus, corpus_group, etc.)

Hence add them to the write_context along with getters and setters and
make the writers aware of their existence. We do not need to modify the
corpus or corpus group's path or architecture any longer as they get
ignored for a different reason now.

Finally, drop the flag handling in abidw as it is already done via
set_opts, which learned about these new flags.

	* include/abg-writer.h (set_write_architecture)
	(set_write_corpus_path): Declare new getter functions.
	(write_corpus): Take a new "member_of_group" argument.
	(set_common_options): Use set_write_{architecture, corpus_path}
	here.
	* src/abg-writer.cc (write_context::m_write_{architecture,
	corpus_path}}): Add new data members.
	(write_context::write_context): Initialize the new data members.
	(write_context::{s,g}et_write_{architecture, corpus}): Define new
	accessors.
	(set_write_{architecture, corpus}): Define new free-form getter
	functions.
	(write_corpus): Add flag to make aware if written as part of a
	group.
	* tools/abidw.cc (load_corpus_and_write_abixml)
	(load_kernel_corpus_group_and_write_abixml): Drop obsolete option
	handling as xml_writer::set_common_options now takes care of it.

Signed-off-by: Matthias Maennich <maennich@google.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>

ldiff --git a/include/abg-writer.h b/include/abg-writer.h
index 200b5f7..729b455 100644
--- a/include/abg-writer.h
+++ b/include/abg-writer.h
@@ -53,6 +53,11 @@ set_show_locs(write_context& ctxt, bool flag);
 void
 set_annotate(write_context& ctxt, bool flag);

+void
+set_write_architecture(write_context& ctxt, bool flag);
+
+void
+set_write_corpus_path(write_context& ctxt, bool flag);

 /// A convenience generic function to set common options (usually used
 /// by Libabigail tools) from a generic options carrying-object, into
@@ -69,6 +74,8 @@ set_common_options(write_context& ctxt, const OPTS& opts)
 {
   set_annotate(ctxt, opts.annotate);
   set_show_locs(ctxt, opts.show_locs);
+  set_write_architecture(ctxt, opts.write_architecture);
+  set_write_corpus_path(ctxt, opts.write_corpus_path);
 }

 void
@@ -105,7 +112,10 @@ write_corpus_to_archive(const corpus_sptr corp,
 			const bool annotate = false);

 bool
-write_corpus(write_context& ctxt, const corpus_sptr& corpus, unsigned indent);
+write_corpus(write_context&	ctxt,
+	     const corpus_sptr& corpus,
+	     unsigned		indent,
+	     bool		member_of_group = false);

 bool ABG_DEPRECATED
 write_corpus(const corpus_sptr& corpus, unsigned indent, write_context& ctxt);

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2019-05-22 14:33:45 +02:00
Matthias Maennich
344138e6b4 abidw: Consolidate setting options
When setting options meant to be used for the write_context, it is easy
to forget to change all relavant locations. In order to consolidate
that, introduce a set_opts function that sets various known options.

We benefit from earlier refactoring as now the write_context is passed
around to carry options for writers. Hence we can be sure, that if we
set up the context correctly (and do not use deprecated functionality),
the respective write_* function will see the options set in the context.

	* include/abg-writer.h (set_common_option): Declare new function.
	* tools/abidw.cc (load_corpus_and_write_abixml)
	(load_kernel_corpus_group_and_write_abixml): Use the newly
	introduced set_common_option.

Signed-off-by: Matthias Maennich <maennich@google.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2019-05-22 14:33:45 +02:00
Matthias Maennich
6c07e82933 write_context: allow mutating the ostream used
Allowing the mutation of the ostream, allows heavy reuse of the
write_context as this is the distinction in most places where
write_context is used.

Hence, fixup various users of write_context and use common objects where
applicable.

	* include/abg-writer.h (set_ostream): Declare new function.
	* src/abg-writer.cc (write_context::m_ostream): Make this data
	member be a pointer rather than a reference.
	(write_context::{write_context, get_ostream): Adjust.  member.
	(write_context::set_ostream): Define new member function.
	(set_ostream): Define new free-form function.
	* tools/abidw.cc (load_corpus_and_write_abixml)
	(load_kernel_corpus_group_and_write_abixml): Use the feature of
	mutating the ostream and reuse the write_context in most cases.

Signed-off-by: Matthias Maennich <maennich@google.com>
2019-05-22 14:33:45 +02:00
Matthias Maennich
6aeed171c1 abg-writer: Refactor write_corpus_group API
Introduce a new call overload for write_corpus_group that follows the
parameter order context, object (i.e. corpus_group), indent.

Deprecate all other overloads that were part of the API and mostly
forward them to the new overload. That effort is made to ensure
write_context is always provided. write_context allows access to all
options that influence the output format.

	* include/abg-writer.h (write_corpus_group): Introduce new
	overload write_corpus_group(ctxt, corpus_group, indent) and
	deprecate all others.
	* src/abg-writer.cc (write_corpus_group): Likewise for the
	definitions and adjust.
	* tools/abidw.cc (load_kernel_corpus_group_and_write_abixml):
	Migrate to new API of write_corpus_group()

Signed-off-by: Matthias Maennich <maennich@google.com>
2019-05-22 14:33:45 +02:00
Matthias Maennich
948f27480f abg-writer: Refactor write_corpus API
Introduce a new overload for write_corpus that follows the parameter
order context, object (i.e. corpus), indent.

Deprecate all other overloads that were part of the API and mostly
forward them to the new overload. That effort is made to ensure
write_context is always provided. write_context allows access to all
options that influence the output format.

	* include/abg-writer.h (write_corpus): Introduce new overload
	write_corpus(ctxt, corpus, indent) and deprecate all others.
	* src/abg-writer.cc (write_corpus): Likewise for the definitions
	and adjust.
	* tests/test-read-dwarf.cc (test_task::perform): Use the new
	write_corpus which requires a write_context.
	* tools/abidw.cc (load_corpus_and_write_abixml, ): Likewise.
	* tools/abilint.cc (main): Likewise. Also simplify logic around the
	locations as they now can be expressed with less code.

Signed-off-by: Matthias Maennich <maennich@google.com>
2019-05-22 14:33:45 +02:00
Matthias Maennich
f5907c7e74 abg-writer: Refactor write_translation_unit API
Introduce a new overload for write_translation_unit that follows the
parameter order context, object (i.e. translation unit), indent.

Deprecate all other overloads that were part of the API and mostly
forward them to the new one. That effort is made to ensure write_context
is always provided. write_context allows access to all options that
influence the output format.

	* include/abg-writer.h (write_translation_unit): Declare a new
	overload write_translation_unit(ctxt, tu, indent) and deprecate
	all others.
	* src/abg-writer.cc (write_translation_unit): Likewise in the
	definitions.
	(write_corpus, dump, write_translation_unit): Adjust.
	* tools/abilint.cc (main): use new write_translation_unit() API

Signed-off-by: Matthias Maennich <maennich@google.com>
2019-05-22 14:33:45 +02:00
Matthias Maennich via libabigail
b01918eb18 Update .gitignore files to ignore typical dev side products
Add / update .gitignore files for tests/ and tools to ignore
binaries, logs, traces typically produced during development.

 * tests/.gitignore: exclude tests binaries and test results
 * tools/.gitignore: update to ignore produced binaries

Signed-off-by: Matthias Maennich <maennich@google.com>
2019-04-16 16:32:52 +02:00
Matthias Maennich via libabigail
eec8e69b7d abilint: fix return types bool -> int
Returning bool literals from main can be misleading. Returning booleans
maps to (by convention):

   return false -> converted to 0 -> rc=0 considered SUCCESS
   return true  -> converted to 1 -> rc=1 considered FAILURE

Compiling with clang also emits:

  abilint.cc:258:7: warning: bool literal returned from 'main' [-Wmain]
      return true;
      ^      ~~~~

The issues can be addressed by consistently returning integers as also
done in all other mains across the project.

Same issue applies to print-diff-tree.cc.

 * tools/abilint.cc: return int in main rather than bool.
 * tests/print-diff-tree.cc: Likewise.

Signed-off-by: Matthias Maennich <maennich@google.com>
2019-04-16 16:11:01 +02:00
Dodji Seketeli
717fd0a460 Separate public types of first binary from those of the second
In abidiff when the user uses --headers-dir{1,2}, she implicitly
indicates the public types of the first and the second binary.  That
means that any type that is defined in a file that is not located
under the directory tree designated by --headers-dir{1,2} is
considered private and any change involving those private types will
be suppressed.

In practice, what happens is that libabigail constructs a suppression
specification which suppress all types that are defined in files that
are not under the directories located by --headers-dir{1,2}.

abidiff has a problem, though.  It uses the same private type
suppressions (derived from --headers-dir1 and --headers-dir2) when
looking at the first binary *and* the second binary.  It should rather
only use the private type suppression specifications derived from
--headers-dir1 when looking at the first binary, and use the private
type suppression specifications derived from --headers-dir2 when
looking at the second binary.

This problem leads to some false positives like the one reported at
https://gitlab.gnome.org/GNOME/pango/issues/343#note_397761.

This patch fixes this issue by using the private type suppression
specifications derived from --headers-dir1 only when looking at the
first binary, and using the private type suppression specifications
derived from --headers-dir2 only when looking at the second binary.

	* include/abg-dwarf-reader.h (read_context_get_path): Declare new
	function.
	* include/abg-reader.h (read_context_get_path): Likewise.
	* src/abg-dwarf-reader.cc (read_context_get_path): Define new function.
	* src/abg-reader.cc (read_context_get_path): Likewise.
	* tools/abidiff.cc (set_suppressions): Set the suppression
	specification derived from the --headers-dir1 option only for the first
	binary, and similarly, from the --headers-dir2 option only for the
	second binary.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2019-01-16 12:27:45 +01:00
Dodji Seketeli
ad8732316a Bug 23044 - Assertions with side effects
There are lots of spots in libabigail's source code where the argument
of the assert() call does have side effects.  This is a problem
because when the code is compiled with the NDEBUG macro defined, the
assert call does nothing, so the side effects of its argument are then
suppressed, changing the behaviour of the program.

To handle this issue, this patch introduces the ABG_ASSERT macro which
is a wrapper around the assert call that enable the use of side
effects in its argument.  The patch now uses that ABG_ASSERT macro
instead of using the assert call directly.

The patch also makes it so that the configure option accepts the
--disable-assert option so that the user can build libabigail with the
NDEBUG macro defined.

Tested by running the testsuite with and without the --disable-assert
option to configure.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2019-01-09 18:36:56 +01:00
Dodji Seketeli
047342467c Update copyright for 2019
* include/abg-comp-filter.h: Update copyright for 2019
	* include/abg-comparison.h: Update copyright for 2019
	* include/abg-config.h: Update copyright for 2019
	* include/abg-corpus.h: Update copyright for 2019
	* include/abg-diff-utils.h: Update copyright for 2019
	* include/abg-dwarf-reader.h: Update copyright for 2019
	* include/abg-fwd.h: Update copyright for 2019
	* include/abg-hash.h: Update copyright for 2019
	* include/abg-ini.h: Update copyright for 2019
	* include/abg-interned-str.h: Update copyright for 2019
	* include/abg-ir.h: Update copyright for 2019
	* include/abg-libxml-utils.h: Update copyright for 2019
	* include/abg-libzip-utils.h: Update copyright for 2019
	* include/abg-reader.h: Update copyright for 2019
	* include/abg-reporter.h: Update copyright for 2019
	* include/abg-sptr-utils.h: Update copyright for 2019
	* include/abg-suppression.h: Update copyright for 2019
	* include/abg-tools-utils.h: Update copyright for 2019
	* include/abg-traverse.h: Update copyright for 2019
	* include/abg-viz-common.h: Update copyright for 2019
	* include/abg-viz-dot.h: Update copyright for 2019
	* include/abg-viz-svg.h: Update copyright for 2019
	* include/abg-workers.h: Update copyright for 2019
	* include/abg-writer.h: Update copyright for 2019
	* src/abg-comp-filter.cc: Update copyright for 2019
	* src/abg-comparison-priv.h: Update copyright for 2019
	* src/abg-comparison.cc: Update copyright for 2019
	* src/abg-config.cc: Update copyright for 2019
	* src/abg-corpus-priv.h: Update copyright for 2019
	* src/abg-corpus.cc: Update copyright for 2019
	* src/abg-default-reporter.cc: Update copyright for 2019
	* src/abg-diff-utils.cc: Update copyright for 2019
	* src/abg-dwarf-reader.cc: Update copyright for 2019
	* src/abg-hash.cc: Update copyright for 2019
	* src/abg-ini.cc: Update copyright for 2019
	* src/abg-internal.h: Update copyright for 2019
	* src/abg-ir-priv.h: Update copyright for 2019
	* src/abg-ir.cc: Update copyright for 2019
	* src/abg-leaf-reporter.cc: Update copyright for 2019
	* src/abg-libxml-utils.cc: Update copyright for 2019
	* src/abg-libzip-utils.cc: Update copyright for 2019
	* src/abg-reader.cc: Update copyright for 2019
	* src/abg-reporter-priv.cc: Update copyright for 2019
	* src/abg-reporter-priv.h: Update copyright for 2019
	* src/abg-sptr-utils.cc: Update copyright for 2019
	* src/abg-suppression-priv.h: Update copyright for 2019
	* src/abg-suppression.cc: Update copyright for 2019
	* src/abg-tools-utils.cc: Update copyright for 2019
	* src/abg-traverse.cc: Update copyright for 2019
	* src/abg-viz-common.cc: Update copyright for 2019
	* src/abg-viz-dot.cc: Update copyright for 2019
	* src/abg-viz-svg.cc: Update copyright for 2019
	* src/abg-workers.cc: Update copyright for 2019
	* src/abg-writer.cc: Update copyright for 2019
	* tests/print-diff-tree.cc: Update copyright for 2019
	* tests/test-abicompat.cc: Update copyright for 2019
	* tests/test-abidiff-exit.cc: Update copyright for 2019
	* tests/test-abidiff.cc: Update copyright for 2019
	* tests/test-alt-dwarf-file.cc: Update copyright for 2019
	* tests/test-core-diff.cc: Update copyright for 2019
	* tests/test-diff-dwarf-abixml.cc: Update copyright for 2019
	* tests/test-diff-dwarf.cc: Update copyright for 2019
	* tests/test-diff-filter.cc: Update copyright for 2019
	* tests/test-diff-pkg.cc: Update copyright for 2019
	* tests/test-diff-suppr.cc: Update copyright for 2019
	* tests/test-diff2.cc: Update copyright for 2019
	* tests/test-ini.cc: Update copyright for 2019
	* tests/test-ir-walker.cc: Update copyright for 2019
	* tests/test-lookup-syms.cc: Update copyright for 2019
	* tests/test-read-dwarf.cc: Update copyright for 2019
	* tests/test-read-write.cc: Update copyright for 2019
	* tests/test-types-stability.cc: Update copyright for 2019
	* tests/test-utils.cc: Update copyright for 2019
	* tests/test-utils.h: Update copyright for 2019
	* tests/test-write-read-archive.cc: Update copyright for 2019
	* tools/abiar.cc: Update copyright for 2019
	* tools/abicompat.cc: Update copyright for 2019
	* tools/abidiff.cc: Update copyright for 2019
	* tools/abidw.cc: Update copyright for 2019
	* tools/abilint.cc: Update copyright for 2019
	* tools/abipkgdiff.cc: Update copyright for 2019
	* tools/abisym.cc: Update copyright for 2019
	* tools/binilint.cc: Update copyright for 2019
	* tools/kmidiff.cc: Update copyright for 2019
	* update-copyright.sh: Update new year to 2019

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2019-01-07 14:54:47 +01:00
Dodji Seketeli
8fee729a34 Some light style change in abidiff.cc
* tools/abidiff.cc (adjust_diff_context_for_kmidiff): Take a
	reference to diff_context rather than a pointer.
	(main): Adjust.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2018-11-08 18:15:28 +01:00
Dodji Seketeli
61cc36b014 Add a --fail-no-debug-info to abidiff
Add an option to make abidiff to fail if doesn't find debug info.
Without this option, abidiff keeps going and works with only ELF
information, as it can't get the debug info.

	* doc/manuals/abidiff.rst: Document the new --fail-no-debug-info
	option.
	* tools/abidiff.cc (options::fail_no_debug_info): Define new data
	member.
	(display_usage): Provide a help string for the new
	--fail-no-debug-info option.
	(parse_command_line): Parse the new option.
	(main): If --fail-no-debug-info and no debug info was found, or
	not alternate debuginfo file was found, bail out.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2018-11-08 09:04:53 +01:00
Dodji Seketeli
3c0701d59d Support having several debuginfo search dirs for a binary
There are use cases where the split debuginfo file of a given binary
is under a given root directory and that the split debuginfo file
itself depends on an alternate debuginfo file that is under another
unrelated root directory.

In that case, the dwarf reader must be able to look for the debuginfo
files under several unrelated root directories.  The tools abidiff and
abidw must thus support having several occurences of the option
--debug-info-dir1 (or --debug-info-dir2) meaning that the debuginfo
files for the binary must be looked for under several root
directories.

This is what this patch does.

	* doc/manuals/abidiff.rst: Adjust doc for the
	--debug-info-dir{1,2} that can now be provided several times.
	* include/abg-dwarf-reader.h ({create, reset}_read_context)
	(read_corpus_from_elf): Take a vector of debug info root dirs.
	* include/abg-tools-utils.h (trim_leading_string)
	(find_file_under_dir, make_path_absolute_to_be_freed)
	(convert_char_stars_to_char_star_stars): Declare new functions.
	* src/abg-dwarf-reader.cc (find_alt_debug_info_link): Renamed
	find_alt_debug_info_location into this.
	(find_alt_debug_info_path): Define new static function.
	(find_alt_debug_info): Take a vector of debug info root dirs.  Use
	the new find_alt_debug_info_path to look into the debug info root
	dirs for the alt debug info.
	(read_context::debug_info_root_paths_): Define new data member.
	(read_context::read_context): Take a vector of debug info root
	dirs and initialize the new read_context::debug_info_root_paths_.
	(read_context::{initialize, create_default_dwfl}): Take a vector
	of debug info root dirs and adjust.
	(read_context::{add_debug_info_root_paths,
	add_debug_info_root_path, find_alt_debug_info}): Define new member
	functions.
	(read_context::load_debug_info): Look into the debug info roots
	for split debug info files.
	(create_read_context, read_corpus_from_elf): Take a vector of
	debug info root dirs and adjust.
	(has_alt_debug_info): Adjust.
	* src/abg-tools-utils.cc (trim_leading_string)
	(make_path_absolute_to_be_freed, find_file_under_dir)
	(convert_char_stars_to_char_star_stars): Define new functions.
	(entry_of_file_with_name): Define new static function.
	(build_corpus_group_from_kernel_dist_under): Adjust.
	* tests/print-diff-tree.cc (main): Adjust.
	* tests/test-diff-dwarf.cc (main): Adjust.
	* tests/test-ir-walker.cc (main): Adjust.
	* tests/test-read-dwarf.cc (main): Adjust.
	* tools/abicompat.cc (main): Adjust.
	* tools/abidiff.cc (options::di_root_paths{1,2}): Changed
	di_root_path{1,2} into this, change their types into vectors of
	allocated char*.
	(options::prepared_di_root_paths{1,2}): Define new data members.
	(options::~options): Define new destructor.
	(parse_command_line): Adjust.
	(prepare_di_root_paths): Define new static function.
	(handle_error): Remove arguments input_file_name,
	debug_info_dir{1,2}.  Now just take an instance of options
	instead.  Adjust.
	(main): Adjust.
	* tools/abidw.cc (options::dir_root_paths): Renamed dir_root_path
	into this and make it be a vector of allocated char*.
	(options::prepared_di_root_paths): Define new data member.
	(options::~options): Free the allocated char* in
	options::dir_root_paths.
	(parse_command_line): Support several --debug-info-dir.
	(load_corpus_and_write_abixml): Adjust.
	(prepare_di_root_paths): Define static function.
	(main): Adjust.
	* tools/abilint.cc (main): Adjust.
	* tools/abipkgdiff.cc (compare): Adjust.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2018-11-08 09:03:32 +01:00
Dodji Seketeli
672af90736 Fix indentation of help string in abipkgdiff
* tools/abipkgdiff.cc (display_usage): Fix indentation of help
	string.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2018-06-08 05:14:23 +02:00
Dodji Seketeli
ee5f2f06a6 Represent sizes and offsets in bytes and hexadecimal values
In current change reports, sizes and offsets are represented in bits,
and as decimal values.  Some users prefer having those offsets be in
bytes and as hexadecimal values.

This commits adds 4 new options to let users see sizes and offsets be
represented either in bits, bytes, decimal or hexadecimal values.

	* doc/manuals/abidiff.rst: Add documentation for the new
	--show-bits, --show-bytes, --show-hex and --show-dec options.
	* doc/manuals/abipkgdiff.rst: Likewise.
	* doc/manuals/kmidiff.rst: Likewise.
	* include/abg-comparison.h (diff_context::{show_hex_values,
	show_offsets_sizes_in_bits}): Declare new member functions.
	* src/abg-comparison-priv.h (diff_context::priv::{hex_values_,
	show_offsets_sizes_in_bits_}): Declare new data members.
	(diff_context::priv::priv): Initialize them.
	* src/abg-comparison.cc (diff_context::{show_hex_values,
	show_offsets_sizes_in_bits}): Define new member functions.
	* src/abg-default-reporter.cc (default_reporter::report): Adjust
	the call to maybe_report_diff_for_symbol.
	* src/abg-leaf-reporter.cc (leaf_reporter::report): Likewise.
	* src/abg-reporter-priv.h (convert_bits_to_bytes)
	(maybe_convert_bits_to_bytes, emit_num_value, show_offset_or_size)
	(show_numerical_change): Declare new functions.
	(maybe_report_diff_for_symbol): Take a diff_context in parameter.
	* src/abg-reporter-priv.cc (convert_bits_to_bytes, emit_num_value)
	(maybe_convert_bits_to_bytes, show_numerical_change)
	(show_offset_or_size): Define new functions.
	(represent): In the overload for method_decl, var_decl, use the
	new emit_num_value function.
	(represent_data_member): Use the new show_offset_or_size function.
	(maybe_show_relative_offset_change): Use the new
	convert_bits_to_bytes, diff_context::show_offsets_sizes_in_bits,
	emit_num_value functions.
	(maybe_show_relative_offset_change): Likewise.
	(report_size_and_alignment_changes): Use the new emit_num_value
	and show_numerical_change functions.
	(maybe_report_diff_for_symbol): Tak a diff_context in argument.
	Use the new show_numerical_change function.
	* tests/test-diff-filter.cc (in_out_spec): Add a new entry to test
	hexa and bytes output.
	* tools/abidiff.cc (options::{show_hexadecimal_values,
	show_offsets_sizes_in_bits}): New data members.
	(options::options): Initialize them.
	(display_usage): New help strings for the new
	--show{bytes,bits,hex,dec} options.
	(parse_command_line): Parse the new --show{bytes,bits,hex,dec} options.
	(set_diff_context_from_opts) Set the diff context wrt hex and
	bytes values.
	* tools/abipkgdiff.cc (options::{show_hexadecimal_values,
	show_offsets_sizes_in_bits}): New data members.
	(options::options): Initialize them.
	(display_usage): New help strings for the new
	--show{bytes,bits,hex,dec} options.
	(set_diff_context_from_opts): Set the diff context wrt hex and
	bytes values.
	(parse_command_line): Parse the new --show{bytes,bits,hex,dec}
	options.
	* tools/kmidiff.cc (options::{show_hexadecimal_values,
	show_offsets_sizes_in_bits}): New data members.
	(options::options): Initialize them.
	(display_usage):New help strings for the new
	--show{bytes,bits,hex,dec} options.
	(parse_command_line): Parse the new --show{bytes,bits,hex,dec}
	options.
	(set_diff_context): Set the diff context wrt hex and bytes values.
	* tests/data/test-diff-filter/test30-pr18904-rvalueref-report2.txt:
	New reference test output.
	* tests/data/Makefile.am: Add the new reference test output above
	to source distribution.
	* tests/data/test-abicompat/test0-fn-changed-report-0.txt: Adjust.
	* tests/data/test-abicompat/test0-fn-changed-report-2.txt: Likewise.
	* tests/data/test-abicompat/test5-fn-changed-report-0.txt: Likewise.
	* tests/data/test-abicompat/test5-fn-changed-report-1.txt: Likewise.
	* tests/data/test-abicompat/test6-var-changed-report-0.txt: Likewise.
	* tests/data/test-abicompat/test6-var-changed-report-1.txt: Likewise.
	* tests/data/test-abicompat/test7-fn-changed-report-0.txt: Likewise.
	* tests/data/test-abicompat/test7-fn-changed-report-1.txt: Likewise.
	* tests/data/test-abicompat/test7-fn-changed-report-2.txt: Likewise.
	* tests/data/test-abicompat/test8-fn-changed-report-0.txt: Likewise.
	* tests/data/test-abicompat/test9-fn-changed-report-0.txt: Likewise.
	* tests/data/test-abidiff/test-PR18791-report0.txt: Likewise.
	* tests/data/test-abidiff/test-qual-type0-report.txt: Likewise.
	* tests/data/test-abidiff/test-struct0-report.txt: Likewise.
	* tests/data/test-abidiff/test-struct1-report.txt: Likewise.
	* tests/data/test-abidiff/test-var0-report.txt: Likewise.
	* tests/data/test-diff-dwarf/test0-report.txt: Likewise.
	* tests/data/test-diff-dwarf/test1-report.txt: Likewise.
	* tests/data/test-diff-dwarf/test10-report.txt: Likewise.
	* tests/data/test-diff-dwarf/test11-report.txt: Likewise.
	* tests/data/test-diff-dwarf/test13-report.txt: Likewise.
	* tests/data/test-diff-dwarf/test21-redundant-fn-report-0.txt: Likewise.
	* tests/data/test-diff-dwarf/test22-changed-parm-c-report-0.txt: Likewise.
	* tests/data/test-diff-dwarf/test26-added-parms-before-variadic-report.txt: Likewise.
	* tests/data/test-diff-dwarf/test27-local-base-diff-report.txt: Likewise.
	* tests/data/test-diff-dwarf/test3-report.txt: Likewise.
	* tests/data/test-diff-dwarf/test32-fnptr-changes-report-0.txt: Likewise.
	* tests/data/test-diff-dwarf/test33-fnref-changes-report-0.txt: Likewise.
	* tests/data/test-diff-dwarf/test34-pr19173-libfoo-report-0.txt: Likewise.
	* tests/data/test-diff-dwarf/test35-pr19173-libfoo-long-clang-report-0.txt: Likewise.
	* tests/data/test-diff-dwarf/test35-pr19173-libfoo-long-gcc-report-0.txt: Likewise.
	* tests/data/test-diff-dwarf/test36-ppc64-aliases-report-0.txt: Likewise.
	* tests/data/test-diff-dwarf/test37-union-report-0.txt: Likewise.
	* tests/data/test-diff-dwarf/test39-union-report-0.txt: Likewise.
	* tests/data/test-diff-dwarf/test40-report-0.txt: Likewise.
	* tests/data/test-diff-dwarf/test43-PR22913-report-0.txt: Likewise.
	* tests/data/test-diff-dwarf/test8-report.txt: Likewise.
	* tests/data/test-diff-dwarf/test9-report.txt: Likewise.
	* tests/data/test-diff-filter/test0-report.txt: Likewise.
	* tests/data/test-diff-filter/test01-report.txt: Likewise.
	* tests/data/test-diff-filter/test1-report.txt: Likewise.
	* tests/data/test-diff-filter/test10-report.txt: Likewise.
	* tests/data/test-diff-filter/test11-report.txt: Likewise.
	* tests/data/test-diff-filter/test13-report.txt: Likewise.
	* tests/data/test-diff-filter/test14-0-report.txt: Likewise.
	* tests/data/test-diff-filter/test14-1-report.txt: Likewise.
	* tests/data/test-diff-filter/test15-0-report.txt: Likewise.
	* tests/data/test-diff-filter/test15-1-report.txt: Likewise.
	* tests/data/test-diff-filter/test16-report-2.txt: Likewise.
	* tests/data/test-diff-filter/test16-report.txt: Likewise.
	* tests/data/test-diff-filter/test17-0-report.txt: Likewise.
	* tests/data/test-diff-filter/test17-1-report.txt: Likewise.
	* tests/data/test-diff-filter/test2-report.txt: Likewise.
	* tests/data/test-diff-filter/test27-redundant-and-filtered-children-nodes-report-0.txt: Likewise.
	* tests/data/test-diff-filter/test27-redundant-and-filtered-children-nodes-report-1.txt: Likewise.
	* tests/data/test-diff-filter/test27-redundant-and-filtered-children-nodes-report-2.txt: Likewise.
	* tests/data/test-diff-filter/test28-redundant-and-filtered-children-nodes-report-0.txt: Likewise.
	* tests/data/test-diff-filter/test28-redundant-and-filtered-children-nodes-report-1.txt: Likewise.
	* tests/data/test-diff-filter/test29-finer-redundancy-marking-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/test31-pr18535-libstdc++-report-0.txt: Likewise.
	* tests/data/test-diff-filter/test31-pr18535-libstdc++-report-1.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/test37-report-0.txt: Likewise.
	* tests/data/test-diff-filter/test39/test39-report-0.txt: Likewise.
	* tests/data/test-diff-filter/test42-leaf-report-output-0.txt: Likewise.
	* tests/data/test-diff-filter/test6-report.txt: Likewise.
	* tests/data/test-diff-filter/test9-report.txt: Likewise.
	* tests/data/test-diff-pkg/dirpkg-1-report-1.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/libsigc++-2.0-0c2a_2.4.0-1_amd64--libsigc++-2.0-0v5_2.4.1-1ubuntu2_amd64-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-2.txt: Likewise.
	* tests/data/test-diff-pkg/symlink-dir-test1-report0.txt: Likewise.
	* tests/data/test-diff-pkg/tarpkg-0-report-0.txt: Likewise.
	* tests/data/test-diff-pkg/tarpkg-1-report-0.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-pkg/tbb-4.1-9.20130314.fc22.x86_64--tbb-4.3-3.20141204.fc23.x86_64-report-1.txt: Likewise.
	* tests/data/test-diff-suppr/test0-type-suppr-report-0.txt: Likewise.
	* tests/data/test-diff-suppr/test0-type-suppr-report-3.txt: Likewise.
	* tests/data/test-diff-suppr/test0-type-suppr-report-5.txt: Likewise.
	* tests/data/test-diff-suppr/test0-type-suppr-report-7.txt: Likewise.
	* tests/data/test-diff-suppr/test1-typedef-suppr-report-0.txt: Likewise.
	* tests/data/test-diff-suppr/test1-typedef-suppr-report-2.txt: Likewise.
	* tests/data/test-diff-suppr/test11-add-data-member-report-0.txt: Likewise.
	* tests/data/test-diff-suppr/test12-add-data-member-report-0.txt: Likewise.
	* tests/data/test-diff-suppr/test12-add-data-member-report-2.txt: Likewise.
	* tests/data/test-diff-suppr/test13-suppr-through-pointer-report-0.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-0.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-5.txt: Likewise.
	* tests/data/test-diff-suppr/test16-suppr-removed-fn-report-0.txt: Likewise.
	* tests/data/test-diff-suppr/test16-suppr-removed-fn-report-2.txt: Likewise.
	* tests/data/test-diff-suppr/test17-suppr-added-var-report-0.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-5.txt: Likewise.
	* tests/data/test-diff-suppr/test18-suppr-removed-var-report-0.txt: Likewise.
	* tests/data/test-diff-suppr/test18-suppr-removed-var-report-2.txt: Likewise.
	* tests/data/test-diff-suppr/test18-suppr-removed-var-report-5.txt: Likewise.
	* tests/data/test-diff-suppr/test2-struct-suppr-report-0.txt: Likewise.
	* tests/data/test-diff-suppr/test23-alias-filter-report-0.txt: Likewise.
	* tests/data/test-diff-suppr/test23-alias-filter-report-2.txt: Likewise.
	* tests/data/test-diff-suppr/test24-soname-report-1.txt: Likewise.
	* tests/data/test-diff-suppr/test24-soname-report-10.txt: Likewise.
	* tests/data/test-diff-suppr/test24-soname-report-12.txt: Likewise.
	* tests/data/test-diff-suppr/test24-soname-report-14.txt: Likewise.
	* tests/data/test-diff-suppr/test24-soname-report-16.txt: Likewise.
	* tests/data/test-diff-suppr/test24-soname-report-4.txt: Likewise.
	* tests/data/test-diff-suppr/test25-typedef-report-0.txt: Likewise.
	* tests/data/test-diff-suppr/test26-loc-suppr-report-0.txt: Likewise.
	* tests/data/test-diff-suppr/test26-loc-suppr-report-3.txt: Likewise.
	* tests/data/test-diff-suppr/test29-soname-report-3.txt: Likewise.
	* tests/data/test-diff-suppr/test29-soname-report-6.txt: Likewise.
	* tests/data/test-diff-suppr/test29-soname-report-8.txt: Likewise.
	* tests/data/test-diff-suppr/test3-struct-suppr-report-0.txt: Likewise.
	* tests/data/test-diff-suppr/test3-struct-suppr-report-1.txt: Likewise.
	* tests/data/test-diff-suppr/test3-struct-suppr-report-2.txt: Likewise.
	* tests/data/test-diff-suppr/test30-report-0.txt: Likewise.
	* tests/data/test-diff-suppr/test31-report-1.txt: Likewise.
	* tests/data/test-diff-suppr/test32-report-0.txt: Likewise.
	* tests/data/test-diff-suppr/test32-report-1.txt: Likewise.
	* tests/data/test-diff-suppr/test33-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/test4-local-suppr-report-0.txt: Likewise.
	* tests/data/test-diff-suppr/test4-local-suppr-report-1.txt: Likewise.
	* tests/data/test-diff-suppr/test5-fn-suppr-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/test6-fn-suppr-report-0-1.txt: Likewise.
	* tests/data/test-diff-suppr/test6-fn-suppr-report-0.txt: Likewise.
	* tests/data/test-diff-suppr/test6-fn-suppr-report-1.txt: Likewise.
	* tests/data/test-diff-suppr/test6-fn-suppr-report-2.txt: Likewise.
	* tests/data/test-diff-suppr/test6-fn-suppr-report-3.txt: Likewise.
	* tests/data/test-diff-suppr/test7-var-suppr-report-0.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-7.txt: Likewise.
	* tests/data/test-diff-suppr/test7-var-suppr-report-8.txt: Likewise.
	* tests/data/test-diff-suppr/test8-redundant-fn-report-0.txt: Likewise.
	* tests/data/test-diff-suppr/test8-redundant-fn-report-1.txt: Likewise.
	* tests/data/test-diff-suppr/test9-changed-parm-c-report-0.txt: Likewise.
	* tests/data/test-diff-suppr/test9-changed-parm-c-report-1.txt: Likewise.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2018-04-30 17:11:40 +02:00
Jonathan Wakely
76764f6f12 Remove unused local set<string> variables
* src/abg-tools-utils.cc (get_dsos_provided_by_rpm): Remove unsed
	set<string> variable.
	* tools/abipkgdiff.cc (maybe_create_public_dso_sonames_set):
	Likewise.

Signed-off-by: Jonathan Wakely <jwakely@redhat.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2018-04-16 13:55:16 +02:00
Dodji Seketeli
35a14ccd79 [abipkgdiff]: in leaf mode we always show redundant changes
In leaf mode we always show redundant changes, by construction.  So
this program should not mess with that.

This patch is part of the set of patches whose 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

	* tools/abipkgdiff.cc (set_diff_context_from_opts):
	diff_context::show_leaf_changes_only automatically makes us show
	redundant changes.  So do not try to show redundant changes in
	that case.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2018-04-13 11:13:03 +02:00
Dodji Seketeli
92a194b553 Don't crash when invoking kmidiff with no debug info root dir
* tools/kmidiff.cc (main): Do not crash on empty debug info root
	dir.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2018-03-30 14:04:31 +02:00
Chenxiong Qi
1ac0c055fa Bug 22722 - Make fedabipkgdiff and its tests support both python 3 and 2
This patch makes fedabipkgdiff Python 3 compatible.  All tests written
in Python are updated and compatible with Python 3 as well.

The patch looks for a Python 3 interperter.  If it finds one then it
runs the tests using that interpreter.  Otherwise it just tries to use
the Python 2 interpreter.

This behaviour can be disabled by the new --disable-python3 option.

	* configure.ac: Add new option --enable-python3. Add new
	test runner file tests/runtestdefaultsupprs-py3 and
	tests/runtestfedabipkgdiffpy3.sh. Add required six Python module.
	* tests/Makefile.am: Add new test files
	tests/runtestdefaultsupprspy3.sh and
	tests/runtestfedabipkgdiffpy3.sh accordingly.
	* tests/mockfedabipkgdiff.in: Convert print statement to
	six.print_. Replace call to function filter with list
	comprehension. Replace basestring with six.string_types.
	* tests/runtestdefaultsupprspy3.sh.in: New shell script to run
	test runtestdefaultsupprs with Python 3.
	* tests/runtestdefaultsupprs.py.in: Repalce a few tabs with
	proper number of spaces which is detected by Python 3
	interpreter.
	* tests/runtestfedabipkgdiffpy3.sh.in: New shell script to run
	test runtestfedabipkgdiff with Python 3.
	* tests/runtestfedabipkgdiff.py.in: Use python from env in
	shebang instead of a fixed path to a Python interpreter.
	* tools/fedabipkgdiff: Globally replace print statement with a
	function call to print which is available by importing
	print_function from __future__ module. Use six.print_ to output
	string to stderr instead. Convert function call to map to
	for-loop. (cmp_nvr): Change argument to handle a Koji build
	mapping instead of only the nvr. (Brew.listBuilds): use the new
	cmp_nvr to sort builds.

Signed-off-by: Chenxiong Qi <cqi@redhat.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2018-03-29 13:46:50 +02:00
Dodji Seketeli
2939397c13 Make abipkgdiff avoid comparing private DSOs from RPMs
When an RPM contains a DSO which SONAME is not listed in the
"provides" property of the package, abipkgdiff ought to consider that
DSO as private to the RPM.  It should thus *NOT* consider that DSO
when comparing ABIs, at least, by default.

This is as per the discussion that was held at
https://pagure.io/task-abicheck/issue/8 and that led to the proposal
https://pagure.io/task-abicheck/issue/8#comment-492466.

This patch implements that scheme.

Basically, the patch looks at the SONAMEs listed in the "provides"
property of the RPM and consider them as the SONAMEs of the set of
"public" DSOs of the RPM.

Thus, if the RPM has a DSO that has no SONAME of one that is not
listed in the set of public SONAMEs of the package, then that DSO is
not considered for ABI comparison.

The patch also introduces a new --private-dso option that disables
this behaviour and compares all DSOs, including those that would be
meant to be private.

	* doc/manuals/abipkgdiff.rst: Add documentation for the new
	--private-dso option.
	* include/abg-tools-utils.h (execute_command_and_get_output)
	(execute_command_and_get_output, remove_trailing_white_spaces):
	Declare new functions.
	* src/abg-tools-utils.cc (execute_command_and_get_output)
	(get_dsos_provided_by_rpm, remove_trailing_white_spaces): Define
	new functions.
	* tests/test-diff-pkg.cc (in_out_specs): Add the new --private-dso
	option where it makes sense.
	* tools/abipkgdiff.cc (options::compare_private_dsos): Add new
	data member.
	(options::options): Initialize it.
	(package::public_dso_sonames_): Add new data member.
	(package::public_dso_sonames): Add new accessors pair.
	(display_usage): Add a help string for the new --private-dso
	option.
	(maybe_create_public_dso_sonames_set)
	(must_compare_public_dso_only): Define new static functions.
	(create_maps_of_package_content): Call the new
	maybe_create_public_dso_sonames_set.  Skip packages which SONAME
	is not in the set of public SONAMES.
	(parse_command_line): Parse the new --private-dso option.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2018-03-28 14:22:35 +02:00
Dodji Seketeli
e85d052422 Fix the output indentation of abidiff --help
* tools/abidiff.cc (display_usage): Fix indentation of the help
	string for the --drop-private-types option.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2018-03-02 16:50:12 +01:00
Dodji Seketeli
a5837326cb Add newline at end of version string display
I screwed up version string display by forgetting to add a newline
after it.  Oops.  Fixed thus.

	* tools/abidiff.cc (main): Add a newline at the end of the version
	string line.
	* tools/abidw.cc (main): Likewise.
	* tools/abipkgdiff.cc (main): Likewise.
	* tools/kmidiff.cc (main): Likewise.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2018-02-06 10:11:13 +01:00