libabigail/doc/manuals/abidiff.rst
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

687 lines
22 KiB
ReStructuredText

.. _abidiff_label:
=======
abidiff
=======
abidiff compares the Application Binary Interfaces (ABI) of two shared
libraries in `ELF`_ format. It emits a meaningful report describing the
differences between the two ABIs.
This tool can also compare the textual representations of the ABI of
two ELF binaries (as emitted by ``abidw``) or an ELF binary against a
textual representation of another ELF binary.
For a comprehensive ABI change report that includes changes about
function and variable sub-types, the two input shared libraries must
be accompanied with their debug information in `DWARF`_ format.
Otherwise, only `ELF`_ symbols that were added or removed are
reported.
.. _abidiff_invocation_label:
Invocation
==========
::
abidiff [options] <first-shared-library> <second-shared-library>
Environment
===========
.. _abidiff_default_supprs_label:
abidiff loads two default :ref:`suppression specifications files
<suppr_spec_label>`, merges their content and use it to filter out ABI
change reports that might be considered as false positives to users.
* Default system-wide suppression specification file
It's located by the optional environment variable
LIBABIGAIL_DEFAULT_SYSTEM_SUPPRESSION_FILE. If that environment
variable is not set, then abidiff tries to load the suppression file
$libdir/libabigail/libabigail-default.abignore. If that file is not
present, then no default system-wide suppression specification file
is loaded.
* Default user suppression specification file.
It's located by the optional environment
LIBABIGAIL_DEFAULT_USER_SUPPRESSION_FILE. If that environment
variable is not set, then abidiff tries to load the suppression file
$HOME/.abignore. If that file is not present, then no default user
suppression specification is loaded.
.. _abidiff_options_label:
Options
=======
* ``--help | -h``
Display a short help about the command and exit.
* ``--version | -v``
Display the version of the program and exit.
* ``--debug-info-dir1 | --d1`` <*di-path1*>
For cases where the debug information for *first-shared-library*
is split out into a separate file, tells ``abidiff`` where to find
that separate debug information file.
Note that *di-path* must point to the root directory under which
the debug information is arranged in a tree-like manner. Under
Red Hat based systems, that directory is usually
``<root>/usr/lib/debug``.
This option can be provided several times with different root
directories. In that case, ``abidiff`` will potentially look into
all those root directories to find the split debug info for
*first-shared-library*.
Note also that this option is not mandatory for split debug
information installed by your system's package manager because
then ``abidiff`` knows where to find it.
* ``--debug-info-dir2 | --d2`` <*di-path2*>
Like ``--debug-info-dir1``, this options tells ``abidiff`` where
to find the split debug information for the
*second-shared-library* file.
This option can be provided several times with different root
directories. In that case, ``abidiff`` will potentially look into
all those root directories to find the split debug info for
*second-shared-library*.
* ``--headers-dir1 | --hd1`` <headers-directory-path-1>
Specifies where to find the public headers of the first shared
library that the tool has to consider. The tool will thus filter
out ABI changes on types that are not defined in public headers.
* ``--headers-dir2 | --hd2`` <headers-directory-path-1>
Specifies where to find the public headers of the second shared
library that the tool has to consider. The tool will thus filter
out ABI changes on types that are not defined in public headers.
* ``--no-linux-kernel-mode``
Without this option, if abidiff detects that the binaries it is
looking at are Linux Kernel binaries (either vmlinux or modules)
then it only considers functions and variables which ELF symbols
are listed in the __ksymtab and __ksymtab_gpl sections.
With this option, abidiff considers the binary as a non-special
ELF binary. It thus considers functions and variables which are
defined and exported in the ELF sense.
* ``--kmi-whitelist | -kaw`` <*path-to-whitelist*>
When analyzing a Linux kernel binary, this option points to the
white list of names of ELF symbols of functions and variables
which ABI must be considered. That white list is called a "Kernel
Module Interface white list". This is because for the Kernel, we
don't talk about ``ABI``; we rather talk about the interface
between the Kernel and its module. Hence the term ``KMI`` rather
than ``ABI``.
Any other function or variable which ELF symbol are not present in
that white list will not be considered by this tool.
If this option is not provided -- thus if no white list is
provided -- then the entire KMI, that is, the set of all publicly
defined and exported functions and global variables by the Linux
Kernel binaries, is considered.
* ``--drop-private-types``
This option is to be used with the ``--headers-dir1`` and
``--headers-dir2`` options. With this option, types that are
*NOT* defined in the headers are entirely dropped from the
internal representation build by Libabigail to represent the ABI.
They thus don't have to be filtered out from the final ABI change
report because they are not even present in Libabigail's
representation.
Without this option however, those private types are kept in the
internal representation and later filtered out from the report.
This options thus potentially makes Libabigail consume less
memory. It's meant to be mainly used to optimize the memory
consumption of the tool on binaries with a lot of publicly defined
and exported types.
* ``--stat``
Rather than displaying the detailed ABI differences between
*first-shared-library* and *second-shared-library*, just display
some summary statistics about these differences.
* ``--symtabs``
Only display the symbol tables of the *first-shared-library* and
*second-shared-library*.
* ``--deleted-fns``
In the resulting report about the differences between
*first-shared-library* and *second-shared-library*, only display
the globally defined functions that got deleted from
*first-shared-library*.
* ``--changed-fns``
In the resulting report about the differences between
*first-shared-library* and *second-shared-library*, only display
the changes in sub-types of the global functions defined in
*first-shared-library*.
* ``--added-fns``
In the resulting report about the differences between
*first-shared-library* and *second-shared-library*, only display
the globally defined functions that were added to
*second-shared-library*.
* ``--deleted-vars``
In the resulting report about the differences between
*first-shared-library* and *second-shared-library*, only display
the globally defined variables that were deleted from
*first-shared-library*.
* ``--changed-vars``
In the resulting report about the differences between
*first-shared-library* and *second-shared-library*, only display
the changes in the sub-types of the global variables defined in
*first-shared-library*
* ``--added-vars``
In the resulting report about the differences between
*first-shared-library* and *second-shared-library*, only display
the global variables that were added (defined) to
*second-shared-library*.
* ``--non-reachable-types|-t``
Analyze and emit change reports for all the types of the binary,
including those that are not reachable from global functions and
variables.
This option might incur some serious performance degradation as
the number of types analyzed can be huge. However, if paired with
the ``--headers-dir{1,2}`` options, the additional non-reachable
types analyzed are restricted to those defined in public headers
files, thus hopefully making the performance hit acceptable.
Also, using this option alongside suppression specifications (by
also using the ``--suppressions`` option) might help keep the number of
analyzed types (and the potential performance degradation) in
control.
Note that without this option, only types that are reachable from
global functions and variables are analyzed, so the tool detects
and reports changes on these reachable types only.
* ``--no-added-syms``
In the resulting report about the differences between
*first-shared-library* and *second-shared-library*, do not display
added functions or variables. Do not display added functions or
variables ELF symbols either. All other kinds of changes are
displayed unless they are explicitely forbidden by other options
on the command line.
* ``--no-linkage-name``
In the resulting report, do not display the linkage names of
the added, removed, or changed functions or variables.
* ``--no-show-locs``
Do not show information about where in the *second shared library*
the respective type was changed.
* ``--show-bytes``
Show sizes and offsets in bytes, not bits. By default, sizes and
offsets are shown in bits.
* ``--show-bits``
Show sizes and offsets in bits, not bytes. This option is
activated by default.
* ``--show-hex``
Show sizes and offsets in hexadecimal base.
* ``--show-dec``
Show sizes and offsets in decimal base. This option is activated
by default.
* ``--no-show-relative-offset-changes``
Without this option, when the offset of a data member changes,
the change report not only mentions the older and newer offset,
but it also mentions by how many bits the data member changes.
With this option, the latter is not shown.
* ``--no-unreferenced-symbols``
In the resulting report, do not display change information about
function and variable symbols that are not referenced by any debug
information. Note that for these symbols not referenced by any
debug information, the change information displayed is either
added or removed symbols.
* ``--no-default-suppression``
Do not load the :ref:`default suppression specification files
<abidiff_default_supprs_label>`.
* ``--suppressions | --suppr`` <*path-to-suppressions*>
Use a :ref:`suppression specification <suppr_spec_label>` file
located at *path-to-suppressions*. Note that this option can
appear multiple times on the command line. In that case, all of
the provided suppression specification files are taken into
account.
Please note that, by default, if this option is not provided, then
the :ref:`default suppression specification files
<abidiff_default_supprs_label>` are loaded .
* ``--drop`` <*regex*>
When reading the *first-shared-library* and
*second-shared-library* ELF input files, drop the globally defined
functions and variables which name match the regular expression
*regex*. As a result, no change involving these functions or
variables will be emitted in the diff report.
* ``--drop-fn`` <*regex*>
When reading the *first-shared-library* and
*second-shared-library* ELF input files, drop the globally defined
functions which name match the regular expression *regex*. As a
result, no change involving these functions will be emitted in the
diff report.
* ``--drop-var`` <*regex*>
When reading the *first-shared-library* and
*second-shared-library* ELF input files, drop the globally defined
variables matching a the regular expression *regex*.
* ``--keep`` <*regex*>
When reading the *first-shared-library* and
*second-shared-library* ELF input files, keep the globally defined
functions and variables which names match the regular expression
*regex*. All other functions and variables are dropped on the
floor and will thus not appear in the resulting diff report.
* ``--keep-fn`` <*regex*>
When reading the *first-shared-library* and
*second-shared-library* ELF input files, keep the globally defined
functions which name match the regular expression *regex*. All
other functions are dropped on the floor and will thus not appear
in the resulting diff report.
* ``--keep-var`` <*regex*>
When reading the *first-shared-library* and
*second-shared-library* ELF input files, keep the globally defined
which names match the regular expression *regex*. All other
variables are dropped on the floor and will thus not appear in the
resulting diff report.
* ``--harmless``
In the diff report, display only the :ref:`harmless
<harmlesschangeconcept_label>` changes. By default, the harmless
changes are filtered out of the diff report keep the clutter to a
minimum and have a greater chance to spot real ABI issues.
* ``--no-harmful``
In the diff report, do not display the :ref:`harmful
<harmfulchangeconcept_label>` changes. By default, only the
harmful changes are displayed in diff report.
* ``--redundant``
In the diff report, do display redundant changes. A redundant
change is a change that has been displayed elsewhere in the
report.
* ``--no-redundant``
In the diff report, do *NOT* display redundant changes. A
redundant change is a change that has been displayed elsewhere in
the report. This option is switched on by default.
* ``--no-architecture``
Do not take architecture in account when comparing ABIs.
* ``--no-corpus-path``
Do not emit the path attribute for the ABI corpus.
* ``--fail-no-debug-info``
If no debug info was found, then this option makes the program to
fail. Otherwise, without this option, the program will attempt to
compare properties of the binaries that are not related to debug
info, like pure ELF properties.
* ``--leaf-changes-only|-l`` only show leaf changes, so don't show
impact analysis report.
The typical output of abidiff when comparing two binaries looks
like this ::
$ abidiff libtest-v0.so libtest-v1.so
Functions changes summary: 0 Removed, 1 Changed, 0 Added function
Variables changes summary: 0 Removed, 0 Changed, 0 Added variable
1 function with some indirect sub-type change:
[C]'function void fn(C&)' at test-v1.cc:13:1 has some indirect sub-type changes:
parameter 1 of type 'C&' has sub-type changes:
in referenced type 'struct C' at test-v1.cc:7:1:
type size hasn't changed
1 data member change:
type of 'leaf* C::m0' changed:
in pointed to type 'struct leaf' at test-v1.cc:1:1:
type size changed from 32 to 64 bits
1 data member insertion:
'char leaf::m1', at offset 32 (in bits) at test-v1.cc:4:1
$
So in that example the report emits information about how the data
member insertion change of "struct leaf" is reachable from
function "void fn(C&)". In other words, the report not only shows
the data member change on "struct leaf", but it also shows the
impact of that change on the function "void fn(C&)".
In abidiff parlance, the change on "struct leaf" is called a leaf
change. So the ``--leaf-changes-only --impacted-interfaces``
options show, well, only the leaf change. And it goes like this:
::
$ abidiff -l libtest-v0.so libtest-v1.so
'struct leaf' changed:
type size changed from 32 to 64 bits
1 data member insertion:
'char leaf::m1', at offset 32 (in bits) at test-v1.cc:4:1
one impacted interface:
function void fn(C&)
$
Note how the report ends by showing the list of interfaces
impacted by the leaf change.
Now if you don't want to see that list of impacted interfaces,
then you can just avoid using the ``--impacted-interface`` option.
You can learn about that option below, in any case.
* ``--impacted-interfaces``
When showing leaf changes, this option instructs abidiff to show
the list of impacted interfaces. This option is thus to be used
in addition the ``--leaf-changes-only`` option, otherwise, it's
ignored.
* ``--dump-diff-tree``
After the diff report, emit a textual representation of the diff
nodes tree used by the comparison engine to represent the changed
functions and variables. That representation is emitted to the
error output for debugging purposes. Note that this diff tree is
relevant only to functions and variables that have some sub-type
changes. Added or removed functions and variables do not have any
diff nodes tree associated to them.
* ``--stats``
Emit statistics about various internal things.
* ``--verbose``
Emit verbose logs about the progress of miscellaneous internal
things.
.. _abidiff_return_value_label:
Return values
=============
The exit code of the ``abidiff`` command is either 0 if the ABI of the
binaries being compared are equal, or non-zero if they differ or if
the tool encountered an error.
In the later case, the exit code is a 8-bits-wide bit field in which
each bit has a specific meaning.
The first bit, of value 1, named ``ABIDIFF_ERROR`` means there was an
error.
The second bit, of value 2, named ``ABIDIFF_USAGE_ERROR`` means there
was an error in the way the user invoked the tool. It might be set,
for instance, if the user invoked the tool with an unknown command
line switch, with a wrong number or argument, etc. If this bit is
set, then the ``ABIDIFF_ERROR`` bit must be set as well.
The third bit, of value 4, named ``ABIDIFF_ABI_CHANGE`` means the ABI
of the binaries being compared are different.
The fourth bit, of value 8, named ``ABIDIFF_ABI_INCOMPATIBLE_CHANGE``
means the ABI of the binaries compared are different in an
incompatible way. If this bit is set, then the ``ABIDIFF_ABI_CHANGE``
bit must be set as well. If the ``ABIDIFF_ABI_CHANGE`` is set and the
``ABIDIFF_INCOMPATIBLE_CHANGE`` is *NOT* set, then it means that the
ABIs being compared might or might not be compatible. In that case, a
human being needs to review the ABI changes to decide if they are
compatible or not.
Note that, at the moment, there are only a few kinds of ABI changes
that would result in setting the flag ``ABIDIFF_ABI_INCOMPATIBLE_CHANGE``.
Those ABI changes are either:
- the removal of the symbol of a function or variable that has been
defined and exported.
- the modification of the index of a member of a virtual function
table (for C++ programs and libraries).
With time, when more ABI change patterns are found to *always*
constitute incompatible ABI changes, we will adapt the code to
recognize those cases and set the ``ABIDIFF_ABI_INCOMPATIBLE_CHANGE``
accordingly. So, if you find such patterns, please let us know.
The remaining bits are not used for the moment.
.. _abidiff_usage_example_label:
Usage examples
==============
1. Detecting a change in a sub-type of a function: ::
$ cat -n test-v0.cc
1 // Compile this with:
2 // g++ -g -Wall -shared -o libtest-v0.so test-v0.cc
3
4 struct S0
5 {
6 int m0;
7 };
8
9 void
10 foo(S0* /*parameter_name*/)
11 {
12 // do something with parameter_name.
13 }
$
$ cat -n test-v1.cc
1 // Compile this with:
2 // g++ -g -Wall -shared -o libtest-v1.so test-v1.cc
3
4 struct type_base
5 {
6 int inserted;
7 };
8
9 struct S0 : public type_base
10 {
11 int m0;
12 };
13
14 void
15 foo(S0* /*parameter_name*/)
16 {
17 // do something with parameter_name.
18 }
$
$ g++ -g -Wall -shared -o libtest-v0.so test-v0.cc
$ g++ -g -Wall -shared -o libtest-v1.so test-v1.cc
$
$ ../build/tools/abidiff libtest-v0.so libtest-v1.so
Functions changes summary: 0 Removed, 1 Changed, 0 Added function
Variables changes summary: 0 Removed, 0 Changed, 0 Added variable
1 function with some indirect sub-type change:
[C]'function void foo(S0*)' has some indirect sub-type changes:
parameter 0 of type 'S0*' has sub-type changes:
in pointed to type 'struct S0':
size changed from 32 to 64 bits
1 base class insertion:
struct type_base
1 data member change:
'int S0::m0' offset changed from 0 to 32
$
2. Detecting another change in a sub-type of a function: ::
$ cat -n test-v0.cc
1 // Compile this with:
2 // g++ -g -Wall -shared -o libtest-v0.so test-v0.cc
3
4 struct S0
5 {
6 int m0;
7 };
8
9 void
10 foo(S0& /*parameter_name*/)
11 {
12 // do something with parameter_name.
13 }
$
$ cat -n test-v1.cc
1 // Compile this with:
2 // g++ -g -Wall -shared -o libtest-v1.so test-v1.cc
3
4 struct S0
5 {
6 char inserted_member;
7 int m0;
8 };
9
10 void
11 foo(S0& /*parameter_name*/)
12 {
13 // do something with parameter_name.
14 }
$
$ g++ -g -Wall -shared -o libtest-v0.so test-v0.cc
$ g++ -g -Wall -shared -o libtest-v1.so test-v1.cc
$
$ ../build/tools/abidiff libtest-v0.so libtest-v1.so
Functions changes summary: 0 Removed, 1 Changed, 0 Added function
Variables changes summary: 0 Removed, 0 Changed, 0 Added variable
1 function with some indirect sub-type change:
[C]'function void foo(S0&)' has some indirect sub-type changes:
parameter 0 of type 'S0&' has sub-type changes:
in referenced type 'struct S0':
size changed from 32 to 64 bits
1 data member insertion:
'char S0::inserted_member', at offset 0 (in bits)
1 data member change:
'int S0::m0' offset changed from 0 to 32
$
3. Detecting that functions got removed or added to a library: ::
$ cat -n test-v0.cc
1 // Compile this with:
2 // g++ -g -Wall -shared -o libtest-v0.so test-v0.cc
3
4 struct S0
5 {
6 int m0;
7 };
8
9 void
10 foo(S0& /*parameter_name*/)
11 {
12 // do something with parameter_name.
13 }
$
$ cat -n test-v1.cc
1 // Compile this with:
2 // g++ -g -Wall -shared -o libtest-v1.so test-v1.cc
3
4 struct S0
5 {
6 char inserted_member;
7 int m0;
8 };
9
10 void
11 bar(S0& /*parameter_name*/)
12 {
13 // do something with parameter_name.
14 }
$
$ g++ -g -Wall -shared -o libtest-v0.so test-v0.cc
$ g++ -g -Wall -shared -o libtest-v1.so test-v1.cc
$
$ ../build/tools/abidiff libtest-v0.so libtest-v1.so
Functions changes summary: 1 Removed, 0 Changed, 1 Added functions
Variables changes summary: 0 Removed, 0 Changed, 0 Added variable
1 Removed function:
'function void foo(S0&)' {_Z3fooR2S0}
1 Added function:
'function void bar(S0&)' {_Z3barR2S0}
$
.. _ELF: http://en.wikipedia.org/wiki/Executable_and_Linkable_Format
.. _DWARF: http://www.dwarfstd.org