libabigail/doc/manuals/abidiff.rst

449 lines
13 KiB
ReStructuredText
Raw Normal View History

.. _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.
Support comparing symbols not referenced by debug info * doc/manuals/abidiff.rst: Adjust intro to mention that w/o debug info, abidiff now works but just report about added/removed symbols. Add documentation about the new --no-unreferenced-symbols option. * include/abg-comparison.h (string_elf_symbol_map): New typedef. (diff_context::show_symbols_unreferenced_by_debug_info): Declare new accessors. * src/abg-comparison.cc (diff_context::priv::show_syms_unreferenced_by_di_): New data member. (diff_context::priv::priv): Adjust. (diff_context::show_symbols_unreferenced_by_debug_info): Implement these accessors. (corpus_diff::priv::{unrefed_fn_syms_edit_script_, unrefed_var_syms_edit_script_, added_unrefed_fn_syms_, deleted_unrefed_fn_syms_, added_unrefed_var_syms_, deleted_unrefed_var_syms_}): New data members. (corpus_diff::priv::diff_stats::{num_func_syms_removed, num_func_syms_added, num_var_syms_removed, num_var_syms_added}): New data members. (corpus_diff::priv::diff_stats::diff_stats): Adjust. (corpus_diff::ensure_lookup_tables_populated): Populate lookup tables for added/removed symbols that are not referenced by any debug info. (corpus_diff::priv::apply_filters_and_compute_diff_stats): Compute stats for the added/removed symbols not referenced by any debug info. (corpus_diff::priv::emit_diff_stats): Emit stats about added/removed symbols that are not referenced by any debug info. (corpus_diff::length): Adjust to take in account added/removed symbols not referenced by any debug info. (show_linkage_name_and_aliases): New static function. (corpus_diff::report): When emitting a symbol name, emit its version too, and tell if it aliases other symbols. Avoid emitted extra new lines. Report added/removed symbols not referenced by any debug info. (compute_diff): In the overload for corpus_sptr, compute the diffs for symbols not referenced by debug info. * include/abg-corpus.h (corpus::get_unreferenced_{function,variable}_symbols): Declare new member functions. * src/abg-corpus.cc (corpus_priv::{unrefed_fun_symbols, unrefed_var_symbols}): New data members. (corpus_priv::build_unreferenced_symbols_tables): Define new member function. (struct comp_elf_symbols_functor): New functor. (corpus::is_empty): Adjust to take in account added/removed symbols not referenced by debug info. (corpus::{get_unreferenced_function_symbols, corpus::get_unreferenced_variable_symbols}): Define these accessors. * include/abg-dwarf-reader.h (enum status): Transform this into bitfields. Add a STATUS_UNKNOWN value that has the value 0. (operator|(status, status), operator&(status, status)) (operator|=(status&, status), operator&=(status, status)): New bit-wise operators to manipulate instances of the status bit-field. * src/abg-dwarf-reader.cc (get_version_for_symbol): Fix this to avoid returning garbage version sometimes. (read_debug_info_into_corpus): Fix this to return a non-null but empty corpus_sptr when there is no debug info available. (operator|(status, status), operator&(status, status)) (operator|=(status&, status), operator&=(status, status)): Define these new bitwise operators to manipulate instances of the status bit-field. (read_corpus_from_elf): Now that the abigail::dwarf_reader::status is a bit-field, set it to reflect if debug info and/or symbol tables have been found. Do not bail out if debug info hasn't been found. Rather, keep going, and go look for symbols-only; this is a kind of operating in degraded mode. * include/abg-ir.h (elf_symbol::get_aliases_id_string): Add a flag that says if the current instance of elf_symbol should be included in the list of aliases or not. * src/abg-ir.cc (elf_symbol::get_aliases_id_string): Define it. * tests/data/test-diff-dwarf/test16-syms-only-v{0,1}.o: New test input. * tools/abidiff.cc (options::show_symbols_not_referenced_by_debug_info): New data member. (options:options): Adjust. (display_usage): Add an info string for the new --no-unreferenced-symbols command line option. (parse_command_line): Parse the new --no-unreferenced-symbols command line. (set_diff_context_from_opts): Set the diff_context according to the presence of --no-unreferenced-symbols. (main): Adjust for the fact that abigail::dwarf_reader::status is now a bit-field. * tools/abilint.cc (main): Adjust for the fact that abigail::dwarf_reader::status is now a bit-field.. (): * tests/data/test-diff-dwarf/test16-syms-only-report.txt: New test reference output. * tests/data/test-diff-dwarf/test16-syms-only-v{0,1}.cc: Source code for new test input. * tests/data/test-diff-dwarf/test17-non-refed-syms-v{0,1}.o: New test input. * tests/data/test-diff-dwarf/test17-non-refed-syms-v{0,1}.cc: New source code for test input. * tests/data/test-diff-dwarf/libtest18-alias-sym-v{0,1}.so: New test input. * tests/data/test-diff-dwarf/test18-alias-sym-report-0.txt: Reference output for new test input. * tests/data/test-diff-dwarf/test18-alias-sym-v{0,1}.cc: Source code for new test input. * tests/data/test-diff-dwarf/test18-alias-sym-version-script: Source code for new test input. * tests/Makefile.am: Add the new test materials to the source distribution. * tests/test-diff-dwarf.cc(in_out_specs): Add the new input tests above to the array of tests to run by this harness. (main): Emit empty reports for empty resulting diffs. * tests/data/test-diff-dwarf/test{0,8,9,12,14-inline-report,}-report.txt: Adjust. * tests/data/test-diff-filter/test{0,01,2,4,5,7,8,9,10,12,13,15-0,15-1}-report.txt: Likewise. * tests/data/test-diff-filter/test{19-enum,20-inline,}-report-0.txt: Likewise. * tests/data/test-diff-suppr/test0-type-suppr-report-{1,2}.txt: Likewise. * tests/data/test-diff-suppr/test{1,2}-typedef-suppr-report-1.txt: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-10-22 16:05:31 +00:00
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.
Make abidiff and abicompat return meaningful exit codes As per https://sourceware.org/bugzilla/show_bug.cgi?id=18146, abidiff the exit code of abidiff and abicompat is now a bit field that can be inspected to know if the ABI change reported is incompatible for sure, or if it needs user review of the output to decide. This patch also updates the documentation. * doc/manuals/abicompat.rst: Update documentation for abicompat exit codes. * doc/manuals/abidiff.rst: Likewise for abidiff exit codes. * include/abg-tools-utils.h (enum abidiff_status): Declare new enum. (operator{|,&,|=}): Declare new operators for the new enum abidiff_status. (abidiff_status_has_error, abidiff_status_has_abi_change) (abidiff_status_has_incompatible_abi_change): Declare new functions. * src/abg-tools-utils.cc (operator{|,&,|=}): Define these new operators. (abidiff_status_has_error, abidiff_status_has_abi_change) (abidiff_status_has_incompatible_abi_change): Define new functions. * tests/test-diff-filter.cc (main): Adjust for the new exit code of abidiff. * tests/test-diff-suppr.cc (main): Likewise. * tests/test-abicompat.cc (main): Likewise. * tools/abicompat.cc (enum abicompat_status): Remove. (operator{|,&,|=}): Remove these operators for enum abicompat_status. (perform_compat_check_in_normal_mode) (perform_compat_check_in_weak_mode): Return abidiff_status instead of abicompat_status. Adjust therefore. (main): Adjust to return abidiff_status now, instead of a just zero for all non-error cases. * tools/abidiff.cc (main): Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-04-10 13:42:35 +00:00
.. _abidiff_invocation_label:
Invocation
==========
::
abidiff [options] <first-shared-library> <second-shared-library>
Make abidiff and abicompat return meaningful exit codes As per https://sourceware.org/bugzilla/show_bug.cgi?id=18146, abidiff the exit code of abidiff and abicompat is now a bit field that can be inspected to know if the ABI change reported is incompatible for sure, or if it needs user review of the output to decide. This patch also updates the documentation. * doc/manuals/abicompat.rst: Update documentation for abicompat exit codes. * doc/manuals/abidiff.rst: Likewise for abidiff exit codes. * include/abg-tools-utils.h (enum abidiff_status): Declare new enum. (operator{|,&,|=}): Declare new operators for the new enum abidiff_status. (abidiff_status_has_error, abidiff_status_has_abi_change) (abidiff_status_has_incompatible_abi_change): Declare new functions. * src/abg-tools-utils.cc (operator{|,&,|=}): Define these new operators. (abidiff_status_has_error, abidiff_status_has_abi_change) (abidiff_status_has_incompatible_abi_change): Define new functions. * tests/test-diff-filter.cc (main): Adjust for the new exit code of abidiff. * tests/test-diff-suppr.cc (main): Likewise. * tests/test-abicompat.cc (main): Likewise. * tools/abicompat.cc (enum abicompat_status): Remove. (operator{|,&,|=}): Remove these operators for enum abicompat_status. (perform_compat_check_in_normal_mode) (perform_compat_check_in_weak_mode): Return abidiff_status instead of abicompat_status. Adjust therefore. (main): Adjust to return abidiff_status now, instead of a just zero for all non-error cases. * tools/abidiff.cc (main): Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-04-10 13:42:35 +00:00
.. _abidiff_options_label:
Options
=======
* ``--help | -h``
Display a short help about the command and exit.
Add --version option to several libabigail tools This patch changed the revision number of the libabigail library to make it reflect the fact that we are not in "release candidate" mode, before the first 1.0 release. So the revision number is now "rc0". The configuration manager has been updated to support version numbers that are strings, so that it can supports things like "rc0". Then, several libabigail tools have been modified to support the --version option to display their version number. * configure.ac: Set the version revision to "rc0". * doc/manuals/abicompat.rst: Adjust manual for new --version option. * doc/manuals/abidiff.rst: Likewise. * doc/manuals/abidw.rst: Likewise. * doc/manuals/abilint.rst: Likewise. * doc/manuals/abipkgdiff.rst: Likewise. * include/abg-config.h (config::{m_format_minor, m_format_major}): Make these be strings. (config::{get,set}_format_minor_version_number): Make these return strings. (config::{get,set}_format_major_version_number): Make these return or take strings. (abigail_get_library_version): Make this take strings. * src/abg-config.cc (config::config): Adjust. (config::{get,set}_format_major_version_number): Make these return or take strings. (config::{get,set}_format_minor_version_number): Make these return strings. (abigail_get_library_version): Make this take strings. * include/abg-version.h.in: Make the version variables be strings. * src/abg-writer.cc (write_translation_unit): The version numbers are now strings so adjust. * tools/{abicompat,abidiff,abidw,abilint,abipkgdiff,abisym}.cc (options::display_version): New data member. (options::options): Initialize it. (display_usage): Add documentation for new --version option. (parse_command_line): Parse new --version option. (main): Support --version. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-11-16 10:39:15 +00:00
* `--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``.
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.
* ``--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*.
* ``--no-linkage-name``
In the resulting report, do not display the linkage names of
the added, removed, or changed functions or variables.
Add the option of printing the file, line and column information about a type being reported. * bash-completion/abicompat: Complete the new "--no-show-locs" option. * bash-completion/abidiff: Likewise. * bash-completion/abidw: Likewise. * bash-completion/abipkgdiff: Likewise. * doc/manuals/abicompat.rst: Mention the new "--no-show-locs" option. * doc/manuals/abidiff.rst: Likewise. * doc/manuals/abidw.rst: Likewise. * doc/manuals/abipkgdiff.rst: Likewise. * include/abg-comparison.h (show_locs): Add declarations. * src/abg-comparison.cc: (diff_context::priv): Add a new switch called "show_locs_" and set its default value to false. (report_loc_info): New function. Outputting the extra information is conditionalized based on the associated diff contexts settings. (show_locs): define a getter/setter for diff_context::priv::show_locs_. ({distinct,pointer,reference,qualified_type,enum,class,scope,fn_parm, typedef,corpus}_diff::report): Call report_loc_info when appropriate. (maybe_report_diff_for_member): Likewise. (represent): Accept a const reference to a diff_context_sptr as a first argument and call report_loc_info on its second argument. * src/abg-dwarf-reader.cc: * tests/data/Makefile.am: Add the new test reference files. * tests/data/test-abicompat/test0-fn-changed-report-2.txt: New test reference output. * tests/data/test-abicompat/test5-fn-changed-report-1.txt: Likewise. * tests/data/test-abicompat/test6-var-changed-report-1.txt: Likewise. * tests/data/test-abicompat/test7-fn-changed-report-2.txt: Likewise. * tests/data/test-diff-filter/test30-pr18904-rvalueref-report1.txt: Likewise. * tests/data/test-diff-filter/test31-pr18535-libstdc++-report-1.txt: Likewise. * tests/data/test-diff-pkg/dirpkg-3-report-2.txt: Likewise. * tests/data/test-diff-suppr/test6-fn-suppr-report-0-1.txt: Likewise. * tests/test-abidiff.cc: Explicitly create a diff context and turn off location emitting. * tests/test-diff-dwarf.cc: Likewise. * tests/test-abicompat.cc: Add --no-show-locs to all existing test arguments. Run a few of the existing tests again, but without this option. * tests/test-diff-filter.cc: Likewise. * tests/test-diff-pkg.cc: Likewise. * tests/test-diff-suppr.cc: Likewise. * tools/abicompat.cc: Handle the new "--no-show-locs" option. * tools/abidiff.cc: Likewise. * tools/abidw.cc: Likewise. * tools/abipkgdiff.cc: Likewise. Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
2015-11-16 09:55:28 +00:00
* ``--no-show-locs``
Do not show information about where in the *second shared library*
the respective type was changed.
* ``--no-unreferenced-symbols``
Support comparing symbols not referenced by debug info * doc/manuals/abidiff.rst: Adjust intro to mention that w/o debug info, abidiff now works but just report about added/removed symbols. Add documentation about the new --no-unreferenced-symbols option. * include/abg-comparison.h (string_elf_symbol_map): New typedef. (diff_context::show_symbols_unreferenced_by_debug_info): Declare new accessors. * src/abg-comparison.cc (diff_context::priv::show_syms_unreferenced_by_di_): New data member. (diff_context::priv::priv): Adjust. (diff_context::show_symbols_unreferenced_by_debug_info): Implement these accessors. (corpus_diff::priv::{unrefed_fn_syms_edit_script_, unrefed_var_syms_edit_script_, added_unrefed_fn_syms_, deleted_unrefed_fn_syms_, added_unrefed_var_syms_, deleted_unrefed_var_syms_}): New data members. (corpus_diff::priv::diff_stats::{num_func_syms_removed, num_func_syms_added, num_var_syms_removed, num_var_syms_added}): New data members. (corpus_diff::priv::diff_stats::diff_stats): Adjust. (corpus_diff::ensure_lookup_tables_populated): Populate lookup tables for added/removed symbols that are not referenced by any debug info. (corpus_diff::priv::apply_filters_and_compute_diff_stats): Compute stats for the added/removed symbols not referenced by any debug info. (corpus_diff::priv::emit_diff_stats): Emit stats about added/removed symbols that are not referenced by any debug info. (corpus_diff::length): Adjust to take in account added/removed symbols not referenced by any debug info. (show_linkage_name_and_aliases): New static function. (corpus_diff::report): When emitting a symbol name, emit its version too, and tell if it aliases other symbols. Avoid emitted extra new lines. Report added/removed symbols not referenced by any debug info. (compute_diff): In the overload for corpus_sptr, compute the diffs for symbols not referenced by debug info. * include/abg-corpus.h (corpus::get_unreferenced_{function,variable}_symbols): Declare new member functions. * src/abg-corpus.cc (corpus_priv::{unrefed_fun_symbols, unrefed_var_symbols}): New data members. (corpus_priv::build_unreferenced_symbols_tables): Define new member function. (struct comp_elf_symbols_functor): New functor. (corpus::is_empty): Adjust to take in account added/removed symbols not referenced by debug info. (corpus::{get_unreferenced_function_symbols, corpus::get_unreferenced_variable_symbols}): Define these accessors. * include/abg-dwarf-reader.h (enum status): Transform this into bitfields. Add a STATUS_UNKNOWN value that has the value 0. (operator|(status, status), operator&(status, status)) (operator|=(status&, status), operator&=(status, status)): New bit-wise operators to manipulate instances of the status bit-field. * src/abg-dwarf-reader.cc (get_version_for_symbol): Fix this to avoid returning garbage version sometimes. (read_debug_info_into_corpus): Fix this to return a non-null but empty corpus_sptr when there is no debug info available. (operator|(status, status), operator&(status, status)) (operator|=(status&, status), operator&=(status, status)): Define these new bitwise operators to manipulate instances of the status bit-field. (read_corpus_from_elf): Now that the abigail::dwarf_reader::status is a bit-field, set it to reflect if debug info and/or symbol tables have been found. Do not bail out if debug info hasn't been found. Rather, keep going, and go look for symbols-only; this is a kind of operating in degraded mode. * include/abg-ir.h (elf_symbol::get_aliases_id_string): Add a flag that says if the current instance of elf_symbol should be included in the list of aliases or not. * src/abg-ir.cc (elf_symbol::get_aliases_id_string): Define it. * tests/data/test-diff-dwarf/test16-syms-only-v{0,1}.o: New test input. * tools/abidiff.cc (options::show_symbols_not_referenced_by_debug_info): New data member. (options:options): Adjust. (display_usage): Add an info string for the new --no-unreferenced-symbols command line option. (parse_command_line): Parse the new --no-unreferenced-symbols command line. (set_diff_context_from_opts): Set the diff_context according to the presence of --no-unreferenced-symbols. (main): Adjust for the fact that abigail::dwarf_reader::status is now a bit-field. * tools/abilint.cc (main): Adjust for the fact that abigail::dwarf_reader::status is now a bit-field.. (): * tests/data/test-diff-dwarf/test16-syms-only-report.txt: New test reference output. * tests/data/test-diff-dwarf/test16-syms-only-v{0,1}.cc: Source code for new test input. * tests/data/test-diff-dwarf/test17-non-refed-syms-v{0,1}.o: New test input. * tests/data/test-diff-dwarf/test17-non-refed-syms-v{0,1}.cc: New source code for test input. * tests/data/test-diff-dwarf/libtest18-alias-sym-v{0,1}.so: New test input. * tests/data/test-diff-dwarf/test18-alias-sym-report-0.txt: Reference output for new test input. * tests/data/test-diff-dwarf/test18-alias-sym-v{0,1}.cc: Source code for new test input. * tests/data/test-diff-dwarf/test18-alias-sym-version-script: Source code for new test input. * tests/Makefile.am: Add the new test materials to the source distribution. * tests/test-diff-dwarf.cc(in_out_specs): Add the new input tests above to the array of tests to run by this harness. (main): Emit empty reports for empty resulting diffs. * tests/data/test-diff-dwarf/test{0,8,9,12,14-inline-report,}-report.txt: Adjust. * tests/data/test-diff-filter/test{0,01,2,4,5,7,8,9,10,12,13,15-0,15-1}-report.txt: Likewise. * tests/data/test-diff-filter/test{19-enum,20-inline,}-report-0.txt: Likewise. * tests/data/test-diff-suppr/test0-type-suppr-report-{1,2}.txt: Likewise. * tests/data/test-diff-suppr/test{1,2}-typedef-suppr-report-1.txt: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-10-22 16:05:31 +00:00
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.
* ``--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; all the suppression
specification files are then taken into account.
* ``--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 change 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.
* ``--dump-diff-tree``
Add a --dump-diff-tree to abidiff for debugging purposes I have felt the need to emit a textual representation of the diff nodes tree maintained by the comparison engine for changed functions and variables. This patch adds that functionality. * include/abg-comparison.h (enum visiting_kind): Add new DO_NOT_MARK_VISITED_NODES_AS_TRAVERSED enumerator. (diff_context::{default_output_stream, error_output_stream, dump_diff_tree}): Declare new accessors. (diff::end_traversing): Take a new boolean flag. (print_diff_tree): Add new overload for diff_sptr. * src/abg-comparison.cc (diff_context::priv::{default_output_stream_, error_output_stream_, dump_diff_tree_}): New data members. (priv::priv): Initialize them. (diff_context::{default_output_stream_, error_output_stream_, dump_diff_tree, dump_diff_tree}): Define new accessors. (diff::end_traversing): Take a new flag that control whether or not to mark the current diff node as having been traversed. (diff::traverse): Take in account the visiting kind carried by the visitor to determine if the visited node should be marked as being traversed. (corpus_diff::priv::maybe_dump_diff_tree): Define new member function. (corpus_diff::report): Call it. (diff_node_printer::visit): Pretty print the diff node just once. (print_diff_tree): Define a new overload for diff_sptr. * tools/abidiff.cc (options::dump_diff_tree): New data member. (options::options): Initialize it. (display_usage): Add a help string for the new --dump-diff-tree command line switch. (parse_command_line): Parse the new --dump-diff-tree command line switch. (set_diff_context_from_opts): Set the diff context according to the --dump-diff-tree presence. * doc/manuals/abidiff.rst: Add a bullet point for the new --dump-diff-tree command line switch. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-12-27 11:42:34 +00:00
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.
Add a --stats to abidiff and abidw For now, this new --stats emits diagnostics about the number of types canonicalized at the very end of building the ABI corpus as well as the number of types that were scheduled for late canonicalizing and that couldn't be canonicalized. * include/abg-dwarf-reader.h (get_show_stats) (set_show_stats): New accessors for a new "show_stats" property of the dwarf reader context. * src/abg-dwarf-reader.cc: Include iostream to use std::cerr. (dwarf_reader::show_stats_): New data member. (dwarf_reader::dwarf_reader): Initialize it. (dwarf_reader::show_stats) (get_show_stats) (set_show_stats): Define new accessors. (dwarf_reader::die_type_map): Add const overload to this accessor. (dwarf_reader::lookup_type_from_die_offset): Make this accessor const. (dwarf_reader::add_late_canonicalized_types_stats): New member function. (dwarf_reader::perform_late_type_canonicalizing): Emit the statistics about late-canonicalized types if the user asked for it. * tools/abidiff.cc (options::show_stats): New data member. (options::options): Initialize it. (display_usage): Document it. (parse_command_line): Parse the new --stats option. (main): Create a dwarf reader context, set the show_stats to it and then use that context to read the corpora before diffing them. * tools/abidw.cc (options::show_stats): New data member. (options::options): Initialize it. (display_usage): Document it. (parse_command_line): Parse the new --stats option. (main): Set the show_stats to the dwarf reader context before using it. * doc/manuals/abidiff.rst: Update the manual. * doc/manuals/abidw.rst: Update the manual. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-08-20 10:28:38 +00:00
* ``--stats``
Emit statistics about various internal things.
* ``--verbose``
Emit verbose logs about the progress of miscellaneous internal
things.
Make abidiff and abicompat return meaningful exit codes As per https://sourceware.org/bugzilla/show_bug.cgi?id=18146, abidiff the exit code of abidiff and abicompat is now a bit field that can be inspected to know if the ABI change reported is incompatible for sure, or if it needs user review of the output to decide. This patch also updates the documentation. * doc/manuals/abicompat.rst: Update documentation for abicompat exit codes. * doc/manuals/abidiff.rst: Likewise for abidiff exit codes. * include/abg-tools-utils.h (enum abidiff_status): Declare new enum. (operator{|,&,|=}): Declare new operators for the new enum abidiff_status. (abidiff_status_has_error, abidiff_status_has_abi_change) (abidiff_status_has_incompatible_abi_change): Declare new functions. * src/abg-tools-utils.cc (operator{|,&,|=}): Define these new operators. (abidiff_status_has_error, abidiff_status_has_abi_change) (abidiff_status_has_incompatible_abi_change): Define new functions. * tests/test-diff-filter.cc (main): Adjust for the new exit code of abidiff. * tests/test-diff-suppr.cc (main): Likewise. * tests/test-abicompat.cc (main): Likewise. * tools/abicompat.cc (enum abicompat_status): Remove. (operator{|,&,|=}): Remove these operators for enum abicompat_status. (perform_compat_check_in_normal_mode) (perform_compat_check_in_weak_mode): Return abidiff_status instead of abicompat_status. Adjust therefore. (main): Adjust to return abidiff_status now, instead of a just zero for all non-error cases. * tools/abidiff.cc (main): Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-04-10 13:42:35 +00:00
.. _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.
Make abidiff and abicompat return meaningful exit codes As per https://sourceware.org/bugzilla/show_bug.cgi?id=18146, abidiff the exit code of abidiff and abicompat is now a bit field that can be inspected to know if the ABI change reported is incompatible for sure, or if it needs user review of the output to decide. This patch also updates the documentation. * doc/manuals/abicompat.rst: Update documentation for abicompat exit codes. * doc/manuals/abidiff.rst: Likewise for abidiff exit codes. * include/abg-tools-utils.h (enum abidiff_status): Declare new enum. (operator{|,&,|=}): Declare new operators for the new enum abidiff_status. (abidiff_status_has_error, abidiff_status_has_abi_change) (abidiff_status_has_incompatible_abi_change): Declare new functions. * src/abg-tools-utils.cc (operator{|,&,|=}): Define these new operators. (abidiff_status_has_error, abidiff_status_has_abi_change) (abidiff_status_has_incompatible_abi_change): Define new functions. * tests/test-diff-filter.cc (main): Adjust for the new exit code of abidiff. * tests/test-diff-suppr.cc (main): Likewise. * tests/test-abicompat.cc (main): Likewise. * tools/abicompat.cc (enum abicompat_status): Remove. (operator{|,&,|=}): Remove these operators for enum abicompat_status. (perform_compat_check_in_normal_mode) (perform_compat_check_in_weak_mode): Return abidiff_status instead of abicompat_status. Adjust therefore. (main): Adjust to return abidiff_status now, instead of a just zero for all non-error cases. * tools/abidiff.cc (main): Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-04-10 13:42:35 +00:00
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