From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id UTtpFdiObGqWUjcAWB0awg (envelope-from ) for ; Fri, 31 Jul 2026 08:02:32 -0400 Authentication-Results: simark.ca; dkim=pass (1024-bit key; unprotected) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=Yshoa5/m; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=4na8JpQB; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=pQbWvAFR; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=hGCdsjZY; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 52BB41E099; Fri, 31 Jul 2026 08:02:32 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-5.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [38.145.34.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 280EA1E099 for ; Fri, 31 Jul 2026 08:02:31 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id E45E04B7A1D0 for ; Fri, 31 Jul 2026 12:02:29 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E45E04B7A1D0 Authentication-Results: sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=Yshoa5/m; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=4na8JpQB; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=pQbWvAFR; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=hGCdsjZY Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2a07:de40:b251:101:10:150:64:1]) by sourceware.org (Postfix) with ESMTPS id 1E7284BBC0C7 for ; Fri, 31 Jul 2026 12:02:04 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 1E7284BBC0C7 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 1E7284BBC0C7 Authentication-Results: sourceware.org; arc=none smtp.remote-ip=2a07:de40:b251:101:10:150:64:1 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1785499324; cv=none; b=TDJann1OesSqIE6yxTRafwlTUgBbJA6GHDAEKELCW6EOs7X3oCZmol3vaEfH2rjtlprXmolMSz0mWYXOyFowf9e22wO8uF/tLkG5khLY3WeZtAuhKtdrzBfTxmA5xCbhHXdVm/Tt8/KeW2GyIMtNtlrclMNxvDZ/3uOpQ+iamQU= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1785499324; c=relaxed/simple; bh=f7Jz79jMu25n1ZeUGWXFgRQHXeJjaA7t4cdi9qhQbKk=; h=DKIM-Signature:DKIM-Signature:DKIM-Signature:DKIM-Signature: Message-ID:Date:MIME-Version:Subject:To:From; b=LRWAKfhhtmSl6xdFPPQQGpve0irO8GJ8O35CZd+iVOXIrb1R2l4wbvqWWHkLlNTkLOMC/AxQLsjEG0TX2YklRomgs1j2YL3xwioHNpqhwjCbvgTuR4RlD/3/WCrqhJxYW5bd1leiFxETHhdZ3uNmJ8bhAR3C31EiLnfqd65oJ/E= ARC-Authentication-Results: i=1; sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=Yshoa5/m; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=4na8JpQB; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=pQbWvAFR; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=hGCdsjZY DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1E7284BBC0C7 Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id EBA5A7DF21; Fri, 31 Jul 2026 12:01:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1785499319; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=W+BiRuMekjdLIKHbRxb5AFBQbO05WwJAozRbnatmJAQ=; b=Yshoa5/mE3iOUIoeajdiN3b4LUOSyzU772dBOg0jG2ixHwheLv6fNjcSqaOdxZd2VeMHdK 1uUh868L21a5qvQvjZUhVAkm07Ofaz1gCXHtISeLmpuD/+rEtXRBpgxkdVUoqR6sszIhB+ nQAWWBW0M0a5b0uTKKesKm5eEaoUgCM= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1785499319; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=W+BiRuMekjdLIKHbRxb5AFBQbO05WwJAozRbnatmJAQ=; b=4na8JpQBUyzytQQzJJu7at8GrHrhdK8khORdzT0/dsOAe6EuZB0hXWprW5nWHK3PQu4242 JHBxTDn7x3p9lnAw== Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=pQbWvAFR; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=hGCdsjZY DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1785499314; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=W+BiRuMekjdLIKHbRxb5AFBQbO05WwJAozRbnatmJAQ=; b=pQbWvAFRWmrb+3a8QCTdMQqz5CEjkJdjV73nqXtuaM8OfHQKMsZUh+JBCBAaqkDwN+8qdQ UuCGSMWxdVvvmRF5QWzLfIA32hV1GRfdBOiGVUKaU9YPwSFF5TcPYNTkZUNq9JhOjq8hT8 yDDggjhFztFen9KdemGtLtRso6Tm8Bg= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1785499314; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=W+BiRuMekjdLIKHbRxb5AFBQbO05WwJAozRbnatmJAQ=; b=hGCdsjZY5wsZ9nwznN7xVqgVivkbzlMdlENEti/H1w/sV0ohElBdb3tVnl+mKcQmKGr24n Zwoh/MbA21L2jICw== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id D6CA6779B0; Fri, 31 Jul 2026 12:01:54 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id TRI6M7KObGr/bAAAD6G6ig (envelope-from ); Fri, 31 Jul 2026 12:01:54 +0000 Message-ID: <2d4071c4-3ed5-4ee0-9391-a421905fcb13@suse.de> Date: Fri, 31 Jul 2026 14:01:54 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] Fix type of imported variable for arraydim.exp To: Tom Tromey , gdb-patches@sourceware.org References: <20260730165933.2515411-1-tromey@adacore.com> Content-Language: en-US From: Tom de Vries In-Reply-To: <20260730165933.2515411-1-tromey@adacore.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Rspamd-Action: no action X-Rspamd-Queue-Id: EBA5A7DF21 X-Spamd-Result: default: False [-4.51 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:106:10:150:64:167:received]; RCVD_VIA_SMTP_AUTH(0.00)[]; ARC_NA(0.00)[]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from]; MIME_TRACE(0.00)[0:+]; MID_RHS_MATCH_FROM(0.00)[]; RCVD_TLS_ALL(0.00)[]; TO_DN_SOME(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_TWO(0.00)[2]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:mid,suse.de:email,suse.de:dkim,imap1.dmz-prg2.suse.org:helo,imap1.dmz-prg2.suse.org:rdns]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; DKIM_TRACE(0.00)[suse.de:+] X-Rspamd-Server: rspamd1.dmz-prg2.suse.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org On 7/30/26 6:59 PM, Tom Tromey wrote: > The test code for gdb.ada/arraydim.exp imports a variable using a > dummy type. Then the test tries to print the type of this variable. > This works ok with GCC, because the import is emitted as a > declaration; but this fails with gnat-llvm, where a definition is > emitted. > > This seems to be a test bug to me. This patch fixes the problem by > using the correct type here. Hi Tom, thanks for fixing this. Do I understand it correctly that there are two (independent) issues: - decl vs def: fixed in arraydim.exp - dummy type vs correct type: fixed in arraydim/foo.adb ? Anyway, the changes in arraydim.exp look fine to me. Given that it's Ada, I can't really comment on the changes in arraydim/foo.adb. I did wonder if the test-case still functioned as regression test after these changes, so I reverse-applied commit 8a48ac9579f ("wrong dimension found in ada-lang.c:ada_array_bound_from_type"): ... diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index 3c6c9af488f..0f28ce65239 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -3360,7 +3360,7 @@ ada_index_type (struct type *type, int n, const char *name) static LONGEST ada_array_bound_from_type (struct type *arr_type, int n, int which) { - struct type *type, *index_type_desc, *index_type; + struct type *type, *elt_type, *index_type_desc, *index_type; int i; gdb_assert (which == 0 || which == 1); @@ -3376,6 +3376,10 @@ ada_array_bound_from_type (struct type *arr_type, int n, int which) else type = arr_type; + elt_type = type; + for (i = n; i > 1; i--) + elt_type = type->target_type (); + if (type->is_fixed_instance ()) { /* The array has already been fixed, so we do not need to @@ -3393,14 +3397,7 @@ ada_array_bound_from_type (struct type *arr_type, int n, int which) index_type = to_fixed_range_type (index_type_desc->field (n - 1).type (), NULL); else - { - struct type *elt_type = check_typedef (type); - - for (i = 1; i < n; i++) - elt_type = check_typedef (elt_type->target_type ()); - - index_type = elt_type->index_type (); - } + index_type = elt_type->index_type (); return (which == 0 ? ada_discrete_type_low_bound (index_type) ... and managed to detect the regression with and without this patch. Reviewed-By: Tom de Vries Thanks, - Tom > --- > gdb/testsuite/gdb.ada/arraydim.exp | 7 ++++++- > gdb/testsuite/gdb.ada/arraydim/foo.adb | 7 ++----- > 2 files changed, 8 insertions(+), 6 deletions(-) > > diff --git a/gdb/testsuite/gdb.ada/arraydim.exp b/gdb/testsuite/gdb.ada/arraydim.exp > index 7b84a7af9b7..815a91ffa82 100644 > --- a/gdb/testsuite/gdb.ada/arraydim.exp > +++ b/gdb/testsuite/gdb.ada/arraydim.exp > @@ -52,8 +52,13 @@ gdb_test "print m'first(3)" " = 4" > gdb_test "print m'last(3)" " = 6" > gdb_test "print m'length(3)" " = 3" > > +# With GCC the test shows "int" as the element type, but with > +# gnat-llvm it shows "integer"; both of these are reasonable enough so > +# we accept either. The difference here is because GCC emits a > +# declaration in the DWARF for foo.o, but gnat-llvm emits a > +# definition. > gdb_test "ptype global_3dim_for_gdb_testing" \ > - "array \\(0 \\.\\. 0, 0 \\.\\. 1, 0 \\.\\. 2\\) of int" > + [quotemeta "array (0 .. 0, 0 .. 1, 0 .. 2) of @/(int|integer)/"] > > gdb_test "print global_3dim_for_gdb_testing'first" " = 0" > gdb_test "print global_3dim_for_gdb_testing'last" " = 0" > diff --git a/gdb/testsuite/gdb.ada/arraydim/foo.adb b/gdb/testsuite/gdb.ada/arraydim/foo.adb > index 86204956d00..8da63e1af93 100644 > --- a/gdb/testsuite/gdb.ada/arraydim/foo.adb > +++ b/gdb/testsuite/gdb.ada/arraydim/foo.adb > @@ -18,11 +18,8 @@ procedure Foo is > type Multi is array (1 .. 1, 2 .. 3, 4 .. 6) of Integer; > M : Multi := (others => (others => (others => 0))); > > - -- Use a fake type for importing our C multi-dimensional array. > - -- It's only to make sure the C unit gets linked in, regardless > - -- of possible optimizations. > - type Void_Star is access integer; > - E : Void_Star; > + type C_Multi is array (0 .. 0, 0 .. 1, 0 .. 2) of Integer; > + E : C_Multi; > pragma Import (C, E, "global_3dim_for_gdb_testing"); > begin > Do_Nothing (M'Address); -- STOP > > base-commit: 6d1be0b90e837e4c82eaaf6f9e8c7da7227902e1