From patchwork Tue Sep 20 07:19:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dodji Seketeli X-Patchwork-Id: 57787 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 89E523858280 for ; Tue, 20 Sep 2022 07:36:47 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 89E523858280 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1663659407; bh=8rIJ1fDEJFvDrb6nW6K2p0j+lTB38h1aNKAON5FRWL8=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Help: List-Subscribe:From:Reply-To:From; b=EbooNLbZBPoj8W00S4F1iA3ezDPgSGB8lSbxmn4W2ieAyNwyLY/ZbiLVTgNp558kK /FbI/zpGrXJIX30fsIcJirgHpQMByq2no35OfMgw4CDveX/TaRUDEYodqGu70RhKBT PwubKUywEqBbR/Yv3h1PRMrtxtnezW1K6c+0Hdk8= X-Original-To: libabigail@sourceware.org Delivered-To: libabigail@sourceware.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 73A7A3858CDA for ; Tue, 20 Sep 2022 07:36:41 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 73A7A3858CDA Received: from mail-qk1-f200.google.com (mail-qk1-f200.google.com [209.85.222.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-630-ptt-LyqUPaGtJPFAJEuj4w-1; Tue, 20 Sep 2022 03:36:39 -0400 X-MC-Unique: ptt-LyqUPaGtJPFAJEuj4w-1 Received: by mail-qk1-f200.google.com with SMTP id h7-20020a05620a400700b006cebec84734so1248636qko.23 for ; Tue, 20 Sep 2022 00:36:39 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=mime-version:user-agent:message-id:date:organization:subject:to :from:x-gm-message-state:from:to:cc:subject:date; bh=8rIJ1fDEJFvDrb6nW6K2p0j+lTB38h1aNKAON5FRWL8=; b=MvdVddtL2I44vD2mwuRclsKZKeZ/gQmX3+/uRu9ELW4r1UVVFeIrzSjXFHAm9YHVUd PI+ig8M1X+pYLJPK7Rt7QHGb0EDK1Ekc9ex1NfumicUjUmfDesUvOpupYWw71PCXs7Jv 4/zwKiK9zRo45NSmhm1YphWaqPVQpBYyhLYkWlaOEloNukLN/ACu9eAc2fZmSsu8P9dY Hiyx/6VuuZXtolXjfeuz8YTBI0iUBcAzrxYR8QGWnws1q7kYT/pdGf2qlvc9wshJBX1D NLNsGRXUrpb0mblEEhgK4/2Pn3dD8vV3QcxL+Q7MWcaFLlY0cQzrmqwRawHRL3afZr7k TpHQ== X-Gm-Message-State: ACrzQf1mc/IZXeGCceCzRiAHfm0hxCKixGZQzLCgXoiIhY2oHiDHb1M/ SQc26bVpxChPmRgfp8XJ/jaXGyuqcwP+UHMjVk93tJ9ug27AboGzbodImBOxrRmkjtRewnJdx5o ATmNU8uCUtDf3gyGgD2oOFHP4XOiR9VqaNTbZr69mw5T+N+tHRO9iEE5CT70vrM2qVKDZ X-Received: by 2002:a05:620a:45a9:b0:6ce:2d55:5870 with SMTP id bp41-20020a05620a45a900b006ce2d555870mr14905206qkb.362.1663659398298; Tue, 20 Sep 2022 00:36:38 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6fV+H0hGWljV0FrJiH7a0xzQsxrV3L7hzKHDAErlWVX5icqF+lKt2PA+WLzM0mQCUReZgw3w== X-Received: by 2002:a05:620a:45a9:b0:6ce:2d55:5870 with SMTP id bp41-20020a05620a45a900b006ce2d555870mr14905194qkb.362.1663659397855; Tue, 20 Sep 2022 00:36:37 -0700 (PDT) Received: from localhost ([88.120.130.27]) by smtp.gmail.com with ESMTPSA id h19-20020a05620a401300b006b9ab3364ffsm590235qko.11.2022.09.20.00.36.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Sep 2022 00:36:37 -0700 (PDT) Received: by localhost (Postfix, from userid 1000) id EA2AC581DB4; Tue, 20 Sep 2022 09:19:15 +0200 (CEST) To: libabigail@sourceware.org Subject: [PATCH, applied] Bug PR29443 - Global variables not emitted to abixml in some cases Organization: Red Hat / France X-Operating-System: Fedora 38 X-URL: http://www.redhat.com Date: Tue, 20 Sep 2022 09:19:15 +0200 Message-ID: <87edw67bt8.fsf@redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-12.1 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libabigail@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Mailing list of the Libabigail project List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-Patchwork-Original-From: Dodji Seketeli via Libabigail From: Dodji Seketeli Reply-To: Dodji Seketeli Errors-To: libabigail-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libabigail" 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 --- 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 new file mode 100644 index 00000000..5c5e4f96 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 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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!{U`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$8g_S#|OR-Z_{?r%8jL2I1{(WYwt-}x|x(yY~d zRi?5MG)}&88bgJ!_}w9UnU)07voZss5I%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 --- /dev/null +++ b/tests/data/test-read-dwarf/PR29443-missing-xx.o.abi @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + + + + + + + + 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} };