From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id pHHtJK4afmIABwYAWB0awg (envelope-from ) for ; Fri, 13 May 2022 04:45:34 -0400 Received: by simark.ca (Postfix, from userid 112) id 8EB0D1E220; Fri, 13 May 2022 04:45:34 -0400 (EDT) Authentication-Results: simark.ca; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=b/MA9DSB; dkim-atps=neutral X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RDNS_DYNAMIC,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Received: from sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 15CC71E00D for ; Fri, 13 May 2022 04:45:34 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B080538485B2 for ; Fri, 13 May 2022 08:45:33 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B080538485B2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1652431533; bh=JTaSYQMrbbxib+fu/upJAT7mmSz96lqAie55rfYMi04=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=b/MA9DSBLWK7to2gnoIgldU0WrEbSG/iWVwWHPJ3ON3jSq6w4lXQahQj8tPu+GzYk CTcE2lWoLKVqQAkl6LcClcpsCebfMI0ypaJs+UtL9WsqItdRZJl8QldSr5dzq/N0VH 0BrGunVEzJ8zvLj+JiXTUz2cwwv2to5LeCjEfrK0= Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by sourceware.org (Postfix) with ESMTPS id 87B29386545C for ; Fri, 13 May 2022 08:36:19 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 87B29386545C 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-out2.suse.de (Postfix) with ESMTPS id BC3741F45F; Fri, 13 May 2022 08:36:18 +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 A454D13446; Fri, 13 May 2022 08:36:18 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id uxoAJ4IYfmLnYQAAMHmgww (envelope-from ); Fri, 13 May 2022 08:36:18 +0000 Date: Fri, 13 May 2022 10:36:17 +0200 To: gdb-patches@sourceware.org Subject: [PATCH][gdb/ada] Fix gdb.ada/dynamic-iface.exp with gcc 7 Message-ID: <20220513083614.GA26242@delia> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.10.1 (2018-07-13) 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: , From: Tom de Vries via Gdb-patches Reply-To: Tom de Vries Cc: Tom Tromey Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org Sender: "Gdb-patches" 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? 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