Commit Graph

206 Commits

Author SHA1 Message Date
Dodji Seketeli
edfe5a1dec abipkgdiff: Add a new --self-check option
After the report of
https://sourceware.org/bugzilla/show_bug.cgi?id=26769 it became
apparent that we want to be able compare a binary against its ABIXML
representation, including for cases where the binaries are embedded in
RPM packages.

This patches thus introduces the --self-check option to abipkgdiff so
that it can be invoked like this:

    $ abipkgdiff --self-check --d1 libstdc++-debuginfo-10.2.1-8.fc34.x86_64.rpm --d1 gcc-debuginfo-10.2.1-8.fc34.x86_64.rpm libstdc++-10.2.1-8.fc34.x86_64.rpm

    ==== SELF CHECK SUCCEEDED for 'libstdc++.so.6.0.28'====
    $

With this option, libabigail compares each binary in the RPM against
its own ABIXML representation.

This should hopefully help to write regression tests which have as
sole inputs the links to download the RPMs.  It's also useful to ease
the process of reproducing the issue raised.

This option can now be used, for instance, by the libabigail-selfcheck
program over at https://pagure.io/libabigail-selfcheck.

	* tools/abipkgdiff.cc (options::self_check): Define new data
	member.
	(options::options): Initialize it.
	(display_usage): Add help string for the --self-check option.
	(parse_command): Parse the new --self-check option.
	(extract_deb): Add missing newline.
	(compare): Remove useless white space.
	(compare_to_self, self_compare_prepared_userspace_package)
	(self_compare_prepared_package, compare_to_self): Add new static
	functions.
	(class self_compare_task): Add new class.
	(prepare_package): Add a new overload that takes just one
	parameter.
	(elf_size_is_greater): Don't crash if the args are empty.
	(main): If the --self-check option is given, make sure we have
	just one package in argument.  Use the new compare_to_self
	function to handle the --self-check option.
	* doc/manuals/abipkgdiff.rst: Add documentation for the new
	--self-check option.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2020-11-23 17:50:05 +01:00
Dodji Seketeli
ee2b54ddd9 Make abidiff and abidw support several --headers-dir{1,2} options
When handling a binary with abidiff or abidw it can be useful to
provide several different header files directories, for the cases
where the header files of the binary are scathered in several
different directories.

It thus becomes possible to invoke abidiff like this:

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

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

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

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

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2020-09-18 10:27:18 +02:00
Giuliano Procida
f18a192aa6 Improve documentation of abidiff --type-id-style
* tools/abidw.cc (display_usage): In documentation of
	"--type-id-style" option, add a missing closing ')', spell
	"type id" without a '-', split overly long string over two
	lines, use "<...>" to indicate mandatory argument and improve
	description of formats.
	* doc/manuals/abidw.rst: In documentation of "--type-id-style"
	option, use "<...>" to indicate mandatory argument.

Signed-off-by: Giuliano Procida <gprocida@google.com>
2020-08-04 18:41:01 +02:00
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
Giuliano Procida
f7a85ec9d0 doc: Fix sufficient suppression property lists.
At present there are discrepancies between the suppression
specification parsing code and the documented lists of properties (per
suppression type) that are consider sufficient to prevent a
suppression specification being ignored altogether.

This patch updates the documentation to match the code and adjusts
some confusing language in the documentation.

	* doc/manuals/libabigail-concepts.rst: Add missing
	sufficient properties for suppress_file, suppress_function and
	suppress_variable. Use consistent language about what will
	happen when no property in the list in provided.

Signed-off-by: Giuliano Procida <gprocida@google.com>
2020-05-13 12:11:11 +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
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
1a9c44e1a8 Update the mailing list registration form on the web page
Since the recent sourceware infrastructure refresh the management of
the mailing list moved to mailman.  So the form we use to register to
the mailing list changed as well.  I have updated the information on
the web page to reflect that.

	* doc/website/mainpage.txt: Use the form at
	https://sourceware.org/mailman/listinfo/libabigail to register to
	the mailing list.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2020-04-07 11:11:37 +02:00
Giuliano Procida
3665c8ff44 Add more leaf change reporting.
The leaf-changes-only reporting path does not report on all the same
kinds of differences as the default reporting path does, such as
reporting about changes to variables, even though they can be
considered leaf changs.

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

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

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

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

Signed-off-by: Giuliano Procida <gprocida@google.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2020-03-13 17:58:30 +01:00
Dodji Seketeli
d12e4b77e6 Update website for 1.7
* doc/website/mainpage.txt: Update for 1.7

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2020-02-26 14:05:26 +01:00
Dodji Seketeli
6a0e7e120b abixml-reader: Support SONAME related properties on file suppression
When comparing binary files (using abidiff for instance) libabigail
can interpret the [suppress_file] section of a suppression
specification.  If the suppression specification matches either of the
compared files, no comparison is performed.

At the moment, that doesn't work when comparing abixml files.

Thus, this patch implements that feature for abixml files.

With this patch, one can now write a suppression specification like
this:

  [suppress_file]
    soname_regexp = <some-regexp>

or

  [suppress_file]
    file_name_regexp = <some-regexp>

If either abixml file has a soname matched by such a regexp, then no
comparison is performed.

	* doc/manuals/libabigail-concepts.rst: Update the documentation to
	mention soname_regexp and soname_not_regexp is supported in the
	[suppress_file] section.
	* include/abg-suppression.h (suppression_matches_soname)
	(suppression_matches_soname_or_filename): Declare new functions.
	Make them be friends of class suppression_base.
	* src/abg-reader.cc
	(read_context::corpus_is_suppressed_by_soname_or_filename): Define
	new member function.
	(read_corpus_from_input): Apply file suppression.
	* src/abg-suppression.cc (read_file_suppression): Support
	"soname_regexp" and "soname_not_regexp" in the [suppress_file]
	section.
	(suppression_matches_soname)
	(suppression_matches_soname_or_filename): Define new functions.
	* tests/data/test-diff-suppr/libtest48-soname-abixml-report-{1,2}.txt:
	New test reference output files.
	Likewise.
	* tests/data/test-diff-suppr/libtest48-soname-abixml-suppr.txt:
	New test suppression file.
	* tests/data/test-diff-suppr/libtest48-soname-abixml-suppr-{2,3,4}.txt::
	Likewise.
	* tests/data/test-diff-suppr/libtest48-soname-abixml-v{0,1}.so: New
	test binary input files.
	* tests/data/test-diff-suppr/libtest48-soname-abixml-v{0,1}.so.abi:
	New abixml for the binary input files above.
	* tests/data/test-diff-suppr/test48-soname-abixml-v{0,1}.c: Source
	code of the binary input files above.
	* tests/data/Makefile.am: Add the above test material to source
	distribution.
	* tests/test-diff-suppr.cc (in_out_specs): Add the test input
	above to this test harness.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2020-02-21 16:01:26 +01: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
