From: Dodji Seketeli <dodji@redhat.com>
To: dodji@redhat.com
Cc: libabigail@sourceware.org
Subject: [PATCH 09/27] dwarf-reader: Avoid duplicating anonymous member types
Date: Thu, 29 Aug 2024 18:01:08 +0200 [thread overview]
Message-ID: <877cbzmi7v.fsf@seketeli.org> (raw)
In-Reply-To: <20240829154711.1883174-1-dodji@redhat.com> (dodji@redhat.com's message of "Thu, 29 Aug 2024 17:46:29 +0200")
[-- Attachment #1: Type: text/plain, Size: 14111 bytes --]
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.
[-- Attachment #2: 0009-dwarf-reader-Avoid-duplicating-anonymous-member-type.patch.gz --]
[-- Type: application/gzip, Size: 1462874 bytes --]
[-- Attachment #3: Type: text/plain, Size: 14 bytes --]
--
Dodji
next prev parent reply other threads:[~2024-08-29 16:13 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-29 15:46 [PATCH 00/27] Implement type hashing & fix self-comparing gcc-gnat in fc37 dodji
2024-08-29 15:52 ` [PATCH 01/27] Implement type hashing Dodji Seketeli
2024-08-29 15:54 ` [PATCH 02/27] ir: Remove the now useless type propagation optimization Dodji Seketeli
2024-08-29 15:55 ` [PATCH 03/27] ir: decl-only classes don't equal fully defined classes under ODR Dodji Seketeli
2024-08-29 15:56 ` [PATCH 04/27] comp-filter: Consider lvalue-ness changes on references as harmful Dodji Seketeli
2024-08-29 15:56 ` [PATCH 05/27] comp-filter: Ignore ptr size when detecting void ptr to ptr change Dodji Seketeli
2024-08-29 15:57 ` [PATCH 06/27] Don't strip typedefs in fn names when pretty-printing and comparing Dodji Seketeli
2024-08-29 15:58 ` [PATCH 07/27] reader: Avoid duplicating member types Dodji Seketeli
2024-08-29 15:58 ` [PATCH 08/27] ir: Cache the result of scope_decl::get_sorted_member_types Dodji Seketeli
2024-08-29 16:01 ` Dodji Seketeli [this message]
2024-08-29 16:02 ` [PATCH 10/27] reader: Avoid duplicating recursive types Dodji Seketeli
2024-08-29 16:02 ` [PATCH 11/27] dwarf-reader: Speed-up decl-only resolution Dodji Seketeli
2024-08-29 16:03 ` [PATCH 12/27] ir: Fix name setting of a ptr-to-mbr-type Dodji Seketeli
2024-08-29 16:04 ` [PATCH 13/27] dwarf-reader: Support LLVM's lingo of declaration-ness Dodji Seketeli
2024-08-29 16:04 ` [PATCH 14/27] reader: Improve logging in the ABIXML reader Dodji Seketeli
2024-08-29 16:05 ` [PATCH 15/27] ir: Improve type logging during type canonicalization Dodji Seketeli
2024-08-29 16:05 ` [PATCH 16/27] tools-utils: Improve logging while reading a Linux kernel Dodji Seketeli
2024-08-29 16:06 ` [PATCH 17/27] dwarf-reader: Fix building of void, void* and variadic parm types Dodji Seketeli
2024-08-29 16:06 ` [PATCH 18/27] {dwarf,btf,ctf}-reader: Set the origin of the corpus group Dodji Seketeli
2024-08-29 16:07 ` [PATCH 19/27] {btf,ctf,dwarf}-reader, ir: Fix self-comparison debugging for corpus groups Dodji Seketeli
2024-08-29 16:07 ` [PATCH 20/27] abilint: Support --verbose option Dodji Seketeli
2024-08-29 16:08 ` [PATCH 21/27] big-tests: Update git sub-module Dodji Seketeli
2024-08-29 16:08 ` [PATCH 22/27] dwarf-reader,tools-utils: Add statistics about built/suppressed functions Dodji Seketeli
2024-08-29 16:09 ` [PATCH 23/27] abidw: Add a --kmi-stablelist option alongside existing --kmi-whitelist Dodji Seketeli
2024-08-29 16:10 ` [PATCH 24/27] dwarf-reader,ir: Fix endless loop while analyzing DWARF from Modula-2 Dodji Seketeli
2024-08-29 16:13 ` [PATCH 25/27] abipkgdiff: Extract devel and main packages in the same directory Dodji Seketeli
2024-08-29 16:13 ` [PATCH 26/27] dwarf-reader,reader.cc: Fix function virtuality setting Dodji Seketeli
2024-08-29 16:15 ` [PATCH 27/27] dwarf-reader,ir,writer: Better support for static member variables Dodji Seketeli
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=877cbzmi7v.fsf@seketeli.org \
--to=dodji@redhat.com \
--cc=libabigail@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).