From: Dodji Seketeli <dodji@redhat.com>
To: libabigail@sourceware.org
Subject: [PATCH, applied] Bug PR29443 - Global variables not emitted to abixml in some cases
Date: Tue, 20 Sep 2022 09:19:15 +0200 [thread overview]
Message-ID: <87edw67bt8.fsf@redhat.com> (raw)
Hello,
When a global variable named V has the same name as member variable
that appears in an anonymous scope and if the the abixml writer emits
the member variable V first, it gets confused when comes the time to
emit the global V as it wrongly thinks it's been already emitted.
This is because when emitting the "internal" pretty representation of
the member variable, libabigail fails to consider printing a qualified
name. So the two 'V' wrongly have names that can't be told apart.
For instance consider the testcase example:
struct A {
struct {
int xx; // #0
};
};
The qualified name of xx, for internal purposes (to name things
internally for the purpose of book keeping) would be:
'A::__anonymous_struct__::xx'.
Libabigail wrongly names it 'xx', hence the confusion with the global variable.
Fixed thus.
* src/abg-ir.cc (var_decl::get_pretty_representation): Always use
qualified name of vars in an anonymous scope for internal
purposes.
* tests/data/test-annotate/PR29443-missing-xx.o.annotated.abi: New
reference test output.
* tests/test-annotate.cc (in_out_specs): Add the above to the test
harness.
* tests/data/test-read-dwarf/PR29443-missing-xx.cc: New source
code for the test.
* tests/data/test-read-dwarf/PR29443-missing-xx.o: New test input
binary.
* tests/data/test-read-dwarf/PR29443-missing-xx.o.abi: New test
reference output.
* tests/data/Makefile.am: Add the new test material to source
distribution.
* tests/test-read-dwarf.cc (in_out_specs): Add the above to the
test harness.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
---
src/abg-ir.cc | 6 ++--
tests/data/Makefile.am | 4 +++
.../PR29443-missing-xx.o.annotated.abi | 32 ++++++++++++++++++
.../test-read-dwarf/PR29443-missing-xx.cc | 8 +++++
.../data/test-read-dwarf/PR29443-missing-xx.o | Bin 0 -> 2648 bytes
.../test-read-dwarf/PR29443-missing-xx.o.abi | 23 +++++++++++++
tests/test-annotate.cc | 5 +++
tests/test-read-dwarf.cc | 8 +++++
8 files changed, 84 insertions(+), 2 deletions(-)
create mode 100644 tests/data/test-annotate/PR29443-missing-xx.o.annotated.abi
create mode 100644 tests/data/test-read-dwarf/PR29443-missing-xx.cc
create mode 100644 tests/data/test-read-dwarf/PR29443-missing-xx.o
create mode 100644 tests/data/test-read-dwarf/PR29443-missing-xx.o.abi
diff --git a/src/abg-ir.cc b/src/abg-ir.cc
index 91c8e99b..b3bec8fa 100644
--- a/src/abg-ir.cc
+++ b/src/abg-ir.cc
@@ -19115,7 +19115,8 @@ var_decl::get_pretty_representation(bool internal, bool qualified_name) const
(is_class_or_union_type(get_type()),
"", /*one_line=*/true, internal);
result += " ";
- if (member_of_anonymous_class || !qualified_name)
+ if (!internal
+ && (member_of_anonymous_class || !qualified_name))
// It doesn't make sense to name the member of an
// anonymous class or union like:
// "__anonymous__::data_member_name". So let's just use
@@ -19130,7 +19131,8 @@ var_decl::get_pretty_representation(bool internal, bool qualified_name) const
get_type_declaration(get_type())->get_qualified_name(internal)
+ " ";
- if (member_of_anonymous_class || !qualified_name)
+ if (!internal
+ && (member_of_anonymous_class || !qualified_name))
// It doesn't make sense to name the member of an
// anonymous class or union like:
// "__anonymous__::data_member_name". So let's just use
diff --git a/tests/data/Makefile.am b/tests/data/Makefile.am
index 782dd7f3..94f3c7bc 100644
--- a/tests/data/Makefile.am
+++ b/tests/data/Makefile.am
@@ -599,6 +599,9 @@ test-read-dwarf/test-libaaudio.so.abi \
test-read-dwarf/PR28584/PR28584-smv.cc \
test-read-dwarf/PR28584/PR28584-smv.clang.o \
test-read-dwarf/PR28584/PR28584-smv.clang.o.abi \
+tests/data/test-read-dwarf/PR29443-missing-xx.cc \
+tests/data/test-read-dwarf/PR29443-missing-xx.o \
+tests/data/test-read-dwarf/PR29443-missing-xx.o.abi \
\
test-read-ctf/test0 \
test-read-ctf/test0.abi \
@@ -714,6 +717,7 @@ test-annotate/libtest24-drop-fns.so.abi \
test-annotate/test-anonymous-members-0.cc \
test-annotate/test-anonymous-members-0.o \
test-annotate/test-anonymous-members-0.o.abi \
+tests/data/test-annotate/PR29443-missing-xx.o.annotated.abi \
\
test-types-stability/pr19434-elf0 \
test-types-stability/pr19139-DomainNeighborMapInst.o \
diff --git a/tests/data/test-annotate/PR29443-missing-xx.o.annotated.abi b/tests/data/test-annotate/PR29443-missing-xx.o.annotated.abi
new file mode 100644
index 00000000..dde6a745
--- /dev/null
+++ b/tests/data/test-annotate/PR29443-missing-xx.o.annotated.abi
@@ -0,0 +1,32 @@
+<abi-corpus version='2.1' architecture='elf-amd-x86_64'>
+ <elf-variable-symbols>
+ <!-- signed char -->
+ <elf-symbol name='a' size='4' type='object-type' binding='global-binding' visibility='default-visibility' is-defined='yes'/>
+ <!-- xx -->
+ <elf-symbol name='xx' size='4' type='object-type' binding='global-binding' visibility='default-visibility' is-defined='yes'/>
+ </elf-variable-symbols>
+ <abi-instr address-size='64' path='PR29443-missing-xx.cc' comp-dir-path='/home/dodji/git/libabigail/fixes/tests/data/test-read-dwarf' language='LANG_C_plus_plus_14'>
+ <!-- int -->
+ <type-decl name='int' size-in-bits='32' id='type-id-1'/>
+ <!-- struct A -->
+ <class-decl name='A' size-in-bits='32' is-struct='yes' visibility='default' filepath='/home/dodji/git/libabigail/fixes/tests/data/test-read-dwarf/PR29443-missing-xx.cc' line='1' column='1' id='type-id-2'>
+ <member-type access='public'>
+ <!-- struct {int xx;} -->
+ <class-decl name='__anonymous_struct__' size-in-bits='32' is-struct='yes' is-anonymous='yes' visibility='default' filepath='/home/dodji/git/libabigail/fixes/tests/data/test-read-dwarf/PR29443-missing-xx.cc' line='2' column='1' id='type-id-3'>
+ <data-member access='public' layout-offset-in-bits='0'>
+ <!-- int xx -->
+ <var-decl name='xx' type-id='type-id-1' visibility='default' filepath='/home/dodji/git/libabigail/fixes/tests/data/test-read-dwarf/PR29443-missing-xx.cc' line='3' column='1'/>
+ </data-member>
+ </class-decl>
+ </member-type>
+ <data-member access='public' layout-offset-in-bits='0'>
+ <!-- struct {int xx;} -->
+ <var-decl name='' type-id='type-id-3' visibility='default'/>
+ </data-member>
+ </class-decl>
+ <!-- A a -->
+ <var-decl name='a' type-id='type-id-2' mangled-name='a' visibility='default' filepath='/home/dodji/git/libabigail/fixes/tests/data/test-read-dwarf/PR29443-missing-xx.cc' line='7' column='1' elf-symbol-id='a'/>
+ <!-- int xx -->
+ <var-decl name='xx' type-id='type-id-1' mangled-name='xx' visibility='default' filepath='/home/dodji/git/libabigail/fixes/tests/data/test-read-dwarf/PR29443-missing-xx.cc' line='13' column='1' elf-symbol-id='xx'/>
+ </abi-instr>
+</abi-corpus>
diff --git a/tests/data/test-read-dwarf/PR29443-missing-xx.cc b/tests/data/test-read-dwarf/PR29443-missing-xx.cc
new file mode 100644
index 00000000..e9e53583
--- /dev/null
+++ b/tests/data/test-read-dwarf/PR29443-missing-xx.cc
@@ -0,0 +1,8 @@
+struct A {
+ struct {
+ int xx;
+ };
+};
+
+struct A a;
+int xx;
diff --git a/tests/data/test-read-dwarf/PR29443-missing-xx.o b/tests/data/test-read-dwarf/PR29443-missing-xx.o
new file mode 100644
index 0000000000000000000000000000000000000000..681c958f6a15a6cd3910bd7d0322ac1e217d1cd4
GIT binary patch
literal 2648
zcmcIm%}*0S6o1og`C5x$6BRMA7>%OtmevLl1!{<Z@gs)B#2eYRLs@ONxVvbH2fdqk
z^1vV9!FcjwG@kUo;K;w=*@M0}oq=UoqA~F$JMX>U`<yp3g_pPPE~FR(MGR(PPg5ws
zR%TBw3$YA2I0jEq&H(EnC`HQ{EsBhrkY=oB0rhm6rTXSj$h6zQj9$V3y2b_TPG>wn
z0_H+@-v}bThJbNl=$*}w^BxAQ1V+#F7`tv>GjHeShEgZ7_#ivipEHfo;n9H;07i}(
zJ*GKrk`K#a{Tz#{nJlFc*4w!$6FbR5N9aBara5aGw58MdiCux%AZq)mh-wCH7m+i@
ze)eaH(fsg3VN{GV#YR&{J84At;{Au#{H05Ut5%`t6r6%poG2D2rV10*g=Jo|mfT1h
z?9#YpH=_-o&(yik1Fwpz8&ub3+EbJEWXZDYkY8&xdA`=FJ@)c-FUmK(id*sOuGh$~
zdTk!&BOXR!zUD@*5bc1wHM{oQ4OZd7a`9TJbj5CZVd(jFyWMuG)&Gz&xehGO&re$y
za2n%(F$gg^JVxXeesmo%5>JPHBTNyKx){6y6FAw^@Z(p42@Fx?pv8c$gCHUX^d5ra
zy-FYhjvPSo%EBOKQl$1YBypuHe#qImfbWG!-Pb;p_p$<Hg%yDC*ptSW+#$kgmp7z-
zTylj=6;8$Q-JTG8BypN=x0H!Bq)fQ#jUY8q${%|oaE6RXs_t?}h0BsF{EgHL8vah|
z;Dnpa$gLocf(~C(QpDR4IP@~Wse~ao0dKfYjaN46E1tjFLYt7?N+saW_L<$l_3M0p
zNW=5F3c(UeBzQ&W)mF2~@n_EQTM>8g_S#|OR-Z_{?r%8jL2I1{(WYwt-}x|x(yY~d
zRi?5MG)}&88bgJ!_}w9UnU)07<IkfHo%3Pw@jF22;&+I2I!`?(;bmHoHacu~)qUxn
zP|otMM@QI}4ZWB60CMtE{or2`K{L4OImz%zSOGlA71Mnmph3sTcSM2~DKXN0@1QNI
z|5tKQs!!^l-kIKi4KY0@LNF`ANm62@`>voZss5I%za(R+KK=UX_16)joD=xPDUyZm
z#X*!+eZ^l$OppIA9lrh{{`Dd8FH)Vr{2$`q%6QEUKFD|-SA8q|9SU?Vy8A~7==)Oh
wQ}L8fk0slV1h=K*Ao8U1r!&#t9)*07ApK_(C%u2ln-sqz&;N5g7-c>FH#uS1YXATM
literal 0
HcmV?d00001
diff --git a/tests/data/test-read-dwarf/PR29443-missing-xx.o.abi b/tests/data/test-read-dwarf/PR29443-missing-xx.o.abi
new file mode 100644
index 00000000..5c5e4f96
--- /dev/null
+++ b/tests/data/test-read-dwarf/PR29443-missing-xx.o.abi
@@ -0,0 +1,23 @@
+<abi-corpus version='2.1'>
+ <elf-variable-symbols>
+ <elf-symbol name='a' size='4' type='object-type' binding='global-binding' visibility='default-visibility' is-defined='yes'/>
+ <elf-symbol name='xx' size='4' type='object-type' binding='global-binding' visibility='default-visibility' is-defined='yes'/>
+ </elf-variable-symbols>
+ <abi-instr address-size='64' path='PR29443-missing-xx.cc' comp-dir-path='/home/dodji/git/libabigail/fixes/tests/data/test-read-dwarf' language='LANG_C_plus_plus_14'>
+ <type-decl name='int' size-in-bits='32' id='type-id-1'/>
+ <class-decl name='A' size-in-bits='32' is-struct='yes' visibility='default' filepath='/home/dodji/git/libabigail/fixes/tests/data/test-read-dwarf/PR29443-missing-xx.cc' line='1' column='1' id='type-id-2'>
+ <member-type access='public'>
+ <class-decl name='__anonymous_struct__' size-in-bits='32' is-struct='yes' is-anonymous='yes' visibility='default' filepath='/home/dodji/git/libabigail/fixes/tests/data/test-read-dwarf/PR29443-missing-xx.cc' line='2' column='1' id='type-id-3'>
+ <data-member access='public' layout-offset-in-bits='0'>
+ <var-decl name='xx' type-id='type-id-1' visibility='default' filepath='/home/dodji/git/libabigail/fixes/tests/data/test-read-dwarf/PR29443-missing-xx.cc' line='3' column='1'/>
+ </data-member>
+ </class-decl>
+ </member-type>
+ <data-member access='public' layout-offset-in-bits='0'>
+ <var-decl name='' type-id='type-id-3' visibility='default'/>
+ </data-member>
+ </class-decl>
+ <var-decl name='a' type-id='type-id-2' mangled-name='a' visibility='default' filepath='/home/dodji/git/libabigail/fixes/tests/data/test-read-dwarf/PR29443-missing-xx.cc' line='7' column='1' elf-symbol-id='a'/>
+ <var-decl name='xx' type-id='type-id-1' mangled-name='xx' visibility='default' filepath='/home/dodji/git/libabigail/fixes/tests/data/test-read-dwarf/PR29443-missing-xx.cc' line='13' column='1' elf-symbol-id='xx'/>
+ </abi-instr>
+</abi-corpus>
diff --git a/tests/test-annotate.cc b/tests/test-annotate.cc
index 750f5e88..b8a1ee75 100644
--- a/tests/test-annotate.cc
+++ b/tests/test-annotate.cc
@@ -131,6 +131,11 @@ InOutSpec in_out_specs[] =
"data/test-annotate/test-anonymous-members-0.o.abi",
"output/test-annotate/test-anonymous-members-0.o.abi",
},
+ {
+ "data/test-read-dwarf/PR29443-missing-xx.o",
+ "data/test-annotate/PR29443-missing-xx.o.annotated.abi",
+ "output/test-annotate/PR29443-missing-xx.o.annotated.abi",
+ },
// This should be the last entry.
{NULL, NULL, NULL}
};
diff --git a/tests/test-read-dwarf.cc b/tests/test-read-dwarf.cc
index 0de4bdd1..0227c89b 100644
--- a/tests/test-read-dwarf.cc
+++ b/tests/test-read-dwarf.cc
@@ -488,6 +488,14 @@ static InOutSpec in_out_specs[] =
"data/test-read-dwarf/PR28584/PR28584-smv.clang.o.abi",
"output/test-read-dwarf/PR28584/PR28584-smv.clang.o.abi",
},
+ {
+ "data/test-read-dwarf/PR29443-missing-xx.o",
+ "",
+ "",
+ SEQUENCE_TYPE_ID_STYLE,
+ "data/test-read-dwarf/PR29443-missing-xx.o.abi",
+ "output/test-read-dwarf/PR29443-missing-xx.o.abi",
+ },
// This should be the last entry.
{NULL, NULL, NULL, SEQUENCE_TYPE_ID_STYLE, NULL, NULL}
};
--
2.37.2
--
Dodji
reply other threads:[~2022-09-20 7:36 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=87edw67bt8.fsf@redhat.com \
--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).