From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id MWjDDSC4NWpV9g8AWB0awg (envelope-from ) for ; Fri, 19 Jun 2026 17:44:00 -0400 Authentication-Results: simark.ca; dkim=fail reason="signature verification failed" (768-bit key; unprotected) header.d=tromey.com header.i=@tromey.com header.a=rsa-sha256 header.s=default header.b=cm9knZ5O; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 329B91E0A3; Fri, 19 Jun 2026 17:44:00 -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.1 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_INVALID,DKIM_SIGNED,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 E5CE61E070 for ; Fri, 19 Jun 2026 17:43:58 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 04DE34BAE7F4 for ; Fri, 19 Jun 2026 21:43:58 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 04DE34BAE7F4 Authentication-Results: sourceware.org; dkim=fail reason="signature verification failed" (768-bit key, unprotected) header.d=tromey.com header.i=@tromey.com header.a=rsa-sha256 header.s=default header.b=cm9knZ5O Received: from omta40.uswest2.a.cloudfilter.net (omta40.uswest2.a.cloudfilter.net [35.89.44.39]) by sourceware.org (Postfix) with ESMTPS id 37E604BAE7D8 for ; Fri, 19 Jun 2026 21:42:37 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 37E604BAE7D8 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tromey.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 37E604BAE7D8 Authentication-Results: sourceware.org; arc=none smtp.remote-ip=35.89.44.39 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1781905357; cv=none; b=vyonwZY+zzJXnTBsA6k5P3rse+Pj9La3s0E2ADpgvxXc+d8aWw2oRI6hKdwGubvuTR46Ocs/WJvv46DV54R6QKEASpMKU7tL4vJf7X7Yej8mOKAltMijVmXU0ahAhAoOVI7TM94M1ZkqJnW0AoOM5KuDDDwb31cIxzUaVeGTPHg= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1781905357; c=relaxed/simple; bh=AcHFBy45ODM6E9U+pPo1arbPFVuBXcQuVExTCWu77Q4=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=tfPQaSkcB8fuvQrKaoKBkfEBcZbJh5YXKQCp4AGk69tNSwiOIRbpznlj9hPsRIXFb+g/YbjmSQbYfW7MGKyQBLIzd7cyI2VVF8cWhQ0c+zXm0HoA+mbJeab+x6dIg2TYQ9mW9sQQqru9mGzyCDNIr0xpakLjMTgC/cInA8wfrSE= ARC-Authentication-Results: i=1; sourceware.org; dkim=policy (768-bit key, unprotected) header.d=tromey.com header.i=@tromey.com header.a=rsa-sha256 header.s=default header.b=cm9knZ5O reason="signing key too small" DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 37E604BAE7D8 Received: from eig-obgw-5006b.ext.cloudfilter.net ([10.0.29.217]) by cmsmtp with ESMTPS id aXtDwj4Vsjgweagyxwfg7C; Fri, 19 Jun 2026 21:42:36 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id agyxw8Lm5hFZUagyxw8DIp; Fri, 19 Jun 2026 21:42:35 +0000 X-Authority-Analysis: v=2.4 cv=RduQC0tv c=1 sm=1 tr=0 ts=6a35b7cb a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=FelO9ux0wxsA:10 a=ItBw4LHWJt0A:10 a=CCpqsmhAAAAA:8 a=mDV3o1hIAAAA:8 a=cZN8AaElhdU_a1ha-RYA:9 a=ul9cdbp4aOFLsgKbc677:22 a=DCx65vhANUyCzuf5D8fC:22 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Content-Transfer-Encoding:MIME-Version:Message-ID:Date:Subject: Cc:To:From:Sender:Reply-To:Content-Type:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: In-Reply-To:References:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=2v8AS/1OjNiJYPqy6jumZ0vOCRU5/mlBk1K7Dmg5NqQ=; b=cm9knZ5OZfMFWLYmWPJPxsEwUD s784KvjtU0ElhZ7pSYLGe23tROvw21XWjUZpCoMY7/P/8UkTXGhi9CYbSYhcYbs7YJSMfS1sTIhPF 7k1XIPPgkXz13bl9nGjL0fcPU; Received: from 75-166-225-82.hlrn.qwest.net ([75.166.225.82]:48398 helo=localhost.localdomain) by box5379.bluehost.com with esmtpsa (TLS1.3) tls TLS_AES_256_GCM_SHA384 (Exim 4.99.2) (envelope-from ) id 1wagyw-00000001Ngo-2H0n; Fri, 19 Jun 2026 15:42:34 -0600 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH] Printing of Fortran arrays with dynamic elements Date: Fri, 19 Jun 2026 15:42:27 -0600 Message-ID: <20260619214227.1998085-1-tom@tromey.com> X-Mailer: git-send-email 2.49.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - box5379.bluehost.com X-AntiAbuse: Original Domain - sourceware.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - tromey.com X-BWhitelist: no X-Source-IP: 75.166.225.82 X-Source-L: No X-Exim-ID: 1wagyw-00000001Ngo-2H0n X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 75-166-225-82.hlrn.qwest.net (localhost.localdomain) [75.166.225.82]:48398 X-Source-Auth: tom+tromey.com X-Email-Count: 1 X-Org: HG=bhshared;ORG=bluehost; X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfEg285Spt8uTA7FBwPXrxx0lmJVYniXs5yprjuJXQCOCApBNu6dbtvC9N4vGt4ESv88hizVG6jt4IMtX/8DrJTbd9wqAa5IXdGhUMwLeEZyx5kyu17e7 BafYV9fLbjJW5gijGvnqZtANkZ7u3g8cyXCPeBHpAXgUFgUiCiUq17sm/nEM91GukATM3cxR7IF9w3DCZ4RNqMi/Z106PE6hdlw= 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 This bug points out a case where a Fortran array has dynamic elements, and each element must have its dynamic type resolved separately. I took the test case directly from the bug, figuring it was ok as the author is at AMD and has some tags in the repository already. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=34276 --- gdb/f-array-walker.h | 9 +++-- .../gdb.fortran/dynamic-elements.exp | 37 +++++++++++++++++++ .../gdb.fortran/dynamic-elements.f90 | 34 +++++++++++++++++ 3 files changed, 77 insertions(+), 3 deletions(-) create mode 100644 gdb/testsuite/gdb.fortran/dynamic-elements.exp create mode 100644 gdb/testsuite/gdb.fortran/dynamic-elements.f90 diff --git a/gdb/f-array-walker.h b/gdb/f-array-walker.h index bb8cb0ca599..4392e54013b 100644 --- a/gdb/f-array-walker.h +++ b/gdb/f-array-walker.h @@ -267,13 +267,16 @@ class fortran_array_walker { LONGEST elt_off = offset + calc.index_offset (i); - if (is_dynamic_type (elt_type)) + struct type *this_elt_type = elt_type; + if (is_dynamic_type (this_elt_type)) { CORE_ADDR e_address = m_address + elt_off; - elt_type = resolve_dynamic_type (elt_type, {}, e_address); + this_elt_type = resolve_dynamic_type (this_elt_type, {}, + e_address); } - m_impl.process_element (elt_type, elt_off, i, i == upperbound); + m_impl.process_element (this_elt_type, elt_off, i, + i == upperbound); } } diff --git a/gdb/testsuite/gdb.fortran/dynamic-elements.exp b/gdb/testsuite/gdb.fortran/dynamic-elements.exp new file mode 100644 index 00000000000..4a83ad09438 --- /dev/null +++ b/gdb/testsuite/gdb.fortran/dynamic-elements.exp @@ -0,0 +1,37 @@ +# Copyright 2026 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# Test where an array has elements of dynamic type, where each element +# is different. + +require allow_fortran_tests + +standard_testfile .f90 +load_lib "fortran.exp" + +if {[prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \ + {debug f90}]} { + return +} + +if {![fortran_runto_main]} { + return +} + +gdb_breakpoint [gdb_get_line_number "stop"] +gdb_continue_to_breakpoint "stop" + +gdb_test "print keys" \ + [quotemeta "@DECIMAL = (( f = (1, 2) ), ( f = (3, 4, 5) ))"] diff --git a/gdb/testsuite/gdb.fortran/dynamic-elements.f90 b/gdb/testsuite/gdb.fortran/dynamic-elements.f90 new file mode 100644 index 00000000000..61a2b6edb3c --- /dev/null +++ b/gdb/testsuite/gdb.fortran/dynamic-elements.f90 @@ -0,0 +1,34 @@ +! Copyright 2026 Free Software Foundation, Inc. +! +! This program is free software; you can redistribute it and/or modify +! it under the terms of the GNU General Public License as published by +! the Free Software Foundation; either version 3 of the License, or +! (at your option) any later version. +! +! This program is distributed in the hope that it will be useful, +! but WITHOUT ANY WARRANTY; without even the implied warranty of +! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +! GNU General Public License for more details. +! +! You should have received a copy of the GNU General Public License +! along with this program. If not, see . + +program test + implicit none + + type :: arr + integer, allocatable :: f (:) + end type + + type(arr), dimension(2) :: keys + allocate (keys(1)%f(2)) + allocate (keys(2)%f(3)) + keys(1)%f(1) = 1 + keys(1)%f(2) = 2 + keys(2)%f(1) = 3 + keys(2)%f(2) = 4 + keys(2)%f(3) = 5 + print *, keys(1)%f(1) ! stop + print *, keys(2)%f(1) + +end program test -- 2.49.0