Dodji Seketeli
b00976517f Support symbol_name_not_regexp in [suppress_{function, variable}]
In the suppress_function and suppress_variable directives of the
suppression specification language, we lack the
'symbol_name_not_regexp' properties, that would allow users to specify
which (function/variable) symbols to *keep* as opposed to specifying
which symbols to suppress.

This patch adds that feature.  That will later allow us to make the
linux kernel symbol white lists[1] functionality use this feature;
that is, upon analysing the content of a kernel symbol whitelist which
lists a symbol named "foo", Libabigail would automatically generate a
suppression specification which contains, e.g a 'suppress_function"
directive that has this new 'symbol_name_not_regexp' property which
value is set to "foo".

Note that the patch makes sure that feature is supported when
analyzing both abixml and DWARF formats.

[1]: You can learn about what a Linux Kernel symbols white list is by
reading about it at
https://sourceware.org/libabigail/manual/kmidiff.html#environment.

	* doc/manuals/libabigail-concepts.rst: Document the new
	symbol_name_not_regexp properties for the
	suppress_{function,variable} directives.
	* include/abg-suppression.h
	({function,variable}_suppression::{g,s}et_symbol_name_not_regex_str):
	Declare new member functions.
	* src/abg-dwarf-reader.cc
	(read_context::is_elf_symbol_suppressed): Define new member functions.
	(read_context::{load_symbol_maps_from_symtab_section,
	populate_symbol_map_from_ksymtab,
	populate_symbol_map_from_ksymtab_reloc}): Drop suppressed symbols
	when reading symbol tables.
	({function,variable}_is_suppressed): Consider that in C, the
	linkage name is _by default_ the same as the function/variable
	name. Remove local variable.
	* include/abg-ir.h (elf_symbol_is_{function,variable}): Add ...
	* src/abg-ir.cc (elf_symbol_is_{function,variable}): ... new
	functions.
	* src/abg-reader.cc (build_elf_symbol): Take an additional boolean
	to detect and drop suppressed symbols.
	(build_elf_symbol_db): Adjust the call to build_elf_symbol to make
	it detect and drop suppressed symbols.
	(read_corpus_from_input): Be mindful that the set of symbols for a
	given corpus can be empty because of suppression specifications.
	* src/abg-suppression-priv.h
	({function,variable}_suppression::priv::symbol_name_not_regex[_str_]):
	Add new data members.
	(function,variable}_suppression::priv::get_symbol_name_not_regex):
	Add new member functions.
	({function,variable}_is_suppressed): Guard against empty name.
	(is_elf_symbol_suppressed): Define new function template.
	* src/abg-suppression.cc
	({function,variable}_suppression::{g,s}et_symbol_name_not_regex_str):
	Define new member functions.
	({function,variable}_suppression::suppresses_function)
	(suppression_matches_{function,variable}_sym_name)
	(read_{function,variable}_suppression): Support the new
	"symbol_name_not_regex" property.
	* tests/data/test-diff-suppr/test44-suppr-sym-name-not-regexp-report-1.txt:
	New test reference report.
	* tests/data/test-diff-suppr/test44-suppr-sym-name-not-regexp-report-2.txt:
	Likewise.
	* tests/data/test-diff-suppr/test44-suppr-sym-name-not-regexp-v{0,1}.c:
	Sources of the new test input.
	* tests/data/test-diff-suppr/test44-suppr-sym-name-not-regexp-v{0,1}.o:
	New test input binaries.
	* tests/data/test-diff-suppr/test44-suppr-sym-name-not-regexp-v{0,1}.o.abi:
	New test input abixml files.
	* tests/data/test-diff-suppr/test44-suppr-sym-name-not-regexp.suppr.txt:
	Next test suppression specification.
	* tests/data/Makefile.am: Add the new test material above to
	source distribution.
	* tests/test-diff-suppr.cc (in_out_specs): Add the input tests
	above to the test harness.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2019-11-08 11:01:54 +01:00
Dodji Seketeli
d2c88645e8 Support the "name_not_regexp" property in the [suppress_type] section
When writting a suppression specification in which the user wants to
keep a family of types (whose names set is specified by a regular
expression) and suppress/drop all other types, one needs to write
something like:

[suppress_type]
  name_regexp = (?!the-regexp-of-the-types-to-keep)

It would be nicer (like what is done for other properties that take
regular expressions as value in suppression specifications) to be able
to write:

[suppress_type]
  name_not_regexp = the-regexp-of-types-to-keep

This patch does just that.

It augments the abigail::suppr::type_suppression type to make it carry
the new 'name_not_regex' property.  It updates the suppression engine
to take the 'name_not_regex' property into account when interpreting
instances of abigail::suppr::type_suppression.  The parser for type
suppression directives is updated to recognize the new name_not_regexp
property.  The manual has been updated accordingly to describe the new
property.  New regression tests have been added.

	* doc/manuals/libabigail-concepts.rst: Update this to document the
	new name_not_regexp property of the suppress_type directive.
	* include/abg-suppression.h
	(type_suppression::{g,s}et_type_name_not_regex_str): Declare new accessors.
	* src/abg-suppression-priv.h
	(type_suppression::priv::{type_name_not_regex_str_,
	type_name_not_regex_}): Define new data members.
	(type_suppression::priv::{get_type_name_not_regex,
	set_type_name_not_regex, get_type_name_not_regex_str,
	set_type_name_not_regex_str}): Define new member functions.
	* src/abg-suppression.cc
	(type_suppression::get_type_name_regex_str): Fix comments.
	(type_suppression::{set_type_name_not_regex_str,
	get_type_name_not_regex_str}): Define new data members.
	(suppression_matches_type_name): Adapt to support the new
	type_name_not_regex property.
	(read_type_suppression): Support parsing the type_name_not_regexp
	property.
	* tests/data/test-diff-suppr/test42-negative-suppr-type-report-0.txt:
	New test reference output.
	* tests/data/test-diff-suppr/test42-negative-suppr-type-report-1.txt: Likewise.
	* tests/data/test-diff-suppr/test42-negative-suppr-type-suppr-1.txt:
	New test input.
	* tests/data/test-diff-suppr/test42-negative-suppr-type-suppr-2.txt: Likewise.
	* tests/data/test-diff-suppr/test42-negative-suppr-type-v0.{cc, o}: Likewise.
	* tests/data/test-diff-suppr/test42-negative-suppr-type-v1.{cc,
	o}: Likewise.
	* tests/data/Makefile.am: Add the test files above to source
	distribution.
	* tests/test-diff-suppr.cc (int_out_specs): Add the new tests to
	the harness.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2019-09-30 14:56:52 +02:00
