libabigail/doc/manuals/abicompat.rst

309 lines
8.6 KiB
ReStructuredText
Raw Normal View History

Initial implementation of the abicompat tool Given an application A that links to a shared library L of version V denoted L(V) and a subsequent version of that library denoted L(V+P), the 'abicompat' tool tells the user if L(V+P) is still ABI compatible with L(V+P). And if it is not, abicompat gives a reports that shows the differences between L(V) and L(V+P) that makes L(V+P) ABI-incompatible with A. The source code of this tool is in the tools/abicompat.cc source file. To support this new tool, this commit changes the comparison engine to optionally avoid showing added symbols that were not referenced by any debug info. It changes the ABI corpus type to allow the specification of a list of variables and functions symbols to keep (and drop all other functions and variables which have other symbols on the floor even before starting to compare the two libraries). This is how the abicompat tool itself works. It basically compares L(V) and L(V+P) but it only looks at their exported functions and variables which symbols are undefined in application A. If the list of exported and defined variables and functions of L(V) whose symbols are undefined in A equals that of L(V+P) (including the sub-types of these variables and functions) A is still compatible with L(V+P). Otherwise, they might not be compatible depending on the kind of differences that are found. * include/abg-comparison.h (diff_context::show_added_symbols_unreferenced_by_debug_info): Declare new accessors. (corpus_diff::{deleted_variables, deleted_unrefed_function_symbols, deleted_unrefed_variable_symbols, apply_filters_and_suppressions_before_reporting}): Declare new methods. (corpus_diff::diff_stats): Declare this new type. Actually this was previously corpus_diff::priv::diff_stats, which was a hidden internal type.. We are moving it here, in the external API so that client code can have more information about changes statistics. Change all the previously publicly accessible data members into accessor functions. * src/abg-comparison.cc (class corpus_diff::diff_stats::priv): New type. (diff_context::priv::show_added_syms_unreferenced_by_di_): New data member. (diff_context::priv::priv): Adjust. (diff_context::show_added_symbols_unreferenced_by_debug_info): Define this new method. (corpus_diff::priv::emit_diff_stats): Do not show the diff stat if the only changes is added function or variables symbols and if we were instructed to not show added symbols. (corpus_diff::priv::{diff_stats_, filters_and_suppr_applied_}): New data members. (corpus_diff::priv::priv): Initialize the filters_and_suppr_applied_ data member. (corpus_diff::priv::diff_stats): Move this type to corpus_diff::diff_stats. (corpus_diff::priv::{apply_filters_and_compute_diff_stats, emit_diff_stats}): Adjust. (corpus_diff::apply_filters_and_suppressions_before_reporting): Define new member function. (corpus_diff::report): Use the new apply_filters_and_suppressions_before_reporting() function, rather than applying the filters and suppressions by ourselves. Also adjust to the use the accessors of the new corpus_diff::diff_stats type. (corpus_diff::{deleted_variables, deleted_unrefed_function_symbols, deleted_unrefed_variable_symbols}): Define new accessors. (corpus_diff::diff_stats::{diff_stats, num_func_removed, num_func_added, num_func_changed, num_func_filtered_out, net_num_func_changed, num_vars_removed, num_vars_added, num_vars_changed, num_vars_filtered_out, net_num_vars_changed, num_func_sym_removed, num_func_syms_added, num_var_syms_removed, num_var_syms_added}): Define new member functions. * include/abg-corpus.h (corpus::{get_sym_ids_of_fns_to_keep, get_sym_ids_of_vars_to_keep}): Declare new methods. * src/abg-corpus.cc (corpus::priv::{sym_id_fns_to_keep, sym_id_vars_to_keep}): Added data members. (symtab_build_visitor_type::{unrefed_fun_symbols, unrefed_var_symbols, sym_id_fns_to_keep, sym_id_vars_to_keep}): Added new data members. (symtab_build_visitor_type::symtab_build_visitor_type): Take two additional parameters for the function and variable symbol ids to keep. (symtab_build_visitor_type::add_fn_to_wip_fns): Take the function symbols to keep in account when building the exported symbol table. (symtab_build_visitor_type::add_var_to_wip_vars): Likewise, take the variable symbols to keep in account when building the exported symbol table. (corpus::priv::build_public_decl_table): Adjust the initialization of the visitor that walks the ABI artifacts to build the exported symbol table to know take a list of function/variable symbols to keep. (corpus::priv::build_unreferenced_symbols_tables): Ensure that the public table of functions/variables is built before doing the work of this function. Also, if a list of variable/function symbols to keep is given, drop all symbols that are not in that list on the floor. (corpus::{get_sym_ids_of_fns_to_keep, get_sym_ids_of_vars_to_keep}): Define new accessors. * tools/abicompat.cc: New abicompat tool. * doc/manuals/abicompat.rst: New documentation source for abicompat. * doc/manuals/libabigail-tools.rst: Add an entry for the abicompat doc. * tests/test-abicompat.cc: New test harness for the 'abicompat' tool. * tests/Makefile.am: Build the runtestabicompat test harness and add it to the list of tests harnesses that are run by make check. * tests/data/test-abicompat/libtest0-fn-changed-libapp-v0.so: New test input. * tests/data/test-abicompat/libtest0-fn-changed-libapp-v1.so: Likewise. * tests/data/test-abicompat/test0-fn-changed-app: Likewise. * tests/data/test-abicompat/test0-fn-changed-0.suppr: Likewise * tests/data/test-abicompat/test0-fn-changed-report-0.txt: Likewise. * tests/data/test-abicompat/test0-fn-changed-report-1.txt: Likewise. * tests/data/test-abicompat/test0-fn-changed-app.cc: Likewise. * tests/data/test-abicompat/test0-fn-changed-libapp.h: Likewise. * tests/data/test-abicompat/test0-fn-changed-libapp-v0.cc: Likewise. * tests/data/test-abicompat/test0-fn-changed-libapp-v1.cc: Likewise. * tests/data/test-abicompat/libtest1-fn-removed-v0.so: Likewise. * tests/data/test-abicompat/libtest1-fn-removed-v1.so: Likewise. * tests/data/test-abicompat/test1-fn-removed-app: Likewise. * tests/data/test-abicompat/test1-fn-removed-app.cc: Likewise. * tests/data/test-abicompat/test1-fn-removed-report-0.txt: Likewise. * tests/data/test-abicompat/test1-fn-removed-v0.cc: Likewise. * tests/data/test-abicompat/test1-fn-removed-v1.cc: Likewise. * tests/data/test-abicompat/libtest2-var-removed-v0.so: Likewise. * tests/data/test-abicompat/libtest2-var-removed-v1.so: Likewise. * tests/data/test-abicompat/test2-var-removed-app: Likewise. * tests/data/test-abicompat/test2-var-removed-app.cc: Likewise. * tests/data/test-abicompat/test2-var-removed-report-0.txt: Likewise. * tests/data/test-abicompat/test2-var-removed-v0.cc: Likewise. * tests/data/test-abicompat/test2-var-removed-v1.cc: Likewise. * tests/data/test-abicompat/libtest3-fn-removed-v0.so: Likewise. * tests/data/test-abicompat/libtest3-fn-removed-v1.so: Likewise. * tests/data/test-abicompat/test3-fn-removed-app: Likewise. * tests/data/test-abicompat/test3-fn-removed-app.cc: Likewise. * tests/data/test-abicompat/test3-fn-removed-report-0.txt: Likewise. * tests/data/test-abicompat/test3-fn-removed-v0.cc: Likewise. * tests/data/test-abicompat/test3-fn-removed-v1.cc: Likewise. * tests/data/test-abicompat/test3-fn-removed-version-script-0 Likewise.: * tests/data/test-abicompat/test3-fn-removed-version-script-1: Likewise. * tests/data/Makefile.am: Add the new test inputs above to the source distribution. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-11-30 17:18:55 +00:00
.. _abicompat_label:
=========
abicompat
=========
abicompat checks that an application that links against a given shared
library is still ABI compatible with a subsequent version of that
library. If the new version of the library introduces an ABI
incompatibility, then abicompat hints the user at what exactly that
incompatibility is.
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
.. _abicompat_invocation_label:
Initial implementation of the abicompat tool Given an application A that links to a shared library L of version V denoted L(V) and a subsequent version of that library denoted L(V+P), the 'abicompat' tool tells the user if L(V+P) is still ABI compatible with L(V+P). And if it is not, abicompat gives a reports that shows the differences between L(V) and L(V+P) that makes L(V+P) ABI-incompatible with A. The source code of this tool is in the tools/abicompat.cc source file. To support this new tool, this commit changes the comparison engine to optionally avoid showing added symbols that were not referenced by any debug info. It changes the ABI corpus type to allow the specification of a list of variables and functions symbols to keep (and drop all other functions and variables which have other symbols on the floor even before starting to compare the two libraries). This is how the abicompat tool itself works. It basically compares L(V) and L(V+P) but it only looks at their exported functions and variables which symbols are undefined in application A. If the list of exported and defined variables and functions of L(V) whose symbols are undefined in A equals that of L(V+P) (including the sub-types of these variables and functions) A is still compatible with L(V+P). Otherwise, they might not be compatible depending on the kind of differences that are found. * include/abg-comparison.h (diff_context::show_added_symbols_unreferenced_by_debug_info): Declare new accessors. (corpus_diff::{deleted_variables, deleted_unrefed_function_symbols, deleted_unrefed_variable_symbols, apply_filters_and_suppressions_before_reporting}): Declare new methods. (corpus_diff::diff_stats): Declare this new type. Actually this was previously corpus_diff::priv::diff_stats, which was a hidden internal type.. We are moving it here, in the external API so that client code can have more information about changes statistics. Change all the previously publicly accessible data members into accessor functions. * src/abg-comparison.cc (class corpus_diff::diff_stats::priv): New type. (diff_context::priv::show_added_syms_unreferenced_by_di_): New data member. (diff_context::priv::priv): Adjust. (diff_context::show_added_symbols_unreferenced_by_debug_info): Define this new method. (corpus_diff::priv::emit_diff_stats): Do not show the diff stat if the only changes is added function or variables symbols and if we were instructed to not show added symbols. (corpus_diff::priv::{diff_stats_, filters_and_suppr_applied_}): New data members. (corpus_diff::priv::priv): Initialize the filters_and_suppr_applied_ data member. (corpus_diff::priv::diff_stats): Move this type to corpus_diff::diff_stats. (corpus_diff::priv::{apply_filters_and_compute_diff_stats, emit_diff_stats}): Adjust. (corpus_diff::apply_filters_and_suppressions_before_reporting): Define new member function. (corpus_diff::report): Use the new apply_filters_and_suppressions_before_reporting() function, rather than applying the filters and suppressions by ourselves. Also adjust to the use the accessors of the new corpus_diff::diff_stats type. (corpus_diff::{deleted_variables, deleted_unrefed_function_symbols, deleted_unrefed_variable_symbols}): Define new accessors. (corpus_diff::diff_stats::{diff_stats, num_func_removed, num_func_added, num_func_changed, num_func_filtered_out, net_num_func_changed, num_vars_removed, num_vars_added, num_vars_changed, num_vars_filtered_out, net_num_vars_changed, num_func_sym_removed, num_func_syms_added, num_var_syms_removed, num_var_syms_added}): Define new member functions. * include/abg-corpus.h (corpus::{get_sym_ids_of_fns_to_keep, get_sym_ids_of_vars_to_keep}): Declare new methods. * src/abg-corpus.cc (corpus::priv::{sym_id_fns_to_keep, sym_id_vars_to_keep}): Added data members. (symtab_build_visitor_type::{unrefed_fun_symbols, unrefed_var_symbols, sym_id_fns_to_keep, sym_id_vars_to_keep}): Added new data members. (symtab_build_visitor_type::symtab_build_visitor_type): Take two additional parameters for the function and variable symbol ids to keep. (symtab_build_visitor_type::add_fn_to_wip_fns): Take the function symbols to keep in account when building the exported symbol table. (symtab_build_visitor_type::add_var_to_wip_vars): Likewise, take the variable symbols to keep in account when building the exported symbol table. (corpus::priv::build_public_decl_table): Adjust the initialization of the visitor that walks the ABI artifacts to build the exported symbol table to know take a list of function/variable symbols to keep. (corpus::priv::build_unreferenced_symbols_tables): Ensure that the public table of functions/variables is built before doing the work of this function. Also, if a list of variable/function symbols to keep is given, drop all symbols that are not in that list on the floor. (corpus::{get_sym_ids_of_fns_to_keep, get_sym_ids_of_vars_to_keep}): Define new accessors. * tools/abicompat.cc: New abicompat tool. * doc/manuals/abicompat.rst: New documentation source for abicompat. * doc/manuals/libabigail-tools.rst: Add an entry for the abicompat doc. * tests/test-abicompat.cc: New test harness for the 'abicompat' tool. * tests/Makefile.am: Build the runtestabicompat test harness and add it to the list of tests harnesses that are run by make check. * tests/data/test-abicompat/libtest0-fn-changed-libapp-v0.so: New test input. * tests/data/test-abicompat/libtest0-fn-changed-libapp-v1.so: Likewise. * tests/data/test-abicompat/test0-fn-changed-app: Likewise. * tests/data/test-abicompat/test0-fn-changed-0.suppr: Likewise * tests/data/test-abicompat/test0-fn-changed-report-0.txt: Likewise. * tests/data/test-abicompat/test0-fn-changed-report-1.txt: Likewise. * tests/data/test-abicompat/test0-fn-changed-app.cc: Likewise. * tests/data/test-abicompat/test0-fn-changed-libapp.h: Likewise. * tests/data/test-abicompat/test0-fn-changed-libapp-v0.cc: Likewise. * tests/data/test-abicompat/test0-fn-changed-libapp-v1.cc: Likewise. * tests/data/test-abicompat/libtest1-fn-removed-v0.so: Likewise. * tests/data/test-abicompat/libtest1-fn-removed-v1.so: Likewise. * tests/data/test-abicompat/test1-fn-removed-app: Likewise. * tests/data/test-abicompat/test1-fn-removed-app.cc: Likewise. * tests/data/test-abicompat/test1-fn-removed-report-0.txt: Likewise. * tests/data/test-abicompat/test1-fn-removed-v0.cc: Likewise. * tests/data/test-abicompat/test1-fn-removed-v1.cc: Likewise. * tests/data/test-abicompat/libtest2-var-removed-v0.so: Likewise. * tests/data/test-abicompat/libtest2-var-removed-v1.so: Likewise. * tests/data/test-abicompat/test2-var-removed-app: Likewise. * tests/data/test-abicompat/test2-var-removed-app.cc: Likewise. * tests/data/test-abicompat/test2-var-removed-report-0.txt: Likewise. * tests/data/test-abicompat/test2-var-removed-v0.cc: Likewise. * tests/data/test-abicompat/test2-var-removed-v1.cc: Likewise. * tests/data/test-abicompat/libtest3-fn-removed-v0.so: Likewise. * tests/data/test-abicompat/libtest3-fn-removed-v1.so: Likewise. * tests/data/test-abicompat/test3-fn-removed-app: Likewise. * tests/data/test-abicompat/test3-fn-removed-app.cc: Likewise. * tests/data/test-abicompat/test3-fn-removed-report-0.txt: Likewise. * tests/data/test-abicompat/test3-fn-removed-v0.cc: Likewise. * tests/data/test-abicompat/test3-fn-removed-v1.cc: Likewise. * tests/data/test-abicompat/test3-fn-removed-version-script-0 Likewise.: * tests/data/test-abicompat/test3-fn-removed-version-script-1: Likewise. * tests/data/Makefile.am: Add the new test inputs above to the source distribution. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-11-30 17:18:55 +00:00
Invocation
==========
::
abicompat [options] [<application> <shared-library-first-version> <shared-library-second-version>]
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
.. _abicompat_options_label:
Initial implementation of the abicompat tool Given an application A that links to a shared library L of version V denoted L(V) and a subsequent version of that library denoted L(V+P), the 'abicompat' tool tells the user if L(V+P) is still ABI compatible with L(V+P). And if it is not, abicompat gives a reports that shows the differences between L(V) and L(V+P) that makes L(V+P) ABI-incompatible with A. The source code of this tool is in the tools/abicompat.cc source file. To support this new tool, this commit changes the comparison engine to optionally avoid showing added symbols that were not referenced by any debug info. It changes the ABI corpus type to allow the specification of a list of variables and functions symbols to keep (and drop all other functions and variables which have other symbols on the floor even before starting to compare the two libraries). This is how the abicompat tool itself works. It basically compares L(V) and L(V+P) but it only looks at their exported functions and variables which symbols are undefined in application A. If the list of exported and defined variables and functions of L(V) whose symbols are undefined in A equals that of L(V+P) (including the sub-types of these variables and functions) A is still compatible with L(V+P). Otherwise, they might not be compatible depending on the kind of differences that are found. * include/abg-comparison.h (diff_context::show_added_symbols_unreferenced_by_debug_info): Declare new accessors. (corpus_diff::{deleted_variables, deleted_unrefed_function_symbols, deleted_unrefed_variable_symbols, apply_filters_and_suppressions_before_reporting}): Declare new methods. (corpus_diff::diff_stats): Declare this new type. Actually this was previously corpus_diff::priv::diff_stats, which was a hidden internal type.. We are moving it here, in the external API so that client code can have more information about changes statistics. Change all the previously publicly accessible data members into accessor functions. * src/abg-comparison.cc (class corpus_diff::diff_stats::priv): New type. (diff_context::priv::show_added_syms_unreferenced_by_di_): New data member. (diff_context::priv::priv): Adjust. (diff_context::show_added_symbols_unreferenced_by_debug_info): Define this new method. (corpus_diff::priv::emit_diff_stats): Do not show the diff stat if the only changes is added function or variables symbols and if we were instructed to not show added symbols. (corpus_diff::priv::{diff_stats_, filters_and_suppr_applied_}): New data members. (corpus_diff::priv::priv): Initialize the filters_and_suppr_applied_ data member. (corpus_diff::priv::diff_stats): Move this type to corpus_diff::diff_stats. (corpus_diff::priv::{apply_filters_and_compute_diff_stats, emit_diff_stats}): Adjust. (corpus_diff::apply_filters_and_suppressions_before_reporting): Define new member function. (corpus_diff::report): Use the new apply_filters_and_suppressions_before_reporting() function, rather than applying the filters and suppressions by ourselves. Also adjust to the use the accessors of the new corpus_diff::diff_stats type. (corpus_diff::{deleted_variables, deleted_unrefed_function_symbols, deleted_unrefed_variable_symbols}): Define new accessors. (corpus_diff::diff_stats::{diff_stats, num_func_removed, num_func_added, num_func_changed, num_func_filtered_out, net_num_func_changed, num_vars_removed, num_vars_added, num_vars_changed, num_vars_filtered_out, net_num_vars_changed, num_func_sym_removed, num_func_syms_added, num_var_syms_removed, num_var_syms_added}): Define new member functions. * include/abg-corpus.h (corpus::{get_sym_ids_of_fns_to_keep, get_sym_ids_of_vars_to_keep}): Declare new methods. * src/abg-corpus.cc (corpus::priv::{sym_id_fns_to_keep, sym_id_vars_to_keep}): Added data members. (symtab_build_visitor_type::{unrefed_fun_symbols, unrefed_var_symbols, sym_id_fns_to_keep, sym_id_vars_to_keep}): Added new data members. (symtab_build_visitor_type::symtab_build_visitor_type): Take two additional parameters for the function and variable symbol ids to keep. (symtab_build_visitor_type::add_fn_to_wip_fns): Take the function symbols to keep in account when building the exported symbol table. (symtab_build_visitor_type::add_var_to_wip_vars): Likewise, take the variable symbols to keep in account when building the exported symbol table. (corpus::priv::build_public_decl_table): Adjust the initialization of the visitor that walks the ABI artifacts to build the exported symbol table to know take a list of function/variable symbols to keep. (corpus::priv::build_unreferenced_symbols_tables): Ensure that the public table of functions/variables is built before doing the work of this function. Also, if a list of variable/function symbols to keep is given, drop all symbols that are not in that list on the floor. (corpus::{get_sym_ids_of_fns_to_keep, get_sym_ids_of_vars_to_keep}): Define new accessors. * tools/abicompat.cc: New abicompat tool. * doc/manuals/abicompat.rst: New documentation source for abicompat. * doc/manuals/libabigail-tools.rst: Add an entry for the abicompat doc. * tests/test-abicompat.cc: New test harness for the 'abicompat' tool. * tests/Makefile.am: Build the runtestabicompat test harness and add it to the list of tests harnesses that are run by make check. * tests/data/test-abicompat/libtest0-fn-changed-libapp-v0.so: New test input. * tests/data/test-abicompat/libtest0-fn-changed-libapp-v1.so: Likewise. * tests/data/test-abicompat/test0-fn-changed-app: Likewise. * tests/data/test-abicompat/test0-fn-changed-0.suppr: Likewise * tests/data/test-abicompat/test0-fn-changed-report-0.txt: Likewise. * tests/data/test-abicompat/test0-fn-changed-report-1.txt: Likewise. * tests/data/test-abicompat/test0-fn-changed-app.cc: Likewise. * tests/data/test-abicompat/test0-fn-changed-libapp.h: Likewise. * tests/data/test-abicompat/test0-fn-changed-libapp-v0.cc: Likewise. * tests/data/test-abicompat/test0-fn-changed-libapp-v1.cc: Likewise. * tests/data/test-abicompat/libtest1-fn-removed-v0.so: Likewise. * tests/data/test-abicompat/libtest1-fn-removed-v1.so: Likewise. * tests/data/test-abicompat/test1-fn-removed-app: Likewise. * tests/data/test-abicompat/test1-fn-removed-app.cc: Likewise. * tests/data/test-abicompat/test1-fn-removed-report-0.txt: Likewise. * tests/data/test-abicompat/test1-fn-removed-v0.cc: Likewise. * tests/data/test-abicompat/test1-fn-removed-v1.cc: Likewise. * tests/data/test-abicompat/libtest2-var-removed-v0.so: Likewise. * tests/data/test-abicompat/libtest2-var-removed-v1.so: Likewise. * tests/data/test-abicompat/test2-var-removed-app: Likewise. * tests/data/test-abicompat/test2-var-removed-app.cc: Likewise. * tests/data/test-abicompat/test2-var-removed-report-0.txt: Likewise. * tests/data/test-abicompat/test2-var-removed-v0.cc: Likewise. * tests/data/test-abicompat/test2-var-removed-v1.cc: Likewise. * tests/data/test-abicompat/libtest3-fn-removed-v0.so: Likewise. * tests/data/test-abicompat/libtest3-fn-removed-v1.so: Likewise. * tests/data/test-abicompat/test3-fn-removed-app: Likewise. * tests/data/test-abicompat/test3-fn-removed-app.cc: Likewise. * tests/data/test-abicompat/test3-fn-removed-report-0.txt: Likewise. * tests/data/test-abicompat/test3-fn-removed-v0.cc: Likewise. * tests/data/test-abicompat/test3-fn-removed-v1.cc: Likewise. * tests/data/test-abicompat/test3-fn-removed-version-script-0 Likewise.: * tests/data/test-abicompat/test3-fn-removed-version-script-1: Likewise. * tests/data/Makefile.am: Add the new test inputs above to the source distribution. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-11-30 17:18:55 +00:00
Options
=======
* ``--help``
Initial implementation of the abicompat tool Given an application A that links to a shared library L of version V denoted L(V) and a subsequent version of that library denoted L(V+P), the 'abicompat' tool tells the user if L(V+P) is still ABI compatible with L(V+P). And if it is not, abicompat gives a reports that shows the differences between L(V) and L(V+P) that makes L(V+P) ABI-incompatible with A. The source code of this tool is in the tools/abicompat.cc source file. To support this new tool, this commit changes the comparison engine to optionally avoid showing added symbols that were not referenced by any debug info. It changes the ABI corpus type to allow the specification of a list of variables and functions symbols to keep (and drop all other functions and variables which have other symbols on the floor even before starting to compare the two libraries). This is how the abicompat tool itself works. It basically compares L(V) and L(V+P) but it only looks at their exported functions and variables which symbols are undefined in application A. If the list of exported and defined variables and functions of L(V) whose symbols are undefined in A equals that of L(V+P) (including the sub-types of these variables and functions) A is still compatible with L(V+P). Otherwise, they might not be compatible depending on the kind of differences that are found. * include/abg-comparison.h (diff_context::show_added_symbols_unreferenced_by_debug_info): Declare new accessors. (corpus_diff::{deleted_variables, deleted_unrefed_function_symbols, deleted_unrefed_variable_symbols, apply_filters_and_suppressions_before_reporting}): Declare new methods. (corpus_diff::diff_stats): Declare this new type. Actually this was previously corpus_diff::priv::diff_stats, which was a hidden internal type.. We are moving it here, in the external API so that client code can have more information about changes statistics. Change all the previously publicly accessible data members into accessor functions. * src/abg-comparison.cc (class corpus_diff::diff_stats::priv): New type. (diff_context::priv::show_added_syms_unreferenced_by_di_): New data member. (diff_context::priv::priv): Adjust. (diff_context::show_added_symbols_unreferenced_by_debug_info): Define this new method. (corpus_diff::priv::emit_diff_stats): Do not show the diff stat if the only changes is added function or variables symbols and if we were instructed to not show added symbols. (corpus_diff::priv::{diff_stats_, filters_and_suppr_applied_}): New data members. (corpus_diff::priv::priv): Initialize the filters_and_suppr_applied_ data member. (corpus_diff::priv::diff_stats): Move this type to corpus_diff::diff_stats. (corpus_diff::priv::{apply_filters_and_compute_diff_stats, emit_diff_stats}): Adjust. (corpus_diff::apply_filters_and_suppressions_before_reporting): Define new member function. (corpus_diff::report): Use the new apply_filters_and_suppressions_before_reporting() function, rather than applying the filters and suppressions by ourselves. Also adjust to the use the accessors of the new corpus_diff::diff_stats type. (corpus_diff::{deleted_variables, deleted_unrefed_function_symbols, deleted_unrefed_variable_symbols}): Define new accessors. (corpus_diff::diff_stats::{diff_stats, num_func_removed, num_func_added, num_func_changed, num_func_filtered_out, net_num_func_changed, num_vars_removed, num_vars_added, num_vars_changed, num_vars_filtered_out, net_num_vars_changed, num_func_sym_removed, num_func_syms_added, num_var_syms_removed, num_var_syms_added}): Define new member functions. * include/abg-corpus.h (corpus::{get_sym_ids_of_fns_to_keep, get_sym_ids_of_vars_to_keep}): Declare new methods. * src/abg-corpus.cc (corpus::priv::{sym_id_fns_to_keep, sym_id_vars_to_keep}): Added data members. (symtab_build_visitor_type::{unrefed_fun_symbols, unrefed_var_symbols, sym_id_fns_to_keep, sym_id_vars_to_keep}): Added new data members. (symtab_build_visitor_type::symtab_build_visitor_type): Take two additional parameters for the function and variable symbol ids to keep. (symtab_build_visitor_type::add_fn_to_wip_fns): Take the function symbols to keep in account when building the exported symbol table. (symtab_build_visitor_type::add_var_to_wip_vars): Likewise, take the variable symbols to keep in account when building the exported symbol table. (corpus::priv::build_public_decl_table): Adjust the initialization of the visitor that walks the ABI artifacts to build the exported symbol table to know take a list of function/variable symbols to keep. (corpus::priv::build_unreferenced_symbols_tables): Ensure that the public table of functions/variables is built before doing the work of this function. Also, if a list of variable/function symbols to keep is given, drop all symbols that are not in that list on the floor. (corpus::{get_sym_ids_of_fns_to_keep, get_sym_ids_of_vars_to_keep}): Define new accessors. * tools/abicompat.cc: New abicompat tool. * doc/manuals/abicompat.rst: New documentation source for abicompat. * doc/manuals/libabigail-tools.rst: Add an entry for the abicompat doc. * tests/test-abicompat.cc: New test harness for the 'abicompat' tool. * tests/Makefile.am: Build the runtestabicompat test harness and add it to the list of tests harnesses that are run by make check. * tests/data/test-abicompat/libtest0-fn-changed-libapp-v0.so: New test input. * tests/data/test-abicompat/libtest0-fn-changed-libapp-v1.so: Likewise. * tests/data/test-abicompat/test0-fn-changed-app: Likewise. * tests/data/test-abicompat/test0-fn-changed-0.suppr: Likewise * tests/data/test-abicompat/test0-fn-changed-report-0.txt: Likewise. * tests/data/test-abicompat/test0-fn-changed-report-1.txt: Likewise. * tests/data/test-abicompat/test0-fn-changed-app.cc: Likewise. * tests/data/test-abicompat/test0-fn-changed-libapp.h: Likewise. * tests/data/test-abicompat/test0-fn-changed-libapp-v0.cc: Likewise. * tests/data/test-abicompat/test0-fn-changed-libapp-v1.cc: Likewise. * tests/data/test-abicompat/libtest1-fn-removed-v0.so: Likewise. * tests/data/test-abicompat/libtest1-fn-removed-v1.so: Likewise. * tests/data/test-abicompat/test1-fn-removed-app: Likewise. * tests/data/test-abicompat/test1-fn-removed-app.cc: Likewise. * tests/data/test-abicompat/test1-fn-removed-report-0.txt: Likewise. * tests/data/test-abicompat/test1-fn-removed-v0.cc: Likewise. * tests/data/test-abicompat/test1-fn-removed-v1.cc: Likewise. * tests/data/test-abicompat/libtest2-var-removed-v0.so: Likewise. * tests/data/test-abicompat/libtest2-var-removed-v1.so: Likewise. * tests/data/test-abicompat/test2-var-removed-app: Likewise. * tests/data/test-abicompat/test2-var-removed-app.cc: Likewise. * tests/data/test-abicompat/test2-var-removed-report-0.txt: Likewise. * tests/data/test-abicompat/test2-var-removed-v0.cc: Likewise. * tests/data/test-abicompat/test2-var-removed-v1.cc: Likewise. * tests/data/test-abicompat/libtest3-fn-removed-v0.so: Likewise. * tests/data/test-abicompat/libtest3-fn-removed-v1.so: Likewise. * tests/data/test-abicompat/test3-fn-removed-app: Likewise. * tests/data/test-abicompat/test3-fn-removed-app.cc: Likewise. * tests/data/test-abicompat/test3-fn-removed-report-0.txt: Likewise. * tests/data/test-abicompat/test3-fn-removed-v0.cc: Likewise. * tests/data/test-abicompat/test3-fn-removed-v1.cc: Likewise. * tests/data/test-abicompat/test3-fn-removed-version-script-0 Likewise.: * tests/data/test-abicompat/test3-fn-removed-version-script-1: Likewise. * tests/data/Makefile.am: Add the new test inputs above to the source distribution. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-11-30 17:18:55 +00:00
Display a short help about the command and exit.
Initial implementation of the abicompat tool Given an application A that links to a shared library L of version V denoted L(V) and a subsequent version of that library denoted L(V+P), the 'abicompat' tool tells the user if L(V+P) is still ABI compatible with L(V+P). And if it is not, abicompat gives a reports that shows the differences between L(V) and L(V+P) that makes L(V+P) ABI-incompatible with A. The source code of this tool is in the tools/abicompat.cc source file. To support this new tool, this commit changes the comparison engine to optionally avoid showing added symbols that were not referenced by any debug info. It changes the ABI corpus type to allow the specification of a list of variables and functions symbols to keep (and drop all other functions and variables which have other symbols on the floor even before starting to compare the two libraries). This is how the abicompat tool itself works. It basically compares L(V) and L(V+P) but it only looks at their exported functions and variables which symbols are undefined in application A. If the list of exported and defined variables and functions of L(V) whose symbols are undefined in A equals that of L(V+P) (including the sub-types of these variables and functions) A is still compatible with L(V+P). Otherwise, they might not be compatible depending on the kind of differences that are found. * include/abg-comparison.h (diff_context::show_added_symbols_unreferenced_by_debug_info): Declare new accessors. (corpus_diff::{deleted_variables, deleted_unrefed_function_symbols, deleted_unrefed_variable_symbols, apply_filters_and_suppressions_before_reporting}): Declare new methods. (corpus_diff::diff_stats): Declare this new type. Actually this was previously corpus_diff::priv::diff_stats, which was a hidden internal type.. We are moving it here, in the external API so that client code can have more information about changes statistics. Change all the previously publicly accessible data members into accessor functions. * src/abg-comparison.cc (class corpus_diff::diff_stats::priv): New type. (diff_context::priv::show_added_syms_unreferenced_by_di_): New data member. (diff_context::priv::priv): Adjust. (diff_context::show_added_symbols_unreferenced_by_debug_info): Define this new method. (corpus_diff::priv::emit_diff_stats): Do not show the diff stat if the only changes is added function or variables symbols and if we were instructed to not show added symbols. (corpus_diff::priv::{diff_stats_, filters_and_suppr_applied_}): New data members. (corpus_diff::priv::priv): Initialize the filters_and_suppr_applied_ data member. (corpus_diff::priv::diff_stats): Move this type to corpus_diff::diff_stats. (corpus_diff::priv::{apply_filters_and_compute_diff_stats, emit_diff_stats}): Adjust. (corpus_diff::apply_filters_and_suppressions_before_reporting): Define new member function. (corpus_diff::report): Use the new apply_filters_and_suppressions_before_reporting() function, rather than applying the filters and suppressions by ourselves. Also adjust to the use the accessors of the new corpus_diff::diff_stats type. (corpus_diff::{deleted_variables, deleted_unrefed_function_symbols, deleted_unrefed_variable_symbols}): Define new accessors. (corpus_diff::diff_stats::{diff_stats, num_func_removed, num_func_added, num_func_changed, num_func_filtered_out, net_num_func_changed, num_vars_removed, num_vars_added, num_vars_changed, num_vars_filtered_out, net_num_vars_changed, num_func_sym_removed, num_func_syms_added, num_var_syms_removed, num_var_syms_added}): Define new member functions. * include/abg-corpus.h (corpus::{get_sym_ids_of_fns_to_keep, get_sym_ids_of_vars_to_keep}): Declare new methods. * src/abg-corpus.cc (corpus::priv::{sym_id_fns_to_keep, sym_id_vars_to_keep}): Added data members. (symtab_build_visitor_type::{unrefed_fun_symbols, unrefed_var_symbols, sym_id_fns_to_keep, sym_id_vars_to_keep}): Added new data members. (symtab_build_visitor_type::symtab_build_visitor_type): Take two additional parameters for the function and variable symbol ids to keep. (symtab_build_visitor_type::add_fn_to_wip_fns): Take the function symbols to keep in account when building the exported symbol table. (symtab_build_visitor_type::add_var_to_wip_vars): Likewise, take the variable symbols to keep in account when building the exported symbol table. (corpus::priv::build_public_decl_table): Adjust the initialization of the visitor that walks the ABI artifacts to build the exported symbol table to know take a list of function/variable symbols to keep. (corpus::priv::build_unreferenced_symbols_tables): Ensure that the public table of functions/variables is built before doing the work of this function. Also, if a list of variable/function symbols to keep is given, drop all symbols that are not in that list on the floor. (corpus::{get_sym_ids_of_fns_to_keep, get_sym_ids_of_vars_to_keep}): Define new accessors. * tools/abicompat.cc: New abicompat tool. * doc/manuals/abicompat.rst: New documentation source for abicompat. * doc/manuals/libabigail-tools.rst: Add an entry for the abicompat doc. * tests/test-abicompat.cc: New test harness for the 'abicompat' tool. * tests/Makefile.am: Build the runtestabicompat test harness and add it to the list of tests harnesses that are run by make check. * tests/data/test-abicompat/libtest0-fn-changed-libapp-v0.so: New test input. * tests/data/test-abicompat/libtest0-fn-changed-libapp-v1.so: Likewise. * tests/data/test-abicompat/test0-fn-changed-app: Likewise. * tests/data/test-abicompat/test0-fn-changed-0.suppr: Likewise * tests/data/test-abicompat/test0-fn-changed-report-0.txt: Likewise. * tests/data/test-abicompat/test0-fn-changed-report-1.txt: Likewise. * tests/data/test-abicompat/test0-fn-changed-app.cc: Likewise. * tests/data/test-abicompat/test0-fn-changed-libapp.h: Likewise. * tests/data/test-abicompat/test0-fn-changed-libapp-v0.cc: Likewise. * tests/data/test-abicompat/test0-fn-changed-libapp-v1.cc: Likewise. * tests/data/test-abicompat/libtest1-fn-removed-v0.so: Likewise. * tests/data/test-abicompat/libtest1-fn-removed-v1.so: Likewise. * tests/data/test-abicompat/test1-fn-removed-app: Likewise. * tests/data/test-abicompat/test1-fn-removed-app.cc: Likewise. * tests/data/test-abicompat/test1-fn-removed-report-0.txt: Likewise. * tests/data/test-abicompat/test1-fn-removed-v0.cc: Likewise. * tests/data/test-abicompat/test1-fn-removed-v1.cc: Likewise. * tests/data/test-abicompat/libtest2-var-removed-v0.so: Likewise. * tests/data/test-abicompat/libtest2-var-removed-v1.so: Likewise. * tests/data/test-abicompat/test2-var-removed-app: Likewise. * tests/data/test-abicompat/test2-var-removed-app.cc: Likewise. * tests/data/test-abicompat/test2-var-removed-report-0.txt: Likewise. * tests/data/test-abicompat/test2-var-removed-v0.cc: Likewise. * tests/data/test-abicompat/test2-var-removed-v1.cc: Likewise. * tests/data/test-abicompat/libtest3-fn-removed-v0.so: Likewise. * tests/data/test-abicompat/libtest3-fn-removed-v1.so: Likewise. * tests/data/test-abicompat/test3-fn-removed-app: Likewise. * tests/data/test-abicompat/test3-fn-removed-app.cc: Likewise. * tests/data/test-abicompat/test3-fn-removed-report-0.txt: Likewise. * tests/data/test-abicompat/test3-fn-removed-v0.cc: Likewise. * tests/data/test-abicompat/test3-fn-removed-v1.cc: Likewise. * tests/data/test-abicompat/test3-fn-removed-version-script-0 Likewise.: * tests/data/test-abicompat/test3-fn-removed-version-script-1: Likewise. * tests/data/Makefile.am: Add the new test inputs above to the source distribution. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-11-30 17:18:55 +00:00
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.
* ``--list-undefined-symbols | -u``
Initial implementation of the abicompat tool Given an application A that links to a shared library L of version V denoted L(V) and a subsequent version of that library denoted L(V+P), the 'abicompat' tool tells the user if L(V+P) is still ABI compatible with L(V+P). And if it is not, abicompat gives a reports that shows the differences between L(V) and L(V+P) that makes L(V+P) ABI-incompatible with A. The source code of this tool is in the tools/abicompat.cc source file. To support this new tool, this commit changes the comparison engine to optionally avoid showing added symbols that were not referenced by any debug info. It changes the ABI corpus type to allow the specification of a list of variables and functions symbols to keep (and drop all other functions and variables which have other symbols on the floor even before starting to compare the two libraries). This is how the abicompat tool itself works. It basically compares L(V) and L(V+P) but it only looks at their exported functions and variables which symbols are undefined in application A. If the list of exported and defined variables and functions of L(V) whose symbols are undefined in A equals that of L(V+P) (including the sub-types of these variables and functions) A is still compatible with L(V+P). Otherwise, they might not be compatible depending on the kind of differences that are found. * include/abg-comparison.h (diff_context::show_added_symbols_unreferenced_by_debug_info): Declare new accessors. (corpus_diff::{deleted_variables, deleted_unrefed_function_symbols, deleted_unrefed_variable_symbols, apply_filters_and_suppressions_before_reporting}): Declare new methods. (corpus_diff::diff_stats): Declare this new type. Actually this was previously corpus_diff::priv::diff_stats, which was a hidden internal type.. We are moving it here, in the external API so that client code can have more information about changes statistics. Change all the previously publicly accessible data members into accessor functions. * src/abg-comparison.cc (class corpus_diff::diff_stats::priv): New type. (diff_context::priv::show_added_syms_unreferenced_by_di_): New data member. (diff_context::priv::priv): Adjust. (diff_context::show_added_symbols_unreferenced_by_debug_info): Define this new method. (corpus_diff::priv::emit_diff_stats): Do not show the diff stat if the only changes is added function or variables symbols and if we were instructed to not show added symbols. (corpus_diff::priv::{diff_stats_, filters_and_suppr_applied_}): New data members. (corpus_diff::priv::priv): Initialize the filters_and_suppr_applied_ data member. (corpus_diff::priv::diff_stats): Move this type to corpus_diff::diff_stats. (corpus_diff::priv::{apply_filters_and_compute_diff_stats, emit_diff_stats}): Adjust. (corpus_diff::apply_filters_and_suppressions_before_reporting): Define new member function. (corpus_diff::report): Use the new apply_filters_and_suppressions_before_reporting() function, rather than applying the filters and suppressions by ourselves. Also adjust to the use the accessors of the new corpus_diff::diff_stats type. (corpus_diff::{deleted_variables, deleted_unrefed_function_symbols, deleted_unrefed_variable_symbols}): Define new accessors. (corpus_diff::diff_stats::{diff_stats, num_func_removed, num_func_added, num_func_changed, num_func_filtered_out, net_num_func_changed, num_vars_removed, num_vars_added, num_vars_changed, num_vars_filtered_out, net_num_vars_changed, num_func_sym_removed, num_func_syms_added, num_var_syms_removed, num_var_syms_added}): Define new member functions. * include/abg-corpus.h (corpus::{get_sym_ids_of_fns_to_keep, get_sym_ids_of_vars_to_keep}): Declare new methods. * src/abg-corpus.cc (corpus::priv::{sym_id_fns_to_keep, sym_id_vars_to_keep}): Added data members. (symtab_build_visitor_type::{unrefed_fun_symbols, unrefed_var_symbols, sym_id_fns_to_keep, sym_id_vars_to_keep}): Added new data members. (symtab_build_visitor_type::symtab_build_visitor_type): Take two additional parameters for the function and variable symbol ids to keep. (symtab_build_visitor_type::add_fn_to_wip_fns): Take the function symbols to keep in account when building the exported symbol table. (symtab_build_visitor_type::add_var_to_wip_vars): Likewise, take the variable symbols to keep in account when building the exported symbol table. (corpus::priv::build_public_decl_table): Adjust the initialization of the visitor that walks the ABI artifacts to build the exported symbol table to know take a list of function/variable symbols to keep. (corpus::priv::build_unreferenced_symbols_tables): Ensure that the public table of functions/variables is built before doing the work of this function. Also, if a list of variable/function symbols to keep is given, drop all symbols that are not in that list on the floor. (corpus::{get_sym_ids_of_fns_to_keep, get_sym_ids_of_vars_to_keep}): Define new accessors. * tools/abicompat.cc: New abicompat tool. * doc/manuals/abicompat.rst: New documentation source for abicompat. * doc/manuals/libabigail-tools.rst: Add an entry for the abicompat doc. * tests/test-abicompat.cc: New test harness for the 'abicompat' tool. * tests/Makefile.am: Build the runtestabicompat test harness and add it to the list of tests harnesses that are run by make check. * tests/data/test-abicompat/libtest0-fn-changed-libapp-v0.so: New test input. * tests/data/test-abicompat/libtest0-fn-changed-libapp-v1.so: Likewise. * tests/data/test-abicompat/test0-fn-changed-app: Likewise. * tests/data/test-abicompat/test0-fn-changed-0.suppr: Likewise * tests/data/test-abicompat/test0-fn-changed-report-0.txt: Likewise. * tests/data/test-abicompat/test0-fn-changed-report-1.txt: Likewise. * tests/data/test-abicompat/test0-fn-changed-app.cc: Likewise. * tests/data/test-abicompat/test0-fn-changed-libapp.h: Likewise. * tests/data/test-abicompat/test0-fn-changed-libapp-v0.cc: Likewise. * tests/data/test-abicompat/test0-fn-changed-libapp-v1.cc: Likewise. * tests/data/test-abicompat/libtest1-fn-removed-v0.so: Likewise. * tests/data/test-abicompat/libtest1-fn-removed-v1.so: Likewise. * tests/data/test-abicompat/test1-fn-removed-app: Likewise. * tests/data/test-abicompat/test1-fn-removed-app.cc: Likewise. * tests/data/test-abicompat/test1-fn-removed-report-0.txt: Likewise. * tests/data/test-abicompat/test1-fn-removed-v0.cc: Likewise. * tests/data/test-abicompat/test1-fn-removed-v1.cc: Likewise. * tests/data/test-abicompat/libtest2-var-removed-v0.so: Likewise. * tests/data/test-abicompat/libtest2-var-removed-v1.so: Likewise. * tests/data/test-abicompat/test2-var-removed-app: Likewise. * tests/data/test-abicompat/test2-var-removed-app.cc: Likewise. * tests/data/test-abicompat/test2-var-removed-report-0.txt: Likewise. * tests/data/test-abicompat/test2-var-removed-v0.cc: Likewise. * tests/data/test-abicompat/test2-var-removed-v1.cc: Likewise. * tests/data/test-abicompat/libtest3-fn-removed-v0.so: Likewise. * tests/data/test-abicompat/libtest3-fn-removed-v1.so: Likewise. * tests/data/test-abicompat/test3-fn-removed-app: Likewise. * tests/data/test-abicompat/test3-fn-removed-app.cc: Likewise. * tests/data/test-abicompat/test3-fn-removed-report-0.txt: Likewise. * tests/data/test-abicompat/test3-fn-removed-v0.cc: Likewise. * tests/data/test-abicompat/test3-fn-removed-v1.cc: Likewise. * tests/data/test-abicompat/test3-fn-removed-version-script-0 Likewise.: * tests/data/test-abicompat/test3-fn-removed-version-script-1: Likewise. * tests/data/Makefile.am: Add the new test inputs above to the source distribution. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-11-30 17:18:55 +00:00
Display the list of undefined symbols of the application and exit.
* ``--show-base-names | -b``
Initial implementation of the abicompat tool Given an application A that links to a shared library L of version V denoted L(V) and a subsequent version of that library denoted L(V+P), the 'abicompat' tool tells the user if L(V+P) is still ABI compatible with L(V+P). And if it is not, abicompat gives a reports that shows the differences between L(V) and L(V+P) that makes L(V+P) ABI-incompatible with A. The source code of this tool is in the tools/abicompat.cc source file. To support this new tool, this commit changes the comparison engine to optionally avoid showing added symbols that were not referenced by any debug info. It changes the ABI corpus type to allow the specification of a list of variables and functions symbols to keep (and drop all other functions and variables which have other symbols on the floor even before starting to compare the two libraries). This is how the abicompat tool itself works. It basically compares L(V) and L(V+P) but it only looks at their exported functions and variables which symbols are undefined in application A. If the list of exported and defined variables and functions of L(V) whose symbols are undefined in A equals that of L(V+P) (including the sub-types of these variables and functions) A is still compatible with L(V+P). Otherwise, they might not be compatible depending on the kind of differences that are found. * include/abg-comparison.h (diff_context::show_added_symbols_unreferenced_by_debug_info): Declare new accessors. (corpus_diff::{deleted_variables, deleted_unrefed_function_symbols, deleted_unrefed_variable_symbols, apply_filters_and_suppressions_before_reporting}): Declare new methods. (corpus_diff::diff_stats): Declare this new type. Actually this was previously corpus_diff::priv::diff_stats, which was a hidden internal type.. We are moving it here, in the external API so that client code can have more information about changes statistics. Change all the previously publicly accessible data members into accessor functions. * src/abg-comparison.cc (class corpus_diff::diff_stats::priv): New type. (diff_context::priv::show_added_syms_unreferenced_by_di_): New data member. (diff_context::priv::priv): Adjust. (diff_context::show_added_symbols_unreferenced_by_debug_info): Define this new method. (corpus_diff::priv::emit_diff_stats): Do not show the diff stat if the only changes is added function or variables symbols and if we were instructed to not show added symbols. (corpus_diff::priv::{diff_stats_, filters_and_suppr_applied_}): New data members. (corpus_diff::priv::priv): Initialize the filters_and_suppr_applied_ data member. (corpus_diff::priv::diff_stats): Move this type to corpus_diff::diff_stats. (corpus_diff::priv::{apply_filters_and_compute_diff_stats, emit_diff_stats}): Adjust. (corpus_diff::apply_filters_and_suppressions_before_reporting): Define new member function. (corpus_diff::report): Use the new apply_filters_and_suppressions_before_reporting() function, rather than applying the filters and suppressions by ourselves. Also adjust to the use the accessors of the new corpus_diff::diff_stats type. (corpus_diff::{deleted_variables, deleted_unrefed_function_symbols, deleted_unrefed_variable_symbols}): Define new accessors. (corpus_diff::diff_stats::{diff_stats, num_func_removed, num_func_added, num_func_changed, num_func_filtered_out, net_num_func_changed, num_vars_removed, num_vars_added, num_vars_changed, num_vars_filtered_out, net_num_vars_changed, num_func_sym_removed, num_func_syms_added, num_var_syms_removed, num_var_syms_added}): Define new member functions. * include/abg-corpus.h (corpus::{get_sym_ids_of_fns_to_keep, get_sym_ids_of_vars_to_keep}): Declare new methods. * src/abg-corpus.cc (corpus::priv::{sym_id_fns_to_keep, sym_id_vars_to_keep}): Added data members. (symtab_build_visitor_type::{unrefed_fun_symbols, unrefed_var_symbols, sym_id_fns_to_keep, sym_id_vars_to_keep}): Added new data members. (symtab_build_visitor_type::symtab_build_visitor_type): Take two additional parameters for the function and variable symbol ids to keep. (symtab_build_visitor_type::add_fn_to_wip_fns): Take the function symbols to keep in account when building the exported symbol table. (symtab_build_visitor_type::add_var_to_wip_vars): Likewise, take the variable symbols to keep in account when building the exported symbol table. (corpus::priv::build_public_decl_table): Adjust the initialization of the visitor that walks the ABI artifacts to build the exported symbol table to know take a list of function/variable symbols to keep. (corpus::priv::build_unreferenced_symbols_tables): Ensure that the public table of functions/variables is built before doing the work of this function. Also, if a list of variable/function symbols to keep is given, drop all symbols that are not in that list on the floor. (corpus::{get_sym_ids_of_fns_to_keep, get_sym_ids_of_vars_to_keep}): Define new accessors. * tools/abicompat.cc: New abicompat tool. * doc/manuals/abicompat.rst: New documentation source for abicompat. * doc/manuals/libabigail-tools.rst: Add an entry for the abicompat doc. * tests/test-abicompat.cc: New test harness for the 'abicompat' tool. * tests/Makefile.am: Build the runtestabicompat test harness and add it to the list of tests harnesses that are run by make check. * tests/data/test-abicompat/libtest0-fn-changed-libapp-v0.so: New test input. * tests/data/test-abicompat/libtest0-fn-changed-libapp-v1.so: Likewise. * tests/data/test-abicompat/test0-fn-changed-app: Likewise. * tests/data/test-abicompat/test0-fn-changed-0.suppr: Likewise * tests/data/test-abicompat/test0-fn-changed-report-0.txt: Likewise. * tests/data/test-abicompat/test0-fn-changed-report-1.txt: Likewise. * tests/data/test-abicompat/test0-fn-changed-app.cc: Likewise. * tests/data/test-abicompat/test0-fn-changed-libapp.h: Likewise. * tests/data/test-abicompat/test0-fn-changed-libapp-v0.cc: Likewise. * tests/data/test-abicompat/test0-fn-changed-libapp-v1.cc: Likewise. * tests/data/test-abicompat/libtest1-fn-removed-v0.so: Likewise. * tests/data/test-abicompat/libtest1-fn-removed-v1.so: Likewise. * tests/data/test-abicompat/test1-fn-removed-app: Likewise. * tests/data/test-abicompat/test1-fn-removed-app.cc: Likewise. * tests/data/test-abicompat/test1-fn-removed-report-0.txt: Likewise. * tests/data/test-abicompat/test1-fn-removed-v0.cc: Likewise. * tests/data/test-abicompat/test1-fn-removed-v1.cc: Likewise. * tests/data/test-abicompat/libtest2-var-removed-v0.so: Likewise. * tests/data/test-abicompat/libtest2-var-removed-v1.so: Likewise. * tests/data/test-abicompat/test2-var-removed-app: Likewise. * tests/data/test-abicompat/test2-var-removed-app.cc: Likewise. * tests/data/test-abicompat/test2-var-removed-report-0.txt: Likewise. * tests/data/test-abicompat/test2-var-removed-v0.cc: Likewise. * tests/data/test-abicompat/test2-var-removed-v1.cc: Likewise. * tests/data/test-abicompat/libtest3-fn-removed-v0.so: Likewise. * tests/data/test-abicompat/libtest3-fn-removed-v1.so: Likewise. * tests/data/test-abicompat/test3-fn-removed-app: Likewise. * tests/data/test-abicompat/test3-fn-removed-app.cc: Likewise. * tests/data/test-abicompat/test3-fn-removed-report-0.txt: Likewise. * tests/data/test-abicompat/test3-fn-removed-v0.cc: Likewise. * tests/data/test-abicompat/test3-fn-removed-v1.cc: Likewise. * tests/data/test-abicompat/test3-fn-removed-version-script-0 Likewise.: * tests/data/test-abicompat/test3-fn-removed-version-script-1: Likewise. * tests/data/Makefile.am: Add the new test inputs above to the source distribution. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-11-30 17:18:55 +00:00
In the resulting report emitted by the tool, this option makes the
application and libraries be referred to by their base names only;
not by a full absolute name. This can be useful for use in
scripts that wants to compare names of the application and
libraries independently of what their directory names are.
* ``--app-debug-info-dir`` <path-to-app-debug-info-directory>
Initial implementation of the abicompat tool Given an application A that links to a shared library L of version V denoted L(V) and a subsequent version of that library denoted L(V+P), the 'abicompat' tool tells the user if L(V+P) is still ABI compatible with L(V+P). And if it is not, abicompat gives a reports that shows the differences between L(V) and L(V+P) that makes L(V+P) ABI-incompatible with A. The source code of this tool is in the tools/abicompat.cc source file. To support this new tool, this commit changes the comparison engine to optionally avoid showing added symbols that were not referenced by any debug info. It changes the ABI corpus type to allow the specification of a list of variables and functions symbols to keep (and drop all other functions and variables which have other symbols on the floor even before starting to compare the two libraries). This is how the abicompat tool itself works. It basically compares L(V) and L(V+P) but it only looks at their exported functions and variables which symbols are undefined in application A. If the list of exported and defined variables and functions of L(V) whose symbols are undefined in A equals that of L(V+P) (including the sub-types of these variables and functions) A is still compatible with L(V+P). Otherwise, they might not be compatible depending on the kind of differences that are found. * include/abg-comparison.h (diff_context::show_added_symbols_unreferenced_by_debug_info): Declare new accessors. (corpus_diff::{deleted_variables, deleted_unrefed_function_symbols, deleted_unrefed_variable_symbols, apply_filters_and_suppressions_before_reporting}): Declare new methods. (corpus_diff::diff_stats): Declare this new type. Actually this was previously corpus_diff::priv::diff_stats, which was a hidden internal type.. We are moving it here, in the external API so that client code can have more information about changes statistics. Change all the previously publicly accessible data members into accessor functions. * src/abg-comparison.cc (class corpus_diff::diff_stats::priv): New type. (diff_context::priv::show_added_syms_unreferenced_by_di_): New data member. (diff_context::priv::priv): Adjust. (diff_context::show_added_symbols_unreferenced_by_debug_info): Define this new method. (corpus_diff::priv::emit_diff_stats): Do not show the diff stat if the only changes is added function or variables symbols and if we were instructed to not show added symbols. (corpus_diff::priv::{diff_stats_, filters_and_suppr_applied_}): New data members. (corpus_diff::priv::priv): Initialize the filters_and_suppr_applied_ data member. (corpus_diff::priv::diff_stats): Move this type to corpus_diff::diff_stats. (corpus_diff::priv::{apply_filters_and_compute_diff_stats, emit_diff_stats}): Adjust. (corpus_diff::apply_filters_and_suppressions_before_reporting): Define new member function. (corpus_diff::report): Use the new apply_filters_and_suppressions_before_reporting() function, rather than applying the filters and suppressions by ourselves. Also adjust to the use the accessors of the new corpus_diff::diff_stats type. (corpus_diff::{deleted_variables, deleted_unrefed_function_symbols, deleted_unrefed_variable_symbols}): Define new accessors. (corpus_diff::diff_stats::{diff_stats, num_func_removed, num_func_added, num_func_changed, num_func_filtered_out, net_num_func_changed, num_vars_removed, num_vars_added, num_vars_changed, num_vars_filtered_out, net_num_vars_changed, num_func_sym_removed, num_func_syms_added, num_var_syms_removed, num_var_syms_added}): Define new member functions. * include/abg-corpus.h (corpus::{get_sym_ids_of_fns_to_keep, get_sym_ids_of_vars_to_keep}): Declare new methods. * src/abg-corpus.cc (corpus::priv::{sym_id_fns_to_keep, sym_id_vars_to_keep}): Added data members. (symtab_build_visitor_type::{unrefed_fun_symbols, unrefed_var_symbols, sym_id_fns_to_keep, sym_id_vars_to_keep}): Added new data members. (symtab_build_visitor_type::symtab_build_visitor_type): Take two additional parameters for the function and variable symbol ids to keep. (symtab_build_visitor_type::add_fn_to_wip_fns): Take the function symbols to keep in account when building the exported symbol table. (symtab_build_visitor_type::add_var_to_wip_vars): Likewise, take the variable symbols to keep in account when building the exported symbol table. (corpus::priv::build_public_decl_table): Adjust the initialization of the visitor that walks the ABI artifacts to build the exported symbol table to know take a list of function/variable symbols to keep. (corpus::priv::build_unreferenced_symbols_tables): Ensure that the public table of functions/variables is built before doing the work of this function. Also, if a list of variable/function symbols to keep is given, drop all symbols that are not in that list on the floor. (corpus::{get_sym_ids_of_fns_to_keep, get_sym_ids_of_vars_to_keep}): Define new accessors. * tools/abicompat.cc: New abicompat tool. * doc/manuals/abicompat.rst: New documentation source for abicompat. * doc/manuals/libabigail-tools.rst: Add an entry for the abicompat doc. * tests/test-abicompat.cc: New test harness for the 'abicompat' tool. * tests/Makefile.am: Build the runtestabicompat test harness and add it to the list of tests harnesses that are run by make check. * tests/data/test-abicompat/libtest0-fn-changed-libapp-v0.so: New test input. * tests/data/test-abicompat/libtest0-fn-changed-libapp-v1.so: Likewise. * tests/data/test-abicompat/test0-fn-changed-app: Likewise. * tests/data/test-abicompat/test0-fn-changed-0.suppr: Likewise * tests/data/test-abicompat/test0-fn-changed-report-0.txt: Likewise. * tests/data/test-abicompat/test0-fn-changed-report-1.txt: Likewise. * tests/data/test-abicompat/test0-fn-changed-app.cc: Likewise. * tests/data/test-abicompat/test0-fn-changed-libapp.h: Likewise. * tests/data/test-abicompat/test0-fn-changed-libapp-v0.cc: Likewise. * tests/data/test-abicompat/test0-fn-changed-libapp-v1.cc: Likewise. * tests/data/test-abicompat/libtest1-fn-removed-v0.so: Likewise. * tests/data/test-abicompat/libtest1-fn-removed-v1.so: Likewise. * tests/data/test-abicompat/test1-fn-removed-app: Likewise. * tests/data/test-abicompat/test1-fn-removed-app.cc: Likewise. * tests/data/test-abicompat/test1-fn-removed-report-0.txt: Likewise. * tests/data/test-abicompat/test1-fn-removed-v0.cc: Likewise. * tests/data/test-abicompat/test1-fn-removed-v1.cc: Likewise. * tests/data/test-abicompat/libtest2-var-removed-v0.so: Likewise. * tests/data/test-abicompat/libtest2-var-removed-v1.so: Likewise. * tests/data/test-abicompat/test2-var-removed-app: Likewise. * tests/data/test-abicompat/test2-var-removed-app.cc: Likewise. * tests/data/test-abicompat/test2-var-removed-report-0.txt: Likewise. * tests/data/test-abicompat/test2-var-removed-v0.cc: Likewise. * tests/data/test-abicompat/test2-var-removed-v1.cc: Likewise. * tests/data/test-abicompat/libtest3-fn-removed-v0.so: Likewise. * tests/data/test-abicompat/libtest3-fn-removed-v1.so: Likewise. * tests/data/test-abicompat/test3-fn-removed-app: Likewise. * tests/data/test-abicompat/test3-fn-removed-app.cc: Likewise. * tests/data/test-abicompat/test3-fn-removed-report-0.txt: Likewise. * tests/data/test-abicompat/test3-fn-removed-v0.cc: Likewise. * tests/data/test-abicompat/test3-fn-removed-v1.cc: Likewise. * tests/data/test-abicompat/test3-fn-removed-version-script-0 Likewise.: * tests/data/test-abicompat/test3-fn-removed-version-script-1: Likewise. * tests/data/Makefile.am: Add the new test inputs above to the source distribution. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-11-30 17:18:55 +00:00
Set the path to the directory under which the debug information of
the application is supposed to be laid out. This is useful for
application binaries for which the debug info is in a separate set
of files.
* ``--lib-debug-info-dir1`` <path-to-lib1-debug-info>
Initial implementation of the abicompat tool Given an application A that links to a shared library L of version V denoted L(V) and a subsequent version of that library denoted L(V+P), the 'abicompat' tool tells the user if L(V+P) is still ABI compatible with L(V+P). And if it is not, abicompat gives a reports that shows the differences between L(V) and L(V+P) that makes L(V+P) ABI-incompatible with A. The source code of this tool is in the tools/abicompat.cc source file. To support this new tool, this commit changes the comparison engine to optionally avoid showing added symbols that were not referenced by any debug info. It changes the ABI corpus type to allow the specification of a list of variables and functions symbols to keep (and drop all other functions and variables which have other symbols on the floor even before starting to compare the two libraries). This is how the abicompat tool itself works. It basically compares L(V) and L(V+P) but it only looks at their exported functions and variables which symbols are undefined in application A. If the list of exported and defined variables and functions of L(V) whose symbols are undefined in A equals that of L(V+P) (including the sub-types of these variables and functions) A is still compatible with L(V+P). Otherwise, they might not be compatible depending on the kind of differences that are found. * include/abg-comparison.h (diff_context::show_added_symbols_unreferenced_by_debug_info): Declare new accessors. (corpus_diff::{deleted_variables, deleted_unrefed_function_symbols, deleted_unrefed_variable_symbols, apply_filters_and_suppressions_before_reporting}): Declare new methods. (corpus_diff::diff_stats): Declare this new type. Actually this was previously corpus_diff::priv::diff_stats, which was a hidden internal type.. We are moving it here, in the external API so that client code can have more information about changes statistics. Change all the previously publicly accessible data members into accessor functions. * src/abg-comparison.cc (class corpus_diff::diff_stats::priv): New type. (diff_context::priv::show_added_syms_unreferenced_by_di_): New data member. (diff_context::priv::priv): Adjust. (diff_context::show_added_symbols_unreferenced_by_debug_info): Define this new method. (corpus_diff::priv::emit_diff_stats): Do not show the diff stat if the only changes is added function or variables symbols and if we were instructed to not show added symbols. (corpus_diff::priv::{diff_stats_, filters_and_suppr_applied_}): New data members. (corpus_diff::priv::priv): Initialize the filters_and_suppr_applied_ data member. (corpus_diff::priv::diff_stats): Move this type to corpus_diff::diff_stats. (corpus_diff::priv::{apply_filters_and_compute_diff_stats, emit_diff_stats}): Adjust. (corpus_diff::apply_filters_and_suppressions_before_reporting): Define new member function. (corpus_diff::report): Use the new apply_filters_and_suppressions_before_reporting() function, rather than applying the filters and suppressions by ourselves. Also adjust to the use the accessors of the new corpus_diff::diff_stats type. (corpus_diff::{deleted_variables, deleted_unrefed_function_symbols, deleted_unrefed_variable_symbols}): Define new accessors. (corpus_diff::diff_stats::{diff_stats, num_func_removed, num_func_added, num_func_changed, num_func_filtered_out, net_num_func_changed, num_vars_removed, num_vars_added, num_vars_changed, num_vars_filtered_out, net_num_vars_changed, num_func_sym_removed, num_func_syms_added, num_var_syms_removed, num_var_syms_added}): Define new member functions. * include/abg-corpus.h (corpus::{get_sym_ids_of_fns_to_keep, get_sym_ids_of_vars_to_keep}): Declare new methods. * src/abg-corpus.cc (corpus::priv::{sym_id_fns_to_keep, sym_id_vars_to_keep}): Added data members. (symtab_build_visitor_type::{unrefed_fun_symbols, unrefed_var_symbols, sym_id_fns_to_keep, sym_id_vars_to_keep}): Added new data members. (symtab_build_visitor_type::symtab_build_visitor_type): Take two additional parameters for the function and variable symbol ids to keep. (symtab_build_visitor_type::add_fn_to_wip_fns): Take the function symbols to keep in account when building the exported symbol table. (symtab_build_visitor_type::add_var_to_wip_vars): Likewise, take the variable symbols to keep in account when building the exported symbol table. (corpus::priv::build_public_decl_table): Adjust the initialization of the visitor that walks the ABI artifacts to build the exported symbol table to know take a list of function/variable symbols to keep. (corpus::priv::build_unreferenced_symbols_tables): Ensure that the public table of functions/variables is built before doing the work of this function. Also, if a list of variable/function symbols to keep is given, drop all symbols that are not in that list on the floor. (corpus::{get_sym_ids_of_fns_to_keep, get_sym_ids_of_vars_to_keep}): Define new accessors. * tools/abicompat.cc: New abicompat tool. * doc/manuals/abicompat.rst: New documentation source for abicompat. * doc/manuals/libabigail-tools.rst: Add an entry for the abicompat doc. * tests/test-abicompat.cc: New test harness for the 'abicompat' tool. * tests/Makefile.am: Build the runtestabicompat test harness and add it to the list of tests harnesses that are run by make check. * tests/data/test-abicompat/libtest0-fn-changed-libapp-v0.so: New test input. * tests/data/test-abicompat/libtest0-fn-changed-libapp-v1.so: Likewise. * tests/data/test-abicompat/test0-fn-changed-app: Likewise. * tests/data/test-abicompat/test0-fn-changed-0.suppr: Likewise * tests/data/test-abicompat/test0-fn-changed-report-0.txt: Likewise. * tests/data/test-abicompat/test0-fn-changed-report-1.txt: Likewise. * tests/data/test-abicompat/test0-fn-changed-app.cc: Likewise. * tests/data/test-abicompat/test0-fn-changed-libapp.h: Likewise. * tests/data/test-abicompat/test0-fn-changed-libapp-v0.cc: Likewise. * tests/data/test-abicompat/test0-fn-changed-libapp-v1.cc: Likewise. * tests/data/test-abicompat/libtest1-fn-removed-v0.so: Likewise. * tests/data/test-abicompat/libtest1-fn-removed-v1.so: Likewise. * tests/data/test-abicompat/test1-fn-removed-app: Likewise. * tests/data/test-abicompat/test1-fn-removed-app.cc: Likewise. * tests/data/test-abicompat/test1-fn-removed-report-0.txt: Likewise. * tests/data/test-abicompat/test1-fn-removed-v0.cc: Likewise. * tests/data/test-abicompat/test1-fn-removed-v1.cc: Likewise. * tests/data/test-abicompat/libtest2-var-removed-v0.so: Likewise. * tests/data/test-abicompat/libtest2-var-removed-v1.so: Likewise. * tests/data/test-abicompat/test2-var-removed-app: Likewise. * tests/data/test-abicompat/test2-var-removed-app.cc: Likewise. * tests/data/test-abicompat/test2-var-removed-report-0.txt: Likewise. * tests/data/test-abicompat/test2-var-removed-v0.cc: Likewise. * tests/data/test-abicompat/test2-var-removed-v1.cc: Likewise. * tests/data/test-abicompat/libtest3-fn-removed-v0.so: Likewise. * tests/data/test-abicompat/libtest3-fn-removed-v1.so: Likewise. * tests/data/test-abicompat/test3-fn-removed-app: Likewise. * tests/data/test-abicompat/test3-fn-removed-app.cc: Likewise. * tests/data/test-abicompat/test3-fn-removed-report-0.txt: Likewise. * tests/data/test-abicompat/test3-fn-removed-v0.cc: Likewise. * tests/data/test-abicompat/test3-fn-removed-v1.cc: Likewise. * tests/data/test-abicompat/test3-fn-removed-version-script-0 Likewise.: * tests/data/test-abicompat/test3-fn-removed-version-script-1: Likewise. * tests/data/Makefile.am: Add the new test inputs above to the source distribution. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-11-30 17:18:55 +00:00
Set the path to the directory under which the debug information of
the first version of the shared library is supposed to be laid
out. This is useful for shared library binaries for which the
debug info is in a separate set of files.
* ``--lib-debug-info-dir2`` <path-to-lib1-debug-info>
Initial implementation of the abicompat tool Given an application A that links to a shared library L of version V denoted L(V) and a subsequent version of that library denoted L(V+P), the 'abicompat' tool tells the user if L(V+P) is still ABI compatible with L(V+P). And if it is not, abicompat gives a reports that shows the differences between L(V) and L(V+P) that makes L(V+P) ABI-incompatible with A. The source code of this tool is in the tools/abicompat.cc source file. To support this new tool, this commit changes the comparison engine to optionally avoid showing added symbols that were not referenced by any debug info. It changes the ABI corpus type to allow the specification of a list of variables and functions symbols to keep (and drop all other functions and variables which have other symbols on the floor even before starting to compare the two libraries). This is how the abicompat tool itself works. It basically compares L(V) and L(V+P) but it only looks at their exported functions and variables which symbols are undefined in application A. If the list of exported and defined variables and functions of L(V) whose symbols are undefined in A equals that of L(V+P) (including the sub-types of these variables and functions) A is still compatible with L(V+P). Otherwise, they might not be compatible depending on the kind of differences that are found. * include/abg-comparison.h (diff_context::show_added_symbols_unreferenced_by_debug_info): Declare new accessors. (corpus_diff::{deleted_variables, deleted_unrefed_function_symbols, deleted_unrefed_variable_symbols, apply_filters_and_suppressions_before_reporting}): Declare new methods. (corpus_diff::diff_stats): Declare this new type. Actually this was previously corpus_diff::priv::diff_stats, which was a hidden internal type.. We are moving it here, in the external API so that client code can have more information about changes statistics. Change all the previously publicly accessible data members into accessor functions. * src/abg-comparison.cc (class corpus_diff::diff_stats::priv): New type. (diff_context::priv::show_added_syms_unreferenced_by_di_): New data member. (diff_context::priv::priv): Adjust. (diff_context::show_added_symbols_unreferenced_by_debug_info): Define this new method. (corpus_diff::priv::emit_diff_stats): Do not show the diff stat if the only changes is added function or variables symbols and if we were instructed to not show added symbols. (corpus_diff::priv::{diff_stats_, filters_and_suppr_applied_}): New data members. (corpus_diff::priv::priv): Initialize the filters_and_suppr_applied_ data member. (corpus_diff::priv::diff_stats): Move this type to corpus_diff::diff_stats. (corpus_diff::priv::{apply_filters_and_compute_diff_stats, emit_diff_stats}): Adjust. (corpus_diff::apply_filters_and_suppressions_before_reporting): Define new member function. (corpus_diff::report): Use the new apply_filters_and_suppressions_before_reporting() function, rather than applying the filters and suppressions by ourselves. Also adjust to the use the accessors of the new corpus_diff::diff_stats type. (corpus_diff::{deleted_variables, deleted_unrefed_function_symbols, deleted_unrefed_variable_symbols}): Define new accessors. (corpus_diff::diff_stats::{diff_stats, num_func_removed, num_func_added, num_func_changed, num_func_filtered_out, net_num_func_changed, num_vars_removed, num_vars_added, num_vars_changed, num_vars_filtered_out, net_num_vars_changed, num_func_sym_removed, num_func_syms_added, num_var_syms_removed, num_var_syms_added}): Define new member functions. * include/abg-corpus.h (corpus::{get_sym_ids_of_fns_to_keep, get_sym_ids_of_vars_to_keep}): Declare new methods. * src/abg-corpus.cc (corpus::priv::{sym_id_fns_to_keep, sym_id_vars_to_keep}): Added data members. (symtab_build_visitor_type::{unrefed_fun_symbols, unrefed_var_symbols, sym_id_fns_to_keep, sym_id_vars_to_keep}): Added new data members. (symtab_build_visitor_type::symtab_build_visitor_type): Take two additional parameters for the function and variable symbol ids to keep. (symtab_build_visitor_type::add_fn_to_wip_fns): Take the function symbols to keep in account when building the exported symbol table. (symtab_build_visitor_type::add_var_to_wip_vars): Likewise, take the variable symbols to keep in account when building the exported symbol table. (corpus::priv::build_public_decl_table): Adjust the initialization of the visitor that walks the ABI artifacts to build the exported symbol table to know take a list of function/variable symbols to keep. (corpus::priv::build_unreferenced_symbols_tables): Ensure that the public table of functions/variables is built before doing the work of this function. Also, if a list of variable/function symbols to keep is given, drop all symbols that are not in that list on the floor. (corpus::{get_sym_ids_of_fns_to_keep, get_sym_ids_of_vars_to_keep}): Define new accessors. * tools/abicompat.cc: New abicompat tool. * doc/manuals/abicompat.rst: New documentation source for abicompat. * doc/manuals/libabigail-tools.rst: Add an entry for the abicompat doc. * tests/test-abicompat.cc: New test harness for the 'abicompat' tool. * tests/Makefile.am: Build the runtestabicompat test harness and add it to the list of tests harnesses that are run by make check. * tests/data/test-abicompat/libtest0-fn-changed-libapp-v0.so: New test input. * tests/data/test-abicompat/libtest0-fn-changed-libapp-v1.so: Likewise. * tests/data/test-abicompat/test0-fn-changed-app: Likewise. * tests/data/test-abicompat/test0-fn-changed-0.suppr: Likewise * tests/data/test-abicompat/test0-fn-changed-report-0.txt: Likewise. * tests/data/test-abicompat/test0-fn-changed-report-1.txt: Likewise. * tests/data/test-abicompat/test0-fn-changed-app.cc: Likewise. * tests/data/test-abicompat/test0-fn-changed-libapp.h: Likewise. * tests/data/test-abicompat/test0-fn-changed-libapp-v0.cc: Likewise. * tests/data/test-abicompat/test0-fn-changed-libapp-v1.cc: Likewise. * tests/data/test-abicompat/libtest1-fn-removed-v0.so: Likewise. * tests/data/test-abicompat/libtest1-fn-removed-v1.so: Likewise. * tests/data/test-abicompat/test1-fn-removed-app: Likewise. * tests/data/test-abicompat/test1-fn-removed-app.cc: Likewise. * tests/data/test-abicompat/test1-fn-removed-report-0.txt: Likewise. * tests/data/test-abicompat/test1-fn-removed-v0.cc: Likewise. * tests/data/test-abicompat/test1-fn-removed-v1.cc: Likewise. * tests/data/test-abicompat/libtest2-var-removed-v0.so: Likewise. * tests/data/test-abicompat/libtest2-var-removed-v1.so: Likewise. * tests/data/test-abicompat/test2-var-removed-app: Likewise. * tests/data/test-abicompat/test2-var-removed-app.cc: Likewise. * tests/data/test-abicompat/test2-var-removed-report-0.txt: Likewise. * tests/data/test-abicompat/test2-var-removed-v0.cc: Likewise. * tests/data/test-abicompat/test2-var-removed-v1.cc: Likewise. * tests/data/test-abicompat/libtest3-fn-removed-v0.so: Likewise. * tests/data/test-abicompat/libtest3-fn-removed-v1.so: Likewise. * tests/data/test-abicompat/test3-fn-removed-app: Likewise. * tests/data/test-abicompat/test3-fn-removed-app.cc: Likewise. * tests/data/test-abicompat/test3-fn-removed-report-0.txt: Likewise. * tests/data/test-abicompat/test3-fn-removed-v0.cc: Likewise. * tests/data/test-abicompat/test3-fn-removed-v1.cc: Likewise. * tests/data/test-abicompat/test3-fn-removed-version-script-0 Likewise.: * tests/data/test-abicompat/test3-fn-removed-version-script-1: Likewise. * tests/data/Makefile.am: Add the new test inputs above to the source distribution. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-11-30 17:18:55 +00:00
Set the path to the directory under which the debug information of
the second version of the shared library is supposed to be laid
out. This is useful for shared library binaries for which the
debug info is in a separate set of files.
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.
* ``--weak-mode``
Add support for abicompat weak mode This patch implements the weak mode of abicompat. In this mode, just the application and the new version of the library are provided. The types of functions and variables of the library that are consumed by the application are compared to the types of the functions and variables expected by the application. The goal is to check if the types of the declarations consumed by the application and provided by the library are compatible with what the application expects. The abicompat first gets the set of symbols undefined in the application and exported by the library. It then builds the set of declarations exported by the library that have those symbols. We call these the set of declarations of the library that are consumed by the application. Note that the debug information for the application does not contain the declarations of the functions/variables whose symbols are undefined. So we can not just read them to compare them to declarations exported by the library. But the *types* of the variables and the *sub-types* of the functions whose symbols are undefined in the application are present in the debug information of the application. So in the weak mode, abicompat compare the *types* of the declarations consumed by the application as expected by the application (described by the debug information of the application) with the types of the declarations exported by the library. To do this a number of changes were necessary. The patch builds a representation of all the types found in the application's debug info. Before that, only the types that are reachable from exported declarations were represented. The abidw tool got a new --load-all-types to test this new ability of loading all types. The patch also adds support for looking a type, not by name, but by its internal representation. In the comparison engine, function_type_diff is introduced to represent changes between two function types. For this, a new class type_or_decl_base has been introduced in the IR. It's now the base class for both decl_base and type_base. And abigail::comparison::diff now takes two pointers of type_or_decl, not decl_base anymore. So function_type_diff can take two function_type now; not that a function_type has no declaration so it doesn't inherit decl_base. A bunch of changes got made just to adjust to this modification. A number of fixes were made too, to make this work, like adding missing comparison operators, removing asserts that too strong, etc.. The patch also adjust the test suite as well as the documentation. * include/abg-fwd.h (class type_or_decl_base): Forward declare this. (is_decl, is_type, is_function_type, get_name, get_type_name) (get_function_type_name, get_pretty_representation) (lookup_function_type_in_corpus, lookup_type_in_translation_unit) (lookup_function_type_in_translation_unit) (synthesize_function_type_from_translation_unit) (hash_type_or_decl): New function declarations. * src/abg-corpus.cc (lookup_type_in_corpus) (lookup_function_type_in_corpus): Define new functions. * include/abg-ir.h (translation_unit::lookup_function_type_in_translation_unit): Declare new friend function. (class type_or_decl_base): Declare this. (operator==(const type_or_decl_base&, const type_or_decl_base&)): Declare new operator. (operator==(const type_or_decl_base_sptr&, const type_or_decl_base_sptr&)): Likewise. (class {decl_base, type_base}): Make these class inherit type_or_decl_base. (decl_base::get_member_scopes): New const overload. (bool operator==(const function_decl::parameter_sptr&, const function_decl::parameter_sptr&)): New operator. (function_type::get_parameters): Remove the non-const overload. (function_type::get_pretty_representation): Declare new member function. (method_type::get_pretty_representation): Likewise. * src/abg-ir.cc (bool operator==(const type_or_decl_base&, const type_or_decl_base&)): Define new equality operator. (bool operator==(const type_or_decl_base_sptr&, const type_or_decl_base_sptr&)): Likewise. (strip_typedef): Do not expect canonicalized types anymore. Now the system accepts (and expects) canonicalized types in certain cases. For instance, non-complete types and aggregated types that contain non-complete sub-types. (get_name, get_function_type_name, get_type_name) (get_pretty_representation, is_decl, is_type, is_function_type) (lookup_function_type_in_translation_unit) (synthesize_function_type_from_translation_unit) (lookup_type_in_scope, lookup_type_in_translation_unit): Define new functions or new overloads. (bool operator==(const function_decl::parameter_sptr&, const function_decl::parameter_sptr& r)): Define new operator. (function_type::get_parameters): Remove non-const overload. (function_type::get_pretty_representation): Define new function. (function_type::traverse): Adjust. (method_type::get_pretty_representation): Likewise. (function_decl::get_pretty_representation): Avoid emitting the type of cdtors. (hash_type_or_decl): Define new function. * include/abg-dwarf-reader.h (create_read_context) (read_corpus_from_elf): Take a new 'read_all_types' flag. * src/abg-dwarf-reader.cc (read_context::load_all_types_): New flag. (read_context::read_context): Initialize it. (read_context::canonical_types_scheduled): If some types still have non-canonicalized sub-types, then do not canonicalize them. (read_context::load_all_types): New member functions. (build_function_decl): Do not represent void return type like empty type anymore, rather, represent it like a void type node. (build_ir_node_from_die): When asked, load all types including those that are not reachable from an exported declaration. (create_read_context, read_corpus_from_elf): Take a new 'load_all_types' flag and honour it. * src/abg-reader.cc (read_context::type_is_from_translation_unit): Support looking up function types in the current translation unit, now that we now how to lookup function types. * include/abg-comparison.h (diff_context::{has_diff_for, add_diff, set_canonical_diff_for, set_or_get_canonical_diff_for, get_canonical_diff_for}): Make these take instances of type_or_decl_base_sptr, instead of decl_base_sptr. (diff::diff): Likewise. (diff::{first_subject, second_subject}): Make these return type_or_decl_base_sptr instead of decl_base_sptr. (type_diff_base::type_diff_base): Make these take instances of type_or_decl_base_sptr instead of decl_base_sptr. (distinct_diff::distinct_diff): Likewise. (distinct_diff::{first, second}): Make these return type_or_decl_base_sptr instead of decl_base_sptr. (distinct_diff::entities_are_of_distinct_kinds): Make these take instances of type_or_decl_base_sptr instead of decl_base_sptr. (class function_type_diff): Create this new type. It's a factorization of the function_decl_diff type. * src/abg-comparison.cc (): * src/abg-comp-filter.cc ({harmless, harmful}_filter::visit): Adjust as diff::{first,second}_subject() now returns a type_or_decl_base_sptr, no more a decl_base_sptr. (decls_type, decls_diff_map_type): Remove these typedefs and replace it with ... (types_or_decls_type, types_or_decls_diff_map_type): ... these. (struct {decls_hash, decls_equals): Remove these type sand replace them with ... (struct {types_or_decls_hash, types_or_decls_equals}): ... these. ({type_suppression, variable_suppression}::suppresses_diff): Adjust. (diff_context::priv::decls_diff_map): Replace this with ... (diff_context::priv::types_or_decls_diff_map): ... this. (diff_context::{has_diff_for, add_diff, get_canonical_diff_for, set_canonical_diff_for, set_or_get_canonical_diff_for}): Take type_or_decl_base_sptr instead of decl_base_sptr. (diff::priv::{first, second}_subject): Make the type of these be type_or_decl_base_sptr, no more decl_base_sptr. (diff::priv::priv): Adjust for the subjects of the diff being of type type_or_decl_sptr now, no more decl_base_sptr. (diff_less_than_functor::operator()(const diff_sptr, const diff_sptr) const): Adjust. (diff::diff): djust for the subjects of the diff being of type type_or_decl_sptr now, no more decl_base_sptr. (diff::{first,second}_subject): Make the type of these be type_or_decl_base_sptr, no more decl_base_sptr. (report_size_and_alignment_changes): Likewise. (type_diff_base::type_diff_base): Make the type of this be type_or_decl_base_sptr instead of type_base_sptr. (distinct_diff::distinct_diff): Make this take instances of type_or_decl_base_sptr instead of decl_base_sptr. (distinct_diff::{first, second, entities_are_of_distinct_kinds}): Likewise. (distinct_diff::has_changes): Simplify logic. (distinct_diff::report): Adjust. (compute_diff_for_types): Add an additional case to support the new function_type. (report_size_and_alignment_changes): Make this take instances of type_or_decl_base_sptr instead of decl_base_sptr. (class_diff::priv::member_type_has_changed): Return an instance of type_or_decl_base_sptr rather than a decl_base_sptr. (class_diff::report): Adjust. (diff_comp::operator()(const diff&, diff&) const): Adjust. (enum function_decl_diff::priv::Flags): Remove. (function_decl_diff::priv::{first_fn_flags_, second_fn_flags_, fn_flags_changes_}): Remove. (function_decl_diff::priv::{fn_is_declared_inline_to_flag, fn_binding_to_flag}): Remove. (function_decl_diff::{deleted_parameter_at, inserted_parameter_at}): Remove. (function_decl_diff::ensure_lookup_tables_populated): Empty this. (function_decl_diff::chain_into_hierarchy): Adjust. (function_decl_diff::function_decl_diff): This now only takes the subjects. It's body is now empty. (function_decl_diff::{return_type_diff, subtype_changed_parms, removed_parms, added_parms, type_diff}): Remove these member functions. (function_decl_diff::type_diff): Define new member function. (function_decl_diff::report): Simplify logic by using the reporting of the child type diff node. (compute_diff): Likewise, in the overload for function_decl_sptr simplify logic by using the child type diff object. (function_type_diff::priv): Define new type. (function_type_diff::{function_type_diff, ensure_lookup_tables_populated, deleted_parameter_at, inserted_parameter_at, finish_diff_type, first_function_type, second_function_type, return_type_diff, subtype_changed_parms, removed_parms, added_parms, get_pretty_representation, has_changes, has_local_changes, report, chain_into_hierarchy}): Define new functions. (compute_diff): Define new overload for function_type_sptr. * tools/abicompat.cc (options::weak_mode): New data member. (options::options): Initialize it. (enum abicompat_status): New enum (abicompat_status operator|(abicompat_status, abicompat_status)) (abicompat_status& operator|=(abicompat_status &, abicompat_status)) (abicompat_status operator&(abicompat_status, abicompat_status)): New operators to manipulate the abicompat_status enum. (display_usage): Add help string for the new --weak-mode option. (parse_command_line): Add the new --weak-mode command line argument. If the tool is called with just the application and one library then assume that we are in the weak mode. (perform_compat_check_in_normal_mode): Define new function, factorized from what was in the main function. (perform_compat_check_in_weak_mode): Define new function. (struct {fn,var}_change): Define new types. (main): Use perform_compat_check_in_weak_mode() and perform_compat_check_in_normal_mode(). * tools/abidiff.cc (main): Adjust. * tools/abidw.cc: (options::load_all_types): Add new data member. (options::options): Initialize it. (display_usage): New help string for --load-all-types. (parse_command_line): Support the new --load-all-types option. (main): Adjust and honour the --load-all-types option. * tools/abilint.cc (main): Adjust. * doc/manuals/abicompat.rst: Update documentation for the new weak mode. Also provide stuff that was missing from the examples provided. * doc/manuals/abidw.rst: Update documentation for the new --load-all-types option. * tests/print-diff-tree.cc (main): Adjust. * tests/test-diff-dwarf.cc (main): Likewise. * tests/test-read-dwarf.cc (main): Likewise. * tests/data/test-abicompat/test0-fn-changed-app: Recompile this. * tests/data/test-abicompat/libtest5-fn-changed-libapp-v{0,1}.so: New new test input binaries * tests/data/test-abicompat/test5-fn-changed-app: Likewise. * tests/data/test-abicompat/test6-var-changed-app: Likewise. * tests/data/test-abicompat/libtest6-var-changed-libapp-v{0,1}.so: Likewise. * tests/data/test-abicompat/test5-fn-changed-report-0.txt: Reference output for one test above. * tests/data/test-abicompat/test6-var-changed-report-0.txt: Likewise. * tests/data/test-abicompat/test5-fn-changed-app.cc: Source file for a binary above. * tests/data/test-abicompat/test5-fn-changed-libapp-v{0,1}.{h,cc}: Likewise. * tests/data/test-abicompat/test6-var-changed-libapp-v{0,1}.{cc,h}: Likewise. * tests/data/test-abicompat/test6-var-changed-app.cc: Likewise. * tests/data/Makefile.am: Add the test related files above to the source distribution. * tests/test-abicompat.cc (in_out_spec): Add the new test input above to the list of inputs to feed to this test harness. (main): Support taking just the app and one library. * tests/data/test-read-dwarf/test{0, 1, 2.so, 3.so, 5.o, 8-qualified-this-pointer.so,}.abi: Adjust for void type being really emitted now, as opposed to just being an empty type. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-04-01 10:13:38 +00:00
This triggers the weak mode of ``abicompat``. In this mode, only
one version of the library is required. That is, abicompat is
invoked like this: ::
abicompat --weak-mode <the-application> <the-library>
Note that the ``--weak-mode`` option can even be omitted if only
one version of the library is given, along with the application;
in that case, ``abicompat`` automatically switches to operate in
weak mode: ::
abicompat <the-application> <the-library>
In this weak mode, the types of functions and variables exported
by the library and consumed by the application (as in, the symbols
of the these functions and variables are undefined in the
application and are defined and exported by the library) are
compared to the version of these types as expected by the
application. And if these two versions of types are different,
``abicompat`` tells the user what the differences are.
In other words, in this mode, ``abicompat`` checks that the types
of the functions and variables exported by the library mean the
same thing as what the application expects, as far as the ABI is
concerned.
Note that in this mode, `abicompat` doesn't detect exported
functions or variables (symbols) that are expected by the
application but that are removed from the library. That is why it
is called ``weak`` mode.
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
.. _abicompat_return_value_label:
Return values
=============
The exit code of the ``abicompat`` 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.
The remaining bits are not used for the moment.
.. _abicompat_usage_example_label:
Initial implementation of the abicompat tool Given an application A that links to a shared library L of version V denoted L(V) and a subsequent version of that library denoted L(V+P), the 'abicompat' tool tells the user if L(V+P) is still ABI compatible with L(V+P). And if it is not, abicompat gives a reports that shows the differences between L(V) and L(V+P) that makes L(V+P) ABI-incompatible with A. The source code of this tool is in the tools/abicompat.cc source file. To support this new tool, this commit changes the comparison engine to optionally avoid showing added symbols that were not referenced by any debug info. It changes the ABI corpus type to allow the specification of a list of variables and functions symbols to keep (and drop all other functions and variables which have other symbols on the floor even before starting to compare the two libraries). This is how the abicompat tool itself works. It basically compares L(V) and L(V+P) but it only looks at their exported functions and variables which symbols are undefined in application A. If the list of exported and defined variables and functions of L(V) whose symbols are undefined in A equals that of L(V+P) (including the sub-types of these variables and functions) A is still compatible with L(V+P). Otherwise, they might not be compatible depending on the kind of differences that are found. * include/abg-comparison.h (diff_context::show_added_symbols_unreferenced_by_debug_info): Declare new accessors. (corpus_diff::{deleted_variables, deleted_unrefed_function_symbols, deleted_unrefed_variable_symbols, apply_filters_and_suppressions_before_reporting}): Declare new methods. (corpus_diff::diff_stats): Declare this new type. Actually this was previously corpus_diff::priv::diff_stats, which was a hidden internal type.. We are moving it here, in the external API so that client code can have more information about changes statistics. Change all the previously publicly accessible data members into accessor functions. * src/abg-comparison.cc (class corpus_diff::diff_stats::priv): New type. (diff_context::priv::show_added_syms_unreferenced_by_di_): New data member. (diff_context::priv::priv): Adjust. (diff_context::show_added_symbols_unreferenced_by_debug_info): Define this new method. (corpus_diff::priv::emit_diff_stats): Do not show the diff stat if the only changes is added function or variables symbols and if we were instructed to not show added symbols. (corpus_diff::priv::{diff_stats_, filters_and_suppr_applied_}): New data members. (corpus_diff::priv::priv): Initialize the filters_and_suppr_applied_ data member. (corpus_diff::priv::diff_stats): Move this type to corpus_diff::diff_stats. (corpus_diff::priv::{apply_filters_and_compute_diff_stats, emit_diff_stats}): Adjust. (corpus_diff::apply_filters_and_suppressions_before_reporting): Define new member function. (corpus_diff::report): Use the new apply_filters_and_suppressions_before_reporting() function, rather than applying the filters and suppressions by ourselves. Also adjust to the use the accessors of the new corpus_diff::diff_stats type. (corpus_diff::{deleted_variables, deleted_unrefed_function_symbols, deleted_unrefed_variable_symbols}): Define new accessors. (corpus_diff::diff_stats::{diff_stats, num_func_removed, num_func_added, num_func_changed, num_func_filtered_out, net_num_func_changed, num_vars_removed, num_vars_added, num_vars_changed, num_vars_filtered_out, net_num_vars_changed, num_func_sym_removed, num_func_syms_added, num_var_syms_removed, num_var_syms_added}): Define new member functions. * include/abg-corpus.h (corpus::{get_sym_ids_of_fns_to_keep, get_sym_ids_of_vars_to_keep}): Declare new methods. * src/abg-corpus.cc (corpus::priv::{sym_id_fns_to_keep, sym_id_vars_to_keep}): Added data members. (symtab_build_visitor_type::{unrefed_fun_symbols, unrefed_var_symbols, sym_id_fns_to_keep, sym_id_vars_to_keep}): Added new data members. (symtab_build_visitor_type::symtab_build_visitor_type): Take two additional parameters for the function and variable symbol ids to keep. (symtab_build_visitor_type::add_fn_to_wip_fns): Take the function symbols to keep in account when building the exported symbol table. (symtab_build_visitor_type::add_var_to_wip_vars): Likewise, take the variable symbols to keep in account when building the exported symbol table. (corpus::priv::build_public_decl_table): Adjust the initialization of the visitor that walks the ABI artifacts to build the exported symbol table to know take a list of function/variable symbols to keep. (corpus::priv::build_unreferenced_symbols_tables): Ensure that the public table of functions/variables is built before doing the work of this function. Also, if a list of variable/function symbols to keep is given, drop all symbols that are not in that list on the floor. (corpus::{get_sym_ids_of_fns_to_keep, get_sym_ids_of_vars_to_keep}): Define new accessors. * tools/abicompat.cc: New abicompat tool. * doc/manuals/abicompat.rst: New documentation source for abicompat. * doc/manuals/libabigail-tools.rst: Add an entry for the abicompat doc. * tests/test-abicompat.cc: New test harness for the 'abicompat' tool. * tests/Makefile.am: Build the runtestabicompat test harness and add it to the list of tests harnesses that are run by make check. * tests/data/test-abicompat/libtest0-fn-changed-libapp-v0.so: New test input. * tests/data/test-abicompat/libtest0-fn-changed-libapp-v1.so: Likewise. * tests/data/test-abicompat/test0-fn-changed-app: Likewise. * tests/data/test-abicompat/test0-fn-changed-0.suppr: Likewise * tests/data/test-abicompat/test0-fn-changed-report-0.txt: Likewise. * tests/data/test-abicompat/test0-fn-changed-report-1.txt: Likewise. * tests/data/test-abicompat/test0-fn-changed-app.cc: Likewise. * tests/data/test-abicompat/test0-fn-changed-libapp.h: Likewise. * tests/data/test-abicompat/test0-fn-changed-libapp-v0.cc: Likewise. * tests/data/test-abicompat/test0-fn-changed-libapp-v1.cc: Likewise. * tests/data/test-abicompat/libtest1-fn-removed-v0.so: Likewise. * tests/data/test-abicompat/libtest1-fn-removed-v1.so: Likewise. * tests/data/test-abicompat/test1-fn-removed-app: Likewise. * tests/data/test-abicompat/test1-fn-removed-app.cc: Likewise. * tests/data/test-abicompat/test1-fn-removed-report-0.txt: Likewise. * tests/data/test-abicompat/test1-fn-removed-v0.cc: Likewise. * tests/data/test-abicompat/test1-fn-removed-v1.cc: Likewise. * tests/data/test-abicompat/libtest2-var-removed-v0.so: Likewise. * tests/data/test-abicompat/libtest2-var-removed-v1.so: Likewise. * tests/data/test-abicompat/test2-var-removed-app: Likewise. * tests/data/test-abicompat/test2-var-removed-app.cc: Likewise. * tests/data/test-abicompat/test2-var-removed-report-0.txt: Likewise. * tests/data/test-abicompat/test2-var-removed-v0.cc: Likewise. * tests/data/test-abicompat/test2-var-removed-v1.cc: Likewise. * tests/data/test-abicompat/libtest3-fn-removed-v0.so: Likewise. * tests/data/test-abicompat/libtest3-fn-removed-v1.so: Likewise. * tests/data/test-abicompat/test3-fn-removed-app: Likewise. * tests/data/test-abicompat/test3-fn-removed-app.cc: Likewise. * tests/data/test-abicompat/test3-fn-removed-report-0.txt: Likewise. * tests/data/test-abicompat/test3-fn-removed-v0.cc: Likewise. * tests/data/test-abicompat/test3-fn-removed-v1.cc: Likewise. * tests/data/test-abicompat/test3-fn-removed-version-script-0 Likewise.: * tests/data/test-abicompat/test3-fn-removed-version-script-1: Likewise. * tests/data/Makefile.am: Add the new test inputs above to the source distribution. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-11-30 17:18:55 +00:00
Usage examples
==============
* Detecting a possible ABI incompatibility in a new shared library
version: ::
Add support for abicompat weak mode This patch implements the weak mode of abicompat. In this mode, just the application and the new version of the library are provided. The types of functions and variables of the library that are consumed by the application are compared to the types of the functions and variables expected by the application. The goal is to check if the types of the declarations consumed by the application and provided by the library are compatible with what the application expects. The abicompat first gets the set of symbols undefined in the application and exported by the library. It then builds the set of declarations exported by the library that have those symbols. We call these the set of declarations of the library that are consumed by the application. Note that the debug information for the application does not contain the declarations of the functions/variables whose symbols are undefined. So we can not just read them to compare them to declarations exported by the library. But the *types* of the variables and the *sub-types* of the functions whose symbols are undefined in the application are present in the debug information of the application. So in the weak mode, abicompat compare the *types* of the declarations consumed by the application as expected by the application (described by the debug information of the application) with the types of the declarations exported by the library. To do this a number of changes were necessary. The patch builds a representation of all the types found in the application's debug info. Before that, only the types that are reachable from exported declarations were represented. The abidw tool got a new --load-all-types to test this new ability of loading all types. The patch also adds support for looking a type, not by name, but by its internal representation. In the comparison engine, function_type_diff is introduced to represent changes between two function types. For this, a new class type_or_decl_base has been introduced in the IR. It's now the base class for both decl_base and type_base. And abigail::comparison::diff now takes two pointers of type_or_decl, not decl_base anymore. So function_type_diff can take two function_type now; not that a function_type has no declaration so it doesn't inherit decl_base. A bunch of changes got made just to adjust to this modification. A number of fixes were made too, to make this work, like adding missing comparison operators, removing asserts that too strong, etc.. The patch also adjust the test suite as well as the documentation. * include/abg-fwd.h (class type_or_decl_base): Forward declare this. (is_decl, is_type, is_function_type, get_name, get_type_name) (get_function_type_name, get_pretty_representation) (lookup_function_type_in_corpus, lookup_type_in_translation_unit) (lookup_function_type_in_translation_unit) (synthesize_function_type_from_translation_unit) (hash_type_or_decl): New function declarations. * src/abg-corpus.cc (lookup_type_in_corpus) (lookup_function_type_in_corpus): Define new functions. * include/abg-ir.h (translation_unit::lookup_function_type_in_translation_unit): Declare new friend function. (class type_or_decl_base): Declare this. (operator==(const type_or_decl_base&, const type_or_decl_base&)): Declare new operator. (operator==(const type_or_decl_base_sptr&, const type_or_decl_base_sptr&)): Likewise. (class {decl_base, type_base}): Make these class inherit type_or_decl_base. (decl_base::get_member_scopes): New const overload. (bool operator==(const function_decl::parameter_sptr&, const function_decl::parameter_sptr&)): New operator. (function_type::get_parameters): Remove the non-const overload. (function_type::get_pretty_representation): Declare new member function. (method_type::get_pretty_representation): Likewise. * src/abg-ir.cc (bool operator==(const type_or_decl_base&, const type_or_decl_base&)): Define new equality operator. (bool operator==(const type_or_decl_base_sptr&, const type_or_decl_base_sptr&)): Likewise. (strip_typedef): Do not expect canonicalized types anymore. Now the system accepts (and expects) canonicalized types in certain cases. For instance, non-complete types and aggregated types that contain non-complete sub-types. (get_name, get_function_type_name, get_type_name) (get_pretty_representation, is_decl, is_type, is_function_type) (lookup_function_type_in_translation_unit) (synthesize_function_type_from_translation_unit) (lookup_type_in_scope, lookup_type_in_translation_unit): Define new functions or new overloads. (bool operator==(const function_decl::parameter_sptr&, const function_decl::parameter_sptr& r)): Define new operator. (function_type::get_parameters): Remove non-const overload. (function_type::get_pretty_representation): Define new function. (function_type::traverse): Adjust. (method_type::get_pretty_representation): Likewise. (function_decl::get_pretty_representation): Avoid emitting the type of cdtors. (hash_type_or_decl): Define new function. * include/abg-dwarf-reader.h (create_read_context) (read_corpus_from_elf): Take a new 'read_all_types' flag. * src/abg-dwarf-reader.cc (read_context::load_all_types_): New flag. (read_context::read_context): Initialize it. (read_context::canonical_types_scheduled): If some types still have non-canonicalized sub-types, then do not canonicalize them. (read_context::load_all_types): New member functions. (build_function_decl): Do not represent void return type like empty type anymore, rather, represent it like a void type node. (build_ir_node_from_die): When asked, load all types including those that are not reachable from an exported declaration. (create_read_context, read_corpus_from_elf): Take a new 'load_all_types' flag and honour it. * src/abg-reader.cc (read_context::type_is_from_translation_unit): Support looking up function types in the current translation unit, now that we now how to lookup function types. * include/abg-comparison.h (diff_context::{has_diff_for, add_diff, set_canonical_diff_for, set_or_get_canonical_diff_for, get_canonical_diff_for}): Make these take instances of type_or_decl_base_sptr, instead of decl_base_sptr. (diff::diff): Likewise. (diff::{first_subject, second_subject}): Make these return type_or_decl_base_sptr instead of decl_base_sptr. (type_diff_base::type_diff_base): Make these take instances of type_or_decl_base_sptr instead of decl_base_sptr. (distinct_diff::distinct_diff): Likewise. (distinct_diff::{first, second}): Make these return type_or_decl_base_sptr instead of decl_base_sptr. (distinct_diff::entities_are_of_distinct_kinds): Make these take instances of type_or_decl_base_sptr instead of decl_base_sptr. (class function_type_diff): Create this new type. It's a factorization of the function_decl_diff type. * src/abg-comparison.cc (): * src/abg-comp-filter.cc ({harmless, harmful}_filter::visit): Adjust as diff::{first,second}_subject() now returns a type_or_decl_base_sptr, no more a decl_base_sptr. (decls_type, decls_diff_map_type): Remove these typedefs and replace it with ... (types_or_decls_type, types_or_decls_diff_map_type): ... these. (struct {decls_hash, decls_equals): Remove these type sand replace them with ... (struct {types_or_decls_hash, types_or_decls_equals}): ... these. ({type_suppression, variable_suppression}::suppresses_diff): Adjust. (diff_context::priv::decls_diff_map): Replace this with ... (diff_context::priv::types_or_decls_diff_map): ... this. (diff_context::{has_diff_for, add_diff, get_canonical_diff_for, set_canonical_diff_for, set_or_get_canonical_diff_for}): Take type_or_decl_base_sptr instead of decl_base_sptr. (diff::priv::{first, second}_subject): Make the type of these be type_or_decl_base_sptr, no more decl_base_sptr. (diff::priv::priv): Adjust for the subjects of the diff being of type type_or_decl_sptr now, no more decl_base_sptr. (diff_less_than_functor::operator()(const diff_sptr, const diff_sptr) const): Adjust. (diff::diff): djust for the subjects of the diff being of type type_or_decl_sptr now, no more decl_base_sptr. (diff::{first,second}_subject): Make the type of these be type_or_decl_base_sptr, no more decl_base_sptr. (report_size_and_alignment_changes): Likewise. (type_diff_base::type_diff_base): Make the type of this be type_or_decl_base_sptr instead of type_base_sptr. (distinct_diff::distinct_diff): Make this take instances of type_or_decl_base_sptr instead of decl_base_sptr. (distinct_diff::{first, second, entities_are_of_distinct_kinds}): Likewise. (distinct_diff::has_changes): Simplify logic. (distinct_diff::report): Adjust. (compute_diff_for_types): Add an additional case to support the new function_type. (report_size_and_alignment_changes): Make this take instances of type_or_decl_base_sptr instead of decl_base_sptr. (class_diff::priv::member_type_has_changed): Return an instance of type_or_decl_base_sptr rather than a decl_base_sptr. (class_diff::report): Adjust. (diff_comp::operator()(const diff&, diff&) const): Adjust. (enum function_decl_diff::priv::Flags): Remove. (function_decl_diff::priv::{first_fn_flags_, second_fn_flags_, fn_flags_changes_}): Remove. (function_decl_diff::priv::{fn_is_declared_inline_to_flag, fn_binding_to_flag}): Remove. (function_decl_diff::{deleted_parameter_at, inserted_parameter_at}): Remove. (function_decl_diff::ensure_lookup_tables_populated): Empty this. (function_decl_diff::chain_into_hierarchy): Adjust. (function_decl_diff::function_decl_diff): This now only takes the subjects. It's body is now empty. (function_decl_diff::{return_type_diff, subtype_changed_parms, removed_parms, added_parms, type_diff}): Remove these member functions. (function_decl_diff::type_diff): Define new member function. (function_decl_diff::report): Simplify logic by using the reporting of the child type diff node. (compute_diff): Likewise, in the overload for function_decl_sptr simplify logic by using the child type diff object. (function_type_diff::priv): Define new type. (function_type_diff::{function_type_diff, ensure_lookup_tables_populated, deleted_parameter_at, inserted_parameter_at, finish_diff_type, first_function_type, second_function_type, return_type_diff, subtype_changed_parms, removed_parms, added_parms, get_pretty_representation, has_changes, has_local_changes, report, chain_into_hierarchy}): Define new functions. (compute_diff): Define new overload for function_type_sptr. * tools/abicompat.cc (options::weak_mode): New data member. (options::options): Initialize it. (enum abicompat_status): New enum (abicompat_status operator|(abicompat_status, abicompat_status)) (abicompat_status& operator|=(abicompat_status &, abicompat_status)) (abicompat_status operator&(abicompat_status, abicompat_status)): New operators to manipulate the abicompat_status enum. (display_usage): Add help string for the new --weak-mode option. (parse_command_line): Add the new --weak-mode command line argument. If the tool is called with just the application and one library then assume that we are in the weak mode. (perform_compat_check_in_normal_mode): Define new function, factorized from what was in the main function. (perform_compat_check_in_weak_mode): Define new function. (struct {fn,var}_change): Define new types. (main): Use perform_compat_check_in_weak_mode() and perform_compat_check_in_normal_mode(). * tools/abidiff.cc (main): Adjust. * tools/abidw.cc: (options::load_all_types): Add new data member. (options::options): Initialize it. (display_usage): New help string for --load-all-types. (parse_command_line): Support the new --load-all-types option. (main): Adjust and honour the --load-all-types option. * tools/abilint.cc (main): Adjust. * doc/manuals/abicompat.rst: Update documentation for the new weak mode. Also provide stuff that was missing from the examples provided. * doc/manuals/abidw.rst: Update documentation for the new --load-all-types option. * tests/print-diff-tree.cc (main): Adjust. * tests/test-diff-dwarf.cc (main): Likewise. * tests/test-read-dwarf.cc (main): Likewise. * tests/data/test-abicompat/test0-fn-changed-app: Recompile this. * tests/data/test-abicompat/libtest5-fn-changed-libapp-v{0,1}.so: New new test input binaries * tests/data/test-abicompat/test5-fn-changed-app: Likewise. * tests/data/test-abicompat/test6-var-changed-app: Likewise. * tests/data/test-abicompat/libtest6-var-changed-libapp-v{0,1}.so: Likewise. * tests/data/test-abicompat/test5-fn-changed-report-0.txt: Reference output for one test above. * tests/data/test-abicompat/test6-var-changed-report-0.txt: Likewise. * tests/data/test-abicompat/test5-fn-changed-app.cc: Source file for a binary above. * tests/data/test-abicompat/test5-fn-changed-libapp-v{0,1}.{h,cc}: Likewise. * tests/data/test-abicompat/test6-var-changed-libapp-v{0,1}.{cc,h}: Likewise. * tests/data/test-abicompat/test6-var-changed-app.cc: Likewise. * tests/data/Makefile.am: Add the test related files above to the source distribution. * tests/test-abicompat.cc (in_out_spec): Add the new test input above to the list of inputs to feed to this test harness. (main): Support taking just the app and one library. * tests/data/test-read-dwarf/test{0, 1, 2.so, 3.so, 5.o, 8-qualified-this-pointer.so,}.abi: Adjust for void type being really emitted now, as opposed to just being an empty type. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-04-01 10:13:38 +00:00
$ cat -n test0.h
1 struct foo
2 {
3 int m0;
4
5 foo()
6 : m0()
7 {}
8 };
9
10 foo*
11 first_func();
12
13 void
14 second_func(foo&);
15
16 void
17 third_func();
$
Initial implementation of the abicompat tool Given an application A that links to a shared library L of version V denoted L(V) and a subsequent version of that library denoted L(V+P), the 'abicompat' tool tells the user if L(V+P) is still ABI compatible with L(V+P). And if it is not, abicompat gives a reports that shows the differences between L(V) and L(V+P) that makes L(V+P) ABI-incompatible with A. The source code of this tool is in the tools/abicompat.cc source file. To support this new tool, this commit changes the comparison engine to optionally avoid showing added symbols that were not referenced by any debug info. It changes the ABI corpus type to allow the specification of a list of variables and functions symbols to keep (and drop all other functions and variables which have other symbols on the floor even before starting to compare the two libraries). This is how the abicompat tool itself works. It basically compares L(V) and L(V+P) but it only looks at their exported functions and variables which symbols are undefined in application A. If the list of exported and defined variables and functions of L(V) whose symbols are undefined in A equals that of L(V+P) (including the sub-types of these variables and functions) A is still compatible with L(V+P). Otherwise, they might not be compatible depending on the kind of differences that are found. * include/abg-comparison.h (diff_context::show_added_symbols_unreferenced_by_debug_info): Declare new accessors. (corpus_diff::{deleted_variables, deleted_unrefed_function_symbols, deleted_unrefed_variable_symbols, apply_filters_and_suppressions_before_reporting}): Declare new methods. (corpus_diff::diff_stats): Declare this new type. Actually this was previously corpus_diff::priv::diff_stats, which was a hidden internal type.. We are moving it here, in the external API so that client code can have more information about changes statistics. Change all the previously publicly accessible data members into accessor functions. * src/abg-comparison.cc (class corpus_diff::diff_stats::priv): New type. (diff_context::priv::show_added_syms_unreferenced_by_di_): New data member. (diff_context::priv::priv): Adjust. (diff_context::show_added_symbols_unreferenced_by_debug_info): Define this new method. (corpus_diff::priv::emit_diff_stats): Do not show the diff stat if the only changes is added function or variables symbols and if we were instructed to not show added symbols. (corpus_diff::priv::{diff_stats_, filters_and_suppr_applied_}): New data members. (corpus_diff::priv::priv): Initialize the filters_and_suppr_applied_ data member. (corpus_diff::priv::diff_stats): Move this type to corpus_diff::diff_stats. (corpus_diff::priv::{apply_filters_and_compute_diff_stats, emit_diff_stats}): Adjust. (corpus_diff::apply_filters_and_suppressions_before_reporting): Define new member function. (corpus_diff::report): Use the new apply_filters_and_suppressions_before_reporting() function, rather than applying the filters and suppressions by ourselves. Also adjust to the use the accessors of the new corpus_diff::diff_stats type. (corpus_diff::{deleted_variables, deleted_unrefed_function_symbols, deleted_unrefed_variable_symbols}): Define new accessors. (corpus_diff::diff_stats::{diff_stats, num_func_removed, num_func_added, num_func_changed, num_func_filtered_out, net_num_func_changed, num_vars_removed, num_vars_added, num_vars_changed, num_vars_filtered_out, net_num_vars_changed, num_func_sym_removed, num_func_syms_added, num_var_syms_removed, num_var_syms_added}): Define new member functions. * include/abg-corpus.h (corpus::{get_sym_ids_of_fns_to_keep, get_sym_ids_of_vars_to_keep}): Declare new methods. * src/abg-corpus.cc (corpus::priv::{sym_id_fns_to_keep, sym_id_vars_to_keep}): Added data members. (symtab_build_visitor_type::{unrefed_fun_symbols, unrefed_var_symbols, sym_id_fns_to_keep, sym_id_vars_to_keep}): Added new data members. (symtab_build_visitor_type::symtab_build_visitor_type): Take two additional parameters for the function and variable symbol ids to keep. (symtab_build_visitor_type::add_fn_to_wip_fns): Take the function symbols to keep in account when building the exported symbol table. (symtab_build_visitor_type::add_var_to_wip_vars): Likewise, take the variable symbols to keep in account when building the exported symbol table. (corpus::priv::build_public_decl_table): Adjust the initialization of the visitor that walks the ABI artifacts to build the exported symbol table to know take a list of function/variable symbols to keep. (corpus::priv::build_unreferenced_symbols_tables): Ensure that the public table of functions/variables is built before doing the work of this function. Also, if a list of variable/function symbols to keep is given, drop all symbols that are not in that list on the floor. (corpus::{get_sym_ids_of_fns_to_keep, get_sym_ids_of_vars_to_keep}): Define new accessors. * tools/abicompat.cc: New abicompat tool. * doc/manuals/abicompat.rst: New documentation source for abicompat. * doc/manuals/libabigail-tools.rst: Add an entry for the abicompat doc. * tests/test-abicompat.cc: New test harness for the 'abicompat' tool. * tests/Makefile.am: Build the runtestabicompat test harness and add it to the list of tests harnesses that are run by make check. * tests/data/test-abicompat/libtest0-fn-changed-libapp-v0.so: New test input. * tests/data/test-abicompat/libtest0-fn-changed-libapp-v1.so: Likewise. * tests/data/test-abicompat/test0-fn-changed-app: Likewise. * tests/data/test-abicompat/test0-fn-changed-0.suppr: Likewise * tests/data/test-abicompat/test0-fn-changed-report-0.txt: Likewise. * tests/data/test-abicompat/test0-fn-changed-report-1.txt: Likewise. * tests/data/test-abicompat/test0-fn-changed-app.cc: Likewise. * tests/data/test-abicompat/test0-fn-changed-libapp.h: Likewise. * tests/data/test-abicompat/test0-fn-changed-libapp-v0.cc: Likewise. * tests/data/test-abicompat/test0-fn-changed-libapp-v1.cc: Likewise. * tests/data/test-abicompat/libtest1-fn-removed-v0.so: Likewise. * tests/data/test-abicompat/libtest1-fn-removed-v1.so: Likewise. * tests/data/test-abicompat/test1-fn-removed-app: Likewise. * tests/data/test-abicompat/test1-fn-removed-app.cc: Likewise. * tests/data/test-abicompat/test1-fn-removed-report-0.txt: Likewise. * tests/data/test-abicompat/test1-fn-removed-v0.cc: Likewise. * tests/data/test-abicompat/test1-fn-removed-v1.cc: Likewise. * tests/data/test-abicompat/libtest2-var-removed-v0.so: Likewise. * tests/data/test-abicompat/libtest2-var-removed-v1.so: Likewise. * tests/data/test-abicompat/test2-var-removed-app: Likewise. * tests/data/test-abicompat/test2-var-removed-app.cc: Likewise. * tests/data/test-abicompat/test2-var-removed-report-0.txt: Likewise. * tests/data/test-abicompat/test2-var-removed-v0.cc: Likewise. * tests/data/test-abicompat/test2-var-removed-v1.cc: Likewise. * tests/data/test-abicompat/libtest3-fn-removed-v0.so: Likewise. * tests/data/test-abicompat/libtest3-fn-removed-v1.so: Likewise. * tests/data/test-abicompat/test3-fn-removed-app: Likewise. * tests/data/test-abicompat/test3-fn-removed-app.cc: Likewise. * tests/data/test-abicompat/test3-fn-removed-report-0.txt: Likewise. * tests/data/test-abicompat/test3-fn-removed-v0.cc: Likewise. * tests/data/test-abicompat/test3-fn-removed-v1.cc: Likewise. * tests/data/test-abicompat/test3-fn-removed-version-script-0 Likewise.: * tests/data/test-abicompat/test3-fn-removed-version-script-1: Likewise. * tests/data/Makefile.am: Add the new test inputs above to the source distribution. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-11-30 17:18:55 +00:00
$ cat -n test-app.cc
1 // Compile with:
2 // g++ -g -Wall -o test-app -L. -ltest-0 test-app.cc
Add support for abicompat weak mode This patch implements the weak mode of abicompat. In this mode, just the application and the new version of the library are provided. The types of functions and variables of the library that are consumed by the application are compared to the types of the functions and variables expected by the application. The goal is to check if the types of the declarations consumed by the application and provided by the library are compatible with what the application expects. The abicompat first gets the set of symbols undefined in the application and exported by the library. It then builds the set of declarations exported by the library that have those symbols. We call these the set of declarations of the library that are consumed by the application. Note that the debug information for the application does not contain the declarations of the functions/variables whose symbols are undefined. So we can not just read them to compare them to declarations exported by the library. But the *types* of the variables and the *sub-types* of the functions whose symbols are undefined in the application are present in the debug information of the application. So in the weak mode, abicompat compare the *types* of the declarations consumed by the application as expected by the application (described by the debug information of the application) with the types of the declarations exported by the library. To do this a number of changes were necessary. The patch builds a representation of all the types found in the application's debug info. Before that, only the types that are reachable from exported declarations were represented. The abidw tool got a new --load-all-types to test this new ability of loading all types. The patch also adds support for looking a type, not by name, but by its internal representation. In the comparison engine, function_type_diff is introduced to represent changes between two function types. For this, a new class type_or_decl_base has been introduced in the IR. It's now the base class for both decl_base and type_base. And abigail::comparison::diff now takes two pointers of type_or_decl, not decl_base anymore. So function_type_diff can take two function_type now; not that a function_type has no declaration so it doesn't inherit decl_base. A bunch of changes got made just to adjust to this modification. A number of fixes were made too, to make this work, like adding missing comparison operators, removing asserts that too strong, etc.. The patch also adjust the test suite as well as the documentation. * include/abg-fwd.h (class type_or_decl_base): Forward declare this. (is_decl, is_type, is_function_type, get_name, get_type_name) (get_function_type_name, get_pretty_representation) (lookup_function_type_in_corpus, lookup_type_in_translation_unit) (lookup_function_type_in_translation_unit) (synthesize_function_type_from_translation_unit) (hash_type_or_decl): New function declarations. * src/abg-corpus.cc (lookup_type_in_corpus) (lookup_function_type_in_corpus): Define new functions. * include/abg-ir.h (translation_unit::lookup_function_type_in_translation_unit): Declare new friend function. (class type_or_decl_base): Declare this. (operator==(const type_or_decl_base&, const type_or_decl_base&)): Declare new operator. (operator==(const type_or_decl_base_sptr&, const type_or_decl_base_sptr&)): Likewise. (class {decl_base, type_base}): Make these class inherit type_or_decl_base. (decl_base::get_member_scopes): New const overload. (bool operator==(const function_decl::parameter_sptr&, const function_decl::parameter_sptr&)): New operator. (function_type::get_parameters): Remove the non-const overload. (function_type::get_pretty_representation): Declare new member function. (method_type::get_pretty_representation): Likewise. * src/abg-ir.cc (bool operator==(const type_or_decl_base&, const type_or_decl_base&)): Define new equality operator. (bool operator==(const type_or_decl_base_sptr&, const type_or_decl_base_sptr&)): Likewise. (strip_typedef): Do not expect canonicalized types anymore. Now the system accepts (and expects) canonicalized types in certain cases. For instance, non-complete types and aggregated types that contain non-complete sub-types. (get_name, get_function_type_name, get_type_name) (get_pretty_representation, is_decl, is_type, is_function_type) (lookup_function_type_in_translation_unit) (synthesize_function_type_from_translation_unit) (lookup_type_in_scope, lookup_type_in_translation_unit): Define new functions or new overloads. (bool operator==(const function_decl::parameter_sptr&, const function_decl::parameter_sptr& r)): Define new operator. (function_type::get_parameters): Remove non-const overload. (function_type::get_pretty_representation): Define new function. (function_type::traverse): Adjust. (method_type::get_pretty_representation): Likewise. (function_decl::get_pretty_representation): Avoid emitting the type of cdtors. (hash_type_or_decl): Define new function. * include/abg-dwarf-reader.h (create_read_context) (read_corpus_from_elf): Take a new 'read_all_types' flag. * src/abg-dwarf-reader.cc (read_context::load_all_types_): New flag. (read_context::read_context): Initialize it. (read_context::canonical_types_scheduled): If some types still have non-canonicalized sub-types, then do not canonicalize them. (read_context::load_all_types): New member functions. (build_function_decl): Do not represent void return type like empty type anymore, rather, represent it like a void type node. (build_ir_node_from_die): When asked, load all types including those that are not reachable from an exported declaration. (create_read_context, read_corpus_from_elf): Take a new 'load_all_types' flag and honour it. * src/abg-reader.cc (read_context::type_is_from_translation_unit): Support looking up function types in the current translation unit, now that we now how to lookup function types. * include/abg-comparison.h (diff_context::{has_diff_for, add_diff, set_canonical_diff_for, set_or_get_canonical_diff_for, get_canonical_diff_for}): Make these take instances of type_or_decl_base_sptr, instead of decl_base_sptr. (diff::diff): Likewise. (diff::{first_subject, second_subject}): Make these return type_or_decl_base_sptr instead of decl_base_sptr. (type_diff_base::type_diff_base): Make these take instances of type_or_decl_base_sptr instead of decl_base_sptr. (distinct_diff::distinct_diff): Likewise. (distinct_diff::{first, second}): Make these return type_or_decl_base_sptr instead of decl_base_sptr. (distinct_diff::entities_are_of_distinct_kinds): Make these take instances of type_or_decl_base_sptr instead of decl_base_sptr. (class function_type_diff): Create this new type. It's a factorization of the function_decl_diff type. * src/abg-comparison.cc (): * src/abg-comp-filter.cc ({harmless, harmful}_filter::visit): Adjust as diff::{first,second}_subject() now returns a type_or_decl_base_sptr, no more a decl_base_sptr. (decls_type, decls_diff_map_type): Remove these typedefs and replace it with ... (types_or_decls_type, types_or_decls_diff_map_type): ... these. (struct {decls_hash, decls_equals): Remove these type sand replace them with ... (struct {types_or_decls_hash, types_or_decls_equals}): ... these. ({type_suppression, variable_suppression}::suppresses_diff): Adjust. (diff_context::priv::decls_diff_map): Replace this with ... (diff_context::priv::types_or_decls_diff_map): ... this. (diff_context::{has_diff_for, add_diff, get_canonical_diff_for, set_canonical_diff_for, set_or_get_canonical_diff_for}): Take type_or_decl_base_sptr instead of decl_base_sptr. (diff::priv::{first, second}_subject): Make the type of these be type_or_decl_base_sptr, no more decl_base_sptr. (diff::priv::priv): Adjust for the subjects of the diff being of type type_or_decl_sptr now, no more decl_base_sptr. (diff_less_than_functor::operator()(const diff_sptr, const diff_sptr) const): Adjust. (diff::diff): djust for the subjects of the diff being of type type_or_decl_sptr now, no more decl_base_sptr. (diff::{first,second}_subject): Make the type of these be type_or_decl_base_sptr, no more decl_base_sptr. (report_size_and_alignment_changes): Likewise. (type_diff_base::type_diff_base): Make the type of this be type_or_decl_base_sptr instead of type_base_sptr. (distinct_diff::distinct_diff): Make this take instances of type_or_decl_base_sptr instead of decl_base_sptr. (distinct_diff::{first, second, entities_are_of_distinct_kinds}): Likewise. (distinct_diff::has_changes): Simplify logic. (distinct_diff::report): Adjust. (compute_diff_for_types): Add an additional case to support the new function_type. (report_size_and_alignment_changes): Make this take instances of type_or_decl_base_sptr instead of decl_base_sptr. (class_diff::priv::member_type_has_changed): Return an instance of type_or_decl_base_sptr rather than a decl_base_sptr. (class_diff::report): Adjust. (diff_comp::operator()(const diff&, diff&) const): Adjust. (enum function_decl_diff::priv::Flags): Remove. (function_decl_diff::priv::{first_fn_flags_, second_fn_flags_, fn_flags_changes_}): Remove. (function_decl_diff::priv::{fn_is_declared_inline_to_flag, fn_binding_to_flag}): Remove. (function_decl_diff::{deleted_parameter_at, inserted_parameter_at}): Remove. (function_decl_diff::ensure_lookup_tables_populated): Empty this. (function_decl_diff::chain_into_hierarchy): Adjust. (function_decl_diff::function_decl_diff): This now only takes the subjects. It's body is now empty. (function_decl_diff::{return_type_diff, subtype_changed_parms, removed_parms, added_parms, type_diff}): Remove these member functions. (function_decl_diff::type_diff): Define new member function. (function_decl_diff::report): Simplify logic by using the reporting of the child type diff node. (compute_diff): Likewise, in the overload for function_decl_sptr simplify logic by using the child type diff object. (function_type_diff::priv): Define new type. (function_type_diff::{function_type_diff, ensure_lookup_tables_populated, deleted_parameter_at, inserted_parameter_at, finish_diff_type, first_function_type, second_function_type, return_type_diff, subtype_changed_parms, removed_parms, added_parms, get_pretty_representation, has_changes, has_local_changes, report, chain_into_hierarchy}): Define new functions. (compute_diff): Define new overload for function_type_sptr. * tools/abicompat.cc (options::weak_mode): New data member. (options::options): Initialize it. (enum abicompat_status): New enum (abicompat_status operator|(abicompat_status, abicompat_status)) (abicompat_status& operator|=(abicompat_status &, abicompat_status)) (abicompat_status operator&(abicompat_status, abicompat_status)): New operators to manipulate the abicompat_status enum. (display_usage): Add help string for the new --weak-mode option. (parse_command_line): Add the new --weak-mode command line argument. If the tool is called with just the application and one library then assume that we are in the weak mode. (perform_compat_check_in_normal_mode): Define new function, factorized from what was in the main function. (perform_compat_check_in_weak_mode): Define new function. (struct {fn,var}_change): Define new types. (main): Use perform_compat_check_in_weak_mode() and perform_compat_check_in_normal_mode(). * tools/abidiff.cc (main): Adjust. * tools/abidw.cc: (options::load_all_types): Add new data member. (options::options): Initialize it. (display_usage): New help string for --load-all-types. (parse_command_line): Support the new --load-all-types option. (main): Adjust and honour the --load-all-types option. * tools/abilint.cc (main): Adjust. * doc/manuals/abicompat.rst: Update documentation for the new weak mode. Also provide stuff that was missing from the examples provided. * doc/manuals/abidw.rst: Update documentation for the new --load-all-types option. * tests/print-diff-tree.cc (main): Adjust. * tests/test-diff-dwarf.cc (main): Likewise. * tests/test-read-dwarf.cc (main): Likewise. * tests/data/test-abicompat/test0-fn-changed-app: Recompile this. * tests/data/test-abicompat/libtest5-fn-changed-libapp-v{0,1}.so: New new test input binaries * tests/data/test-abicompat/test5-fn-changed-app: Likewise. * tests/data/test-abicompat/test6-var-changed-app: Likewise. * tests/data/test-abicompat/libtest6-var-changed-libapp-v{0,1}.so: Likewise. * tests/data/test-abicompat/test5-fn-changed-report-0.txt: Reference output for one test above. * tests/data/test-abicompat/test6-var-changed-report-0.txt: Likewise. * tests/data/test-abicompat/test5-fn-changed-app.cc: Source file for a binary above. * tests/data/test-abicompat/test5-fn-changed-libapp-v{0,1}.{h,cc}: Likewise. * tests/data/test-abicompat/test6-var-changed-libapp-v{0,1}.{cc,h}: Likewise. * tests/data/test-abicompat/test6-var-changed-app.cc: Likewise. * tests/data/Makefile.am: Add the test related files above to the source distribution. * tests/test-abicompat.cc (in_out_spec): Add the new test input above to the list of inputs to feed to this test harness. (main): Support taking just the app and one library. * tests/data/test-read-dwarf/test{0, 1, 2.so, 3.so, 5.o, 8-qualified-this-pointer.so,}.abi: Adjust for void type being really emitted now, as opposed to just being an empty type. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-04-01 10:13:38 +00:00
3
Initial implementation of the abicompat tool Given an application A that links to a shared library L of version V denoted L(V) and a subsequent version of that library denoted L(V+P), the 'abicompat' tool tells the user if L(V+P) is still ABI compatible with L(V+P). And if it is not, abicompat gives a reports that shows the differences between L(V) and L(V+P) that makes L(V+P) ABI-incompatible with A. The source code of this tool is in the tools/abicompat.cc source file. To support this new tool, this commit changes the comparison engine to optionally avoid showing added symbols that were not referenced by any debug info. It changes the ABI corpus type to allow the specification of a list of variables and functions symbols to keep (and drop all other functions and variables which have other symbols on the floor even before starting to compare the two libraries). This is how the abicompat tool itself works. It basically compares L(V) and L(V+P) but it only looks at their exported functions and variables which symbols are undefined in application A. If the list of exported and defined variables and functions of L(V) whose symbols are undefined in A equals that of L(V+P) (including the sub-types of these variables and functions) A is still compatible with L(V+P). Otherwise, they might not be compatible depending on the kind of differences that are found. * include/abg-comparison.h (diff_context::show_added_symbols_unreferenced_by_debug_info): Declare new accessors. (corpus_diff::{deleted_variables, deleted_unrefed_function_symbols, deleted_unrefed_variable_symbols, apply_filters_and_suppressions_before_reporting}): Declare new methods. (corpus_diff::diff_stats): Declare this new type. Actually this was previously corpus_diff::priv::diff_stats, which was a hidden internal type.. We are moving it here, in the external API so that client code can have more information about changes statistics. Change all the previously publicly accessible data members into accessor functions. * src/abg-comparison.cc (class corpus_diff::diff_stats::priv): New type. (diff_context::priv::show_added_syms_unreferenced_by_di_): New data member. (diff_context::priv::priv): Adjust. (diff_context::show_added_symbols_unreferenced_by_debug_info): Define this new method. (corpus_diff::priv::emit_diff_stats): Do not show the diff stat if the only changes is added function or variables symbols and if we were instructed to not show added symbols. (corpus_diff::priv::{diff_stats_, filters_and_suppr_applied_}): New data members. (corpus_diff::priv::priv): Initialize the filters_and_suppr_applied_ data member. (corpus_diff::priv::diff_stats): Move this type to corpus_diff::diff_stats. (corpus_diff::priv::{apply_filters_and_compute_diff_stats, emit_diff_stats}): Adjust. (corpus_diff::apply_filters_and_suppressions_before_reporting): Define new member function. (corpus_diff::report): Use the new apply_filters_and_suppressions_before_reporting() function, rather than applying the filters and suppressions by ourselves. Also adjust to the use the accessors of the new corpus_diff::diff_stats type. (corpus_diff::{deleted_variables, deleted_unrefed_function_symbols, deleted_unrefed_variable_symbols}): Define new accessors. (corpus_diff::diff_stats::{diff_stats, num_func_removed, num_func_added, num_func_changed, num_func_filtered_out, net_num_func_changed, num_vars_removed, num_vars_added, num_vars_changed, num_vars_filtered_out, net_num_vars_changed, num_func_sym_removed, num_func_syms_added, num_var_syms_removed, num_var_syms_added}): Define new member functions. * include/abg-corpus.h (corpus::{get_sym_ids_of_fns_to_keep, get_sym_ids_of_vars_to_keep}): Declare new methods. * src/abg-corpus.cc (corpus::priv::{sym_id_fns_to_keep, sym_id_vars_to_keep}): Added data members. (symtab_build_visitor_type::{unrefed_fun_symbols, unrefed_var_symbols, sym_id_fns_to_keep, sym_id_vars_to_keep}): Added new data members. (symtab_build_visitor_type::symtab_build_visitor_type): Take two additional parameters for the function and variable symbol ids to keep. (symtab_build_visitor_type::add_fn_to_wip_fns): Take the function symbols to keep in account when building the exported symbol table. (symtab_build_visitor_type::add_var_to_wip_vars): Likewise, take the variable symbols to keep in account when building the exported symbol table. (corpus::priv::build_public_decl_table): Adjust the initialization of the visitor that walks the ABI artifacts to build the exported symbol table to know take a list of function/variable symbols to keep. (corpus::priv::build_unreferenced_symbols_tables): Ensure that the public table of functions/variables is built before doing the work of this function. Also, if a list of variable/function symbols to keep is given, drop all symbols that are not in that list on the floor. (corpus::{get_sym_ids_of_fns_to_keep, get_sym_ids_of_vars_to_keep}): Define new accessors. * tools/abicompat.cc: New abicompat tool. * doc/manuals/abicompat.rst: New documentation source for abicompat. * doc/manuals/libabigail-tools.rst: Add an entry for the abicompat doc. * tests/test-abicompat.cc: New test harness for the 'abicompat' tool. * tests/Makefile.am: Build the runtestabicompat test harness and add it to the list of tests harnesses that are run by make check. * tests/data/test-abicompat/libtest0-fn-changed-libapp-v0.so: New test input. * tests/data/test-abicompat/libtest0-fn-changed-libapp-v1.so: Likewise. * tests/data/test-abicompat/test0-fn-changed-app: Likewise. * tests/data/test-abicompat/test0-fn-changed-0.suppr: Likewise * tests/data/test-abicompat/test0-fn-changed-report-0.txt: Likewise. * tests/data/test-abicompat/test0-fn-changed-report-1.txt: Likewise. * tests/data/test-abicompat/test0-fn-changed-app.cc: Likewise. * tests/data/test-abicompat/test0-fn-changed-libapp.h: Likewise. * tests/data/test-abicompat/test0-fn-changed-libapp-v0.cc: Likewise. * tests/data/test-abicompat/test0-fn-changed-libapp-v1.cc: Likewise. * tests/data/test-abicompat/libtest1-fn-removed-v0.so: Likewise. * tests/data/test-abicompat/libtest1-fn-removed-v1.so: Likewise. * tests/data/test-abicompat/test1-fn-removed-app: Likewise. * tests/data/test-abicompat/test1-fn-removed-app.cc: Likewise. * tests/data/test-abicompat/test1-fn-removed-report-0.txt: Likewise. * tests/data/test-abicompat/test1-fn-removed-v0.cc: Likewise. * tests/data/test-abicompat/test1-fn-removed-v1.cc: Likewise. * tests/data/test-abicompat/libtest2-var-removed-v0.so: Likewise. * tests/data/test-abicompat/libtest2-var-removed-v1.so: Likewise. * tests/data/test-abicompat/test2-var-removed-app: Likewise. * tests/data/test-abicompat/test2-var-removed-app.cc: Likewise. * tests/data/test-abicompat/test2-var-removed-report-0.txt: Likewise. * tests/data/test-abicompat/test2-var-removed-v0.cc: Likewise. * tests/data/test-abicompat/test2-var-removed-v1.cc: Likewise. * tests/data/test-abicompat/libtest3-fn-removed-v0.so: Likewise. * tests/data/test-abicompat/libtest3-fn-removed-v1.so: Likewise. * tests/data/test-abicompat/test3-fn-removed-app: Likewise. * tests/data/test-abicompat/test3-fn-removed-app.cc: Likewise. * tests/data/test-abicompat/test3-fn-removed-report-0.txt: Likewise. * tests/data/test-abicompat/test3-fn-removed-v0.cc: Likewise. * tests/data/test-abicompat/test3-fn-removed-v1.cc: Likewise. * tests/data/test-abicompat/test3-fn-removed-version-script-0 Likewise.: * tests/data/test-abicompat/test3-fn-removed-version-script-1: Likewise. * tests/data/Makefile.am: Add the new test inputs above to the source distribution. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-11-30 17:18:55 +00:00
4 #include "test0.h"
Add support for abicompat weak mode This patch implements the weak mode of abicompat. In this mode, just the application and the new version of the library are provided. The types of functions and variables of the library that are consumed by the application are compared to the types of the functions and variables expected by the application. The goal is to check if the types of the declarations consumed by the application and provided by the library are compatible with what the application expects. The abicompat first gets the set of symbols undefined in the application and exported by the library. It then builds the set of declarations exported by the library that have those symbols. We call these the set of declarations of the library that are consumed by the application. Note that the debug information for the application does not contain the declarations of the functions/variables whose symbols are undefined. So we can not just read them to compare them to declarations exported by the library. But the *types* of the variables and the *sub-types* of the functions whose symbols are undefined in the application are present in the debug information of the application. So in the weak mode, abicompat compare the *types* of the declarations consumed by the application as expected by the application (described by the debug information of the application) with the types of the declarations exported by the library. To do this a number of changes were necessary. The patch builds a representation of all the types found in the application's debug info. Before that, only the types that are reachable from exported declarations were represented. The abidw tool got a new --load-all-types to test this new ability of loading all types. The patch also adds support for looking a type, not by name, but by its internal representation. In the comparison engine, function_type_diff is introduced to represent changes between two function types. For this, a new class type_or_decl_base has been introduced in the IR. It's now the base class for both decl_base and type_base. And abigail::comparison::diff now takes two pointers of type_or_decl, not decl_base anymore. So function_type_diff can take two function_type now; not that a function_type has no declaration so it doesn't inherit decl_base. A bunch of changes got made just to adjust to this modification. A number of fixes were made too, to make this work, like adding missing comparison operators, removing asserts that too strong, etc.. The patch also adjust the test suite as well as the documentation. * include/abg-fwd.h (class type_or_decl_base): Forward declare this. (is_decl, is_type, is_function_type, get_name, get_type_name) (get_function_type_name, get_pretty_representation) (lookup_function_type_in_corpus, lookup_type_in_translation_unit) (lookup_function_type_in_translation_unit) (synthesize_function_type_from_translation_unit) (hash_type_or_decl): New function declarations. * src/abg-corpus.cc (lookup_type_in_corpus) (lookup_function_type_in_corpus): Define new functions. * include/abg-ir.h (translation_unit::lookup_function_type_in_translation_unit): Declare new friend function. (class type_or_decl_base): Declare this. (operator==(const type_or_decl_base&, const type_or_decl_base&)): Declare new operator. (operator==(const type_or_decl_base_sptr&, const type_or_decl_base_sptr&)): Likewise. (class {decl_base, type_base}): Make these class inherit type_or_decl_base. (decl_base::get_member_scopes): New const overload. (bool operator==(const function_decl::parameter_sptr&, const function_decl::parameter_sptr&)): New operator. (function_type::get_parameters): Remove the non-const overload. (function_type::get_pretty_representation): Declare new member function. (method_type::get_pretty_representation): Likewise. * src/abg-ir.cc (bool operator==(const type_or_decl_base&, const type_or_decl_base&)): Define new equality operator. (bool operator==(const type_or_decl_base_sptr&, const type_or_decl_base_sptr&)): Likewise. (strip_typedef): Do not expect canonicalized types anymore. Now the system accepts (and expects) canonicalized types in certain cases. For instance, non-complete types and aggregated types that contain non-complete sub-types. (get_name, get_function_type_name, get_type_name) (get_pretty_representation, is_decl, is_type, is_function_type) (lookup_function_type_in_translation_unit) (synthesize_function_type_from_translation_unit) (lookup_type_in_scope, lookup_type_in_translation_unit): Define new functions or new overloads. (bool operator==(const function_decl::parameter_sptr&, const function_decl::parameter_sptr& r)): Define new operator. (function_type::get_parameters): Remove non-const overload. (function_type::get_pretty_representation): Define new function. (function_type::traverse): Adjust. (method_type::get_pretty_representation): Likewise. (function_decl::get_pretty_representation): Avoid emitting the type of cdtors. (hash_type_or_decl): Define new function. * include/abg-dwarf-reader.h (create_read_context) (read_corpus_from_elf): Take a new 'read_all_types' flag. * src/abg-dwarf-reader.cc (read_context::load_all_types_): New flag. (read_context::read_context): Initialize it. (read_context::canonical_types_scheduled): If some types still have non-canonicalized sub-types, then do not canonicalize them. (read_context::load_all_types): New member functions. (build_function_decl): Do not represent void return type like empty type anymore, rather, represent it like a void type node. (build_ir_node_from_die): When asked, load all types including those that are not reachable from an exported declaration. (create_read_context, read_corpus_from_elf): Take a new 'load_all_types' flag and honour it. * src/abg-reader.cc (read_context::type_is_from_translation_unit): Support looking up function types in the current translation unit, now that we now how to lookup function types. * include/abg-comparison.h (diff_context::{has_diff_for, add_diff, set_canonical_diff_for, set_or_get_canonical_diff_for, get_canonical_diff_for}): Make these take instances of type_or_decl_base_sptr, instead of decl_base_sptr. (diff::diff): Likewise. (diff::{first_subject, second_subject}): Make these return type_or_decl_base_sptr instead of decl_base_sptr. (type_diff_base::type_diff_base): Make these take instances of type_or_decl_base_sptr instead of decl_base_sptr. (distinct_diff::distinct_diff): Likewise. (distinct_diff::{first, second}): Make these return type_or_decl_base_sptr instead of decl_base_sptr. (distinct_diff::entities_are_of_distinct_kinds): Make these take instances of type_or_decl_base_sptr instead of decl_base_sptr. (class function_type_diff): Create this new type. It's a factorization of the function_decl_diff type. * src/abg-comparison.cc (): * src/abg-comp-filter.cc ({harmless, harmful}_filter::visit): Adjust as diff::{first,second}_subject() now returns a type_or_decl_base_sptr, no more a decl_base_sptr. (decls_type, decls_diff_map_type): Remove these typedefs and replace it with ... (types_or_decls_type, types_or_decls_diff_map_type): ... these. (struct {decls_hash, decls_equals): Remove these type sand replace them with ... (struct {types_or_decls_hash, types_or_decls_equals}): ... these. ({type_suppression, variable_suppression}::suppresses_diff): Adjust. (diff_context::priv::decls_diff_map): Replace this with ... (diff_context::priv::types_or_decls_diff_map): ... this. (diff_context::{has_diff_for, add_diff, get_canonical_diff_for, set_canonical_diff_for, set_or_get_canonical_diff_for}): Take type_or_decl_base_sptr instead of decl_base_sptr. (diff::priv::{first, second}_subject): Make the type of these be type_or_decl_base_sptr, no more decl_base_sptr. (diff::priv::priv): Adjust for the subjects of the diff being of type type_or_decl_sptr now, no more decl_base_sptr. (diff_less_than_functor::operator()(const diff_sptr, const diff_sptr) const): Adjust. (diff::diff): djust for the subjects of the diff being of type type_or_decl_sptr now, no more decl_base_sptr. (diff::{first,second}_subject): Make the type of these be type_or_decl_base_sptr, no more decl_base_sptr. (report_size_and_alignment_changes): Likewise. (type_diff_base::type_diff_base): Make the type of this be type_or_decl_base_sptr instead of type_base_sptr. (distinct_diff::distinct_diff): Make this take instances of type_or_decl_base_sptr instead of decl_base_sptr. (distinct_diff::{first, second, entities_are_of_distinct_kinds}): Likewise. (distinct_diff::has_changes): Simplify logic. (distinct_diff::report): Adjust. (compute_diff_for_types): Add an additional case to support the new function_type. (report_size_and_alignment_changes): Make this take instances of type_or_decl_base_sptr instead of decl_base_sptr. (class_diff::priv::member_type_has_changed): Return an instance of type_or_decl_base_sptr rather than a decl_base_sptr. (class_diff::report): Adjust. (diff_comp::operator()(const diff&, diff&) const): Adjust. (enum function_decl_diff::priv::Flags): Remove. (function_decl_diff::priv::{first_fn_flags_, second_fn_flags_, fn_flags_changes_}): Remove. (function_decl_diff::priv::{fn_is_declared_inline_to_flag, fn_binding_to_flag}): Remove. (function_decl_diff::{deleted_parameter_at, inserted_parameter_at}): Remove. (function_decl_diff::ensure_lookup_tables_populated): Empty this. (function_decl_diff::chain_into_hierarchy): Adjust. (function_decl_diff::function_decl_diff): This now only takes the subjects. It's body is now empty. (function_decl_diff::{return_type_diff, subtype_changed_parms, removed_parms, added_parms, type_diff}): Remove these member functions. (function_decl_diff::type_diff): Define new member function. (function_decl_diff::report): Simplify logic by using the reporting of the child type diff node. (compute_diff): Likewise, in the overload for function_decl_sptr simplify logic by using the child type diff object. (function_type_diff::priv): Define new type. (function_type_diff::{function_type_diff, ensure_lookup_tables_populated, deleted_parameter_at, inserted_parameter_at, finish_diff_type, first_function_type, second_function_type, return_type_diff, subtype_changed_parms, removed_parms, added_parms, get_pretty_representation, has_changes, has_local_changes, report, chain_into_hierarchy}): Define new functions. (compute_diff): Define new overload for function_type_sptr. * tools/abicompat.cc (options::weak_mode): New data member. (options::options): Initialize it. (enum abicompat_status): New enum (abicompat_status operator|(abicompat_status, abicompat_status)) (abicompat_status& operator|=(abicompat_status &, abicompat_status)) (abicompat_status operator&(abicompat_status, abicompat_status)): New operators to manipulate the abicompat_status enum. (display_usage): Add help string for the new --weak-mode option. (parse_command_line): Add the new --weak-mode command line argument. If the tool is called with just the application and one library then assume that we are in the weak mode. (perform_compat_check_in_normal_mode): Define new function, factorized from what was in the main function. (perform_compat_check_in_weak_mode): Define new function. (struct {fn,var}_change): Define new types. (main): Use perform_compat_check_in_weak_mode() and perform_compat_check_in_normal_mode(). * tools/abidiff.cc (main): Adjust. * tools/abidw.cc: (options::load_all_types): Add new data member. (options::options): Initialize it. (display_usage): New help string for --load-all-types. (parse_command_line): Support the new --load-all-types option. (main): Adjust and honour the --load-all-types option. * tools/abilint.cc (main): Adjust. * doc/manuals/abicompat.rst: Update documentation for the new weak mode. Also provide stuff that was missing from the examples provided. * doc/manuals/abidw.rst: Update documentation for the new --load-all-types option. * tests/print-diff-tree.cc (main): Adjust. * tests/test-diff-dwarf.cc (main): Likewise. * tests/test-read-dwarf.cc (main): Likewise. * tests/data/test-abicompat/test0-fn-changed-app: Recompile this. * tests/data/test-abicompat/libtest5-fn-changed-libapp-v{0,1}.so: New new test input binaries * tests/data/test-abicompat/test5-fn-changed-app: Likewise. * tests/data/test-abicompat/test6-var-changed-app: Likewise. * tests/data/test-abicompat/libtest6-var-changed-libapp-v{0,1}.so: Likewise. * tests/data/test-abicompat/test5-fn-changed-report-0.txt: Reference output for one test above. * tests/data/test-abicompat/test6-var-changed-report-0.txt: Likewise. * tests/data/test-abicompat/test5-fn-changed-app.cc: Source file for a binary above. * tests/data/test-abicompat/test5-fn-changed-libapp-v{0,1}.{h,cc}: Likewise. * tests/data/test-abicompat/test6-var-changed-libapp-v{0,1}.{cc,h}: Likewise. * tests/data/test-abicompat/test6-var-changed-app.cc: Likewise. * tests/data/Makefile.am: Add the test related files above to the source distribution. * tests/test-abicompat.cc (in_out_spec): Add the new test input above to the list of inputs to feed to this test harness. (main): Support taking just the app and one library. * tests/data/test-read-dwarf/test{0, 1, 2.so, 3.so, 5.o, 8-qualified-this-pointer.so,}.abi: Adjust for void type being really emitted now, as opposed to just being an empty type. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-04-01 10:13:38 +00:00
5
Initial implementation of the abicompat tool Given an application A that links to a shared library L of version V denoted L(V) and a subsequent version of that library denoted L(V+P), the 'abicompat' tool tells the user if L(V+P) is still ABI compatible with L(V+P). And if it is not, abicompat gives a reports that shows the differences between L(V) and L(V+P) that makes L(V+P) ABI-incompatible with A. The source code of this tool is in the tools/abicompat.cc source file. To support this new tool, this commit changes the comparison engine to optionally avoid showing added symbols that were not referenced by any debug info. It changes the ABI corpus type to allow the specification of a list of variables and functions symbols to keep (and drop all other functions and variables which have other symbols on the floor even before starting to compare the two libraries). This is how the abicompat tool itself works. It basically compares L(V) and L(V+P) but it only looks at their exported functions and variables which symbols are undefined in application A. If the list of exported and defined variables and functions of L(V) whose symbols are undefined in A equals that of L(V+P) (including the sub-types of these variables and functions) A is still compatible with L(V+P). Otherwise, they might not be compatible depending on the kind of differences that are found. * include/abg-comparison.h (diff_context::show_added_symbols_unreferenced_by_debug_info): Declare new accessors. (corpus_diff::{deleted_variables, deleted_unrefed_function_symbols, deleted_unrefed_variable_symbols, apply_filters_and_suppressions_before_reporting}): Declare new methods. (corpus_diff::diff_stats): Declare this new type. Actually this was previously corpus_diff::priv::diff_stats, which was a hidden internal type.. We are moving it here, in the external API so that client code can have more information about changes statistics. Change all the previously publicly accessible data members into accessor functions. * src/abg-comparison.cc (class corpus_diff::diff_stats::priv): New type. (diff_context::priv::show_added_syms_unreferenced_by_di_): New data member. (diff_context::priv::priv): Adjust. (diff_context::show_added_symbols_unreferenced_by_debug_info): Define this new method. (corpus_diff::priv::emit_diff_stats): Do not show the diff stat if the only changes is added function or variables symbols and if we were instructed to not show added symbols. (corpus_diff::priv::{diff_stats_, filters_and_suppr_applied_}): New data members. (corpus_diff::priv::priv): Initialize the filters_and_suppr_applied_ data member. (corpus_diff::priv::diff_stats): Move this type to corpus_diff::diff_stats. (corpus_diff::priv::{apply_filters_and_compute_diff_stats, emit_diff_stats}): Adjust. (corpus_diff::apply_filters_and_suppressions_before_reporting): Define new member function. (corpus_diff::report): Use the new apply_filters_and_suppressions_before_reporting() function, rather than applying the filters and suppressions by ourselves. Also adjust to the use the accessors of the new corpus_diff::diff_stats type. (corpus_diff::{deleted_variables, deleted_unrefed_function_symbols, deleted_unrefed_variable_symbols}): Define new accessors. (corpus_diff::diff_stats::{diff_stats, num_func_removed, num_func_added, num_func_changed, num_func_filtered_out, net_num_func_changed, num_vars_removed, num_vars_added, num_vars_changed, num_vars_filtered_out, net_num_vars_changed, num_func_sym_removed, num_func_syms_added, num_var_syms_removed, num_var_syms_added}): Define new member functions. * include/abg-corpus.h (corpus::{get_sym_ids_of_fns_to_keep, get_sym_ids_of_vars_to_keep}): Declare new methods. * src/abg-corpus.cc (corpus::priv::{sym_id_fns_to_keep, sym_id_vars_to_keep}): Added data members. (symtab_build_visitor_type::{unrefed_fun_symbols, unrefed_var_symbols, sym_id_fns_to_keep, sym_id_vars_to_keep}): Added new data members. (symtab_build_visitor_type::symtab_build_visitor_type): Take two additional parameters for the function and variable symbol ids to keep. (symtab_build_visitor_type::add_fn_to_wip_fns): Take the function symbols to keep in account when building the exported symbol table. (symtab_build_visitor_type::add_var_to_wip_vars): Likewise, take the variable symbols to keep in account when building the exported symbol table. (corpus::priv::build_public_decl_table): Adjust the initialization of the visitor that walks the ABI artifacts to build the exported symbol table to know take a list of function/variable symbols to keep. (corpus::priv::build_unreferenced_symbols_tables): Ensure that the public table of functions/variables is built before doing the work of this function. Also, if a list of variable/function symbols to keep is given, drop all symbols that are not in that list on the floor. (corpus::{get_sym_ids_of_fns_to_keep, get_sym_ids_of_vars_to_keep}): Define new accessors. * tools/abicompat.cc: New abicompat tool. * doc/manuals/abicompat.rst: New documentation source for abicompat. * doc/manuals/libabigail-tools.rst: Add an entry for the abicompat doc. * tests/test-abicompat.cc: New test harness for the 'abicompat' tool. * tests/Makefile.am: Build the runtestabicompat test harness and add it to the list of tests harnesses that are run by make check. * tests/data/test-abicompat/libtest0-fn-changed-libapp-v0.so: New test input. * tests/data/test-abicompat/libtest0-fn-changed-libapp-v1.so: Likewise. * tests/data/test-abicompat/test0-fn-changed-app: Likewise. * tests/data/test-abicompat/test0-fn-changed-0.suppr: Likewise * tests/data/test-abicompat/test0-fn-changed-report-0.txt: Likewise. * tests/data/test-abicompat/test0-fn-changed-report-1.txt: Likewise. * tests/data/test-abicompat/test0-fn-changed-app.cc: Likewise. * tests/data/test-abicompat/test0-fn-changed-libapp.h: Likewise. * tests/data/test-abicompat/test0-fn-changed-libapp-v0.cc: Likewise. * tests/data/test-abicompat/test0-fn-changed-libapp-v1.cc: Likewise. * tests/data/test-abicompat/libtest1-fn-removed-v0.so: Likewise. * tests/data/test-abicompat/libtest1-fn-removed-v1.so: Likewise. * tests/data/test-abicompat/test1-fn-removed-app: Likewise. * tests/data/test-abicompat/test1-fn-removed-app.cc: Likewise. * tests/data/test-abicompat/test1-fn-removed-report-0.txt: Likewise. * tests/data/test-abicompat/test1-fn-removed-v0.cc: Likewise. * tests/data/test-abicompat/test1-fn-removed-v1.cc: Likewise. * tests/data/test-abicompat/libtest2-var-removed-v0.so: Likewise. * tests/data/test-abicompat/libtest2-var-removed-v1.so: Likewise. * tests/data/test-abicompat/test2-var-removed-app: Likewise. * tests/data/test-abicompat/test2-var-removed-app.cc: Likewise. * tests/data/test-abicompat/test2-var-removed-report-0.txt: Likewise. * tests/data/test-abicompat/test2-var-removed-v0.cc: Likewise. * tests/data/test-abicompat/test2-var-removed-v1.cc: Likewise. * tests/data/test-abicompat/libtest3-fn-removed-v0.so: Likewise. * tests/data/test-abicompat/libtest3-fn-removed-v1.so: Likewise. * tests/data/test-abicompat/test3-fn-removed-app: Likewise. * tests/data/test-abicompat/test3-fn-removed-app.cc: Likewise. * tests/data/test-abicompat/test3-fn-removed-report-0.txt: Likewise. * tests/data/test-abicompat/test3-fn-removed-v0.cc: Likewise. * tests/data/test-abicompat/test3-fn-removed-v1.cc: Likewise. * tests/data/test-abicompat/test3-fn-removed-version-script-0 Likewise.: * tests/data/test-abicompat/test3-fn-removed-version-script-1: Likewise. * tests/data/Makefile.am: Add the new test inputs above to the source distribution. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-11-30 17:18:55 +00:00
6 int
7 main()
8 {
9 foo* f = first_func();
10 second_func(*f);
11 return 0;
12 }
$
Add support for abicompat weak mode This patch implements the weak mode of abicompat. In this mode, just the application and the new version of the library are provided. The types of functions and variables of the library that are consumed by the application are compared to the types of the functions and variables expected by the application. The goal is to check if the types of the declarations consumed by the application and provided by the library are compatible with what the application expects. The abicompat first gets the set of symbols undefined in the application and exported by the library. It then builds the set of declarations exported by the library that have those symbols. We call these the set of declarations of the library that are consumed by the application. Note that the debug information for the application does not contain the declarations of the functions/variables whose symbols are undefined. So we can not just read them to compare them to declarations exported by the library. But the *types* of the variables and the *sub-types* of the functions whose symbols are undefined in the application are present in the debug information of the application. So in the weak mode, abicompat compare the *types* of the declarations consumed by the application as expected by the application (described by the debug information of the application) with the types of the declarations exported by the library. To do this a number of changes were necessary. The patch builds a representation of all the types found in the application's debug info. Before that, only the types that are reachable from exported declarations were represented. The abidw tool got a new --load-all-types to test this new ability of loading all types. The patch also adds support for looking a type, not by name, but by its internal representation. In the comparison engine, function_type_diff is introduced to represent changes between two function types. For this, a new class type_or_decl_base has been introduced in the IR. It's now the base class for both decl_base and type_base. And abigail::comparison::diff now takes two pointers of type_or_decl, not decl_base anymore. So function_type_diff can take two function_type now; not that a function_type has no declaration so it doesn't inherit decl_base. A bunch of changes got made just to adjust to this modification. A number of fixes were made too, to make this work, like adding missing comparison operators, removing asserts that too strong, etc.. The patch also adjust the test suite as well as the documentation. * include/abg-fwd.h (class type_or_decl_base): Forward declare this. (is_decl, is_type, is_function_type, get_name, get_type_name) (get_function_type_name, get_pretty_representation) (lookup_function_type_in_corpus, lookup_type_in_translation_unit) (lookup_function_type_in_translation_unit) (synthesize_function_type_from_translation_unit) (hash_type_or_decl): New function declarations. * src/abg-corpus.cc (lookup_type_in_corpus) (lookup_function_type_in_corpus): Define new functions. * include/abg-ir.h (translation_unit::lookup_function_type_in_translation_unit): Declare new friend function. (class type_or_decl_base): Declare this. (operator==(const type_or_decl_base&, const type_or_decl_base&)): Declare new operator. (operator==(const type_or_decl_base_sptr&, const type_or_decl_base_sptr&)): Likewise. (class {decl_base, type_base}): Make these class inherit type_or_decl_base. (decl_base::get_member_scopes): New const overload. (bool operator==(const function_decl::parameter_sptr&, const function_decl::parameter_sptr&)): New operator. (function_type::get_parameters): Remove the non-const overload. (function_type::get_pretty_representation): Declare new member function. (method_type::get_pretty_representation): Likewise. * src/abg-ir.cc (bool operator==(const type_or_decl_base&, const type_or_decl_base&)): Define new equality operator. (bool operator==(const type_or_decl_base_sptr&, const type_or_decl_base_sptr&)): Likewise. (strip_typedef): Do not expect canonicalized types anymore. Now the system accepts (and expects) canonicalized types in certain cases. For instance, non-complete types and aggregated types that contain non-complete sub-types. (get_name, get_function_type_name, get_type_name) (get_pretty_representation, is_decl, is_type, is_function_type) (lookup_function_type_in_translation_unit) (synthesize_function_type_from_translation_unit) (lookup_type_in_scope, lookup_type_in_translation_unit): Define new functions or new overloads. (bool operator==(const function_decl::parameter_sptr&, const function_decl::parameter_sptr& r)): Define new operator. (function_type::get_parameters): Remove non-const overload. (function_type::get_pretty_representation): Define new function. (function_type::traverse): Adjust. (method_type::get_pretty_representation): Likewise. (function_decl::get_pretty_representation): Avoid emitting the type of cdtors. (hash_type_or_decl): Define new function. * include/abg-dwarf-reader.h (create_read_context) (read_corpus_from_elf): Take a new 'read_all_types' flag. * src/abg-dwarf-reader.cc (read_context::load_all_types_): New flag. (read_context::read_context): Initialize it. (read_context::canonical_types_scheduled): If some types still have non-canonicalized sub-types, then do not canonicalize them. (read_context::load_all_types): New member functions. (build_function_decl): Do not represent void return type like empty type anymore, rather, represent it like a void type node. (build_ir_node_from_die): When asked, load all types including those that are not reachable from an exported declaration. (create_read_context, read_corpus_from_elf): Take a new 'load_all_types' flag and honour it. * src/abg-reader.cc (read_context::type_is_from_translation_unit): Support looking up function types in the current translation unit, now that we now how to lookup function types. * include/abg-comparison.h (diff_context::{has_diff_for, add_diff, set_canonical_diff_for, set_or_get_canonical_diff_for, get_canonical_diff_for}): Make these take instances of type_or_decl_base_sptr, instead of decl_base_sptr. (diff::diff): Likewise. (diff::{first_subject, second_subject}): Make these return type_or_decl_base_sptr instead of decl_base_sptr. (type_diff_base::type_diff_base): Make these take instances of type_or_decl_base_sptr instead of decl_base_sptr. (distinct_diff::distinct_diff): Likewise. (distinct_diff::{first, second}): Make these return type_or_decl_base_sptr instead of decl_base_sptr. (distinct_diff::entities_are_of_distinct_kinds): Make these take instances of type_or_decl_base_sptr instead of decl_base_sptr. (class function_type_diff): Create this new type. It's a factorization of the function_decl_diff type. * src/abg-comparison.cc (): * src/abg-comp-filter.cc ({harmless, harmful}_filter::visit): Adjust as diff::{first,second}_subject() now returns a type_or_decl_base_sptr, no more a decl_base_sptr. (decls_type, decls_diff_map_type): Remove these typedefs and replace it with ... (types_or_decls_type, types_or_decls_diff_map_type): ... these. (struct {decls_hash, decls_equals): Remove these type sand replace them with ... (struct {types_or_decls_hash, types_or_decls_equals}): ... these. ({type_suppression, variable_suppression}::suppresses_diff): Adjust. (diff_context::priv::decls_diff_map): Replace this with ... (diff_context::priv::types_or_decls_diff_map): ... this. (diff_context::{has_diff_for, add_diff, get_canonical_diff_for, set_canonical_diff_for, set_or_get_canonical_diff_for}): Take type_or_decl_base_sptr instead of decl_base_sptr. (diff::priv::{first, second}_subject): Make the type of these be type_or_decl_base_sptr, no more decl_base_sptr. (diff::priv::priv): Adjust for the subjects of the diff being of type type_or_decl_sptr now, no more decl_base_sptr. (diff_less_than_functor::operator()(const diff_sptr, const diff_sptr) const): Adjust. (diff::diff): djust for the subjects of the diff being of type type_or_decl_sptr now, no more decl_base_sptr. (diff::{first,second}_subject): Make the type of these be type_or_decl_base_sptr, no more decl_base_sptr. (report_size_and_alignment_changes): Likewise. (type_diff_base::type_diff_base): Make the type of this be type_or_decl_base_sptr instead of type_base_sptr. (distinct_diff::distinct_diff): Make this take instances of type_or_decl_base_sptr instead of decl_base_sptr. (distinct_diff::{first, second, entities_are_of_distinct_kinds}): Likewise. (distinct_diff::has_changes): Simplify logic. (distinct_diff::report): Adjust. (compute_diff_for_types): Add an additional case to support the new function_type. (report_size_and_alignment_changes): Make this take instances of type_or_decl_base_sptr instead of decl_base_sptr. (class_diff::priv::member_type_has_changed): Return an instance of type_or_decl_base_sptr rather than a decl_base_sptr. (class_diff::report): Adjust. (diff_comp::operator()(const diff&, diff&) const): Adjust. (enum function_decl_diff::priv::Flags): Remove. (function_decl_diff::priv::{first_fn_flags_, second_fn_flags_, fn_flags_changes_}): Remove. (function_decl_diff::priv::{fn_is_declared_inline_to_flag, fn_binding_to_flag}): Remove. (function_decl_diff::{deleted_parameter_at, inserted_parameter_at}): Remove. (function_decl_diff::ensure_lookup_tables_populated): Empty this. (function_decl_diff::chain_into_hierarchy): Adjust. (function_decl_diff::function_decl_diff): This now only takes the subjects. It's body is now empty. (function_decl_diff::{return_type_diff, subtype_changed_parms, removed_parms, added_parms, type_diff}): Remove these member functions. (function_decl_diff::type_diff): Define new member function. (function_decl_diff::report): Simplify logic by using the reporting of the child type diff node. (compute_diff): Likewise, in the overload for function_decl_sptr simplify logic by using the child type diff object. (function_type_diff::priv): Define new type. (function_type_diff::{function_type_diff, ensure_lookup_tables_populated, deleted_parameter_at, inserted_parameter_at, finish_diff_type, first_function_type, second_function_type, return_type_diff, subtype_changed_parms, removed_parms, added_parms, get_pretty_representation, has_changes, has_local_changes, report, chain_into_hierarchy}): Define new functions. (compute_diff): Define new overload for function_type_sptr. * tools/abicompat.cc (options::weak_mode): New data member. (options::options): Initialize it. (enum abicompat_status): New enum (abicompat_status operator|(abicompat_status, abicompat_status)) (abicompat_status& operator|=(abicompat_status &, abicompat_status)) (abicompat_status operator&(abicompat_status, abicompat_status)): New operators to manipulate the abicompat_status enum. (display_usage): Add help string for the new --weak-mode option. (parse_command_line): Add the new --weak-mode command line argument. If the tool is called with just the application and one library then assume that we are in the weak mode. (perform_compat_check_in_normal_mode): Define new function, factorized from what was in the main function. (perform_compat_check_in_weak_mode): Define new function. (struct {fn,var}_change): Define new types. (main): Use perform_compat_check_in_weak_mode() and perform_compat_check_in_normal_mode(). * tools/abidiff.cc (main): Adjust. * tools/abidw.cc: (options::load_all_types): Add new data member. (options::options): Initialize it. (display_usage): New help string for --load-all-types. (parse_command_line): Support the new --load-all-types option. (main): Adjust and honour the --load-all-types option. * tools/abilint.cc (main): Adjust. * doc/manuals/abicompat.rst: Update documentation for the new weak mode. Also provide stuff that was missing from the examples provided. * doc/manuals/abidw.rst: Update documentation for the new --load-all-types option. * tests/print-diff-tree.cc (main): Adjust. * tests/test-diff-dwarf.cc (main): Likewise. * tests/test-read-dwarf.cc (main): Likewise. * tests/data/test-abicompat/test0-fn-changed-app: Recompile this. * tests/data/test-abicompat/libtest5-fn-changed-libapp-v{0,1}.so: New new test input binaries * tests/data/test-abicompat/test5-fn-changed-app: Likewise. * tests/data/test-abicompat/test6-var-changed-app: Likewise. * tests/data/test-abicompat/libtest6-var-changed-libapp-v{0,1}.so: Likewise. * tests/data/test-abicompat/test5-fn-changed-report-0.txt: Reference output for one test above. * tests/data/test-abicompat/test6-var-changed-report-0.txt: Likewise. * tests/data/test-abicompat/test5-fn-changed-app.cc: Source file for a binary above. * tests/data/test-abicompat/test5-fn-changed-libapp-v{0,1}.{h,cc}: Likewise. * tests/data/test-abicompat/test6-var-changed-libapp-v{0,1}.{cc,h}: Likewise. * tests/data/test-abicompat/test6-var-changed-app.cc: Likewise. * tests/data/Makefile.am: Add the test related files above to the source distribution. * tests/test-abicompat.cc (in_out_spec): Add the new test input above to the list of inputs to feed to this test harness. (main): Support taking just the app and one library. * tests/data/test-read-dwarf/test{0, 1, 2.so, 3.so, 5.o, 8-qualified-this-pointer.so,}.abi: Adjust for void type being really emitted now, as opposed to just being an empty type. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-04-01 10:13:38 +00:00
Initial implementation of the abicompat tool Given an application A that links to a shared library L of version V denoted L(V) and a subsequent version of that library denoted L(V+P), the 'abicompat' tool tells the user if L(V+P) is still ABI compatible with L(V+P). And if it is not, abicompat gives a reports that shows the differences between L(V) and L(V+P) that makes L(V+P) ABI-incompatible with A. The source code of this tool is in the tools/abicompat.cc source file. To support this new tool, this commit changes the comparison engine to optionally avoid showing added symbols that were not referenced by any debug info. It changes the ABI corpus type to allow the specification of a list of variables and functions symbols to keep (and drop all other functions and variables which have other symbols on the floor even before starting to compare the two libraries). This is how the abicompat tool itself works. It basically compares L(V) and L(V+P) but it only looks at their exported functions and variables which symbols are undefined in application A. If the list of exported and defined variables and functions of L(V) whose symbols are undefined in A equals that of L(V+P) (including the sub-types of these variables and functions) A is still compatible with L(V+P). Otherwise, they might not be compatible depending on the kind of differences that are found. * include/abg-comparison.h (diff_context::show_added_symbols_unreferenced_by_debug_info): Declare new accessors. (corpus_diff::{deleted_variables, deleted_unrefed_function_symbols, deleted_unrefed_variable_symbols, apply_filters_and_suppressions_before_reporting}): Declare new methods. (corpus_diff::diff_stats): Declare this new type. Actually this was previously corpus_diff::priv::diff_stats, which was a hidden internal type.. We are moving it here, in the external API so that client code can have more information about changes statistics. Change all the previously publicly accessible data members into accessor functions. * src/abg-comparison.cc (class corpus_diff::diff_stats::priv): New type. (diff_context::priv::show_added_syms_unreferenced_by_di_): New data member. (diff_context::priv::priv): Adjust. (diff_context::show_added_symbols_unreferenced_by_debug_info): Define this new method. (corpus_diff::priv::emit_diff_stats): Do not show the diff stat if the only changes is added function or variables symbols and if we were instructed to not show added symbols. (corpus_diff::priv::{diff_stats_, filters_and_suppr_applied_}): New data members. (corpus_diff::priv::priv): Initialize the filters_and_suppr_applied_ data member. (corpus_diff::priv::diff_stats): Move this type to corpus_diff::diff_stats. (corpus_diff::priv::{apply_filters_and_compute_diff_stats, emit_diff_stats}): Adjust. (corpus_diff::apply_filters_and_suppressions_before_reporting): Define new member function. (corpus_diff::report): Use the new apply_filters_and_suppressions_before_reporting() function, rather than applying the filters and suppressions by ourselves. Also adjust to the use the accessors of the new corpus_diff::diff_stats type. (corpus_diff::{deleted_variables, deleted_unrefed_function_symbols, deleted_unrefed_variable_symbols}): Define new accessors. (corpus_diff::diff_stats::{diff_stats, num_func_removed, num_func_added, num_func_changed, num_func_filtered_out, net_num_func_changed, num_vars_removed, num_vars_added, num_vars_changed, num_vars_filtered_out, net_num_vars_changed, num_func_sym_removed, num_func_syms_added, num_var_syms_removed, num_var_syms_added}): Define new member functions. * include/abg-corpus.h (corpus::{get_sym_ids_of_fns_to_keep, get_sym_ids_of_vars_to_keep}): Declare new methods. * src/abg-corpus.cc (corpus::priv::{sym_id_fns_to_keep, sym_id_vars_to_keep}): Added data members. (symtab_build_visitor_type::{unrefed_fun_symbols, unrefed_var_symbols, sym_id_fns_to_keep, sym_id_vars_to_keep}): Added new data members. (symtab_build_visitor_type::symtab_build_visitor_type): Take two additional parameters for the function and variable symbol ids to keep. (symtab_build_visitor_type::add_fn_to_wip_fns): Take the function symbols to keep in account when building the exported symbol table. (symtab_build_visitor_type::add_var_to_wip_vars): Likewise, take the variable symbols to keep in account when building the exported symbol table. (corpus::priv::build_public_decl_table): Adjust the initialization of the visitor that walks the ABI artifacts to build the exported symbol table to know take a list of function/variable symbols to keep. (corpus::priv::build_unreferenced_symbols_tables): Ensure that the public table of functions/variables is built before doing the work of this function. Also, if a list of variable/function symbols to keep is given, drop all symbols that are not in that list on the floor. (corpus::{get_sym_ids_of_fns_to_keep, get_sym_ids_of_vars_to_keep}): Define new accessors. * tools/abicompat.cc: New abicompat tool. * doc/manuals/abicompat.rst: New documentation source for abicompat. * doc/manuals/libabigail-tools.rst: Add an entry for the abicompat doc. * tests/test-abicompat.cc: New test harness for the 'abicompat' tool. * tests/Makefile.am: Build the runtestabicompat test harness and add it to the list of tests harnesses that are run by make check. * tests/data/test-abicompat/libtest0-fn-changed-libapp-v0.so: New test input. * tests/data/test-abicompat/libtest0-fn-changed-libapp-v1.so: Likewise. * tests/data/test-abicompat/test0-fn-changed-app: Likewise. * tests/data/test-abicompat/test0-fn-changed-0.suppr: Likewise * tests/data/test-abicompat/test0-fn-changed-report-0.txt: Likewise. * tests/data/test-abicompat/test0-fn-changed-report-1.txt: Likewise. * tests/data/test-abicompat/test0-fn-changed-app.cc: Likewise. * tests/data/test-abicompat/test0-fn-changed-libapp.h: Likewise. * tests/data/test-abicompat/test0-fn-changed-libapp-v0.cc: Likewise. * tests/data/test-abicompat/test0-fn-changed-libapp-v1.cc: Likewise. * tests/data/test-abicompat/libtest1-fn-removed-v0.so: Likewise. * tests/data/test-abicompat/libtest1-fn-removed-v1.so: Likewise. * tests/data/test-abicompat/test1-fn-removed-app: Likewise. * tests/data/test-abicompat/test1-fn-removed-app.cc: Likewise. * tests/data/test-abicompat/test1-fn-removed-report-0.txt: Likewise. * tests/data/test-abicompat/test1-fn-removed-v0.cc: Likewise. * tests/data/test-abicompat/test1-fn-removed-v1.cc: Likewise. * tests/data/test-abicompat/libtest2-var-removed-v0.so: Likewise. * tests/data/test-abicompat/libtest2-var-removed-v1.so: Likewise. * tests/data/test-abicompat/test2-var-removed-app: Likewise. * tests/data/test-abicompat/test2-var-removed-app.cc: Likewise. * tests/data/test-abicompat/test2-var-removed-report-0.txt: Likewise. * tests/data/test-abicompat/test2-var-removed-v0.cc: Likewise. * tests/data/test-abicompat/test2-var-removed-v1.cc: Likewise. * tests/data/test-abicompat/libtest3-fn-removed-v0.so: Likewise. * tests/data/test-abicompat/libtest3-fn-removed-v1.so: Likewise. * tests/data/test-abicompat/test3-fn-removed-app: Likewise. * tests/data/test-abicompat/test3-fn-removed-app.cc: Likewise. * tests/data/test-abicompat/test3-fn-removed-report-0.txt: Likewise. * tests/data/test-abicompat/test3-fn-removed-v0.cc: Likewise. * tests/data/test-abicompat/test3-fn-removed-v1.cc: Likewise. * tests/data/test-abicompat/test3-fn-removed-version-script-0 Likewise.: * tests/data/test-abicompat/test3-fn-removed-version-script-1: Likewise. * tests/data/Makefile.am: Add the new test inputs above to the source distribution. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-11-30 17:18:55 +00:00
$ cat -n test0.cc
1 // Compile this with:
2 // g++ -g -Wall -shared -o libtest-0.so test0.cc
Add support for abicompat weak mode This patch implements the weak mode of abicompat. In this mode, just the application and the new version of the library are provided. The types of functions and variables of the library that are consumed by the application are compared to the types of the functions and variables expected by the application. The goal is to check if the types of the declarations consumed by the application and provided by the library are compatible with what the application expects. The abicompat first gets the set of symbols undefined in the application and exported by the library. It then builds the set of declarations exported by the library that have those symbols. We call these the set of declarations of the library that are consumed by the application. Note that the debug information for the application does not contain the declarations of the functions/variables whose symbols are undefined. So we can not just read them to compare them to declarations exported by the library. But the *types* of the variables and the *sub-types* of the functions whose symbols are undefined in the application are present in the debug information of the application. So in the weak mode, abicompat compare the *types* of the declarations consumed by the application as expected by the application (described by the debug information of the application) with the types of the declarations exported by the library. To do this a number of changes were necessary. The patch builds a representation of all the types found in the application's debug info. Before that, only the types that are reachable from exported declarations were represented. The abidw tool got a new --load-all-types to test this new ability of loading all types. The patch also adds support for looking a type, not by name, but by its internal representation. In the comparison engine, function_type_diff is introduced to represent changes between two function types. For this, a new class type_or_decl_base has been introduced in the IR. It's now the base class for both decl_base and type_base. And abigail::comparison::diff now takes two pointers of type_or_decl, not decl_base anymore. So function_type_diff can take two function_type now; not that a function_type has no declaration so it doesn't inherit decl_base. A bunch of changes got made just to adjust to this modification. A number of fixes were made too, to make this work, like adding missing comparison operators, removing asserts that too strong, etc.. The patch also adjust the test suite as well as the documentation. * include/abg-fwd.h (class type_or_decl_base): Forward declare this. (is_decl, is_type, is_function_type, get_name, get_type_name) (get_function_type_name, get_pretty_representation) (lookup_function_type_in_corpus, lookup_type_in_translation_unit) (lookup_function_type_in_translation_unit) (synthesize_function_type_from_translation_unit) (hash_type_or_decl): New function declarations. * src/abg-corpus.cc (lookup_type_in_corpus) (lookup_function_type_in_corpus): Define new functions. * include/abg-ir.h (translation_unit::lookup_function_type_in_translation_unit): Declare new friend function. (class type_or_decl_base): Declare this. (operator==(const type_or_decl_base&, const type_or_decl_base&)): Declare new operator. (operator==(const type_or_decl_base_sptr&, const type_or_decl_base_sptr&)): Likewise. (class {decl_base, type_base}): Make these class inherit type_or_decl_base. (decl_base::get_member_scopes): New const overload. (bool operator==(const function_decl::parameter_sptr&, const function_decl::parameter_sptr&)): New operator. (function_type::get_parameters): Remove the non-const overload. (function_type::get_pretty_representation): Declare new member function. (method_type::get_pretty_representation): Likewise. * src/abg-ir.cc (bool operator==(const type_or_decl_base&, const type_or_decl_base&)): Define new equality operator. (bool operator==(const type_or_decl_base_sptr&, const type_or_decl_base_sptr&)): Likewise. (strip_typedef): Do not expect canonicalized types anymore. Now the system accepts (and expects) canonicalized types in certain cases. For instance, non-complete types and aggregated types that contain non-complete sub-types. (get_name, get_function_type_name, get_type_name) (get_pretty_representation, is_decl, is_type, is_function_type) (lookup_function_type_in_translation_unit) (synthesize_function_type_from_translation_unit) (lookup_type_in_scope, lookup_type_in_translation_unit): Define new functions or new overloads. (bool operator==(const function_decl::parameter_sptr&, const function_decl::parameter_sptr& r)): Define new operator. (function_type::get_parameters): Remove non-const overload. (function_type::get_pretty_representation): Define new function. (function_type::traverse): Adjust. (method_type::get_pretty_representation): Likewise. (function_decl::get_pretty_representation): Avoid emitting the type of cdtors. (hash_type_or_decl): Define new function. * include/abg-dwarf-reader.h (create_read_context) (read_corpus_from_elf): Take a new 'read_all_types' flag. * src/abg-dwarf-reader.cc (read_context::load_all_types_): New flag. (read_context::read_context): Initialize it. (read_context::canonical_types_scheduled): If some types still have non-canonicalized sub-types, then do not canonicalize them. (read_context::load_all_types): New member functions. (build_function_decl): Do not represent void return type like empty type anymore, rather, represent it like a void type node. (build_ir_node_from_die): When asked, load all types including those that are not reachable from an exported declaration. (create_read_context, read_corpus_from_elf): Take a new 'load_all_types' flag and honour it. * src/abg-reader.cc (read_context::type_is_from_translation_unit): Support looking up function types in the current translation unit, now that we now how to lookup function types. * include/abg-comparison.h (diff_context::{has_diff_for, add_diff, set_canonical_diff_for, set_or_get_canonical_diff_for, get_canonical_diff_for}): Make these take instances of type_or_decl_base_sptr, instead of decl_base_sptr. (diff::diff): Likewise. (diff::{first_subject, second_subject}): Make these return type_or_decl_base_sptr instead of decl_base_sptr. (type_diff_base::type_diff_base): Make these take instances of type_or_decl_base_sptr instead of decl_base_sptr. (distinct_diff::distinct_diff): Likewise. (distinct_diff::{first, second}): Make these return type_or_decl_base_sptr instead of decl_base_sptr. (distinct_diff::entities_are_of_distinct_kinds): Make these take instances of type_or_decl_base_sptr instead of decl_base_sptr. (class function_type_diff): Create this new type. It's a factorization of the function_decl_diff type. * src/abg-comparison.cc (): * src/abg-comp-filter.cc ({harmless, harmful}_filter::visit): Adjust as diff::{first,second}_subject() now returns a type_or_decl_base_sptr, no more a decl_base_sptr. (decls_type, decls_diff_map_type): Remove these typedefs and replace it with ... (types_or_decls_type, types_or_decls_diff_map_type): ... these. (struct {decls_hash, decls_equals): Remove these type sand replace them with ... (struct {types_or_decls_hash, types_or_decls_equals}): ... these. ({type_suppression, variable_suppression}::suppresses_diff): Adjust. (diff_context::priv::decls_diff_map): Replace this with ... (diff_context::priv::types_or_decls_diff_map): ... this. (diff_context::{has_diff_for, add_diff, get_canonical_diff_for, set_canonical_diff_for, set_or_get_canonical_diff_for}): Take type_or_decl_base_sptr instead of decl_base_sptr. (diff::priv::{first, second}_subject): Make the type of these be type_or_decl_base_sptr, no more decl_base_sptr. (diff::priv::priv): Adjust for the subjects of the diff being of type type_or_decl_sptr now, no more decl_base_sptr. (diff_less_than_functor::operator()(const diff_sptr, const diff_sptr) const): Adjust. (diff::diff): djust for the subjects of the diff being of type type_or_decl_sptr now, no more decl_base_sptr. (diff::{first,second}_subject): Make the type of these be type_or_decl_base_sptr, no more decl_base_sptr. (report_size_and_alignment_changes): Likewise. (type_diff_base::type_diff_base): Make the type of this be type_or_decl_base_sptr instead of type_base_sptr. (distinct_diff::distinct_diff): Make this take instances of type_or_decl_base_sptr instead of decl_base_sptr. (distinct_diff::{first, second, entities_are_of_distinct_kinds}): Likewise. (distinct_diff::has_changes): Simplify logic. (distinct_diff::report): Adjust. (compute_diff_for_types): Add an additional case to support the new function_type. (report_size_and_alignment_changes): Make this take instances of type_or_decl_base_sptr instead of decl_base_sptr. (class_diff::priv::member_type_has_changed): Return an instance of type_or_decl_base_sptr rather than a decl_base_sptr. (class_diff::report): Adjust. (diff_comp::operator()(const diff&, diff&) const): Adjust. (enum function_decl_diff::priv::Flags): Remove. (function_decl_diff::priv::{first_fn_flags_, second_fn_flags_, fn_flags_changes_}): Remove. (function_decl_diff::priv::{fn_is_declared_inline_to_flag, fn_binding_to_flag}): Remove. (function_decl_diff::{deleted_parameter_at, inserted_parameter_at}): Remove. (function_decl_diff::ensure_lookup_tables_populated): Empty this. (function_decl_diff::chain_into_hierarchy): Adjust. (function_decl_diff::function_decl_diff): This now only takes the subjects. It's body is now empty. (function_decl_diff::{return_type_diff, subtype_changed_parms, removed_parms, added_parms, type_diff}): Remove these member functions. (function_decl_diff::type_diff): Define new member function. (function_decl_diff::report): Simplify logic by using the reporting of the child type diff node. (compute_diff): Likewise, in the overload for function_decl_sptr simplify logic by using the child type diff object. (function_type_diff::priv): Define new type. (function_type_diff::{function_type_diff, ensure_lookup_tables_populated, deleted_parameter_at, inserted_parameter_at, finish_diff_type, first_function_type, second_function_type, return_type_diff, subtype_changed_parms, removed_parms, added_parms, get_pretty_representation, has_changes, has_local_changes, report, chain_into_hierarchy}): Define new functions. (compute_diff): Define new overload for function_type_sptr. * tools/abicompat.cc (options::weak_mode): New data member. (options::options): Initialize it. (enum abicompat_status): New enum (abicompat_status operator|(abicompat_status, abicompat_status)) (abicompat_status& operator|=(abicompat_status &, abicompat_status)) (abicompat_status operator&(abicompat_status, abicompat_status)): New operators to manipulate the abicompat_status enum. (display_usage): Add help string for the new --weak-mode option. (parse_command_line): Add the new --weak-mode command line argument. If the tool is called with just the application and one library then assume that we are in the weak mode. (perform_compat_check_in_normal_mode): Define new function, factorized from what was in the main function. (perform_compat_check_in_weak_mode): Define new function. (struct {fn,var}_change): Define new types. (main): Use perform_compat_check_in_weak_mode() and perform_compat_check_in_normal_mode(). * tools/abidiff.cc (main): Adjust. * tools/abidw.cc: (options::load_all_types): Add new data member. (options::options): Initialize it. (display_usage): New help string for --load-all-types. (parse_command_line): Support the new --load-all-types option. (main): Adjust and honour the --load-all-types option. * tools/abilint.cc (main): Adjust. * doc/manuals/abicompat.rst: Update documentation for the new weak mode. Also provide stuff that was missing from the examples provided. * doc/manuals/abidw.rst: Update documentation for the new --load-all-types option. * tests/print-diff-tree.cc (main): Adjust. * tests/test-diff-dwarf.cc (main): Likewise. * tests/test-read-dwarf.cc (main): Likewise. * tests/data/test-abicompat/test0-fn-changed-app: Recompile this. * tests/data/test-abicompat/libtest5-fn-changed-libapp-v{0,1}.so: New new test input binaries * tests/data/test-abicompat/test5-fn-changed-app: Likewise. * tests/data/test-abicompat/test6-var-changed-app: Likewise. * tests/data/test-abicompat/libtest6-var-changed-libapp-v{0,1}.so: Likewise. * tests/data/test-abicompat/test5-fn-changed-report-0.txt: Reference output for one test above. * tests/data/test-abicompat/test6-var-changed-report-0.txt: Likewise. * tests/data/test-abicompat/test5-fn-changed-app.cc: Source file for a binary above. * tests/data/test-abicompat/test5-fn-changed-libapp-v{0,1}.{h,cc}: Likewise. * tests/data/test-abicompat/test6-var-changed-libapp-v{0,1}.{cc,h}: Likewise. * tests/data/test-abicompat/test6-var-changed-app.cc: Likewise. * tests/data/Makefile.am: Add the test related files above to the source distribution. * tests/test-abicompat.cc (in_out_spec): Add the new test input above to the list of inputs to feed to this test harness. (main): Support taking just the app and one library. * tests/data/test-read-dwarf/test{0, 1, 2.so, 3.so, 5.o, 8-qualified-this-pointer.so,}.abi: Adjust for void type being really emitted now, as opposed to just being an empty type. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-04-01 10:13:38 +00:00
3
Initial implementation of the abicompat tool Given an application A that links to a shared library L of version V denoted L(V) and a subsequent version of that library denoted L(V+P), the 'abicompat' tool tells the user if L(V+P) is still ABI compatible with L(V+P). And if it is not, abicompat gives a reports that shows the differences between L(V) and L(V+P) that makes L(V+P) ABI-incompatible with A. The source code of this tool is in the tools/abicompat.cc source file. To support this new tool, this commit changes the comparison engine to optionally avoid showing added symbols that were not referenced by any debug info. It changes the ABI corpus type to allow the specification of a list of variables and functions symbols to keep (and drop all other functions and variables which have other symbols on the floor even before starting to compare the two libraries). This is how the abicompat tool itself works. It basically compares L(V) and L(V+P) but it only looks at their exported functions and variables which symbols are undefined in application A. If the list of exported and defined variables and functions of L(V) whose symbols are undefined in A equals that of L(V+P) (including the sub-types of these variables and functions) A is still compatible with L(V+P). Otherwise, they might not be compatible depending on the kind of differences that are found. * include/abg-comparison.h (diff_context::show_added_symbols_unreferenced_by_debug_info): Declare new accessors. (corpus_diff::{deleted_variables, deleted_unrefed_function_symbols, deleted_unrefed_variable_symbols, apply_filters_and_suppressions_before_reporting}): Declare new methods. (corpus_diff::diff_stats): Declare this new type. Actually this was previously corpus_diff::priv::diff_stats, which was a hidden internal type.. We are moving it here, in the external API so that client code can have more information about changes statistics. Change all the previously publicly accessible data members into accessor functions. * src/abg-comparison.cc (class corpus_diff::diff_stats::priv): New type. (diff_context::priv::show_added_syms_unreferenced_by_di_): New data member. (diff_context::priv::priv): Adjust. (diff_context::show_added_symbols_unreferenced_by_debug_info): Define this new method. (corpus_diff::priv::emit_diff_stats): Do not show the diff stat if the only changes is added function or variables symbols and if we were instructed to not show added symbols. (corpus_diff::priv::{diff_stats_, filters_and_suppr_applied_}): New data members. (corpus_diff::priv::priv): Initialize the filters_and_suppr_applied_ data member. (corpus_diff::priv::diff_stats): Move this type to corpus_diff::diff_stats. (corpus_diff::priv::{apply_filters_and_compute_diff_stats, emit_diff_stats}): Adjust. (corpus_diff::apply_filters_and_suppressions_before_reporting): Define new member function. (corpus_diff::report): Use the new apply_filters_and_suppressions_before_reporting() function, rather than applying the filters and suppressions by ourselves. Also adjust to the use the accessors of the new corpus_diff::diff_stats type. (corpus_diff::{deleted_variables, deleted_unrefed_function_symbols, deleted_unrefed_variable_symbols}): Define new accessors. (corpus_diff::diff_stats::{diff_stats, num_func_removed, num_func_added, num_func_changed, num_func_filtered_out, net_num_func_changed, num_vars_removed, num_vars_added, num_vars_changed, num_vars_filtered_out, net_num_vars_changed, num_func_sym_removed, num_func_syms_added, num_var_syms_removed, num_var_syms_added}): Define new member functions. * include/abg-corpus.h (corpus::{get_sym_ids_of_fns_to_keep, get_sym_ids_of_vars_to_keep}): Declare new methods. * src/abg-corpus.cc (corpus::priv::{sym_id_fns_to_keep, sym_id_vars_to_keep}): Added data members. (symtab_build_visitor_type::{unrefed_fun_symbols, unrefed_var_symbols, sym_id_fns_to_keep, sym_id_vars_to_keep}): Added new data members. (symtab_build_visitor_type::symtab_build_visitor_type): Take two additional parameters for the function and variable symbol ids to keep. (symtab_build_visitor_type::add_fn_to_wip_fns): Take the function symbols to keep in account when building the exported symbol table. (symtab_build_visitor_type::add_var_to_wip_vars): Likewise, take the variable symbols to keep in account when building the exported symbol table. (corpus::priv::build_public_decl_table): Adjust the initialization of the visitor that walks the ABI artifacts to build the exported symbol table to know take a list of function/variable symbols to keep. (corpus::priv::build_unreferenced_symbols_tables): Ensure that the public table of functions/variables is built before doing the work of this function. Also, if a list of variable/function symbols to keep is given, drop all symbols that are not in that list on the floor. (corpus::{get_sym_ids_of_fns_to_keep, get_sym_ids_of_vars_to_keep}): Define new accessors. * tools/abicompat.cc: New abicompat tool. * doc/manuals/abicompat.rst: New documentation source for abicompat. * doc/manuals/libabigail-tools.rst: Add an entry for the abicompat doc. * tests/test-abicompat.cc: New test harness for the 'abicompat' tool. * tests/Makefile.am: Build the runtestabicompat test harness and add it to the list of tests harnesses that are run by make check. * tests/data/test-abicompat/libtest0-fn-changed-libapp-v0.so: New test input. * tests/data/test-abicompat/libtest0-fn-changed-libapp-v1.so: Likewise. * tests/data/test-abicompat/test0-fn-changed-app: Likewise. * tests/data/test-abicompat/test0-fn-changed-0.suppr: Likewise * tests/data/test-abicompat/test0-fn-changed-report-0.txt: Likewise. * tests/data/test-abicompat/test0-fn-changed-report-1.txt: Likewise. * tests/data/test-abicompat/test0-fn-changed-app.cc: Likewise. * tests/data/test-abicompat/test0-fn-changed-libapp.h: Likewise. * tests/data/test-abicompat/test0-fn-changed-libapp-v0.cc: Likewise. * tests/data/test-abicompat/test0-fn-changed-libapp-v1.cc: Likewise. * tests/data/test-abicompat/libtest1-fn-removed-v0.so: Likewise. * tests/data/test-abicompat/libtest1-fn-removed-v1.so: Likewise. * tests/data/test-abicompat/test1-fn-removed-app: Likewise. * tests/data/test-abicompat/test1-fn-removed-app.cc: Likewise. * tests/data/test-abicompat/test1-fn-removed-report-0.txt: Likewise. * tests/data/test-abicompat/test1-fn-removed-v0.cc: Likewise. * tests/data/test-abicompat/test1-fn-removed-v1.cc: Likewise. * tests/data/test-abicompat/libtest2-var-removed-v0.so: Likewise. * tests/data/test-abicompat/libtest2-var-removed-v1.so: Likewise. * tests/data/test-abicompat/test2-var-removed-app: Likewise. * tests/data/test-abicompat/test2-var-removed-app.cc: Likewise. * tests/data/test-abicompat/test2-var-removed-report-0.txt: Likewise. * tests/data/test-abicompat/test2-var-removed-v0.cc: Likewise. * tests/data/test-abicompat/test2-var-removed-v1.cc: Likewise. * tests/data/test-abicompat/libtest3-fn-removed-v0.so: Likewise. * tests/data/test-abicompat/libtest3-fn-removed-v1.so: Likewise. * tests/data/test-abicompat/test3-fn-removed-app: Likewise. * tests/data/test-abicompat/test3-fn-removed-app.cc: Likewise. * tests/data/test-abicompat/test3-fn-removed-report-0.txt: Likewise. * tests/data/test-abicompat/test3-fn-removed-v0.cc: Likewise. * tests/data/test-abicompat/test3-fn-removed-v1.cc: Likewise. * tests/data/test-abicompat/test3-fn-removed-version-script-0 Likewise.: * tests/data/test-abicompat/test3-fn-removed-version-script-1: Likewise. * tests/data/Makefile.am: Add the new test inputs above to the source distribution. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-11-30 17:18:55 +00:00
4 #include "test0.h"
Add support for abicompat weak mode This patch implements the weak mode of abicompat. In this mode, just the application and the new version of the library are provided. The types of functions and variables of the library that are consumed by the application are compared to the types of the functions and variables expected by the application. The goal is to check if the types of the declarations consumed by the application and provided by the library are compatible with what the application expects. The abicompat first gets the set of symbols undefined in the application and exported by the library. It then builds the set of declarations exported by the library that have those symbols. We call these the set of declarations of the library that are consumed by the application. Note that the debug information for the application does not contain the declarations of the functions/variables whose symbols are undefined. So we can not just read them to compare them to declarations exported by the library. But the *types* of the variables and the *sub-types* of the functions whose symbols are undefined in the application are present in the debug information of the application. So in the weak mode, abicompat compare the *types* of the declarations consumed by the application as expected by the application (described by the debug information of the application) with the types of the declarations exported by the library. To do this a number of changes were necessary. The patch builds a representation of all the types found in the application's debug info. Before that, only the types that are reachable from exported declarations were represented. The abidw tool got a new --load-all-types to test this new ability of loading all types. The patch also adds support for looking a type, not by name, but by its internal representation. In the comparison engine, function_type_diff is introduced to represent changes between two function types. For this, a new class type_or_decl_base has been introduced in the IR. It's now the base class for both decl_base and type_base. And abigail::comparison::diff now takes two pointers of type_or_decl, not decl_base anymore. So function_type_diff can take two function_type now; not that a function_type has no declaration so it doesn't inherit decl_base. A bunch of changes got made just to adjust to this modification. A number of fixes were made too, to make this work, like adding missing comparison operators, removing asserts that too strong, etc.. The patch also adjust the test suite as well as the documentation. * include/abg-fwd.h (class type_or_decl_base): Forward declare this. (is_decl, is_type, is_function_type, get_name, get_type_name) (get_function_type_name, get_pretty_representation) (lookup_function_type_in_corpus, lookup_type_in_translation_unit) (lookup_function_type_in_translation_unit) (synthesize_function_type_from_translation_unit) (hash_type_or_decl): New function declarations. * src/abg-corpus.cc (lookup_type_in_corpus) (lookup_function_type_in_corpus): Define new functions. * include/abg-ir.h (translation_unit::lookup_function_type_in_translation_unit): Declare new friend function. (class type_or_decl_base): Declare this. (operator==(const type_or_decl_base&, const type_or_decl_base&)): Declare new operator. (operator==(const type_or_decl_base_sptr&, const type_or_decl_base_sptr&)): Likewise. (class {decl_base, type_base}): Make these class inherit type_or_decl_base. (decl_base::get_member_scopes): New const overload. (bool operator==(const function_decl::parameter_sptr&, const function_decl::parameter_sptr&)): New operator. (function_type::get_parameters): Remove the non-const overload. (function_type::get_pretty_representation): Declare new member function. (method_type::get_pretty_representation): Likewise. * src/abg-ir.cc (bool operator==(const type_or_decl_base&, const type_or_decl_base&)): Define new equality operator. (bool operator==(const type_or_decl_base_sptr&, const type_or_decl_base_sptr&)): Likewise. (strip_typedef): Do not expect canonicalized types anymore. Now the system accepts (and expects) canonicalized types in certain cases. For instance, non-complete types and aggregated types that contain non-complete sub-types. (get_name, get_function_type_name, get_type_name) (get_pretty_representation, is_decl, is_type, is_function_type) (lookup_function_type_in_translation_unit) (synthesize_function_type_from_translation_unit) (lookup_type_in_scope, lookup_type_in_translation_unit): Define new functions or new overloads. (bool operator==(const function_decl::parameter_sptr&, const function_decl::parameter_sptr& r)): Define new operator. (function_type::get_parameters): Remove non-const overload. (function_type::get_pretty_representation): Define new function. (function_type::traverse): Adjust. (method_type::get_pretty_representation): Likewise. (function_decl::get_pretty_representation): Avoid emitting the type of cdtors. (hash_type_or_decl): Define new function. * include/abg-dwarf-reader.h (create_read_context) (read_corpus_from_elf): Take a new 'read_all_types' flag. * src/abg-dwarf-reader.cc (read_context::load_all_types_): New flag. (read_context::read_context): Initialize it. (read_context::canonical_types_scheduled): If some types still have non-canonicalized sub-types, then do not canonicalize them. (read_context::load_all_types): New member functions. (build_function_decl): Do not represent void return type like empty type anymore, rather, represent it like a void type node. (build_ir_node_from_die): When asked, load all types including those that are not reachable from an exported declaration. (create_read_context, read_corpus_from_elf): Take a new 'load_all_types' flag and honour it. * src/abg-reader.cc (read_context::type_is_from_translation_unit): Support looking up function types in the current translation unit, now that we now how to lookup function types. * include/abg-comparison.h (diff_context::{has_diff_for, add_diff, set_canonical_diff_for, set_or_get_canonical_diff_for, get_canonical_diff_for}): Make these take instances of type_or_decl_base_sptr, instead of decl_base_sptr. (diff::diff): Likewise. (diff::{first_subject, second_subject}): Make these return type_or_decl_base_sptr instead of decl_base_sptr. (type_diff_base::type_diff_base): Make these take instances of type_or_decl_base_sptr instead of decl_base_sptr. (distinct_diff::distinct_diff): Likewise. (distinct_diff::{first, second}): Make these return type_or_decl_base_sptr instead of decl_base_sptr. (distinct_diff::entities_are_of_distinct_kinds): Make these take instances of type_or_decl_base_sptr instead of decl_base_sptr. (class function_type_diff): Create this new type. It's a factorization of the function_decl_diff type. * src/abg-comparison.cc (): * src/abg-comp-filter.cc ({harmless, harmful}_filter::visit): Adjust as diff::{first,second}_subject() now returns a type_or_decl_base_sptr, no more a decl_base_sptr. (decls_type, decls_diff_map_type): Remove these typedefs and replace it with ... (types_or_decls_type, types_or_decls_diff_map_type): ... these. (struct {decls_hash, decls_equals): Remove these type sand replace them with ... (struct {types_or_decls_hash, types_or_decls_equals}): ... these. ({type_suppression, variable_suppression}::suppresses_diff): Adjust. (diff_context::priv::decls_diff_map): Replace this with ... (diff_context::priv::types_or_decls_diff_map): ... this. (diff_context::{has_diff_for, add_diff, get_canonical_diff_for, set_canonical_diff_for, set_or_get_canonical_diff_for}): Take type_or_decl_base_sptr instead of decl_base_sptr. (diff::priv::{first, second}_subject): Make the type of these be type_or_decl_base_sptr, no more decl_base_sptr. (diff::priv::priv): Adjust for the subjects of the diff being of type type_or_decl_sptr now, no more decl_base_sptr. (diff_less_than_functor::operator()(const diff_sptr, const diff_sptr) const): Adjust. (diff::diff): djust for the subjects of the diff being of type type_or_decl_sptr now, no more decl_base_sptr. (diff::{first,second}_subject): Make the type of these be type_or_decl_base_sptr, no more decl_base_sptr. (report_size_and_alignment_changes): Likewise. (type_diff_base::type_diff_base): Make the type of this be type_or_decl_base_sptr instead of type_base_sptr. (distinct_diff::distinct_diff): Make this take instances of type_or_decl_base_sptr instead of decl_base_sptr. (distinct_diff::{first, second, entities_are_of_distinct_kinds}): Likewise. (distinct_diff::has_changes): Simplify logic. (distinct_diff::report): Adjust. (compute_diff_for_types): Add an additional case to support the new function_type. (report_size_and_alignment_changes): Make this take instances of type_or_decl_base_sptr instead of decl_base_sptr. (class_diff::priv::member_type_has_changed): Return an instance of type_or_decl_base_sptr rather than a decl_base_sptr. (class_diff::report): Adjust. (diff_comp::operator()(const diff&, diff&) const): Adjust. (enum function_decl_diff::priv::Flags): Remove. (function_decl_diff::priv::{first_fn_flags_, second_fn_flags_, fn_flags_changes_}): Remove. (function_decl_diff::priv::{fn_is_declared_inline_to_flag, fn_binding_to_flag}): Remove. (function_decl_diff::{deleted_parameter_at, inserted_parameter_at}): Remove. (function_decl_diff::ensure_lookup_tables_populated): Empty this. (function_decl_diff::chain_into_hierarchy): Adjust. (function_decl_diff::function_decl_diff): This now only takes the subjects. It's body is now empty. (function_decl_diff::{return_type_diff, subtype_changed_parms, removed_parms, added_parms, type_diff}): Remove these member functions. (function_decl_diff::type_diff): Define new member function. (function_decl_diff::report): Simplify logic by using the reporting of the child type diff node. (compute_diff): Likewise, in the overload for function_decl_sptr simplify logic by using the child type diff object. (function_type_diff::priv): Define new type. (function_type_diff::{function_type_diff, ensure_lookup_tables_populated, deleted_parameter_at, inserted_parameter_at, finish_diff_type, first_function_type, second_function_type, return_type_diff, subtype_changed_parms, removed_parms, added_parms, get_pretty_representation, has_changes, has_local_changes, report, chain_into_hierarchy}): Define new functions. (compute_diff): Define new overload for function_type_sptr. * tools/abicompat.cc (options::weak_mode): New data member. (options::options): Initialize it. (enum abicompat_status): New enum (abicompat_status operator|(abicompat_status, abicompat_status)) (abicompat_status& operator|=(abicompat_status &, abicompat_status)) (abicompat_status operator&(abicompat_status, abicompat_status)): New operators to manipulate the abicompat_status enum. (display_usage): Add help string for the new --weak-mode option. (parse_command_line): Add the new --weak-mode command line argument. If the tool is called with just the application and one library then assume that we are in the weak mode. (perform_compat_check_in_normal_mode): Define new function, factorized from what was in the main function. (perform_compat_check_in_weak_mode): Define new function. (struct {fn,var}_change): Define new types. (main): Use perform_compat_check_in_weak_mode() and perform_compat_check_in_normal_mode(). * tools/abidiff.cc (main): Adjust. * tools/abidw.cc: (options::load_all_types): Add new data member. (options::options): Initialize it. (display_usage): New help string for --load-all-types. (parse_command_line): Support the new --load-all-types option. (main): Adjust and honour the --load-all-types option. * tools/abilint.cc (main): Adjust. * doc/manuals/abicompat.rst: Update documentation for the new weak mode. Also provide stuff that was missing from the examples provided. * doc/manuals/abidw.rst: Update documentation for the new --load-all-types option. * tests/print-diff-tree.cc (main): Adjust. * tests/test-diff-dwarf.cc (main): Likewise. * tests/test-read-dwarf.cc (main): Likewise. * tests/data/test-abicompat/test0-fn-changed-app: Recompile this. * tests/data/test-abicompat/libtest5-fn-changed-libapp-v{0,1}.so: New new test input binaries * tests/data/test-abicompat/test5-fn-changed-app: Likewise. * tests/data/test-abicompat/test6-var-changed-app: Likewise. * tests/data/test-abicompat/libtest6-var-changed-libapp-v{0,1}.so: Likewise. * tests/data/test-abicompat/test5-fn-changed-report-0.txt: Reference output for one test above. * tests/data/test-abicompat/test6-var-changed-report-0.txt: Likewise. * tests/data/test-abicompat/test5-fn-changed-app.cc: Source file for a binary above. * tests/data/test-abicompat/test5-fn-changed-libapp-v{0,1}.{h,cc}: Likewise. * tests/data/test-abicompat/test6-var-changed-libapp-v{0,1}.{cc,h}: Likewise. * tests/data/test-abicompat/test6-var-changed-app.cc: Likewise. * tests/data/Makefile.am: Add the test related files above to the source distribution. * tests/test-abicompat.cc (in_out_spec): Add the new test input above to the list of inputs to feed to this test harness. (main): Support taking just the app and one library. * tests/data/test-read-dwarf/test{0, 1, 2.so, 3.so, 5.o, 8-qualified-this-pointer.so,}.abi: Adjust for void type being really emitted now, as opposed to just being an empty type. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-04-01 10:13:38 +00:00
5
Initial implementation of the abicompat tool Given an application A that links to a shared library L of version V denoted L(V) and a subsequent version of that library denoted L(V+P), the 'abicompat' tool tells the user if L(V+P) is still ABI compatible with L(V+P). And if it is not, abicompat gives a reports that shows the differences between L(V) and L(V+P) that makes L(V+P) ABI-incompatible with A. The source code of this tool is in the tools/abicompat.cc source file. To support this new tool, this commit changes the comparison engine to optionally avoid showing added symbols that were not referenced by any debug info. It changes the ABI corpus type to allow the specification of a list of variables and functions symbols to keep (and drop all other functions and variables which have other symbols on the floor even before starting to compare the two libraries). This is how the abicompat tool itself works. It basically compares L(V) and L(V+P) but it only looks at their exported functions and variables which symbols are undefined in application A. If the list of exported and defined variables and functions of L(V) whose symbols are undefined in A equals that of L(V+P) (including the sub-types of these variables and functions) A is still compatible with L(V+P). Otherwise, they might not be compatible depending on the kind of differences that are found. * include/abg-comparison.h (diff_context::show_added_symbols_unreferenced_by_debug_info): Declare new accessors. (corpus_diff::{deleted_variables, deleted_unrefed_function_symbols, deleted_unrefed_variable_symbols, apply_filters_and_suppressions_before_reporting}): Declare new methods. (corpus_diff::diff_stats): Declare this new type. Actually this was previously corpus_diff::priv::diff_stats, which was a hidden internal type.. We are moving it here, in the external API so that client code can have more information about changes statistics. Change all the previously publicly accessible data members into accessor functions. * src/abg-comparison.cc (class corpus_diff::diff_stats::priv): New type. (diff_context::priv::show_added_syms_unreferenced_by_di_): New data member. (diff_context::priv::priv): Adjust. (diff_context::show_added_symbols_unreferenced_by_debug_info): Define this new method. (corpus_diff::priv::emit_diff_stats): Do not show the diff stat if the only changes is added function or variables symbols and if we were instructed to not show added symbols. (corpus_diff::priv::{diff_stats_, filters_and_suppr_applied_}): New data members. (corpus_diff::priv::priv): Initialize the filters_and_suppr_applied_ data member. (corpus_diff::priv::diff_stats): Move this type to corpus_diff::diff_stats. (corpus_diff::priv::{apply_filters_and_compute_diff_stats, emit_diff_stats}): Adjust. (corpus_diff::apply_filters_and_suppressions_before_reporting): Define new member function. (corpus_diff::report): Use the new apply_filters_and_suppressions_before_reporting() function, rather than applying the filters and suppressions by ourselves. Also adjust to the use the accessors of the new corpus_diff::diff_stats type. (corpus_diff::{deleted_variables, deleted_unrefed_function_symbols, deleted_unrefed_variable_symbols}): Define new accessors. (corpus_diff::diff_stats::{diff_stats, num_func_removed, num_func_added, num_func_changed, num_func_filtered_out, net_num_func_changed, num_vars_removed, num_vars_added, num_vars_changed, num_vars_filtered_out, net_num_vars_changed, num_func_sym_removed, num_func_syms_added, num_var_syms_removed, num_var_syms_added}): Define new member functions. * include/abg-corpus.h (corpus::{get_sym_ids_of_fns_to_keep, get_sym_ids_of_vars_to_keep}): Declare new methods. * src/abg-corpus.cc (corpus::priv::{sym_id_fns_to_keep, sym_id_vars_to_keep}): Added data members. (symtab_build_visitor_type::{unrefed_fun_symbols, unrefed_var_symbols, sym_id_fns_to_keep, sym_id_vars_to_keep}): Added new data members. (symtab_build_visitor_type::symtab_build_visitor_type): Take two additional parameters for the function and variable symbol ids to keep. (symtab_build_visitor_type::add_fn_to_wip_fns): Take the function symbols to keep in account when building the exported symbol table. (symtab_build_visitor_type::add_var_to_wip_vars): Likewise, take the variable symbols to keep in account when building the exported symbol table. (corpus::priv::build_public_decl_table): Adjust the initialization of the visitor that walks the ABI artifacts to build the exported symbol table to know take a list of function/variable symbols to keep. (corpus::priv::build_unreferenced_symbols_tables): Ensure that the public table of functions/variables is built before doing the work of this function. Also, if a list of variable/function symbols to keep is given, drop all symbols that are not in that list on the floor. (corpus::{get_sym_ids_of_fns_to_keep, get_sym_ids_of_vars_to_keep}): Define new accessors. * tools/abicompat.cc: New abicompat tool. * doc/manuals/abicompat.rst: New documentation source for abicompat. * doc/manuals/libabigail-tools.rst: Add an entry for the abicompat doc. * tests/test-abicompat.cc: New test harness for the 'abicompat' tool. * tests/Makefile.am: Build the runtestabicompat test harness and add it to the list of tests harnesses that are run by make check. * tests/data/test-abicompat/libtest0-fn-changed-libapp-v0.so: New test input. * tests/data/test-abicompat/libtest0-fn-changed-libapp-v1.so: Likewise. * tests/data/test-abicompat/test0-fn-changed-app: Likewise. * tests/data/test-abicompat/test0-fn-changed-0.suppr: Likewise * tests/data/test-abicompat/test0-fn-changed-report-0.txt: Likewise. * tests/data/test-abicompat/test0-fn-changed-report-1.txt: Likewise. * tests/data/test-abicompat/test0-fn-changed-app.cc: Likewise. * tests/data/test-abicompat/test0-fn-changed-libapp.h: Likewise. * tests/data/test-abicompat/test0-fn-changed-libapp-v0.cc: Likewise. * tests/data/test-abicompat/test0-fn-changed-libapp-v1.cc: Likewise. * tests/data/test-abicompat/libtest1-fn-removed-v0.so: Likewise. * tests/data/test-abicompat/libtest1-fn-removed-v1.so: Likewise. * tests/data/test-abicompat/test1-fn-removed-app: Likewise. * tests/data/test-abicompat/test1-fn-removed-app.cc: Likewise. * tests/data/test-abicompat/test1-fn-removed-report-0.txt: Likewise. * tests/data/test-abicompat/test1-fn-removed-v0.cc: Likewise. * tests/data/test-abicompat/test1-fn-removed-v1.cc: Likewise. * tests/data/test-abicompat/libtest2-var-removed-v0.so: Likewise. * tests/data/test-abicompat/libtest2-var-removed-v1.so: Likewise. * tests/data/test-abicompat/test2-var-removed-app: Likewise. * tests/data/test-abicompat/test2-var-removed-app.cc: Likewise. * tests/data/test-abicompat/test2-var-removed-report-0.txt: Likewise. * tests/data/test-abicompat/test2-var-removed-v0.cc: Likewise. * tests/data/test-abicompat/test2-var-removed-v1.cc: Likewise. * tests/data/test-abicompat/libtest3-fn-removed-v0.so: Likewise. * tests/data/test-abicompat/libtest3-fn-removed-v1.so: Likewise. * tests/data/test-abicompat/test3-fn-removed-app: Likewise. * tests/data/test-abicompat/test3-fn-removed-app.cc: Likewise. * tests/data/test-abicompat/test3-fn-removed-report-0.txt: Likewise. * tests/data/test-abicompat/test3-fn-removed-v0.cc: Likewise. * tests/data/test-abicompat/test3-fn-removed-v1.cc: Likewise. * tests/data/test-abicompat/test3-fn-removed-version-script-0 Likewise.: * tests/data/test-abicompat/test3-fn-removed-version-script-1: Likewise. * tests/data/Makefile.am: Add the new test inputs above to the source distribution. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-11-30 17:18:55 +00:00
6 foo*
7 first_func()
8 {
Add support for abicompat weak mode This patch implements the weak mode of abicompat. In this mode, just the application and the new version of the library are provided. The types of functions and variables of the library that are consumed by the application are compared to the types of the functions and variables expected by the application. The goal is to check if the types of the declarations consumed by the application and provided by the library are compatible with what the application expects. The abicompat first gets the set of symbols undefined in the application and exported by the library. It then builds the set of declarations exported by the library that have those symbols. We call these the set of declarations of the library that are consumed by the application. Note that the debug information for the application does not contain the declarations of the functions/variables whose symbols are undefined. So we can not just read them to compare them to declarations exported by the library. But the *types* of the variables and the *sub-types* of the functions whose symbols are undefined in the application are present in the debug information of the application. So in the weak mode, abicompat compare the *types* of the declarations consumed by the application as expected by the application (described by the debug information of the application) with the types of the declarations exported by the library. To do this a number of changes were necessary. The patch builds a representation of all the types found in the application's debug info. Before that, only the types that are reachable from exported declarations were represented. The abidw tool got a new --load-all-types to test this new ability of loading all types. The patch also adds support for looking a type, not by name, but by its internal representation. In the comparison engine, function_type_diff is introduced to represent changes between two function types. For this, a new class type_or_decl_base has been introduced in the IR. It's now the base class for both decl_base and type_base. And abigail::comparison::diff now takes two pointers of type_or_decl, not decl_base anymore. So function_type_diff can take two function_type now; not that a function_type has no declaration so it doesn't inherit decl_base. A bunch of changes got made just to adjust to this modification. A number of fixes were made too, to make this work, like adding missing comparison operators, removing asserts that too strong, etc.. The patch also adjust the test suite as well as the documentation. * include/abg-fwd.h (class type_or_decl_base): Forward declare this. (is_decl, is_type, is_function_type, get_name, get_type_name) (get_function_type_name, get_pretty_representation) (lookup_function_type_in_corpus, lookup_type_in_translation_unit) (lookup_function_type_in_translation_unit) (synthesize_function_type_from_translation_unit) (hash_type_or_decl): New function declarations. * src/abg-corpus.cc (lookup_type_in_corpus) (lookup_function_type_in_corpus): Define new functions. * include/abg-ir.h (translation_unit::lookup_function_type_in_translation_unit): Declare new friend function. (class type_or_decl_base): Declare this. (operator==(const type_or_decl_base&, const type_or_decl_base&)): Declare new operator. (operator==(const type_or_decl_base_sptr&, const type_or_decl_base_sptr&)): Likewise. (class {decl_base, type_base}): Make these class inherit type_or_decl_base. (decl_base::get_member_scopes): New const overload. (bool operator==(const function_decl::parameter_sptr&, const function_decl::parameter_sptr&)): New operator. (function_type::get_parameters): Remove the non-const overload. (function_type::get_pretty_representation): Declare new member function. (method_type::get_pretty_representation): Likewise. * src/abg-ir.cc (bool operator==(const type_or_decl_base&, const type_or_decl_base&)): Define new equality operator. (bool operator==(const type_or_decl_base_sptr&, const type_or_decl_base_sptr&)): Likewise. (strip_typedef): Do not expect canonicalized types anymore. Now the system accepts (and expects) canonicalized types in certain cases. For instance, non-complete types and aggregated types that contain non-complete sub-types. (get_name, get_function_type_name, get_type_name) (get_pretty_representation, is_decl, is_type, is_function_type) (lookup_function_type_in_translation_unit) (synthesize_function_type_from_translation_unit) (lookup_type_in_scope, lookup_type_in_translation_unit): Define new functions or new overloads. (bool operator==(const function_decl::parameter_sptr&, const function_decl::parameter_sptr& r)): Define new operator. (function_type::get_parameters): Remove non-const overload. (function_type::get_pretty_representation): Define new function. (function_type::traverse): Adjust. (method_type::get_pretty_representation): Likewise. (function_decl::get_pretty_representation): Avoid emitting the type of cdtors. (hash_type_or_decl): Define new function. * include/abg-dwarf-reader.h (create_read_context) (read_corpus_from_elf): Take a new 'read_all_types' flag. * src/abg-dwarf-reader.cc (read_context::load_all_types_): New flag. (read_context::read_context): Initialize it. (read_context::canonical_types_scheduled): If some types still have non-canonicalized sub-types, then do not canonicalize them. (read_context::load_all_types): New member functions. (build_function_decl): Do not represent void return type like empty type anymore, rather, represent it like a void type node. (build_ir_node_from_die): When asked, load all types including those that are not reachable from an exported declaration. (create_read_context, read_corpus_from_elf): Take a new 'load_all_types' flag and honour it. * src/abg-reader.cc (read_context::type_is_from_translation_unit): Support looking up function types in the current translation unit, now that we now how to lookup function types. * include/abg-comparison.h (diff_context::{has_diff_for, add_diff, set_canonical_diff_for, set_or_get_canonical_diff_for, get_canonical_diff_for}): Make these take instances of type_or_decl_base_sptr, instead of decl_base_sptr. (diff::diff): Likewise. (diff::{first_subject, second_subject}): Make these return type_or_decl_base_sptr instead of decl_base_sptr. (type_diff_base::type_diff_base): Make these take instances of type_or_decl_base_sptr instead of decl_base_sptr. (distinct_diff::distinct_diff): Likewise. (distinct_diff::{first, second}): Make these return type_or_decl_base_sptr instead of decl_base_sptr. (distinct_diff::entities_are_of_distinct_kinds): Make these take instances of type_or_decl_base_sptr instead of decl_base_sptr. (class function_type_diff): Create this new type. It's a factorization of the function_decl_diff type. * src/abg-comparison.cc (): * src/abg-comp-filter.cc ({harmless, harmful}_filter::visit): Adjust as diff::{first,second}_subject() now returns a type_or_decl_base_sptr, no more a decl_base_sptr. (decls_type, decls_diff_map_type): Remove these typedefs and replace it with ... (types_or_decls_type, types_or_decls_diff_map_type): ... these. (struct {decls_hash, decls_equals): Remove these type sand replace them with ... (struct {types_or_decls_hash, types_or_decls_equals}): ... these. ({type_suppression, variable_suppression}::suppresses_diff): Adjust. (diff_context::priv::decls_diff_map): Replace this with ... (diff_context::priv::types_or_decls_diff_map): ... this. (diff_context::{has_diff_for, add_diff, get_canonical_diff_for, set_canonical_diff_for, set_or_get_canonical_diff_for}): Take type_or_decl_base_sptr instead of decl_base_sptr. (diff::priv::{first, second}_subject): Make the type of these be type_or_decl_base_sptr, no more decl_base_sptr. (diff::priv::priv): Adjust for the subjects of the diff being of type type_or_decl_sptr now, no more decl_base_sptr. (diff_less_than_functor::operator()(const diff_sptr, const diff_sptr) const): Adjust. (diff::diff): djust for the subjects of the diff being of type type_or_decl_sptr now, no more decl_base_sptr. (diff::{first,second}_subject): Make the type of these be type_or_decl_base_sptr, no more decl_base_sptr. (report_size_and_alignment_changes): Likewise. (type_diff_base::type_diff_base): Make the type of this be type_or_decl_base_sptr instead of type_base_sptr. (distinct_diff::distinct_diff): Make this take instances of type_or_decl_base_sptr instead of decl_base_sptr. (distinct_diff::{first, second, entities_are_of_distinct_kinds}): Likewise. (distinct_diff::has_changes): Simplify logic. (distinct_diff::report): Adjust. (compute_diff_for_types): Add an additional case to support the new function_type. (report_size_and_alignment_changes): Make this take instances of type_or_decl_base_sptr instead of decl_base_sptr. (class_diff::priv::member_type_has_changed): Return an instance of type_or_decl_base_sptr rather than a decl_base_sptr. (class_diff::report): Adjust. (diff_comp::operator()(const diff&, diff&) const): Adjust. (enum function_decl_diff::priv::Flags): Remove. (function_decl_diff::priv::{first_fn_flags_, second_fn_flags_, fn_flags_changes_}): Remove. (function_decl_diff::priv::{fn_is_declared_inline_to_flag, fn_binding_to_flag}): Remove. (function_decl_diff::{deleted_parameter_at, inserted_parameter_at}): Remove. (function_decl_diff::ensure_lookup_tables_populated): Empty this. (function_decl_diff::chain_into_hierarchy): Adjust. (function_decl_diff::function_decl_diff): This now only takes the subjects. It's body is now empty. (function_decl_diff::{return_type_diff, subtype_changed_parms, removed_parms, added_parms, type_diff}): Remove these member functions. (function_decl_diff::type_diff): Define new member function. (function_decl_diff::report): Simplify logic by using the reporting of the child type diff node. (compute_diff): Likewise, in the overload for function_decl_sptr simplify logic by using the child type diff object. (function_type_diff::priv): Define new type. (function_type_diff::{function_type_diff, ensure_lookup_tables_populated, deleted_parameter_at, inserted_parameter_at, finish_diff_type, first_function_type, second_function_type, return_type_diff, subtype_changed_parms, removed_parms, added_parms, get_pretty_representation, has_changes, has_local_changes, report, chain_into_hierarchy}): Define new functions. (compute_diff): Define new overload for function_type_sptr. * tools/abicompat.cc (options::weak_mode): New data member. (options::options): Initialize it. (enum abicompat_status): New enum (abicompat_status operator|(abicompat_status, abicompat_status)) (abicompat_status& operator|=(abicompat_status &, abicompat_status)) (abicompat_status operator&(abicompat_status, abicompat_status)): New operators to manipulate the abicompat_status enum. (display_usage): Add help string for the new --weak-mode option. (parse_command_line): Add the new --weak-mode command line argument. If the tool is called with just the application and one library then assume that we are in the weak mode. (perform_compat_check_in_normal_mode): Define new function, factorized from what was in the main function. (perform_compat_check_in_weak_mode): Define new function. (struct {fn,var}_change): Define new types. (main): Use perform_compat_check_in_weak_mode() and perform_compat_check_in_normal_mode(). * tools/abidiff.cc (main): Adjust. * tools/abidw.cc: (options::load_all_types): Add new data member. (options::options): Initialize it. (display_usage): New help string for --load-all-types. (parse_command_line): Support the new --load-all-types option. (main): Adjust and honour the --load-all-types option. * tools/abilint.cc (main): Adjust. * doc/manuals/abicompat.rst: Update documentation for the new weak mode. Also provide stuff that was missing from the examples provided. * doc/manuals/abidw.rst: Update documentation for the new --load-all-types option. * tests/print-diff-tree.cc (main): Adjust. * tests/test-diff-dwarf.cc (main): Likewise. * tests/test-read-dwarf.cc (main): Likewise. * tests/data/test-abicompat/test0-fn-changed-app: Recompile this. * tests/data/test-abicompat/libtest5-fn-changed-libapp-v{0,1}.so: New new test input binaries * tests/data/test-abicompat/test5-fn-changed-app: Likewise. * tests/data/test-abicompat/test6-var-changed-app: Likewise. * tests/data/test-abicompat/libtest6-var-changed-libapp-v{0,1}.so: Likewise. * tests/data/test-abicompat/test5-fn-changed-report-0.txt: Reference output for one test above. * tests/data/test-abicompat/test6-var-changed-report-0.txt: Likewise. * tests/data/test-abicompat/test5-fn-changed-app.cc: Source file for a binary above. * tests/data/test-abicompat/test5-fn-changed-libapp-v{0,1}.{h,cc}: Likewise. * tests/data/test-abicompat/test6-var-changed-libapp-v{0,1}.{cc,h}: Likewise. * tests/data/test-abicompat/test6-var-changed-app.cc: Likewise. * tests/data/Makefile.am: Add the test related files above to the source distribution. * tests/test-abicompat.cc (in_out_spec): Add the new test input above to the list of inputs to feed to this test harness. (main): Support taking just the app and one library. * tests/data/test-read-dwarf/test{0, 1, 2.so, 3.so, 5.o, 8-qualified-this-pointer.so,}.abi: Adjust for void type being really emitted now, as opposed to just being an empty type. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-04-01 10:13:38 +00:00
9 foo* f = new foo();
10 return f;
11 }
12
13 void
14 second_func(foo&)
15 {
16 }
17
18 void
19 third_func()
20 {
21 }
$
$ cat -n test1.h
1 struct foo
2 {
3 int m0;
4 char m1; /* <-- a new member got added here! */
5
6 foo()
7 : m0(),
8 m1()
9 {}
10 };
11
12 foo*
13 first_func();
14
15 void
16 second_func(foo&);
17
18 void
19 third_func();
Initial implementation of the abicompat tool Given an application A that links to a shared library L of version V denoted L(V) and a subsequent version of that library denoted L(V+P), the 'abicompat' tool tells the user if L(V+P) is still ABI compatible with L(V+P). And if it is not, abicompat gives a reports that shows the differences between L(V) and L(V+P) that makes L(V+P) ABI-incompatible with A. The source code of this tool is in the tools/abicompat.cc source file. To support this new tool, this commit changes the comparison engine to optionally avoid showing added symbols that were not referenced by any debug info. It changes the ABI corpus type to allow the specification of a list of variables and functions symbols to keep (and drop all other functions and variables which have other symbols on the floor even before starting to compare the two libraries). This is how the abicompat tool itself works. It basically compares L(V) and L(V+P) but it only looks at their exported functions and variables which symbols are undefined in application A. If the list of exported and defined variables and functions of L(V) whose symbols are undefined in A equals that of L(V+P) (including the sub-types of these variables and functions) A is still compatible with L(V+P). Otherwise, they might not be compatible depending on the kind of differences that are found. * include/abg-comparison.h (diff_context::show_added_symbols_unreferenced_by_debug_info): Declare new accessors. (corpus_diff::{deleted_variables, deleted_unrefed_function_symbols, deleted_unrefed_variable_symbols, apply_filters_and_suppressions_before_reporting}): Declare new methods. (corpus_diff::diff_stats): Declare this new type. Actually this was previously corpus_diff::priv::diff_stats, which was a hidden internal type.. We are moving it here, in the external API so that client code can have more information about changes statistics. Change all the previously publicly accessible data members into accessor functions. * src/abg-comparison.cc (class corpus_diff::diff_stats::priv): New type. (diff_context::priv::show_added_syms_unreferenced_by_di_): New data member. (diff_context::priv::priv): Adjust. (diff_context::show_added_symbols_unreferenced_by_debug_info): Define this new method. (corpus_diff::priv::emit_diff_stats): Do not show the diff stat if the only changes is added function or variables symbols and if we were instructed to not show added symbols. (corpus_diff::priv::{diff_stats_, filters_and_suppr_applied_}): New data members. (corpus_diff::priv::priv): Initialize the filters_and_suppr_applied_ data member. (corpus_diff::priv::diff_stats): Move this type to corpus_diff::diff_stats. (corpus_diff::priv::{apply_filters_and_compute_diff_stats, emit_diff_stats}): Adjust. (corpus_diff::apply_filters_and_suppressions_before_reporting): Define new member function. (corpus_diff::report): Use the new apply_filters_and_suppressions_before_reporting() function, rather than applying the filters and suppressions by ourselves. Also adjust to the use the accessors of the new corpus_diff::diff_stats type. (corpus_diff::{deleted_variables, deleted_unrefed_function_symbols, deleted_unrefed_variable_symbols}): Define new accessors. (corpus_diff::diff_stats::{diff_stats, num_func_removed, num_func_added, num_func_changed, num_func_filtered_out, net_num_func_changed, num_vars_removed, num_vars_added, num_vars_changed, num_vars_filtered_out, net_num_vars_changed, num_func_sym_removed, num_func_syms_added, num_var_syms_removed, num_var_syms_added}): Define new member functions. * include/abg-corpus.h (corpus::{get_sym_ids_of_fns_to_keep, get_sym_ids_of_vars_to_keep}): Declare new methods. * src/abg-corpus.cc (corpus::priv::{sym_id_fns_to_keep, sym_id_vars_to_keep}): Added data members. (symtab_build_visitor_type::{unrefed_fun_symbols, unrefed_var_symbols, sym_id_fns_to_keep, sym_id_vars_to_keep}): Added new data members. (symtab_build_visitor_type::symtab_build_visitor_type): Take two additional parameters for the function and variable symbol ids to keep. (symtab_build_visitor_type::add_fn_to_wip_fns): Take the function symbols to keep in account when building the exported symbol table. (symtab_build_visitor_type::add_var_to_wip_vars): Likewise, take the variable symbols to keep in account when building the exported symbol table. (corpus::priv::build_public_decl_table): Adjust the initialization of the visitor that walks the ABI artifacts to build the exported symbol table to know take a list of function/variable symbols to keep. (corpus::priv::build_unreferenced_symbols_tables): Ensure that the public table of functions/variables is built before doing the work of this function. Also, if a list of variable/function symbols to keep is given, drop all symbols that are not in that list on the floor. (corpus::{get_sym_ids_of_fns_to_keep, get_sym_ids_of_vars_to_keep}): Define new accessors. * tools/abicompat.cc: New abicompat tool. * doc/manuals/abicompat.rst: New documentation source for abicompat. * doc/manuals/libabigail-tools.rst: Add an entry for the abicompat doc. * tests/test-abicompat.cc: New test harness for the 'abicompat' tool. * tests/Makefile.am: Build the runtestabicompat test harness and add it to the list of tests harnesses that are run by make check. * tests/data/test-abicompat/libtest0-fn-changed-libapp-v0.so: New test input. * tests/data/test-abicompat/libtest0-fn-changed-libapp-v1.so: Likewise. * tests/data/test-abicompat/test0-fn-changed-app: Likewise. * tests/data/test-abicompat/test0-fn-changed-0.suppr: Likewise * tests/data/test-abicompat/test0-fn-changed-report-0.txt: Likewise. * tests/data/test-abicompat/test0-fn-changed-report-1.txt: Likewise. * tests/data/test-abicompat/test0-fn-changed-app.cc: Likewise. * tests/data/test-abicompat/test0-fn-changed-libapp.h: Likewise. * tests/data/test-abicompat/test0-fn-changed-libapp-v0.cc: Likewise. * tests/data/test-abicompat/test0-fn-changed-libapp-v1.cc: Likewise. * tests/data/test-abicompat/libtest1-fn-removed-v0.so: Likewise. * tests/data/test-abicompat/libtest1-fn-removed-v1.so: Likewise. * tests/data/test-abicompat/test1-fn-removed-app: Likewise. * tests/data/test-abicompat/test1-fn-removed-app.cc: Likewise. * tests/data/test-abicompat/test1-fn-removed-report-0.txt: Likewise. * tests/data/test-abicompat/test1-fn-removed-v0.cc: Likewise. * tests/data/test-abicompat/test1-fn-removed-v1.cc: Likewise. * tests/data/test-abicompat/libtest2-var-removed-v0.so: Likewise. * tests/data/test-abicompat/libtest2-var-removed-v1.so: Likewise. * tests/data/test-abicompat/test2-var-removed-app: Likewise. * tests/data/test-abicompat/test2-var-removed-app.cc: Likewise. * tests/data/test-abicompat/test2-var-removed-report-0.txt: Likewise. * tests/data/test-abicompat/test2-var-removed-v0.cc: Likewise. * tests/data/test-abicompat/test2-var-removed-v1.cc: Likewise. * tests/data/test-abicompat/libtest3-fn-removed-v0.so: Likewise. * tests/data/test-abicompat/libtest3-fn-removed-v1.so: Likewise. * tests/data/test-abicompat/test3-fn-removed-app: Likewise. * tests/data/test-abicompat/test3-fn-removed-app.cc: Likewise. * tests/data/test-abicompat/test3-fn-removed-report-0.txt: Likewise. * tests/data/test-abicompat/test3-fn-removed-v0.cc: Likewise. * tests/data/test-abicompat/test3-fn-removed-v1.cc: Likewise. * tests/data/test-abicompat/test3-fn-removed-version-script-0 Likewise.: * tests/data/test-abicompat/test3-fn-removed-version-script-1: Likewise. * tests/data/Makefile.am: Add the new test inputs above to the source distribution. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-11-30 17:18:55 +00:00
$
Add support for abicompat weak mode This patch implements the weak mode of abicompat. In this mode, just the application and the new version of the library are provided. The types of functions and variables of the library that are consumed by the application are compared to the types of the functions and variables expected by the application. The goal is to check if the types of the declarations consumed by the application and provided by the library are compatible with what the application expects. The abicompat first gets the set of symbols undefined in the application and exported by the library. It then builds the set of declarations exported by the library that have those symbols. We call these the set of declarations of the library that are consumed by the application. Note that the debug information for the application does not contain the declarations of the functions/variables whose symbols are undefined. So we can not just read them to compare them to declarations exported by the library. But the *types* of the variables and the *sub-types* of the functions whose symbols are undefined in the application are present in the debug information of the application. So in the weak mode, abicompat compare the *types* of the declarations consumed by the application as expected by the application (described by the debug information of the application) with the types of the declarations exported by the library. To do this a number of changes were necessary. The patch builds a representation of all the types found in the application's debug info. Before that, only the types that are reachable from exported declarations were represented. The abidw tool got a new --load-all-types to test this new ability of loading all types. The patch also adds support for looking a type, not by name, but by its internal representation. In the comparison engine, function_type_diff is introduced to represent changes between two function types. For this, a new class type_or_decl_base has been introduced in the IR. It's now the base class for both decl_base and type_base. And abigail::comparison::diff now takes two pointers of type_or_decl, not decl_base anymore. So function_type_diff can take two function_type now; not that a function_type has no declaration so it doesn't inherit decl_base. A bunch of changes got made just to adjust to this modification. A number of fixes were made too, to make this work, like adding missing comparison operators, removing asserts that too strong, etc.. The patch also adjust the test suite as well as the documentation. * include/abg-fwd.h (class type_or_decl_base): Forward declare this. (is_decl, is_type, is_function_type, get_name, get_type_name) (get_function_type_name, get_pretty_representation) (lookup_function_type_in_corpus, lookup_type_in_translation_unit) (lookup_function_type_in_translation_unit) (synthesize_function_type_from_translation_unit) (hash_type_or_decl): New function declarations. * src/abg-corpus.cc (lookup_type_in_corpus) (lookup_function_type_in_corpus): Define new functions. * include/abg-ir.h (translation_unit::lookup_function_type_in_translation_unit): Declare new friend function. (class type_or_decl_base): Declare this. (operator==(const type_or_decl_base&, const type_or_decl_base&)): Declare new operator. (operator==(const type_or_decl_base_sptr&, const type_or_decl_base_sptr&)): Likewise. (class {decl_base, type_base}): Make these class inherit type_or_decl_base. (decl_base::get_member_scopes): New const overload. (bool operator==(const function_decl::parameter_sptr&, const function_decl::parameter_sptr&)): New operator. (function_type::get_parameters): Remove the non-const overload. (function_type::get_pretty_representation): Declare new member function. (method_type::get_pretty_representation): Likewise. * src/abg-ir.cc (bool operator==(const type_or_decl_base&, const type_or_decl_base&)): Define new equality operator. (bool operator==(const type_or_decl_base_sptr&, const type_or_decl_base_sptr&)): Likewise. (strip_typedef): Do not expect canonicalized types anymore. Now the system accepts (and expects) canonicalized types in certain cases. For instance, non-complete types and aggregated types that contain non-complete sub-types. (get_name, get_function_type_name, get_type_name) (get_pretty_representation, is_decl, is_type, is_function_type) (lookup_function_type_in_translation_unit) (synthesize_function_type_from_translation_unit) (lookup_type_in_scope, lookup_type_in_translation_unit): Define new functions or new overloads. (bool operator==(const function_decl::parameter_sptr&, const function_decl::parameter_sptr& r)): Define new operator. (function_type::get_parameters): Remove non-const overload. (function_type::get_pretty_representation): Define new function. (function_type::traverse): Adjust. (method_type::get_pretty_representation): Likewise. (function_decl::get_pretty_representation): Avoid emitting the type of cdtors. (hash_type_or_decl): Define new function. * include/abg-dwarf-reader.h (create_read_context) (read_corpus_from_elf): Take a new 'read_all_types' flag. * src/abg-dwarf-reader.cc (read_context::load_all_types_): New flag. (read_context::read_context): Initialize it. (read_context::canonical_types_scheduled): If some types still have non-canonicalized sub-types, then do not canonicalize them. (read_context::load_all_types): New member functions. (build_function_decl): Do not represent void return type like empty type anymore, rather, represent it like a void type node. (build_ir_node_from_die): When asked, load all types including those that are not reachable from an exported declaration. (create_read_context, read_corpus_from_elf): Take a new 'load_all_types' flag and honour it. * src/abg-reader.cc (read_context::type_is_from_translation_unit): Support looking up function types in the current translation unit, now that we now how to lookup function types. * include/abg-comparison.h (diff_context::{has_diff_for, add_diff, set_canonical_diff_for, set_or_get_canonical_diff_for, get_canonical_diff_for}): Make these take instances of type_or_decl_base_sptr, instead of decl_base_sptr. (diff::diff): Likewise. (diff::{first_subject, second_subject}): Make these return type_or_decl_base_sptr instead of decl_base_sptr. (type_diff_base::type_diff_base): Make these take instances of type_or_decl_base_sptr instead of decl_base_sptr. (distinct_diff::distinct_diff): Likewise. (distinct_diff::{first, second}): Make these return type_or_decl_base_sptr instead of decl_base_sptr. (distinct_diff::entities_are_of_distinct_kinds): Make these take instances of type_or_decl_base_sptr instead of decl_base_sptr. (class function_type_diff): Create this new type. It's a factorization of the function_decl_diff type. * src/abg-comparison.cc (): * src/abg-comp-filter.cc ({harmless, harmful}_filter::visit): Adjust as diff::{first,second}_subject() now returns a type_or_decl_base_sptr, no more a decl_base_sptr. (decls_type, decls_diff_map_type): Remove these typedefs and replace it with ... (types_or_decls_type, types_or_decls_diff_map_type): ... these. (struct {decls_hash, decls_equals): Remove these type sand replace them with ... (struct {types_or_decls_hash, types_or_decls_equals}): ... these. ({type_suppression, variable_suppression}::suppresses_diff): Adjust. (diff_context::priv::decls_diff_map): Replace this with ... (diff_context::priv::types_or_decls_diff_map): ... this. (diff_context::{has_diff_for, add_diff, get_canonical_diff_for, set_canonical_diff_for, set_or_get_canonical_diff_for}): Take type_or_decl_base_sptr instead of decl_base_sptr. (diff::priv::{first, second}_subject): Make the type of these be type_or_decl_base_sptr, no more decl_base_sptr. (diff::priv::priv): Adjust for the subjects of the diff being of type type_or_decl_sptr now, no more decl_base_sptr. (diff_less_than_functor::operator()(const diff_sptr, const diff_sptr) const): Adjust. (diff::diff): djust for the subjects of the diff being of type type_or_decl_sptr now, no more decl_base_sptr. (diff::{first,second}_subject): Make the type of these be type_or_decl_base_sptr, no more decl_base_sptr. (report_size_and_alignment_changes): Likewise. (type_diff_base::type_diff_base): Make the type of this be type_or_decl_base_sptr instead of type_base_sptr. (distinct_diff::distinct_diff): Make this take instances of type_or_decl_base_sptr instead of decl_base_sptr. (distinct_diff::{first, second, entities_are_of_distinct_kinds}): Likewise. (distinct_diff::has_changes): Simplify logic. (distinct_diff::report): Adjust. (compute_diff_for_types): Add an additional case to support the new function_type. (report_size_and_alignment_changes): Make this take instances of type_or_decl_base_sptr instead of decl_base_sptr. (class_diff::priv::member_type_has_changed): Return an instance of type_or_decl_base_sptr rather than a decl_base_sptr. (class_diff::report): Adjust. (diff_comp::operator()(const diff&, diff&) const): Adjust. (enum function_decl_diff::priv::Flags): Remove. (function_decl_diff::priv::{first_fn_flags_, second_fn_flags_, fn_flags_changes_}): Remove. (function_decl_diff::priv::{fn_is_declared_inline_to_flag, fn_binding_to_flag}): Remove. (function_decl_diff::{deleted_parameter_at, inserted_parameter_at}): Remove. (function_decl_diff::ensure_lookup_tables_populated): Empty this. (function_decl_diff::chain_into_hierarchy): Adjust. (function_decl_diff::function_decl_diff): This now only takes the subjects. It's body is now empty. (function_decl_diff::{return_type_diff, subtype_changed_parms, removed_parms, added_parms, type_diff}): Remove these member functions. (function_decl_diff::type_diff): Define new member function. (function_decl_diff::report): Simplify logic by using the reporting of the child type diff node. (compute_diff): Likewise, in the overload for function_decl_sptr simplify logic by using the child type diff object. (function_type_diff::priv): Define new type. (function_type_diff::{function_type_diff, ensure_lookup_tables_populated, deleted_parameter_at, inserted_parameter_at, finish_diff_type, first_function_type, second_function_type, return_type_diff, subtype_changed_parms, removed_parms, added_parms, get_pretty_representation, has_changes, has_local_changes, report, chain_into_hierarchy}): Define new functions. (compute_diff): Define new overload for function_type_sptr. * tools/abicompat.cc (options::weak_mode): New data member. (options::options): Initialize it. (enum abicompat_status): New enum (abicompat_status operator|(abicompat_status, abicompat_status)) (abicompat_status& operator|=(abicompat_status &, abicompat_status)) (abicompat_status operator&(abicompat_status, abicompat_status)): New operators to manipulate the abicompat_status enum. (display_usage): Add help string for the new --weak-mode option. (parse_command_line): Add the new --weak-mode command line argument. If the tool is called with just the application and one library then assume that we are in the weak mode. (perform_compat_check_in_normal_mode): Define new function, factorized from what was in the main function. (perform_compat_check_in_weak_mode): Define new function. (struct {fn,var}_change): Define new types. (main): Use perform_compat_check_in_weak_mode() and perform_compat_check_in_normal_mode(). * tools/abidiff.cc (main): Adjust. * tools/abidw.cc: (options::load_all_types): Add new data member. (options::options): Initialize it. (display_usage): New help string for --load-all-types. (parse_command_line): Support the new --load-all-types option. (main): Adjust and honour the --load-all-types option. * tools/abilint.cc (main): Adjust. * doc/manuals/abicompat.rst: Update documentation for the new weak mode. Also provide stuff that was missing from the examples provided. * doc/manuals/abidw.rst: Update documentation for the new --load-all-types option. * tests/print-diff-tree.cc (main): Adjust. * tests/test-diff-dwarf.cc (main): Likewise. * tests/test-read-dwarf.cc (main): Likewise. * tests/data/test-abicompat/test0-fn-changed-app: Recompile this. * tests/data/test-abicompat/libtest5-fn-changed-libapp-v{0,1}.so: New new test input binaries * tests/data/test-abicompat/test5-fn-changed-app: Likewise. * tests/data/test-abicompat/test6-var-changed-app: Likewise. * tests/data/test-abicompat/libtest6-var-changed-libapp-v{0,1}.so: Likewise. * tests/data/test-abicompat/test5-fn-changed-report-0.txt: Reference output for one test above. * tests/data/test-abicompat/test6-var-changed-report-0.txt: Likewise. * tests/data/test-abicompat/test5-fn-changed-app.cc: Source file for a binary above. * tests/data/test-abicompat/test5-fn-changed-libapp-v{0,1}.{h,cc}: Likewise. * tests/data/test-abicompat/test6-var-changed-libapp-v{0,1}.{cc,h}: Likewise. * tests/data/test-abicompat/test6-var-changed-app.cc: Likewise. * tests/data/Makefile.am: Add the test related files above to the source distribution. * tests/test-abicompat.cc (in_out_spec): Add the new test input above to the list of inputs to feed to this test harness. (main): Support taking just the app and one library. * tests/data/test-read-dwarf/test{0, 1, 2.so, 3.so, 5.o, 8-qualified-this-pointer.so,}.abi: Adjust for void type being really emitted now, as opposed to just being an empty type. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-04-01 10:13:38 +00:00
Initial implementation of the abicompat tool Given an application A that links to a shared library L of version V denoted L(V) and a subsequent version of that library denoted L(V+P), the 'abicompat' tool tells the user if L(V+P) is still ABI compatible with L(V+P). And if it is not, abicompat gives a reports that shows the differences between L(V) and L(V+P) that makes L(V+P) ABI-incompatible with A. The source code of this tool is in the tools/abicompat.cc source file. To support this new tool, this commit changes the comparison engine to optionally avoid showing added symbols that were not referenced by any debug info. It changes the ABI corpus type to allow the specification of a list of variables and functions symbols to keep (and drop all other functions and variables which have other symbols on the floor even before starting to compare the two libraries). This is how the abicompat tool itself works. It basically compares L(V) and L(V+P) but it only looks at their exported functions and variables which symbols are undefined in application A. If the list of exported and defined variables and functions of L(V) whose symbols are undefined in A equals that of L(V+P) (including the sub-types of these variables and functions) A is still compatible with L(V+P). Otherwise, they might not be compatible depending on the kind of differences that are found. * include/abg-comparison.h (diff_context::show_added_symbols_unreferenced_by_debug_info): Declare new accessors. (corpus_diff::{deleted_variables, deleted_unrefed_function_symbols, deleted_unrefed_variable_symbols, apply_filters_and_suppressions_before_reporting}): Declare new methods. (corpus_diff::diff_stats): Declare this new type. Actually this was previously corpus_diff::priv::diff_stats, which was a hidden internal type.. We are moving it here, in the external API so that client code can have more information about changes statistics. Change all the previously publicly accessible data members into accessor functions. * src/abg-comparison.cc (class corpus_diff::diff_stats::priv): New type. (diff_context::priv::show_added_syms_unreferenced_by_di_): New data member. (diff_context::priv::priv): Adjust. (diff_context::show_added_symbols_unreferenced_by_debug_info): Define this new method. (corpus_diff::priv::emit_diff_stats): Do not show the diff stat if the only changes is added function or variables symbols and if we were instructed to not show added symbols. (corpus_diff::priv::{diff_stats_, filters_and_suppr_applied_}): New data members. (corpus_diff::priv::priv): Initialize the filters_and_suppr_applied_ data member. (corpus_diff::priv::diff_stats): Move this type to corpus_diff::diff_stats. (corpus_diff::priv::{apply_filters_and_compute_diff_stats, emit_diff_stats}): Adjust. (corpus_diff::apply_filters_and_suppressions_before_reporting): Define new member function. (corpus_diff::report): Use the new apply_filters_and_suppressions_before_reporting() function, rather than applying the filters and suppressions by ourselves. Also adjust to the use the accessors of the new corpus_diff::diff_stats type. (corpus_diff::{deleted_variables, deleted_unrefed_function_symbols, deleted_unrefed_variable_symbols}): Define new accessors. (corpus_diff::diff_stats::{diff_stats, num_func_removed, num_func_added, num_func_changed, num_func_filtered_out, net_num_func_changed, num_vars_removed, num_vars_added, num_vars_changed, num_vars_filtered_out, net_num_vars_changed, num_func_sym_removed, num_func_syms_added, num_var_syms_removed, num_var_syms_added}): Define new member functions. * include/abg-corpus.h (corpus::{get_sym_ids_of_fns_to_keep, get_sym_ids_of_vars_to_keep}): Declare new methods. * src/abg-corpus.cc (corpus::priv::{sym_id_fns_to_keep, sym_id_vars_to_keep}): Added data members. (symtab_build_visitor_type::{unrefed_fun_symbols, unrefed_var_symbols, sym_id_fns_to_keep, sym_id_vars_to_keep}): Added new data members. (symtab_build_visitor_type::symtab_build_visitor_type): Take two additional parameters for the function and variable symbol ids to keep. (symtab_build_visitor_type::add_fn_to_wip_fns): Take the function symbols to keep in account when building the exported symbol table. (symtab_build_visitor_type::add_var_to_wip_vars): Likewise, take the variable symbols to keep in account when building the exported symbol table. (corpus::priv::build_public_decl_table): Adjust the initialization of the visitor that walks the ABI artifacts to build the exported symbol table to know take a list of function/variable symbols to keep. (corpus::priv::build_unreferenced_symbols_tables): Ensure that the public table of functions/variables is built before doing the work of this function. Also, if a list of variable/function symbols to keep is given, drop all symbols that are not in that list on the floor. (corpus::{get_sym_ids_of_fns_to_keep, get_sym_ids_of_vars_to_keep}): Define new accessors. * tools/abicompat.cc: New abicompat tool. * doc/manuals/abicompat.rst: New documentation source for abicompat. * doc/manuals/libabigail-tools.rst: Add an entry for the abicompat doc. * tests/test-abicompat.cc: New test harness for the 'abicompat' tool. * tests/Makefile.am: Build the runtestabicompat test harness and add it to the list of tests harnesses that are run by make check. * tests/data/test-abicompat/libtest0-fn-changed-libapp-v0.so: New test input. * tests/data/test-abicompat/libtest0-fn-changed-libapp-v1.so: Likewise. * tests/data/test-abicompat/test0-fn-changed-app: Likewise. * tests/data/test-abicompat/test0-fn-changed-0.suppr: Likewise * tests/data/test-abicompat/test0-fn-changed-report-0.txt: Likewise. * tests/data/test-abicompat/test0-fn-changed-report-1.txt: Likewise. * tests/data/test-abicompat/test0-fn-changed-app.cc: Likewise. * tests/data/test-abicompat/test0-fn-changed-libapp.h: Likewise. * tests/data/test-abicompat/test0-fn-changed-libapp-v0.cc: Likewise. * tests/data/test-abicompat/test0-fn-changed-libapp-v1.cc: Likewise. * tests/data/test-abicompat/libtest1-fn-removed-v0.so: Likewise. * tests/data/test-abicompat/libtest1-fn-removed-v1.so: Likewise. * tests/data/test-abicompat/test1-fn-removed-app: Likewise. * tests/data/test-abicompat/test1-fn-removed-app.cc: Likewise. * tests/data/test-abicompat/test1-fn-removed-report-0.txt: Likewise. * tests/data/test-abicompat/test1-fn-removed-v0.cc: Likewise. * tests/data/test-abicompat/test1-fn-removed-v1.cc: Likewise. * tests/data/test-abicompat/libtest2-var-removed-v0.so: Likewise. * tests/data/test-abicompat/libtest2-var-removed-v1.so: Likewise. * tests/data/test-abicompat/test2-var-removed-app: Likewise. * tests/data/test-abicompat/test2-var-removed-app.cc: Likewise. * tests/data/test-abicompat/test2-var-removed-report-0.txt: Likewise. * tests/data/test-abicompat/test2-var-removed-v0.cc: Likewise. * tests/data/test-abicompat/test2-var-removed-v1.cc: Likewise. * tests/data/test-abicompat/libtest3-fn-removed-v0.so: Likewise. * tests/data/test-abicompat/libtest3-fn-removed-v1.so: Likewise. * tests/data/test-abicompat/test3-fn-removed-app: Likewise. * tests/data/test-abicompat/test3-fn-removed-app.cc: Likewise. * tests/data/test-abicompat/test3-fn-removed-report-0.txt: Likewise. * tests/data/test-abicompat/test3-fn-removed-v0.cc: Likewise. * tests/data/test-abicompat/test3-fn-removed-v1.cc: Likewise. * tests/data/test-abicompat/test3-fn-removed-version-script-0 Likewise.: * tests/data/test-abicompat/test3-fn-removed-version-script-1: Likewise. * tests/data/Makefile.am: Add the new test inputs above to the source distribution. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-11-30 17:18:55 +00:00
$ cat -n test1.cc
1 // Compile this with:
2 // g++ -g -Wall -shared -o libtest-1.so test1.cc
Add support for abicompat weak mode This patch implements the weak mode of abicompat. In this mode, just the application and the new version of the library are provided. The types of functions and variables of the library that are consumed by the application are compared to the types of the functions and variables expected by the application. The goal is to check if the types of the declarations consumed by the application and provided by the library are compatible with what the application expects. The abicompat first gets the set of symbols undefined in the application and exported by the library. It then builds the set of declarations exported by the library that have those symbols. We call these the set of declarations of the library that are consumed by the application. Note that the debug information for the application does not contain the declarations of the functions/variables whose symbols are undefined. So we can not just read them to compare them to declarations exported by the library. But the *types* of the variables and the *sub-types* of the functions whose symbols are undefined in the application are present in the debug information of the application. So in the weak mode, abicompat compare the *types* of the declarations consumed by the application as expected by the application (described by the debug information of the application) with the types of the declarations exported by the library. To do this a number of changes were necessary. The patch builds a representation of all the types found in the application's debug info. Before that, only the types that are reachable from exported declarations were represented. The abidw tool got a new --load-all-types to test this new ability of loading all types. The patch also adds support for looking a type, not by name, but by its internal representation. In the comparison engine, function_type_diff is introduced to represent changes between two function types. For this, a new class type_or_decl_base has been introduced in the IR. It's now the base class for both decl_base and type_base. And abigail::comparison::diff now takes two pointers of type_or_decl, not decl_base anymore. So function_type_diff can take two function_type now; not that a function_type has no declaration so it doesn't inherit decl_base. A bunch of changes got made just to adjust to this modification. A number of fixes were made too, to make this work, like adding missing comparison operators, removing asserts that too strong, etc.. The patch also adjust the test suite as well as the documentation. * include/abg-fwd.h (class type_or_decl_base): Forward declare this. (is_decl, is_type, is_function_type, get_name, get_type_name) (get_function_type_name, get_pretty_representation) (lookup_function_type_in_corpus, lookup_type_in_translation_unit) (lookup_function_type_in_translation_unit) (synthesize_function_type_from_translation_unit) (hash_type_or_decl): New function declarations. * src/abg-corpus.cc (lookup_type_in_corpus) (lookup_function_type_in_corpus): Define new functions. * include/abg-ir.h (translation_unit::lookup_function_type_in_translation_unit): Declare new friend function. (class type_or_decl_base): Declare this. (operator==(const type_or_decl_base&, const type_or_decl_base&)): Declare new operator. (operator==(const type_or_decl_base_sptr&, const type_or_decl_base_sptr&)): Likewise. (class {decl_base, type_base}): Make these class inherit type_or_decl_base. (decl_base::get_member_scopes): New const overload. (bool operator==(const function_decl::parameter_sptr&, const function_decl::parameter_sptr&)): New operator. (function_type::get_parameters): Remove the non-const overload. (function_type::get_pretty_representation): Declare new member function. (method_type::get_pretty_representation): Likewise. * src/abg-ir.cc (bool operator==(const type_or_decl_base&, const type_or_decl_base&)): Define new equality operator. (bool operator==(const type_or_decl_base_sptr&, const type_or_decl_base_sptr&)): Likewise. (strip_typedef): Do not expect canonicalized types anymore. Now the system accepts (and expects) canonicalized types in certain cases. For instance, non-complete types and aggregated types that contain non-complete sub-types. (get_name, get_function_type_name, get_type_name) (get_pretty_representation, is_decl, is_type, is_function_type) (lookup_function_type_in_translation_unit) (synthesize_function_type_from_translation_unit) (lookup_type_in_scope, lookup_type_in_translation_unit): Define new functions or new overloads. (bool operator==(const function_decl::parameter_sptr&, const function_decl::parameter_sptr& r)): Define new operator. (function_type::get_parameters): Remove non-const overload. (function_type::get_pretty_representation): Define new function. (function_type::traverse): Adjust. (method_type::get_pretty_representation): Likewise. (function_decl::get_pretty_representation): Avoid emitting the type of cdtors. (hash_type_or_decl): Define new function. * include/abg-dwarf-reader.h (create_read_context) (read_corpus_from_elf): Take a new 'read_all_types' flag. * src/abg-dwarf-reader.cc (read_context::load_all_types_): New flag. (read_context::read_context): Initialize it. (read_context::canonical_types_scheduled): If some types still have non-canonicalized sub-types, then do not canonicalize them. (read_context::load_all_types): New member functions. (build_function_decl): Do not represent void return type like empty type anymore, rather, represent it like a void type node. (build_ir_node_from_die): When asked, load all types including those that are not reachable from an exported declaration. (create_read_context, read_corpus_from_elf): Take a new 'load_all_types' flag and honour it. * src/abg-reader.cc (read_context::type_is_from_translation_unit): Support looking up function types in the current translation unit, now that we now how to lookup function types. * include/abg-comparison.h (diff_context::{has_diff_for, add_diff, set_canonical_diff_for, set_or_get_canonical_diff_for, get_canonical_diff_for}): Make these take instances of type_or_decl_base_sptr, instead of decl_base_sptr. (diff::diff): Likewise. (diff::{first_subject, second_subject}): Make these return type_or_decl_base_sptr instead of decl_base_sptr. (type_diff_base::type_diff_base): Make these take instances of type_or_decl_base_sptr instead of decl_base_sptr. (distinct_diff::distinct_diff): Likewise. (distinct_diff::{first, second}): Make these return type_or_decl_base_sptr instead of decl_base_sptr. (distinct_diff::entities_are_of_distinct_kinds): Make these take instances of type_or_decl_base_sptr instead of decl_base_sptr. (class function_type_diff): Create this new type. It's a factorization of the function_decl_diff type. * src/abg-comparison.cc (): * src/abg-comp-filter.cc ({harmless, harmful}_filter::visit): Adjust as diff::{first,second}_subject() now returns a type_or_decl_base_sptr, no more a decl_base_sptr. (decls_type, decls_diff_map_type): Remove these typedefs and replace it with ... (types_or_decls_type, types_or_decls_diff_map_type): ... these. (struct {decls_hash, decls_equals): Remove these type sand replace them with ... (struct {types_or_decls_hash, types_or_decls_equals}): ... these. ({type_suppression, variable_suppression}::suppresses_diff): Adjust. (diff_context::priv::decls_diff_map): Replace this with ... (diff_context::priv::types_or_decls_diff_map): ... this. (diff_context::{has_diff_for, add_diff, get_canonical_diff_for, set_canonical_diff_for, set_or_get_canonical_diff_for}): Take type_or_decl_base_sptr instead of decl_base_sptr. (diff::priv::{first, second}_subject): Make the type of these be type_or_decl_base_sptr, no more decl_base_sptr. (diff::priv::priv): Adjust for the subjects of the diff being of type type_or_decl_sptr now, no more decl_base_sptr. (diff_less_than_functor::operator()(const diff_sptr, const diff_sptr) const): Adjust. (diff::diff): djust for the subjects of the diff being of type type_or_decl_sptr now, no more decl_base_sptr. (diff::{first,second}_subject): Make the type of these be type_or_decl_base_sptr, no more decl_base_sptr. (report_size_and_alignment_changes): Likewise. (type_diff_base::type_diff_base): Make the type of this be type_or_decl_base_sptr instead of type_base_sptr. (distinct_diff::distinct_diff): Make this take instances of type_or_decl_base_sptr instead of decl_base_sptr. (distinct_diff::{first, second, entities_are_of_distinct_kinds}): Likewise. (distinct_diff::has_changes): Simplify logic. (distinct_diff::report): Adjust. (compute_diff_for_types): Add an additional case to support the new function_type. (report_size_and_alignment_changes): Make this take instances of type_or_decl_base_sptr instead of decl_base_sptr. (class_diff::priv::member_type_has_changed): Return an instance of type_or_decl_base_sptr rather than a decl_base_sptr. (class_diff::report): Adjust. (diff_comp::operator()(const diff&, diff&) const): Adjust. (enum function_decl_diff::priv::Flags): Remove. (function_decl_diff::priv::{first_fn_flags_, second_fn_flags_, fn_flags_changes_}): Remove. (function_decl_diff::priv::{fn_is_declared_inline_to_flag, fn_binding_to_flag}): Remove. (function_decl_diff::{deleted_parameter_at, inserted_parameter_at}): Remove. (function_decl_diff::ensure_lookup_tables_populated): Empty this. (function_decl_diff::chain_into_hierarchy): Adjust. (function_decl_diff::function_decl_diff): This now only takes the subjects. It's body is now empty. (function_decl_diff::{return_type_diff, subtype_changed_parms, removed_parms, added_parms, type_diff}): Remove these member functions. (function_decl_diff::type_diff): Define new member function. (function_decl_diff::report): Simplify logic by using the reporting of the child type diff node. (compute_diff): Likewise, in the overload for function_decl_sptr simplify logic by using the child type diff object. (function_type_diff::priv): Define new type. (function_type_diff::{function_type_diff, ensure_lookup_tables_populated, deleted_parameter_at, inserted_parameter_at, finish_diff_type, first_function_type, second_function_type, return_type_diff, subtype_changed_parms, removed_parms, added_parms, get_pretty_representation, has_changes, has_local_changes, report, chain_into_hierarchy}): Define new functions. (compute_diff): Define new overload for function_type_sptr. * tools/abicompat.cc (options::weak_mode): New data member. (options::options): Initialize it. (enum abicompat_status): New enum (abicompat_status operator|(abicompat_status, abicompat_status)) (abicompat_status& operator|=(abicompat_status &, abicompat_status)) (abicompat_status operator&(abicompat_status, abicompat_status)): New operators to manipulate the abicompat_status enum. (display_usage): Add help string for the new --weak-mode option. (parse_command_line): Add the new --weak-mode command line argument. If the tool is called with just the application and one library then assume that we are in the weak mode. (perform_compat_check_in_normal_mode): Define new function, factorized from what was in the main function. (perform_compat_check_in_weak_mode): Define new function. (struct {fn,var}_change): Define new types. (main): Use perform_compat_check_in_weak_mode() and perform_compat_check_in_normal_mode(). * tools/abidiff.cc (main): Adjust. * tools/abidw.cc: (options::load_all_types): Add new data member. (options::options): Initialize it. (display_usage): New help string for --load-all-types. (parse_command_line): Support the new --load-all-types option. (main): Adjust and honour the --load-all-types option. * tools/abilint.cc (main): Adjust. * doc/manuals/abicompat.rst: Update documentation for the new weak mode. Also provide stuff that was missing from the examples provided. * doc/manuals/abidw.rst: Update documentation for the new --load-all-types option. * tests/print-diff-tree.cc (main): Adjust. * tests/test-diff-dwarf.cc (main): Likewise. * tests/test-read-dwarf.cc (main): Likewise. * tests/data/test-abicompat/test0-fn-changed-app: Recompile this. * tests/data/test-abicompat/libtest5-fn-changed-libapp-v{0,1}.so: New new test input binaries * tests/data/test-abicompat/test5-fn-changed-app: Likewise. * tests/data/test-abicompat/test6-var-changed-app: Likewise. * tests/data/test-abicompat/libtest6-var-changed-libapp-v{0,1}.so: Likewise. * tests/data/test-abicompat/test5-fn-changed-report-0.txt: Reference output for one test above. * tests/data/test-abicompat/test6-var-changed-report-0.txt: Likewise. * tests/data/test-abicompat/test5-fn-changed-app.cc: Source file for a binary above. * tests/data/test-abicompat/test5-fn-changed-libapp-v{0,1}.{h,cc}: Likewise. * tests/data/test-abicompat/test6-var-changed-libapp-v{0,1}.{cc,h}: Likewise. * tests/data/test-abicompat/test6-var-changed-app.cc: Likewise. * tests/data/Makefile.am: Add the test related files above to the source distribution. * tests/test-abicompat.cc (in_out_spec): Add the new test input above to the list of inputs to feed to this test harness. (main): Support taking just the app and one library. * tests/data/test-read-dwarf/test{0, 1, 2.so, 3.so, 5.o, 8-qualified-this-pointer.so,}.abi: Adjust for void type being really emitted now, as opposed to just being an empty type. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-04-01 10:13:38 +00:00
3
Initial implementation of the abicompat tool Given an application A that links to a shared library L of version V denoted L(V) and a subsequent version of that library denoted L(V+P), the 'abicompat' tool tells the user if L(V+P) is still ABI compatible with L(V+P). And if it is not, abicompat gives a reports that shows the differences between L(V) and L(V+P) that makes L(V+P) ABI-incompatible with A. The source code of this tool is in the tools/abicompat.cc source file. To support this new tool, this commit changes the comparison engine to optionally avoid showing added symbols that were not referenced by any debug info. It changes the ABI corpus type to allow the specification of a list of variables and functions symbols to keep (and drop all other functions and variables which have other symbols on the floor even before starting to compare the two libraries). This is how the abicompat tool itself works. It basically compares L(V) and L(V+P) but it only looks at their exported functions and variables which symbols are undefined in application A. If the list of exported and defined variables and functions of L(V) whose symbols are undefined in A equals that of L(V+P) (including the sub-types of these variables and functions) A is still compatible with L(V+P). Otherwise, they might not be compatible depending on the kind of differences that are found. * include/abg-comparison.h (diff_context::show_added_symbols_unreferenced_by_debug_info): Declare new accessors. (corpus_diff::{deleted_variables, deleted_unrefed_function_symbols, deleted_unrefed_variable_symbols, apply_filters_and_suppressions_before_reporting}): Declare new methods. (corpus_diff::diff_stats): Declare this new type. Actually this was previously corpus_diff::priv::diff_stats, which was a hidden internal type.. We are moving it here, in the external API so that client code can have more information about changes statistics. Change all the previously publicly accessible data members into accessor functions. * src/abg-comparison.cc (class corpus_diff::diff_stats::priv): New type. (diff_context::priv::show_added_syms_unreferenced_by_di_): New data member. (diff_context::priv::priv): Adjust. (diff_context::show_added_symbols_unreferenced_by_debug_info): Define this new method. (corpus_diff::priv::emit_diff_stats): Do not show the diff stat if the only changes is added function or variables symbols and if we were instructed to not show added symbols. (corpus_diff::priv::{diff_stats_, filters_and_suppr_applied_}): New data members. (corpus_diff::priv::priv): Initialize the filters_and_suppr_applied_ data member. (corpus_diff::priv::diff_stats): Move this type to corpus_diff::diff_stats. (corpus_diff::priv::{apply_filters_and_compute_diff_stats, emit_diff_stats}): Adjust. (corpus_diff::apply_filters_and_suppressions_before_reporting): Define new member function. (corpus_diff::report): Use the new apply_filters_and_suppressions_before_reporting() function, rather than applying the filters and suppressions by ourselves. Also adjust to the use the accessors of the new corpus_diff::diff_stats type. (corpus_diff::{deleted_variables, deleted_unrefed_function_symbols, deleted_unrefed_variable_symbols}): Define new accessors. (corpus_diff::diff_stats::{diff_stats, num_func_removed, num_func_added, num_func_changed, num_func_filtered_out, net_num_func_changed, num_vars_removed, num_vars_added, num_vars_changed, num_vars_filtered_out, net_num_vars_changed, num_func_sym_removed, num_func_syms_added, num_var_syms_removed, num_var_syms_added}): Define new member functions. * include/abg-corpus.h (corpus::{get_sym_ids_of_fns_to_keep, get_sym_ids_of_vars_to_keep}): Declare new methods. * src/abg-corpus.cc (corpus::priv::{sym_id_fns_to_keep, sym_id_vars_to_keep}): Added data members. (symtab_build_visitor_type::{unrefed_fun_symbols, unrefed_var_symbols, sym_id_fns_to_keep, sym_id_vars_to_keep}): Added new data members. (symtab_build_visitor_type::symtab_build_visitor_type): Take two additional parameters for the function and variable symbol ids to keep. (symtab_build_visitor_type::add_fn_to_wip_fns): Take the function symbols to keep in account when building the exported symbol table. (symtab_build_visitor_type::add_var_to_wip_vars): Likewise, take the variable symbols to keep in account when building the exported symbol table. (corpus::priv::build_public_decl_table): Adjust the initialization of the visitor that walks the ABI artifacts to build the exported symbol table to know take a list of function/variable symbols to keep. (corpus::priv::build_unreferenced_symbols_tables): Ensure that the public table of functions/variables is built before doing the work of this function. Also, if a list of variable/function symbols to keep is given, drop all symbols that are not in that list on the floor. (corpus::{get_sym_ids_of_fns_to_keep, get_sym_ids_of_vars_to_keep}): Define new accessors. * tools/abicompat.cc: New abicompat tool. * doc/manuals/abicompat.rst: New documentation source for abicompat. * doc/manuals/libabigail-tools.rst: Add an entry for the abicompat doc. * tests/test-abicompat.cc: New test harness for the 'abicompat' tool. * tests/Makefile.am: Build the runtestabicompat test harness and add it to the list of tests harnesses that are run by make check. * tests/data/test-abicompat/libtest0-fn-changed-libapp-v0.so: New test input. * tests/data/test-abicompat/libtest0-fn-changed-libapp-v1.so: Likewise. * tests/data/test-abicompat/test0-fn-changed-app: Likewise. * tests/data/test-abicompat/test0-fn-changed-0.suppr: Likewise * tests/data/test-abicompat/test0-fn-changed-report-0.txt: Likewise. * tests/data/test-abicompat/test0-fn-changed-report-1.txt: Likewise. * tests/data/test-abicompat/test0-fn-changed-app.cc: Likewise. * tests/data/test-abicompat/test0-fn-changed-libapp.h: Likewise. * tests/data/test-abicompat/test0-fn-changed-libapp-v0.cc: Likewise. * tests/data/test-abicompat/test0-fn-changed-libapp-v1.cc: Likewise. * tests/data/test-abicompat/libtest1-fn-removed-v0.so: Likewise. * tests/data/test-abicompat/libtest1-fn-removed-v1.so: Likewise. * tests/data/test-abicompat/test1-fn-removed-app: Likewise. * tests/data/test-abicompat/test1-fn-removed-app.cc: Likewise. * tests/data/test-abicompat/test1-fn-removed-report-0.txt: Likewise. * tests/data/test-abicompat/test1-fn-removed-v0.cc: Likewise. * tests/data/test-abicompat/test1-fn-removed-v1.cc: Likewise. * tests/data/test-abicompat/libtest2-var-removed-v0.so: Likewise. * tests/data/test-abicompat/libtest2-var-removed-v1.so: Likewise. * tests/data/test-abicompat/test2-var-removed-app: Likewise. * tests/data/test-abicompat/test2-var-removed-app.cc: Likewise. * tests/data/test-abicompat/test2-var-removed-report-0.txt: Likewise. * tests/data/test-abicompat/test2-var-removed-v0.cc: Likewise. * tests/data/test-abicompat/test2-var-removed-v1.cc: Likewise. * tests/data/test-abicompat/libtest3-fn-removed-v0.so: Likewise. * tests/data/test-abicompat/libtest3-fn-removed-v1.so: Likewise. * tests/data/test-abicompat/test3-fn-removed-app: Likewise. * tests/data/test-abicompat/test3-fn-removed-app.cc: Likewise. * tests/data/test-abicompat/test3-fn-removed-report-0.txt: Likewise. * tests/data/test-abicompat/test3-fn-removed-v0.cc: Likewise. * tests/data/test-abicompat/test3-fn-removed-v1.cc: Likewise. * tests/data/test-abicompat/test3-fn-removed-version-script-0 Likewise.: * tests/data/test-abicompat/test3-fn-removed-version-script-1: Likewise. * tests/data/Makefile.am: Add the new test inputs above to the source distribution. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-11-30 17:18:55 +00:00
4 #include "test1.h"
Add support for abicompat weak mode This patch implements the weak mode of abicompat. In this mode, just the application and the new version of the library are provided. The types of functions and variables of the library that are consumed by the application are compared to the types of the functions and variables expected by the application. The goal is to check if the types of the declarations consumed by the application and provided by the library are compatible with what the application expects. The abicompat first gets the set of symbols undefined in the application and exported by the library. It then builds the set of declarations exported by the library that have those symbols. We call these the set of declarations of the library that are consumed by the application. Note that the debug information for the application does not contain the declarations of the functions/variables whose symbols are undefined. So we can not just read them to compare them to declarations exported by the library. But the *types* of the variables and the *sub-types* of the functions whose symbols are undefined in the application are present in the debug information of the application. So in the weak mode, abicompat compare the *types* of the declarations consumed by the application as expected by the application (described by the debug information of the application) with the types of the declarations exported by the library. To do this a number of changes were necessary. The patch builds a representation of all the types found in the application's debug info. Before that, only the types that are reachable from exported declarations were represented. The abidw tool got a new --load-all-types to test this new ability of loading all types. The patch also adds support for looking a type, not by name, but by its internal representation. In the comparison engine, function_type_diff is introduced to represent changes between two function types. For this, a new class type_or_decl_base has been introduced in the IR. It's now the base class for both decl_base and type_base. And abigail::comparison::diff now takes two pointers of type_or_decl, not decl_base anymore. So function_type_diff can take two function_type now; not that a function_type has no declaration so it doesn't inherit decl_base. A bunch of changes got made just to adjust to this modification. A number of fixes were made too, to make this work, like adding missing comparison operators, removing asserts that too strong, etc.. The patch also adjust the test suite as well as the documentation. * include/abg-fwd.h (class type_or_decl_base): Forward declare this. (is_decl, is_type, is_function_type, get_name, get_type_name) (get_function_type_name, get_pretty_representation) (lookup_function_type_in_corpus, lookup_type_in_translation_unit) (lookup_function_type_in_translation_unit) (synthesize_function_type_from_translation_unit) (hash_type_or_decl): New function declarations. * src/abg-corpus.cc (lookup_type_in_corpus) (lookup_function_type_in_corpus): Define new functions. * include/abg-ir.h (translation_unit::lookup_function_type_in_translation_unit): Declare new friend function. (class type_or_decl_base): Declare this. (operator==(const type_or_decl_base&, const type_or_decl_base&)): Declare new operator. (operator==(const type_or_decl_base_sptr&, const type_or_decl_base_sptr&)): Likewise. (class {decl_base, type_base}): Make these class inherit type_or_decl_base. (decl_base::get_member_scopes): New const overload. (bool operator==(const function_decl::parameter_sptr&, const function_decl::parameter_sptr&)): New operator. (function_type::get_parameters): Remove the non-const overload. (function_type::get_pretty_representation): Declare new member function. (method_type::get_pretty_representation): Likewise. * src/abg-ir.cc (bool operator==(const type_or_decl_base&, const type_or_decl_base&)): Define new equality operator. (bool operator==(const type_or_decl_base_sptr&, const type_or_decl_base_sptr&)): Likewise. (strip_typedef): Do not expect canonicalized types anymore. Now the system accepts (and expects) canonicalized types in certain cases. For instance, non-complete types and aggregated types that contain non-complete sub-types. (get_name, get_function_type_name, get_type_name) (get_pretty_representation, is_decl, is_type, is_function_type) (lookup_function_type_in_translation_unit) (synthesize_function_type_from_translation_unit) (lookup_type_in_scope, lookup_type_in_translation_unit): Define new functions or new overloads. (bool operator==(const function_decl::parameter_sptr&, const function_decl::parameter_sptr& r)): Define new operator. (function_type::get_parameters): Remove non-const overload. (function_type::get_pretty_representation): Define new function. (function_type::traverse): Adjust. (method_type::get_pretty_representation): Likewise. (function_decl::get_pretty_representation): Avoid emitting the type of cdtors. (hash_type_or_decl): Define new function. * include/abg-dwarf-reader.h (create_read_context) (read_corpus_from_elf): Take a new 'read_all_types' flag. * src/abg-dwarf-reader.cc (read_context::load_all_types_): New flag. (read_context::read_context): Initialize it. (read_context::canonical_types_scheduled): If some types still have non-canonicalized sub-types, then do not canonicalize them. (read_context::load_all_types): New member functions. (build_function_decl): Do not represent void return type like empty type anymore, rather, represent it like a void type node. (build_ir_node_from_die): When asked, load all types including those that are not reachable from an exported declaration. (create_read_context, read_corpus_from_elf): Take a new 'load_all_types' flag and honour it. * src/abg-reader.cc (read_context::type_is_from_translation_unit): Support looking up function types in the current translation unit, now that we now how to lookup function types. * include/abg-comparison.h (diff_context::{has_diff_for, add_diff, set_canonical_diff_for, set_or_get_canonical_diff_for, get_canonical_diff_for}): Make these take instances of type_or_decl_base_sptr, instead of decl_base_sptr. (diff::diff): Likewise. (diff::{first_subject, second_subject}): Make these return type_or_decl_base_sptr instead of decl_base_sptr. (type_diff_base::type_diff_base): Make these take instances of type_or_decl_base_sptr instead of decl_base_sptr. (distinct_diff::distinct_diff): Likewise. (distinct_diff::{first, second}): Make these return type_or_decl_base_sptr instead of decl_base_sptr. (distinct_diff::entities_are_of_distinct_kinds): Make these take instances of type_or_decl_base_sptr instead of decl_base_sptr. (class function_type_diff): Create this new type. It's a factorization of the function_decl_diff type. * src/abg-comparison.cc (): * src/abg-comp-filter.cc ({harmless, harmful}_filter::visit): Adjust as diff::{first,second}_subject() now returns a type_or_decl_base_sptr, no more a decl_base_sptr. (decls_type, decls_diff_map_type): Remove these typedefs and replace it with ... (types_or_decls_type, types_or_decls_diff_map_type): ... these. (struct {decls_hash, decls_equals): Remove these type sand replace them with ... (struct {types_or_decls_hash, types_or_decls_equals}): ... these. ({type_suppression, variable_suppression}::suppresses_diff): Adjust. (diff_context::priv::decls_diff_map): Replace this with ... (diff_context::priv::types_or_decls_diff_map): ... this. (diff_context::{has_diff_for, add_diff, get_canonical_diff_for, set_canonical_diff_for, set_or_get_canonical_diff_for}): Take type_or_decl_base_sptr instead of decl_base_sptr. (diff::priv::{first, second}_subject): Make the type of these be type_or_decl_base_sptr, no more decl_base_sptr. (diff::priv::priv): Adjust for the subjects of the diff being of type type_or_decl_sptr now, no more decl_base_sptr. (diff_less_than_functor::operator()(const diff_sptr, const diff_sptr) const): Adjust. (diff::diff): djust for the subjects of the diff being of type type_or_decl_sptr now, no more decl_base_sptr. (diff::{first,second}_subject): Make the type of these be type_or_decl_base_sptr, no more decl_base_sptr. (report_size_and_alignment_changes): Likewise. (type_diff_base::type_diff_base): Make the type of this be type_or_decl_base_sptr instead of type_base_sptr. (distinct_diff::distinct_diff): Make this take instances of type_or_decl_base_sptr instead of decl_base_sptr. (distinct_diff::{first, second, entities_are_of_distinct_kinds}): Likewise. (distinct_diff::has_changes): Simplify logic. (distinct_diff::report): Adjust. (compute_diff_for_types): Add an additional case to support the new function_type. (report_size_and_alignment_changes): Make this take instances of type_or_decl_base_sptr instead of decl_base_sptr. (class_diff::priv::member_type_has_changed): Return an instance of type_or_decl_base_sptr rather than a decl_base_sptr. (class_diff::report): Adjust. (diff_comp::operator()(const diff&, diff&) const): Adjust. (enum function_decl_diff::priv::Flags): Remove. (function_decl_diff::priv::{first_fn_flags_, second_fn_flags_, fn_flags_changes_}): Remove. (function_decl_diff::priv::{fn_is_declared_inline_to_flag, fn_binding_to_flag}): Remove. (function_decl_diff::{deleted_parameter_at, inserted_parameter_at}): Remove. (function_decl_diff::ensure_lookup_tables_populated): Empty this. (function_decl_diff::chain_into_hierarchy): Adjust. (function_decl_diff::function_decl_diff): This now only takes the subjects. It's body is now empty. (function_decl_diff::{return_type_diff, subtype_changed_parms, removed_parms, added_parms, type_diff}): Remove these member functions. (function_decl_diff::type_diff): Define new member function. (function_decl_diff::report): Simplify logic by using the reporting of the child type diff node. (compute_diff): Likewise, in the overload for function_decl_sptr simplify logic by using the child type diff object. (function_type_diff::priv): Define new type. (function_type_diff::{function_type_diff, ensure_lookup_tables_populated, deleted_parameter_at, inserted_parameter_at, finish_diff_type, first_function_type, second_function_type, return_type_diff, subtype_changed_parms, removed_parms, added_parms, get_pretty_representation, has_changes, has_local_changes, report, chain_into_hierarchy}): Define new functions. (compute_diff): Define new overload for function_type_sptr. * tools/abicompat.cc (options::weak_mode): New data member. (options::options): Initialize it. (enum abicompat_status): New enum (abicompat_status operator|(abicompat_status, abicompat_status)) (abicompat_status& operator|=(abicompat_status &, abicompat_status)) (abicompat_status operator&(abicompat_status, abicompat_status)): New operators to manipulate the abicompat_status enum. (display_usage): Add help string for the new --weak-mode option. (parse_command_line): Add the new --weak-mode command line argument. If the tool is called with just the application and one library then assume that we are in the weak mode. (perform_compat_check_in_normal_mode): Define new function, factorized from what was in the main function. (perform_compat_check_in_weak_mode): Define new function. (struct {fn,var}_change): Define new types. (main): Use perform_compat_check_in_weak_mode() and perform_compat_check_in_normal_mode(). * tools/abidiff.cc (main): Adjust. * tools/abidw.cc: (options::load_all_types): Add new data member. (options::options): Initialize it. (display_usage): New help string for --load-all-types. (parse_command_line): Support the new --load-all-types option. (main): Adjust and honour the --load-all-types option. * tools/abilint.cc (main): Adjust. * doc/manuals/abicompat.rst: Update documentation for the new weak mode. Also provide stuff that was missing from the examples provided. * doc/manuals/abidw.rst: Update documentation for the new --load-all-types option. * tests/print-diff-tree.cc (main): Adjust. * tests/test-diff-dwarf.cc (main): Likewise. * tests/test-read-dwarf.cc (main): Likewise. * tests/data/test-abicompat/test0-fn-changed-app: Recompile this. * tests/data/test-abicompat/libtest5-fn-changed-libapp-v{0,1}.so: New new test input binaries * tests/data/test-abicompat/test5-fn-changed-app: Likewise. * tests/data/test-abicompat/test6-var-changed-app: Likewise. * tests/data/test-abicompat/libtest6-var-changed-libapp-v{0,1}.so: Likewise. * tests/data/test-abicompat/test5-fn-changed-report-0.txt: Reference output for one test above. * tests/data/test-abicompat/test6-var-changed-report-0.txt: Likewise. * tests/data/test-abicompat/test5-fn-changed-app.cc: Source file for a binary above. * tests/data/test-abicompat/test5-fn-changed-libapp-v{0,1}.{h,cc}: Likewise. * tests/data/test-abicompat/test6-var-changed-libapp-v{0,1}.{cc,h}: Likewise. * tests/data/test-abicompat/test6-var-changed-app.cc: Likewise. * tests/data/Makefile.am: Add the test related files above to the source distribution. * tests/test-abicompat.cc (in_out_spec): Add the new test input above to the list of inputs to feed to this test harness. (main): Support taking just the app and one library. * tests/data/test-read-dwarf/test{0, 1, 2.so, 3.so, 5.o, 8-qualified-this-pointer.so,}.abi: Adjust for void type being really emitted now, as opposed to just being an empty type. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-04-01 10:13:38 +00:00
5
Initial implementation of the abicompat tool Given an application A that links to a shared library L of version V denoted L(V) and a subsequent version of that library denoted L(V+P), the 'abicompat' tool tells the user if L(V+P) is still ABI compatible with L(V+P). And if it is not, abicompat gives a reports that shows the differences between L(V) and L(V+P) that makes L(V+P) ABI-incompatible with A. The source code of this tool is in the tools/abicompat.cc source file. To support this new tool, this commit changes the comparison engine to optionally avoid showing added symbols that were not referenced by any debug info. It changes the ABI corpus type to allow the specification of a list of variables and functions symbols to keep (and drop all other functions and variables which have other symbols on the floor even before starting to compare the two libraries). This is how the abicompat tool itself works. It basically compares L(V) and L(V+P) but it only looks at their exported functions and variables which symbols are undefined in application A. If the list of exported and defined variables and functions of L(V) whose symbols are undefined in A equals that of L(V+P) (including the sub-types of these variables and functions) A is still compatible with L(V+P). Otherwise, they might not be compatible depending on the kind of differences that are found. * include/abg-comparison.h (diff_context::show_added_symbols_unreferenced_by_debug_info): Declare new accessors. (corpus_diff::{deleted_variables, deleted_unrefed_function_symbols, deleted_unrefed_variable_symbols, apply_filters_and_suppressions_before_reporting}): Declare new methods. (corpus_diff::diff_stats): Declare this new type. Actually this was previously corpus_diff::priv::diff_stats, which was a hidden internal type.. We are moving it here, in the external API so that client code can have more information about changes statistics. Change all the previously publicly accessible data members into accessor functions. * src/abg-comparison.cc (class corpus_diff::diff_stats::priv): New type. (diff_context::priv::show_added_syms_unreferenced_by_di_): New data member. (diff_context::priv::priv): Adjust. (diff_context::show_added_symbols_unreferenced_by_debug_info): Define this new method. (corpus_diff::priv::emit_diff_stats): Do not show the diff stat if the only changes is added function or variables symbols and if we were instructed to not show added symbols. (corpus_diff::priv::{diff_stats_, filters_and_suppr_applied_}): New data members. (corpus_diff::priv::priv): Initialize the filters_and_suppr_applied_ data member. (corpus_diff::priv::diff_stats): Move this type to corpus_diff::diff_stats. (corpus_diff::priv::{apply_filters_and_compute_diff_stats, emit_diff_stats}): Adjust. (corpus_diff::apply_filters_and_suppressions_before_reporting): Define new member function. (corpus_diff::report): Use the new apply_filters_and_suppressions_before_reporting() function, rather than applying the filters and suppressions by ourselves. Also adjust to the use the accessors of the new corpus_diff::diff_stats type. (corpus_diff::{deleted_variables, deleted_unrefed_function_symbols, deleted_unrefed_variable_symbols}): Define new accessors. (corpus_diff::diff_stats::{diff_stats, num_func_removed, num_func_added, num_func_changed, num_func_filtered_out, net_num_func_changed, num_vars_removed, num_vars_added, num_vars_changed, num_vars_filtered_out, net_num_vars_changed, num_func_sym_removed, num_func_syms_added, num_var_syms_removed, num_var_syms_added}): Define new member functions. * include/abg-corpus.h (corpus::{get_sym_ids_of_fns_to_keep, get_sym_ids_of_vars_to_keep}): Declare new methods. * src/abg-corpus.cc (corpus::priv::{sym_id_fns_to_keep, sym_id_vars_to_keep}): Added data members. (symtab_build_visitor_type::{unrefed_fun_symbols, unrefed_var_symbols, sym_id_fns_to_keep, sym_id_vars_to_keep}): Added new data members. (symtab_build_visitor_type::symtab_build_visitor_type): Take two additional parameters for the function and variable symbol ids to keep. (symtab_build_visitor_type::add_fn_to_wip_fns): Take the function symbols to keep in account when building the exported symbol table. (symtab_build_visitor_type::add_var_to_wip_vars): Likewise, take the variable symbols to keep in account when building the exported symbol table. (corpus::priv::build_public_decl_table): Adjust the initialization of the visitor that walks the ABI artifacts to build the exported symbol table to know take a list of function/variable symbols to keep. (corpus::priv::build_unreferenced_symbols_tables): Ensure that the public table of functions/variables is built before doing the work of this function. Also, if a list of variable/function symbols to keep is given, drop all symbols that are not in that list on the floor. (corpus::{get_sym_ids_of_fns_to_keep, get_sym_ids_of_vars_to_keep}): Define new accessors. * tools/abicompat.cc: New abicompat tool. * doc/manuals/abicompat.rst: New documentation source for abicompat. * doc/manuals/libabigail-tools.rst: Add an entry for the abicompat doc. * tests/test-abicompat.cc: New test harness for the 'abicompat' tool. * tests/Makefile.am: Build the runtestabicompat test harness and add it to the list of tests harnesses that are run by make check. * tests/data/test-abicompat/libtest0-fn-changed-libapp-v0.so: New test input. * tests/data/test-abicompat/libtest0-fn-changed-libapp-v1.so: Likewise. * tests/data/test-abicompat/test0-fn-changed-app: Likewise. * tests/data/test-abicompat/test0-fn-changed-0.suppr: Likewise * tests/data/test-abicompat/test0-fn-changed-report-0.txt: Likewise. * tests/data/test-abicompat/test0-fn-changed-report-1.txt: Likewise. * tests/data/test-abicompat/test0-fn-changed-app.cc: Likewise. * tests/data/test-abicompat/test0-fn-changed-libapp.h: Likewise. * tests/data/test-abicompat/test0-fn-changed-libapp-v0.cc: Likewise. * tests/data/test-abicompat/test0-fn-changed-libapp-v1.cc: Likewise. * tests/data/test-abicompat/libtest1-fn-removed-v0.so: Likewise. * tests/data/test-abicompat/libtest1-fn-removed-v1.so: Likewise. * tests/data/test-abicompat/test1-fn-removed-app: Likewise. * tests/data/test-abicompat/test1-fn-removed-app.cc: Likewise. * tests/data/test-abicompat/test1-fn-removed-report-0.txt: Likewise. * tests/data/test-abicompat/test1-fn-removed-v0.cc: Likewise. * tests/data/test-abicompat/test1-fn-removed-v1.cc: Likewise. * tests/data/test-abicompat/libtest2-var-removed-v0.so: Likewise. * tests/data/test-abicompat/libtest2-var-removed-v1.so: Likewise. * tests/data/test-abicompat/test2-var-removed-app: Likewise. * tests/data/test-abicompat/test2-var-removed-app.cc: Likewise. * tests/data/test-abicompat/test2-var-removed-report-0.txt: Likewise. * tests/data/test-abicompat/test2-var-removed-v0.cc: Likewise. * tests/data/test-abicompat/test2-var-removed-v1.cc: Likewise. * tests/data/test-abicompat/libtest3-fn-removed-v0.so: Likewise. * tests/data/test-abicompat/libtest3-fn-removed-v1.so: Likewise. * tests/data/test-abicompat/test3-fn-removed-app: Likewise. * tests/data/test-abicompat/test3-fn-removed-app.cc: Likewise. * tests/data/test-abicompat/test3-fn-removed-report-0.txt: Likewise. * tests/data/test-abicompat/test3-fn-removed-v0.cc: Likewise. * tests/data/test-abicompat/test3-fn-removed-v1.cc: Likewise. * tests/data/test-abicompat/test3-fn-removed-version-script-0 Likewise.: * tests/data/test-abicompat/test3-fn-removed-version-script-1: Likewise. * tests/data/Makefile.am: Add the new test inputs above to the source distribution. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-11-30 17:18:55 +00:00
6 foo*
7 first_func()
8 {
Add support for abicompat weak mode This patch implements the weak mode of abicompat. In this mode, just the application and the new version of the library are provided. The types of functions and variables of the library that are consumed by the application are compared to the types of the functions and variables expected by the application. The goal is to check if the types of the declarations consumed by the application and provided by the library are compatible with what the application expects. The abicompat first gets the set of symbols undefined in the application and exported by the library. It then builds the set of declarations exported by the library that have those symbols. We call these the set of declarations of the library that are consumed by the application. Note that the debug information for the application does not contain the declarations of the functions/variables whose symbols are undefined. So we can not just read them to compare them to declarations exported by the library. But the *types* of the variables and the *sub-types* of the functions whose symbols are undefined in the application are present in the debug information of the application. So in the weak mode, abicompat compare the *types* of the declarations consumed by the application as expected by the application (described by the debug information of the application) with the types of the declarations exported by the library. To do this a number of changes were necessary. The patch builds a representation of all the types found in the application's debug info. Before that, only the types that are reachable from exported declarations were represented. The abidw tool got a new --load-all-types to test this new ability of loading all types. The patch also adds support for looking a type, not by name, but by its internal representation. In the comparison engine, function_type_diff is introduced to represent changes between two function types. For this, a new class type_or_decl_base has been introduced in the IR. It's now the base class for both decl_base and type_base. And abigail::comparison::diff now takes two pointers of type_or_decl, not decl_base anymore. So function_type_diff can take two function_type now; not that a function_type has no declaration so it doesn't inherit decl_base. A bunch of changes got made just to adjust to this modification. A number of fixes were made too, to make this work, like adding missing comparison operators, removing asserts that too strong, etc.. The patch also adjust the test suite as well as the documentation. * include/abg-fwd.h (class type_or_decl_base): Forward declare this. (is_decl, is_type, is_function_type, get_name, get_type_name) (get_function_type_name, get_pretty_representation) (lookup_function_type_in_corpus, lookup_type_in_translation_unit) (lookup_function_type_in_translation_unit) (synthesize_function_type_from_translation_unit) (hash_type_or_decl): New function declarations. * src/abg-corpus.cc (lookup_type_in_corpus) (lookup_function_type_in_corpus): Define new functions. * include/abg-ir.h (translation_unit::lookup_function_type_in_translation_unit): Declare new friend function. (class type_or_decl_base): Declare this. (operator==(const type_or_decl_base&, const type_or_decl_base&)): Declare new operator. (operator==(const type_or_decl_base_sptr&, const type_or_decl_base_sptr&)): Likewise. (class {decl_base, type_base}): Make these class inherit type_or_decl_base. (decl_base::get_member_scopes): New const overload. (bool operator==(const function_decl::parameter_sptr&, const function_decl::parameter_sptr&)): New operator. (function_type::get_parameters): Remove the non-const overload. (function_type::get_pretty_representation): Declare new member function. (method_type::get_pretty_representation): Likewise. * src/abg-ir.cc (bool operator==(const type_or_decl_base&, const type_or_decl_base&)): Define new equality operator. (bool operator==(const type_or_decl_base_sptr&, const type_or_decl_base_sptr&)): Likewise. (strip_typedef): Do not expect canonicalized types anymore. Now the system accepts (and expects) canonicalized types in certain cases. For instance, non-complete types and aggregated types that contain non-complete sub-types. (get_name, get_function_type_name, get_type_name) (get_pretty_representation, is_decl, is_type, is_function_type) (lookup_function_type_in_translation_unit) (synthesize_function_type_from_translation_unit) (lookup_type_in_scope, lookup_type_in_translation_unit): Define new functions or new overloads. (bool operator==(const function_decl::parameter_sptr&, const function_decl::parameter_sptr& r)): Define new operator. (function_type::get_parameters): Remove non-const overload. (function_type::get_pretty_representation): Define new function. (function_type::traverse): Adjust. (method_type::get_pretty_representation): Likewise. (function_decl::get_pretty_representation): Avoid emitting the type of cdtors. (hash_type_or_decl): Define new function. * include/abg-dwarf-reader.h (create_read_context) (read_corpus_from_elf): Take a new 'read_all_types' flag. * src/abg-dwarf-reader.cc (read_context::load_all_types_): New flag. (read_context::read_context): Initialize it. (read_context::canonical_types_scheduled): If some types still have non-canonicalized sub-types, then do not canonicalize them. (read_context::load_all_types): New member functions. (build_function_decl): Do not represent void return type like empty type anymore, rather, represent it like a void type node. (build_ir_node_from_die): When asked, load all types including those that are not reachable from an exported declaration. (create_read_context, read_corpus_from_elf): Take a new 'load_all_types' flag and honour it. * src/abg-reader.cc (read_context::type_is_from_translation_unit): Support looking up function types in the current translation unit, now that we now how to lookup function types. * include/abg-comparison.h (diff_context::{has_diff_for, add_diff, set_canonical_diff_for, set_or_get_canonical_diff_for, get_canonical_diff_for}): Make these take instances of type_or_decl_base_sptr, instead of decl_base_sptr. (diff::diff): Likewise. (diff::{first_subject, second_subject}): Make these return type_or_decl_base_sptr instead of decl_base_sptr. (type_diff_base::type_diff_base): Make these take instances of type_or_decl_base_sptr instead of decl_base_sptr. (distinct_diff::distinct_diff): Likewise. (distinct_diff::{first, second}): Make these return type_or_decl_base_sptr instead of decl_base_sptr. (distinct_diff::entities_are_of_distinct_kinds): Make these take instances of type_or_decl_base_sptr instead of decl_base_sptr. (class function_type_diff): Create this new type. It's a factorization of the function_decl_diff type. * src/abg-comparison.cc (): * src/abg-comp-filter.cc ({harmless, harmful}_filter::visit): Adjust as diff::{first,second}_subject() now returns a type_or_decl_base_sptr, no more a decl_base_sptr. (decls_type, decls_diff_map_type): Remove these typedefs and replace it with ... (types_or_decls_type, types_or_decls_diff_map_type): ... these. (struct {decls_hash, decls_equals): Remove these type sand replace them with ... (struct {types_or_decls_hash, types_or_decls_equals}): ... these. ({type_suppression, variable_suppression}::suppresses_diff): Adjust. (diff_context::priv::decls_diff_map): Replace this with ... (diff_context::priv::types_or_decls_diff_map): ... this. (diff_context::{has_diff_for, add_diff, get_canonical_diff_for, set_canonical_diff_for, set_or_get_canonical_diff_for}): Take type_or_decl_base_sptr instead of decl_base_sptr. (diff::priv::{first, second}_subject): Make the type of these be type_or_decl_base_sptr, no more decl_base_sptr. (diff::priv::priv): Adjust for the subjects of the diff being of type type_or_decl_sptr now, no more decl_base_sptr. (diff_less_than_functor::operator()(const diff_sptr, const diff_sptr) const): Adjust. (diff::diff): djust for the subjects of the diff being of type type_or_decl_sptr now, no more decl_base_sptr. (diff::{first,second}_subject): Make the type of these be type_or_decl_base_sptr, no more decl_base_sptr. (report_size_and_alignment_changes): Likewise. (type_diff_base::type_diff_base): Make the type of this be type_or_decl_base_sptr instead of type_base_sptr. (distinct_diff::distinct_diff): Make this take instances of type_or_decl_base_sptr instead of decl_base_sptr. (distinct_diff::{first, second, entities_are_of_distinct_kinds}): Likewise. (distinct_diff::has_changes): Simplify logic. (distinct_diff::report): Adjust. (compute_diff_for_types): Add an additional case to support the new function_type. (report_size_and_alignment_changes): Make this take instances of type_or_decl_base_sptr instead of decl_base_sptr. (class_diff::priv::member_type_has_changed): Return an instance of type_or_decl_base_sptr rather than a decl_base_sptr. (class_diff::report): Adjust. (diff_comp::operator()(const diff&, diff&) const): Adjust. (enum function_decl_diff::priv::Flags): Remove. (function_decl_diff::priv::{first_fn_flags_, second_fn_flags_, fn_flags_changes_}): Remove. (function_decl_diff::priv::{fn_is_declared_inline_to_flag, fn_binding_to_flag}): Remove. (function_decl_diff::{deleted_parameter_at, inserted_parameter_at}): Remove. (function_decl_diff::ensure_lookup_tables_populated): Empty this. (function_decl_diff::chain_into_hierarchy): Adjust. (function_decl_diff::function_decl_diff): This now only takes the subjects. It's body is now empty. (function_decl_diff::{return_type_diff, subtype_changed_parms, removed_parms, added_parms, type_diff}): Remove these member functions. (function_decl_diff::type_diff): Define new member function. (function_decl_diff::report): Simplify logic by using the reporting of the child type diff node. (compute_diff): Likewise, in the overload for function_decl_sptr simplify logic by using the child type diff object. (function_type_diff::priv): Define new type. (function_type_diff::{function_type_diff, ensure_lookup_tables_populated, deleted_parameter_at, inserted_parameter_at, finish_diff_type, first_function_type, second_function_type, return_type_diff, subtype_changed_parms, removed_parms, added_parms, get_pretty_representation, has_changes, has_local_changes, report, chain_into_hierarchy}): Define new functions. (compute_diff): Define new overload for function_type_sptr. * tools/abicompat.cc (options::weak_mode): New data member. (options::options): Initialize it. (enum abicompat_status): New enum (abicompat_status operator|(abicompat_status, abicompat_status)) (abicompat_status& operator|=(abicompat_status &, abicompat_status)) (abicompat_status operator&(abicompat_status, abicompat_status)): New operators to manipulate the abicompat_status enum. (display_usage): Add help string for the new --weak-mode option. (parse_command_line): Add the new --weak-mode command line argument. If the tool is called with just the application and one library then assume that we are in the weak mode. (perform_compat_check_in_normal_mode): Define new function, factorized from what was in the main function. (perform_compat_check_in_weak_mode): Define new function. (struct {fn,var}_change): Define new types. (main): Use perform_compat_check_in_weak_mode() and perform_compat_check_in_normal_mode(). * tools/abidiff.cc (main): Adjust. * tools/abidw.cc: (options::load_all_types): Add new data member. (options::options): Initialize it. (display_usage): New help string for --load-all-types. (parse_command_line): Support the new --load-all-types option. (main): Adjust and honour the --load-all-types option. * tools/abilint.cc (main): Adjust. * doc/manuals/abicompat.rst: Update documentation for the new weak mode. Also provide stuff that was missing from the examples provided. * doc/manuals/abidw.rst: Update documentation for the new --load-all-types option. * tests/print-diff-tree.cc (main): Adjust. * tests/test-diff-dwarf.cc (main): Likewise. * tests/test-read-dwarf.cc (main): Likewise. * tests/data/test-abicompat/test0-fn-changed-app: Recompile this. * tests/data/test-abicompat/libtest5-fn-changed-libapp-v{0,1}.so: New new test input binaries * tests/data/test-abicompat/test5-fn-changed-app: Likewise. * tests/data/test-abicompat/test6-var-changed-app: Likewise. * tests/data/test-abicompat/libtest6-var-changed-libapp-v{0,1}.so: Likewise. * tests/data/test-abicompat/test5-fn-changed-report-0.txt: Reference output for one test above. * tests/data/test-abicompat/test6-var-changed-report-0.txt: Likewise. * tests/data/test-abicompat/test5-fn-changed-app.cc: Source file for a binary above. * tests/data/test-abicompat/test5-fn-changed-libapp-v{0,1}.{h,cc}: Likewise. * tests/data/test-abicompat/test6-var-changed-libapp-v{0,1}.{cc,h}: Likewise. * tests/data/test-abicompat/test6-var-changed-app.cc: Likewise. * tests/data/Makefile.am: Add the test related files above to the source distribution. * tests/test-abicompat.cc (in_out_spec): Add the new test input above to the list of inputs to feed to this test harness. (main): Support taking just the app and one library. * tests/data/test-read-dwarf/test{0, 1, 2.so, 3.so, 5.o, 8-qualified-this-pointer.so,}.abi: Adjust for void type being really emitted now, as opposed to just being an empty type. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-04-01 10:13:38 +00:00
9 foo* f = new foo();
10 return f;
11 }
12
13 void
14 second_func(foo&)
15 {
16 }
17
18 /* Let's comment out the definition of third_func()
19 void
20 third_func()
21 {
22 }
23 */
$
Initial implementation of the abicompat tool Given an application A that links to a shared library L of version V denoted L(V) and a subsequent version of that library denoted L(V+P), the 'abicompat' tool tells the user if L(V+P) is still ABI compatible with L(V+P). And if it is not, abicompat gives a reports that shows the differences between L(V) and L(V+P) that makes L(V+P) ABI-incompatible with A. The source code of this tool is in the tools/abicompat.cc source file. To support this new tool, this commit changes the comparison engine to optionally avoid showing added symbols that were not referenced by any debug info. It changes the ABI corpus type to allow the specification of a list of variables and functions symbols to keep (and drop all other functions and variables which have other symbols on the floor even before starting to compare the two libraries). This is how the abicompat tool itself works. It basically compares L(V) and L(V+P) but it only looks at their exported functions and variables which symbols are undefined in application A. If the list of exported and defined variables and functions of L(V) whose symbols are undefined in A equals that of L(V+P) (including the sub-types of these variables and functions) A is still compatible with L(V+P). Otherwise, they might not be compatible depending on the kind of differences that are found. * include/abg-comparison.h (diff_context::show_added_symbols_unreferenced_by_debug_info): Declare new accessors. (corpus_diff::{deleted_variables, deleted_unrefed_function_symbols, deleted_unrefed_variable_symbols, apply_filters_and_suppressions_before_reporting}): Declare new methods. (corpus_diff::diff_stats): Declare this new type. Actually this was previously corpus_diff::priv::diff_stats, which was a hidden internal type.. We are moving it here, in the external API so that client code can have more information about changes statistics. Change all the previously publicly accessible data members into accessor functions. * src/abg-comparison.cc (class corpus_diff::diff_stats::priv): New type. (diff_context::priv::show_added_syms_unreferenced_by_di_): New data member. (diff_context::priv::priv): Adjust. (diff_context::show_added_symbols_unreferenced_by_debug_info): Define this new method. (corpus_diff::priv::emit_diff_stats): Do not show the diff stat if the only changes is added function or variables symbols and if we were instructed to not show added symbols. (corpus_diff::priv::{diff_stats_, filters_and_suppr_applied_}): New data members. (corpus_diff::priv::priv): Initialize the filters_and_suppr_applied_ data member. (corpus_diff::priv::diff_stats): Move this type to corpus_diff::diff_stats. (corpus_diff::priv::{apply_filters_and_compute_diff_stats, emit_diff_stats}): Adjust. (corpus_diff::apply_filters_and_suppressions_before_reporting): Define new member function. (corpus_diff::report): Use the new apply_filters_and_suppressions_before_reporting() function, rather than applying the filters and suppressions by ourselves. Also adjust to the use the accessors of the new corpus_diff::diff_stats type. (corpus_diff::{deleted_variables, deleted_unrefed_function_symbols, deleted_unrefed_variable_symbols}): Define new accessors. (corpus_diff::diff_stats::{diff_stats, num_func_removed, num_func_added, num_func_changed, num_func_filtered_out, net_num_func_changed, num_vars_removed, num_vars_added, num_vars_changed, num_vars_filtered_out, net_num_vars_changed, num_func_sym_removed, num_func_syms_added, num_var_syms_removed, num_var_syms_added}): Define new member functions. * include/abg-corpus.h (corpus::{get_sym_ids_of_fns_to_keep, get_sym_ids_of_vars_to_keep}): Declare new methods. * src/abg-corpus.cc (corpus::priv::{sym_id_fns_to_keep, sym_id_vars_to_keep}): Added data members. (symtab_build_visitor_type::{unrefed_fun_symbols, unrefed_var_symbols, sym_id_fns_to_keep, sym_id_vars_to_keep}): Added new data members. (symtab_build_visitor_type::symtab_build_visitor_type): Take two additional parameters for the function and variable symbol ids to keep. (symtab_build_visitor_type::add_fn_to_wip_fns): Take the function symbols to keep in account when building the exported symbol table. (symtab_build_visitor_type::add_var_to_wip_vars): Likewise, take the variable symbols to keep in account when building the exported symbol table. (corpus::priv::build_public_decl_table): Adjust the initialization of the visitor that walks the ABI artifacts to build the exported symbol table to know take a list of function/variable symbols to keep. (corpus::priv::build_unreferenced_symbols_tables): Ensure that the public table of functions/variables is built before doing the work of this function. Also, if a list of variable/function symbols to keep is given, drop all symbols that are not in that list on the floor. (corpus::{get_sym_ids_of_fns_to_keep, get_sym_ids_of_vars_to_keep}): Define new accessors. * tools/abicompat.cc: New abicompat tool. * doc/manuals/abicompat.rst: New documentation source for abicompat. * doc/manuals/libabigail-tools.rst: Add an entry for the abicompat doc. * tests/test-abicompat.cc: New test harness for the 'abicompat' tool. * tests/Makefile.am: Build the runtestabicompat test harness and add it to the list of tests harnesses that are run by make check. * tests/data/test-abicompat/libtest0-fn-changed-libapp-v0.so: New test input. * tests/data/test-abicompat/libtest0-fn-changed-libapp-v1.so: Likewise. * tests/data/test-abicompat/test0-fn-changed-app: Likewise. * tests/data/test-abicompat/test0-fn-changed-0.suppr: Likewise * tests/data/test-abicompat/test0-fn-changed-report-0.txt: Likewise. * tests/data/test-abicompat/test0-fn-changed-report-1.txt: Likewise. * tests/data/test-abicompat/test0-fn-changed-app.cc: Likewise. * tests/data/test-abicompat/test0-fn-changed-libapp.h: Likewise. * tests/data/test-abicompat/test0-fn-changed-libapp-v0.cc: Likewise. * tests/data/test-abicompat/test0-fn-changed-libapp-v1.cc: Likewise. * tests/data/test-abicompat/libtest1-fn-removed-v0.so: Likewise. * tests/data/test-abicompat/libtest1-fn-removed-v1.so: Likewise. * tests/data/test-abicompat/test1-fn-removed-app: Likewise. * tests/data/test-abicompat/test1-fn-removed-app.cc: Likewise. * tests/data/test-abicompat/test1-fn-removed-report-0.txt: Likewise. * tests/data/test-abicompat/test1-fn-removed-v0.cc: Likewise. * tests/data/test-abicompat/test1-fn-removed-v1.cc: Likewise. * tests/data/test-abicompat/libtest2-var-removed-v0.so: Likewise. * tests/data/test-abicompat/libtest2-var-removed-v1.so: Likewise. * tests/data/test-abicompat/test2-var-removed-app: Likewise. * tests/data/test-abicompat/test2-var-removed-app.cc: Likewise. * tests/data/test-abicompat/test2-var-removed-report-0.txt: Likewise. * tests/data/test-abicompat/test2-var-removed-v0.cc: Likewise. * tests/data/test-abicompat/test2-var-removed-v1.cc: Likewise. * tests/data/test-abicompat/libtest3-fn-removed-v0.so: Likewise. * tests/data/test-abicompat/libtest3-fn-removed-v1.so: Likewise. * tests/data/test-abicompat/test3-fn-removed-app: Likewise. * tests/data/test-abicompat/test3-fn-removed-app.cc: Likewise. * tests/data/test-abicompat/test3-fn-removed-report-0.txt: Likewise. * tests/data/test-abicompat/test3-fn-removed-v0.cc: Likewise. * tests/data/test-abicompat/test3-fn-removed-v1.cc: Likewise. * tests/data/test-abicompat/test3-fn-removed-version-script-0 Likewise.: * tests/data/test-abicompat/test3-fn-removed-version-script-1: Likewise. * tests/data/Makefile.am: Add the new test inputs above to the source distribution. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-11-30 17:18:55 +00:00
* Compile the first and second versions of the libraries:
Initial implementation of the abicompat tool Given an application A that links to a shared library L of version V denoted L(V) and a subsequent version of that library denoted L(V+P), the 'abicompat' tool tells the user if L(V+P) is still ABI compatible with L(V+P). And if it is not, abicompat gives a reports that shows the differences between L(V) and L(V+P) that makes L(V+P) ABI-incompatible with A. The source code of this tool is in the tools/abicompat.cc source file. To support this new tool, this commit changes the comparison engine to optionally avoid showing added symbols that were not referenced by any debug info. It changes the ABI corpus type to allow the specification of a list of variables and functions symbols to keep (and drop all other functions and variables which have other symbols on the floor even before starting to compare the two libraries). This is how the abicompat tool itself works. It basically compares L(V) and L(V+P) but it only looks at their exported functions and variables which symbols are undefined in application A. If the list of exported and defined variables and functions of L(V) whose symbols are undefined in A equals that of L(V+P) (including the sub-types of these variables and functions) A is still compatible with L(V+P). Otherwise, they might not be compatible depending on the kind of differences that are found. * include/abg-comparison.h (diff_context::show_added_symbols_unreferenced_by_debug_info): Declare new accessors. (corpus_diff::{deleted_variables, deleted_unrefed_function_symbols, deleted_unrefed_variable_symbols, apply_filters_and_suppressions_before_reporting}): Declare new methods. (corpus_diff::diff_stats): Declare this new type. Actually this was previously corpus_diff::priv::diff_stats, which was a hidden internal type.. We are moving it here, in the external API so that client code can have more information about changes statistics. Change all the previously publicly accessible data members into accessor functions. * src/abg-comparison.cc (class corpus_diff::diff_stats::priv): New type. (diff_context::priv::show_added_syms_unreferenced_by_di_): New data member. (diff_context::priv::priv): Adjust. (diff_context::show_added_symbols_unreferenced_by_debug_info): Define this new method. (corpus_diff::priv::emit_diff_stats): Do not show the diff stat if the only changes is added function or variables symbols and if we were instructed to not show added symbols. (corpus_diff::priv::{diff_stats_, filters_and_suppr_applied_}): New data members. (corpus_diff::priv::priv): Initialize the filters_and_suppr_applied_ data member. (corpus_diff::priv::diff_stats): Move this type to corpus_diff::diff_stats. (corpus_diff::priv::{apply_filters_and_compute_diff_stats, emit_diff_stats}): Adjust. (corpus_diff::apply_filters_and_suppressions_before_reporting): Define new member function. (corpus_diff::report): Use the new apply_filters_and_suppressions_before_reporting() function, rather than applying the filters and suppressions by ourselves. Also adjust to the use the accessors of the new corpus_diff::diff_stats type. (corpus_diff::{deleted_variables, deleted_unrefed_function_symbols, deleted_unrefed_variable_symbols}): Define new accessors. (corpus_diff::diff_stats::{diff_stats, num_func_removed, num_func_added, num_func_changed, num_func_filtered_out, net_num_func_changed, num_vars_removed, num_vars_added, num_vars_changed, num_vars_filtered_out, net_num_vars_changed, num_func_sym_removed, num_func_syms_added, num_var_syms_removed, num_var_syms_added}): Define new member functions. * include/abg-corpus.h (corpus::{get_sym_ids_of_fns_to_keep, get_sym_ids_of_vars_to_keep}): Declare new methods. * src/abg-corpus.cc (corpus::priv::{sym_id_fns_to_keep, sym_id_vars_to_keep}): Added data members. (symtab_build_visitor_type::{unrefed_fun_symbols, unrefed_var_symbols, sym_id_fns_to_keep, sym_id_vars_to_keep}): Added new data members. (symtab_build_visitor_type::symtab_build_visitor_type): Take two additional parameters for the function and variable symbol ids to keep. (symtab_build_visitor_type::add_fn_to_wip_fns): Take the function symbols to keep in account when building the exported symbol table. (symtab_build_visitor_type::add_var_to_wip_vars): Likewise, take the variable symbols to keep in account when building the exported symbol table. (corpus::priv::build_public_decl_table): Adjust the initialization of the visitor that walks the ABI artifacts to build the exported symbol table to know take a list of function/variable symbols to keep. (corpus::priv::build_unreferenced_symbols_tables): Ensure that the public table of functions/variables is built before doing the work of this function. Also, if a list of variable/function symbols to keep is given, drop all symbols that are not in that list on the floor. (corpus::{get_sym_ids_of_fns_to_keep, get_sym_ids_of_vars_to_keep}): Define new accessors. * tools/abicompat.cc: New abicompat tool. * doc/manuals/abicompat.rst: New documentation source for abicompat. * doc/manuals/libabigail-tools.rst: Add an entry for the abicompat doc. * tests/test-abicompat.cc: New test harness for the 'abicompat' tool. * tests/Makefile.am: Build the runtestabicompat test harness and add it to the list of tests harnesses that are run by make check. * tests/data/test-abicompat/libtest0-fn-changed-libapp-v0.so: New test input. * tests/data/test-abicompat/libtest0-fn-changed-libapp-v1.so: Likewise. * tests/data/test-abicompat/test0-fn-changed-app: Likewise. * tests/data/test-abicompat/test0-fn-changed-0.suppr: Likewise * tests/data/test-abicompat/test0-fn-changed-report-0.txt: Likewise. * tests/data/test-abicompat/test0-fn-changed-report-1.txt: Likewise. * tests/data/test-abicompat/test0-fn-changed-app.cc: Likewise. * tests/data/test-abicompat/test0-fn-changed-libapp.h: Likewise. * tests/data/test-abicompat/test0-fn-changed-libapp-v0.cc: Likewise. * tests/data/test-abicompat/test0-fn-changed-libapp-v1.cc: Likewise. * tests/data/test-abicompat/libtest1-fn-removed-v0.so: Likewise. * tests/data/test-abicompat/libtest1-fn-removed-v1.so: Likewise. * tests/data/test-abicompat/test1-fn-removed-app: Likewise. * tests/data/test-abicompat/test1-fn-removed-app.cc: Likewise. * tests/data/test-abicompat/test1-fn-removed-report-0.txt: Likewise. * tests/data/test-abicompat/test1-fn-removed-v0.cc: Likewise. * tests/data/test-abicompat/test1-fn-removed-v1.cc: Likewise. * tests/data/test-abicompat/libtest2-var-removed-v0.so: Likewise. * tests/data/test-abicompat/libtest2-var-removed-v1.so: Likewise. * tests/data/test-abicompat/test2-var-removed-app: Likewise. * tests/data/test-abicompat/test2-var-removed-app.cc: Likewise. * tests/data/test-abicompat/test2-var-removed-report-0.txt: Likewise. * tests/data/test-abicompat/test2-var-removed-v0.cc: Likewise. * tests/data/test-abicompat/test2-var-removed-v1.cc: Likewise. * tests/data/test-abicompat/libtest3-fn-removed-v0.so: Likewise. * tests/data/test-abicompat/libtest3-fn-removed-v1.so: Likewise. * tests/data/test-abicompat/test3-fn-removed-app: Likewise. * tests/data/test-abicompat/test3-fn-removed-app.cc: Likewise. * tests/data/test-abicompat/test3-fn-removed-report-0.txt: Likewise. * tests/data/test-abicompat/test3-fn-removed-v0.cc: Likewise. * tests/data/test-abicompat/test3-fn-removed-v1.cc: Likewise. * tests/data/test-abicompat/test3-fn-removed-version-script-0 Likewise.: * tests/data/test-abicompat/test3-fn-removed-version-script-1: Likewise. * tests/data/Makefile.am: Add the new test inputs above to the source distribution. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-11-30 17:18:55 +00:00
``libtest-0.so`` and ``libtest-1.so``: ::
$ g++ -g -Wall -shared -o libtest-0.so test0.cc
$ g++ -g -Wall -shared -o libtest-1.so test1.cc
* Compile the application and link it against the first version of
the library, creating the ``test-app`` binary: ::
$ g++ -g -Wall -o test-app -L. -ltest-0.so test-app.cc
* Now, use ``abicompat`` to see if libtest-1.so is ABI compatible
with app, with respect to the ABI of libtest-0.so: ::
Initial implementation of the abicompat tool Given an application A that links to a shared library L of version V denoted L(V) and a subsequent version of that library denoted L(V+P), the 'abicompat' tool tells the user if L(V+P) is still ABI compatible with L(V+P). And if it is not, abicompat gives a reports that shows the differences between L(V) and L(V+P) that makes L(V+P) ABI-incompatible with A. The source code of this tool is in the tools/abicompat.cc source file. To support this new tool, this commit changes the comparison engine to optionally avoid showing added symbols that were not referenced by any debug info. It changes the ABI corpus type to allow the specification of a list of variables and functions symbols to keep (and drop all other functions and variables which have other symbols on the floor even before starting to compare the two libraries). This is how the abicompat tool itself works. It basically compares L(V) and L(V+P) but it only looks at their exported functions and variables which symbols are undefined in application A. If the list of exported and defined variables and functions of L(V) whose symbols are undefined in A equals that of L(V+P) (including the sub-types of these variables and functions) A is still compatible with L(V+P). Otherwise, they might not be compatible depending on the kind of differences that are found. * include/abg-comparison.h (diff_context::show_added_symbols_unreferenced_by_debug_info): Declare new accessors. (corpus_diff::{deleted_variables, deleted_unrefed_function_symbols, deleted_unrefed_variable_symbols, apply_filters_and_suppressions_before_reporting}): Declare new methods. (corpus_diff::diff_stats): Declare this new type. Actually this was previously corpus_diff::priv::diff_stats, which was a hidden internal type.. We are moving it here, in the external API so that client code can have more information about changes statistics. Change all the previously publicly accessible data members into accessor functions. * src/abg-comparison.cc (class corpus_diff::diff_stats::priv): New type. (diff_context::priv::show_added_syms_unreferenced_by_di_): New data member. (diff_context::priv::priv): Adjust. (diff_context::show_added_symbols_unreferenced_by_debug_info): Define this new method. (corpus_diff::priv::emit_diff_stats): Do not show the diff stat if the only changes is added function or variables symbols and if we were instructed to not show added symbols. (corpus_diff::priv::{diff_stats_, filters_and_suppr_applied_}): New data members. (corpus_diff::priv::priv): Initialize the filters_and_suppr_applied_ data member. (corpus_diff::priv::diff_stats): Move this type to corpus_diff::diff_stats. (corpus_diff::priv::{apply_filters_and_compute_diff_stats, emit_diff_stats}): Adjust. (corpus_diff::apply_filters_and_suppressions_before_reporting): Define new member function. (corpus_diff::report): Use the new apply_filters_and_suppressions_before_reporting() function, rather than applying the filters and suppressions by ourselves. Also adjust to the use the accessors of the new corpus_diff::diff_stats type. (corpus_diff::{deleted_variables, deleted_unrefed_function_symbols, deleted_unrefed_variable_symbols}): Define new accessors. (corpus_diff::diff_stats::{diff_stats, num_func_removed, num_func_added, num_func_changed, num_func_filtered_out, net_num_func_changed, num_vars_removed, num_vars_added, num_vars_changed, num_vars_filtered_out, net_num_vars_changed, num_func_sym_removed, num_func_syms_added, num_var_syms_removed, num_var_syms_added}): Define new member functions. * include/abg-corpus.h (corpus::{get_sym_ids_of_fns_to_keep, get_sym_ids_of_vars_to_keep}): Declare new methods. * src/abg-corpus.cc (corpus::priv::{sym_id_fns_to_keep, sym_id_vars_to_keep}): Added data members. (symtab_build_visitor_type::{unrefed_fun_symbols, unrefed_var_symbols, sym_id_fns_to_keep, sym_id_vars_to_keep}): Added new data members. (symtab_build_visitor_type::symtab_build_visitor_type): Take two additional parameters for the function and variable symbol ids to keep. (symtab_build_visitor_type::add_fn_to_wip_fns): Take the function symbols to keep in account when building the exported symbol table. (symtab_build_visitor_type::add_var_to_wip_vars): Likewise, take the variable symbols to keep in account when building the exported symbol table. (corpus::priv::build_public_decl_table): Adjust the initialization of the visitor that walks the ABI artifacts to build the exported symbol table to know take a list of function/variable symbols to keep. (corpus::priv::build_unreferenced_symbols_tables): Ensure that the public table of functions/variables is built before doing the work of this function. Also, if a list of variable/function symbols to keep is given, drop all symbols that are not in that list on the floor. (corpus::{get_sym_ids_of_fns_to_keep, get_sym_ids_of_vars_to_keep}): Define new accessors. * tools/abicompat.cc: New abicompat tool. * doc/manuals/abicompat.rst: New documentation source for abicompat. * doc/manuals/libabigail-tools.rst: Add an entry for the abicompat doc. * tests/test-abicompat.cc: New test harness for the 'abicompat' tool. * tests/Makefile.am: Build the runtestabicompat test harness and add it to the list of tests harnesses that are run by make check. * tests/data/test-abicompat/libtest0-fn-changed-libapp-v0.so: New test input. * tests/data/test-abicompat/libtest0-fn-changed-libapp-v1.so: Likewise. * tests/data/test-abicompat/test0-fn-changed-app: Likewise. * tests/data/test-abicompat/test0-fn-changed-0.suppr: Likewise * tests/data/test-abicompat/test0-fn-changed-report-0.txt: Likewise. * tests/data/test-abicompat/test0-fn-changed-report-1.txt: Likewise. * tests/data/test-abicompat/test0-fn-changed-app.cc: Likewise. * tests/data/test-abicompat/test0-fn-changed-libapp.h: Likewise. * tests/data/test-abicompat/test0-fn-changed-libapp-v0.cc: Likewise. * tests/data/test-abicompat/test0-fn-changed-libapp-v1.cc: Likewise. * tests/data/test-abicompat/libtest1-fn-removed-v0.so: Likewise. * tests/data/test-abicompat/libtest1-fn-removed-v1.so: Likewise. * tests/data/test-abicompat/test1-fn-removed-app: Likewise. * tests/data/test-abicompat/test1-fn-removed-app.cc: Likewise. * tests/data/test-abicompat/test1-fn-removed-report-0.txt: Likewise. * tests/data/test-abicompat/test1-fn-removed-v0.cc: Likewise. * tests/data/test-abicompat/test1-fn-removed-v1.cc: Likewise. * tests/data/test-abicompat/libtest2-var-removed-v0.so: Likewise. * tests/data/test-abicompat/libtest2-var-removed-v1.so: Likewise. * tests/data/test-abicompat/test2-var-removed-app: Likewise. * tests/data/test-abicompat/test2-var-removed-app.cc: Likewise. * tests/data/test-abicompat/test2-var-removed-report-0.txt: Likewise. * tests/data/test-abicompat/test2-var-removed-v0.cc: Likewise. * tests/data/test-abicompat/test2-var-removed-v1.cc: Likewise. * tests/data/test-abicompat/libtest3-fn-removed-v0.so: Likewise. * tests/data/test-abicompat/libtest3-fn-removed-v1.so: Likewise. * tests/data/test-abicompat/test3-fn-removed-app: Likewise. * tests/data/test-abicompat/test3-fn-removed-app.cc: Likewise. * tests/data/test-abicompat/test3-fn-removed-report-0.txt: Likewise. * tests/data/test-abicompat/test3-fn-removed-v0.cc: Likewise. * tests/data/test-abicompat/test3-fn-removed-v1.cc: Likewise. * tests/data/test-abicompat/test3-fn-removed-version-script-0 Likewise.: * tests/data/test-abicompat/test3-fn-removed-version-script-1: Likewise. * tests/data/Makefile.am: Add the new test inputs above to the source distribution. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-11-30 17:18:55 +00:00
$ abicompat test-app libtest-0.so libtest-1.so
ELF file 'test-app' might not be ABI compatible with 'libtest-1.so' due to differences with 'libtest-0.so' below:
Add support for abicompat weak mode This patch implements the weak mode of abicompat. In this mode, just the application and the new version of the library are provided. The types of functions and variables of the library that are consumed by the application are compared to the types of the functions and variables expected by the application. The goal is to check if the types of the declarations consumed by the application and provided by the library are compatible with what the application expects. The abicompat first gets the set of symbols undefined in the application and exported by the library. It then builds the set of declarations exported by the library that have those symbols. We call these the set of declarations of the library that are consumed by the application. Note that the debug information for the application does not contain the declarations of the functions/variables whose symbols are undefined. So we can not just read them to compare them to declarations exported by the library. But the *types* of the variables and the *sub-types* of the functions whose symbols are undefined in the application are present in the debug information of the application. So in the weak mode, abicompat compare the *types* of the declarations consumed by the application as expected by the application (described by the debug information of the application) with the types of the declarations exported by the library. To do this a number of changes were necessary. The patch builds a representation of all the types found in the application's debug info. Before that, only the types that are reachable from exported declarations were represented. The abidw tool got a new --load-all-types to test this new ability of loading all types. The patch also adds support for looking a type, not by name, but by its internal representation. In the comparison engine, function_type_diff is introduced to represent changes between two function types. For this, a new class type_or_decl_base has been introduced in the IR. It's now the base class for both decl_base and type_base. And abigail::comparison::diff now takes two pointers of type_or_decl, not decl_base anymore. So function_type_diff can take two function_type now; not that a function_type has no declaration so it doesn't inherit decl_base. A bunch of changes got made just to adjust to this modification. A number of fixes were made too, to make this work, like adding missing comparison operators, removing asserts that too strong, etc.. The patch also adjust the test suite as well as the documentation. * include/abg-fwd.h (class type_or_decl_base): Forward declare this. (is_decl, is_type, is_function_type, get_name, get_type_name) (get_function_type_name, get_pretty_representation) (lookup_function_type_in_corpus, lookup_type_in_translation_unit) (lookup_function_type_in_translation_unit) (synthesize_function_type_from_translation_unit) (hash_type_or_decl): New function declarations. * src/abg-corpus.cc (lookup_type_in_corpus) (lookup_function_type_in_corpus): Define new functions. * include/abg-ir.h (translation_unit::lookup_function_type_in_translation_unit): Declare new friend function. (class type_or_decl_base): Declare this. (operator==(const type_or_decl_base&, const type_or_decl_base&)): Declare new operator. (operator==(const type_or_decl_base_sptr&, const type_or_decl_base_sptr&)): Likewise. (class {decl_base, type_base}): Make these class inherit type_or_decl_base. (decl_base::get_member_scopes): New const overload. (bool operator==(const function_decl::parameter_sptr&, const function_decl::parameter_sptr&)): New operator. (function_type::get_parameters): Remove the non-const overload. (function_type::get_pretty_representation): Declare new member function. (method_type::get_pretty_representation): Likewise. * src/abg-ir.cc (bool operator==(const type_or_decl_base&, const type_or_decl_base&)): Define new equality operator. (bool operator==(const type_or_decl_base_sptr&, const type_or_decl_base_sptr&)): Likewise. (strip_typedef): Do not expect canonicalized types anymore. Now the system accepts (and expects) canonicalized types in certain cases. For instance, non-complete types and aggregated types that contain non-complete sub-types. (get_name, get_function_type_name, get_type_name) (get_pretty_representation, is_decl, is_type, is_function_type) (lookup_function_type_in_translation_unit) (synthesize_function_type_from_translation_unit) (lookup_type_in_scope, lookup_type_in_translation_unit): Define new functions or new overloads. (bool operator==(const function_decl::parameter_sptr&, const function_decl::parameter_sptr& r)): Define new operator. (function_type::get_parameters): Remove non-const overload. (function_type::get_pretty_representation): Define new function. (function_type::traverse): Adjust. (method_type::get_pretty_representation): Likewise. (function_decl::get_pretty_representation): Avoid emitting the type of cdtors. (hash_type_or_decl): Define new function. * include/abg-dwarf-reader.h (create_read_context) (read_corpus_from_elf): Take a new 'read_all_types' flag. * src/abg-dwarf-reader.cc (read_context::load_all_types_): New flag. (read_context::read_context): Initialize it. (read_context::canonical_types_scheduled): If some types still have non-canonicalized sub-types, then do not canonicalize them. (read_context::load_all_types): New member functions. (build_function_decl): Do not represent void return type like empty type anymore, rather, represent it like a void type node. (build_ir_node_from_die): When asked, load all types including those that are not reachable from an exported declaration. (create_read_context, read_corpus_from_elf): Take a new 'load_all_types' flag and honour it. * src/abg-reader.cc (read_context::type_is_from_translation_unit): Support looking up function types in the current translation unit, now that we now how to lookup function types. * include/abg-comparison.h (diff_context::{has_diff_for, add_diff, set_canonical_diff_for, set_or_get_canonical_diff_for, get_canonical_diff_for}): Make these take instances of type_or_decl_base_sptr, instead of decl_base_sptr. (diff::diff): Likewise. (diff::{first_subject, second_subject}): Make these return type_or_decl_base_sptr instead of decl_base_sptr. (type_diff_base::type_diff_base): Make these take instances of type_or_decl_base_sptr instead of decl_base_sptr. (distinct_diff::distinct_diff): Likewise. (distinct_diff::{first, second}): Make these return type_or_decl_base_sptr instead of decl_base_sptr. (distinct_diff::entities_are_of_distinct_kinds): Make these take instances of type_or_decl_base_sptr instead of decl_base_sptr. (class function_type_diff): Create this new type. It's a factorization of the function_decl_diff type. * src/abg-comparison.cc (): * src/abg-comp-filter.cc ({harmless, harmful}_filter::visit): Adjust as diff::{first,second}_subject() now returns a type_or_decl_base_sptr, no more a decl_base_sptr. (decls_type, decls_diff_map_type): Remove these typedefs and replace it with ... (types_or_decls_type, types_or_decls_diff_map_type): ... these. (struct {decls_hash, decls_equals): Remove these type sand replace them with ... (struct {types_or_decls_hash, types_or_decls_equals}): ... these. ({type_suppression, variable_suppression}::suppresses_diff): Adjust. (diff_context::priv::decls_diff_map): Replace this with ... (diff_context::priv::types_or_decls_diff_map): ... this. (diff_context::{has_diff_for, add_diff, get_canonical_diff_for, set_canonical_diff_for, set_or_get_canonical_diff_for}): Take type_or_decl_base_sptr instead of decl_base_sptr. (diff::priv::{first, second}_subject): Make the type of these be type_or_decl_base_sptr, no more decl_base_sptr. (diff::priv::priv): Adjust for the subjects of the diff being of type type_or_decl_sptr now, no more decl_base_sptr. (diff_less_than_functor::operator()(const diff_sptr, const diff_sptr) const): Adjust. (diff::diff): djust for the subjects of the diff being of type type_or_decl_sptr now, no more decl_base_sptr. (diff::{first,second}_subject): Make the type of these be type_or_decl_base_sptr, no more decl_base_sptr. (report_size_and_alignment_changes): Likewise. (type_diff_base::type_diff_base): Make the type of this be type_or_decl_base_sptr instead of type_base_sptr. (distinct_diff::distinct_diff): Make this take instances of type_or_decl_base_sptr instead of decl_base_sptr. (distinct_diff::{first, second, entities_are_of_distinct_kinds}): Likewise. (distinct_diff::has_changes): Simplify logic. (distinct_diff::report): Adjust. (compute_diff_for_types): Add an additional case to support the new function_type. (report_size_and_alignment_changes): Make this take instances of type_or_decl_base_sptr instead of decl_base_sptr. (class_diff::priv::member_type_has_changed): Return an instance of type_or_decl_base_sptr rather than a decl_base_sptr. (class_diff::report): Adjust. (diff_comp::operator()(const diff&, diff&) const): Adjust. (enum function_decl_diff::priv::Flags): Remove. (function_decl_diff::priv::{first_fn_flags_, second_fn_flags_, fn_flags_changes_}): Remove. (function_decl_diff::priv::{fn_is_declared_inline_to_flag, fn_binding_to_flag}): Remove. (function_decl_diff::{deleted_parameter_at, inserted_parameter_at}): Remove. (function_decl_diff::ensure_lookup_tables_populated): Empty this. (function_decl_diff::chain_into_hierarchy): Adjust. (function_decl_diff::function_decl_diff): This now only takes the subjects. It's body is now empty. (function_decl_diff::{return_type_diff, subtype_changed_parms, removed_parms, added_parms, type_diff}): Remove these member functions. (function_decl_diff::type_diff): Define new member function. (function_decl_diff::report): Simplify logic by using the reporting of the child type diff node. (compute_diff): Likewise, in the overload for function_decl_sptr simplify logic by using the child type diff object. (function_type_diff::priv): Define new type. (function_type_diff::{function_type_diff, ensure_lookup_tables_populated, deleted_parameter_at, inserted_parameter_at, finish_diff_type, first_function_type, second_function_type, return_type_diff, subtype_changed_parms, removed_parms, added_parms, get_pretty_representation, has_changes, has_local_changes, report, chain_into_hierarchy}): Define new functions. (compute_diff): Define new overload for function_type_sptr. * tools/abicompat.cc (options::weak_mode): New data member. (options::options): Initialize it. (enum abicompat_status): New enum (abicompat_status operator|(abicompat_status, abicompat_status)) (abicompat_status& operator|=(abicompat_status &, abicompat_status)) (abicompat_status operator&(abicompat_status, abicompat_status)): New operators to manipulate the abicompat_status enum. (display_usage): Add help string for the new --weak-mode option. (parse_command_line): Add the new --weak-mode command line argument. If the tool is called with just the application and one library then assume that we are in the weak mode. (perform_compat_check_in_normal_mode): Define new function, factorized from what was in the main function. (perform_compat_check_in_weak_mode): Define new function. (struct {fn,var}_change): Define new types. (main): Use perform_compat_check_in_weak_mode() and perform_compat_check_in_normal_mode(). * tools/abidiff.cc (main): Adjust. * tools/abidw.cc: (options::load_all_types): Add new data member. (options::options): Initialize it. (display_usage): New help string for --load-all-types. (parse_command_line): Support the new --load-all-types option. (main): Adjust and honour the --load-all-types option. * tools/abilint.cc (main): Adjust. * doc/manuals/abicompat.rst: Update documentation for the new weak mode. Also provide stuff that was missing from the examples provided. * doc/manuals/abidw.rst: Update documentation for the new --load-all-types option. * tests/print-diff-tree.cc (main): Adjust. * tests/test-diff-dwarf.cc (main): Likewise. * tests/test-read-dwarf.cc (main): Likewise. * tests/data/test-abicompat/test0-fn-changed-app: Recompile this. * tests/data/test-abicompat/libtest5-fn-changed-libapp-v{0,1}.so: New new test input binaries * tests/data/test-abicompat/test5-fn-changed-app: Likewise. * tests/data/test-abicompat/test6-var-changed-app: Likewise. * tests/data/test-abicompat/libtest6-var-changed-libapp-v{0,1}.so: Likewise. * tests/data/test-abicompat/test5-fn-changed-report-0.txt: Reference output for one test above. * tests/data/test-abicompat/test6-var-changed-report-0.txt: Likewise. * tests/data/test-abicompat/test5-fn-changed-app.cc: Source file for a binary above. * tests/data/test-abicompat/test5-fn-changed-libapp-v{0,1}.{h,cc}: Likewise. * tests/data/test-abicompat/test6-var-changed-libapp-v{0,1}.{cc,h}: Likewise. * tests/data/test-abicompat/test6-var-changed-app.cc: Likewise. * tests/data/Makefile.am: Add the test related files above to the source distribution. * tests/test-abicompat.cc (in_out_spec): Add the new test input above to the list of inputs to feed to this test harness. (main): Support taking just the app and one library. * tests/data/test-read-dwarf/test{0, 1, 2.so, 3.so, 5.o, 8-qualified-this-pointer.so,}.abi: Adjust for void type being really emitted now, as opposed to just being an empty type. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-04-01 10:13:38 +00:00
Functions changes summary: 0 Removed, 2 Changed, 0 Added functions
Initial implementation of the abicompat tool Given an application A that links to a shared library L of version V denoted L(V) and a subsequent version of that library denoted L(V+P), the 'abicompat' tool tells the user if L(V+P) is still ABI compatible with L(V+P). And if it is not, abicompat gives a reports that shows the differences between L(V) and L(V+P) that makes L(V+P) ABI-incompatible with A. The source code of this tool is in the tools/abicompat.cc source file. To support this new tool, this commit changes the comparison engine to optionally avoid showing added symbols that were not referenced by any debug info. It changes the ABI corpus type to allow the specification of a list of variables and functions symbols to keep (and drop all other functions and variables which have other symbols on the floor even before starting to compare the two libraries). This is how the abicompat tool itself works. It basically compares L(V) and L(V+P) but it only looks at their exported functions and variables which symbols are undefined in application A. If the list of exported and defined variables and functions of L(V) whose symbols are undefined in A equals that of L(V+P) (including the sub-types of these variables and functions) A is still compatible with L(V+P). Otherwise, they might not be compatible depending on the kind of differences that are found. * include/abg-comparison.h (diff_context::show_added_symbols_unreferenced_by_debug_info): Declare new accessors. (corpus_diff::{deleted_variables, deleted_unrefed_function_symbols, deleted_unrefed_variable_symbols, apply_filters_and_suppressions_before_reporting}): Declare new methods. (corpus_diff::diff_stats): Declare this new type. Actually this was previously corpus_diff::priv::diff_stats, which was a hidden internal type.. We are moving it here, in the external API so that client code can have more information about changes statistics. Change all the previously publicly accessible data members into accessor functions. * src/abg-comparison.cc (class corpus_diff::diff_stats::priv): New type. (diff_context::priv::show_added_syms_unreferenced_by_di_): New data member. (diff_context::priv::priv): Adjust. (diff_context::show_added_symbols_unreferenced_by_debug_info): Define this new method. (corpus_diff::priv::emit_diff_stats): Do not show the diff stat if the only changes is added function or variables symbols and if we were instructed to not show added symbols. (corpus_diff::priv::{diff_stats_, filters_and_suppr_applied_}): New data members. (corpus_diff::priv::priv): Initialize the filters_and_suppr_applied_ data member. (corpus_diff::priv::diff_stats): Move this type to corpus_diff::diff_stats. (corpus_diff::priv::{apply_filters_and_compute_diff_stats, emit_diff_stats}): Adjust. (corpus_diff::apply_filters_and_suppressions_before_reporting): Define new member function. (corpus_diff::report): Use the new apply_filters_and_suppressions_before_reporting() function, rather than applying the filters and suppressions by ourselves. Also adjust to the use the accessors of the new corpus_diff::diff_stats type. (corpus_diff::{deleted_variables, deleted_unrefed_function_symbols, deleted_unrefed_variable_symbols}): Define new accessors. (corpus_diff::diff_stats::{diff_stats, num_func_removed, num_func_added, num_func_changed, num_func_filtered_out, net_num_func_changed, num_vars_removed, num_vars_added, num_vars_changed, num_vars_filtered_out, net_num_vars_changed, num_func_sym_removed, num_func_syms_added, num_var_syms_removed, num_var_syms_added}): Define new member functions. * include/abg-corpus.h (corpus::{get_sym_ids_of_fns_to_keep, get_sym_ids_of_vars_to_keep}): Declare new methods. * src/abg-corpus.cc (corpus::priv::{sym_id_fns_to_keep, sym_id_vars_to_keep}): Added data members. (symtab_build_visitor_type::{unrefed_fun_symbols, unrefed_var_symbols, sym_id_fns_to_keep, sym_id_vars_to_keep}): Added new data members. (symtab_build_visitor_type::symtab_build_visitor_type): Take two additional parameters for the function and variable symbol ids to keep. (symtab_build_visitor_type::add_fn_to_wip_fns): Take the function symbols to keep in account when building the exported symbol table. (symtab_build_visitor_type::add_var_to_wip_vars): Likewise, take the variable symbols to keep in account when building the exported symbol table. (corpus::priv::build_public_decl_table): Adjust the initialization of the visitor that walks the ABI artifacts to build the exported symbol table to know take a list of function/variable symbols to keep. (corpus::priv::build_unreferenced_symbols_tables): Ensure that the public table of functions/variables is built before doing the work of this function. Also, if a list of variable/function symbols to keep is given, drop all symbols that are not in that list on the floor. (corpus::{get_sym_ids_of_fns_to_keep, get_sym_ids_of_vars_to_keep}): Define new accessors. * tools/abicompat.cc: New abicompat tool. * doc/manuals/abicompat.rst: New documentation source for abicompat. * doc/manuals/libabigail-tools.rst: Add an entry for the abicompat doc. * tests/test-abicompat.cc: New test harness for the 'abicompat' tool. * tests/Makefile.am: Build the runtestabicompat test harness and add it to the list of tests harnesses that are run by make check. * tests/data/test-abicompat/libtest0-fn-changed-libapp-v0.so: New test input. * tests/data/test-abicompat/libtest0-fn-changed-libapp-v1.so: Likewise. * tests/data/test-abicompat/test0-fn-changed-app: Likewise. * tests/data/test-abicompat/test0-fn-changed-0.suppr: Likewise * tests/data/test-abicompat/test0-fn-changed-report-0.txt: Likewise. * tests/data/test-abicompat/test0-fn-changed-report-1.txt: Likewise. * tests/data/test-abicompat/test0-fn-changed-app.cc: Likewise. * tests/data/test-abicompat/test0-fn-changed-libapp.h: Likewise. * tests/data/test-abicompat/test0-fn-changed-libapp-v0.cc: Likewise. * tests/data/test-abicompat/test0-fn-changed-libapp-v1.cc: Likewise. * tests/data/test-abicompat/libtest1-fn-removed-v0.so: Likewise. * tests/data/test-abicompat/libtest1-fn-removed-v1.so: Likewise. * tests/data/test-abicompat/test1-fn-removed-app: Likewise. * tests/data/test-abicompat/test1-fn-removed-app.cc: Likewise. * tests/data/test-abicompat/test1-fn-removed-report-0.txt: Likewise. * tests/data/test-abicompat/test1-fn-removed-v0.cc: Likewise. * tests/data/test-abicompat/test1-fn-removed-v1.cc: Likewise. * tests/data/test-abicompat/libtest2-var-removed-v0.so: Likewise. * tests/data/test-abicompat/libtest2-var-removed-v1.so: Likewise. * tests/data/test-abicompat/test2-var-removed-app: Likewise. * tests/data/test-abicompat/test2-var-removed-app.cc: Likewise. * tests/data/test-abicompat/test2-var-removed-report-0.txt: Likewise. * tests/data/test-abicompat/test2-var-removed-v0.cc: Likewise. * tests/data/test-abicompat/test2-var-removed-v1.cc: Likewise. * tests/data/test-abicompat/libtest3-fn-removed-v0.so: Likewise. * tests/data/test-abicompat/libtest3-fn-removed-v1.so: Likewise. * tests/data/test-abicompat/test3-fn-removed-app: Likewise. * tests/data/test-abicompat/test3-fn-removed-app.cc: Likewise. * tests/data/test-abicompat/test3-fn-removed-report-0.txt: Likewise. * tests/data/test-abicompat/test3-fn-removed-v0.cc: Likewise. * tests/data/test-abicompat/test3-fn-removed-v1.cc: Likewise. * tests/data/test-abicompat/test3-fn-removed-version-script-0 Likewise.: * tests/data/test-abicompat/test3-fn-removed-version-script-1: Likewise. * tests/data/Makefile.am: Add the new test inputs above to the source distribution. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-11-30 17:18:55 +00:00
Variables changes summary: 0 Removed, 0 Changed, 0 Added variable
Add support for abicompat weak mode This patch implements the weak mode of abicompat. In this mode, just the application and the new version of the library are provided. The types of functions and variables of the library that are consumed by the application are compared to the types of the functions and variables expected by the application. The goal is to check if the types of the declarations consumed by the application and provided by the library are compatible with what the application expects. The abicompat first gets the set of symbols undefined in the application and exported by the library. It then builds the set of declarations exported by the library that have those symbols. We call these the set of declarations of the library that are consumed by the application. Note that the debug information for the application does not contain the declarations of the functions/variables whose symbols are undefined. So we can not just read them to compare them to declarations exported by the library. But the *types* of the variables and the *sub-types* of the functions whose symbols are undefined in the application are present in the debug information of the application. So in the weak mode, abicompat compare the *types* of the declarations consumed by the application as expected by the application (described by the debug information of the application) with the types of the declarations exported by the library. To do this a number of changes were necessary. The patch builds a representation of all the types found in the application's debug info. Before that, only the types that are reachable from exported declarations were represented. The abidw tool got a new --load-all-types to test this new ability of loading all types. The patch also adds support for looking a type, not by name, but by its internal representation. In the comparison engine, function_type_diff is introduced to represent changes between two function types. For this, a new class type_or_decl_base has been introduced in the IR. It's now the base class for both decl_base and type_base. And abigail::comparison::diff now takes two pointers of type_or_decl, not decl_base anymore. So function_type_diff can take two function_type now; not that a function_type has no declaration so it doesn't inherit decl_base. A bunch of changes got made just to adjust to this modification. A number of fixes were made too, to make this work, like adding missing comparison operators, removing asserts that too strong, etc.. The patch also adjust the test suite as well as the documentation. * include/abg-fwd.h (class type_or_decl_base): Forward declare this. (is_decl, is_type, is_function_type, get_name, get_type_name) (get_function_type_name, get_pretty_representation) (lookup_function_type_in_corpus, lookup_type_in_translation_unit) (lookup_function_type_in_translation_unit) (synthesize_function_type_from_translation_unit) (hash_type_or_decl): New function declarations. * src/abg-corpus.cc (lookup_type_in_corpus) (lookup_function_type_in_corpus): Define new functions. * include/abg-ir.h (translation_unit::lookup_function_type_in_translation_unit): Declare new friend function. (class type_or_decl_base): Declare this. (operator==(const type_or_decl_base&, const type_or_decl_base&)): Declare new operator. (operator==(const type_or_decl_base_sptr&, const type_or_decl_base_sptr&)): Likewise. (class {decl_base, type_base}): Make these class inherit type_or_decl_base. (decl_base::get_member_scopes): New const overload. (bool operator==(const function_decl::parameter_sptr&, const function_decl::parameter_sptr&)): New operator. (function_type::get_parameters): Remove the non-const overload. (function_type::get_pretty_representation): Declare new member function. (method_type::get_pretty_representation): Likewise. * src/abg-ir.cc (bool operator==(const type_or_decl_base&, const type_or_decl_base&)): Define new equality operator. (bool operator==(const type_or_decl_base_sptr&, const type_or_decl_base_sptr&)): Likewise. (strip_typedef): Do not expect canonicalized types anymore. Now the system accepts (and expects) canonicalized types in certain cases. For instance, non-complete types and aggregated types that contain non-complete sub-types. (get_name, get_function_type_name, get_type_name) (get_pretty_representation, is_decl, is_type, is_function_type) (lookup_function_type_in_translation_unit) (synthesize_function_type_from_translation_unit) (lookup_type_in_scope, lookup_type_in_translation_unit): Define new functions or new overloads. (bool operator==(const function_decl::parameter_sptr&, const function_decl::parameter_sptr& r)): Define new operator. (function_type::get_parameters): Remove non-const overload. (function_type::get_pretty_representation): Define new function. (function_type::traverse): Adjust. (method_type::get_pretty_representation): Likewise. (function_decl::get_pretty_representation): Avoid emitting the type of cdtors. (hash_type_or_decl): Define new function. * include/abg-dwarf-reader.h (create_read_context) (read_corpus_from_elf): Take a new 'read_all_types' flag. * src/abg-dwarf-reader.cc (read_context::load_all_types_): New flag. (read_context::read_context): Initialize it. (read_context::canonical_types_scheduled): If some types still have non-canonicalized sub-types, then do not canonicalize them. (read_context::load_all_types): New member functions. (build_function_decl): Do not represent void return type like empty type anymore, rather, represent it like a void type node. (build_ir_node_from_die): When asked, load all types including those that are not reachable from an exported declaration. (create_read_context, read_corpus_from_elf): Take a new 'load_all_types' flag and honour it. * src/abg-reader.cc (read_context::type_is_from_translation_unit): Support looking up function types in the current translation unit, now that we now how to lookup function types. * include/abg-comparison.h (diff_context::{has_diff_for, add_diff, set_canonical_diff_for, set_or_get_canonical_diff_for, get_canonical_diff_for}): Make these take instances of type_or_decl_base_sptr, instead of decl_base_sptr. (diff::diff): Likewise. (diff::{first_subject, second_subject}): Make these return type_or_decl_base_sptr instead of decl_base_sptr. (type_diff_base::type_diff_base): Make these take instances of type_or_decl_base_sptr instead of decl_base_sptr. (distinct_diff::distinct_diff): Likewise. (distinct_diff::{first, second}): Make these return type_or_decl_base_sptr instead of decl_base_sptr. (distinct_diff::entities_are_of_distinct_kinds): Make these take instances of type_or_decl_base_sptr instead of decl_base_sptr. (class function_type_diff): Create this new type. It's a factorization of the function_decl_diff type. * src/abg-comparison.cc (): * src/abg-comp-filter.cc ({harmless, harmful}_filter::visit): Adjust as diff::{first,second}_subject() now returns a type_or_decl_base_sptr, no more a decl_base_sptr. (decls_type, decls_diff_map_type): Remove these typedefs and replace it with ... (types_or_decls_type, types_or_decls_diff_map_type): ... these. (struct {decls_hash, decls_equals): Remove these type sand replace them with ... (struct {types_or_decls_hash, types_or_decls_equals}): ... these. ({type_suppression, variable_suppression}::suppresses_diff): Adjust. (diff_context::priv::decls_diff_map): Replace this with ... (diff_context::priv::types_or_decls_diff_map): ... this. (diff_context::{has_diff_for, add_diff, get_canonical_diff_for, set_canonical_diff_for, set_or_get_canonical_diff_for}): Take type_or_decl_base_sptr instead of decl_base_sptr. (diff::priv::{first, second}_subject): Make the type of these be type_or_decl_base_sptr, no more decl_base_sptr. (diff::priv::priv): Adjust for the subjects of the diff being of type type_or_decl_sptr now, no more decl_base_sptr. (diff_less_than_functor::operator()(const diff_sptr, const diff_sptr) const): Adjust. (diff::diff): djust for the subjects of the diff being of type type_or_decl_sptr now, no more decl_base_sptr. (diff::{first,second}_subject): Make the type of these be type_or_decl_base_sptr, no more decl_base_sptr. (report_size_and_alignment_changes): Likewise. (type_diff_base::type_diff_base): Make the type of this be type_or_decl_base_sptr instead of type_base_sptr. (distinct_diff::distinct_diff): Make this take instances of type_or_decl_base_sptr instead of decl_base_sptr. (distinct_diff::{first, second, entities_are_of_distinct_kinds}): Likewise. (distinct_diff::has_changes): Simplify logic. (distinct_diff::report): Adjust. (compute_diff_for_types): Add an additional case to support the new function_type. (report_size_and_alignment_changes): Make this take instances of type_or_decl_base_sptr instead of decl_base_sptr. (class_diff::priv::member_type_has_changed): Return an instance of type_or_decl_base_sptr rather than a decl_base_sptr. (class_diff::report): Adjust. (diff_comp::operator()(const diff&, diff&) const): Adjust. (enum function_decl_diff::priv::Flags): Remove. (function_decl_diff::priv::{first_fn_flags_, second_fn_flags_, fn_flags_changes_}): Remove. (function_decl_diff::priv::{fn_is_declared_inline_to_flag, fn_binding_to_flag}): Remove. (function_decl_diff::{deleted_parameter_at, inserted_parameter_at}): Remove. (function_decl_diff::ensure_lookup_tables_populated): Empty this. (function_decl_diff::chain_into_hierarchy): Adjust. (function_decl_diff::function_decl_diff): This now only takes the subjects. It's body is now empty. (function_decl_diff::{return_type_diff, subtype_changed_parms, removed_parms, added_parms, type_diff}): Remove these member functions. (function_decl_diff::type_diff): Define new member function. (function_decl_diff::report): Simplify logic by using the reporting of the child type diff node. (compute_diff): Likewise, in the overload for function_decl_sptr simplify logic by using the child type diff object. (function_type_diff::priv): Define new type. (function_type_diff::{function_type_diff, ensure_lookup_tables_populated, deleted_parameter_at, inserted_parameter_at, finish_diff_type, first_function_type, second_function_type, return_type_diff, subtype_changed_parms, removed_parms, added_parms, get_pretty_representation, has_changes, has_local_changes, report, chain_into_hierarchy}): Define new functions. (compute_diff): Define new overload for function_type_sptr. * tools/abicompat.cc (options::weak_mode): New data member. (options::options): Initialize it. (enum abicompat_status): New enum (abicompat_status operator|(abicompat_status, abicompat_status)) (abicompat_status& operator|=(abicompat_status &, abicompat_status)) (abicompat_status operator&(abicompat_status, abicompat_status)): New operators to manipulate the abicompat_status enum. (display_usage): Add help string for the new --weak-mode option. (parse_command_line): Add the new --weak-mode command line argument. If the tool is called with just the application and one library then assume that we are in the weak mode. (perform_compat_check_in_normal_mode): Define new function, factorized from what was in the main function. (perform_compat_check_in_weak_mode): Define new function. (struct {fn,var}_change): Define new types. (main): Use perform_compat_check_in_weak_mode() and perform_compat_check_in_normal_mode(). * tools/abidiff.cc (main): Adjust. * tools/abidw.cc: (options::load_all_types): Add new data member. (options::options): Initialize it. (display_usage): New help string for --load-all-types. (parse_command_line): Support the new --load-all-types option. (main): Adjust and honour the --load-all-types option. * tools/abilint.cc (main): Adjust. * doc/manuals/abicompat.rst: Update documentation for the new weak mode. Also provide stuff that was missing from the examples provided. * doc/manuals/abidw.rst: Update documentation for the new --load-all-types option. * tests/print-diff-tree.cc (main): Adjust. * tests/test-diff-dwarf.cc (main): Likewise. * tests/test-read-dwarf.cc (main): Likewise. * tests/data/test-abicompat/test0-fn-changed-app: Recompile this. * tests/data/test-abicompat/libtest5-fn-changed-libapp-v{0,1}.so: New new test input binaries * tests/data/test-abicompat/test5-fn-changed-app: Likewise. * tests/data/test-abicompat/test6-var-changed-app: Likewise. * tests/data/test-abicompat/libtest6-var-changed-libapp-v{0,1}.so: Likewise. * tests/data/test-abicompat/test5-fn-changed-report-0.txt: Reference output for one test above. * tests/data/test-abicompat/test6-var-changed-report-0.txt: Likewise. * tests/data/test-abicompat/test5-fn-changed-app.cc: Source file for a binary above. * tests/data/test-abicompat/test5-fn-changed-libapp-v{0,1}.{h,cc}: Likewise. * tests/data/test-abicompat/test6-var-changed-libapp-v{0,1}.{cc,h}: Likewise. * tests/data/test-abicompat/test6-var-changed-app.cc: Likewise. * tests/data/Makefile.am: Add the test related files above to the source distribution. * tests/test-abicompat.cc (in_out_spec): Add the new test input above to the list of inputs to feed to this test harness. (main): Support taking just the app and one library. * tests/data/test-read-dwarf/test{0, 1, 2.so, 3.so, 5.o, 8-qualified-this-pointer.so,}.abi: Adjust for void type being really emitted now, as opposed to just being an empty type. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-04-01 10:13:38 +00:00
2 functions with some indirect sub-type change:
Initial implementation of the abicompat tool Given an application A that links to a shared library L of version V denoted L(V) and a subsequent version of that library denoted L(V+P), the 'abicompat' tool tells the user if L(V+P) is still ABI compatible with L(V+P). And if it is not, abicompat gives a reports that shows the differences between L(V) and L(V+P) that makes L(V+P) ABI-incompatible with A. The source code of this tool is in the tools/abicompat.cc source file. To support this new tool, this commit changes the comparison engine to optionally avoid showing added symbols that were not referenced by any debug info. It changes the ABI corpus type to allow the specification of a list of variables and functions symbols to keep (and drop all other functions and variables which have other symbols on the floor even before starting to compare the two libraries). This is how the abicompat tool itself works. It basically compares L(V) and L(V+P) but it only looks at their exported functions and variables which symbols are undefined in application A. If the list of exported and defined variables and functions of L(V) whose symbols are undefined in A equals that of L(V+P) (including the sub-types of these variables and functions) A is still compatible with L(V+P). Otherwise, they might not be compatible depending on the kind of differences that are found. * include/abg-comparison.h (diff_context::show_added_symbols_unreferenced_by_debug_info): Declare new accessors. (corpus_diff::{deleted_variables, deleted_unrefed_function_symbols, deleted_unrefed_variable_symbols, apply_filters_and_suppressions_before_reporting}): Declare new methods. (corpus_diff::diff_stats): Declare this new type. Actually this was previously corpus_diff::priv::diff_stats, which was a hidden internal type.. We are moving it here, in the external API so that client code can have more information about changes statistics. Change all the previously publicly accessible data members into accessor functions. * src/abg-comparison.cc (class corpus_diff::diff_stats::priv): New type. (diff_context::priv::show_added_syms_unreferenced_by_di_): New data member. (diff_context::priv::priv): Adjust. (diff_context::show_added_symbols_unreferenced_by_debug_info): Define this new method. (corpus_diff::priv::emit_diff_stats): Do not show the diff stat if the only changes is added function or variables symbols and if we were instructed to not show added symbols. (corpus_diff::priv::{diff_stats_, filters_and_suppr_applied_}): New data members. (corpus_diff::priv::priv): Initialize the filters_and_suppr_applied_ data member. (corpus_diff::priv::diff_stats): Move this type to corpus_diff::diff_stats. (corpus_diff::priv::{apply_filters_and_compute_diff_stats, emit_diff_stats}): Adjust. (corpus_diff::apply_filters_and_suppressions_before_reporting): Define new member function. (corpus_diff::report): Use the new apply_filters_and_suppressions_before_reporting() function, rather than applying the filters and suppressions by ourselves. Also adjust to the use the accessors of the new corpus_diff::diff_stats type. (corpus_diff::{deleted_variables, deleted_unrefed_function_symbols, deleted_unrefed_variable_symbols}): Define new accessors. (corpus_diff::diff_stats::{diff_stats, num_func_removed, num_func_added, num_func_changed, num_func_filtered_out, net_num_func_changed, num_vars_removed, num_vars_added, num_vars_changed, num_vars_filtered_out, net_num_vars_changed, num_func_sym_removed, num_func_syms_added, num_var_syms_removed, num_var_syms_added}): Define new member functions. * include/abg-corpus.h (corpus::{get_sym_ids_of_fns_to_keep, get_sym_ids_of_vars_to_keep}): Declare new methods. * src/abg-corpus.cc (corpus::priv::{sym_id_fns_to_keep, sym_id_vars_to_keep}): Added data members. (symtab_build_visitor_type::{unrefed_fun_symbols, unrefed_var_symbols, sym_id_fns_to_keep, sym_id_vars_to_keep}): Added new data members. (symtab_build_visitor_type::symtab_build_visitor_type): Take two additional parameters for the function and variable symbol ids to keep. (symtab_build_visitor_type::add_fn_to_wip_fns): Take the function symbols to keep in account when building the exported symbol table. (symtab_build_visitor_type::add_var_to_wip_vars): Likewise, take the variable symbols to keep in account when building the exported symbol table. (corpus::priv::build_public_decl_table): Adjust the initialization of the visitor that walks the ABI artifacts to build the exported symbol table to know take a list of function/variable symbols to keep. (corpus::priv::build_unreferenced_symbols_tables): Ensure that the public table of functions/variables is built before doing the work of this function. Also, if a list of variable/function symbols to keep is given, drop all symbols that are not in that list on the floor. (corpus::{get_sym_ids_of_fns_to_keep, get_sym_ids_of_vars_to_keep}): Define new accessors. * tools/abicompat.cc: New abicompat tool. * doc/manuals/abicompat.rst: New documentation source for abicompat. * doc/manuals/libabigail-tools.rst: Add an entry for the abicompat doc. * tests/test-abicompat.cc: New test harness for the 'abicompat' tool. * tests/Makefile.am: Build the runtestabicompat test harness and add it to the list of tests harnesses that are run by make check. * tests/data/test-abicompat/libtest0-fn-changed-libapp-v0.so: New test input. * tests/data/test-abicompat/libtest0-fn-changed-libapp-v1.so: Likewise. * tests/data/test-abicompat/test0-fn-changed-app: Likewise. * tests/data/test-abicompat/test0-fn-changed-0.suppr: Likewise * tests/data/test-abicompat/test0-fn-changed-report-0.txt: Likewise. * tests/data/test-abicompat/test0-fn-changed-report-1.txt: Likewise. * tests/data/test-abicompat/test0-fn-changed-app.cc: Likewise. * tests/data/test-abicompat/test0-fn-changed-libapp.h: Likewise. * tests/data/test-abicompat/test0-fn-changed-libapp-v0.cc: Likewise. * tests/data/test-abicompat/test0-fn-changed-libapp-v1.cc: Likewise. * tests/data/test-abicompat/libtest1-fn-removed-v0.so: Likewise. * tests/data/test-abicompat/libtest1-fn-removed-v1.so: Likewise. * tests/data/test-abicompat/test1-fn-removed-app: Likewise. * tests/data/test-abicompat/test1-fn-removed-app.cc: Likewise. * tests/data/test-abicompat/test1-fn-removed-report-0.txt: Likewise. * tests/data/test-abicompat/test1-fn-removed-v0.cc: Likewise. * tests/data/test-abicompat/test1-fn-removed-v1.cc: Likewise. * tests/data/test-abicompat/libtest2-var-removed-v0.so: Likewise. * tests/data/test-abicompat/libtest2-var-removed-v1.so: Likewise. * tests/data/test-abicompat/test2-var-removed-app: Likewise. * tests/data/test-abicompat/test2-var-removed-app.cc: Likewise. * tests/data/test-abicompat/test2-var-removed-report-0.txt: Likewise. * tests/data/test-abicompat/test2-var-removed-v0.cc: Likewise. * tests/data/test-abicompat/test2-var-removed-v1.cc: Likewise. * tests/data/test-abicompat/libtest3-fn-removed-v0.so: Likewise. * tests/data/test-abicompat/libtest3-fn-removed-v1.so: Likewise. * tests/data/test-abicompat/test3-fn-removed-app: Likewise. * tests/data/test-abicompat/test3-fn-removed-app.cc: Likewise. * tests/data/test-abicompat/test3-fn-removed-report-0.txt: Likewise. * tests/data/test-abicompat/test3-fn-removed-v0.cc: Likewise. * tests/data/test-abicompat/test3-fn-removed-v1.cc: Likewise. * tests/data/test-abicompat/test3-fn-removed-version-script-0 Likewise.: * tests/data/test-abicompat/test3-fn-removed-version-script-1: Likewise. * tests/data/Makefile.am: Add the new test inputs above to the source distribution. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-11-30 17:18:55 +00:00
[C]'function foo* first_func()' has some indirect sub-type changes:
return type changed:
in pointed to type 'struct foo':
size changed from 32 to 64 bits
1 data member insertion:
Add support for abicompat weak mode This patch implements the weak mode of abicompat. In this mode, just the application and the new version of the library are provided. The types of functions and variables of the library that are consumed by the application are compared to the types of the functions and variables expected by the application. The goal is to check if the types of the declarations consumed by the application and provided by the library are compatible with what the application expects. The abicompat first gets the set of symbols undefined in the application and exported by the library. It then builds the set of declarations exported by the library that have those symbols. We call these the set of declarations of the library that are consumed by the application. Note that the debug information for the application does not contain the declarations of the functions/variables whose symbols are undefined. So we can not just read them to compare them to declarations exported by the library. But the *types* of the variables and the *sub-types* of the functions whose symbols are undefined in the application are present in the debug information of the application. So in the weak mode, abicompat compare the *types* of the declarations consumed by the application as expected by the application (described by the debug information of the application) with the types of the declarations exported by the library. To do this a number of changes were necessary. The patch builds a representation of all the types found in the application's debug info. Before that, only the types that are reachable from exported declarations were represented. The abidw tool got a new --load-all-types to test this new ability of loading all types. The patch also adds support for looking a type, not by name, but by its internal representation. In the comparison engine, function_type_diff is introduced to represent changes between two function types. For this, a new class type_or_decl_base has been introduced in the IR. It's now the base class for both decl_base and type_base. And abigail::comparison::diff now takes two pointers of type_or_decl, not decl_base anymore. So function_type_diff can take two function_type now; not that a function_type has no declaration so it doesn't inherit decl_base. A bunch of changes got made just to adjust to this modification. A number of fixes were made too, to make this work, like adding missing comparison operators, removing asserts that too strong, etc.. The patch also adjust the test suite as well as the documentation. * include/abg-fwd.h (class type_or_decl_base): Forward declare this. (is_decl, is_type, is_function_type, get_name, get_type_name) (get_function_type_name, get_pretty_representation) (lookup_function_type_in_corpus, lookup_type_in_translation_unit) (lookup_function_type_in_translation_unit) (synthesize_function_type_from_translation_unit) (hash_type_or_decl): New function declarations. * src/abg-corpus.cc (lookup_type_in_corpus) (lookup_function_type_in_corpus): Define new functions. * include/abg-ir.h (translation_unit::lookup_function_type_in_translation_unit): Declare new friend function. (class type_or_decl_base): Declare this. (operator==(const type_or_decl_base&, const type_or_decl_base&)): Declare new operator. (operator==(const type_or_decl_base_sptr&, const type_or_decl_base_sptr&)): Likewise. (class {decl_base, type_base}): Make these class inherit type_or_decl_base. (decl_base::get_member_scopes): New const overload. (bool operator==(const function_decl::parameter_sptr&, const function_decl::parameter_sptr&)): New operator. (function_type::get_parameters): Remove the non-const overload. (function_type::get_pretty_representation): Declare new member function. (method_type::get_pretty_representation): Likewise. * src/abg-ir.cc (bool operator==(const type_or_decl_base&, const type_or_decl_base&)): Define new equality operator. (bool operator==(const type_or_decl_base_sptr&, const type_or_decl_base_sptr&)): Likewise. (strip_typedef): Do not expect canonicalized types anymore. Now the system accepts (and expects) canonicalized types in certain cases. For instance, non-complete types and aggregated types that contain non-complete sub-types. (get_name, get_function_type_name, get_type_name) (get_pretty_representation, is_decl, is_type, is_function_type) (lookup_function_type_in_translation_unit) (synthesize_function_type_from_translation_unit) (lookup_type_in_scope, lookup_type_in_translation_unit): Define new functions or new overloads. (bool operator==(const function_decl::parameter_sptr&, const function_decl::parameter_sptr& r)): Define new operator. (function_type::get_parameters): Remove non-const overload. (function_type::get_pretty_representation): Define new function. (function_type::traverse): Adjust. (method_type::get_pretty_representation): Likewise. (function_decl::get_pretty_representation): Avoid emitting the type of cdtors. (hash_type_or_decl): Define new function. * include/abg-dwarf-reader.h (create_read_context) (read_corpus_from_elf): Take a new 'read_all_types' flag. * src/abg-dwarf-reader.cc (read_context::load_all_types_): New flag. (read_context::read_context): Initialize it. (read_context::canonical_types_scheduled): If some types still have non-canonicalized sub-types, then do not canonicalize them. (read_context::load_all_types): New member functions. (build_function_decl): Do not represent void return type like empty type anymore, rather, represent it like a void type node. (build_ir_node_from_die): When asked, load all types including those that are not reachable from an exported declaration. (create_read_context, read_corpus_from_elf): Take a new 'load_all_types' flag and honour it. * src/abg-reader.cc (read_context::type_is_from_translation_unit): Support looking up function types in the current translation unit, now that we now how to lookup function types. * include/abg-comparison.h (diff_context::{has_diff_for, add_diff, set_canonical_diff_for, set_or_get_canonical_diff_for, get_canonical_diff_for}): Make these take instances of type_or_decl_base_sptr, instead of decl_base_sptr. (diff::diff): Likewise. (diff::{first_subject, second_subject}): Make these return type_or_decl_base_sptr instead of decl_base_sptr. (type_diff_base::type_diff_base): Make these take instances of type_or_decl_base_sptr instead of decl_base_sptr. (distinct_diff::distinct_diff): Likewise. (distinct_diff::{first, second}): Make these return type_or_decl_base_sptr instead of decl_base_sptr. (distinct_diff::entities_are_of_distinct_kinds): Make these take instances of type_or_decl_base_sptr instead of decl_base_sptr. (class function_type_diff): Create this new type. It's a factorization of the function_decl_diff type. * src/abg-comparison.cc (): * src/abg-comp-filter.cc ({harmless, harmful}_filter::visit): Adjust as diff::{first,second}_subject() now returns a type_or_decl_base_sptr, no more a decl_base_sptr. (decls_type, decls_diff_map_type): Remove these typedefs and replace it with ... (types_or_decls_type, types_or_decls_diff_map_type): ... these. (struct {decls_hash, decls_equals): Remove these type sand replace them with ... (struct {types_or_decls_hash, types_or_decls_equals}): ... these. ({type_suppression, variable_suppression}::suppresses_diff): Adjust. (diff_context::priv::decls_diff_map): Replace this with ... (diff_context::priv::types_or_decls_diff_map): ... this. (diff_context::{has_diff_for, add_diff, get_canonical_diff_for, set_canonical_diff_for, set_or_get_canonical_diff_for}): Take type_or_decl_base_sptr instead of decl_base_sptr. (diff::priv::{first, second}_subject): Make the type of these be type_or_decl_base_sptr, no more decl_base_sptr. (diff::priv::priv): Adjust for the subjects of the diff being of type type_or_decl_sptr now, no more decl_base_sptr. (diff_less_than_functor::operator()(const diff_sptr, const diff_sptr) const): Adjust. (diff::diff): djust for the subjects of the diff being of type type_or_decl_sptr now, no more decl_base_sptr. (diff::{first,second}_subject): Make the type of these be type_or_decl_base_sptr, no more decl_base_sptr. (report_size_and_alignment_changes): Likewise. (type_diff_base::type_diff_base): Make the type of this be type_or_decl_base_sptr instead of type_base_sptr. (distinct_diff::distinct_diff): Make this take instances of type_or_decl_base_sptr instead of decl_base_sptr. (distinct_diff::{first, second, entities_are_of_distinct_kinds}): Likewise. (distinct_diff::has_changes): Simplify logic. (distinct_diff::report): Adjust. (compute_diff_for_types): Add an additional case to support the new function_type. (report_size_and_alignment_changes): Make this take instances of type_or_decl_base_sptr instead of decl_base_sptr. (class_diff::priv::member_type_has_changed): Return an instance of type_or_decl_base_sptr rather than a decl_base_sptr. (class_diff::report): Adjust. (diff_comp::operator()(const diff&, diff&) const): Adjust. (enum function_decl_diff::priv::Flags): Remove. (function_decl_diff::priv::{first_fn_flags_, second_fn_flags_, fn_flags_changes_}): Remove. (function_decl_diff::priv::{fn_is_declared_inline_to_flag, fn_binding_to_flag}): Remove. (function_decl_diff::{deleted_parameter_at, inserted_parameter_at}): Remove. (function_decl_diff::ensure_lookup_tables_populated): Empty this. (function_decl_diff::chain_into_hierarchy): Adjust. (function_decl_diff::function_decl_diff): This now only takes the subjects. It's body is now empty. (function_decl_diff::{return_type_diff, subtype_changed_parms, removed_parms, added_parms, type_diff}): Remove these member functions. (function_decl_diff::type_diff): Define new member function. (function_decl_diff::report): Simplify logic by using the reporting of the child type diff node. (compute_diff): Likewise, in the overload for function_decl_sptr simplify logic by using the child type diff object. (function_type_diff::priv): Define new type. (function_type_diff::{function_type_diff, ensure_lookup_tables_populated, deleted_parameter_at, inserted_parameter_at, finish_diff_type, first_function_type, second_function_type, return_type_diff, subtype_changed_parms, removed_parms, added_parms, get_pretty_representation, has_changes, has_local_changes, report, chain_into_hierarchy}): Define new functions. (compute_diff): Define new overload for function_type_sptr. * tools/abicompat.cc (options::weak_mode): New data member. (options::options): Initialize it. (enum abicompat_status): New enum (abicompat_status operator|(abicompat_status, abicompat_status)) (abicompat_status& operator|=(abicompat_status &, abicompat_status)) (abicompat_status operator&(abicompat_status, abicompat_status)): New operators to manipulate the abicompat_status enum. (display_usage): Add help string for the new --weak-mode option. (parse_command_line): Add the new --weak-mode command line argument. If the tool is called with just the application and one library then assume that we are in the weak mode. (perform_compat_check_in_normal_mode): Define new function, factorized from what was in the main function. (perform_compat_check_in_weak_mode): Define new function. (struct {fn,var}_change): Define new types. (main): Use perform_compat_check_in_weak_mode() and perform_compat_check_in_normal_mode(). * tools/abidiff.cc (main): Adjust. * tools/abidw.cc: (options::load_all_types): Add new data member. (options::options): Initialize it. (display_usage): New help string for --load-all-types. (parse_command_line): Support the new --load-all-types option. (main): Adjust and honour the --load-all-types option. * tools/abilint.cc (main): Adjust. * doc/manuals/abicompat.rst: Update documentation for the new weak mode. Also provide stuff that was missing from the examples provided. * doc/manuals/abidw.rst: Update documentation for the new --load-all-types option. * tests/print-diff-tree.cc (main): Adjust. * tests/test-diff-dwarf.cc (main): Likewise. * tests/test-read-dwarf.cc (main): Likewise. * tests/data/test-abicompat/test0-fn-changed-app: Recompile this. * tests/data/test-abicompat/libtest5-fn-changed-libapp-v{0,1}.so: New new test input binaries * tests/data/test-abicompat/test5-fn-changed-app: Likewise. * tests/data/test-abicompat/test6-var-changed-app: Likewise. * tests/data/test-abicompat/libtest6-var-changed-libapp-v{0,1}.so: Likewise. * tests/data/test-abicompat/test5-fn-changed-report-0.txt: Reference output for one test above. * tests/data/test-abicompat/test6-var-changed-report-0.txt: Likewise. * tests/data/test-abicompat/test5-fn-changed-app.cc: Source file for a binary above. * tests/data/test-abicompat/test5-fn-changed-libapp-v{0,1}.{h,cc}: Likewise. * tests/data/test-abicompat/test6-var-changed-libapp-v{0,1}.{cc,h}: Likewise. * tests/data/test-abicompat/test6-var-changed-app.cc: Likewise. * tests/data/Makefile.am: Add the test related files above to the source distribution. * tests/test-abicompat.cc (in_out_spec): Add the new test input above to the list of inputs to feed to this test harness. (main): Support taking just the app and one library. * tests/data/test-read-dwarf/test{0, 1, 2.so, 3.so, 5.o, 8-qualified-this-pointer.so,}.abi: Adjust for void type being really emitted now, as opposed to just being an empty type. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-04-01 10:13:38 +00:00
'char foo::m1', at offset 32 (in bits)
[C]'function void second_func(foo&)' has some indirect sub-type changes:
parameter 0 of type 'foo&' has sub-type changes:
referenced type 'struct foo' changed, as reported earlier
Initial implementation of the abicompat tool Given an application A that links to a shared library L of version V denoted L(V) and a subsequent version of that library denoted L(V+P), the 'abicompat' tool tells the user if L(V+P) is still ABI compatible with L(V+P). And if it is not, abicompat gives a reports that shows the differences between L(V) and L(V+P) that makes L(V+P) ABI-incompatible with A. The source code of this tool is in the tools/abicompat.cc source file. To support this new tool, this commit changes the comparison engine to optionally avoid showing added symbols that were not referenced by any debug info. It changes the ABI corpus type to allow the specification of a list of variables and functions symbols to keep (and drop all other functions and variables which have other symbols on the floor even before starting to compare the two libraries). This is how the abicompat tool itself works. It basically compares L(V) and L(V+P) but it only looks at their exported functions and variables which symbols are undefined in application A. If the list of exported and defined variables and functions of L(V) whose symbols are undefined in A equals that of L(V+P) (including the sub-types of these variables and functions) A is still compatible with L(V+P). Otherwise, they might not be compatible depending on the kind of differences that are found. * include/abg-comparison.h (diff_context::show_added_symbols_unreferenced_by_debug_info): Declare new accessors. (corpus_diff::{deleted_variables, deleted_unrefed_function_symbols, deleted_unrefed_variable_symbols, apply_filters_and_suppressions_before_reporting}): Declare new methods. (corpus_diff::diff_stats): Declare this new type. Actually this was previously corpus_diff::priv::diff_stats, which was a hidden internal type.. We are moving it here, in the external API so that client code can have more information about changes statistics. Change all the previously publicly accessible data members into accessor functions. * src/abg-comparison.cc (class corpus_diff::diff_stats::priv): New type. (diff_context::priv::show_added_syms_unreferenced_by_di_): New data member. (diff_context::priv::priv): Adjust. (diff_context::show_added_symbols_unreferenced_by_debug_info): Define this new method. (corpus_diff::priv::emit_diff_stats): Do not show the diff stat if the only changes is added function or variables symbols and if we were instructed to not show added symbols. (corpus_diff::priv::{diff_stats_, filters_and_suppr_applied_}): New data members. (corpus_diff::priv::priv): Initialize the filters_and_suppr_applied_ data member. (corpus_diff::priv::diff_stats): Move this type to corpus_diff::diff_stats. (corpus_diff::priv::{apply_filters_and_compute_diff_stats, emit_diff_stats}): Adjust. (corpus_diff::apply_filters_and_suppressions_before_reporting): Define new member function. (corpus_diff::report): Use the new apply_filters_and_suppressions_before_reporting() function, rather than applying the filters and suppressions by ourselves. Also adjust to the use the accessors of the new corpus_diff::diff_stats type. (corpus_diff::{deleted_variables, deleted_unrefed_function_symbols, deleted_unrefed_variable_symbols}): Define new accessors. (corpus_diff::diff_stats::{diff_stats, num_func_removed, num_func_added, num_func_changed, num_func_filtered_out, net_num_func_changed, num_vars_removed, num_vars_added, num_vars_changed, num_vars_filtered_out, net_num_vars_changed, num_func_sym_removed, num_func_syms_added, num_var_syms_removed, num_var_syms_added}): Define new member functions. * include/abg-corpus.h (corpus::{get_sym_ids_of_fns_to_keep, get_sym_ids_of_vars_to_keep}): Declare new methods. * src/abg-corpus.cc (corpus::priv::{sym_id_fns_to_keep, sym_id_vars_to_keep}): Added data members. (symtab_build_visitor_type::{unrefed_fun_symbols, unrefed_var_symbols, sym_id_fns_to_keep, sym_id_vars_to_keep}): Added new data members. (symtab_build_visitor_type::symtab_build_visitor_type): Take two additional parameters for the function and variable symbol ids to keep. (symtab_build_visitor_type::add_fn_to_wip_fns): Take the function symbols to keep in account when building the exported symbol table. (symtab_build_visitor_type::add_var_to_wip_vars): Likewise, take the variable symbols to keep in account when building the exported symbol table. (corpus::priv::build_public_decl_table): Adjust the initialization of the visitor that walks the ABI artifacts to build the exported symbol table to know take a list of function/variable symbols to keep. (corpus::priv::build_unreferenced_symbols_tables): Ensure that the public table of functions/variables is built before doing the work of this function. Also, if a list of variable/function symbols to keep is given, drop all symbols that are not in that list on the floor. (corpus::{get_sym_ids_of_fns_to_keep, get_sym_ids_of_vars_to_keep}): Define new accessors. * tools/abicompat.cc: New abicompat tool. * doc/manuals/abicompat.rst: New documentation source for abicompat. * doc/manuals/libabigail-tools.rst: Add an entry for the abicompat doc. * tests/test-abicompat.cc: New test harness for the 'abicompat' tool. * tests/Makefile.am: Build the runtestabicompat test harness and add it to the list of tests harnesses that are run by make check. * tests/data/test-abicompat/libtest0-fn-changed-libapp-v0.so: New test input. * tests/data/test-abicompat/libtest0-fn-changed-libapp-v1.so: Likewise. * tests/data/test-abicompat/test0-fn-changed-app: Likewise. * tests/data/test-abicompat/test0-fn-changed-0.suppr: Likewise * tests/data/test-abicompat/test0-fn-changed-report-0.txt: Likewise. * tests/data/test-abicompat/test0-fn-changed-report-1.txt: Likewise. * tests/data/test-abicompat/test0-fn-changed-app.cc: Likewise. * tests/data/test-abicompat/test0-fn-changed-libapp.h: Likewise. * tests/data/test-abicompat/test0-fn-changed-libapp-v0.cc: Likewise. * tests/data/test-abicompat/test0-fn-changed-libapp-v1.cc: Likewise. * tests/data/test-abicompat/libtest1-fn-removed-v0.so: Likewise. * tests/data/test-abicompat/libtest1-fn-removed-v1.so: Likewise. * tests/data/test-abicompat/test1-fn-removed-app: Likewise. * tests/data/test-abicompat/test1-fn-removed-app.cc: Likewise. * tests/data/test-abicompat/test1-fn-removed-report-0.txt: Likewise. * tests/data/test-abicompat/test1-fn-removed-v0.cc: Likewise. * tests/data/test-abicompat/test1-fn-removed-v1.cc: Likewise. * tests/data/test-abicompat/libtest2-var-removed-v0.so: Likewise. * tests/data/test-abicompat/libtest2-var-removed-v1.so: Likewise. * tests/data/test-abicompat/test2-var-removed-app: Likewise. * tests/data/test-abicompat/test2-var-removed-app.cc: Likewise. * tests/data/test-abicompat/test2-var-removed-report-0.txt: Likewise. * tests/data/test-abicompat/test2-var-removed-v0.cc: Likewise. * tests/data/test-abicompat/test2-var-removed-v1.cc: Likewise. * tests/data/test-abicompat/libtest3-fn-removed-v0.so: Likewise. * tests/data/test-abicompat/libtest3-fn-removed-v1.so: Likewise. * tests/data/test-abicompat/test3-fn-removed-app: Likewise. * tests/data/test-abicompat/test3-fn-removed-app.cc: Likewise. * tests/data/test-abicompat/test3-fn-removed-report-0.txt: Likewise. * tests/data/test-abicompat/test3-fn-removed-v0.cc: Likewise. * tests/data/test-abicompat/test3-fn-removed-v1.cc: Likewise. * tests/data/test-abicompat/test3-fn-removed-version-script-0 Likewise.: * tests/data/test-abicompat/test3-fn-removed-version-script-1: Likewise. * tests/data/Makefile.am: Add the new test inputs above to the source distribution. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-11-30 17:18:55 +00:00
$
Add support for abicompat weak mode This patch implements the weak mode of abicompat. In this mode, just the application and the new version of the library are provided. The types of functions and variables of the library that are consumed by the application are compared to the types of the functions and variables expected by the application. The goal is to check if the types of the declarations consumed by the application and provided by the library are compatible with what the application expects. The abicompat first gets the set of symbols undefined in the application and exported by the library. It then builds the set of declarations exported by the library that have those symbols. We call these the set of declarations of the library that are consumed by the application. Note that the debug information for the application does not contain the declarations of the functions/variables whose symbols are undefined. So we can not just read them to compare them to declarations exported by the library. But the *types* of the variables and the *sub-types* of the functions whose symbols are undefined in the application are present in the debug information of the application. So in the weak mode, abicompat compare the *types* of the declarations consumed by the application as expected by the application (described by the debug information of the application) with the types of the declarations exported by the library. To do this a number of changes were necessary. The patch builds a representation of all the types found in the application's debug info. Before that, only the types that are reachable from exported declarations were represented. The abidw tool got a new --load-all-types to test this new ability of loading all types. The patch also adds support for looking a type, not by name, but by its internal representation. In the comparison engine, function_type_diff is introduced to represent changes between two function types. For this, a new class type_or_decl_base has been introduced in the IR. It's now the base class for both decl_base and type_base. And abigail::comparison::diff now takes two pointers of type_or_decl, not decl_base anymore. So function_type_diff can take two function_type now; not that a function_type has no declaration so it doesn't inherit decl_base. A bunch of changes got made just to adjust to this modification. A number of fixes were made too, to make this work, like adding missing comparison operators, removing asserts that too strong, etc.. The patch also adjust the test suite as well as the documentation. * include/abg-fwd.h (class type_or_decl_base): Forward declare this. (is_decl, is_type, is_function_type, get_name, get_type_name) (get_function_type_name, get_pretty_representation) (lookup_function_type_in_corpus, lookup_type_in_translation_unit) (lookup_function_type_in_translation_unit) (synthesize_function_type_from_translation_unit) (hash_type_or_decl): New function declarations. * src/abg-corpus.cc (lookup_type_in_corpus) (lookup_function_type_in_corpus): Define new functions. * include/abg-ir.h (translation_unit::lookup_function_type_in_translation_unit): Declare new friend function. (class type_or_decl_base): Declare this. (operator==(const type_or_decl_base&, const type_or_decl_base&)): Declare new operator. (operator==(const type_or_decl_base_sptr&, const type_or_decl_base_sptr&)): Likewise. (class {decl_base, type_base}): Make these class inherit type_or_decl_base. (decl_base::get_member_scopes): New const overload. (bool operator==(const function_decl::parameter_sptr&, const function_decl::parameter_sptr&)): New operator. (function_type::get_parameters): Remove the non-const overload. (function_type::get_pretty_representation): Declare new member function. (method_type::get_pretty_representation): Likewise. * src/abg-ir.cc (bool operator==(const type_or_decl_base&, const type_or_decl_base&)): Define new equality operator. (bool operator==(const type_or_decl_base_sptr&, const type_or_decl_base_sptr&)): Likewise. (strip_typedef): Do not expect canonicalized types anymore. Now the system accepts (and expects) canonicalized types in certain cases. For instance, non-complete types and aggregated types that contain non-complete sub-types. (get_name, get_function_type_name, get_type_name) (get_pretty_representation, is_decl, is_type, is_function_type) (lookup_function_type_in_translation_unit) (synthesize_function_type_from_translation_unit) (lookup_type_in_scope, lookup_type_in_translation_unit): Define new functions or new overloads. (bool operator==(const function_decl::parameter_sptr&, const function_decl::parameter_sptr& r)): Define new operator. (function_type::get_parameters): Remove non-const overload. (function_type::get_pretty_representation): Define new function. (function_type::traverse): Adjust. (method_type::get_pretty_representation): Likewise. (function_decl::get_pretty_representation): Avoid emitting the type of cdtors. (hash_type_or_decl): Define new function. * include/abg-dwarf-reader.h (create_read_context) (read_corpus_from_elf): Take a new 'read_all_types' flag. * src/abg-dwarf-reader.cc (read_context::load_all_types_): New flag. (read_context::read_context): Initialize it. (read_context::canonical_types_scheduled): If some types still have non-canonicalized sub-types, then do not canonicalize them. (read_context::load_all_types): New member functions. (build_function_decl): Do not represent void return type like empty type anymore, rather, represent it like a void type node. (build_ir_node_from_die): When asked, load all types including those that are not reachable from an exported declaration. (create_read_context, read_corpus_from_elf): Take a new 'load_all_types' flag and honour it. * src/abg-reader.cc (read_context::type_is_from_translation_unit): Support looking up function types in the current translation unit, now that we now how to lookup function types. * include/abg-comparison.h (diff_context::{has_diff_for, add_diff, set_canonical_diff_for, set_or_get_canonical_diff_for, get_canonical_diff_for}): Make these take instances of type_or_decl_base_sptr, instead of decl_base_sptr. (diff::diff): Likewise. (diff::{first_subject, second_subject}): Make these return type_or_decl_base_sptr instead of decl_base_sptr. (type_diff_base::type_diff_base): Make these take instances of type_or_decl_base_sptr instead of decl_base_sptr. (distinct_diff::distinct_diff): Likewise. (distinct_diff::{first, second}): Make these return type_or_decl_base_sptr instead of decl_base_sptr. (distinct_diff::entities_are_of_distinct_kinds): Make these take instances of type_or_decl_base_sptr instead of decl_base_sptr. (class function_type_diff): Create this new type. It's a factorization of the function_decl_diff type. * src/abg-comparison.cc (): * src/abg-comp-filter.cc ({harmless, harmful}_filter::visit): Adjust as diff::{first,second}_subject() now returns a type_or_decl_base_sptr, no more a decl_base_sptr. (decls_type, decls_diff_map_type): Remove these typedefs and replace it with ... (types_or_decls_type, types_or_decls_diff_map_type): ... these. (struct {decls_hash, decls_equals): Remove these type sand replace them with ... (struct {types_or_decls_hash, types_or_decls_equals}): ... these. ({type_suppression, variable_suppression}::suppresses_diff): Adjust. (diff_context::priv::decls_diff_map): Replace this with ... (diff_context::priv::types_or_decls_diff_map): ... this. (diff_context::{has_diff_for, add_diff, get_canonical_diff_for, set_canonical_diff_for, set_or_get_canonical_diff_for}): Take type_or_decl_base_sptr instead of decl_base_sptr. (diff::priv::{first, second}_subject): Make the type of these be type_or_decl_base_sptr, no more decl_base_sptr. (diff::priv::priv): Adjust for the subjects of the diff being of type type_or_decl_sptr now, no more decl_base_sptr. (diff_less_than_functor::operator()(const diff_sptr, const diff_sptr) const): Adjust. (diff::diff): djust for the subjects of the diff being of type type_or_decl_sptr now, no more decl_base_sptr. (diff::{first,second}_subject): Make the type of these be type_or_decl_base_sptr, no more decl_base_sptr. (report_size_and_alignment_changes): Likewise. (type_diff_base::type_diff_base): Make the type of this be type_or_decl_base_sptr instead of type_base_sptr. (distinct_diff::distinct_diff): Make this take instances of type_or_decl_base_sptr instead of decl_base_sptr. (distinct_diff::{first, second, entities_are_of_distinct_kinds}): Likewise. (distinct_diff::has_changes): Simplify logic. (distinct_diff::report): Adjust. (compute_diff_for_types): Add an additional case to support the new function_type. (report_size_and_alignment_changes): Make this take instances of type_or_decl_base_sptr instead of decl_base_sptr. (class_diff::priv::member_type_has_changed): Return an instance of type_or_decl_base_sptr rather than a decl_base_sptr. (class_diff::report): Adjust. (diff_comp::operator()(const diff&, diff&) const): Adjust. (enum function_decl_diff::priv::Flags): Remove. (function_decl_diff::priv::{first_fn_flags_, second_fn_flags_, fn_flags_changes_}): Remove. (function_decl_diff::priv::{fn_is_declared_inline_to_flag, fn_binding_to_flag}): Remove. (function_decl_diff::{deleted_parameter_at, inserted_parameter_at}): Remove. (function_decl_diff::ensure_lookup_tables_populated): Empty this. (function_decl_diff::chain_into_hierarchy): Adjust. (function_decl_diff::function_decl_diff): This now only takes the subjects. It's body is now empty. (function_decl_diff::{return_type_diff, subtype_changed_parms, removed_parms, added_parms, type_diff}): Remove these member functions. (function_decl_diff::type_diff): Define new member function. (function_decl_diff::report): Simplify logic by using the reporting of the child type diff node. (compute_diff): Likewise, in the overload for function_decl_sptr simplify logic by using the child type diff object. (function_type_diff::priv): Define new type. (function_type_diff::{function_type_diff, ensure_lookup_tables_populated, deleted_parameter_at, inserted_parameter_at, finish_diff_type, first_function_type, second_function_type, return_type_diff, subtype_changed_parms, removed_parms, added_parms, get_pretty_representation, has_changes, has_local_changes, report, chain_into_hierarchy}): Define new functions. (compute_diff): Define new overload for function_type_sptr. * tools/abicompat.cc (options::weak_mode): New data member. (options::options): Initialize it. (enum abicompat_status): New enum (abicompat_status operator|(abicompat_status, abicompat_status)) (abicompat_status& operator|=(abicompat_status &, abicompat_status)) (abicompat_status operator&(abicompat_status, abicompat_status)): New operators to manipulate the abicompat_status enum. (display_usage): Add help string for the new --weak-mode option. (parse_command_line): Add the new --weak-mode command line argument. If the tool is called with just the application and one library then assume that we are in the weak mode. (perform_compat_check_in_normal_mode): Define new function, factorized from what was in the main function. (perform_compat_check_in_weak_mode): Define new function. (struct {fn,var}_change): Define new types. (main): Use perform_compat_check_in_weak_mode() and perform_compat_check_in_normal_mode(). * tools/abidiff.cc (main): Adjust. * tools/abidw.cc: (options::load_all_types): Add new data member. (options::options): Initialize it. (display_usage): New help string for --load-all-types. (parse_command_line): Support the new --load-all-types option. (main): Adjust and honour the --load-all-types option. * tools/abilint.cc (main): Adjust. * doc/manuals/abicompat.rst: Update documentation for the new weak mode. Also provide stuff that was missing from the examples provided. * doc/manuals/abidw.rst: Update documentation for the new --load-all-types option. * tests/print-diff-tree.cc (main): Adjust. * tests/test-diff-dwarf.cc (main): Likewise. * tests/test-read-dwarf.cc (main): Likewise. * tests/data/test-abicompat/test0-fn-changed-app: Recompile this. * tests/data/test-abicompat/libtest5-fn-changed-libapp-v{0,1}.so: New new test input binaries * tests/data/test-abicompat/test5-fn-changed-app: Likewise. * tests/data/test-abicompat/test6-var-changed-app: Likewise. * tests/data/test-abicompat/libtest6-var-changed-libapp-v{0,1}.so: Likewise. * tests/data/test-abicompat/test5-fn-changed-report-0.txt: Reference output for one test above. * tests/data/test-abicompat/test6-var-changed-report-0.txt: Likewise. * tests/data/test-abicompat/test5-fn-changed-app.cc: Source file for a binary above. * tests/data/test-abicompat/test5-fn-changed-libapp-v{0,1}.{h,cc}: Likewise. * tests/data/test-abicompat/test6-var-changed-libapp-v{0,1}.{cc,h}: Likewise. * tests/data/test-abicompat/test6-var-changed-app.cc: Likewise. * tests/data/Makefile.am: Add the test related files above to the source distribution. * tests/test-abicompat.cc (in_out_spec): Add the new test input above to the list of inputs to feed to this test harness. (main): Support taking just the app and one library. * tests/data/test-read-dwarf/test{0, 1, 2.so, 3.so, 5.o, 8-qualified-this-pointer.so,}.abi: Adjust for void type being really emitted now, as opposed to just being an empty type. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-04-01 10:13:38 +00:00
* Now use the weak mode of abicompat, that is, providing just the
application and the new version of the library: ::
$ abicompat --weak-mode test-app libtest-1.so
functions defined in library
'libtest-1.so'
have sub-types that are different from what application
'test-app'
expects:
function foo* first_func():
return type changed:
in pointed to type 'struct foo':
size changed from 32 to 64 bits
1 data member insertion:
'char foo::m1', at offset 32 (in bits)
$