[PATCH] dwarf-reader: Fix DIE origin handling & scope getting

Dodji Seketeli dodji@redhat.com
Fri Mar 1 17:27:49 GMT 2024


Hello,

While looking at something else, I noticed that a number of times the
code to create the IR for function-decl was adding the function to the
wrong scope, especially for DIEs that had a chain of
DW_AT_abstract_origin *and* DW_AT_specification attributes.

Suppose we are looking at a DIE D that has a DW_AT_abstract_origin
attribute pointing to a DIE D'.  D' itself has a DW_AT_specification
that points to D''.  The scope of the function should be represented
by the scope DIE of D'', not the scope DIE of D'.  Unfortunately
build_ir_node_from_die was sometimes using the scope of D'.

This patch fixes that by introducing a new die_origin_die function
that returns the ultimate origin of a DIE.  In the case above, the
ultimate origin of D is D''.  die_origin_die is thus used by
get_scope_die and get_scope_for_die to get the correct scope of a DIE.
The code of build_ir_node_from_die that handles DW_TAG_subprogram DIEs
is thus simplified as get_scope_for_die now does the heavy lifting of
handling DW_AT_abstract_origin and DW_AT_specification.

The result is a simpler and easier to maintain build_ir_node_from_die
and hopefully a more correct one.  A lot of the ABIXML and the type
denomination in change reports of the test suite have been updated to
reflect the more accurate representation.

	* src/abg-dwarf-reader.cc (die_origin_die): New static function.
	(get_scope_die, get_scope_for_die): Use the new die_origin_die
	above.
	(build_ir_node_from_die): Don't handle DW_AT_abstract_origin and
	DW_AT_specification here.  In general, do not handle getting the
	scope.  Rather, just rely on get_scope_for_die.
	* tests/data/test-annotate/libtest24-drop-fns-2.so.abi: Adjust.
	* tests/data/test-annotate/libtest24-drop-fns.so.abi: Likewise.
	* tests/data/test-annotate/test1.abi: Likewise.
	* 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/test2.so.abi: Likewise.
	* tests/data/test-annotate/test20-pr19025-libvtkParallelCore-6.1.so.abi:
	Likewise.
	* tests/data/test-annotate/test6.so.abi: Likewise.
	* tests/data/test-annotate/test8-qualified-this-pointer.so.abi:
	Likewise.
	* tests/data/test-diff-dwarf-abixml/test0-pr19026-libvtkIOSQL-6.1.so.1.abi:
	Likewise.
	* tests/data/test-diff-dwarf/test0-report.txt: Likewise.
	* tests/data/test-diff-dwarf/test28-vtable-changes-report-0.txt:
	Likewise.
	* tests/data/test-diff-dwarf/test29-vtable-changes-report-0.txt:
	Likewise.
	* tests/data/test-diff-dwarf/test30-vtable-changes-report-0.txt:
	Likewise.
	* tests/data/test-diff-dwarf/test31-vtable-changes-report-0.txt:
	Likewise.
	* tests/data/test-diff-dwarf/test36-ppc64-aliases-report-0.txt:
	Likewise.
	* tests/data/test-diff-dwarf/test41-PR20476-hidden-report-0.txt:
	Likewise.
	* tests/data/test-diff-dwarf/test42-PR21296-clanggcc-report0.txt:
	Likewise.
	* tests/data/test-diff-dwarf/test5-report.txt: Likewise.
	* tests/data/test-diff-dwarf/test8-report.txt: Likewise.
	* tests/data/test-diff-filter/test0-report.txt: Likewise.
	* tests/data/test-diff-filter/test01-report.txt: Likewise.
	* tests/data/test-diff-filter/test10-report.txt: Likewise.
	* tests/data/test-diff-filter/test13-report.txt: Likewise.
	* tests/data/test-diff-filter/test2-report.txt: Likewise.
	* tests/data/test-diff-filter/test28-redundant-and-filtered-children-nodes-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/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/test35-pr18754-no-added-syms-report-1.txt:
	Likewise.
	* tests/data/test-diff-filter/test41-report-0.txt: Likewise.
	* tests/data/test-diff-filter/test9-report.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-diff-suppr/test24-soname-report-1.txt: Likewise.
	* tests/data/test-diff-suppr/test24-soname-report-10.txt:
	Likewise.
	* tests/data/test-diff-suppr/test24-soname-report-12.txt:
	Likewise.
	* tests/data/test-diff-suppr/test24-soname-report-14.txt:
	Likewise.
	* tests/data/test-diff-suppr/test24-soname-report-16.txt:
	Likewise.
	* tests/data/test-diff-suppr/test24-soname-report-4.txt: Likewise.
	* tests/data/test-diff-suppr/test31-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/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/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/test14-pr18893.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/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/test2.so.abi: Likewise.
	* tests/data/test-read-dwarf/test2.so.hash.abi: Likewise.
	* tests/data/test-read-dwarf/test20-pr19025-libvtkParallelCore-6.1.so.abi:
	Likewise.
	* tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi:
	Likewise.
	* tests/data/test-read-dwarf/test6.so.abi: Likewise.
	* tests/data/test-read-dwarf/test6.so.hash.abi: Likewise.
	* tests/data/test-read-dwarf/test8-qualified-this-pointer.so.abi:
	Likewise.
	* tests/data/test-read-dwarf/test8-qualified-this-pointer.so.hash.abi:
	Likewise.
	* tests/data/test-read-dwarf/test9-pr18818-clang.so.abi: Likewise.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Applying to the master branch
