[PATCH 09/27] dwarf-reader: Avoid duplicating anonymous member types
Dodji Seketeli
dodji@redhat.com
Thu Aug 29 16:01:08 GMT 2024
Hello,
Sometimes, anonymous member types are duplicated in some classes read
by the DWARF reader. This is because the DWARF reader doesn't lookup
anonymous member types in their class scope before adding them into
their scope.
This patch teaches the DWARF reader how to name an anonymous class,
union or enum by using its flat pretty representation, e.g:
struct {int blah; char meh;}
That flat representation is used as the name of the anonymous type to
look it up in a given class scope before adding it to that scope. If
the scope already contains the type, then the type is not added.
Now that class scopes have their proper anonymous member types, it
appeared that the filtering of change reports needed a number of
adaptations because we are now seeing things that we were not seeing
before. For instance two new change categories
NON_COMPATIBLE_DISTINCT_CHANGE_CATEGORY and
NON_COMPATIBLE_NAME_CHANGE_CATEGORY are added. The former is for a
change where a given type becomes another type of a different kind in
an non-compatible way. For instance, a struct type becomes an enum
type. The later category is for a change in a name of the type,
resulting in a non-compatible change. Thus, new non-compatible
changes can now be categorized and reported as such.
* include/abg-comp-filter.h (has_void_ptr_to_ptr_change)
(has_harmless_enum_to_int_change)
(has_benign_array_of_unknown_size_change): Declare new functions.
* include/abg-comparison.h (enum diff_category): Add
NON_COMPATIBLE_DISTINCT_CHANGE_CATEGORY,
NON_COMPATIBLE_NAME_CHANGE_CATEGORY enumerators. Update the other
enumerator values. Also, update the EVERYTHING_CATEGORY
enumerator value.
* include/abg-ir.h (class_decl::find_base_class): Document the
name of the parameter.
* src/abg-comp-filter.cc (type_diff_has_cv_qual_change_only)
(is_non_compatible_distinct_change, is_void_ptr_to_ptr): Define
new static functions.
(has_subtype_changes): Remove static function.
(class_diff_has_only_harmless_changes): Do not bother checking if
the class_diff has subtype changes. If there are, the category of
those changes is going to be propagated upward to this current
diff node. Update the comments.
(has_harmless_name_change): A diff node carrying compatible types
or types that differ only from their CV qualifiers should qualify
as having a harmless name change.
(has_harmless_enum_to_int_change): Make this function be
non-static.
(type_diff_has_cv_qual_change_only): Introduce an overload that
takes two ABI artifacts instead of one diff node. Make the diff
node overload use the new one. Simplify logic by essentially
peeling off qualified or typedefs first. Then if what remain is
pointer or array types, look at their underlying types. If the
remaining underlying types are equal then return true.
(has_void_ptr_to_ptr_change): Use the new is_void_ptr_to_ptr
function. This allows the function to detect void* -> pointer and
pointer -> void* changes. And it simplifies the logic.
* src/abg-comparison.cc (distinct_diff::compatible_child_diff):
Build a compatible child diff node iff the two diff subject are
actually compatible meaning, they are equal modulo a typedef.
(get_default_harmful_categories_bitmap): Add the new
abigail::comparison::{NON_COMPATIBLE_DISTINCT_CHANGE_CATEGORY,NON_COMPATIBLE_NAME_CHANGE_CATEGORY}
enumerators to the bitmap of harmful categories.
(operator<<(ostream& o, diff_category c)): Update this to support
emitting the new
abigail::comparison::{NON_COMPATIBLE_DISTINCT_CHANGE_CATEGORY,NON_COMPATIBLE_NAME_CHANGE_CATEGORY}
enumerators.
(class_or_union_diff::priv::count_filtered_{subtype_}changed_dm):
Fix logic for counting local changes.
diff::has_local_changes_to_be_reported is not reliable so do not
rely on it. We might want to remove that function in the end.
(category_propagation_visitor::visit_end): If the current diff
node has a harmless void pointer to pointer, enum to int, or a
benign array of unknown size change, do not propagate the
NON_COMPATIBLE_{NAME,DISTINCT}_CHANGE_CATEGORY that have
necessarily bubbled up from some of their distant children nodes.
* src/abg-dwarf-reader.cc
(maybe_set_member_type_access_specifier)
(get_next_member_sibling_die): Declare this pre-existing static
function.
(get_internal_anonymous_die_name)
(lookup_class_typedef_or_enum_type_from_corpus)
(lookup_class_typedef_or_enum_type_from_corpus): Remove.
(die_return_and_parm_names_from_fn_type_die): Add is_method_type
and return_type_name parameters. Fix the representation of member
functions.
(die_function_signature): Add qualified_name parameter. Adjust
call to die_return_and_parm_names_from_fn_type_die.
(die_type_name, die_enum_flat_representation)
(die_class_flat_representation)
(die_class_or_enum_flat_representation): Define new static
functions.
(reader::get_die_qualified_type_name, die_qualified_type_name):
For anonymous class or enum types, use the new
die_class_or_enum_flat_representation. Adjust the call to
die_return_and_parm_names_from_fn_type_die. For function types fix
the name representation.
(die_pretty_print_type): Adjust call to
die_return_and_parm_names_from_fn_type_die.
(die_pretty_print_decl): Take qualified_name and include_fns
parameters. Use the new die_type_name for variable type names.
Adjust call to die_function_signature.
(die_pretty_print): Adjust call die_pretty_print_decl.
(get_member_child_die): Remove useless vertical space.
(build_enum_underlying_type): Sort this enum underlying type (and
potentially hash it) before canonicalizing it.
(add_or_update_class_type): If an anonymous type is in the global
scope, take that into account when building its internal anonymous
die name. Lookup anonymous member types before adding them to the
class scope to avoid duplicating them in their scope.
(add_or_update_union_type): Likewise, lookup anonymous member
types before adding them to the union scope to avoid duplicating
them in their scope.
(build_subranges_from_array_type_die): Const-ify the input reader.
Adjust call to build_ir_node_from_die. Associate the subrange DIE
to the IR node built.
(build_ir_node_from_die): Get the current corpus from the reader
because it might be set for scope passed to this function, or the
scope might be nullptr. Schedule base types for canonicalization
like all the other types. Also, lookup all class/union types
before adding them to their class scope.
* src/abg-leaf-reporter.cc (leaf_reporter::report): In the
overload for class_or_union_diff, report changed data members and
their sub-types.
* tests/Makefile.am: Do not XFAIL the test runtestabidiffexit. No
more tests are XFAILED. All tests should now pass.
* tests/data/test-abidiff-exit/PR30503/libsdl/libsdl-1.2.60-1.2.64-report.txt:
Adjust.
* tests/data/test-abidiff-exit/PR31513/reported/PR31513-reported-report-1.txt:
Likewise.
* tests/data/test-abidiff-exit/qualifier-typedef-array-report-1.txt:
Likewise.
* tests/data/test-annotate/libtest24-drop-fns-2.so.abi: Likewise.
* tests/data/test-annotate/libtest24-drop-fns.so.abi: Likewise.
* tests/data/test-annotate/test0.abi: Likewise.
* tests/data/test-annotate/test1.abi: Likewise.
* tests/data/test-annotate/test15-pr18892.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.
* tests/data/test-diff-dwarf/PR25058-liblttng-ctl-report-1.txt:
Likewise.
* tests/data/test-diff-dwarf/test4-report.txt: Likewise.
* tests/data/test-diff-dwarf/test5-report.txt: Likewise.
* tests/data/test-diff-filter/test-PR26739-2-report-0.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/test31-pr18535-libstdc++-report-0.txt:
Likewise.
* tests/data/test-diff-filter/test31-pr18535-libstdc++-report-1.txt:
Likewise.
* tests/data/test-diff-filter/test35-pr18754-no-added-syms-report-0.txt:
Likewise.
* tests/data/test-diff-filter/test41-report-0.txt: Likewise.
* tests/data/test-diff-filter/test5-report.txt: Likewise.
* 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:
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-diff-pkg/tbb-4.1-9.20130314.fc22.x86_64--tbb-4.3-3.20141204.fc23.x86_64-report-0.txt:
Likewise.
* tests/data/test-diff-pkg/tbb-4.1-9.20130314.fc22.x86_64--tbb-4.3-3.20141204.fc23.x86_64-report-1.txt:
Likewise.
* tests/data/test-read-dwarf/PR22015-libboost_iostreams.so.abi:
Likewise.
* tests/data/test-read-dwarf/PR22122-libftdc.so.abi: Likewise.
* tests/data/test-read-dwarf/PR24378-fn-is-not-scope.abi:
Likewise.
* tests/data/test-read-dwarf/PR25007-sdhci.ko.abi: Likewise.
* tests/data/test-read-dwarf/libtest24-drop-fns-2.so.abi:
Likewise.
* tests/data/test-read-dwarf/libtest24-drop-fns.so.abi: Likewise.
* tests/data/test-read-dwarf/test-libaaudio.so.abi: Likewise.
* tests/data/test-read-dwarf/test-libandroid.so.abi: Likewise.
* tests/data/test-read-dwarf/test0.abi: Likewise.
* tests/data/test-read-dwarf/test0.hash.abi: Likewise.
* tests/data/test-read-dwarf/test1.abi: Likewise.
* tests/data/test-read-dwarf/test1.hash.abi: Likewise.
* tests/data/test-read-dwarf/test10-pr18818-gcc.so.abi: Likewise.
* tests/data/test-read-dwarf/test11-pr18828.so.abi: Likewise.
* tests/data/test-read-dwarf/test12-pr18844.so.abi: Likewise.
* tests/data/test-read-dwarf/test15-pr18892.so.abi: Likewise.
* tests/data/test-read-dwarf/test16-pr18904.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.
* tests/data/test-read-dwarf/test21-pr19092.so.abi: Likewise.
* tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi:
Likewise.
* tests/data/test-read-dwarf/test9-pr18818-clang.so.abi: Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
---
include/abg-comp-filter.h | 9 +
include/abg-comparison.h | 32 +-
include/abg-ir.h | 2 +-
src/abg-comp-filter.cc | 225 +-
src/abg-comparison.cc | 64 +-
src/abg-dwarf-reader.cc | 1024 +-
src/abg-leaf-reporter.cc | 24 +-
tests/Makefile.am | 2 -
.../libsdl/libsdl-1.2.60-1.2.64-report.txt | 12 +-
.../reported/PR31513-reported-report-1.txt | 20 +-
.../qualifier-typedef-array-report-1.txt | 64 +-
.../test-annotate/libtest24-drop-fns-2.so.abi | 4 +-
.../test-annotate/libtest24-drop-fns.so.abi | 4 +-
tests/data/test-annotate/test0.abi | 4 +-
tests/data/test-annotate/test1.abi | 4 +-
.../data/test-annotate/test15-pr18892.so.abi | 8368 +++---
...st18-pr19037-libvtkRenderingLIC-6.1.so.abi | 2181 +-
...19-pr19023-libtcmalloc_and_profiler.so.abi | 5514 ++--
...st20-pr19025-libvtkParallelCore-6.1.so.abi | 6075 ++--
.../data/test-annotate/test21-pr19092.so.abi | 6 +-
.../PR25058-liblttng-ctl-report-1.txt | 15 +-
tests/data/test-diff-dwarf/test4-report.txt | 6 +-
tests/data/test-diff-dwarf/test5-report.txt | 4 +-
.../test-PR26739-2-report-0.txt | 16 +-
.../test30-pr18904-rvalueref-report0.txt | 46 +-
.../test30-pr18904-rvalueref-report1.txt | 46 +-
.../test30-pr18904-rvalueref-report2.txt | 46 +-
.../test31-pr18535-libstdc++-report-0.txt | 2 +-
.../test31-pr18535-libstdc++-report-1.txt | 2 +-
.../test35-pr18754-no-added-syms-report-0.txt | 46 +-
.../data/test-diff-filter/test41-report-0.txt | 32 +-
tests/data/test-diff-filter/test5-report.txt | 9 +-
...libICE-1.0.9-2.el7.x86_64.rpm-report-0.txt | 13 +-
...l7.x86_64-0.12.8-1.el7.x86_64-report-2.txt | 23 +-
...bb-4.3-3.20141204.fc23.x86_64-report-0.txt | 59 +-
...bb-4.3-3.20141204.fc23.x86_64-report-1.txt | 45 +-
.../PR22015-libboost_iostreams.so.abi | 6 +-
.../test-read-dwarf/PR22122-libftdc.so.abi | 3741 ++-
.../PR24378-fn-is-not-scope.abi | 22 +-
.../data/test-read-dwarf/PR25007-sdhci.ko.abi | 6 +-
.../libtest24-drop-fns-2.so.abi | 4 +-
.../test-read-dwarf/libtest24-drop-fns.so.abi | 4 +-
.../test-read-dwarf/test-libaaudio.so.abi | 6 +-
.../test-read-dwarf/test-libandroid.so.abi | 197 +-
tests/data/test-read-dwarf/test0.abi | 4 +-
tests/data/test-read-dwarf/test0.hash.abi | 4 +-
tests/data/test-read-dwarf/test1.abi | 4 +-
tests/data/test-read-dwarf/test1.hash.abi | 4 +-
.../test-read-dwarf/test10-pr18818-gcc.so.abi | 524 +-
.../test-read-dwarf/test11-pr18828.so.abi | 10 +-
.../test-read-dwarf/test12-pr18844.so.abi | 18079 +++++------
.../test-read-dwarf/test15-pr18892.so.abi | 8306 +++---
.../test-read-dwarf/test16-pr18904.so.abi | 8470 +++---
...st18-pr19037-libvtkRenderingLIC-6.1.so.abi | 2143 +-
...19-pr19023-libtcmalloc_and_profiler.so.abi | 5485 ++--
...st20-pr19025-libvtkParallelCore-6.1.so.abi | 5964 ++--
.../test-read-dwarf/test21-pr19092.so.abi | 6 +-
.../test22-pr19097-libstdc++.so.6.0.17.so.abi | 24829 ++++++++--------
.../test9-pr18818-clang.so.abi | 857 +-
59 files changed, 51445 insertions(+), 51278 deletions(-)
The patch is too big so I am attaching it gzip'ed.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0009-dwarf-reader-Avoid-duplicating-anonymous-member-type.patch.gz
Type: application/gzip
Size: 1462874 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/libabigail/attachments/20240829/c8ee01df/attachment-0001.gz>
-------------- next part --------------
--
Dodji
More information about the Libabigail
mailing list