mirror of
git://sourceware.org/git/libabigail.git
synced 2024-12-27 04:02:07 +00:00
425f8a4ec4
158 Commits
Author | SHA1 | Message | Date | |
---|---|---|---|---|
Dodji Seketeli
|
425f8a4ec4 |
Detect vtable changes from member function changes
This patch adds vtable changes detection based on the detection of virtual member function changes. That is, when a member function changes, if that member function is virtual, then infer if the change implies changes to the vtable of the containing class. Before that patch, we were doing the vtable change detection when we were comparing two classes; we were then comparing their virtual member functions. But as for a given class all its virtual member functions are not necessarily emitted in the DWARF debug info (only the virtual member functions that are used in a given translation unit are emitted in that translation unit) it's not reliable to compare virtual member functions as part of comparing a given class. We thus decided some patches ago to stop comparing virtual member functions when we compare two classes. So with this patch now, we still detect changes to the vtable and emit an appropriate message to the user. * include/abg-ir.h (class_decl::{has_virtual_base, has_vtable}): Declare new member functions. * src/abg-comp-filter.cc (has_virtual_mem_fn_change): New overload for function_decl_diff. (has_virtual_mem_fn_change): In the overload for diff*, support virtual member function changes detection for function_decl_diff*. * src/abg-comparison.cc (function_decl_diff::report): Detect and report changes to a vtable by looking a changes that can happen to a given member function. (corpus_diff::report): Detect and report changes to vtables by looking at changes change to member functions. * tests/data/test-diff-dwarf/test29-vtable-changes-report-0.txt: New text input. * tests/data/test-diff-dwarf/test29-vtable-changes-v{0,1}.cc: Source code of new test input binaries. * tests/data/test-diff-dwarf/test29-vtable-changes-v{0,1}.o: New test input binaries. * tests/data/test-diff-dwarf/test30-vtable-changes-report-0.txt: New text input. * tests/data/test-diff-dwarf/test30-vtable-changes-v{0,1}.cc: New test input. * tests/data/test-diff-dwarf/test30-vtable-changes-v{0,1}.o: New test input binaries. * tests/data/test-diff-dwarf/test31-vtable-changes-report-0.txt: New test input. * tests/data/test-diff-dwarf/test31-vtable-changes-v{0,1}.cc: Source code of new test input binary. * tests/data/test-diff-dwarf/test31-vtable-changes-v{0,1}.o: New test input binary. * tests/data/Makefile.am: Add the new test input files above to source distribution. * tests/test-diff-dwarf.cc (in_out_specs): Consume the new test inputs above. Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
Dodji Seketeli
|
fbba4bf0ed |
Fix template comparison operators
There are two issues in comparing templates currently. One is that comparing member class template recurses for ever (oops). The other is that the logic of comparing function templates is wrong and leads to false comparisons. * include/abg-ir.h (function_tdecl::operator==): Introduce a new virtual member operator that takes a function_tdecl&. * src/abg-ir.cc (class_decl::member_function_template::operator==): Avoid the static cast in the overload for member_base. In the overload for member_class_template, avoid infinite recursion. (function_tdecl::operator==): In the overload for decl_base, do not do the real work here in the overload for decl_base Rather, the real work is done in the new overload for function_tdecl, and all other overloads call that one. Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
Dodji Seketeli
|
9ab2c3a3fd |
Use size/alignment of class definition when requested on declaration
Sometimes during hashing the "type sub-object" of a class can be queried for its size or alignment. In those case, if the class is a declaration that happens to be accompanied with a definition, its the size/alignment of the definition that we want, not the one of the declaration, that is zero. Otherwise, this can cause spurious hashing changes between two class types that are otherwise equivalent modulo the use of a class declaration. This patch being part of a series that aims at fixing a number of type hashing issues, the regression tests are adjusted at the end of the series, not here. * include/abg-ir.h (type_base::{set_size_in_bits, set_alignment_in_bits}): Make these member functions virtual. (class_decl::{set_size_in_bits, get_size_in_bits, get_alignment_in_bits, set_alignment_in_bits}): Declare these virtual member functions. * src/abg-ir.cc (class_decl::{set_size_in_bits, get_size_in_bits, get_alignment_in_bits, set_alignment_in_bits}): Define these virtual functions. Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
Dodji Seketeli
|
39b2e8b7d5 |
Make decl_base::get_qualified_name() work when decl context changes
decl_base::get_qualified_name() caches its result. So when it's first called on a decl that is not added to a scope, what is returned is a non-qualified name. Which is all right. But then when the decl is later added to a scope, the cached result of decl_base::get_qualified_name() is not longer correct. This patch resets the cache of decl_base::get_qualified_name() when the decl gets added to a new scope. * include/abg-ir.h (class decl_base): Make class scope_decl a friend of decl_base. (type_base::priv_): Make this protected, rather than private. * src/abg-ir.cc (scope_decl::add_member_decl) (scope_decl::insert_member_decl): Reset the cache of the result of decl_base::get_qualified_name(). * tests/data/test-abidiff/test-PR18791-report0.txt: Adjust. Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
Dodji Seketeli
|
636202c833 |
Fix style issues
* include/abg-ir.h (struct ir_node_visitor): Fix the wording of the comment of this type. * src/abg-dwarf-reader.cc (build_ir_node_from_die): Fix the filling of the text of the comment of the code that chooses to perform early canonicalizing. Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
Dodji Seketeli
|
0cf1828a90 |
Fix type synthesis to fix abicompat weak mode
While looking further in the issue Sinny Kumari reported, I realized that the weak mode wasn't working in that example either. It turned out that synthesizing qualified types was not working because we were just looking them up in the binary, rather than looking up the un-qualified underlying type and then synthezing the resulting qualified type. This patch just does that. * include/abg-fwd.h (synthesize_type_from_translation_unit): Declare new function. (synthesize_function_type_from_translation_unit): Make the translation_unit parameter non-const because the function needs to bind the life time of the synthesized function to the life time of the translation unit. Make this function be a friend of abigail::ir::translation_unit. (synthesize_function_type_from_translation_unit): * src/abg-ir.cc (translation_unit::priv::synthesized_types_): New data member. (synthesize_type_from_translation_unit): Define new function. (synthesize_function_type_from_translation_unit): Make the translation_unit parameter non-const. If the return is void, then take that in account carefuly. Rather than just looking up the type of parameters and return value, synthesize them too, especially when they are qualified types. Bind the life time of the synthesized function type to the lifetime of the translation unit. * tests/data/test-abicompat/test7-fn-changed-report-1.txt: New test reference output. * tests/test-abicompat.cc (in_out_spec): Run the harness on the exisiting test7-fn-changed-app and libtest7-fn-changed-libapp-v1 but in weak mode this time. Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
Dodji Seketeli
|
7cae79e0d8 |
On changed fn, show symbol info when name is different from linkage name in C
In change reports for function sub-type changes, for the C language, when the name of the function is different from its linkage name, even when the function symbol has no aliases, show the symbol information of the function. * include/abg-ir.h (translation_unit::language): New enum type. (translation_unit::{get_language, set_language}): Declare new accessors. (translation_unit_language_to_string) (string_to_translation_unit_language, is_c_language) (is_cplus_plus_language): Declare new functions. * src/abg-ir.cc (translation_unit::priv::language_): New data member. (translation_unit::priv::language_): Initialize it. (translation_unit::{set_language, get_language}): Define new member functions. (translation_unit_language_to_string) (string_to_translation_unit_language, is_c_language) (is_cplus_plus_language): Define new functions. * src/abg-dwarf-reader.cc (dwarf_language_to_tu_language): New static function. (build_translation_unit_and_add_to_ir): Read the language of the translation unit. * src/abg-comparison.cc (corpus_diff::report): When reporting a change in a function sub-type, if we are in C language translation unit, if the function name is different from its linkage name, even if the symbol doesn't have any alias, show symbol information. * src/abg-reader.cc (read_translation_unit_from_input): Read the 'language' property of the translation unit, if present. * src/abg-writer.cc (write_translation_unit): Write the 'language' property to the translation unit, if present. * tests/data/test-read-dwarf/test0.abi: Adjust for the new 'language' property of the 'abi-instr' element. * tests/data/test-read-dwarf/test1.abi: Likewise. * tests/data/test-read-dwarf/test2.so.abi: Likewise. * tests/data/test-read-dwarf/test3.so.abi: Likewise. * tests/data/test-read-dwarf/test4.so.abi: Likewise. * tests/data/test-read-dwarf/test5.o.abi: Likewise. * tests/data/test-read-dwarf/test6.so.abi: Likewise. * tests/data/test-read-dwarf/test7.so.abi: Likewise. * tests/data/test-read-dwarf/test8-qualified-this-pointer.so.abi: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
Dodji Seketeli
|
5b09ea77e2 |
Handle the life time of the map of canonical types
While working on something else, it turned out that we need to cleanup (de-allocate) the map of canonical types when all the translation units that own types are de-allocated. Otherwise, when new translation units are created later, the types in the canonical types map become unrelated to the types in these new translation units, leading to memory management issues. This patch introduces a "usage watchdog" which detects when no translation unit uses the type system anymore. That usage watchdog is then used in the destructor of the translation_unit type to de-allocate the global data that is logically owned by by the type system. The patch also changes the API to read translation units and corpora in a way that forces users to get a handle on the resulting shared pointer. * include/abg-ir.h (type_base::canonical_types_map_type): Move this typedef into abg-ir.cc and out of the type_base namespace. (type_base::get_canonical_types_map): Likewise. * src/abg-ir.cc (canonical_types_map_type): New typedef that got moved here from type_base::canonical_types_map_type. (get_canonical_types_map): Likewise got moved here from type_base::get_canonical_types_map. Made static in the process. (class usage_watchdog): New type. (usage_watchdog_sptr, usage_watchdog_wptr): New typedefs. (get_usage_watchdog, get_usage_watchdog_wptr, ref_usage_watchdog) (maybe_cleanup_type_system_data): New static functions. (translation_unit::priv::usage_watchdog_): Add new data member. (translation_unit::priv::priv): Get a reference on the usage watchdog. (translation_unit::priv::~priv): If the usage watchdog says that the type system is not used, then cleanup the global data logically owned by the type system. * include/abg-dwarf-reader.h (read_corpus_from_elf): Make this return a corpus and set the status by reference using a parameter. * src/abg-dwarf-reader.cc (read_corpus_from_elf): Implement the above. * include/abg-reader.h (read_translation_unit_from_file) (read_translation_unit_from_buffer) (read_translation_unit_from_istream): Remove the overloads that do not return a translation_unit_sptr and that pass it as a parameter. Only keep the overloads that return a translation_unit_sptr, forcing users of the API to own a proper reference on the resulting translation_unit pointer. That is important to handle the life time of the global data of the type system that need to be cleared when the last translation unit is de-allocated. * src/abg-reader.cc (read_translation_unit_from_input): Make this return a translation_unit_sptr. (read_translation_unit_from_file) (read_translation_unit_from_buffer) (read_translation_unit_from_istream): Remove the overloads that do not return a translation_unit_sptr and that pass it as a parameter. Only keep the overloads that return a translation_unit_sptr. (read_to_translation_unit): Make this return a translation_unit_sptr. * tests/print-diff-tree.cc (main): Adjust. * tests/test-diff-dwarf.cc (main): Likewise. * tests/test-ir-walker.cc (main): Likewise. * tests/test-read-dwarf.cc (main): Likewise. * tests/test-read-write.cc (main): Likewise. * tools/abicompat.cc (main): Likewise. * tools/abidiff.cc (main): Likewise. * tools/abidw.cc (main): Likewise. * tools/abilint.cc (main): Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
Dodji Seketeli
|
fe9fa7a05f |
Support filtering out just one alias of a function
Suppose a function private_foo() has a symbol private_foo and also a another one (an alias) named public_foo. Then suppose we want to filter out sub-type changes to private_foo(). But then we still want to see changes to public_foo. This patch does add this feature. The [suppress_function] directive now has a new (hidden) boolean 'allow_other_aliases' property. When set to 'yes' or 'true', if the function being looked at has an alias symbol that does *NOT* match the other properties of the directive, then the directive doesn't suppress reports for the function. This new property is set to yes by default. This means that when a function has got multiple aliases, to suppress the function, one needs to write a regular expression that matches the names of aliases. Otherwise the function will not be suppressed. * include/abg-comparison.h (function_suppression::{get, set}_allow_other_aliases): Declare new member functions. * src/abg-comparison.cc (function_suppression::priv::allow_other_aliases_): New data member. (function_suppression::priv::priv): Initialize it to 'true'. (function_suppression::{get, set}_allow_other_aliases): Define new member functions. (read_function_suppression): Parse the new "allow_other_aliases" property. (function_suppression::suppresses_function): Update to evaluate the new 'allow_other_aliases' property when there is a property to match against some a symbol name of the function. (corpus_diff::report): Fix the printing of function aliases when printing sub-type changes to properly emit the plural of the word 'symbol' when the function has several aliases. * include/abg-ir.h (elf_symbol::get_number_of_aliases): Declare new member function. * src/abg-ir.cc (elf_symbol::get_number_of_aliases): Define new member function. * doc/manuals/libabigail-concepts.rst: Update manual. * tests/data/test-diff-dwarf/test5-report.txt: Adjust. * tests/data/test-diff-suppr/libtest23-alias-filter-v0.so: New test input. * tests/data/test-diff-suppr/libtest23-alias-filter-v1.so: Likewise. * tests/data/test-diff-suppr/test23-alias-filter-0.suppr: Likewise. * tests/data/test-diff-suppr/test23-alias-filter-1.suppr: Likewise. * tests/data/test-diff-suppr/test23-alias-filter-2.suppr: Likewise. * tests/data/test-diff-suppr/test23-alias-filter-3.suppr: Likewise. * tests/data/test-diff-suppr/test23-alias-filter-4.suppr: Likewise. * tests/data/test-diff-suppr/test23-alias-filter-report-0.txt: Likewise. * tests/data/test-diff-suppr/test23-alias-filter-report-1.txt: Likewise. * tests/data/test-diff-suppr/test23-alias-filter-report-2.txt: Likewise. * tests/data/test-diff-suppr/test23-alias-filter-report-3.txt: Likewise. * tests/data/test-diff-suppr/test23-alias-filter-report-4.txt: Likewise. * tests/data/test-diff-suppr/test23-alias-filter-report-5.txt: Likewise. * tests/data/test-diff-suppr/test23-alias-filter-v0.c: Likewise. * tests/data/test-diff-suppr/test23-alias-filter-v1.c: Likewise. * tests/data/test-diff-suppr/test23-alias-filter-version-script: Likewise. * tests/data/Makefile.am: Add the new test stuff to source distribution. * tests/test-diff-suppr.cc (in_out_spec): Add the tests inputs above to the list of input to run over. Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
Dodji Seketeli
|
25dc383b40 |
Show aliases of functions with changed sub-types
The report emitted by abidiff now tells the user about the aliases of the current function, when that function has some sub-type changes. * include/abg-ir.h (elf_symbol::get_aliases_id_string): Declare new overload. * src/abg-ir.cc (elf_symbol::get_aliases_id_string): Define new overload. * src/abg-comparison.cc (corpus_diff::report): For functions with sub-type changes report their aliases. Do not do this if the function is a constructor or destructor because these almost always have aliases, at least with GCC and the developer most certainly has not done anything special for that; she would thus be uselessly surprised by that remote implementation detail. * tests/data/test-diff-dwarf/test5-report.txt: Adjust test. Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
Dodji Seketeli
|
9e64891731 |
Do not compare static data members when comparing types
The comparison code was too eager in comparing class types because it
was comparing static data members in the process. This was causing
some spurious false positives about functions or variables sub-type
changes. This patch fixes that by not comparing static data members
when comparing class types.
* include/abg-ir.h (class_decl::get_non_static_data_members):
Declare new data members.
* src/abg-comparison.cc
(class_diff::ensure_lookup_tables_populated): Only look at
non-static data members.
(compute_diff): In the overload for class_decl, only compare
non-static data members.
* src/abg-hash.cc (class_decl:#️⃣:operator()): Do not hash
static data members members hashing a class_decl.
* src/abg-ir.cc (class_decl::priv::data_members_): New data
member.
(class_decl::priv::priv): When initializing data members, store
the non-static data members on the side, in the new
class_decl::priv::non_static_data_members_ data member.
(class_decl::get_non_static_data_members): Define member function.
(class_decl::add_data_member): Store the non-static data members
on the side in class_decl::priv::non_static_data_members_.
(equals): In the overload for class_decl, do not take in account
static data members when running the comparison.
* tests/data/test-diff-dwarf/test7-report.txt: Adjust.
* tests/data/test-diff-filter/test12-report.txt: Adjust.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
|
||
Dodji Seketeli
|
723222568e |
Change the linkage name only when necessary
Up to now the linkage name of a declaration was set to the name of it's underlying symbol. This patch changes that to instead honour what the DW_AT_linkage_name DWARF property says, unless the value of that property is either missing or wrong. * include/abg-ir.h (elf_symbol::get_alias_from_name): Declare new member function. * src/abg-ir.cc (elf_symbol::get_alias_from_name): Define it. * src/abg-dwarf-reader.cc (build_var_decl, build_function_decl): Once the linkage name is supposed to contain the value of the DW_AT_linkage_name attribute, set it the name of the underlying symbol only if value of DW_At_linkage_name is missing or different from the names of all the aliases of the underlying symbol. * tests/data/test-read-dwarf/test2.so.abi: Adjust. Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
Dodji Seketeli
|
41d0ad035f |
Fix symbols comparison
While working on something else, I noticed that the code for handling copying symbols (and their aliases) was broken, and so comparing two symbols which main name were different by which had aliases that were equal was wrongly resulting in the two symbol being different. I think we shouldn't actually copy symbols and their aliases. Once a symbol is allocated, interested code should just manipulate that symbol by address rather than by value an thus do away with the copying. The patch does that, essentially. In the implementation of a symbol, the aliases as well as the main symbol are now weak pointers, rather than naked pointers. Numerous API entry points that were taking containers of elf_symbol (and were copying elf_symbols over) are not taking containers of smart pointers to elf_symbol. Copying of instances of elf_symbol is now thus disabled. As a result many tests that were exercising elf_symbols (with alias) comparison have been updated. As a result, many empty sub-result of PR libabigail/PR17948 are now fixed. * include/abg-ir.h (elf_symbol_wptr): New typedef. (elf_symbol): Make the constructors and assignment operator private. The type can neither be copied nor created with the new operator. (elf_symbol::create): New static member function. (elf_symbol::{get_main_symbol, get_next_alias, add_alias}): Adjust. ( compute_aliases_for_elf_symbol): Likewise. (elf_symbol::operator=): Make this private. (elf_symbol::get_alias_which_equals): Declare new member function. * src/abg-comp-filter.cc (function_name_changed_but_not_symbol): Adjust. * src/abg-comparison.cc (class_diff::ensure_lookup_tables_populated): Adjust. * src/abg-corpus.cc (corpus::priv::build_unreferenced_symbols_tables): Likewise. * include/abg-dwarf-reader.h (lookup_symbol_from_elf) (lookup_public_function_symbol_from_elf): Adjust. * src/abg-dwarf-reader.cc (lookup_symbol_from_sysv_hash_tab) (lookup_symbol_from_gnu_hash_tab, lookup_symbol_from_elf_hash_tab) (lookup_symbol_from_symtab, lookup_symbol_from_elf) (lookup_public_function_symbol_from_elf) (lookup_public_variable_symbol_from_elf): Adjust. (read_context::lookup_elf_symbol_from_index): Likewise. (read_context::lookup_elf_fn_symbol_from_address): Likewise. (read_context::lookup_elf_var_symbol_from_address): Likewise. (read_context::lookup_public_function_symbol_from_elf): Likewise. (read_context::lookup_public_variable_symbol_from_elf): Likewise. (read_context::load_symbol_maps): Likewise. (build_var_decl, build_function_decl): Likewise. * src/abg-ir.cc (elf_symbol::priv::{main_symbol_, next_alias_}): Change the type of these from elf_symbol* to elf_symbol_wptr. (elf_symbol::priv::priv): Adjust. (elf_symbol::{create, get_alias_which_equals}): Define new functions. (textually_equals): Likewise. (elf_symbol::{get_main_symbol, is_main_symbol, get_next_alias, add_alias}): Adjust to return or take elf_symbol_sptr type, rather than a elf_symbol* one. (elf_symbol::{get_aliases_id_string, does_alias}): Adjust. (compute_alias_for_elf_symbol): Likewise. (elf_symbol::operator==): Two symbols A and B are now equal if A has at least one alias that is textually equal to B. (equals): In the overload for function_decls, in the part where we compare the decl_base part of the functions without considering their decl names, we now also omit considering their linkage names, because we compared they symbols before. * tools/abisym.cc (main): Adjust. * tests/data/test-diff-dwarf/test12-report.txt: Adjust. * tests/data/test-diff-dwarf/test12-report.txt: Adjust. * tests/data/test-diff-dwarf/test18-alias-sym-report-0.txt: Adjust. * tests/data/test-diff-dwarf/test8-report.txt: Adjust. * tests/data/test-diff-filter/test10-report.txt: Adjust. * tests/data/test-diff-filter/test13-report.txt: Adjust. * tests/data/test-diff-filter/test2-report.txt: Adjust. * tests/data/test-diff-filter/test20-inline-report-0.txt: Adjust. * tests/data/test-diff-filter/test20-inline-report-1.txt: Adjust. * tests/data/test-diff-filter/test9-report.txt: Adjust. Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
Dodji Seketeli
|
5c08779f5d |
Add debugging function for function parameters
* include/abg-ir.h (function_decl::parameter::get_pretty_representation): Declare new virtual member function. * src/abg-ir.cc (function_decl::parameter::get_pretty_representation): Define it. Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
Dodji Seketeli
|
5852910238 |
Return a reference to smart pointer for the void type node
This is just a small optimization in the passing * src/abg-ir.h (type_decl::get_void_type_decl): Return a reference to the smart pointer initially returned. * src/abg-ir.cc (type_decl::get_void_type_decl): Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
Dodji Seketeli
|
9b4d20db90 |
Bug 18342 - Segmentation fault while comparing functions with variadic parameters
In the IR built from DWARF, a variadic variadic parameter has an empty type. Later during type comparison, comparing an empty (NULL) type with other types proves to be troublesome. This patch handles the issue by creating a new kind of abigail::type_decl type specifically for variadic parameters. This is like what is done for void types. After that it appears that the categorizing sub-system flags a change of variadic type to non-variadic type as redundant if that change appears several times on different functions. We don't want that because it can hide important changes we want to see. The patch fixes that too. * include/abg-fwd.h (is_array_type): New overload for a naked pointer. * include/abg-ir.h (type_decl::get_variadic_parameter_type_decl): Declare new static function. * src/abg-ir.cc (is_array_type): Define new function overload for naked pointers (type_decl::get_variadic_parameter_type_decl): Define new static function. * src/abg-dwarf-reader.cc (build_function_decl): The type of variadic parameter is now a special type_decl. * include/abg-comparison.h (is_diff_of_variadic_parameter_type) (is_diff_of_variadic_parameter): New function declarations. * src/abg-comparison.cc (is_diff_of_variadic_parameter_type) (is_diff_of_variadic_parameter): Define new functions. (compute_diff): Refuse to return a NULL diff for types. Assert that the parameters are non-NULL. (report_size_and_alignment_changes): We are comparing arrays only if the two parameters are arrays. (fn_parm_diff::fn_parm_diff): Refuse that type diff for this diff node is non empty. (fn_parm_diff::report): Strengthen an assert. Cleanup a comment. (redundancy_marking_visitor::visit_begin): Do not mark function type and variadic parms diff nodes as redundant for local changes. * tests/data/test-diff-dwarf/libtest26-added-parms-before-variadic-v{0,1}.so: New test input binaries. * tests/data/test-diff-dwarf/test26-added-parms-before-variadic-report.txt: New test output reference. * tests/data/test-diff-dwarf/test26-added-parms-before-variadic-v{0,1}.c: Source code of the new test input binaries above. * tests/data/Makefile.am: Add the new test stuff to source distribution. * tests/test-diff-dwarf.cc (in_out_specs): Add the new test inputs above to the set of input to run this test harness over. Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
Dodji Seketeli
|
a102a2f032 |
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> |
||
Dodji Seketeli
|
635e5fa6b2 |
Delay non-complete class type resolution up to end of corpus reading
From the DWARF emitted by GCC 4.4.7 for libstdc++ we encountered an
interesting construct.
A non-complete version of std::runtime_error is declared in
libstdc++-v3/src/functexcept.cc and is represented in DWARF as:
[ 37344] class_type
name (strp) "runtime_error"
declaration (flag)
Then a bit later, that *non-complete* class is used as a base class
for a class, *without* being fully defined! This shouldn't happen
but, well, it does:
[ 3b3a1] class_type
specification (ref4) [ 3733e]
byte_size (data1) 16
decl_file (data1) 5
decl_line (data1) 141
containing_type (ref4) [ 3734a]
sibling (ref4) [3b405]
[ 3b3b1] inheritance
type (ref4) [ 37344] <---- here.
The thing is that, later, in another translation unit
(libstdc++-v3/src/stdexcept.cc), that same class is defined fully:
[ 7e9f9] class_type
name (strp) "runtime_error"
declaration (flag)
[...]
[ 80c95] class_type
specification (ref4) [ 7e9f9]
byte_size (data1) 16
decl_file (data1) 4
decl_line (data1) 108
containing_type (ref4) [ 7e9ff]
sibling (ref4) [ 80d2b]
[...] <---------- and the definition goes here.
But then you see that the DIE offset of the "version" of the
runtime_error class that is "defined" libstdc++-v3/src/stdexcept.cc in
is different from the version that is only declared in
libstdc++-v3/src/functexcept.cc. But virtue of the "One Definition
Rule", we can assume that they designate the same type. But still,
runtime_error should have been defined in
libstdc++-v3/src/stdexcept.cc. Anyhow, libabigail needs to be able to
handle this. That is, it needs to wait until the entire ABI corpus is
loaded from DWARF, then lookup the definition of all the non-complete
types we have encountered.
And then only after that non-complete type resolution has taken place,
we can proceed with type canonicalizing, rather than doing it after
the loading of each translation unit like what we were doing
previously.
This is what this patch does.
* include/abg-fwd.h (lookup_type_in_corpus): Declare new function.
* src/abg-corpus.cc (lookup_type_in_corpus): Define new function
here.
* include/abg-ir.h (function_types_type): Declare new typedef.
(translation_unit::get_canonical_function_type): Remove member function.
(translation_unit::bind_function_type_life_time): Declare new
member function.
(classes_type): New typedef.
* src/abg-ir.cc
(translation_unit::priv::canonical_function_types_): Remove data
member.
(translation_unit::priv::function_types): New data member.
(translation_unit::get_canonical_function_type): Remove this
function definition.
(translation_unit::bind_function_type_life_time): New function
definition.
(lookup_node_in_scope): Ensure that the type returned is
complete.
* src/abg-dwarf-reader.cc (string_classes_map): New typedef.
(read_context::decl_only_classes_map_): New data member.
(read_context::declaration_only_classes): New accessor.
(read_context::{maybe_schedule_declaration_only_class_for_resolution,
is_decl_only_class_scheduled_for_resolution,
resolve_declaration_only_classes, current_elf_file_is_executable,
current_elf_file_is_dso}): Define new member functions.
(read_context::clear_per_translation_unit_data): Do not clear the
data structures that associate DIEs to decls/types or that contain
the types to canonicalize here. Rather, clear them ...
(read_context::clear_per_corpus_data): ... here instead.
(read_context::build_translation_unit_and_add_to_ir): Do not
perform late type canonicalizing here. Rather, do it ...
(read_debug_info_into_corpus): ... here instead. And before that,
call read_context::clear_per_corpus_data() and the new
read_context::resolve_declaration_only_classes() here.
(build_class_type_and_add_to_ir): Schedule the non-complete types
for resolution to complete types. Assert that base classes that
are non-complete are scheduled to be completed.
(build_function_decl): Do not try to canonicalize function types
this early, systematically. Now, all the non-complete types needs
to be completed before starting canonicalizing. So let function
types go through the normal processes of deciding when to
canonicalize them. But then, bind the life time of the function
type to the life time of the current translation unit.
(maybe_canonicalize_type): If a class type is non-complete,
schedule it for late canonicalizing.
* src/abg-hash.cc (class_decl:#️⃣:operator()(const class_decl&)
const): During hashing, a base class should be complete.
* src/abg-reader.cc
(read_context::clear_per_translation_unit_data): Do not clear
id/xml node, and type maps here. Rather, clear it ...
(read_context::clear_per_corpus_data): ... here instead.
(read_translation_unit_from_input): Do not perform late
canonicalizing here. Rather, do it ...
(read_corpus_from_input): ... here. Also, call the new
read_context::clear_per_corpus_data() here.
(build_function_decl): Do not canonicalize function types here so
early. Rather, bind the life time of the function type to the
life time of the translation unit.
* src/abg-writer.cc (write_translation_unit): Do not clear the
type/ID map here.
* tests/data/test-read-dwarf/test2.so.abi: Adjust test input.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
|
||
Dodji Seketeli
|
de8dec2016 |
From inside the comparison engine re-use IR's equality operators
From inside the comparison engine, I noticed that there were some discrepancies between some comparison performed there and the comparison performed from inside the internal representation of abigail::ir. This can lead to some change reports in which the reporter thinks there are changes in the IR where there actually are not. This patch re-uses comparison operators from the generic IR, rather than re-implementing them in the comparison engine. * include/abg-ir.h (operator==(scope_decl_sptr, scope_decl_sptr)): Declare. (operator==(type_decl_sptr, type_decl_sptr)): Likewise. (operator==(enum_type_decl_sptr, enum_type_decl_sptr)): Likewise. * src/abg-comparison.cc (diff_length_of_decl_bases) (diff_length_of_type_bases): Remove these static functions. (class_diff::has_changes): Re-use the comparison operator for class_decl_sptr. (type_decl_diff::has_changes): Re-use the comparison operator for type_decl_sptr. * src/abg-ir.cc (operator==(scope_decl_sptr, scope_decl_sptr)): Define. (operator==(type_decl_sptr, type_decl_sptr)): Likewise. (operator==(enum_type_decl_sptr, enum_type_decl_sptr)): Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
Dodji Seketeli
|
915042e207 |
Pass a bunch of smart pointers by reference
Some smart pointers handling got high on performance profiles. I am passing those by reference here. * include/abg-fwd.h (get_member_is_static, is_member_function) (get_member_function_is_ctor, set_member_function_is_ctor) (get_member_function_is_dtor, set_member_function_is_dtor) (get_member_function_is_const, set_member_function_is_const) (get_member_function_vtable_offset) (set_member_function_vtable_offset) (get_member_function_is_virtual): Declare the smart pointer parameter of these as being passed by reference. * include/abg-ir.h (get_member_access_specifier) (get_member_is_static, get_member_access_specifier) (set_member_function_is_ctor, set_member_function_is_const) (set_member_function_vtable_offset): Likewise, for these friend declarations to the decl_base type. * src/abg-ir.cc (get_member_access_specifier) (get_member_is_static, is_member_function) (get_member_function_is_ctor, set_member_function_is_ctor) (get_member_function_is_dtor, set_member_function_is_dtor) (get_member_function_is_const, set_member_function_is_const) (get_member_function_vtable_offset) (set_member_function_vtable_offset) (get_member_function_is_virtual): In these definitions, the smart pointer parameter is passed by reference. Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
Dodji Seketeli
|
ffeb36eeda |
Make decl_base::get_context_rel() return a naked pointer
Accessing the context relationship of declarations and setting some member properties appear to be high in performance profiles due to shared pointer handling. This patch makes the context relationship accessors return a naked pointer and also passes a bunch of shared pointer as references around. * include/abg-fwd.h (set_member_is_static): Add an overload that takes the member as a reference to a smart pointer. (set_member_function_{is_dtor, is_ctor, is_const, vtable_offset, is_virtual}): Pass the member function as a reference. (set_member_function_is_const, set_member_function_is_virtual): Pass the member function as a non-const reference. * include/abg-ir.h (decl_base::get_context_rel): Return a naked pointer. (set_member_is_static, set_member_function_is_virtual): Adjust this friend declaration. (set_member_access_specifier): Add an overload that takes a reference to the member. Pass a reference to smart pointer to the other overload. (set_member_function_is_{is_ctor,is_dtor,is_const,is_virtual,vtable_offset}): Take a non-const reference to function_decl. * src/abg-ir.cc (decl_base::get_context_rel): Likewise. (equals(const decl_base&, const decl_base&, change_kind*)): Adjust. (equals(const var_decl&, const var_decl&, change_kind*)): Likewise. (get_member_access_specifier, get_member_is_static) (set_data_member_offset, get_data_member_offset) (set_data_member_is_laid_out, get_data_member_is_laid_out) (get_member_function_is_ctor, set_member_function_is_ctor) (get_member_function_is_dtor, set_member_function_is_dtor) (get_member_function_is_const, set_member_function_is_const) (get_member_function_vtable_offset) (set_member_function_vtable_offset) (get_member_function_is_virtual, set_member_function_is_virtual): Likewise. (set_member_access_specifier): Add an overload that takes a reference to decl_base. (set_member_is_static, set_member_function_{is_dtor, is_ctor, is_const, vtable_offset, is_virtual}): Pass the member function as a reference.): Add an overload that takes the member as a reference, and write the older overload in terms of the new one. Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
Dodji Seketeli
|
d79e9803f4 |
Make overloads of decl_base::get_qualified_name() return a reference
* incude/abg-ir.h (decl::get_{qualified_name, qualified_parent_name}): Return a reference to a string rather than a copy of a string. (qualified_type_def::get_qualified_name): Likewise. (reference_type_def::get_qualified_name): Likewise. (array_type_def::get_qualified_name): Likewise. (class enum_type_decl::enumerator): Make this is an out-of-line pimpled class implementation. (enum_type_decl::enumerator::{get, set}_enum_type): Declare new method. (enum_type_decl::enumerator::get_qualified_name): Change this so that it doesn't take the name of the enum type anymore. * src/abg-comparison.cc (enum_diff::report): Adjust for enum_type_decl::enumerator::get_qualified_name() not taking the name of the enum type anymore. * src/abg-ir.cc (decl_base::get_qualified_parent_name): Return a reference to string. (decl_base::get_qualified_name): Likewise. (decl_base::get_qualified_name(string&)): Use the new verson of decl_base::get_qualified_name() that returns a reference. ({qualified_type_def, pointer_type_def, reference_type_def, array_type_def}::get_qualified_name()): Return a string reference. ({qualified_type_def, pointer_type_def, reference_type_def, array_type_def}::get_qualified_name(string& qualified_name) const): Use the new qualified_type_def::get_qualified_name() that returns a string reference. (class enum_type_decl::priv): New type. (enum_type_decl::{get_underlying_type, get_enumerators}): Adjust. (enum_type_decl::{enumerator::enumerator, enumerator::operator==, enumerator::get_name, enumerator::get_qualified_name, enumerator::set_name, enumerator::get_value, enumerator::set_value, enumerator::get_enum_type, enumerator::set_enum_type}): Define methodes out-of-line here. Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
Dodji Seketeli
|
dc2f054d03 |
Build the set of exported decls directly during DWARF loading
Until now, after the ABI corpus was built from DWARF, the translation units of the corpus were walked and each function was considered for addition into the set of exported decls. During that walking, a first version of the set was put into a std::list and then, a set of filters (user-provided tunables like a list of regular expressions to keep or remove some functions from the exported decls) is applied to that list and the final set of exported decls is put in a std::vector. Profiling has shown that this process of building the set of exported decls is a hot spot and also that the current use of std::list was a big memory consumer especially on binaries with large exported symbol tables. So this patch builds the set of exported decls "on the fly", during DWARF reading, as opposed to waiting after the DWARF is read and having to walk the corpus again. The corpus defines a policy object that encapsulates the methods for determining if a function or variable ought to be part of the set of exported decls. The DWARF reader uses that policy object to determine which functions and variables among those built during the reading ought be part of the exported decls; the policy object also has a reference to the final vector (managed by the corpus) that must hold the exported decls, so the decls are put in that vector directly without unnecessary copying. Profiling also showed that the string copying done by {var_decl,function_decl}::get_id() was a hot spot. So the patch returns a reference there. With this patch applied, the peak memory consumption of abidiff on libabigail.so itself (abidiff libabigail.so libabigail.so) is 54MB of resident and takes 2 minutes and 16s (on my slow system). Without the patch the peak consumption was more than 300MB and it was taking slightly longer. For the test of bug https://sourceware.org/bugzilla/show_bug.cgi?id=17948, memory consumtion and wall clock time spent is down from 3.4GB and 1m59s to 760MB and 0m43s. * include/abg-ir.h ({var,function}_decl::get_id): Return a reference. * src/abg-ir.cc ({var,function}_decl::get_id): Return a reference to the string rather than copying it over. * include/abg-corpus.h (class corpus::exported_decls_builder): Declare new type. (corpus::{sort_functions, sort_variables, maybe_drop_some_exported_decls, get_exported_decls_builder}): Declare new methods. * src/abg-corpus.h (corpus::exported_decls_builder::priv): Define new type. (class symtab_build_visitor_type): Remove this type that is useless now. (corpus::exported_decls_builder::{exported_decls_builder, exported_functions, exported_variables, maybe_add_fn_to_exported_fns, maybe_add_var_to_exported_vars}): Define new functions. (corpus::priv::is_public_decl_table_built): Remove this data member. It's now useless. (corpus::priv::priv): Adjust. (corpus::priv::build_public_decl_table): Remove this member function. It's now useless. (corpus::{priv::build_unreferenced_symbols_tables, get_functions, get_variables}): No need to build the public decls table here. It's already built by the time the corpus is read from DWARF now. (corpus::{sort_functions, sort_variables, maybe_drop_some_exported_decls, get_exported_decls_builder}): Define new member functions. * src/abg-dwarf-reader.cc (read_context::exported_decls_builder): New data member. (read_context::read_context): Initialize it. (read_context::{exported_decls_builder, maybe_add_fn_to_exported_fns, maybe_add_var_to_exported_vars}): Define new member functions. (read_debug_info_into_corpus): Get the the new 'exported_decls_builder' object from the corpus and stick it into the read context so the DWARF reading code can use it to build the exported decls set. When the DWARF reading is done, sort the set of exported functions and variables that was built. (build_ir_node_from_die): When a function or variable is built, consider putting it into the set of exported decls. * tools/abicompat.cc (main): Now that the exported decls is built *before* we had a chance to stick the list of symbol IDs to keep, call corpus::maybe_drop_some_exported_decls() to update the set of exported decls we should consider for the corpus. was applied to that list and the final Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
Dodji Seketeli
|
cc3f6a86a7 |
Make strip_typedef() act on canonical types only
strip_typedef(), when constructing new pointers, references and other composite types was building new types that weakly referred to their sub-types; for instance, a pointer type has a weak reference on its pointed-type. That means the referred-to type must be 'own' by something else. That means that strip_typedef() needs to create types which lifetime is "long enough". This patch ensures that strip_typedef() returns a canonical type; and we are sure that a canonical type is live during the entire life time of the libabigail library itself. So that means strip_typedef can only be used after types have been canonicalized. To that end, this patch changes is_class_type() to make it not strip typedefs. That way, is_class_type() can be used even when canonicalized types are not yet available. The patch then introduces a new is_compatible_with_class_type() function that strips typedef. The code of type_size_changed() that wanted to strip typedefs is then adjusted to use this new is_compatible_with_class_type() instead. * include/abg-fwd.h (is_compatible_with_class_type): Declare new function. (canonicalize): Move the declaration here, from ... * include/abg-ir.h (canonicalize): ... here. * src/abg-ir.cc (strip_typedef): Assert that the input type is canonicalized. Make sure that weak references are on canonicalized types. Make sure that the returned type is a canonical one. (canonicalize): Make this return the canonical type that it has computed. * src/abg-comp-filter.cc (type_size_changed): Use the new is_compatible_with_class_type() function, instead of is_class_type(). Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
Dodji Seketeli
|
8b28d171c3 |
Canonicalize types either early or late after TU reading
While trying to diff two identical files (abidiff foo.so foo.so) it appeared that canonicalizing types during e.g, the DWARF reading process was leading to subtle errors because it's extremely hard to know when a type is complete. That is, during the building of a class type C, a pointer to C can be built before C is complete. Worse, even after reading the DIE (from DWARF) of class C, there can be DIE seen later in the translation unit that modifies type C. In these late cases, one needs to wait -- not only until C is fully built, but also sometimes, after the translation unit is fully built -- to canonicalize C and then the pointer to C. This kind of things. So now there are two possible points in time when canonicalization of a type can happen. It can happen early, when the type is built. This is the case for basic types and composite types for which all sub-types are canonicalized already. It can happen late, right after we've finished reading the debug info for the current translation unit. So this patch fixes the IR traversal and uses that to walk the translation unit (or even types) after it's built. It does away with the first attempt to perform early canonicalizing only. The patch also handles type canonicalizing while reading xml-abi format. * include/abg-fwd.h (is_class_type) (type_has_non_canonicalized_subtype): Declare new functions. (is_member_type): Remove the overload that takes a decl_base_sptr. It's superfluous. We just need the one that takes a type_base_sptr. * include/abg-ir.h (translation_unit::{is_constructed, set_is_constructed}): Add new methods. (class_decl::has_virtual_member_functions): Likewise. (class decl_base): Makes it virtually inherit ir_traversable_base. (class type_base): Make this virtually inherit traversable_base too. (type_base::canonicalize): Renamed enable_canonical_equality into this. (type_base::traverse): Declare new virtual method. (canonicalize): Renamed enable_canonical_equality into this. (scope_type_decl::traverse): Declare new virtual method. (namespace_decl::get_pretty_representation): Declare new virtual method. (function_type::traverse): Likewise. (class_decl::base_spec::traverse): Likewise. (ir_node_visitor::visit): Remove the overloads and replace each of them with a pair of ... (ir_node_visitor::{visit_begin, visit_end}): ... of these. * include/abg-traverse.h (traversable_base::visiting): New method. (traversable_base::visiting_): New data member. (traversable_base::traversable_base): New constructor. * src/abg-ir.cc ({scope_decl, type_decl, namespace_decl, qualified_type_def, pointer_type_def, reference_type_def, array_type_def, enum_type_decl, typedef_decl, var_decl, function_decl, function_decl::parameter, class_decl, class_decl::member_function_template, class_decl::member_class_template, function_tdecl, class_tdecl}::traverse): Fix this to properly set the traversable_base::visiting_ flag and to reflect the new signatures of the ir_node_visitor methods. ({type_base, scope_type_decl, function_type, class_decl::base_spec}::traverse): New method. (type_base::get_canonical_type_for): Handle the case of the type already having a canonical type. Properly hash the type using the dynamic type hasher. Look through declaration-only classes to consider the definition of the class instead. Fix logic to have a single pointer of return, to ease debugging. (canonicalize): Renamed enable_canonical_equality into this. (namespace_decl::get_pretty_representation): Define new method. (ir_node_visitor::visit): Replace each of these overloads with a pair of visit_begin/visit_end ones. (translation_unit::priv::is_constructed_): New data member. (translation_unit::priv::priv): Initialize it. (translation_unit::{is_constructed, set_is_constructed}): Define new methods. (is_member_type(const decl_base_sptr)): Remove. (is_class_type(decl_base *d)): Define new function. (class_decl::has_virtual_member_functions): Define new method. (equals(const class_decl&, const class_decl&, change_kind*)): If the containing translation unit is not constructed yet, do not take virtual member functions in account when comparing the classes. This is because when reading from DWARF, there can be DIEs that change the number of virtual member functions after the DIE of the class. So one needs to start taking virtual members into account only after the translation unit has been constructed. (class non_canonicalized_subtype_detector): Define new type. (type_has_non_canonicalized_subtype): Define new function. * src/abg-corpus.cc (symtab_build_visitor_type::visit): Renamed this into symtab_build_visitor_type::visit_end. * src/abg-dwarf-reader.cc (die_type_map_type): New typedef. (die_class_map_type): This is now a typedef on a map of Dwarf_Off/class_decl_sptr. (read_context::{die_type_map_, alternate_die_type_map_, types_to_canonicalize_, alt_types_to_canonicalize_}): New data members. (read_context::{associate_die_to_decl, associate_die_to_decl_primary}): Make these methods public. (read_context::{associate_die_to_type, lookup_type_from_die_offset, is_wip_class_die_offset, types_to_canonicalize, schedule_type_for_canonicalization}): Define new methods. (build_type_decl, build_enum_type) (build_class_type_and_add_to_ir, build_qualified_type) (build_pointer_type_def, build_reference_type, build_array_type) (build_typedef_type, build_function_decl): Do not canonicalize types here. (maybe_canonicalize_type): Define new function. (build_ir_node_from_die): Take a new flag that says if the ir node is a member type/function or not. Early-canonicalize base types. Canonicalize composite types that have only canonicalized sub-types. Schedule the other types for late canonicalizing. For class types, early canonicalize those that are non-member types, that are fully constructed and that have only canonicalized sub-types. Adjust to the new signature of build_ir_node_from_die. (get_scope_for_die, build_namespace_decl_and_add_to_ir) (build_qualified_type, build_pointer_type_def) (build_reference_type, build_array_type, build_typedef_type) (build_var_decl, build_function_decl): Adjust for the new signature of build_ir_node_from_die. (build_translation_unit_and_add_to_ir): Likewise. Perform the late canonicalizing of the types that have been scheduled for that. (build_class_type_and_add_to_ir): Return a class_decl_sptr, not a decl_base_sptr. Adjust for the new signature of build_ir_node_from_die. Early canonicalize member types that are created and added to a given class, or schedule them for late canonicalizing. * src/abg-reader.cc (class read_context::{m_wip_classes_map, m_types_to_canonicalize}): New data members. (read_context::{clear_types_to_canonicalize, clear_wip_classes_map, mark_class_as_wip, unmark_class_as_wip, is_wip_class, maybe_canonicalize_type, schedule_type_for_late_canonicalizing, perform_late_type_canonicalizing}): Add new method definitions. (read_context::clear_per_translation_unit_data): Call read_context::clear_types_to_canonicalize(). (read_translation_unit_from_input): Call read_context::perform_late_type_canonicalizing() at the end of the function. (build_function_decl): Fix the function type canonicalizing (per translation) that was already in place. Do the canonicalizing of these only when the type is fully built. Oops. This was really brokend. Also, when the function type is constructed, consider it for type canonicalizing. (build_type_decl): Early canonicalize basic types. (build_qualified_type_decl, build_pointer_type_def) (build_pointer_type_def, build_reference_type_def) (build_array_type_def, build_enum_type_decl, build_typedef_decl): Handle the canonicalizing for these composite types: either early or late. (build_class_decl): Likewise. Also, mark this class a 'being built' until it's fully built. This helps the canonicalizing code to know that it should leave a class alone until it's fully built. * tests/test-ir-walker.cc (struct name_printing_visitor): Adjust to the visitor methods naming change. * configure.ac: Generate the tests/runtestcanonicalizetypes.sh testing script from tests/runtestcanonicalizetypes.sh.in. * tests/runtestcanonicalizetypes.sh.in: Add the template for the new runtestcanonicalizetypes.sh script that test for type canonicalizing. * tests/Makefile.am: Add the new runtestcanonicalizetypes.sh regression testing script to the build system. Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
Dodji Seketeli
|
d1d4965ee1 |
Misc style fixes
* include/abg-ir.h (reference_type_def::get_pointed_to_type): use type_base_sptr, rather than shared_ptr<type_base> (typdef_decl::get_underlying_type): Likewise. (function_decl::get_return_type): Likewise. (function_decl::set_type): Likewise. (class_decl::member_class_template::as_class_tdecl): Likewise. * src/abg-comparison.cc (compute_diff): Remove useless vertical space. (corpus_diff::traverse): Add a vertical space after this. * src/abg-dwarf-reader.cc (type_ptr_map): Remove this unused typedef. (get_version_for_symbol) (finish_member_function_reading): Fix the comments of these functions. * src/abg-reader.cc (build_function_decl): Return a function_decl_sptr rather than a shared_ptr<function_decl>. (build_qualified_type_decl) (build_pointer_type_def, build_reference_type_def) (build_array_type_def, build_typedef_decl, build_class_decl): Use the is_<someking_of_type> functions here, rather than using the dynamic cast. This increases maintainability. Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
Dodji Seketeli
|
8fbd4f93ba |
Initial implementation of canonical type comparison in the IR
Comparing types that are equal showed up high in profiles. This patch
is an answer to that. It implements the notion of canonical type for
types known to libabigail. Then when comparing two types, if they
have a canonical types, just comparing the pointer value of their
canonical type is enough. This speeds up type comparison somewhat;
comparing the Xorg binaries from rhel 6 and 7 goes from more than 20h
(I gave up after that) to under 15 minutes.
* include/abg-ir.h (class type_base): Pimplify this class.
(type_base::canonical_types_map_type): New typedef.
(type_base::{get_canonical_types_map, get_canonical_type_for,
get_canonical_type}): Declare new member functions.
(enable_canonical_equality): Declare new function.
(struct type_base::hash): Declare this functor here.
* src/abg-ir.cc ():
* src/abg-dwarf-reader.cc (build_type_decl, build_enum_type)
(build_class_type_and_add_to_ir, build_qualified_type)
(build_pointer_type_def, build_reference_type, build_array_type)
(build_typedef_type, build_function_decl): Enable canonical
equality for the resulting type returned by these functions.
* src/abg-hash.cc (type_base:#️⃣:operator()(const type_base&)):
Adjust as this is now out-of-line. Also, add two overloads for
type_base* and type_base_sptr.
(struct type_base::priv): Define new type for private data of
type_base.
(type_base::{get_canonical_types_map, get_canonical_type_for,
get_canonical_type}): Define new member functions.
(enable_canonical_equality): Define new function
(type_base::{type_base, set_size_in_bits, get_size_in_bits,
set_alignment_in_bits, get_alignment_in_bits}): Adjust.
({type_decl, scope_type_decl, qualified_type_def,
pointer_type_def, reference_type_def, array_type_def,
enum_type_decl, typedef_decl, function_type,
class_decl}::operator==): If the types being compared have
canonical type then use them for comparison.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
|
||
Dodji Seketeli
|
34b94a06da |
Get out as early as possible when comparing different ABI artefacts
When the the of 'equals' overloaded functions was introduced, it was to get the possibility to have a hint about the kind of difference (local or sub-type difference) there was between two different ABI artifacts. To do that, it was quite common to keep on comparing the two artifacts even when we knew there were different, because we need to know all the kinds of the differences there are. Now, profiling shows that doing this generally is too costly. So, this patch adds a way to doing it only when necessary. * include/abg-ir.h (equal): Turn the last parameter of type change_kind& into a change_kind*. Do this on all the overloads' declarations. * src/abg-ir.cc (equal): Do the same for the definitions of the overloads and adapt them to report about the kind of changes makes the two ABI artifact different -- only if the change_kind pointer is non-null. That way, callers have a way to choose if they want to go the expensive route of knowing what kind of changes there are. ({decl_base, scope_decl, type_base, scope_type_decl, qualified_type_def, pointer_type_def, pointer_type_def, reference_type_def, array_type_def, enum_type_decl, typedef_decl, var_decl, function_type, function_decl, function_decl::parameter, class_decl::base_spec, class_decl}::operator==): Adjust to the new signature of equals; call it with the change_kind* parameter set to NULL. * src/abg-comparison.cc ({var_diff, pointer_diff, array_diff, reference_diff, qualified_type_diff, enum_diff, class_diff, base_diff, scope_diff, fn_parm_diff, function_decl_diff, type_decl_diff, typedef_diff}::has_local_changes): Adjust. Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
Dodji Seketeli
|
19013fd110 |
Sort functions & variables diff nodes in the diff tree
Since the work on un-sharing diff tree nodes, it looks like some reports of regression tests on i686 order functions and variables in different orders, leading to test failures on 32 bits platforms because they are different fromthe 64 bits platforms that we use as a reference. This patch sorts (lexicographically) the children diff nodes of a given diff node in general, and also sorts the set of diff nodes for functions and variables that have sub-type changes, in a given corpus_diff. That way, the result of the diff report should be sorted the same way, whatever the platform. * include/abg-comparison.h (function_decl_diff_sptrs_type) (var_diff_sptrs_type): New typedefs. (corpus_diff::{changed_functions, changed_variables}): Declare new methods. * src/abg-comparison.cc (sort_string_function_decl_diff_sptr_map) (sort_string_var_diff_sptr_map): Forward declare these static functions there were already defined later. (struct diff_less_than_functor): Define new comparison functor. (diff::append_child_node): Sort the children diff nodes of a given diff node. (corpus_diff::priv::changed_fns_map_): Renamed the data member corpus_diff::priv::changed_fns_ into this. (corpus_diff::priv::changed_fns_): New data member that is a sorted vector of changed functions. (corpus_diff::priv::{lookup_tables_empty, clear_lookup_tables}): Adjust changed_fns_ -> changed_fns_map_ and changed_vars_ -> changed_vars_map_. (corpus_diff::priv::ensure_lookup_tables_populated): Likewise. Sort the changed functions and changed variables. (corpus_diff::priv::apply_filters_and_compute_diff_stats): Adjust changed_fns_ -> changed_fns_map_ and changed_vars_ -> changed_vars_map_. Also, walk the changed functions and variables diff nodes in their sorted order. (corpus_diff::priv::{categorize_redundant_changed_sub_nodes, clear_redundancy_categorization, maybe_dump_diff_tree}): Walk the changed functions and variables diff nodes in their sorted order. * include/abg-ir.h (function_decl::get_pretty_representation_of_declarator): Declarenew method. * src/abg-ir.cc (function_decl::get_pretty_representation_of_declarator): Define new function. Its content got split out of ... (function_decl::get_pretty_representation): ... this one. * src/abg-comparison.cc (corpus_diff::chain_into_hierarchy): Consider the sorted the children nodes of a diff tree node. (corpus_diff::append_child_node): Keep the children nodes of a diff tree node sorted. (corpus_diff::{changed_functions, changed_variables, length, report}): Adjust. (corpus_diff::{changed_functions_sorted, changed_variables_sorted}): Define new functions. (function_comp::operator()): First compare the qualified function names along with the parameter declarations, then the rest. (sort_string_function_decl_diff_sptr_map) (sort_string_var_diff_sptr_map): Adjust. * tests/data/test-abicompat/test0-fn-changed-report-0.txt: Adjust. * tests/data/test-diff-suppr/test5-fn-suppr-report-0.txt: Adjust. * tests/data/test-diff-suppr/test8-redundant-fn-report-0.txt: Adjust. Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
Dodji Seketeli
|
76837d1cbf |
Update copyright years
* include/abg-comp-filter.h: Update copyright years. * include/abg-comparison.h: Likewise. * include/abg-config.h: Likewise. * include/abg-corpus.h: Likewise. * include/abg-diff-utils.h: Likewise. * include/abg-dwarf-reader.h: Likewise. * include/abg-fwd.h: Likewise. * include/abg-hash.h: Likewise. * include/abg-ini.h: Likewise. * include/abg-ir.h: Likewise. * include/abg-libxml-utils.h: Likewise. * include/abg-libzip-utils.h: Likewise. * include/abg-reader.h: Likewise. * include/abg-sptr-utils.h: Likewise. * include/abg-traverse.h: Likewise. * include/abg-viz-common.h: Likewise. * include/abg-viz-dot.h: Likewise. * include/abg-viz-svg.h: Likewise. * include/abg-writer.h: Likewise. * src/abg-comp-filter.cc: Likewise. * src/abg-comparison.cc: Likewise. * src/abg-config.cc: Likewise. * src/abg-corpus.cc: Likewise. * src/abg-diff-utils.cc: Likewise. * src/abg-dwarf-reader.cc: Likewise. * src/abg-hash.cc: Likewise. * src/abg-ini.cc: Likewise. * src/abg-ir.cc: Likewise. * src/abg-libxml-utils.cc: Likewise. * src/abg-libzip-utils.cc: Likewise. * src/abg-reader.cc: Likewise. * src/abg-traverse.cc: Likewise. * src/abg-viz-common.cc: Likewise. * src/abg-viz-dot.cc: Likewise. * src/abg-viz-svg.cc: Likewise. * src/abg-writer.cc: Likewise. * tests/print-diff-tree.cc: Likewise. * tests/test-abidiff.cc: Likewise. * tests/test-alt-dwarf-file.cc: Likewise. * tests/test-core-diff.cc: Likewise. * tests/test-diff-dwarf.cc: Likewise. * tests/test-diff-filter.cc: Likewise. * tests/test-diff-suppr.cc: Likewise. * tests/test-diff2.cc: Likewise. * tests/test-ir-walker.cc: Likewise. * tests/test-lookup-syms.cc: Likewise. * tests/test-read-dwarf.cc: Likewise. * tests/test-read-write.cc: Likewise. * tests/test-utils.cc: Likewise. * tests/test-utils.h: Likewise. * tests/test-write-read-archive.cc: Likewise. * tools/abg-tools-utils.cc: Likewise. * tools/abg-tools-utils.h: Likewise. * tools/abiar.cc: Likewise. * tools/abidiff.cc: Likewise. * tools/abidw.cc: Likewise. * tools/abilint.cc: Likewise. * tools/abisym.cc: Likewise. * tools/binilint.cc: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
Dodji Seketeli
|
817aa5555e |
Un-share diff nodes in the comparison IR
Until now, the diff nodes of the comparison IR were shared. That is,
two diffs about the same subjects were represented by the same diff
node that would appear twice in the tree.
This was preventing us from spotting e.g, the first occurrence of a
diff node that would later (in the tree) turn to be redundant because
all redundant diff nodes are represented by the same diff node
pointer.
This patch now makes each diff node be different, as far of pointer
comparison is concerned. But it introduces the concept of canonical
diff node to ease the comparison between two diff nodes. Two diff
nodes that are equal have the same canonical diff node.
With this facility, it's now possible to tell the difference between
diff nodes that are (structurally) equal. It's not possible to say
things like "this is the first or second occurrence of the redundant
diff node foo'.
* include/abg-ir.h: Prefix the doc string with "///", rather than
writing it inside a /**/ comment.
* include/abg-comparison.h (function_decl_diff)
(function_decl_diff_sptr, fn_parm_diff, fn_parm_diff_sptr)
(var_diff_sptr, base_diff, class_diff, class_diff_sptr): Move
these class & typedef decls to the top of the file.
(string_changed_base_map, string_changed_parm_map)
(unsigned_changed_parm_map, changed_function_ptr)
(string_changed_function_ptr_map): Remove these typedefs.
(string_base_diff_sptr_map, string_fn_parm_diff_sptr_map)
(unsigned_fn_parm_diff_sptr_map, string_var_diff_sptr_map)
(unsigned_var_diff_sptr_map, string_function_decl_diff_sptr_map)
(string_var_diff_ptr_map): New typedefs.
(diff_context::{has_diff_for,add_diff}): Make these member
functions private.
(diff_context::{set_canonical_diff_for,
set_or_get_canonical_diff_for}): Declare new private member
functions.
(diff_context::{get_canonical_diff_for,
initialize_canonical_diff}): New public member functions.
(diff_context::maybe_apply_filters): Set the default value of the
'traverse_nodes_once' parameter to false.
(compute_diff): Make the overload for class_decl_sptr friend of
the diff_context class.
(class diff): Make the diff_context class a friend of this one.
(diff::set_canonical_diff): Declare new private member function.
(diff::get_canonical_diff): Declare new public member function.
(diff::children_nodes): Make this return a vector<diff_sptr>, rather
than a vector<diff*>.
(diff::append_child_node): Make this take a diff_sptr rather than
a diff*.
(class fn_parm_diff): Declare new type.
(compute_diff): Declare new overload for the new
function_decl::parameter_sptr.
(function_decl_diff::subtype_changed_parms): Return a
string_fn_parm_diff_sptr_map rather than a string_changed_parm.
(function_decl_diff::children_nodes): Return a vector<diff_sptr>.
(function_decl_diff::append_child_node): Take a diff_sptr.
(function_decl_diff::changed_functions): Return a
string_function_decl_diff_sptr_map.
(function_decl_diff::changed_variables): Return a
string_var_diff_sptr.
(class function_decl::parameter): Make this a pimpled class.
Also, make it inherit decl_base.
(equals): New overload for function_decl::parameter.
(struct function_decl::parameter::hash): Declare this.
(ir_node_visitor::visit): Declare new overload for
function_decl::parameter.
* src/abg-comparison.cc: Add doc-string about the internal
representation of the comparison engine and also about the concept
of canonical diff of the comparison engine.
(RETURN_IF_BEING_REPORTED_OR_WAS_REPORTED_EARLIER)
(RETURN_IF_BEING_REPORTED_OR_WAS_REPORTED_EARLIER2)
(RETURN_IF_BEING_REPORTED_OR_WAS_REPORTED_EARLIER3): Consider the
canonical diff when trying to know if the current node was
reported earlier.
(diff_context::priv::canonical_diffs): New data member.
(diff_context::{get_canonical_diff_for, set_canonical_diff_for,
set_or_get_canonical_diff_for, initialize_canonical_diff}): Define
new member functions.
(diff_context::{diff_has_been_traversed, mark_diff_as_traversed):
Consider canonical diff for these tests and actions.
(diff::priv::children_): Change the type of this to
vector<diff_sptr>.
(diff::canonical_diff_): New data member.
(diff::diff): Initialize the diff::canonical_diff_ data member.
(diff::begin_traversing): Mark the canonical diff node too.
(diff::is_traversing): Consider the canonical diff node in this
test.
(diff::end_traversing): Make the canonical diff node too. Also
mark the current node as having been traversed.
(diff::children_nodes): Return a vector<diff_sptr> type.
(diff::{get_canonical_diff, set_canonical_diff}): Define new
member functions.
(diff::append_child_node): Take a diff_sptr type parameter.
(diff::{reported_once, currently_reporting}): Flag the canonical
diff node too. And consider the canonical diff node when checking
the flag.
(diff::traverse): No need to mark the node as being traversed
because the diff::end_traversing() function does it now. Adjust
the code because diff::children_nodes() now returns
vector<diff_sptr>.
({distinct_diff, var_diff, pointer_diff, array_diff,
reference_diff, qualified_type_diff, enum_diff, class_diff,
base_diff, scope_diff, function_decl_diff, typedef_diff,
corpus_diff}::chain_into_hierarchy): Adjust to the new type that
diff::append_child_node() takes. Also, take into account that the
diff nodes are now un-shared.
(compute_diff_for_distinct_kinds, compute_diff_for_types)
(compute_diff): Do not share diff nodes anymore. Initialize the
canonical diff node for the new created node.
(represent): Take a var_diff_sptr rather than two var_decl_sptr.
Adjust. Also take in account the fact that diff nodes are not
shared anymore, and that they do have canonical diffs.
(var_diff::type_diff): Make the computation of the type_diff of
the var_diff be lazy. This avoids infinite (recursive) creation
of diff nodes when a class diff node has a sub-type of data member
that is a class diff node too.
(var_diff::report): Detect redundant reporting of this kind of
diff node.
(class_diff::priv::changed_bases_): Change the type of this to
string_base_diff_sptr_map.
(class_diff::priv::subtype_changed_dm_): Change the type of this
to string_var_diff_sptr_map.
(class_diff::priv::changed_dm_): Change the type of this to
unsigned_var_diff_sptr_map.
(class_diff::priv::{count_filtered_subtype_changed_dm,
count_filtered_bases}): Do not take a diff_context_sptr anymore.
(class_diff::ensure_lookup_tables_populated): changed_bases_
subtype_changed_dm_ and changed_dm_ are now *NOT* shared diff
nodes anymore.
(class_diff::priv::base_has_changed): Adjust.
(class_diff::priv::subtype_changed_dm): Adjust.
(class_diff::priv::count_filtered_bases): Adjust as changed_bases_
is now a map of un-shared diff nodes.
(class_diff::priv::count_filtered_subtype_changed_dm): Adjust as
subtype_changed_dm_ is now a map of un-shared diff nodes.
(class_diff::priv::{count_filtered_changed_mem_fns,
count_filtered_inserted_mem_fns, count_filtered_deleted_mem_fns,
}): Adjust for change of the default parameter value of
diff_context::maybe_apply_filters().
(class_diff::~class_diff): New destructor.
(class_diff::changed_bases): Return a string_base_diff_sptr_map&
type.
(class_diff::{inserted_data_members, deleted_data_members,
changed_member_fns}): Add doc strings.
(struct changed_data_member_comp): Remove.
(struct var_diff_comp): New comparison functor.
(sort_changed_data_members): Remove.
(sort_var_diffs): Define new sorting function.
(class_diff::report): Adjust.
(fn_parm_diff::*): Define member types and functions of the new
fn_parm_diff type.
(function_decl_diff::priv::{subtype_changed_parms_,
changed_parms_by_id_}): Make these take a map of fn_parm_diff_sptr
nodes.
(function_decl_diff::ensure_lookup_tables_populated): Adjust to
the fact that priv_->subtype_changed_parms_ and
priv_->priv_->changed_parms_by_id_ now are maps of un-shared
fn_parm_diff_sptr nodes.
(function_decl_diff::subtype_changed_parms): Adjust.
(struct changed_parm_comp): Remove.
(struct fn_parm_diff_comp): New comparison functor.
(sort_changed_parm_map): Remove.
(sort_string_fn_parm_diff_sptr_map): New sorting function.
(function_decl_diff::report): Adjust.
(corpus_diff::priv::children_): Change the type of this to
vector<diff_sptr>.
(corpus_diff::priv::changed_fns_): Changed the type of this to
string_function_decl_diff_sptr_map.
(corpus_diff::priv::changed_vars_): Changed the type of this to
string_var_diff_sptr_map.
(corpus_diff::priv::ensure_lookup_tables_populated): Adjust.
(corpus_diff::priv::apply_filters_and_compute_diff_stats}):
Adjust. Do not need to clear redundancy categorization anymore
because the diff nodes are not shared anymore.
(corpus_diff::priv::categorize_redundant_changed_sub_nodes):
Adjust.
(corpus_diff::priv::clear_redundancy_categorization): Adjust.
(corpus_diff::changed_variables): Adjust.
(struct changed_function_ptr_comp): Remove.
(struct function_decl_diff_comp): New comparison functor.
(sort_string_changed_function_ptr_map): Remove.
(sort_string_function_decl_diff_sptr_map): Define new sorting
function.
(struct changed_vars_comp): Remove.
(struct var_diff_sptr_comp): New comparison functor.
(sort_changed_vars): Remove.
(sort_string_var_diff_sptr_map): Define new sorting function.
(corpus_diff::report): Adjust.
(corpus_diff::traverse): Adjust.
({category_propagation_visitor,
suppression_categorization_visitor}::visit_end): Adjust.
(clear_redundancy_categorization): Adjust.
* src/abg-hash.cc (function_decl::parameter:#️⃣:operator):
Adjust.
* src/abg-ir.cc (struct function_decl::parameter::priv): Define
here as part of pimpl-ifying the function_decl::parameter type.
(function_decl::parameter::*): Define here the member functions as
part of pimpl-ifying the function_decl::parameter type.
(equals): Define the overload for function_decl::parameter here
too.
(ir_node_visitor::visit(function_decl::parameter*)): Define this.
* tests/data/test-abicompat/test0-fn-changed-report-0.txt: Adjust.
* tests/data/test-diff-suppr/test5-fn-suppr-report-0.txt: Adjust.
* tests/data/test-diff-dwarf/libtest21-redundant-fn-v0.so: New
test input data.
* tests/data/test-diff-dwarf/libtest21-redundant-fn-v1.so:
Likewise.
* tests/data/test-diff-dwarf/test21-redundant-fn-v0.cc: Source
code for test input binary above.
* tests/data/test-diff-dwarf/test21-redundant-fn-v1.cc: Likewise.
* tests/data/test-diff-dwarf/test21-redundant-fn-report-0.txt: New
test input data.
* tests/data/test-diff-dwarf/libtest22-changed-parm-c-v0.so: New
test input data.
* tests/data/test-diff-dwarf/libtest22-changed-parm-c-v1.so:
Likewise.
* tests/data/test-diff-dwarf/test22-changed-parm-c-v0.c: Source
code for test input binary above.
* tests/data/test-diff-dwarf/test22-changed-parm-c-v1.c: Likewise.
* tests/test-diff-dwarf.cc (in_out_spec): Add the new test input
data to the vector the test inputs to run this harness over.
* tests/data/test-diff-suppr/test8-redundant-fn-report-0.txt: New
test input data.
* tests/data/test-diff-suppr/test8-redundant-fn-report-1.txt:
Likewise.
* tests/data/test-diff-suppr/libtest8-redundant-fn-v0.so: New test
input binary.
* tests/data/test-diff-suppr/libtest8-redundant-fn-v1.so: Likewise.
* tests/data/test-diff-suppr/test8-redundant-fn-v0.cc: Source code
code for binary test input above.
* tests/data/test-diff-suppr/test8-redundant-fn-v1.cc: Likewise.
* tests/data/test-diff-suppr/test9-changed-parm-c-report-0.txt:
New test input data.
* tests/data/test-diff-suppr/test9-changed-parm-c-report-1.txt:
Likewise.
* tests/data/test-diff-suppr/libtest9-changed-parm-c-v0.so: New
test input binary.
* tests/data/test-diff-suppr/libtest9-changed-parm-c-v1.so: New
test input binary.
* tests/data/test-diff-suppr/test9-changed-parm-c-v0.c: Source
code for binary test input above.
* tests/data/test-diff-suppr/test9-changed-parm-c-v1.c: Likewise.
* tests/test-diff-suppr.cc (in_out_specs): Add the new test input
data to the vector the test inputs to run this harness over.
* tests/data/Makefile.am: Add the new files to the source
distribution.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
|
||
Dodji Seketeli
|
1b75fd3eac |
Make determining of compatible types complete
Until now, two types that are different were considered compatible if one type is a typedef of the other. This is useful because two different types, if compatible, are not ABI-incompatible. This patch extends the concept of compatible types to types which might have sub-types that are typedefs of each others, including function types. Note implementing this required that I fixed various other things left and right. Like style fixes, crash avoiding fixes, etc. * include/abg-fwd.h (is_reference_type, is_function_type) (is_method_type): Declare new predicates. * include/abg-ir.h (class qualified_type_def): Pimpl this class. (qualified_type_def::qualified_type_def): Use the convenience type_base_sptr typedef. (qualified_type_def::{get_cv_quals, set_cv_quals}): Use the qualified_type_def::CV type rather than char. (qualified_type_def::get_underlying_type): Use the convenience type_base_sptr typedef. (pointer_type_def::pointer_type_def): Likewise. (function_decl::parameter::parameter): Add a new constructor. * src/abg-ir.cc (is_reference_type, is_function_type) (is_method_type): Define new predicates. (class qualified_type_def::priv): Define this new private type, for the purpose of Pimpl-ifying the qualified_type_def class. (qualified_type_def::{qualified_type_def, build_name, get_cv_quals_string_prefix, get_underlying_type}): Adjust for the purpose of Pimpl-ifying the qualified_type_def class. (equals): In the qualified_type_def, reference_type_def overloads, trust the fact that we have operator== overload for the type_base_sptr. This avoids crashes for when the (possible) underlying type is null. (pointer_type_def::operator==): Likewise. (strip_typedef): Make this recursively strip typedefs from sub-types. (types_are_compatible): Handle null types. (qualified_type_def::{get_cv_quals, set_cv_quals}): Handle qualified_type_def::CV rather than char. (pointer_type_def::pointer_type_def): Use the convenience type_base_sptr typedef. * include/abg-comparison.h (distinct_diff::compatible_child_diff): Declare new member function. * src/abg-comparison.cc (distinct_diff::compatible_child_diff): Define new member function. (distinct_diff::chain_into_hierarchy): Chain the compatible child diff node that might be present. (distinct_diff::report): Now when a distinct diff carries a compatible change, mention it in the report. * src/abg-comp-filter.cc (is_compatible_change): A compatible change can now involve types that are not typedefs. Only their sub-types need to be involved with typedef-ness. * tests/data/test-diff-dwarf/test{2,4,5}-report.txt: Adjust. * tests/data/test-diff-filter/libtest21-compatible-vars-v0.so: New test data input. * tests/data/test-diff-filter/libtest21-compatible-vars-v1.so: Likewise. * tests/data/test-diff-filter/test21-compatible-vars-report-0.txt Likewise. * tests/data/test-diff-filter/test21-compatible-vars-report-1.txt Likewise. * tests/data/test-diff-filter/test21-compatible-vars-v0.cc: Source code for the first data input binary above. * tests/data/test-diff-filter/test21-compatible-vars-v1.cc: Source code for the second data input binary above. * tests/data/test-diff-filter/libtest22-compatible-fns-v0.so: New test data input. * tests/data/test-diff-filter/libtest22-compatible-fns-v1.so Likewise. * tests/data/test-diff-filter/test22-compatible-fns-report-0.txt: New test data input. * tests/data/test-diff-filter/test22-compatible-fns-report-1.txt: Likewise. * tests/data/test-diff-filter/test22-compatible-fns-v0.c: Source code for the first test data input binary above. * tests/data/test-diff-filter/test22-compatible-fns-v1.c: Source code for the second test data input binary above. * tests/data/Makefile.am: Add the new test input data to source distribution. * tests/test-diff-filter.cc (in_out_specs): Add the new test data input above to the list of test data this harness has to be run over. Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
Dodji Seketeli
|
6be1218195 |
Rename elf_symbol::get_is_defined() to elf_symbol::is_defined()
It's let's awkward to type if (elf_symbol->is_defined()); than ...->get_is_defined(). So I am going to the former. A chance we still can change ABI here ;-) * include/abg-ir.h (elf_symbol::get_is_defined): Rename into elf_symbol::is_defined. (elf_symbol::set_is_defined): Rename into elf_symbol::is_defined. * src/abg-ir.cc (elf_symbol::get_is_defined): Likewise, rename this into elf_symbol::is_defined. (elf_symbol::set_is_defined): Likewise, rename this into elf_symbol::is_defined. (elf_symbol::{elf_symbol, is_public}): Adjust. * src/abg-writer.cc (write_elf_symbol): Adjust. Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
Dodji Seketeli
|
d3b188f859 |
Fix template parameter hashing: make it know about enclosing template
* include/abg-ir.h (template_parameter_sptr, template_decl_sptr) (template_decl_wptr): Declare new typedefs. (class template_decl): Make this virtually inherit decl_base and pimpl-ify it. (class template_parameter): Pimpl-ify this. Make the constructor take the enclosing template parameter. (struct template_decl::hash): Declare this here, rather than in src/abg-hash.cc (class type_tparameter, non_type_tparameter, template_tparameter) (class type_composition, function_tdecl, class_tdecl): Pimpl-ify this. * src/abg-hash.cc (template_parameter:#️⃣:operator()): Hash the enclosing template parameter. Avoid infinite recursion due to the loop hash parameter -> hash template -> hash parameter. (template_decl:#️⃣:operator()) Define this here, now that it's declared in abg-ir.h. Also, avoid infinite recursion here; this is complementary to what is done in the hashing for template_parameter. ({type_tparameter, template_tparameter, }:#️⃣:operator()): Cache the calculated hash just as what is done for other types hashed. (template_decl::priv): Define this new type. (template_decl::{add_template_parameter, get_template_parameters, ~template_decl}): Define these here to pimpl-ify template_decl. (template_parameter::priv): Define this new type. (template_parameter::template_parameter): Define this here to pimpl-ify template_parameter. Note also that this now takes the enclosing template decl. (template_parameter::{get_index, get_enclosing_template_decl, get_hashing_has_started, set_hashing_has_started, operator::==}): Define these here to pimpl-ify template_parameter. (type_tparameter::priv): Define this new type. (type_tparameter::type_tparameter): Define this here to pimpl-ify type_tparameter. Also, not that this constructor now takes the enclosing template decl. (class non_type_tparameter::priv): Define new type. (non_type_tparameter::{non_type_tparameter, get_type}): Define these here to pimpl-ify non_type_tparameter. The constructor now takes the enclosing template. (template_tparameter::priv): Define new type. (template_tparameter::template_tparameter): Define this here to pimpl-ify template_tparameter. This constructor now takes the enclosing template. (class type_composition::priv): New type. (type_composition::{type_composition, get_composed_type, set_composed_type}): Define these here to pimpl-ify type_composition. The constructor now takes the enclosing template decl. (class function_tdecl::priv): Define new type. (function_tdecl::{function_tdecl, set_pattern, get_pattern, get_binding}): Define this here to pimpl-ify function_tdecl. (class class_tdecl::priv): Define this new type. (class_tdecl::class_tdecl): Define this here to pimpl-ify class_tdecl. (class_tdecl::set_pattern): Adjust to pimpl-ify. (class_tdecl::get_pattern): Define new pimpl-ified getter. * src/abg-reader.cc (build_function_tdecl, build_class_tdecl): Cleanup. Pass the enclosing template to the template parameters that are built. (build_type_tparameter, build_type_composition) (build_non_type_tparameter, build_template_tparameter) (build_template_parameter): Take the enclosing template declaration and pass it to the template parameter being created. * tests/data/test-read-write/test12.xml: Fix and Adjust. * tests/data/test-read-write/test13.xml: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
Dodji Seketeli
|
ca8e5e38af |
Style fix
* include/abg-ir.h (class location): Remove useless white space. * src/abg-writer.cc (type_has_existing_id): Use type_base_sptr rather than shared_ptr<type_base>. (write_template_tparameter): Use template_tparameter_sptr rather than shared_ptr<template_tparameter>. Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
Dodji Seketeli
|
23772b3f8d |
Initial support for function suppressions
* include/abg-comparison.h (enum visiting_kind): Change the meaning of this. It was to determine if traversal was to be done in a pre or post manner. But with the recent addition of diff_node_visitor::visit_{begin,end}() notifiers, the pre/post handling is taken care of in a different way. So now the meaning of this enum is changed to handle whether diff node children should be visited or not. So the enumerators are now DEFAULT_VISITING_KIND, and SKIP_CHILDREN_VISITING_KIND. And it's a bit-field. (operator{&,~}): Declare more bit manipulation operators for the enum visiting_kind. (function_suppression_sptr, function_suppressions_type): New typedefs. (function_suppression, function_suppression::parameter_spec): Declare new types. (read_function_suppressions): Declare new function. (diff_node_visitor::diff_node_visitor): Adjust for the enum visiting_kind change. Value-initialize the visiting_kind_ data member. * src/abg-comparison.cc (operator{&,~}): Define these operators for enum visiting_kind. (read_type_suppressions): Forward declare this static function. (read_function_suppression, read_parameter_spec_from_string): Define new static functions. (read_suppressions): Update to read function suppressions too, using the new read_function_suppression function above. (class function_suppression::parameter_spec::priv): Define new type. (function_suppression::parameter_spec::*): Define the member functions of the new function_suppression::parameter_spec type. (class function_suppression::priv): Define new type. (function_suppression::*): Define the member functions of the new function_suppression type. (diff::traverse): There is no more {PRE,POST}_VISITING_KIND enumerator. So nuke the code that was dealing with it. (redundancy_marking_visitor::skip_children_nodes_): New data member flag. (redundancy_marking_visitor::visit_begin): If the current diff node is not be reported (is filtered out), do not bother visit its children nodes for the purpose of marking redundant nodes. So use the new skip_children_nodes_ flag above to know we are in that case. (redundancy_marking_visitor::visit_end): Unset the new skip_children_nodes_ flag above when appropriate. * include/abg-fwd.h (is_function_decl): Declare new function. * include/abg-ir.h (function_type::get_parm_at_index_from_first_non_implicit_parm): Declare new member function. * src/abg-ir.cc (is_function_decl): Define new function. (function_type::get_parm_at_index_from_first_non_implicit_parm): Define new member function. * src/abg-comp-filter.cc (apply_filter): Adjust for the enum visiting_kind change. No need to set it for filters anymore * doc/suppr-doc.txt: Update examples of function suppression. * doc/manuals/libabigail-concepts.rst: Update the manual for the function suppression addition. * tests/data/test-diff-suppr/libtest5-fn-suppr-v0.so: New test input. * tests/data/test-diff-suppr/libtest5-fn-suppr-v1.so: New test input. * tests/data/test-diff-suppr/libtest6-fn-suppr-v0.so: New test input. * tests/data/test-diff-suppr/libtest6-fn-suppr-v1.so: New test input. * tests/data/test-diff-suppr/test5-fn-suppr-0.suppr: New test input. * tests/data/test-diff-suppr/test5-fn-suppr-1.suppr: New test input. * tests/data/test-diff-suppr/test5-fn-suppr-2.suppr: New test input. * tests/data/test-diff-suppr/test5-fn-suppr-3.suppr: New test input. * tests/data/test-diff-suppr/test5-fn-suppr-4.suppr: New test input. * tests/data/test-diff-suppr/test5-fn-suppr-report-0.txt: New test input. * tests/data/test-diff-suppr/test5-fn-suppr-report-1.txt: New test input. * tests/data/test-diff-suppr/test5-fn-suppr-report-2.txt: New test input. * tests/data/test-diff-suppr/test5-fn-suppr-report-3.txt: New test input. * tests/data/test-diff-suppr/test5-fn-suppr-report-4.txt: New test input. * tests/data/test-diff-suppr/test5-fn-suppr-report-5.txt: New test input. * tests/data/test-diff-suppr/test5-fn-suppr-v0.cc: Source code for new test input. * tests/data/test-diff-suppr/test5-fn-suppr-v1.cc: Source code for new test input. * tests/data/test-diff-suppr/test6-fn-suppr-0.suppr: New test input. * tests/data/test-diff-suppr/test6-fn-suppr-1.suppr: New test input. * tests/data/test-diff-suppr/test6-fn-suppr-2.suppr: New test input. * tests/data/test-diff-suppr/test6-fn-suppr-3.suppr: New test input. * tests/data/test-diff-suppr/test6-fn-suppr-report-0.txt: New test input. * tests/data/test-diff-suppr/test6-fn-suppr-report-1.txt: New test input. * tests/data/test-diff-suppr/test6-fn-suppr-report-2.txt: New test input. * tests/data/test-diff-suppr/test6-fn-suppr-report-3.txt: New test input. * tests/data/test-diff-suppr/test6-fn-suppr-report-4.txt: New test input. * tests/data/test-diff-suppr/test6-fn-suppr-v0.cc: Source code for new test input. * tests/data/test-diff-suppr/test6-fn-suppr-v1.cc: Source code for new test input. * tests/data/test-diff-suppr/test6-fn-suppr-version-script: New test input. * tests/Makefile.am: Add the new files above to source the distribution. * tests/test-diff-suppr.cc (in_out_specs): Add the test inputs above to the list of tests to be run by this harness. Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
Dodji Seketeli
|
8a3b969f87 |
Pimplify abigail::ir::function_type
* include/abg-ir.h (function_type::priv_): Declare new data member. (function_type::<all the methods>): Move the inline methods out of line in src/abg-ir.cc. (function_type::{return_type_, parms_}): Move these ... * src/abg-ir.cc (function_type::priv::{return_type_, parms_}): ... Here. (struct function_type::priv): New type for the private data of function_type. (function_type::<all the methods>): Move the previously inline methods of function_type here. Adjust them to tap into priv_->* to get the private data members. Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
Dodji Seketeli
|
362d8aa919 |
Light style fix
* include/abg-ir.h (function_decl::get_type): Change the return type from shared_ptr<function_type> to function_type_sptr. Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
Dodji Seketeli
|
f44110b326 |
Support comparing symbols not referenced by debug info
* doc/manuals/abidiff.rst: Adjust intro to mention that w/o debug info, abidiff now works but just report about added/removed symbols. Add documentation about the new --no-unreferenced-symbols option. * include/abg-comparison.h (string_elf_symbol_map): New typedef. (diff_context::show_symbols_unreferenced_by_debug_info): Declare new accessors. * src/abg-comparison.cc (diff_context::priv::show_syms_unreferenced_by_di_): New data member. (diff_context::priv::priv): Adjust. (diff_context::show_symbols_unreferenced_by_debug_info): Implement these accessors. (corpus_diff::priv::{unrefed_fn_syms_edit_script_, unrefed_var_syms_edit_script_, added_unrefed_fn_syms_, deleted_unrefed_fn_syms_, added_unrefed_var_syms_, deleted_unrefed_var_syms_}): New data members. (corpus_diff::priv::diff_stats::{num_func_syms_removed, num_func_syms_added, num_var_syms_removed, num_var_syms_added}): New data members. (corpus_diff::priv::diff_stats::diff_stats): Adjust. (corpus_diff::ensure_lookup_tables_populated): Populate lookup tables for added/removed symbols that are not referenced by any debug info. (corpus_diff::priv::apply_filters_and_compute_diff_stats): Compute stats for the added/removed symbols not referenced by any debug info. (corpus_diff::priv::emit_diff_stats): Emit stats about added/removed symbols that are not referenced by any debug info. (corpus_diff::length): Adjust to take in account added/removed symbols not referenced by any debug info. (show_linkage_name_and_aliases): New static function. (corpus_diff::report): When emitting a symbol name, emit its version too, and tell if it aliases other symbols. Avoid emitted extra new lines. Report added/removed symbols not referenced by any debug info. (compute_diff): In the overload for corpus_sptr, compute the diffs for symbols not referenced by debug info. * include/abg-corpus.h (corpus::get_unreferenced_{function,variable}_symbols): Declare new member functions. * src/abg-corpus.cc (corpus_priv::{unrefed_fun_symbols, unrefed_var_symbols}): New data members. (corpus_priv::build_unreferenced_symbols_tables): Define new member function. (struct comp_elf_symbols_functor): New functor. (corpus::is_empty): Adjust to take in account added/removed symbols not referenced by debug info. (corpus::{get_unreferenced_function_symbols, corpus::get_unreferenced_variable_symbols}): Define these accessors. * include/abg-dwarf-reader.h (enum status): Transform this into bitfields. Add a STATUS_UNKNOWN value that has the value 0. (operator|(status, status), operator&(status, status)) (operator|=(status&, status), operator&=(status, status)): New bit-wise operators to manipulate instances of the status bit-field. * src/abg-dwarf-reader.cc (get_version_for_symbol): Fix this to avoid returning garbage version sometimes. (read_debug_info_into_corpus): Fix this to return a non-null but empty corpus_sptr when there is no debug info available. (operator|(status, status), operator&(status, status)) (operator|=(status&, status), operator&=(status, status)): Define these new bitwise operators to manipulate instances of the status bit-field. (read_corpus_from_elf): Now that the abigail::dwarf_reader::status is a bit-field, set it to reflect if debug info and/or symbol tables have been found. Do not bail out if debug info hasn't been found. Rather, keep going, and go look for symbols-only; this is a kind of operating in degraded mode. * include/abg-ir.h (elf_symbol::get_aliases_id_string): Add a flag that says if the current instance of elf_symbol should be included in the list of aliases or not. * src/abg-ir.cc (elf_symbol::get_aliases_id_string): Define it. * tests/data/test-diff-dwarf/test16-syms-only-v{0,1}.o: New test input. * tools/abidiff.cc (options::show_symbols_not_referenced_by_debug_info): New data member. (options:options): Adjust. (display_usage): Add an info string for the new --no-unreferenced-symbols command line option. (parse_command_line): Parse the new --no-unreferenced-symbols command line. (set_diff_context_from_opts): Set the diff_context according to the presence of --no-unreferenced-symbols. (main): Adjust for the fact that abigail::dwarf_reader::status is now a bit-field. * tools/abilint.cc (main): Adjust for the fact that abigail::dwarf_reader::status is now a bit-field.. (): * tests/data/test-diff-dwarf/test16-syms-only-report.txt: New test reference output. * tests/data/test-diff-dwarf/test16-syms-only-v{0,1}.cc: Source code for new test input. * tests/data/test-diff-dwarf/test17-non-refed-syms-v{0,1}.o: New test input. * tests/data/test-diff-dwarf/test17-non-refed-syms-v{0,1}.cc: New source code for test input. * tests/data/test-diff-dwarf/libtest18-alias-sym-v{0,1}.so: New test input. * tests/data/test-diff-dwarf/test18-alias-sym-report-0.txt: Reference output for new test input. * tests/data/test-diff-dwarf/test18-alias-sym-v{0,1}.cc: Source code for new test input. * tests/data/test-diff-dwarf/test18-alias-sym-version-script: Source code for new test input. * tests/Makefile.am: Add the new test materials to the source distribution. * tests/test-diff-dwarf.cc(in_out_specs): Add the new input tests above to the array of tests to run by this harness. (main): Emit empty reports for empty resulting diffs. * tests/data/test-diff-dwarf/test{0,8,9,12,14-inline-report,}-report.txt: Adjust. * tests/data/test-diff-filter/test{0,01,2,4,5,7,8,9,10,12,13,15-0,15-1}-report.txt: Likewise. * tests/data/test-diff-filter/test{19-enum,20-inline,}-report-0.txt: Likewise. * tests/data/test-diff-suppr/test0-type-suppr-report-{1,2}.txt: Likewise. * tests/data/test-diff-suppr/test{1,2}-typedef-suppr-report-1.txt: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
Dodji Seketeli
|
e4c21097fa |
Write comparison functions that hint at the kind of changes they see
* include/abg-ir.h (enum change_kind): Declare new enum. (operator|(change_kind, change_kind), operator&(change_kind, change_kind), operator|=(change_kind&, change_kind)): Declare new bit-wise operators for the new enum change_kind. (equals): Declare this new comparison function for decl_base, scope_decl, type_base, type_decl, scope_type_decl, qualified_type_def, pointer_type_def, reference_type_def, array_type_def, enum_type_decl, typedef_decl, var_decl, function_decl, function_type, class_decl, and class_decl::base_spec. (class_decl::base_spec::operator(const decl_base&)): Declare new equality operator. * src/abg-ir.cc (operator|(change_kind l, change_kind r)) (operator&(change_kind l, change_kind r), operator|=(change_kind& l, change_kind r), operator&=(change_kind& l, change_kind r)): Define these new operators. (equals): Define this new comparison function for decl_base, scope_decl, type_base, type_decl, scope_type_decl, qualified_type_def, pointer_type_def, reference_type_def, array_type_def, enum_type_decl, typedef_decl, var_decl, function_decl, function_type, class_decl, and class_decl::base_spec. ({decl_base, scope_decl, type_base, type_decl, scope_type_decl, qualified_type_def, pointer_type_def, reference_type_def, array_type_def, enum_type_decl, typedef_decl, var_decl, function_decl, function_type, class_decl, class_decl::base_spec}::operator==): Re-write these comparison operators in terms of their relevant equal() functions. Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
Dodji Seketeli
|
fccc516656 |
Put IR artifacts in the abigail::ir namespace
* include/abg-fwd.h: Wrap IR artifacts into abigail::ir namespace. Inject that new abigail::ir namespace into the abigail namespace. * include/abg-ir.h: Wrap IR artifacts into abigail::ir namespace. (function_decl::parameter::get_type_name): Adjust the call to abigail::get_type_name. It's now a call to abigail::ir::get_type_name. * src/abg-ir.cc: Wrap IR artifacts into abigail::ir namespace. * include/abg-traverse.h: Wrap the ir traversing artifact into the abigail::ir namespace too. * src/abg-traverse.cc: Adjust. * include/abg-corpus.h: Wrap corpus type stuff into abigail::ir. * include/abg-dwarf-reader.h: Inject namespace abigail::ir stuff into the abigail::dwarf_reader namespace. * include/abg-reader.h: Inject namespace abigail::ir stuff into the abigail::xml_reader namespace. * src/abg-reader.cc: Adjust. * include/abg-writer.h: Inject namespace abigail::ir stuff into the abigail::xml_writer namespace. * src/abg-writer.cc: Inject namespace abigail::ir stuff into abigail namespace here too. * src/abg-hash.cc: Inject the abigail::ir namespace into the abigail namespace. * tools/abg-tools-utils.cc: Adjust for the injection of abigail::function_decl. It's now abigail::ir::function_decl. Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
Dodji Seketeli
|
5c67f59f76 |
constify dm_context_rel::operator==
* include/abg-ir.h (dm_context_rel::operator==): Make this const. Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
Dodji Seketeli
|
b9d97f21c3 |
Fixup member functions which virtual-ness has just been set
* include/abg-ir.h (fixup_virtual_member_function): Declare new function. (class_decl): Declare fixup_virtual_member_function() as a member. * src/abg-ir.cc (set_member_function_is_virtual): Ensure that the member function that has seen its virtualness set is also put correctly put in the vector of virtual member functions of its class. Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
Dodji Seketeli
|
cbf1debeab |
Fix reading several clones of the same member function from DWARF
* include/abg-fwd.h (set_member_function_is_ctor) (set_member_function_is_dtor, set_member_function_is_const) (set_member_function_vtable_offset): Declare new functions. * include/abg-ir.h (class_decl::sort_virtual_mem_fns): Declare new member function. (mem_fn_context_rel::{vtable_offset, is_constructor is_destructor, is_const}): Add these setters. (set_member_function_is_ctor, set_member_function_is_dtor) (set_member_function_is_static, set_member_function_is_const) (set_member_function_vtable_offset) (set_member_function_is_virtual): Declare these new friend function to class class_decl::method_decl. * src/abg-dwarf-reader.cc (finish_member_function_reading): Split this out from build_class_type_and_add_to_ir. Use the new setters for member functions properties introduced above. (build_class_type_and_add_to_ir): Factorize the creation of member function by using build_ir_node_from_die. Once that function has created the member function in a rather generic way, use the new finish_member_function_reading to set the remaining specific properties for member functions. (build_function_decl): When called to read additional properties of a function_decl, allow this to read and update the elf symbol properties too. This is useful for building a clone of a function that already has an elf symbol. (build_ir_node_from_die): When building a function decl, consider the case of a DIE that has both DW_AT_specification and DW_AT_abstract_origin set. That is, DW_AT_abstract_origin is set, and the origin has DW_AT_specification set. This is basically a clone of a function that implements an interface (this happens for destructors, for instance). In this case, really do the cloning of the interface implementation. If the cloned function happens to be member function, use finish_member_function_reading to read the properties relevant to its method-ness. * src/abg-ir.cc (set_member_function_is_ctor) (set_member_function_is_dtor, set_member_function_is_const) (set_member_function_vtable_offset) (class_decl::sort_virtual_mem_fns): Define new functions. (sort_virtual_member_functions): Define new static function. (struct virtual_member_function_less_than): New functor. (class_decl::add_member_function): Keep virtual member functions vector sorted. * data/test-read-dwarf/test1.abi: Adjust. Now, both the cdtor specification and all the clones that implements the different are emitted. * data/test-read-dwarf/test2.so.abi: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
Dodji Seketeli
|
46dbc9ce41 |
Rename member_function_is_virtual to get_member_function_is_virtual
* include/abg-fwd.h (get_member_function_is_virtual): Renamed the
declaration of member_function_is_virtual into this.
* src/abg-ir.cc (get_member_function_is_virtual): Likewise for its
definition.
* include/abg-ir.h (class decl_base): Adjust the friend function
member_function_is_virtual references.
* src/abg-comp-filter.cc (has_virtual_mem_fn_change)
(has_non_virtual_mem_fn_change): Adjust.
* src/abg-comparison.cc (represent)
(SKIP_MEM_FN_IF_VIRTUALITY_DISALLOWED, class_diff::report):
Likewise.
* src/abg-hash.cc (class_decl:#️⃣:operator()): Likewise.
(function_decl::clone, class_decl::add_member_function): Adjust.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
|
||
Dodji Seketeli
|
fde3436568 |
Better support for inline related diffs
* include/abg-comparison.h (diff_category::HARMLESS_SYMBOL_ALIAS_CHANGE_CATEORY): New enumerator. (diff_category::EVERYTHING_CATEGORY): Adjust. * include/abg-ir.h (elf_symbol::get_aliases_id_string) (elf_symbol::does_alias, elf_symbols_alias) (compute_aliases_for_elf_symbol): Declare new functions ... * src/abg-ir.cc (elf_symbol::get_aliases_id_string) (elf_symbol::does_alias, elf_symbols_alias) (compute_aliases_for_elf_symbol): ... and define them. (function_decl::operator==): Take in account elf symbol aliases. * src/abg-comp-filter.cc (function_name_changed_but_not_symbol): Define new static functions. (harmless_filter::visit): Categorize function name changes that n doesn't impact underlying elf symbols (or the fact that two symbols were aliases and are not anymore) as harmless. * src/abg-comparison.cc (function_decl_diff::report): Properly report function name changes, or symbol aliases changes for that matter. Also report inline-ness declaration changes. * src/abg-dwarf-reader.cc (die_is_declared_inline): New static function. (build_function_decl): Use the above. * tools/bidiff.cc (set_diff_context_from_opts): Add abigail::comparison::HARMLESS_SYMBOL_ALIAS_CHANGE_CATEORY into the harmless change camp. * tests/data/test-diff-dwarf/test14-inline-report.txt: New test input. * tests/data/test-diff-dwarf/test14-inline-v0.o: Likewise. * tests/data/test-diff-dwarf/test14-inline-v1.o: Likewise. * tests/data/test-diff-dwarf/test14-inline-v0.cc: Source code for test input. * tests/data/test-diff-dwarf/test14-inline-v1.cc: Source code for test input. * tests/test-diff-dwarf.cc: Run this test harness over the new input above. * tests/data/test-diff-filter/test20-inline-report-0.txt: Likewise. * tests/data/test-diff-filter/test20-inline-report-1.txt: Likewise. * tests/data/test-diff-filter/test20-inline-v0.o: New test input. * tests/data/test-diff-filter/test20-inline-v1.o: New test input. * tests/data/test-diff-filter/test20-inline-v0.cc: Source code for test input. * tests/data/test-diff-filter/test20-inline-v1.cc: Likewise. * tests/test-diff-filter.cc: Run this test harness over the new input above. Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
Dodji Seketeli
|
41cfd5a82b |
Add constness to elf_symbol::operator==
* include/abg-ir.h (elf_symbol::operator==): Add a const to the declaration ... * src/abg-ir.cc (elf_symbol::operator==): ... and to the definition. Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
Dodji Seketeli
|
5f9a3bf4dd |
Fix memory leaks due to cycles in types ownership
* include/abg-fwd.h (std::tr1::weak_ptr): Inject this type in the abigail namespace. * include/abg-ir.h: Write a memory management guideline for the IR artifacts. (Type_base_wptr, function_type_wptr) (class_decl_wptr): New typedefs. (translation_unit::get_canonical_function_type): Declare new member function. (qualified_type_def::underlying_type_) (reference_type_def::pointed_to_type_) (typedef_decl::underlying_type_, function_decl::parameter::type_) (function_type::return_type_, method_type::class_type_) (non_type_tparameter::type_, type_composition::type_): Make this a weak pointer. (qualified_type_def::get_pointed_to_type) (reference_type_def::get_pointed_to_type) (array_type::get_element_type, typedef_decl::get_underlying_type) (var_decl::get_type, function_decl::parameter::get_type) (function_type::get_return_type, method_type::get_class_type) (non_type_tparameter::get_type) (type_composition::get_composed_type): Adjust to make this return a shared pointer initialized with the content of the weak pointer. (function_decl::function_decl, method_decl::method_decl): Remove the overload that doesn't take a type. This is because now, function types need to be registered to their containing translation unit. (struct function_type::hash): Declare here. * src/abg-hash.cc (struct function_type::hash): Declare this in abg-ir.h and just define the methods here. * src/abg-ir.cc (fn_type_ptr_map): New typedef. (translation_unit::priv::canonical_types_): Remove this unused member. (translation_unit::priv::canonical_function_types_): New member. (translation_unit::get_canonical_function_type): Define this function. (array_type_def::priv::element_type_, var_decl::priv::type_) (function_decl::priv::type_): Make this a weak pointer. (qualified_type_def::get_underlying_type) (pointer_type_def::get_pointed_to_type) (reference_type_def::get_pointed_to_type) (array_type_def::get_element_type) (typedef_decl::get_underlying_type, var_decl::get_type) (function_decl::get_type): Adjust to make this return a shared pointer initialized with the content of the weak pointer. (qualified_type_def::build_name) (pointer_type_def::get_qualified_name) (reference_type_def::get_qualified_name): Adjust. (method_type::set_class_type): Cleanup the logic. (function_decl::priv::priv): Remove the overload that takes a bare pointer to a type. This should not be used now that we need the function type to registered with the translation unit. (function_decl::function_decl): Remove the overload that doesn't take a type. This is because now, function types need to be registered to their containing translation unit. * src/abg-dwarf-reader.cc (build_function_decl): Register the function type within its translation type and use its canonical version. This complies with the new memory management rules. * src/abg-reader.cc (build_function_decl): Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
Dodji Seketeli
|
a2f1adb617 |
Update copyright notice
* include/abg-ir.h: Update year of copyright notice. Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
Dodji Seketeli
|
30b7fb8e5a |
During comparison use symbol name + version as decl ID
* include/abg-ir.h ({var,function}_decl::get_id): New member function declarations. * src/abg-ir.cc ({var,function}_decl::get_id): New member function definitions. * src/abg-comparison.cc (corpus_diff::priv::ensure_lookup_tables_populated): Use the ::get_id() function to get an identifier for the function or variable. * src/abg-corpus.cc (symtab_build_visitor_type::build_id): Use the get_id of the function/variable. Signed-off-by: Dodji Seketeli <dodji@redhat.com> |