---
 src/abg-dwarf-reader.cc                       |   241 +-
 .../test-annotate/libtest24-drop-fns-2.so.abi |     2 +-
 .../test-annotate/libtest24-drop-fns.so.abi   |     2 +-
 tests/data/test-annotate/test1.abi            |    70 +-
 .../data/test-annotate/test14-pr18893.so.abi  | 16746 ++---
 .../data/test-annotate/test15-pr18892.so.abi  | 17626 ++---
 .../data/test-annotate/test17-pr19027.so.abi  | 29685 ++++----
 ...st18-pr19037-libvtkRenderingLIC-6.1.so.abi | 20078 ++---
 ...19-pr19023-libtcmalloc_and_profiler.so.abi | 25278 +++----
 tests/data/test-annotate/test2.so.abi         |    46 +-
 ...st20-pr19025-libvtkParallelCore-6.1.so.abi | 23861 +++---
 tests/data/test-annotate/test6.so.abi         |     8 +-
 .../test8-qualified-this-pointer.so.abi       |    10 +-
 .../test0-pr19026-libvtkIOSQL-6.1.so.1.abi    | 16663 ++---
 tests/data/test-diff-dwarf/test0-report.txt   |    32 +-
 .../test28-vtable-changes-report-0.txt        |     7 +-
 .../test29-vtable-changes-report-0.txt        |    28 +-
 .../test30-vtable-changes-report-0.txt        |    28 +-
 .../test31-vtable-changes-report-0.txt        |    28 +-
 .../test36-ppc64-aliases-report-0.txt         |    23 +-
 .../test41-PR20476-hidden-report-0.txt        |    58 +-
 .../test42-PR21296-clanggcc-report0.txt       |     9 +-
 tests/data/test-diff-dwarf/test5-report.txt   |    11 +-
 tests/data/test-diff-dwarf/test8-report.txt   |    38 +-
 tests/data/test-diff-filter/test0-report.txt  |    36 +-
 tests/data/test-diff-filter/test01-report.txt |    36 +-
 tests/data/test-diff-filter/test10-report.txt |    11 +-
 tests/data/test-diff-filter/test13-report.txt |    23 +-
 tests/data/test-diff-filter/test2-report.txt  |    11 +-
 ...t-and-filtered-children-nodes-report-1.txt |    10 +-
 .../test30-pr18904-rvalueref-report0.txt      |   338 +-
 .../test30-pr18904-rvalueref-report1.txt      |   344 +-
 .../test30-pr18904-rvalueref-report2.txt      |   344 +-
 .../test31-pr18535-libstdc++-report-0.txt     |     8 +-
 .../test31-pr18535-libstdc++-report-1.txt     |     8 +-
 .../test35-pr18754-no-added-syms-report-0.txt |   236 +-
 .../test35-pr18754-no-added-syms-report-1.txt |     6 +-
 .../data/test-diff-filter/test41-report-0.txt |    89 +-
 tests/data/test-diff-filter/test9-report.txt  |    11 +-
 ...bb-4.3-3.20141204.fc23.x86_64-report-0.txt |   377 +-
 ...bb-4.3-3.20141204.fc23.x86_64-report-1.txt |   123 +-
 .../test24-soname-report-1.txt                |    13 +-
 .../test24-soname-report-10.txt               |    13 +-
 .../test24-soname-report-12.txt               |    13 +-
 .../test24-soname-report-14.txt               |    13 +-
 .../test24-soname-report-16.txt               |    13 +-
 .../test24-soname-report-4.txt                |    13 +-
 .../data/test-diff-suppr/test31-report-1.txt  |    11 +-
 .../PR22015-libboost_iostreams.so.abi         |   799 +-
 .../test-read-dwarf/PR22122-libftdc.so.abi    | 17805 +----
 .../libtest24-drop-fns-2.so.abi               |     2 +-
 .../test-read-dwarf/libtest24-drop-fns.so.abi |     2 +-
 .../test-read-dwarf/test-libaaudio.so.abi     |   275 +-
 .../test-read-dwarf/test-libandroid.so.abi    |  4865 +-
 tests/data/test-read-dwarf/test1.abi          |    39 +-
 tests/data/test-read-dwarf/test1.hash.abi     |    33 +-
 .../test-read-dwarf/test10-pr18818-gcc.so.abi |  5890 +-
 .../test-read-dwarf/test11-pr18828.so.abi     | 11886 +--
 .../test-read-dwarf/test12-pr18844.so.abi     | 24007 +++---
 .../test-read-dwarf/test14-pr18893.so.abi     | 10915 ++-
 .../test-read-dwarf/test15-pr18892.so.abi     | 14972 ++--
 .../test-read-dwarf/test16-pr18904.so.abi     | 16930 ++---
 .../test-read-dwarf/test17-pr19027.so.abi     | 21639 +++---
 ...st18-pr19037-libvtkRenderingLIC-6.1.so.abi | 15336 ++--
 ...19-pr19023-libtcmalloc_and_profiler.so.abi | 20204 +++--
 tests/data/test-read-dwarf/test2.so.abi       |    34 +-
 tests/data/test-read-dwarf/test2.so.hash.abi  |    22 +-
 ...st20-pr19025-libvtkParallelCore-6.1.so.abi | 18624 +++--
 .../test22-pr19097-libstdc++.so.6.0.17.so.abi | 61103 ++++++++--------
 tests/data/test-read-dwarf/test6.so.abi       |     5 +-
 tests/data/test-read-dwarf/test6.so.hash.abi  |     3 +-
 .../test8-qualified-this-pointer.so.abi       |     7 +-
 .../test8-qualified-this-pointer.so.hash.abi  |     5 +-
 .../test9-pr18818-clang.so.abi                |   850 +-
 74 files changed, 180983 insertions(+), 217947 deletions(-)

This file is quite big, so I am attaching it in gzipped form.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0008-dwarf-reader-Fix-DIE-origin-handling-scope-getting.patch.gz
Type: application/gzip
Size: 2830583 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/libabigail/attachments/20240301/10432247/attachment-0001.gz>
-------------- next part --------------


-- 
		Dodji


More information about the Libabigail mailing list