Dodji Seketeli
4acf2d6926 Update website mainpage for 1.6 release
* doc/website/mainpage.txt: Update for 1.6 release.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2019-03-29 17:31:33 +01:00
Dodji Seketeli
3826ab5308 Bug 24139 - Support suppressing some enumerator changes
This patch teaches the suppression specification subsystem how to
ignore changes of some enumerators in particular.

The patch adds a new property to the [suppress_type] section which is:

    changed_enumerators = enumerator1, enumerator2, etc

This property is taken into accound iff the current suppress_type does
have the 'type_kind = enum' property.

Changes to enum types that match the new 'changed_enumerators'
property are suppressed.

	* doc/manuals/libabigail-concepts.rst: Document the new
	'changed_enumerators' property.
	* include/abg-suppression.h
	(type_suppression::{g, s}et_changed_enumerator_names): Declare two
	new member functions.
	* src/abg-suppression-priv.h
	(type_suppression::priv::changed_enumerator_names_): Add a new
	data member.
	* src/abg-suppression.cc
	(type_suppression::{g,s}et_changed_enumerator_names): Define two
	new member functions.
	(type_suppression::suppresses_diff): Support evaluating the new
	'changed_enumerators = <vector of changed enumerators>'.
	(read_type_suppression): Read the new list
	property'changed_enumerators" and store it into the
	type_suppression using the new
	type_suppression::set_changed_enumerator_names ().
	* tests/data/test-diff-suppr/libtest4{0,1}-enumerator-changes-v{0,1}.so:
	Add new test inpujts.
	* tests/data/test-diff-suppr/test4{0,1}-enumerator-changes-0.suppr:
	Add a new suppr spec for this new test.
	* tests/data/test-diff-suppr/test4{0,1}-enumerator-changes-report-0.txt:
	The default report.
	* tests/data/test-diff-suppr/test4{0,1}-enumerator-changes-v{0,1}.cc:
	Add Source code of libtest4{0,1}-enumerator-changes-v{0,1}.so.
	* tests/data/Makefile.am: Add the test files above to source
	distribution.
	* tests/test-diff-suppr.cc: Add the test input files above to the
	harness.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2019-01-31 09:20:06 +01:00
Xiao Jia via libabigail
e993ccb64b Some documentation fixes
* COMPILING: Add the pkg-config dependency.
	* doc/manuals/kmidiff.rst: Replace the redundant --full-impact
	documentation with the proper --impacted-interfaces one.

Signed-off-by: Xiao Jia <xiaoj@google.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2018-12-07 11:21:50 +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
6b036291b8 Update website for 1.5
* doc/website/mainpage.txt: Update website for 1.5

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2018-10-26 16:54:51 +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
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
991297f58a Update website for 1.2
* doc/website/mainpage.txt: Update link to download the tarball,
	for 1.2.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2018-03-06 18:06:36 +01:00
Dodji Seketeli
790aecb1c1 Fix typo in abipkgdiff documenation
* doc/manuals/abipkgdiff.rst: Fix a typo

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2018-03-06 15:31:45 +01:00
Dodji Seketeli
5a7a5bb694 Update abipkgdiff documentation wrt suppression specifications
* doc/manuals/abipkgdiff.rst: Mention the .abignore file that is
	read by the tool and considered as a suppression specification
	file.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2018-03-06 15:31:45 +01:00
Dodji Seketeli
fd48a22905 Update website for 1.1
* doc/website/mainpage.txt: Update for 1.1.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2018-01-29 12:02:20 +01:00
Dodji Seketeli
f17710619a Bug 22684 - Add --d{1,2} options to kmidiff
kmidiff lacks options specifying where to find split debug info for
the Linux kernel binaries it's comparing.

