From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by sourceware.org (Postfix) with ESMTPS id 44B77382D53A for ; Mon, 23 May 2022 12:51:52 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 44B77382D53A Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 7769D21A32; Mon, 23 May 2022 12:51:51 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 5B75A13AA5; Mon, 23 May 2022 12:51:51 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id SE/AFGeDi2KwRwAAMHmgww (envelope-from ); Mon, 23 May 2022 12:51:51 +0000 Message-ID: <8d16664e-d919-89d2-76cb-06d84d544823@suse.de> Date: Mon, 23 May 2022 14:51:51 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.8.0 Subject: [committed][gdb/ada] Fix gdb.ada/dynamic-iface.exp with gcc 7 Content-Language: en-US From: Tom de Vries To: gdb-patches@sourceware.org Cc: Tom Tromey References: <20220513083614.GA26242@delia> In-Reply-To: <20220513083614.GA26242@delia> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-12.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_NUMSUBJECT, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE 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: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 May 2022 12:51:53 -0000 On 5/13/22 10:36, Tom de Vries wrote: > Hi, > > This test in test-case gdb.ada/dynamic-iface.exp passes with gcc 8: > ... > (gdb) print obj^M > $1 = (n => 3, a => "ABC", value => 93)^M > (gdb) PASS: gdb.ada/dynamic-iface.exp: print local as interface > ... > but fails with gcc 7: > ... > (gdb) print obj^M > $1 = ()^M > (gdb) FAIL: gdb.ada/dynamic-iface.exp: print local as interface > ... > > More concretely, we have trouble finding the type of obj. With gcc 8: > ... > $ gdb -q -batch main -ex "b concrete.adb:20" -ex run -ex "ptype obj" > ... > type = new concrete.intermediate with record > value: integer; > end record > ... > and with gcc 7: > ... > type = tagged record null; end record > ... > > The translation from tagged type to "full view" type happens in > ada_tag_value_at_base_address, where we hit this code: > ... > /* Storage_Offset'Last is used to indicate that a dynamic offset to > top is used. In this situation the offset is stored just after > the tag, in the object itself. */ > if (offset_to_top == last) > { > struct value *tem = value_addr (tag); > tem = value_ptradd (tem, 1); > tem = value_cast (ptr_type, tem); > offset_to_top = value_as_long (value_ind (tem)); > } > ... > resulting in an offset_to_top for gcc 8: > ... > (gdb) p offset_to_top > $1 = -16 > ... > and for gcc 7: > ... > (gdb) p offset_to_top > $1 = 16 > ... > > The difference is expected, it bisects to gcc commit d0567dc0dbf ("[multiple > changes]") which mentions this change. > > There's some code right after the code quoted above that deals with this > change: > ... > else if (offset_to_top > 0) > { > /* OFFSET_TO_TOP used to be a positive value to be subtracted > from the base address. This was however incompatible with > C++ dispatch table: C++ uses a *negative* value to *add* > to the base address. Ada's convention has therefore been > changed in GNAT 19.0w 20171023: since then, C++ and Ada > use the same convention. Here, we support both cases by > checking the sign of OFFSET_TO_TOP. */ > offset_to_top = -offset_to_top; > } > ... > but it's not activated because of the 'else'. > > Fix this by removing the 'else'. > > Tested on x86_64-linux, with gcc 7.5.0. > > Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29057 > > Any comments? > Committed. Thanks, - Tom > [gdb/ada] Fix gdb.ada/dynamic-iface.exp with gcc 7 > > --- > gdb/ada-lang.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c > index 8333671c48b..e0a7a302e3a 100644 > --- a/gdb/ada-lang.c > +++ b/gdb/ada-lang.c > @@ -6492,7 +6492,8 @@ ada_tag_value_at_base_address (struct value *obj) > tem = value_cast (ptr_type, tem); > offset_to_top = value_as_long (value_ind (tem)); > } > - else if (offset_to_top > 0) > + > + if (offset_to_top > 0) > { > /* OFFSET_TO_TOP used to be a positive value to be subtracted > from the base address. This was however incompatible with