mirror of
git://sourceware.org/git/libabigail.git
synced 2024-12-14 22:14:35 +00:00
1ab36e02e5
482 Commits
Author | SHA1 | Message | Date | |
---|---|---|---|---|
Giuliano Procida
|
1ab36e02e5 |
Add missing newlines to end of test files.
Various test files were missing terminal newlines. * tests/data/test-diff-suppr/test0-type-suppr-2.suppr: Add final new line. * tests/data/test-diff-suppr/test22-suppr-removed-var-sym-4.suppr: Likewise. * tests/data/test-diff-suppr/test23-alias-filter-0.suppr: Likewise. * tests/data/test-diff-suppr/test23-alias-filter-4.suppr: Likewise. * tests/data/test-diff-suppr/test28-add-aliased-function-1.suppr: Likewise. * tests/data/test-diff-suppr/test28-add-aliased-function-2.suppr: Likewise. * tests/data/test-diff-suppr/test28-add-aliased-function-3.suppr: Likewise. * tests/data/test-diff-suppr/test28-add-aliased-function-4.suppr: Likewise. * tests/data/test-diff-suppr/test41-enumerator-changes-0.suppr: Likewise. * tests/data/test-diff-suppr/test7-var-suppr-7.suppr: Likewise. * tests/data/test-ini/test01-equal-in-property-string.abignore: Likewise. Signed-off-by: Giuliano Procida <gprocida@google.com> |
||
Dodji Seketeli
|
59610d5572 |
Bug 26568 - Union should support more than one anonymous member
When building a union type we try to ensure that each member is present only once. This is because the code to build the union is also used to actually update a partially constructed union. To do so, before adding a member to the union, the member is looked up (among the current members) by name to see if it's already present or not. But then for anonymous members, the name of the member is empty. After the first anonymous member is added to the union, subsequent look-ups with an empty name all succeed. So no more than one anonymous member is added to the union. Oops. A way to fix this is to perform the lookup by taking into account the type of the anonymous data member, not its (empty) name. We already do this for anonymous data members of classes/structs. This patch thus uses that type-based anonymous data member lookup for unions. But then now that unions can have several anonymous members, another issue was uncovered. Array types whose elements are of anonymous type can be wrongly considered different because of canonicalization issues. Let's suppose we have these two arrays whose internal pretty representation are: "__anonymous_struct_1__ foo[5]" and "__anonymous_struct_2__ foo[5]" These are arrays of 5 elements of type anonymous struct. Suppose the anonymous structs "__anonymous_struct_1__" and "__anonymous_struct_2__" are structurally equivalent. Because the internal names of these array element types are different, the internal pretty representations of the arrays are different. And thus the canonical types of the two arrays are different. And that's wrong. In this particular case, they should have the same canonical type and thus be considered equivalent. This patch thus teaches 'get_type_name' to make the internal type name of anonymous types of a given kind be the same. Thus, making all arrays of 5 anonymous struct have the same pretty representation: "__anonymous_struct__ foo[5]" This gives the type canonicalizer a chance to detect that those arrays having the same canonical type. These two changes while being seemingly unrelated need to be bundled together to fix a number of issues in the existing test reference outputs because fixing the first one is needed to uncover the later issue. * src/abg-dwarf-reader.cc (add_or_update_union_type): Don't use the empty name of anonymous members in the lookup to ensure that all data members are unique. Rather, use the whole anonymous member itself for the lookup, just like is done to handle anonymous data member in classes/structs. * src/abg-reader.cc (build_union_decl): Likewise. * src/abg-ir.cc (get_generic_anonymous_internal_type_name): Define new static function. (get_type_name): For internal purposes, make the type name of all anonymous types of a given kind to be the same. This allows the internal representation of anonymous types which are based on type names to all be the same, so that they can be compared among themselves during type canonicalization. * tests/data/test-read-dwarf/test-PR26568-{1,2}.c: Source code of binary test input. * tests/data/test-read-dwarf/test-PR26568-{1,2}.o: New binary test input. * tests/data/test-read-dwarf/test-PR26568-{1,2}.o.abi: New reference test ouput. * tests/data/Makefile.am: Add the new test material above to source distribution. * tests/test-read-dwarf.cc (in_out_specs): Add the new binary test input above to this test harness. * tests/data/test-diff-dwarf-abixml/PR25409-librte_bus_dpaa.so.20.0.abi: Adjust. * tests/data/test-read-dwarf/PR22122-libftdc.so.abi: Likewise. * tests/data/test-read-dwarf/PR25007-sdhci.ko.abi: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
Dodji Seketeli
|
ee2b54ddd9 |
Make abidiff and abidw support several --headers-dir{1,2} options
When handling a binary with abidiff or abidw it can be useful to provide several different header files directories, for the cases where the header files of the binary are scathered in several different directories. It thus becomes possible to invoke abidiff like this: abidiff --headers-dir1 first-header-dir1 \ --headers-dir1 second-header-dir1 \ --headers-dir2 first-header-dir2 \ --headers-dir2 second-header-dir2 \ binary1 binary2 This patch adds support for that. It also modifies the tests/test-abidiff-exit.cc test harness to make it take header directories. With that modification done, a new test is added in that harness to exercise this new feature. This should close the feature request over at https://sourceware.org/bugzilla/show_bug.cgi?id=26565. * doc/manuals/abidiff.rst: Update documentation for the --headers-dir{1,2} options. * doc/manuals/abidw.rst: Likewise for the --header-dir option. * include/abg-tools-utils.h (gen_suppr_spec_from_headers): Add new overload that takes a vector of headers root dirs. * src/abg-tools-utils.cc (gen_suppr_spec_from_headers_root_dir): Define new function. (gen_suppr_spec_from_headers): Define a new overload that takes a vector of head_root_dir strings; it uses the new gen_suppr_spec_from_headers function. Use the new overload in the previous one that takes just one head_root_dir string. * tools/abidiff.cc (options::headers_dirs{1,2}): Rename option::headers_dir{1,2} into this one and make it be a vector of strings rather than just a string. (parse_command_line): Support several --headers-dir{1,2} on the command line. (set_diff_context_from_opts, set_suppressions): Adjust. * tools/abidw.cc (options::headers_dirs): Renamed options::headers_dir into this and make it be a vector of strings rather than just a string. (parse_command_line): Support several --headers-dir on the command line. (set_suppressions): Adjust. * tests/data/test-abidiff-exit/test-headers-dirs/headers-a/header-a-v{0,1}.h: Header files of new binary test input. * tests/data/test-abidiff-exit/test-headers-dirs/headers-b/header-b-v{0,1}.h: Likewise. * tests/data/test-abidiff-exit/test-headers-dirs/test-headers-dir-v{0,1}.c: Source code of new binary test input. * tests/data/test-abidiff-exit/test-headers-dirs/test-headers-dir-report-{1,2}.txt: Reference output of new binary test input. * tests/data/test-abidiff-exit/test-headers-dirs/test-headers-dir-v{0,1}.o: New binary test input. * tests/data/Makefile.am: Add the new files above to source distribution. * tests/test-abidiff-exit.cc (InOutSpec::in_elfv{0,1}_path): Add new data members. (in_out_specs): Adjust the content of this array as its type changed. Also, add two new entries to run the test over the new binary test inputs above. (do_prefix_strings): Define new static function. (main): Use it the new do_prefix_strings here. Make abidiff use the --header-dir{1,2} option whenever header directories are specified in an entry of the in_out_specs array. Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
Dodji Seketeli
|
3d7916caa4 |
Bug 26309 - Wrong leaf reporting of changes to typedef underlying type
In leaf mode, libabigail fails to report changes to the underlying type of a typedef. At its core, this is due to the fact that changes to the underlying type of a typedef are not considered local. As the leaf reporter only reports local changes (as opposed to non-local changes which are changes to sub-types) it doesn't detect those non-local typedef changes. To handle this, this patch makes changes to the underlying type of a typedef be considered as local changes. This is like what we already do for pointer and qualified types. Now that we have another set of changes to report in the leaf reporter, we need to handle how to propagate the category and redundancy status of those changes. The patch does this too. Also, just like we do pointer and qualified type changes, the patch avoids marking the diff node carrying the typedef change as being a leaf change. That way, only existing leaf changes carrying that typedef diff node will be reported. For instance, a function whose parameter has a typedef change will be reported because that change to the function is considered a leaf change. Otherwise, reporting the typedef (or the pointer or qualified) type change on its own is not useful unless it impacts those leaf changes that we deem useful. The patch adds the example given in problem report to the testsuite. * src/abg-ir.cc (equals): In the overload for typedef_decls, report changes to the underlying type as being local of kind LOCAL_TYPE_CHANGE_KIND. * src/abg-comparison.cc (leaf_diff_node_marker_visitor::visit_begin): Do not mark typedef diff node as leaf node. (suppression_categorization_visitor::visit_end): Propagate the 'suppressed' category of the underlying type to the parent typedef unless the later has a local non-type change. (redundancy_marking_visitor::visit_end): Likewise for the 'redundant' category. * include/abg-reporter.h (report_non_type_typedef_changes): Rename ... * src/abg-default-reporter.cc (report_non_type_typedef_changes): ... report_local_typedef_changes into this. * src/abg-leaf-reporter.cc (leaf_reporter::report): Make the leaf reporter invoke the reporting method of the default reporter for typedefs as all typedef changes are now local. * tests/data/test-diff-filter/test-PR26309-report-0.txt: Add new test reference output. * tests/data/test-diff-filter/test-PR26309-v{0,1}.o: Add new test binary input. * tests/data/test-diff-filter/test-PR26309-v{0,1}.c: Add source code for new test binary input. * tests/data/Makefile.am: Add the new text material above to source distribution. * tests/test-diff-filter.cc (in_out_specs): Add the new test input above to this test harness. * tests/data/test-diff-pkg/spice-server-0.12.4-19.el7.x86_64-0.12.8-1.el7.x86_64-report-3.txt: Adjust. Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
Dodji Seketeli
|
5cf2473d3c |
writer: Avoid using dynamic hashing in type maps
When using type maps the hash used for a given type T is usually the pointer value of the canonical type of T. In the rare cases where T doesn't have a canonical type, we were using a 'dynamic hash' computed by recursively walking the components of T and progressively building a hash that way. The dynamic hashing code hasn't been updated in a while and would need some overhaul to support hashing with schemes like MD5 or maybe sha even. It might be useful for various use cases that have been proposed by some users over the years but nobody was motivated enough to implement it. In the mean time, rather than trying to come up with a fully beefed up dynamic hashing code, we'd rather just return a constant number for non canonicalized types. In practise that amounts to forcing the code of the maps to always use structural comparison for those non canonicalized types. Note that the amount of non-canonicalized types should be fairly small. For now, the only non-canonicalized types should be declaration-only types and those are quite fast to compare anyway. This patch thus introduces a new hashing scheme for maps in the writer which just uses a numerical constant as the hash for non-canonicalized types. * include/abg-fwd.h (hash_as_canonical_type_or_constant): Declare ... * src/abg-ir.cc (hash_as_canonical_type_or_constant): ... new function. * src/abg-writer.cc (type_hasher::operator()): Use the new hash_as_canonical_type_or_constant. * tests/data/test-read-dwarf/test16-pr18904.so.abi: Adjust. Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
Dodji Seketeli
|
005ab5c9bd |
Use flat representation to canonicalize anonymous classes and unions
During the canonicalization of a type T, the algorithm uses the internal pretty representation of T to limit the number of types to compare T to. That internal pretty representation is based on the type name. For anonymous types, the type name is not unique; it's constructed just for internal purposes. So using that in the pretty representation might negatively impact the accuracy of the canonicalization; it might make it so that two types might wrongly be considered canonicaly different. To fix that, this change makes the internal pretty representation of anonymous classes (and unions) use their flat representation. For the record, the flat representation of an anonymous struct with a an integer and a char data members is the string: 'struct {int i; char c;}' * src/abg-ir.cc ({class, union}_decl::get_pretty_representation): Use the flat representation of the class or union even for internal purposes. * tests/data/test-annotate/libtest23.so.abi: Adjust. * tests/data/test-diff-dwarf/PR25058-liblttng-ctl-report-1.txt: Likewise. * tests/data/test-diff-filter/test30-pr18904-rvalueref-report0.txt: Likewise. * tests/data/test-diff-filter/test30-pr18904-rvalueref-report1.txt: Likewise. * tests/data/test-diff-filter/test30-pr18904-rvalueref-report2.txt: Likewise. * tests/data/test-diff-filter/test35-pr18754-no-added-syms-report-0.txt: Likewise. * tests/data/test-diff-pkg/spice-server-0.12.4-19.el7.x86_64-0.12.8-1.el7.x86_64-report-2.txt: Likewise. * tests/data/test-read-dwarf/PR25007-sdhci.ko.abi: Likewise. * tests/data/test-read-dwarf/libtest23.so.abi: Likewise. * tests/data/test-read-dwarf/test11-pr18828.so.abi: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
Giuliano Procida
|
0bd4b93517 |
DWARF: track chained DIE declaration-only status
Bug 26297: Possible misinterpretation of DW_AT_declaration via DW_AT_specification A DIE representing a definition can refer to the DIE that represents the matching declaration by using the DW_AT_specification attribute. A similar situation exists for a cloned entity (like a cloned variable or function) where the DW_AT_abstract_origin points to the original entity. Usually, to get the union of the attributes for a given definition DIE, we also need to gather the attributes carried by the declaration (or original) DIE accompanying the current definition DIE. For the "is_declaration" attribute however, we should only look at the current (definition) DIE at hand. Said otherwise, we should not follow declaration/origin link when we want to know if a given entity is declaration-only. Thus, this commit causes the DWARF reader to only consider a DIE to be "declaration only" if all DIEs in the chain leading to it have the DW_AT_declaration attribute set. It is a follow-up commit to a change making die_is_declaration_only examine just the immediate DIE. The responsibility of tracking the cumulative declaration-only status of DIEs falls on build_ir_node_from_die which is the function that makes recursive calls to itself on encountering a DW_AT_specification or DW_AT_abstract_origin link. Various other functions that would have previously called die_is_declaration_only are modified so that get the cumulative value for this flag, rather than just examing the DIE they are given. This change eliminates a lot of spurious declaration-only types in ABI output and may also prevent the same, particularly when anonymous, from confusing libabigail's type equality and canonicalisation logic. * src/abg-dwarf-reader.cc (add_or_update_class_type): Add an is_declaration_only argument. Use this in favour of the die_is_declaration_only helper function. (add_or_update_union_type): Ditto. (function_is_suppressed): Ditto. (build_or_get_fn_decl_if_not_suppressed): Ditto. (build_enum_type): Ditto. (build_ir_node_from_die): To the main overload, add is_declaration_only argument and default this to true. Update this to false if the given DIE is not declaration only and pass this on in recusrive calls and calls to build_enum_type, add_or_update_union_type, add_or_update_class_type and build_or_get_fn_decl_if_not_suppressed. * tests/data/test-annotate/test17-pr19027.so.abi: Update test. This is mostly the removal of is-declaration-only attributes, removal of unreachable parts of the type graph and type id renumbering. * tests/data/test-annotate/test18-pr19037-libvtkRenderingLIC-6.1.so.abi: Likewise. * tests/data/test-annotate/test19-pr19023-libtcmalloc_and_profiler.so.abi: Likewise. * tests/data/test-annotate/test20-pr19025-libvtkParallelCore-6.1.so.abi: Likewise. * tests/data/test-diff-dwarf-abixml/test0-pr19026-libvtkIOSQL-6.1.so.1-report-0.txt: Likewise. * tests/data/test-read-dwarf/test17-pr19027.so.abi: Likewise. * tests/data/test-read-dwarf/test18-pr19037-libvtkRenderingLIC-6.1.so.abi: Likewise. * tests/data/test-read-dwarf/test19-pr19023-libtcmalloc_and_profiler.so.abi: Likewise. * tests/data/test-read-dwarf/test20-pr19025-libvtkParallelCore-6.1.so.abi: Likewise. Signed-off-by: Giuliano Procida <gprocida@google.com> Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
Giuliano Procida
|
386fede9ce |
DWARF: look up DW_AT_declaration non-recursively
Bug 26297: Possible misinterpretation of DW_AT_declaration via DW_AT_specification The DWARF attribute DW_AT_declaration indicates that a DIE is "declaration only". DWARF DIEs can be linked with DW_AT_specification and DW_AT_abstract_origin attributes, effectively combining them. A lone DW_AT_declaration in a chain of such DIEs should not render the whole chain declaration only. The function die_is_declaration_only currently traverses such links in search of the attribute which precludes being able to check for the attribute at each DIE in the chain and some DIEs are mistakenly treated as declaration-only by the DWARF reader. This commit changes die_is_declaration_only to examine the given DIE only. It extends the die_flag_attribute function so that it can perform a direct as well as a recursive attribute search. The function die_die_attribute's 'look_thru_abstract_origin' argument is renamed to 'recursively' to match. A following commit will change the DWARF reader to ensure it takes note of the declaration-only status of all DIEs in a chain. * src/abg-dwarf-reader.cc (die_die_attribute): Rename 'look_thru_abstract_origin' argument to 'recursively' and mention DW_AT_specification in its doc comment. Remove stale comment for non-existent argument. Simplify code with the help of the ternary operator. (die_flag_attribute): Add recursively argument, defaulted to true. If this is false, look for attribute using dwarf_attr rather than dwarf_attr_integrate. (die_is_declaration_only): Call die_flag_attribute specifying non-recursive attribute search. * tests/data/test-annotate/test15-pr18892.so.abi: Update tests. This is mostly the removal of unreachable parts of the type graph and type id renumbering. * tests/data/test-annotate/test18-pr19037-libvtkRenderingLIC-6.1.so.abi: Likewise. * tests/data/test-annotate/test19-pr19023-libtcmalloc_and_profiler.so.abi: Likewise. * tests/data/test-diff-dwarf-abixml/test0-pr19026-libvtkIOSQL-6.1.so.1-report-0.txt: Likewise. * tests/data/test-read-dwarf/test15-pr18892.so.abi: Likewise. * tests/data/test-read-dwarf/test18-pr19037-libvtkRenderingLIC-6.1.so.abi: Likewise. * tests/data/test-read-dwarf/test19-pr19023-libtcmalloc_and_profiler.so.abi: Likewise. * tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi: Likewise. Signed-off-by: Giuliano Procida <gprocida@google.com> |
||
Giuliano Procida
|
dfd410c585 |
Fix maybe_report_data_members_replaced_by_anon_dm
The function maybe_report_data_members_replaced_by_anon_dm has a bug and some minor issues. This commit tidies these up. The function came to my attention when a broken equality test triggered an infinite loop. The issues were: - dms_replaced_by_same_anon_dm declared outside loop, gets reused - self-comparison of first decl, potential infinite loop - anonymous_data_member, assigned but not used - two iterators i, j used, when one would suffice The first issue results in incorrect diff reports if data members in a structure are replaced by more than one anonymous data member. This commit adds additional test cases for this, following the pattern used for the existing PR25661 ones. The second issue only affects behaviour if equality is defined inconsistently with object identity. * src/abg-reporter-priv.cc (maybe_report_data_members_replaced_by_anon_dm): Move declarations of anonymous_data_member and dms_replaced_by_same_anon_dm into inner loop. Use anonymous_data_member for testing and reporting, allowing iterators i and j to be replaced by just iterator i. Push first decl onto dms_replaced_by_same_anon_dm unconditionally and move control flow logic into loop condition. * tests/data/Makefile.am: Add new test cases. * tests/data/test-diff-filter/test-PR25661-7-report-1.txt: New test case file. * tests/data/test-diff-filter/test-PR25661-7-report-2.txt: Likewise. * tests/data/test-diff-filter/test-PR25661-7-report-3.txt: Likewise. * tests/data/test-diff-filter/test-PR25661-7-report-4.txt: Likewise. * tests/data/test-diff-filter/test-PR25661-7-v0.c: Likewise. * tests/data/test-diff-filter/test-PR25661-7-v0.o: Likewise. * tests/data/test-diff-filter/test-PR25661-7-v1.c: Likewise. * tests/data/test-diff-filter/test-PR25661-7-v1.o: Likewise. * tests/test-diff-filter.cc: Call new test cases. Signed-off-by: Giuliano Procida <gprocida@google.com> |
||
Giuliano Procida
|
d5576ba30a |
Fix decl_base comparison function
When two decl_base ojects are compared, there are both fast and slow paths to the name comparison. The latter is roughly equivalent to comparing names after applying the regex s/(__anonymous_(?:struct|union|enum)__)\d+/\1/g to the names before comparing them while the former is a straight string comparison with some tweaks for detecting anonymous types. The slow path is taken care of by the helper function tools_utils::decl_names_equal but unfortunately, there is a missing negation of the returned bool. This commit fixes this and updates the few affected tests. Rather than just adding a '!', this commit replaces the negative decls_are_different with a positive decls_are_same. I spent far too long staring at the code before I spotted the mistake and having positively-named things improves readability. The same helper function is also called by has_harmless_name_change and that should be reviewed as well. * src/abg-ir.cc (equals): In the decl_base overload, note that the value returned by decl_names_equal should be negated and replace decls_are_different with decls_are_same, negating all occurrences. * tests/data/test-diff-dwarf/PR25058-liblttng-ctl-report-1.txt: Update tests, removing some spurious anonymous union name change. * tests/data/test-diff-filter/test33-report-0.txt: Diff now completely empty. * tests/data/test-diff-pkg/elfutils-libs-0.170-4.el7.x86_64-multiple-sym-vers-report-0.txt: 3 functions previously considered to have harmless changes are now deemed to have no changes. * tests/data/test-diff-pkg/spice-server-0.12.4-19.el7.x86_64-0.12.8-1.el7.x86_64-report-2.txt: 1 struct RedStore data member previously considered to have harmless changes is now deemed to have no changes. * tests/data/test-read-dwarf/test9-pr18818-clang.so.abi: One instance of an anonymous struct removed and a typedef repointed at another existing instance; many type ids renumbered. Signed-off-by: Giuliano Procida <gprocida@google.com> Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
Dodji Seketeli
|
817a2755bc |
Bug 26261 - Fix logic for canonicalizing DW_TAG_subroutine_type DIEs
In the function compare_dies, the handling of DW_TAG_subroutine_type was unfinished. This DIE represents function types pointed-to by function pointer. It doesn't represent the type of a "real" function type like the abigail::ir::function_type would. The represent more an interface to a function, which a pointer can point to or which can be used to issue a call. So intended idea is that compare_dies compares two DIEs of the DW_TAG_subroutine_type and DW_TAG_subprogram kind (the later represents real function definitions) among other kinds, structurally, but by trying to optimize for speed, for the purpose of canonicalizing DIEs even before type canonicalization happens at the libabigail IR level. This is critical to save space (and time) by doing DIE de-duplication on huge binaries. This patch finishes to implement the comparison for DW_TAG_subroutine_type and comes with a carefully crafted test case that hits that code path. * src/abg-dwarf-reader.cc (compare_dies): Get out early if we are are in the middle of a potential recursive comparison of function types. Likewise if we detect that the two function types have different textual representations, linkage names, or have a the same textual representation, linkage names and are defined in the same translation unit. * tests/data/test-read-dwarf/PR26261/PR26261-exe: New test binary input file. * tests/data/test-read-dwarf/PR26261/PR26261-exe.abi: New reference test output file. * tests/data/test-read-dwarf/PR26261/PR26261-main.c: Source code of the binary above. * tests/data/test-read-dwarf/PR26261/PR26261-obj{a,b}.{c,h}: Likewise. * tests/data/test-read-dwarf/PR26261/Makefile: Makefile to build the exe out of the source files. * tests/data/Makefile.am: Add the new test input files to source distribution. * tests/test-read-dwarf.cc (in_out_spec): Add the binary test input above to the test harness. Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
Giuliano Procida
|
ca956fb48e |
abg-writer.cc: Fix indentation of XML output
The XML writer produces valid XML. However, it differs in a few respects from that obtained with xmllint --format. - there is no XML declaration at the start - attributes use single quotes rather than double quotes - indentation is mostly 2 spaces but this is broken in places This commit fixes the last of these issues as it actually causes readability issues when examining diffs. It also does this for every test XML file, whether used as input, compared against output or not used at all, to match what xmllint --format would do. * src/abg-writer.cc (write_canonical_types_of_scope): Do not add additional indentation. (write_translation_unit): Pass additional indentation to write_canonical_types_of_scope. (write_class_decl): Ensure optional annotations of base classes have the same indentation as the base classes themselves. * tests/data/test-annotate/libtest23.so.abi: Fix indentation. * tests/data/test-annotate/libtest24-drop-fns-2.so.abi: Ditto. * tests/data/test-annotate/libtest24-drop-fns.so.abi: Ditto. * tests/data/test-annotate/test-anonymous-members-0.o.abi: Ditto. * tests/data/test-annotate/test1.abi: Ditto. * tests/data/test-annotate/test14-pr18893.so.abi: Ditto. * tests/data/test-annotate/test15-pr18892.so.abi: Ditto. * tests/data/test-annotate/test17-pr19027.so.abi: Ditto. * tests/data/test-annotate/test18-pr19037-libvtkRenderingLIC-6.1.so.abi: Ditto. * tests/data/test-annotate/test19-pr19023-libtcmalloc_and_profiler.so.abi: Ditto. * tests/data/test-annotate/test20-pr19025-libvtkParallelCore-6.1.so.abi: Ditto. * tests/data/test-annotate/test21-pr19092.so.abi: Ditto. * tests/data/test-diff-suppr/test45-abi-wl.xml: Ditto. * tests/data/test-diff-suppr/test45-abi.xml: Ditto. * tests/data/test-diff-suppr/test46-PR25128-base.xml: Ditto. * tests/data/test-diff-suppr/test46-PR25128-new.xml: Ditto. * tests/data/test-read-dwarf/PR22015-libboost_iostreams.so.abi: Ditto. * tests/data/test-read-dwarf/PR22122-libftdc.so.abi: Ditto. * tests/data/test-read-dwarf/libtest23.so.abi: Ditto. * tests/data/test-read-dwarf/libtest24-drop-fns-2.so.abi: Ditto. * tests/data/test-read-dwarf/libtest24-drop-fns.so.abi: Ditto. * tests/data/test-read-dwarf/test1.abi: Ditto. * tests/data/test-read-dwarf/test1.hash.abi: Ditto. * tests/data/test-read-dwarf/test10-pr18818-gcc.so.abi: Ditto. * tests/data/test-read-dwarf/test11-pr18828.so.abi: Ditto. * tests/data/test-read-dwarf/test12-pr18844.so.abi: Ditto. * tests/data/test-read-dwarf/test14-pr18893.so.abi: Ditto. * tests/data/test-read-dwarf/test15-pr18892.so.abi: Ditto. * tests/data/test-read-dwarf/test16-pr18904.so.abi: Ditto. * tests/data/test-read-dwarf/test17-pr19027.so.abi: Ditto. * tests/data/test-read-dwarf/test18-pr19037-libvtkRenderingLIC-6.1.so.abi: Ditto. * tests/data/test-read-dwarf/test19-pr19023-libtcmalloc_and_profiler.so.abi: Ditto. * tests/data/test-read-dwarf/test20-pr19025-libvtkParallelCore-6.1.so.abi: Ditto. * tests/data/test-read-dwarf/test21-pr19092.so.abi: Ditto. * tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi: Ditto. * tests/data/test-read-dwarf/test9-pr18818-clang.so.abi: Ditto. * tests/data/test-read-write/test10.xml: Ditto. * tests/data/test-read-write/test15.xml: Ditto. * tests/data/test-read-write/test21.xml: Ditto. * tests/data/test-read-write/test28-without-std-fns-ref.xml: Ditto. * tests/data/test-read-write/test28-without-std-vars-ref.xml: Ditto. Signed-off-by: Giuliano Procida <gprocida@google.com> |
||
Giuliano Procida
|
6579ea4d54 |
Remove ABI XML test data file blank lines
Following a change which eliminated the output of extra blank lines in XML output, it now also makes sense to remove such blank lines from saved generated XML files. This commit does this. * tests/data/test-abidiff/test-PR18166-libtirpc.so.abi: Remove blank lines. * tests/data/test-diff-dwarf-abixml/PR25409-librte_bus_dpaa.so.20.0.abi: Ditto. * tests/data/test-diff-dwarf-abixml/test0-pr19026-libvtkIOSQL-6.1.so.1.abi: Ditto. * tests/data/test-diff-suppr/test45-abi-wl.xml: Ditto. * tests/data/test-diff-suppr/test45-abi.xml: Ditto. * tests/data/test-diff-suppr/test46-PR25128-base.xml: Ditto. * tests/data/test-diff-suppr/test46-PR25128-new.xml: Ditto. Signed-off-by: Giuliano Procida <gprocida@google.com> |
||
Giuliano Procida
|
697347e402 |
Fix corpus_diff::has_net_changes for --leaf-changes-only mode
This function was not aware of --leaf-changes-only mode. - Stats counters for changed variables and types have different names in the different modes. - Net leaf type changes were not included in leaf mode. For some inputs, this resulted in abidiff producing an empty report but returning a non-zero exit status in --leaf-changes-only mode. For other inputs the combination of both issues still resulted in the correct return code. This included the following test-abidiff-exit test cases: - test-leaf-peeling - test-leaf2 - test-no-stray-comma This patch makes corpus_diff::has_net_changes mirror emit_diff_stats, modulo flags like --non-reachable-types which if absent can still result in discrepancies between output and return code. To achieve this in a more maintainable way, the patch introduces a new interface reporter_base::diff_has_net_changes. That interface is implemented by all current reporters. Each reporter focuses on its own particularities to provide the required behavious. Then corpus_diff:has_net_changes just has to invoke reporter_base::diff_has_net_changes on the reporter that is currently in used. The tests below verify that the exit code is zero when all the changes between the test files are suppressed. * include/abg-reporter.h ({reporter_base, default_reporter, leaf_reporter}::diff_has_net_changes): Add new virtual function. This breaks binary compatibility but should conserve source compatibility. * src/abg-default-reporter.cc (default_reporter::diff_has_net_changes): Define new member function. * src/abg-leaf-reporter.cc (leaf_reporter::diff_has_net_changes): Likewise. * src/abg-comparison.cc (corpus_diff::has_net_changes): Invoke reporter_base::diff_has_net_changes on the current reporter, rather than trying to handle all the different kinds of reporters here. (corpus_diff::priv::apply_filters_and_compute_diff_stats): Add a TODO to possibly delegate the implementation of this function to the reporters. * tests/data/Makefile.am: Add new test case files. * tests/data/test-abidiff-exit/test-net-change-report0.txt: Normal mode, nothing suppressed. * tests/data/test-abidiff-exit/test-net-change-report1.txt: Normal mode, everything suppressed. * tests/data/test-abidiff-exit/test-net-change-report2.txt: Leaf mode, nothing suppressed. * tests/data/test-abidiff-exit/test-net-change-report3.txt: Leaf mode, everything suppressions. * tests/data/test-abidiff-exit/test-net-change-v0.c: Test file * tests/data/test-abidiff-exit/test-net-change-v0.o: Test file * tests/data/test-abidiff-exit/test-net-change-v1.c: Test file * tests/data/test-abidiff-exit/test-net-change-v1.o: Test file * tests/data/test-abidiff-exit/test-net-change.abignore: This suppresses changes for all variables, functions and types in the test files, except for the 'victim' function. * tests/test-abidiff-exit.cc: Run new test cases. Reviewed-by: Matthias Maennich <maennich@google.com> Signed-off-by: Giuliano Procida <gprocida@google.com> Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
Giuliano Procida
|
e0d29a919d |
reporter: Fix report whitespace typos.
The patch fixes two minor formatting typos. * src/abg-reporter-priv.cc (represent): Add missing space to string split across two lines in certain anonymous data member diffs. * src/abg-default-reporter.cc (report): In the array_diff overload, eliminate trailing space at end of line. * tests/data/test-diff-dwarf/test10-report.txt: Delete trailing whitespace. * tests/data/test-diff-filter/test24-compatible-vars-report-1.txt: Ditto. * tests/data/test-diff-pkg/libICE-1.0.6-1.el6.x86_64.rpm--libICE-1.0.9-2.el7.x86_64.rpm-report-0.txt: Ditto. * tests/data/test-diff-pkg/libcdio-0.94-1.fc26.x86_64--libcdio-0.94-2.fc26.x86_64-report.1.txt: Ditto. * tests/data/test-diff-pkg/tbb-4.1-9.20130314.fc22.x86_64--tbb-4.3-3.20141204.fc23.x86_64-report-0.txt: Ditto. * tests/data/test-diff-pkg/spice-server-0.12.4-19.el7.x86_64-0.12.8-1.el7.x86_64-report-2.txt: Ditto. Signed-off-by: Giuliano Procida <gprocida@google.com> Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
Giuliano Procida
|
f0bf868022 |
abg-writer.cc: Clean up new line emission.
The XML writer has a few different styles of new line handling in different places. Some functions are responsible for line termination, others are not and there is bespoke logic and state variables in a few places. Extra or missing newlines should have no impact on the semantics of any given ABI file but they do affect textual diffs and diff statistics. By insisting the XML emitted should have exactly one XML tag (or comment) per line, we can simplify the code and make it more composable. This commit does this, yielding a modest reduction in code size and eliminating all blank lines in XML output (7127 blank lines in current tests). The commit also fixes some code whitespace. * src/abg-writer.cc (annotate): In the function_decl::parameter_sptr overload, fix code whitespace. (write_decl_in_scope): Remove wrote_context state variable and associated logic; emit new line unconditionally after end of XML tags and nowhere else. (write_canonical_types_of_scope): Emit new line after end of XML comment and nowhere else. (write_translation_unit): Emit new line after end of XML tags and nowhere else. (write_type_decl): Likewise. (write_namespace_decl): Likewise. (write_qualified_type_def): Emit new line after end of XML tag. (write_pointer_type_def): Likewise. (write_reference_type_def): Likewise. (write_array_type_def): Emit new line after end of XML tags and nowhere else. (write_enum_type_decl): Emit new line after end of XML tag. (write_elf_symbol): Likewise. (write_elf_symbols_table): Emit no new lines. (write_elf_needed): Emit new line unconditionally after end of XML tags. (write_typedef_decl): Emit new line after end of XML tag. (write_var_decl): Emit new line after end of XML tag. (write_function_decl): Likewise. (write_function_type): Fold two output statements into one; emit new line after end of XML tag. (write_class_decl_opening_tag): Emit new line unconditionally after end of XML tags and simplify empty element tag logic. (write_union_decl_opening_tag): Likewise. (write_class_decl): Emit new line after end of XML tag and nowhere else. (write_union_decl): Likewise. (write_member_type_opening_tag): Emit new line after end of XML tag. (write_member_type): Emit new lines only after XML tags. (write_type_tparameter): Emit new line after XML tag. (write_non_type_tparameter): Likewise. (write_template_tparameter): Emit new line after XML tag and nowhere else. (write_type_composition): Likewise. (write_template_parameters): Emit no new lines. (write_function_tdecl): Emit new line after XML tag and nowhere else. (write_class_tdecl): Likewise. (write_corpus): Emit new lines only after XML tags. (dump): In the decl_base_sptr overload, don't emit final new line as this is now done by write_decl. In the var_decl_sptr overload, don't emit final new line (mistakenly done to cerr instead of o) as this is now done by write_var_decl. In the translation_unit overload, don't emit final new line as this doubles that emitted by write_translation_unit. * tests/data/test-annotate/libtest23.so.abi: Delete all blank lines. * tests/data/test-annotate/libtest24-drop-fns-2.so.abi: Ditto. * tests/data/test-annotate/libtest24-drop-fns.so.abi: Ditto. * tests/data/test-annotate/test-anonymous-members-0.o.abi: Ditto. * tests/data/test-annotate/test1.abi: Ditto. * tests/data/test-annotate/test13-pr18894.so.abi: Ditto. * tests/data/test-annotate/test14-pr18893.so.abi: Ditto. * tests/data/test-annotate/test15-pr18892.so.abi: Ditto. * tests/data/test-annotate/test17-pr19027.so.abi: Ditto. * tests/data/test-annotate/test18-pr19037-libvtkRenderingLIC-6.1.so.abi: Ditto. * tests/data/test-annotate/test19-pr19023-libtcmalloc_and_profiler.so.abi: Ditto. * tests/data/test-annotate/test20-pr19025-libvtkParallelCore-6.1.so.abi: Ditto. * tests/data/test-annotate/test21-pr19092.so.abi: Ditto. * tests/data/test-annotate/test7.so.abi: Ditto. * tests/data/test-read-dwarf/PR22015-libboost_iostreams.so.abi: Ditto. * tests/data/test-read-dwarf/PR22122-libftdc.so.abi: Ditto. * tests/data/test-read-dwarf/PR25007-sdhci.ko.abi: Ditto. * tests/data/test-read-dwarf/PR25042-libgdbm-clang-dwarf5.so.6.0.0.abi: Ditto. * tests/data/test-read-dwarf/libtest23.so.abi: Ditto. * tests/data/test-read-dwarf/libtest24-drop-fns-2.so.abi: Ditto. * tests/data/test-read-dwarf/libtest24-drop-fns.so.abi: Ditto. * tests/data/test-read-dwarf/test1.abi: Ditto. * tests/data/test-read-dwarf/test1.hash.abi: Ditto. * tests/data/test-read-dwarf/test10-pr18818-gcc.so.abi: Ditto. * tests/data/test-read-dwarf/test11-pr18828.so.abi: Ditto. * tests/data/test-read-dwarf/test12-pr18844.so.abi: Ditto. * tests/data/test-read-dwarf/test13-pr18894.so.abi: Ditto. * tests/data/test-read-dwarf/test14-pr18893.so.abi: Ditto. * tests/data/test-read-dwarf/test15-pr18892.so.abi: Ditto. * tests/data/test-read-dwarf/test16-pr18904.so.abi: Ditto. * tests/data/test-read-dwarf/test17-pr19027.so.abi: Ditto. * tests/data/test-read-dwarf/test18-pr19037-libvtkRenderingLIC-6.1.so.abi: Ditto. * tests/data/test-read-dwarf/test19-pr19023-libtcmalloc_and_profiler.so.abi: Ditto. * tests/data/test-read-dwarf/test20-pr19025-libvtkParallelCore-6.1.so.abi: Ditto. * tests/data/test-read-dwarf/test21-pr19092.so.abi: Ditto. * tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi: Ditto. * tests/data/test-read-dwarf/test7.so.abi: Ditto. * tests/data/test-read-dwarf/test7.so.hash.abi: Ditto. * tests/data/test-read-dwarf/test9-pr18818-clang.so.abi: Ditto. * tests/data/test-read-write/test10.xml: Ditto. * tests/data/test-read-write/test15.xml: Ditto. * tests/data/test-read-write/test21.xml: Ditto. * tests/data/test-read-write/test25.xml: Ditto. * tests/data/test-read-write/test28-without-std-fns-ref.xml: Ditto. * tests/data/test-read-write/test28-without-std-vars-ref.xml: Ditto. Signed-off-by: Giuliano Procida <gprocida@google.com> Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
Giuliano Procida
|
8e8e0778f2 |
Use pointers not strings in type graph comparison.
During structural comparison of types there is the possibilitiy of infinite recursion as types can have self-references and there can be more elaborate mutual references between them. The current comparison algorithm keeps track of currently seen (struct and function) types by name. This causes earlier caching of names than is needed and, more significantly, may result in types comparing equal unexpectedly. This commit switches to storing their addresses instead. This change affects some tests which show more diffs than previously. src/abg-ir.cc: (environment::priv): Change types of classes_being_compared_ and fn_types_being_compared_ to be simple sets of pointers. (function_type::priv::mark_as_being_compared): Just add address to set. (function_type::priv::unmark_as_being_compared): Just remove address from set. (function_type::priv::comparison_started): Just look up address in set. (class_or_union::priv::mark_as_being_compared): Just add address to set. (class_or_union::priv::unmark_as_being_compared): Just remove address from set. (class_or_union::priv::comparison_started): Just look up address in set. * tests/data/test-diff-dwarf/PR25058-liblttng-ctl-report-1.txt: Update. * tests/data/test-diff-pkg/elfutils-libs-0.170-4.el7.x86_64-multiple-sym-vers-report-0.txt: Update. * tests/data/test-diff-pkg/spice-server-0.12.4-19.el7.x86_64-0.12.8-1.el7.x86_64-report-2.txt: Update. * tests/data/test-diff-pkg/spice-server-0.12.4-19.el7.x86_64-0.12.8-1.el7.x86_64-report-3.txt: Update. Signed-off-by: Giuliano Procida <gprocida@google.com> |
||
Giuliano Procida
|
b0f98180e0 |
Add tests for declaration-only enums.
* tests/data/test-abidiff-exit/test-decl-enum-report-2.txt: Add new test reference output. * tests/data/test-abidiff-exit/test-decl-enum-report-3.txt: Likewise. * tests/data/test-abidiff-exit/test-decl-enum-report.txt: Likewise. * tests/data/test-abidiff-exit/test-decl-enum-v{0,1}.c: Add source code for the binaries below. * tests/data/test-abidiff-exit/test-decl-enum-v{0,1}.o: Add new binary test inputs. * tests/data/Makefile.am: Add the new files above to source distribution. * tests/test-abidiff-exit.cc: Add the test inputs above to the test harness. Signed-off-by: Giuliano Procida <gprocida@google.com> Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
Giuliano Procida
|
6295ff70ef |
Add declaration-only enums to XML reader/writer.
* src/abg-reader.cc (build_enum_type_decl): Detect a declaration-only enum and flag it as such. (build_type_decl): Support reading the "is-declaration" attribute. (build_class_decl): Adjust. * src/abg-writer.cc (write_is_declaration_only): Renamed write_class_or_union_is_declaration_only into this. (write_enum_is_declaration_only): Remove. (write_type_decl, write_enum_type_decl) (write_class_decl_opening_tag, write_union_decl_opening_tag): Use write_is_declaration_only. * tests/data/test-read-dwarf/PR22122-libftdc.so.abi: Adjust. * tests/data/test-read-dwarf/test12-pr18844.so.abi: Likewise. * tests/data/test-read-dwarf/test9-pr18818-clang.so.abi: Likewise. Signed-off-by: Giuliano Procida <gprocida@google.com> Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
Dodji Seketeli
|
346e88dd76 |
Bug 26135 - Wrong linkage name causes anonymous classes miscomparison
When comparing decls, the overload of the 'equals' function for instances of decl_base compares their linkage names. If they are different, then the decls are generally considered different. Class declarations (and definitions) also use the 'equals' function referred to above. So when two classes have different linkage names, they are always considered different. Now let's consider the case of an anonymous class. It doesn't have any user-provided name, by definition. Libabigail does, however, assigns it an internal name for various (internal) purposes. That internal name is generally ignored for the purpose of (anonymous) type comparison. So by design, two anonymous classes can have different internal anonymous names and yet still happen to be equal. The root issue in this problem report is that by default, the linkage name of a class is set to its name. And when that class is anonymous, its internal name is used as its linkage name. Oops. That leads to anonymous classes being wrongly considered different. This patch fixes the issue by providing additional constructors for a class type to avoid using the internal anonymous name as its linkage name. Note that the same issue is present for unions so the patch does the a similar thing for union types. Enums are properly handled so we don't need to do anything in that regard. For good measure, the patch also adds an assert to type_base::get_canonical_types_for to ensure that anonymous class or union types don't have linkage names for now. * include/abg-ir.h (class_decl::class_decl): Add two overloads that take the "is_anonymous" flag. (union_decl::union_decl): Likewise. * src/abg-ir.cc (class_decl::class_decl): Define two overloads that take the "is_anonymous" flag and set the linkage name accordingly. (union_decl::union_decl): Likewise. (type_base::get_canonical_type_for): Assert that an anonymous class or union can't have a linkage name for now. * src/abg-dwarf-reader.cc (add_or_update_class_type) (add_or_update_union_type): Use a new overload for the constuctor of {class, union}_decl and set the "is_anonymous" flag. Don't use decl_base::set_is_anonymous anymore. * src/abg-reader.cc (build_class_decl, build_union_decl): Likewise. * tests/data/test-read-dwarf/PR22122-libftdc.so.abi: Adjust. * tests/data/test-read-dwarf/test12-pr18844.so.abi: Likewise. * tests/data/test-read-dwarf/test9-pr18818-clang.so.abi: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
Dodji Seketeli
|
a5d02b95a6 |
Bug 26127 - abidw --annotate emits incomplete function types
When we get the qualified name of a pointer type, the result is cached so that subsequent invocations of the getter yields a faster result. When the pointed-to type is not yet fully constructed at the time of the first invocation of the getter of the qualified name, what is cached is the name of the pointer to a non-yet fully qualified type. Then after the pointed-to type is fully constructed (and canonicalized), the pointer type also becomes canonicalized (in that order) and thus, the cache needs to be invalidated so that the qualified name of the pointer to the fully qualified type is cached again by a subsequent invocation of the getter. The problem in this problem report is that the cache doesn't get invalidated when the pointer type is canonicalized. This patch fixes that. A similar issue exists with reference and qualified types so the patch addresses it for those types as well. * include/abg-ir.h (decl_base::clear_qualified_name): Declare new protected member function. ({pointer_type_def, reference_type_def, qualified_type_def, function_type}::on_canonical_type_set): Declare virtual member functions. * src/abg-ir.cc (decl_base::clear_qualified_name): Define new protected member function. ({pointer_type_def, reference_type_def, qualified_type_def, function_type}::on_canonical_type_set): Define virtual member functions. * tests/data/test-annotate/test17-pr19027.so.abi: Adjust. * tests/data/test-annotate/test18-pr19037-libvtkRenderingLIC-6.1.so.abi: Likewise. * tests/data/test-annotate/test20-pr19025-libvtkParallelCore-6.1.so.abi: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
Giuliano Procida
|
84fc161a0b |
Fix bug that suppressed DWARF read tests.
Commit |
||
Giuliano Procida
|
29de666641 |
abg-writer: Add support for stable hash type ids.
The type ids currently emitted by the XML writer are simply type-id-1, type-id-2 etc. Additions or removals of types early in this sequence result in cascading changes to many other XML elements. This commit adds support for stable type ids in the form of hashes of libabigail's internal type names. On fairly rare occasions (typically involving unnamed types), the names of two distinct types can be the same. In any case, if there is a hash collision the XML writer will find the next unused id and so preserve uniqueness. Diffs between large XML files produced using --type-id-style hash will be much smaller and easier to review. This also commit adds some test cases to verify that the hashing is actually stable across architectures. * doc/manuals/abidw.rst: Replace stray documentation of --named-type-ids with documention of new --type-id-style option. * include/abg-writer.h (type_id_style_kind): Add new enum. (set_type_id_style): Add new write_context setter. (set_common_options): Set type id style in write context. * include/abg-hash.h (fnv_hash): Declare new 32-bit FNV-1a hash function in abigail::hashing namespace. * src/abg-hash.h (fnv_hash): Define new 32-bit FNV-1a hash function in abigail::hashing namespace. * src/abg-writer.cc (write_context): Add m_type_id_style member to record type style to use, defaulting to SEQUENCE_TYPE_ID_STYLE; add m_used_type_id_hashes to record already-used hashes. (write_context::get_type_id_style): Add new getter. (write_context::set_type_id_style): Add new setter. (get_id_for_type): Add support for HASH_TYPE_ID_STYLE style. (set_type_id_style): Add new helper function. * tools/abidw.cc (options): Add type_id_style member. (display_usage): Add description of --type-id-style option. (parse_command_line): Parse --type-id-style option. * tests/data/Makefile.am: Add new hash type id ABI files. * tests/test-read-dwarf.cc: (InOutSpec): Add type_id_style member. (in_out_specs): Set type_id_style to SEQUENCE_TYPE_ID_STYLE in existing test specifications. Duplicate first 9 test cases with type_id_style set to HASH_TYPE_ID_STYLE. * tests/data/test-read-dwarf/test0.hash.abi: New ABI XML file with hash type ids. * tests/data/test-read-dwarf/test1.hash.abi: Ditto. * tests/data/test-read-dwarf/test2.so.hash.abi: Ditto. * tests/data/test-read-dwarf/test3.so.hash.abi: Ditto. * tests/data/test-read-dwarf/test4.so.hash.abi: Ditto. * tests/data/test-read-dwarf/test5.o.hash.abi: Ditto. * tests/data/test-read-dwarf/test6.so.hash.abi: Ditto. * tests/data/test-read-dwarf/test7.so.hash.abi: Ditto. * tests/data/test-read-dwarf/test8-qualified-this-pointer.so.hash.abi: Ditto. Signed-off-by: Giuliano Procida <gprocida@google.com> Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
Matthias Maennich
|
72eb3fe482 |
tests: Add kernel symtab test suite
Add (Catch based) test suite to test kernel symbol table (ksymtab) reading through the result persisted in abigail::corpus. The test cases are created through simple kernel module C source files targeting the desired properties ((gpl) exported / local functions / variables). The kernel binaries are built without debug information to keep them reasonably small and reproducible. That is just enough sufficient to analyze ksymtabs. The Makefile that comes with them recreates the test cases from the sources, given a kernel source tree with the appropriate version, e.g. make KDIR=/path/to/4.14 This covers ksymtab reading and ensuring we detect the kernel binary correctly. The kernel versions are selected based on features introduced into the Linux kernel that affect the ksymtab representation. - Linux v4.14 - reasonably old kernel to start with (actually v4.14.180) - Linux v4.19 - first version having position relative relocations (PREL) in ksymtab entries on some platforms (actually v4.19.123) - Linux v5.4 - first version having symbol namespaces (actually v5.4.41) - Linux v5.6 - latest released stable kernel as of writing (actually v5.6.13) * tests/data/Makefile.am: add new test data for runtestsymtab * tests/data/test-symtab/kernel-4.14/Makefile: New test case makefile. * tests/data/test-symtab/kernel-4.14/empty.c: Likewise. * tests/data/test-symtab/kernel-4.14/one_of_each.c: Likewise. * tests/data/test-symtab/kernel-4.14/single_function.c: Likewise. * tests/data/test-symtab/kernel-4.14/single_function_gpl.c: Likewise. * tests/data/test-symtab/kernel-4.14/single_variable.c: Likewise. * tests/data/test-symtab/kernel-4.14/single_variable_gpl.c: Likewise. * tests/data/test-symtab/kernel-4.14/empty.ko: New test data. * tests/data/test-symtab/kernel-4.14/one_of_each.ko: Likewise. * tests/data/test-symtab/kernel-4.14/single_function.ko: Likewise. * tests/data/test-symtab/kernel-4.14/single_function_gpl.ko: Likewise. * tests/data/test-symtab/kernel-4.14/single_variable.ko: Likewise. * tests/data/test-symtab/kernel-4.14/single_variable_gpl.ko: Likewise. * tests/data/test-symtab/kernel-4.19/Makefile: New test case makefile. * tests/data/test-symtab/kernel-4.19/empty.c: Likewise. * tests/data/test-symtab/kernel-4.19/one_of_each.c: Likewise. * tests/data/test-symtab/kernel-4.19/single_function.c: Likewise. * tests/data/test-symtab/kernel-4.19/single_function_gpl.c: Likewise. * tests/data/test-symtab/kernel-4.19/single_variable.c: Likewise. * tests/data/test-symtab/kernel-4.19/single_variable_gpl.c: Likewise. * tests/data/test-symtab/kernel-4.19/empty.ko: New test data. * tests/data/test-symtab/kernel-4.19/one_of_each.ko: Likewise. * tests/data/test-symtab/kernel-4.19/single_function.ko: Likewise. * tests/data/test-symtab/kernel-4.19/single_function_gpl.ko: Likewise. * tests/data/test-symtab/kernel-4.19/single_variable.ko: Likewise. * tests/data/test-symtab/kernel-4.19/single_variable_gpl.ko: Likewise. * tests/data/test-symtab/kernel-5.4/Makefile: New test case makefile. * tests/data/test-symtab/kernel-5.4/empty.c: Likewise. * tests/data/test-symtab/kernel-5.4/one_of_each.c: Likewise. * tests/data/test-symtab/kernel-5.4/single_function.c: Likewise. * tests/data/test-symtab/kernel-5.4/single_function_gpl.c: Likewise. * tests/data/test-symtab/kernel-5.4/single_variable.c: Likewise. * tests/data/test-symtab/kernel-5.4/single_variable_gpl.c: Likewise. * tests/data/test-symtab/kernel-5.4/empty.ko: New test data. * tests/data/test-symtab/kernel-5.4/one_of_each.ko: Likewise. * tests/data/test-symtab/kernel-5.4/single_function.ko: Likewise. * tests/data/test-symtab/kernel-5.4/single_function_gpl.ko: Likewise. * tests/data/test-symtab/kernel-5.4/single_variable.ko: Likewise. * tests/data/test-symtab/kernel-5.4/single_variable_gpl.ko: Likewise. * tests/data/test-symtab/kernel-5.6/Makefile: New test case makefile. * tests/data/test-symtab/kernel-5.6/empty.c: Likewise. * tests/data/test-symtab/kernel-5.6/one_of_each.c: Likewise. * tests/data/test-symtab/kernel-5.6/single_function.c: Likewise. * tests/data/test-symtab/kernel-5.6/single_function_gpl.c: Likewise. * tests/data/test-symtab/kernel-5.6/single_variable.c: Likewise. * tests/data/test-symtab/kernel-5.6/single_variable_gpl.c: Likewise. * tests/data/test-symtab/kernel-5.6/empty.ko: New test data. * tests/data/test-symtab/kernel-5.6/one_of_each.ko: Likewise. * tests/data/test-symtab/kernel-5.6/single_function.ko: Likewise. * tests/data/test-symtab/kernel-5.6/single_function_gpl.ko: Likewise. * tests/data/test-symtab/kernel-5.6/single_variable.ko: Likewise. * tests/data/test-symtab/kernel-5.6/single_variable_gpl.ko: Likewise. * tests/data/test-symtab/kernel/Makefile: New test case source file. * tests/data/test-symtab/kernel/empty.c: Likewise. * tests/data/test-symtab/kernel/one_of_each.c: Likewise. * tests/data/test-symtab/kernel/single_function.c: Likewise. * tests/data/test-symtab/kernel/single_function_gpl.c: Likewise. * tests/data/test-symtab/kernel/single_variable.c: Likewise. * tests/data/test-symtab/kernel/single_variable_gpl.c: Likewise. * tests/test-symtab.cc: New test case to test kernel symtabs. Signed-off-by: Matthias Maennich <maennich@google.com> Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
Matthias Maennich
|
2a79ab78f4 |
tests: Add symtab test suite
Add (Catch based) test suite to test symbol table reading through the result persisted in abigail::corpus. The test cases are created through simple C source files targeting the desired properties (having an undefined/export function or both). The Makefile that comes with them recreates the test cases from the sources. This covers reading sorted_(undefined_)var|fun_symbols as well as the corresponding symbols maps accessible through the accessors of abigail::corpus. * tests/Makefile.am: add new test runtestsymtab * tests/data/Makefile.am: add new test data for runtestsymtab * tests/data/test-symtab/Makefile: Add this to build the binaries below from their source code. * tests/data/test-symtab/basic/empty.c: New test case source. * tests/data/test-symtab/basic/link_against_me.c: Likewise. * tests/data/test-symtab/basic/no_debug_info.c: Likewise. * tests/data/test-symtab/basic/one_function_one_variable.c: Likewise. * tests/data/test-symtab/basic/one_function_one_variable_undefined.c: Likewise. * tests/data/test-symtab/basic/single_function.c: Likewise. * tests/data/test-symtab/basic/single_undefined_function.c: Likewise. * tests/data/test-symtab/basic/single_undefined_variable.c: Likewise. * tests/data/test-symtab/basic/single_variable.c: Likewise. * tests/data/test-symtab/basic/empty.so: New test data, built from the Makefile above. * tests/data/test-symtab/basic/link_against_me.so: Likewise. * tests/data/test-symtab/basic/no_debug_info.so: Likewise. * tests/data/test-symtab/basic/one_function_one_variable.so: Likewise. * tests/data/test-symtab/basic/one_function_one_variable_undefined.so: Likewise. * tests/data/test-symtab/basic/single_function.so: Likewise. * tests/data/test-symtab/basic/single_undefined_function.so: Likewise. * tests/data/test-symtab/basic/single_undefined_variable.so: Likewise. * tests/data/test-symtab/basic/single_variable.so: Likewise. * tests/test-symtab.cc: New test driver. Signed-off-by: Matthias Maennich <maennich@google.com> Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
Dodji Seketeli
|
5eb4d7627a |
Bug 25661 - Support data member replacement by anonymous data member
We ought to detect when a data member is replaced by an anonymous data member in a way that doesn't change the ABI in an incompatible way, especially when that change is non equivocal. For instance, consider this ABI-visible struct: struct S { int a; }; Now, consider that it's changed into: struct S { union { int a; char b; }; }; Stricto sensu, the bit-layout of struct S doesn't change and so that change isn't ABI-incompatible. The current version of libabigail however flags that change as a /potential/ issue and asks the user for further review. It appears that this class of changes is frequent enough to be annoying, especially in semi-automatic ABI compliance checking setups where we want the least possible "false positives". This patch detects that kind of change patterns where a data member is replaced by an anonymous data member in a benign way, in terms of ABI. So now let's look at a more complicated example where an ABI-visible type looks like: struct S { int a; int b; int c; }; Now suppose that type was changed into: struct S { union { int tag[3]; struct { int a; int b; int c; }; }; }; The patch allows abidiff to recognise that kind of pattern, filter out the detected change and report by default that the two binaries are ABI compatible. Here are the output that we'd get: $ abidiff test-v0.o test-v1.o Functions changes summary: 0 Removed, 0 Changed (1 filtered out), 0 Added function Variables changes summary: 0 Removed, 0 Changed, 0 Added variable When asked to show the detailed of the filtered out changes, we get: $ abidiff --harmless test-v0.o test-v1.o Functions changes summary: 0 Removed, 1 Changed, 0 Added function Variables changes summary: 0 Removed, 0 Changed, 0 Added variable 1 function with some indirect sub-type change: [C] 'function void foo(S*)' at test-v1.cc:18:1 has some indirect sub-type changes: parameter 1 of type 'S*' has sub-type changes: in pointed to type 'struct S' at test-v1.cc:1:1: type size hasn't changed data members 'S::a', 'S::b', 'S::c' were replaced by anonymous data member: 'union {int tag[3]; struct {int a; int b; int c;};}' And using the leaf-node reporter, that would give: $ abidiff --leaf-changes-only --harmless test-v0.o test-v1.o Leaf changes summary: 1 artifact changed Changed leaf types summary: 1 leaf type changed Removed/Changed/Added functions summary: 0 Removed, 0 Changed, 0 Added function Removed/Changed/Added variables summary: 0 Removed, 0 Changed, 0 Added variable 'struct S at test-v0.cc:1:1' changed: type size hasn't changed data members 'S::a', 'S::b', 'S::c' were replaced by anonymous data member: 'union {int tag[3]; struct {int a; int b; int c;};}' * include/abg-comp-filter.h (has_data_member_replaced_by_anon_dm): Declare new function. * include/abg-comparison.h (changed_var_sptr) (changed_var_sptrs_type): Declare new typedefs. (HARMLESS_DATA_MEMBER_CHANGE_CATEGORY): Add a new enumerator to the diff_category enum. (EVERYTHING_CATEGORY): In the diff_category, adjust this enumerator to OR the new HARMLESS_DATA_MEMBER_CHANGE_CATEGORY into it. (SUPPRESSED_CATEGORY, PRIVATE_TYPE_CATEGORY) (SIZE_OR_OFFSET_CHANGE_CATEGORY, VIRTUAL_MEMBER_CHANGE_CATEGORY) (CLASS_DECL_ONLY_DEF_CHANGE_CATEGORY) (FN_PARM_TYPE_TOP_CV_CHANGE_CATEGORY) (FN_RETURN_TYPE_CV_CHANGE_CATEGORY, VAR_TYPE_CV_CHANGE_CATEGORY) (VOID_PTR_TO_PTR_CHANGE_CATEGORY) (BENIGN_INFINITE_ARRAY_CHANGE_CATEGORY): Adjust the value of these enumerators of the diff_category enum. (class_or_union_diff::{data_members_replaced_by_adms, ordered_data_members_replaced_by_adms}): Declare new member functions. * include/abg-fwd.h (var_decl_wptr): Declare new typedef. (get_next_data_member, get_first_non_anonymous_data_member) (find_data_member_from_anonymous_data_member) (get_absolute_data_member_offset): Declare new functions. * include/abg-ir.h (struct anonymous_dm_hash): Declare new type. (anonymous_data_member_sptr_set_type): Declare new typedef. (class decl_base): Befriend class class_or_union. (class dm_context_rel): Pimpl-ify this class. (dm_context_rel::{g,s}et_anonymous_data_member_types): Declare new member functions. (var_decl::get_anon_dm_reliable_name): Declare new member function. (class var_decl): Make get_absolute_data_member_offset, get_absolute_data_member_offset be friends of this. (class_or_union::maybe_fixup_members_of_anon_data_member): Declare new protected member function. * src/abg-comp-filter.cc (has_data_member_replaced_by_anon_dm): Define new function. (categorize_harmless_diff_node): Use the above. * src/abg-comparison-priv.h (class_or_union_diff::priv::{dms_replaced_by_adms_, changed_var_sptrs_type dms_replaced_by_adms_ordered_}): Add new data members. (data_member_comp::compare_data_members): Factorize this out of ... (data_member_comp::operator()(decl_base_sptr&, decl_base_sptr&)): ... this. (data_member_comp::operator()(changed_var_sptr&, changed_var_sptr&)): Add new member function. (sort_changed_data_members): Declare ... * src/abg-comparison.cc (sort_changed_data_members): ... new function. (get_default_harmless_categories_bitmap): Adjust to take the new abigail::comparison::HARMLESS_DATA_MEMBER_CHANGE_CATEGORY into account. (operator<<(ostream& o, diff_category c)): Likewise. (class_or_union_diff::ensure_lookup_tables_populated): Handle Handle the insertion of anonymous data members to replace existing data members. (class_or_union_diff::{data_members_replaced_by_adms, ordered_data_members_replaced_by_adms}): Define new accessors. (suppression_categorization_visitor::visit_end): Propagate the SUPPRESSION_CATEGORIZATION_VISITOR from changes to the type of the data member if the data member doesn't have real local changes. * src/abg-default-reporter.cc (default_reporter::report): Report about anonymous data members that replace data members. * src/abg-ir.cc (struct dm_context_rel::priv): Define new data structure. (dm_context_rel::{dm_context_rel, get_is_laid_out, set_is_laid_out, get_offset_in_bits, set_offset_in_bits, operator==, operator!=, get_anonymous_data_member, set_anonymous_data_member}): Define the member functions here as they are not inline anymore. (class_or_union::maybe_fixup_members_of_anon_data_member): Define new member function. (class_or_union::add_data_member): Use it. (get_first_non_anonymous_data_member, get_next_data_member) (get_absolute_data_member_offset) (find_data_member_from_anonymous_data_member): Define new functions. * src/abg-reporter-priv.h (maybe_report_data_members_replaced_by_anon_dm): Declare ... * src/abg-reporter-priv.cc (maybe_report_data_members_replaced_by_anon_dm): ... new function. * src/abg-leaf-reporter.cc (leaf_reporter::report): Report data members replaced by anonymous data members. * tests/data/test-diff-filter/test-PR25661-[1-6]-report-[1-4].txt: New test reference outputs. * tests/data/test-diff-filter/test-PR25661-[1-6]-v{0,1}.c: Test source code files. * tests/data/test-diff-filter/test-PR25661-[1-6]-v{0,1}.o: Test binary input files. * tests/data/Makefile.am: Add the new test files above to source distribution. * tests/test-diff-filter.cc (in_out_specs): Add the binary test inputs above to this test harness. * tests/data/test-diff-dwarf/test45-anon-dm-change-report-0.txt: Adjust. Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
Dodji Seketeli
|
88fcbfeced |
dwarf-reader: support several anonymous data members in a given class
At the moment, if a class has more than one anonymous data member, we are just keeping the first one and dropping the others. This patch fixes that. Now that there is the possibility of having several anonymous data members in a given class we need to be able to name them correctly, to tell them apart. That means we cannot use the name returned by var_decl::get_name() as that name is empty for an anonymous data member. This patch thus introduces a new method var_decl::get_anon_dm_reliable_name() which returns a name that is reliable (non-empty) even when the var_decl designates an anonymous data member. Note that there are many situations where we still need to have var_decl::get_name() behave like it used to, so we can't make it invariably return what var_decl::get_anon_dm_reliable_name() returns today. * include/abg-ir.h (class_or_union::find_anonymous_data_member): Declare a new member function. (class_or_union::find_data_member): Declare a new overload. (var_decl::get_anon_dm_reliable_name): Declare new member function. * src/abg-ir.cc (var_decl::get_pretty_representation): Make this work on a var_decl is going to be used to represent an anonymous data member even before the var_decl has been added to its finale scope. This is useful to make class_or_union::find_data_member work on a var_decl that is to be used as an anonymous data member. (var_decl::get_anon_dm_reliable_name): Define new member function. (class_or_union::find_data_member): In the existing overload that takes a string, look for the named data member inside the anonymous data members. Define a new overload that takes a var_decl_sptr, to look for anonymous data members. (class_or_union::find_anonymous_data_member): Define a new member function. (lookup_data_member): Use the existing class_or_union::find_data_member. * src/abg-reader.cc: (build_class_decl): Use the full anonymous variable for lookup, rather than its name which is empty and will thus give false positives. * src/abg-dwarf-reader.cc (add_or_update_class_type): Likewise. * src/abg-comparison.cc (class_or_union_diff::ensure_lookup_tables_populated): Name anonymous data members properly - as opposed to wrongly using their empty name. * src/abg-reporter-priv.cc (represent): In the overload for var_diff_sptr, make sure that changes to the /type/ of a variable declaration are always reported. * tests/data/test-abidiff-exit/test-member-size-report0.txt: Adjust as we now emit more detailed changes about anonymous data members. * tests/data/test-abidiff-exit/test-member-size-report1.txt: Likewise. * tests/data/test-annotate/test-anonymous-members-0.o.abi: Adjust to reflect the fact that a class can now have several anonymous data members. * tests/data/test-diff-dwarf-abixml/PR25409-librte_bus_dpaa.so.20.0.abi: Likewise. * tests/data/test-diff-filter/test30-pr18904-rvalueref-report0.txt: Likewise. * tests/data/test-diff-filter/test30-pr18904-rvalueref-report1.txt: Likewise. * tests/data/test-diff-filter/test35-pr18754-no-added-syms-report-0.txt: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
Dodji Seketeli
|
48f26ddc00 |
{default,leaf}-reporter: group data members changes reports together
There are two kinds of data member changes: 1/ changes to the type or offset of a given data member basically, in this kind of change, the name of the data member remained the same. 2/ changes where the data member (at a given offset) was replaced by something else completely. Today, the comparison engine recognizes these two kinds of changes and records them in two different data structures. This is useful because it allows for a finer grain analysis. But when we report these changes, today, we report them separately and sometimes that doesn't make sense. For instance, because there is no change of the 1/ kind, the reporter would say "no data member changes", and yet go ahead and emit data member changes of the 2/ kind. This patch groups the reporting of the two kinds of changes so that when it says "no data member changes", it means there was no data member changes at all. * include/abg-comparison.h (class_or_union_diff::{sorted_changed_data_members, count_filtered_changed_data_members, sorted_subtype_changed_data_members, count_filtered_subtype_changed_data_members}): Declare ... * src/abg-comparison.cc (class_or_union_diff::{sorted_changed_data_members, count_filtered_changed_data_members, sorted_subtype_changed_data_members, count_filtered_subtype_changed_data_members}): ... accessors for existing private data members. * src/abg-default-reporter.cc (default_reporter::report): In the class_or_union_diff& overload, group the reporting of the changes to data member sub-types with the replacement of data members. These are just data member changes after all. Use the newly declared accessors for better measure. * src/abg-leaf-reporter.cc (leaf_reporter::report): Likewise. * tests/data/test-diff-dwarf/test45-anon-dm-change-report-0.txt: Adjust. * src/abg-leaf-reporter.cc (leaf_reporter::report): Likewise. * tests/data/test-diff-pkg/spice-server-0.12.4-19.el7.x86_64-0.12.8-1.el7.x86_64-report-2.txt: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
Dodji Seketeli
|
e2341a939c |
Bug 25986 - Wrong name of function type used in change report
We have introduced type name caching long ago to speed up operations involving type names. Then last year, I was looking at some speed optimization in the xml-writer and I started playing with the caching to quantify the speed impact that early caching could have on emitting writting out the abixml, independantly from the potential accuracy issues that could have. And somehow I accidentally committed one of those experimental patches: https://sourceware.org/git/?p=libabigail.git;a=commit;h=7699dfc921d248fa6d5cbdbeab9d501b17ef3f52. This commit reverts that bogus patch. There should be no speed impact because the writter now de-duplicates types at writting time by "simply" writting out the canonical types, as opposed to the naive approach we were using then. This fixes the bug reported at https://sourceware.org/bugzilla/show_bug.cgi?id=25986 which shows the impact of caching the wrong name of the type, which happens when caching occurs before the type is canonicalized. * src/abg-ir.cc (function_type::get_cached_name): Don't cache names for non-canonicalized types. * tests/data/test-abidiff-exit/test-fun-param-report.txt: Add reference output for new test. * tests/data/test-abidiff-exit/test-fun-param-v{0,1}.abi: Add new test input files. * tests/data/test-abidiff-exit/test-fun-param-v{0,1}.c: Add source files for the above. * tests/data/test-abidiff-exit/test-fun-param-v{0,1}.o: Add binaries for the above. Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
Giuliano Procida
|
dc0ac49157 |
Tidy checks for sufficient suppression properties.
Each suppression specification must have at least one of a documented per-suppression type list of properties defined if it is to be considered at all. At present: - suppression specifications which fail the check are silently ignored - in the function suppression case, the check does not trigger an early return and risks a later null pointer dereference. This commit: - reimplements the checks using arrays and helper function calls - adds a helper function to determine if a suppression specification is going to be ignored due a lack of properties - makes the parsing functions return failure early if the check fails Inconsistencies between suppression types (in particular, the treatment of the "label" property) remain. The only behavioural change may be to how present but empty properties are handled. This is an edge case that may be worth revisiting in a more general fashion in a later commit. * src/abg-suppression.cc (check_sufficient_props): New helper function to check for sufficient properties in a section. (read_type_suppression): Replace conditional logic with call to check_sufficient_props. (read_function_suppression): Ditto. (read_variable_suppression): Ditto. (read_file_suppression): Ditto. * tests/data/test-diff-suppr/test15-suppr-added-fn-4.suppr: Explain why the suppression will be ignored. * tests/data/test-diff-suppr/test16-suppr-removed-fn-4.suppr: Ditto. * tests/data/test-diff-suppr/test17-suppr-added-var-4.suppr: Ditto. * tests/data/test-diff-suppr/test18-suppr-removed-var-4.suppr: Ditto. Signed-off-by: Giuliano Procida <gprocida@google.com> |
||
Matthias Maennich
|
246ca20049 |
corpus/writer: sort emitted translation units by path name
By sorting the corpora output, we achieve determinism for the emitted XML file across multiple runs of abidw. For that to happen, change the collection of translation units to a std::set (instead of std::vector), sorted by absolute path name. Test data needed adjustments, but changes are fully compatible. * include/abg-fwd.h: remove translation_units fwd declaration. * include/abg-ir.h (struct shared_translation_unit_comparator): Define new class. (translation_units): Define new typedef. * src/abg-corpus.cc (corpus::add): do checked insert into the translation_units set (rather than vector::push_back) * tests/data/test-annotate/test13-pr18894.so.abi: Adjust test data. * tests/data/test-annotate/test14-pr18893.so.abi: Likewise. * tests/data/test-annotate/test15-pr18892.so.abi: Likewise. * tests/data/test-annotate/test17-pr19027.so.abi: Likewise. * tests/data/test-annotate/test18-pr19037-libvtkRenderingLIC-6.1.so.abi: Likewise. * tests/data/test-annotate/test19-pr19023-libtcmalloc_and_profiler.so.abi: Likewise. * tests/data/test-annotate/test20-pr19025-libvtkParallelCore-6.1.so.abi: Likewise. * tests/data/test-annotate/test21-pr19092.so.abi: Likewise. Signed-off-by: Matthias Maennich <maennich@google.com> Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
Giuliano Procida
|
4e11174eae |
abidiff: Omit declaration-only type size 0 diffs.
When reporting declaration-only type changes, the size is reported as changing to or from 0, which is not correct. The declaration type is of unknown size. This patch eliminates such size reports. * src/abg-reporter-priv.cc (report_size_and_alignment_changes): Filter out declaration-only / defined type size changes unconditionally. * tests/data/test-abidiff-exit/test-decl-struct-report.txt: Update test. Signed-off-by: Giuliano Procida <gprocida@google.com> |
||
Giuliano Procida
|
39ab7e8b22 |
abidiff: Blank line after declaration-only diff.
In the case where a type change is summarised as declaration-only to defined or vice versa, the trailing new line was missing. * src/abg-default-reporter.cc (default_reporter::report): In the class_or_union_diff overload, emit a new line at the end of the declaration-only reporting path. * tests/data/test-abidiff-exit/test-decl-struct-report.txt: Add missing blank lines. Signed-off-by: Giuliano Procida <gprocida@google.com> |
||
Giuliano Procida
|
bddb6b7d09 |
Add tests for declaration-only struct diffs.
There were no tests exercising this reporting path. The new test is run with --harmless as these changes are considered harmless. * tests/data/Makefile.am: Add new test case files. * tests/data/test-abidiff-exit/test-decl-struct-report.txt: New test case generating "declaration-only" output. * tests/data/test-abidiff-exit/test-decl-struct-v0.c: Ditto. * tests/data/test-abidiff-exit/test-decl-struct-v0.o: Ditto. * tests/data/test-abidiff-exit/test-decl-struct-v1.c: Ditto. * tests/data/test-abidiff-exit/test-decl-struct-v1.o: Ditto. * tests/test-abidiff-exit.cc: Run new test case. Signed-off-by: Giuliano Procida <gprocida@google.com> |
||
Giuliano Procida
|
037b5a1ca6 |
test24-soname-suppr*txt: Fix suppression syntax.
The property name "reached_through" should have been "accessed_through" and the property value "reference_or_pointer" should have been "reference-or-pointer". This patch fixes these issues. * tests/data/test-diff-suppr/test24-soname-suppr-0.txt: Fix typo, change "reached_through" to "accessed_through". * tests/data/test-diff-suppr/test24-soname-suppr-1.txt: Ditto. * tests/data/test-diff-suppr/test24-soname-suppr-2.txt: Ditto. * tests/data/test-diff-suppr/test24-soname-suppr-3.txt: Ditto. * tests/data/test-diff-suppr/test24-soname-suppr-4.txt: Ditto. Signed-off-by: Giuliano Procida <gprocida@google.com> Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
Giuliano Procida
|
086083734e |
test35-leaf.suppr: fix regex typo.
Bad regexes are silently ignored. This will be fixed in a later commit. * tests/data/test-diff-suppr/test35-leaf.suppr: Fix typo in regex, "*." -> ".*". Signed-off-by: Giuliano Procida <gprocida@google.com> Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
Giuliano Procida
|
b4f1a796bd |
abidiff: Document and refresh tests.
Following on from giving some test file more descriptive names, this patch actually documents in brief the purpose of these recently added tests. It also improves the coverage of the test-leaf-cxx-members test to include deletion and insertion report text as well. * tests/data/test-abidiff-exit/test-leaf-cxx-members-v1.cc: Comment test. Reorder members of ops to get better coverage. * tests/data/test-abidiff-exit/test-leaf-fun-type-v1.cc: Comment test. * tests/data/test-abidiff-exit/test-leaf-more-v1.cc: Ditto. * tests/data/test-abidiff-exit/test-leaf-peeling-v1.cc: Comment test. Update comment on ops2. * tests/data/test-abidiff-exit/test-leaf-redundant-v1.c: Comment test. * tests/data/test-abidiff-exit/test-leaf-stats-v1.cc: Ditto. * tests/data/test-abidiff-exit/test-leaf-cxx-members-report.txt: Update locations. Update report to reflect deletion, insertion and changed members (was previously changed only).: * tests/data/test-abidiff-exit/test-leaf-peeling-report.txt: Update locations. * tests/data/test-abidiff-exit/test-leaf-redundant-report.txt: Ditto.: * tests/data/test-abidiff-exit/test-leaf-cxx-members-v0.cc: Added one line comment referring to -v1 source file. * tests/data/test-abidiff-exit/test-leaf-fun-type-v0.cc: Ditto. * tests/data/test-abidiff-exit/test-leaf-more-v0.cc: Ditto. * tests/data/test-abidiff-exit/test-leaf-peeling-v0.cc: Ditto. * tests/data/test-abidiff-exit/test-leaf-redundant-v0.c: Ditto. * tests/data/test-abidiff-exit/test-leaf-stats-v0.cc: Ditto. * tests/data/test-abidiff-exit/test-leaf-cxx-members-v0.o: Recompiled. * tests/data/test-abidiff-exit/test-leaf-cxx-members-v1.o: Ditto. * tests/data/test-abidiff-exit/test-leaf-fun-type-v0.o: Ditto. * tests/data/test-abidiff-exit/test-leaf-fun-type-v1.o: Ditto. * tests/data/test-abidiff-exit/test-leaf-more-v0.o: Ditto. * tests/data/test-abidiff-exit/test-leaf-more-v1.o: Ditto. * tests/data/test-abidiff-exit/test-leaf-peeling-v0.o: Ditto. * tests/data/test-abidiff-exit/test-leaf-peeling-v1.o: Ditto. * tests/data/test-abidiff-exit/test-leaf-redundant-v0.o: Ditto. * tests/data/test-abidiff-exit/test-leaf-redundant-v1.o: Ditto. * tests/data/test-abidiff-exit/test-leaf-stats-v0.o: Ditto. * tests/data/test-abidiff-exit/test-leaf-stats-v1.o: Ditto. Signed-off-by: Giuliano Procida <gprocida@google.com> |
||
Giuliano Procida
|
4bbe135690 |
abg-reporter-priv.cc: Fix anonymous member size change reports.
Data members have names (unless anonymous), types, sizes and offsets (if a member of a class or struct). It is the responsibility of the represent function to detail all differences of a changed member. The size of a member is the same as the size of its type. A recent change to the function focused on cleaning up the formatting logic and added a catch-all case to the end of it in case no diff information had been emitted by then. This catch-all triggered for anonymous structs and union diffs under certain circumstances when these anonymous members had changed in size. This patch ensures size change information for a member is emitted exactly once (unless the type change has been or is being reported already). It also ensures anonymous members are identified appropriately and includes a test case would otherwise reach the catch-all case in both default and --leaf-changes-only modes. * src/abg-reporter-priv.cc (represent): In the var_diff_sptr overload, factor out some expressions as local variables, rely on diff_to_be_reported to decide whether to emit a change, fold together local/non-local change reporting using local_changes to preserve current name formatting differences, keep track explicitly of whether size information has been emitted and ensure it happens if needed, make offset and size change reporting for anonymous data members more meaningful. * tests/test-abidiff-exit.cc: Run new test cases. * tests/data/Makefile.am: Add new test files. * tests/data/test-abidiff-exit/test-member-size-v0.cc: New test. * tests/data/test-abidiff-exit/test-member-size-v0.o: Ditto. * tests/data/test-abidiff-exit/test-member-size-v1.cc: Ditto. * tests/data/test-abidiff-exit/test-member-size-v1.o: Ditto. * tests/data/test-abidiff-exit/test-member-size-report0.txt: New test, default mode. * tests/data/test-abidiff-exit/test-member-size-report1.txt: New test, --leaf-changes-only mode. * tests/data/test-abidiff-exit/test-leaf-cxx-members-report.txt: Eliminate duplicate reporting of member sizes. * tests/data/test-abidiff-exit/test-leaf-more-report.txt: Ditto. * tests/data/test-abidiff-exit/test-leaf-peeling-report.txt: Ditto. * tests/data/test-abidiff-exit/test-no-stray-comma-report.txt: Ditto. * tests/data/test-diff-dwarf/test45-anon-dm-change-report-0.txt: Add size report for anonymous data member. * tests/data/test-diff-filter/test44-anonymous-data-member-report-0.txt: Ditto. * tests/data/test-diff-pkg/libsigc++-2.0-0c2a_2.4.0-1_amd64--libsigc++-2.0-0v5_2.4.1-1ubuntu2_amd64-report-0.txt: Add missing size change report. * tests/data/test-diff-suppr/test36-leaf-report-0.txt: Remove size change report for previously reported type. * tests/data/test-diff-suppr/test46-PR25128-report-1.txt: Eliminate duplicate reporting of member size change. * tests/data/test-diff-suppr/test46-PR25128-report-2.txt: Ditto. Signed-off-by: Giuliano Procida <gprocida@google.com> Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
Giuliano Procida
|
22b2ba96f5 |
abidiff: More compact references to prior diffs.
In both the default and leaf reporting modes, when there is a repeated or circular reference to a type difference of a member variable, some placeholder text is emitted instead. In the leaf reporter: type 'struct S' of 'foo::bar' changed as reported earlier In the default reporter, this spans two lines: type of 'S foo::bar' changed: details were reported earlier This patch changes the latter to the more compact: type of 'S foo::bar' changed, as reported earlier More generally, this patch makes the punctuation of such placeholder text more consistent with a comma separating the phrases in all cases. It doesn't attempt to reconcile the different formatting of member variable declarations between the two modes. * src/abg-reporter-priv.cc (represent): In the var_diff_sptr overload, use consistent punctuation and keep to a single line of output when referring back to an existing type diff report. Remove unnecessary braces around single line conditional blocks. * src/abg-reporter-priv.h: In the macro RETURN_IF_BEING_REPORTED_OR_WAS_REPORTED_EARLIER, use consistent punctuation when referring back to an existing type diff report. * tests/data/test-abidiff/test-PR18791-report0.txt: Adjust formatting of back references to existing type diff reports. * tests/data/test-diff-dwarf/PR25058-liblttng-ctl-report-1.txt: Ditto. * tests/data/test-diff-filter/test16-report-2.txt: Ditto. * tests/data/test-diff-filter/test17-1-report.txt: Ditto. * tests/data/test-diff-filter/test25-cyclic-type-report-1.txt: Ditto. * tests/data/test-diff-pkg/spice-server-0.12.4-19.el7.x86_64-0.12.8-1.el7.x86_64-report-2.txt: Ditto. * tests/data/test-diff-suppr/test36-leaf-report-0.txt: Ditto. Signed-off-by: Giuliano Procida <gprocida@google.com> Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
Giuliano Procida
|
7e0d52834b |
Rename test-abidiff-exit/test-leaf[0-3] files.
The files tests/data/test-abidiff-exit/test-leaf[0-3]-* were introduced in a series of changes. Numbering rather than naming the tests turned out to be a bad choice: it caused confusion when dealing with merge conflicts due to reordering of commits. This patch renames the tests to give them more descriptive names, which is good practice anyway. * tests/data/Makefile.am: Rename test files. * tests/test-abidiff-exit.cc: Rename test files. * tests/data/test-abidiff-exit/test-leaf-fun-type-report.txt: Renamed from test-leaf2-report.txt. * tests/data/test-abidiff-exit/test-leaf-fun-type-v0.cc: Renamed from test-leaf2-v0.cc. * tests/data/test-abidiff-exit/test-leaf-fun-type-v0.o: Renamed from test-leaf2-v0.o. * tests/data/test-abidiff-exit/test-leaf-fun-type-v1.cc: Renamed from test-leaf2-v1.cc. * tests/data/test-abidiff-exit/test-leaf-fun-type-v1.o: Renamed from test-leaf2-v1.o. * tests/data/test-abidiff-exit/test-leaf-more-report.txt: Renamed from test-leaf1-report.txt. * tests/data/test-abidiff-exit/test-leaf-more-v0.cc: Renamed from test-leaf1-v0.cc. * tests/data/test-abidiff-exit/test-leaf-more-v0.o: Renamed from test-leaf1-v0.o. * tests/data/test-abidiff-exit/test-leaf-more-v1.cc: Renamed from test-leaf1-v1.cc. * tests/data/test-abidiff-exit/test-leaf-more-v1.o: Renamed from test-leaf1-v1.o. * tests/data/test-abidiff-exit/test-leaf-redundant-report.txt: Renamed from test-leaf3-report.txt. * tests/data/test-abidiff-exit/test-leaf-redundant-v0.c: Renamed from test-leaf3-v0.c. * tests/data/test-abidiff-exit/test-leaf-redundant-v0.o: Renamed from test-leaf3-v0.o. * tests/data/test-abidiff-exit/test-leaf-redundant-v1.c: Renamed from test-leaf3-v1.c. * tests/data/test-abidiff-exit/test-leaf-redundant-v1.o: Renamed from test-leaf3-v1.o. * tests/data/test-abidiff-exit/test-leaf-stats-report.txt: Renamed from test-leaf0-report.txt. * tests/data/test-abidiff-exit/test-leaf-stats-v0.cc: Renamed from test-leaf0-v0.cc. * tests/data/test-abidiff-exit/test-leaf-stats-v0.o: Renamed from test-leaf0-v0.o. * tests/data/test-abidiff-exit/test-leaf-stats-v1.cc: Renamed from test-leaf0-v1.cc. * tests/data/test-abidiff-exit/test-leaf-stats-v1.o: Renamed from test-leaf0-v1.o. Signed-off-by: Giuliano Procida <gprocida@google.com> |
||
Giuliano Procida
|
94844853fb |
abidiffpkg: Remove stray test report file.
The file tests/data/test-diff-pkg/dirpkg-2-report-1.txt looks like it was committed in error. It's not used, its contents don't match the implied directories being compared and there are other tests that cover the same functionality, with or without --no-abignore, anyway. * tests/data/Makefile.am: Removed tests/data/test-diff-pkg/dirpkg-2-report-1.txt. * tests/data/test-diff-pkg/dirpkg-2-report-1.txt: Removed. Signed-off-by: Giuliano Procida <gprocida@google.com> |
||
Giuliano Procida
|
609dc8813d |
test-diff-suppr.cc: Add missing tests.
Commit |
||
Giuliano Procida
|
ef90972a4a |
abidiff: Remove blank line after typedef changes.
This patch removes perhaps the last remaining cause of double blank lines in output. The state variable emit_nl was being set to true just after emitting a new line which resulted in a blank line after every local typedef change report. * include/abg-reporter.h (default_reporter::report_local_typedef_changes): Change return type to void. * src/abg-default-reporter.cc: (default_reporter::report_local_typedef_changes): Change return type to void, remove emit_nl state variable and logic. * tests/data/test-abidiff/test-PR18791-report0.txt: Remove blank lines. * tests/data/test-diff-dwarf/test42-PR21296-clanggcc-report0.txt: Ditto. * tests/data/test-diff-suppr/test39-opaque-type-report-0.txt: Ditto. Signed-off-by: Giuliano Procida <gprocida@google.com> |
||
Giuliano Procida
|
2d5389f265 |
Fix size calculations for multidimensional arrays.
The code in abg-ir.cc that calculated the memory size of an array summed, rather than multiplied, the dimensions. It also did duplicate work for each dimension after the first. Existing code in abg-reader.cc asserted that array size information read from XML match freshly calculated values. This patch corrects the calculation, eliminates the duplicate work and updates the XML reader validation to just emit a warning if old bad array size information is found. * include/abg-ir.h (array_type_def::append_subrange): Remove this function. * src/abg-ir.cc (array_type_def::set_element_type): Add a note about safe usage. (array_type_def::append_subrange): Inline this function into its only caller append_subranges and remove it. (array_type_def::append_subranges): Do correct multiplicative calculation of multidimensional array sizes. * src/abg-reader.cc (build_array_type_def): When checking calculated against read array sizes, warn once if value matches old behaviour rather than raising an assertion. Otherwise, before raising an assertion, emit an informative error message. * tests/data/test-annotate/test14-pr18893.so.abi: Correct array sizes. * tests/data/test-annotate/test17-pr19027.so.abi: Ditto. * tests/data/test-annotate/test19-pr19023-libtcmalloc_and_profiler.so.abi: Ditto. * tests/data/test-annotate/test7.so.abi: Ditto. * tests/data/test-diff-dwarf/test10-report.txt: Ditto. * tests/data/test-diff-dwarf/test11-report.txt: Ditto. * tests/data/test-read-write/test25.xml: Ditto. Reviewed-by: Matthias Maennich <maennich@google.com> Signed-off-by: Giuliano Procida <gprocida@google.com> |
||
Giuliano Procida
|
88c90d14d9 |
abidiff: Remove new lines after parameter diffs.
These blank lines break up the output unexpectedly and often cause double blank lines after reporting of function changes. * src/abg-default-reporter.cc: (report_local_function_type_changes): Remove unnecessary blank lines after lists of parameter changes. * tests/data/test-*/test*report*.txt: Remove blank lines after parameter change lists in 12 files. Reviewed-by: Matthias Maennich <maennich@google.com> Signed-off-by: Giuliano Procida <gprocida@google.com> |
||
Giuliano Procida
|
10b93d084c |
abidiff: Eliminate leaf mode double blank lines.
In --leaf-changes-only mode, the report currently has 2 blank lines after each type-diff section. This patches changes this to 1. * src/abg-leaf-reporter.cc: (report_diffs) Emit 1 instead of 2 new lines between sections. * tests/data/test-abidiff-exit/test-leaf-peeling-report.txt: Replace double blank lines with single ones. * tests/data/test-diff-filter/libtest45-basic-type-change-report-1.txt: Ditto. * tests/data/test-diff-suppr/test36-leaf-report-0.txt: Ditto. * tests/data/test-*/test*report*.txt:: Ditto. Reviewed-by: Matthias Maennich <maennich@google.com> Signed-off-by: Giuliano Procida <gprocida@google.com> |
||
Giuliano Procida
|
7070d3b65a |
abidiff: Fix variable declaration formatting.
The represent(var_diff_sptr) function tracks vertical "\n" and horizontal ", " spacing using two state variables: - emitted - the main diff text has been emitted - begin_with_and - main text emitted && new line started, so any further description must be indented and prefixed "and ". - if emitted is true and begin_with_and is false, then further description is prefixed with ", " instead. There was some inconsistent emission of new lines and maintenance of the state variables. This patch documents the variables and makes sure new lines and state variables are kept in sync. Finally, it is theoretically possible to reach the end of the function without emitted becoming true. This patch adds a TODO and makes sure at least something is output should that ever happen. * src/abg-reporter-priv.cc: (represent) In the var_diff_sptr overload, make sure the state variables begin_with_and and emitted are updated consistently; add a TODO for one case which may result in the end of the function being reached without having emitted a report; add missing new lines following reporting of anonymous member changes; only emit a final new line if begin_with_and hasn't tracked one already; document state variables. * tests/data/test-diff-dwarf/test45-anon-dm-change-report-0.txt: Add missing blank line after anonymous member change text. * tests/data/test-diff-filter/test44-anonymous-data-member-report-1.txt: Add missing "and " continuation. Reviewed-by: Matthias Maennich <maennich@google.com> Signed-off-by: Giuliano Procida <gprocida@google.com> Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
Giuliano Procida
|
786fcba8ae |
abidiff: Remove member function diff blank lines.
Currently, lists of member function deletions, additions and changes are each followed by a blank line in abidiff output. While this formatting works reasonably well in leaf-changes-only mode for top-level changes to types, it is inconsistent with everthing else. In particular, when reporting member function diffs in default mode, or more deeply nested in leaf mode, the blank lines are jarring. There was also no test coverage for leaf-changes-only mode. This change removes these blank lines and associated state variables and logic. It adds a test case for leaf-changes-only mode. Note that the patch also modifies default mode reporting of member types, template member functions and template member classes analogously, but I wasn't able to exercise those code paths. * src/abg-default-reporter.cc (report): In the class_or_union_diff overload, don't emit a new line after each list of member function, member type, template member function and template member class changes. * src/abg-leaf-reporter.cc (report): : In the class_or_union_diff overload, don't emit a new line after each list of member function changes. * tests/data/Makefile.am: Add new test case files. * tests/data/test-abidiff-exit/test-leaf-cxx-members-v0.cc: New test case for --leaf-changes-only member function diffs. * tests/data/test-abidiff-exit/test-leaf-cxx-members-v0.o: Ditto. * tests/data/test-abidiff-exit/test-leaf-cxx-members-v1.cc: Ditto. Also add a TODO regarding a potentially bad diff. * tests/data/test-abidiff-exit/test-leaf-cxx-members-v1.o: Ditto. * tests/data/test-abidiff/test-struct1-report.txt: Remove blank lines after member function changes lists. * tests/data/test-diff-dwarf/test41-PR20476-hidden-report-0.txt: Ditto. * tests/data/test-diff-pkg/tbb-4.1-9.20130314.fc22.x86_64--tbb-4.3-3.20141204.fc23.x86_64-report-0.txt: Ditto. * tests/test-abidiff-exit.cc: Add new test case. Reviewed-by: Matthias Maennich <maennich@google.com> Signed-off-by: Giuliano Procida <gprocida@google.com> Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
Giuliano Procida
|
340b53300e |
abidiff: Fix enum impacted interfaces blank line.
There was a spurious new line at the end of reporting enum diffs, before reporting impacted interfaces, if requested. * src/abg-default-reporter.cc (report): In the enum_diff overload, don't emit a blank line before a possible "impacted interfaces" stanza. In the class_or_union overload, change a stray conditional to use the emitted state variable for consistency. * tests/data/test*report*.txt: Remove blank lines after enum diffs in 17 files. Reviewed-by: Matthias Maennich <maennich@google.com> Signed-off-by: Giuliano Procida <gprocida@google.com> |
||
Giuliano Procida
|
912c436250 |
abidiff: Remove blank line after base class diffs.
This patch removes the blank line emitted after base class diffs. These are jarring, particularly when the diffs are nested. * src/abg-default-reporter.cc (report): In the class_diff overload, eliminate the extra blank line after base class changes and remove unneeded new line logic. * tests/data/test*report*.txt: Remove blank lines after base class diffs in 9 files. Reviewed-by: Matthias Maennich <maennich@google.com> Signed-off-by: Giuliano Procida <gprocida@google.com> |