This patch adds those options.

	* doc/manuals/kmidiff.rst: Add documentation for the new options.
	* tools/kmidiff.cc (options::{di_root_path{1,2}): New data
	members.
	(display_usage): Add help strings for the new options.
	(parse_command_line): Parse the new options.
	(main): Pass the debug info root directory to
	build_corpus_group_from_kernel_dist_under.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2018-01-09 16:19:30 +01:00
Dodji Seketeli
d57639c051 Update & cleanup the tools manuals summary
* doc/manuals/abidw.rst: Use the same header structure as or the
	other tools manual.
	* doc/manuals/kmidiff.rst: Likewise.
	* doc/manuals/libabigail-tools.rst: Add the new kmidiff tool to
	the summary.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-12-11 14:30:04 +01:00
Dodji Seketeli
eead00efb0 Bug 22436 - make abipkgdiff accept several debuginfo packages
Sometimes, the debug information for one given package P can have been
split into several packages.  In that case, we need abipkgdiff to
consider several debug info packages for a given input binary package.

This patch makes abipkgdiff to accept several --d{1,2} <debug-info-package>
option, for a given input package.

	* doc/manuals/abipkgdiff.rst: Document the fact that --d{1,2} can
	be provided several times on the command line.
	* tools/abipkgdiff.cc (options::debug_packages{1,2}): Rename the
	debug_package{1,2} data members into this, and make them be vector
	of strings, rather than just strings.
	(package::debug_info_packages_): Renamed
	package::debug_info_package_ into this and make it be a vector of
	package_sptr, rather than just a package_sptr.
	(package::debug_info_packages): Renamed the method
	package::debug_info_package into this and -- for the getter
	overload -- make it return a vector of package_sptr, rather than
	just a package_sptr.  Likewise for the setter overload.  Add a
	non-const getter overload.
	(package::erase_extraction_directories)
	(extract_package_and_map_its_content): Adjust.
	(extract_rpm, extract_deb): Do not erase the content of the
	extraction directory (if it was pre-existing) prior to extracting
	the RPM/deb into it.
	(pkg_extraction::pkgs): Renamed pkg_extraction::pkg into this and
	make it be a vector of packages, rather than just a package.
	(pkg_extraction::pkg_extraction): Adjust to take a package_sptr
	rather than just a package.  Add an overload to take a vector of
	packages_sptr.
	(pkg_extraction::perform): Extract the vector of package that the
	task is not responsible for, not just one random package.
	(extract_package_and_map_its_content): Adjust.
	(prepare_packages): Take smart pointers to package rather than
	just packages.  Adjust accordingly.
	(compare_prepared_package): Make the overload that takes two
	packages to take two smart pointers of packages.
	(compare): Make the overload that takes two package take two
	package_sptr.
	(parse_command_line): Parse having --d{1,2} several times for a
	given input package.
	(main): Take several debug info packages for one input file.
	* include/abg-tools-utils.h (split_string): Declare ...
	* src/abg-tools-utils.cc (split_string): ... new function.
	* tests/data/test-diff-pkg/libxfce4ui-debuginfo-4.12.1-8.fc27.ppc64.rpm:
	Add a new RPM test input file.
	* tests/data/test-diff-pkg/libxfce4ui-devel-4.12.1-8.fc27.ppc64-self-report-ok-0.txt:
	new reference output file.
	* tests/data/Makefile.am: Add the new test input files above to source
	distribution.
	* tests/test-diff-pkg.cc (in_out_spec): Add new test entry to
	specify two debug info packages for one input package.
	(test_task::perform): Support having several debug info package
	paths in the IntOutSpec::{first,second}_in_debug_package_path data
	member.  The debug info packages paths are separated by either a
	white space or commas.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-11-27 17:15:20 +01:00
Dodji Seketeli
837a4806e8 Update website for 1.0
* doc/website/mainpage.txt: Update after 1.0 release.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-11-22 15:55:43 +01:00
Dodji Seketeli
8c51a89525 Wire the --no-show-locs option to abidw
Up until now, the --no-show-locs option only had effect when abidiff
was used with the --abidiff option.  It had no effect on the ABIXML
output of abidw.

This patch changes that to make it so that --no-show-locs avoids
emitting source location to the ABIXML output.

	* doc/manuals/abidw.rst: Update the documentation.
	* tests/test-annotate.cc: Now that --no-show-locs has an effect on
	the ABIXML output, let's not use it here, because it changes the
	output and we don't want that.
	* tools/abidw.cc (display_usage): Fix a typo in the help string.
	(load_corpus_and_write_abixml): Set the "show-locs" option to the
	write_context object that we use.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-11-02 12:57:11 +01:00
Dodji Seketeli
7dc8265c54 Add a --suppressions option to fedabipkgdiff
This patch adds a --suppressions option to fedabipkgdiff so that a
suppression specification can be applied to the comparisons performed.

	* tools/fedabipkgdiff (abipkgdiff): If a suppression file was
	provided, pass it to the underlying abipkgdiff tool.
	(build_commandline_args_parser): Parse the new --suppressions
	option.
	* docs/manuals/fedabipkgdiff.rst: Add documentation for the new
	--suppressions option.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-10-16 14:45:32 +02:00
Dodji Seketeli
cef581e9e1 Add --impacted-changes option to kmidiff
kmidiff displays leaf changes by default and and it does so by *not*
showing impacted interfaces.

This patch add a --impacted-changes option to kmidiff so that it shows
the interfaces that are impacted by each leaf change.  Thus, by
default, no impacted interface is shown.

	* doc/manuals/kmidiff.rst: Document the new --impacted-changes
	option.
	* tools/kmidif.cc (options::show_impacted_interfaces): Add new
	data member.
	(options::options): Initialize the new data member to false.
	(display_usage): Add a description string for the new
	--impacted-changes option.
	(parse_command_line): Parse the new --impacted-changes option.
	(set_diff_context): Update the 'show-impacted-interface' property
	accordingly.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-10-08 18:51:35 +02:00
Dodji Seketeli
9b34a860e2 Add --full-impact option to kmidiff
This patch changes the default report emitted by kmidiff.  Now, it
emits a leaf changes report by default.  And if the user wants the
classical kind of report then she can use the --full-impact option.

	* doc/manuals/kmidiff.rst: Add documentation for the new
	--full-impact|-f option.
	* tools/kmidiff.cc (options::leaf_changes_only): Add new data
	member.
	(option::option): Initialize the new data member.
	(display_usage): Add a documentation string for the new
	--full-impact|-f option.
	(parse_command_line): Parse the new --full-impact|-f option.
	(set_diff_context): Set the diff context appropriately.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-10-08 18:51:35 +02:00
Dodji Seketeli
d3ddf609d9 Add a --leaf-changes-only option to abipkgdiff
This patch adds the --leaf-changes-only option to abipkgdiff, just
like what we have for abidiff.  The patch also emit leaf changes
report by default when comparing two Linux Kernel packages.

The patch also adds the --impacted-interfaces and --full-impact
options.

	* doc/manuals/abipkgdiff.rst: Add documentation for the new
	--leaf-change-only, --impacted-interfaces and --full-impact
	options.
	* tools/abipkgdiff.cc (options::{leaf_changes_only,
	show_impacted_interfaces, show_full_impact_report): Add new data
	members.
	(options::options): Initialize them.
	(display_usage): Add help strings for the new --leaf-change-only,
	--impacted-interfaces and --full-impact|-f options.
	(set_diff_context_from_opts): Set the diff context for the
	'leaf-changes-only' and 'show-impacted-interfaces' flags.
	(parse_command_line): Parse the --leaf-change-only,
	--impacted-interfaces and --full-impact options.  Handle the case
	where the --linux-kernel-abi-whitelist|-w option is given a
	whitelist *package*.
	* tests/data/test-diff-pkg/spice-server-0.12.4-19.el7.x86_64-0.12.8-1.el7.x86_64-report-3.txt:
	New test output reference.
	* tests/test-diff-pkg.cc (in_out_spec): Compare
	data/test-diff-pkg/spice-server-0.12.4-19.el7.x86_64.rpm and
	data/test-diff-pkg/spice-server-0.12.8-1.el7.x86_64.rpm with the
	new --leaf-changes-only and --impacted-interfaces options, using
	the new output reference above.
	* tests/data/Makefile.am: Add the new test material to source
	distribution.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-10-08 18:51:35 +02:00
Dodji Seketeli
108a6074a5 Initial implementation of a --leaf-changes-only option to abidiff
This patch allows abidiff to take the --leaf-changes-only option and
then to display only the changes that are local to any given type.
That means the reporting agent won't follow pointers when displaying
changes.  That gives less context to the ABI change reports but then
they are less cluttered.

To do this, the patch introduces a new reporting agent to libabigail:
abigail::comparison::leaf_reporter.  When given a graph of diff nodes,
this agent only reports about the leaf (local) changes.  That is, it
will *NOT* follow pointers, references, underlying types of qualified
and typedef types and things like that. It will just report about
changes that are local to a given type.

This reporting agent is then used (in lieu of the default
abigail::comparison::default_reporter agent) when the
--leaf-changes-only option is provided by the user on the command line
of abidiff.

Note that abidiff also takes the --impacted-interfaces option to so
that the leaf reporter shows the set of interfaces impacted
by each leaf change.

	* doc/manuals/abidiff.rst: Add documentation the new
	--leaf-changes-only and --impacted-interfaces options.
	* src/abg-leaf-reporter.cc: New file.
	* src/Makefile.am: Add the new src/abg-leaf-reporter.cc file to
	source distribution.
	* include/abg-fwd.h (get_var_size_in_bits)
	(function_decl_is_less_than): Declare new functions.
	(get_name): Add new overload for type_or_decl_base*.
	* include/abg-ir.h (struct type_or_decl_hash, type_or_decl_equal)
	(type_or_decl_base_comp): Define new types.
	(artifact_sptr_set_type, artifact_ptr_set_type): Define new
	typedefs.
	* include/abg-comp-filter.h: Update copyright year.
	(has_basic_type_name_change): Add new function declaration.
	* src/abg-comp-filter.cc (decl_name_changed): Take a
	type_or_decl_base rather than just a decl.  Add an overload for
	diff*.
	(has_basic_type_name_change): Define new function.
	* include/abg-comparison.h: Update copyright year.
	(string_diff_ptr_map): Define this new typedef.
	(class diff_maps): Define this new class.
	(diff_context::{set_corpora}): Remove this member function.
	(diff_context::{set_corpus_diff, get_corpus_diff,
	show_leaf_changes_only, show_impacted_interfaces,
	forbid_visiting_a_node_twice_per_interface}): Declare these new
	member functions.
	(diff_node_visitor::priv_): Add a new pimpl data member.
	(diff_node_visitor::{diff_node_visitor, get_visiting_kind,
	set_visiting_kind}): Turn these into out-of-line member functions.
	(diff_node_visitor::{set,get}_current_topmost_iface_diff): Add new
	member functions.
	(class {scope_diff, function_type_diff, corpus_diff}): Add class
	leaf_reporter as a friend.
	(corpus_diff::mark_leaf_diff_nodes, get_leaf_diffs): Declare new
	member functions.
	(diff::{visiting_a_node_twice_is_forbidden_per_interface,
	parent_interface_node}): Define new member functions.
	(is_diff_of_basic_type): Return a type_decl_diff* rather than just
	a bool.
	(is_enum_diff, is_array_diff, is_function_type, is_typedef_diff)
	(is_corpus_diff): Declare new functions.
	(corpus_diff::diff_stats::{num_leaf_changes,
	num_leaf_changes_filtered_out, net_num_leaf_changes}): Add new
	member functions.
	(is_distinct_diff): Declare new function.
	* include/abg-reporter.h: Forward-declare "class diff_maps".
	(reporter_base::diff_to_be_reported): Declare a new virtual member
	function.
	(reporter_base::{report_local_typedef_changes,
	report_local_reference_type_changes,
	report_local_function_type_changes}): Declare new member
	functions.
	(class leaf_reporter): Define new type.
	* src/abg-comparison-priv.h (struct diff_hash, diff_equal): Define
	new types.
	(diff_artifact_set_map_type): Define new typedef.
	(diff_context::priv::{first_corpus_, second_corpus_}): Remove
	these data members.
	(diff_context::priv::{corpus_diff_, leaf_changes_only_,
	reset_visited_diffs_for_each_interface_,
	show_impacted_interfaces_}): Add new data members.
	(diff_context::priv::priv): Adjust.
	(corpus_diff::priv::{leaf_diffs_, parent_interface_}): Add new
	data member.
	(corpus_diff::diff_stats::priv::{num_leaf_changes,
	num_leaf_changes_filtered_out}): Add new data members.
	(corpus_diff::priv::count_leaf_changes): Define new member
	function.
	(sort_artifacts_set, get_fn_decl_or_var_decl_diff_ancestor)
	(is_diff_of_global_decls): Declare new functions.
	(function_comp::operator()): Factorize this out into the new
	function abigail::ir::function_decl_is_less_than.
	* src/abg-ir.cc (get_var_size_in_bits)
	(function_decl_is_less_than): Define new functions.
	(get_name): Define new overload for type_or_decl_base*.
	* src/abg-comparison.cc (is_enum_diff, is_typedef_diff)
	(is_array_diff, is_function_type_diff, is_corpus_diff)
	(is_distinct_diff, sort_artifacts_set, is_diff_of_global_decls):
	Define new functions.
	(is_union_diff): Fix comment.
	(diff_context::forbid_visiting_a_node_twice_per_interface): Define
	new member functions.
	(diff_context::set_corpus_diff, get_corpus_diff)
	(diff_context::show_leaf_changes_only)
	(diff_context::visiting_a_node_twice_is_forbidden_per_interface)
	(diff_context::show_impacted_interfaces): Define new member
	functions.
	(diff_context::get_reporter): Create the reporter that matches
	what diff_context::show_leaf_changes_only says.
	(diff_node_visitor::priv): Define a new type.
	(diff_node_visitor::{diff_node_visitor, get_visiting_kind,
	set_visiting_kind, or_visiting_kind,
	set_current_topmost_iface_diff, get_current_topmost_iface_diff}):
	Define new out-of-line member functions.
	(struct diff_maps::priv): Define new type.
	(diff_maps::{diff_maps, get_type_decl_diff_map,
	get_type_decl_diff_map, get_enum_diff_map, get_class_diff_map,
	get_union_diff_map, get_typedef_diff_map, get_array_diff_map,
	get_function_type_diff_map, get_function_decl_diff_map,
	get_var_decl_diff_map, get_reference_diff_map,
	get_fn_parm_diff_map, get_distinct_diff_map, insert_diff_node,
	lookup_impacted_interfaces}): Define member functions.
	(corpus_diff::{mark_leaf_diff_nodes, get_leaf_diffs}): Define new
	member functions.
	(struct leaf_diff_node_marker_visitor): Define new type.
	(corpus_diff::apply_filters_and_suppressions_before_reporting):
	Mark diff nodes in here.
	(corpus_diff::traverse): Appropriately set the current topmost
	interface into the visitor before visiting a diff node.
	(compute_diff): In the overload for corpus_sptr, adjust to reflect
	that we are now storing the corpus_diff in the diff context.
	(is_diff_of_basic_type): Return a type_decl_diff*, not just a
	bool.
	(corpus_diff::priv::count_leaf_changes): Define a new member
	function.
	(corpus_diff::diff_stats::{num_leaf_changes,
	num_leaf_changes_filtered_out, net_num_leaf_changes}): Define new
	member functions.
	(corpus_diff::priv::apply_filters_and_compute_diff_stats): Use the
	new corpus_diff::priv::count_leaf_changes to compute the number of
	leaf changes.
	(corpus_diff::priv::emit_diff_stats): Emit the report about leaf
	type changes when necessary.
	* src/abg-reporter-priv.h (report_mem_header): Declare new
	overload.
	(maybe_show_relative_offset_change,): Pass the var_diff_sptr
	parameter by const reference.
	(represent): Pass the var_diff_sptr parameter by const reference
	and take a new "local-only" flag.
	(maybe_show_relative_size_change)
	(maybe_report_interfaces_impacted_by_diff): Declare new functions.
	* src/abg-default-reporter.cc: Adjust copyright year.
	(default_reporter::{report_local_typedef_changes,
	report_local_qualified_type_changes,
	report_local_reference_type_changes,
	report_local_function_type_changes}): Define new member functions.
	(default_reporter::report): Adjust.  Add an overload for
	function_type_diff&. In the overload for qualified_type_diff, if
	the name of the underlying type changed, do not detail the changes
	any further.  In the overload for function_decl_diff, Adjust to
	use the new diff_context::get_{first, second}_corpus member
	function.  In the overload for enum_diff, call the new
	maybe_report_interfaces_impacted_by_diff that is advertised below.
	* src/abg-reporter-priv.cc (represent): Adjust the overload for
	var_diff_sptr.
	(report_mem_header): Define new overload.
	(maybe_show_relative_size_change)
	(maybe_report_interfaces_impacted_by_diff): Define new functions.
	(reporter_base::diff_to_be_reported): Define new member function.
	(maybe_show_relative_offset_change): Pass the var_diff_sptr
	parameter by const reference.
	(represent): In the overload for var_diff_sptr, pass the
	var_diff_sptr parameter by reference.  Take a 'local_only' flag.
	Iisplay type changes only if we are not displaying "local changes
	only".  Display size changes of data members too, when in
	"local-only" mode.
	* src/abg-suppression.cc (sonames_of_binaries_match)
	(names_of_binaries_match): Adjust.
	* tools/abidiff.cc (options::{leaf_changes_only,
	show_impacted_interfaces}): Add new data members.
	(display_usage): Emit usage string for the new --leaf-changes-only
	and --impacted-interfaces options.
	(parse_command_line): Parse the new --leaf-changes-only and the
	--impacted-interfaces options.
	(set_diff_context_from_opts): Set the 'show-leaf-changes' and the
	'show-impacted-interfaces' flags.
	* tests/data/test-diff-filter/libtest42-leaf-report-v{0,1}.so: New
	test input.
	* tests/data/test-diff-filter/test42-leaf-report-output-0.txt: New
	test reference output.
	* tests/data/test-diff-filter/test42-leaf-report-v{0,1}.cc: Source
	code of the new test inputs.
	* tests/test-diff-filter.cc (in_out_specs): Use the new test
	inputs above in this harness.
	* tests/data/test-diff-suppr/libtest35-leaf-v0.so: New test input.
	* tests/data/test-diff-suppr/test35-leaf-report-0.txt: New test
	reference output.
	* tests/data/test-diff-suppr/test35-leaf-v{0,1}.cc: Source code of
	the new test inputs.
	* tests/data/test-diff-suppr/test35-leaf.suppr: Suppression
	specification to use for the test35 test.
	* tests/data/test-diff-suppr/libtest36-leaf-v0.so: New test input.
	* tests/data/test-diff-suppr/libtest36-leaf-v1.so: Likewise.
	* tests/data/test-diff-suppr/test36-leaf-report-0.txt: New
	reference test output.
	* tests/data/test-diff-suppr/test36-leaf-v0.cc: Source code of
	test input above.
	* tests/data/test-diff-suppr/test36-leaf-v1.cc: Likewise.
	* tests/test-diff-suppr.cc (in_out_specs): Use the new test inputs
	above in this harness.
	* tests/data/Makefile.am: Add the new test inputs above to source
	distribution.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-10-08 18:51:35 +02:00
Dodji Seketeli
63acb64bcf Support up to two --wp options for abipkgdiff
The user should be able to specify one white list package per kernel
package on the command line.  That means the user should be able to
say:

    --wp whitelist-pkg1 --wp whitelist-pkg2

on the command line.

This patch adds support for that.

	* doc/manuals/abipkgdiff.rst: Update the documentation to say that
	--wp can be provided twice, but not more than that.
	* tools/abipkgdiff.cc (options::kabi_whitelist_packages): Rename
	kabi_whitelist_package to this, and make be of vector<string>
	type.
	(package::erase_extraction_directories): Erase the white list
	package extracted data.
	(maybe_handle_kabi_whitelist_pkg, parse_command_line): Adjust.
	(main): Make sure there is no more than 2 --wp on the command
	line.  Associate a white list package to each kernel package on
	the command line.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-07-12 10:40:15 +02:00
Dodji Seketeli
6cf8f0b21f Replace --lkaw with -w and --lkaw-pkg with --wp
Make these short options be shorter.

	* doc/manuals/abipkgdiff.rst: Adjust the documentation.
	* tools/abipkgdiff.cc (display_usage): Adjust the usage string.
	(parse_command_line): Parse -w instead of --lkaw and --wp
	insteadof --lkaw-pkg.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-07-11 17:14:18 +02:00
Dodji Seketeli
41496eae52 Fix doc glitch in abidiff.rst
* doc/manuals/abidiff.rst: Fix glitch.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-07-03 17:45:49 +02:00
Dodji Seketeli
8bf7b7d26b Add documentation for the kmidiff tool
* doc/manuals/kmidiff.rst: New doc file.
	* doc/manuals/Makefile.am: Add the above file to source
	distribution.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-07-03 17:45:45 +02:00
Dodji Seketeli
e09fc8c9e2 Initial support of de-serializing the KMI of a Linux Kernel Tree
With this patch, kmidiff knows how to compare a serialized
corpus_group that represents a Kernel Module Interface (a .kmi file)
against either another serialized .kmi file, or against a kernel tree.

The patch extends the abixml reader to make it parse an
'abi-corpus-group' element.  To do that, the patch modifies
read_corpus_from_input to make it be capable of parsing several
'abi-corpus' in a row.  That modified function is then used by a new
read_corpus_group_from_input, which is itself used by the new public
entry points read_corpus_group_from_native_xml_file and
read_corpus_group_from_native_xml.

With that read_corpus_group_from_native_xml_file building block
function, the kmidiff program is modified so that it can take either
two directory trees, two .kmi files or one directory tree and one .kmi
file.

	* include/abg-libxml-utils.h (advance_to_next_sibling_element):
	Declare new function.
	* src/abg-libxml-utils.cc (go_to_next_sibling_element_or_stay)
	(advance_to_next_sibling_element): Define new functions.
	* include/abg-reader.h (read_corpus_group_from_input)
	(read_corpus_group_from_native_xml)
	(read_corpus_group_from_native_xml_file): Declare new functions.
	* src/abg-reader.cc (read_context::m_corpus_group): New data
	member.
	(read_context::{get_corpus_group, set_corpus_group}): Define new
	member functions.
	(read_translation_unit_from_input): Cleanup logic.
	(read_corpus_from_input): Don't assume that the document is
	starting with an 'abi-corpus' element.  Support the mode where a
	caller called the xmlTextReaderExpand function (and so we are
	given an expanded xmlNodePtr) and the mode where we need to use
	the xmlTextReader API to walk through the 'abi-corpus' element.
	Also, if we are building a corpus group, do not clear what used to
	be 'per-corpus' data.  That data must be shared by all the corpora
	of a given abi-corpus-group.
	(read_corpus_group_from_input, read_corpus_group_from_native_xml)
	(read_corpus_group_from_native_xml_file): Define new functions.
	* include/abg-tools-utils.h (FILE_TYPE_XML_CORPUS_GROUP): New
	enumerator of the file_type enum.
	* src/abg-tools-utils.cc (operator<<): In the overload for
	file_type, add a case for the new FILE_TYPE_XML_CORPUS_GROUP.
	(guess_file_type): Dectect abi-corpus-group xml element.
	* tools/abidiff.cc (adjust_diff_context_for_kmidiff): Define new
	static function.
	(main): Adjust to handle the new FILE_TYPE_XML_CORPUS_GROUP.  That
	is, compare two FILE_TYPE_XML_CORPUS_GROUP if they are present.
	* tools/abilint.cc (main): Likewise.
	* tools/kmidiff.cc (main): Detect that one of two .kmi files are
	passed.  In that case, load the .kmi file(s), build a corpus_group
	of it and use it in the comparison.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-07-03 17:45:41 +02:00
Dodji Seketeli
adb656cc76 Initial support of the serialization of the KMI of a Linux Kernel Tree
We have the kmidiff program that takes two Linux Kernel trees
containing the vmlinux binary and its modules and compare their Kernel
Module Interface, aka KMI.

We need to be able to serialize (save in a file) a representation of
that KMI.  We need to load that KMI back, and compare two serialized
KMIs.

This patch implements the serialization of the KMI of a Linux Kernel
tree.  It actually serializes an instance of abigail::ir::corpus_group
that is a collection of instances of abigail::ir::corpus.  The KMI of
each individual binary (vmlinux or kernel module) is represented by
one abigail::ir::corpus.  All the corpora share the same definitions
of types and decls, whenever that makes sense.

The patch thus factorizes the routines used to walk a Linux kernel out
of the kmidiff program.  These routines are then re-used in the abidw
program to make it walk a Linux kernel tree (when the --linux-tree
option is provided), load the vmlinux and module binaries as an
instance of abigail::corpus_group and serialize it out into an output
stream.

	* include/abg-tools-utils.h (check_dir)
	(get_binary_paths_from_kernel_dist)
	(build_corpus_group_from_kernel_dist_under): Declare new
	functions.  The last two functions are being moved from
	tools/kmidiff.cc so that they can be re-used.
	* include/abg-writer.h (write_corpus): Declare one overload that
	takes a write_context parameter.
	(write_corpus_group): Declare three overloads of this new function.
	* src/abg-tools-utils.cc (check_dir): Define new function.
	(load_generate_apply_suppressions, is_vmlinux, is_kernel_module)
	(find_vmlinux_and_module_paths)
	(get_binary_paths_from_kernel_dist)
	(build_corpus_group_from_kernel_dist_under): Define new functions.
	* src/abg-writer.cc (write_context::set_annotate): Define new
	member function.
	(write_corpus): Add an overload that takes a write_context.  Adapt
	the existing overload to make it use this new one.
	(write_corpus_group): Define this new function and two additional
	overloads for it.
	* tools/kmidiff.cc (set_suppressions, is_vmlinux)
	(is_kernel_module, find_vmlinux_and_module_paths)
	(get_binary_paths_from_kernel_dist)
	(build_corpus_group_from_kernel_dist_under): Remove.
	(main): Adjust the call to
	build_corpus_group_from_kernel_dist_under as its arguments are now
	adapted since it's been factorized out into abg-tools-utils.h.
	* tools/abidw.cc (options::corpus_group_for_linux): Define new
	data member.
	(options::options): Adjust.
	(display_usage): Add help strings for the new --linux-tree option.
	(load_corpus_and_write_abixml): Factorize this function out of the
	main function.
	(load_kernel_corpus_group_and_write_abixml): Define new function.
	(main): Use the factorized load_corpus_and_write_abixml and the
	new load_corpus_and_write_abixml functions.
	* tests/test-read-write.cc: Adjust.
	* doc/manuals/abidw.rst: Add documentation for the new
	--linux-tree option.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-07-03 17:45:41 +02:00
Dodji Seketeli
eae7ca0426 Introduce the --kmi-whitelist option to abidiff
abidiff had an --linux-kernel-abi-whitelist option.  Rename it
--kmi-whitelist.

	* doc/manuals/abidiff.rst: Add documentation for the
	--kmi-whitelist option.
	* tools/abidiff.cc (display_usage): Emit help string for the
	--kmi-whitelist option
	(parse_command_line): Parse the new --kmi-whitelist option, of the
	-w shortcut.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-07-03 17:45:37 +02:00
Dodji Seketeli
c15eecc9a0 Make abidw support the --kmi-whitelist option
When writting out the ABI of a Linux kernel binary we must be able to
restrict it to the set of functions and global variables which ELF
symbols have names defined in a white list.

This patch adds that support, using the --kmi-whitelist
option.

	* tools/abidw.cc (options::{kabi_whitelist_paths,
	kabi_whitelist_supprs}): New data members.
	(display_usage): Add a help string for the new --kmi-whitelist
	option.
	(parse_command_line): Parse the new --kmi-whitelist option.
	(maybe_check_suppression_files): Check the presence of the linux
	kernel abi white list passed by the option --kmi-whitelist.
	(main): Ignore loading the symbol table if the kernel abi white
	list is provided.
	* doc/manuals/abidw.rst: Add documentation for the new option.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-07-03 17:45:37 +02:00
Dodji Seketeli
5f92a183bb Make abipkgdiff compare two kernel packages
This patch makes abipkgdiff compare two kernel packages.  At the
moment the comparison is done by comparing each binary from the first
package to its counterpart in the second package.  No optimization is
done do represent a vmlinux binary and its modules as one single
entity.  So this is different from what kmidiff does.

	* include/abg-suppression.h
	(variable_suppression::variable_suppression): Add default arguments
	to the parameters.
	* include/abg-tools-utils.h (dir_exists, dir_is_empty)
	(string_begins_with, get_rpm_name, get_rpm_arch, get_deb_name)
	(file_is_kernel_package, file_is_kernel_debuginfo_package):
	Declare new functions.
	* src/abg-tools-utils.cc (dir_exists, dir_is_empty)
	(string_begins_with, get_deb_name, get_rpm_name, get_rpm_arch)
	(file_is_kernel_package, file_is_kernel_debuginfo_package): Define
	new functions.
	(gen_suppr_spec_from_kernel_abi_whitelist): The kernel ABI
	whitelist is made of ELF symbols names that ought to match
	functions *and* variables that have ELF symbols with those names.
	So generate variable suppression specifications as well.  Not just
	function suppression specifications.
	* tools/abipkgdiff.cc (options::{kabi_whitelist_package,
	show_symbols_not_referenced_by_debug_info, kabi_whitelist_paths,
	kabi_suppressions}): New data members.
	(options::options): Adjust.
	(package::KIND_KABI_WHITELISTS): New enumerator in the
	package::kind enum.
	(package::kabi_whitelist_package_): New data member.
	(package::{base_name, kabi_whitelist_package, }): New member
	functions.
	(display_usage): Add a help string to the new
	--linux-kernel-abi-whitelist and --no-unreferenced-symbols
	options.
	(parse_command_line): Parse the new --no-unreferenced-symbols,
	--linux-kernel-abi-whitelist and --lkaw-pkg options.
	(maybe_check_suppression_files): Check the presence of kabi
	whitelist files.
	(set_diff_context_from_opts): Consider (not) showing symbols not
	referenced by debug info.
	(compare): If we are looking at linux kernel packages, take the
	kernel abi whitelist into account, apply the suppressions
	resulting from the kabi whitelists to the ELF read context.
	(maybe_collect_kabi_whitelists)
	(get_kabi_whitelists_from_arch_under_dir)
	(maybe_handle_kabi_whitelist_pkg, maybe_collect_kabi_whitelists)
	(get_interesting_files_under_dir): Define new functions.
	(maybe_update_vector_of_package_content): Take a new
	file_name_to_look_for parameter.
	(create_maps_of_package_content)
	(extract_package_and_map_its_content): Consider the case of the
	package being a linux kernel package.
	(main): Take the potential --lkaw-pkg into account.
	* doc/manuals/abipkgdiff.rst: Add documentation for options
	--linux-kernel-abi-whitelist, --lkaw-pkg and
	--no-unreferenced-symbols.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-07-03 17:45:36 +02:00
Chenxiong Qi
33ee1f2a5d Bug 20087 - Clean cache before or after ABI comparison
Cache data, currently containing downloaded RPM packages from Koji, is
stored in XDG_CACHE_HOME. This patch allows user to delete cache before
or after the ABI comparison, or both.

	* configure.ac: Require shutil module.
	* doc/manuals/fedabipkgdiff.rst: Add document for new option
	clean-cache, clean-cache-before, and clean-cache-after.
	* tools/fedabipkgdiff (build_commandline_args_parser): Add new
	option --clean-cache, --clean-cache-before and
	--clean-cache-after.
	(diff_local_rpm_with_latest_rpm_from_koji): Delete download
	cache directory before or after downloading RPMs.
	(diff_latest_rpms_based_on_distros): Likewise.
	(diff_two_nvras_from_koji): Likewise.
	(diff_from_two_rpm_files): Likewise.
	* bash-completion/fedabipkgdiff: Add new options.
	* tests/mockfedabipkgdiff.in (get_download_dir): Rewrite to
	behave just like the original get_download_dir.
	(mock_get_download_dir): Removed.
	(DOWNLOAD_CACHE_DIR): New global variable pointing directory
	holding packages during tests.
	(run_fedabipkgdiff): Mock original get_download_dir with the
	rewrite get_download_dir.
	* tests/runtestfedabipkgdiff.py.in (run_fedabipkgdiff_tests):
	Add --clean-cache to run tests to ensure no regression.

Signed-off-by: Chenxiong Qi <cqi@redhat.com>
2017-03-22 15:43:37 +01:00