From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id 3W+wGDdgZmKhbAIAWB0awg (envelope-from ) for ; Mon, 25 Apr 2022 04:47:51 -0400 Received: by simark.ca (Postfix, from userid 112) id 5906D1E058; Mon, 25 Apr 2022 04:47:51 -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=HJwm+bRR; 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 5140E1E01D for ; Mon, 25 Apr 2022 04:47:50 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 504CE385843E for ; Mon, 25 Apr 2022 08:47:48 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 504CE385843E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1650876468; bh=ipNgK1fF4FLsBVUVtJwMh+6qscDOgD682LAc890sh1A=; h=To:Subject:In-Reply-To:References:Date:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=HJwm+bRROKcO0F4ZeDaBKFAdRqm1TJeUEs7PnDVLK9AM+lE83rAt5rdIq8D9jVkPU RTFaRxtTXMSFBfavWAFOV4ddn7QhnVWY17qh/yst/wtumkiTVH/hycijpeOyCh1+bk o8HS1yRLH48MeBLXORuIMX5wjC1iG0QYosgC71Bg= 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 0F10E3858C2D for ; Mon, 25 Apr 2022 08:47:28 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 0F10E3858C2D Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-634-FM1w7ITMPuG9Z0VaPeD9mA-1; Mon, 25 Apr 2022 04:47:26 -0400 X-MC-Unique: FM1w7ITMPuG9Z0VaPeD9mA-1 Received: by mail-wm1-f70.google.com with SMTP id d6-20020a05600c34c600b0039296a2ac7cso6901049wmq.1 for ; Mon, 25 Apr 2022 01:47:26 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:in-reply-to:references:date :message-id:mime-version; bh=ipNgK1fF4FLsBVUVtJwMh+6qscDOgD682LAc890sh1A=; b=v2oMnMfB+awqTb6+vAXOj52waYC+9/w3cYvO4OLIYWApWwgDjkSVwY5TgqdG/zUHwh hJLAeh2akncIasshhOvPICX0QLWFIwJcrj1dkFJQxVBSnDXJOqXeFX7Fe5CP6/FqKWYR TR4ZmNDLyZ+xO2y1xZsBd8R0ngkcDtTxq9m2Ef/OOTAD1fbm2Jy3KlCY4KudWKQAdVYY 0QMGLIUtjlDgnWdEtqsesphgmtfpEr14iU20Bwzph13XCppC/BF58ilX8xR/XFZAl/el IUB8/uEACKLdYLUktgl/MzN7IrUlmuX9jDqXW07YqYGEwP+OKBOYjbKYfhxNJJd6ccc7 gCkA== X-Gm-Message-State: AOAM533GPN1Oeo1TRaC4EVIVdXIDQI5dOqQ42C9tnYJNZhvu988ebnaZ rp9/dj+nStt4mnJDhqUh68NidXvlcSYJs14SuUB8uNWNSIYUvTM+aJo59bZYZbzIpqXczsfO4T/ 4IDarO7KT3CyRqH1KqsdXDg== X-Received: by 2002:a5d:4e45:0:b0:20a:d742:608a with SMTP id r5-20020a5d4e45000000b0020ad742608amr5937593wrt.84.1650876444951; Mon, 25 Apr 2022 01:47:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxzbtHh+Xc31nBTPbmaVo0n+MyzqErU9Kb4i/Pv+WzCUyyK5S6t9AD+DPoR0pl1DnZY2gEqjQ== X-Received: by 2002:a5d:4e45:0:b0:20a:d742:608a with SMTP id r5-20020a5d4e45000000b0020ad742608amr5937581wrt.84.1650876444724; Mon, 25 Apr 2022 01:47:24 -0700 (PDT) Received: from localhost (host81-136-113-48.range81-136.btcentralplus.com. [81.136.113.48]) by smtp.gmail.com with ESMTPSA id l8-20020a5d6d88000000b0020a98986534sm8796714wrs.43.2022.04.25.01.47.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Apr 2022 01:47:23 -0700 (PDT) To: "Potharla\, Rupesh" , Tom Tromey , "Potharla\, Rupesh via Gdb-patches" Subject: RE: GDB/Fortran: Support for Assumed Rank Zero. In-Reply-To: References: <20220413112753.4c6f1128@f35-zws-1> <20220414142845.281b878d@f35-zws-1> <20220415123112.697ff872@f35-zws-1> <87tuaqy0uz.fsf@tromey.com> <87sfq7rd94.fsf@redhat.com> <87a6cdqj2q.fsf@redhat.com> Date: Mon, 25 Apr 2022 09:47:22 +0100 Message-ID: <871qxlr1lx.fsf@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain 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: Andrew Burgess via Gdb-patches Reply-To: Andrew Burgess Cc: "George, Jini Susan" , "Parasuraman, Hariharan" , "Sharma, Alok Kumar" Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org Sender: "Gdb-patches" "Potharla, Rupesh" writes: > [AMD Official Use Only - General] > > Thanks Andrew, > >>> -static struct dynamic_prop_list * >>> +struct dynamic_prop_list * >>> copy_dynamic_prop_list (struct obstack *objfile_obstack, >>> struct dynamic_prop_list *list) { >> >>Please leave this as 'static', and just add a forward declaration within the >>gdbtypes.c. >> >>With that change, this is OK to commit. > > Made the code changes suggested and attached the patch which I am > planning to commit. LGTM. Thanks, Andrew > > > Regards, > Rupesh P > > > >>-----Original Message----- >>From: Andrew Burgess >>Sent: Friday, April 22, 2022 8:09 PM >>To: Potharla, Rupesh ; Tom Tromey >>; Potharla, Rupesh via Gdb-patches >patches@sourceware.org> >>Cc: George, Jini Susan ; Parasuraman, >>Hariharan ; Sharma, Alok Kumar >> >>Subject: RE: GDB/Fortran: Support for Assumed Rank Zero. >> >>[CAUTION: External Email] >> >>"Potharla, Rupesh via Gdb-patches" writes: >> >>> [AMD Official Use Only] >>> >>> Thanks, Andrew, >>> >>> Made suggested code changes and attached the updated patch. Requesting >>> to review the code changes. >> >>Thanks, this all looks fine to me, except for one small issue... >> >>> From fbfa2f4c26eeef7547603aafafb9525d66d1b172 Mon Sep 17 00:00:00 >>2001 >>> From: rupothar >>> Date: Fri, 8 Apr 2022 16:05:41 +0530 >>> Subject: [PATCH] gdb/fortran: Support for assumed rank zero >>> >>> If a variable is passed to function in FORTRAN as an argument the >>> variable is treated as an array with rank zero. GDB currently does >>> not support the case for assumed rank 0. This patch provides support >>> for assumed rank 0 and updates the testcase as well. >>> >>> Without patch: >>> Breakpoint 1, arank::sub1 (a=>> failed to resolve dynamic array rank>) at assumedrank.f90:11 >>> 11 PRINT *, RANK(a) >>> (gdb) p a >>> failed to resolve dynamic array rank >>> (gdb) p rank(a) >>> failed to resolve dynamic array rank >>> >>> With patch: >>> Breakpoint 1, arank::sub1 (a=0) at assumedrank.f90:11 >>> 11 PRINT *, RANK(a) >>> (gdb) p a >>> $1 = 0 >>> (gdb) p rank(a) >>> $2 = 0 >>> --- >>> gdb/gdbtypes.c | 21 ++++++++++++++++----- >>> gdb/gdbtypes.h | 4 +++- >>> gdb/testsuite/gdb.fortran/assumedrank.exp | 6 ++++++ >>> gdb/testsuite/gdb.fortran/assumedrank.f90 | 3 +++ >>> 4 files changed, 28 insertions(+), 6 deletions(-) >>> >>> diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c index >>> 49ecb199b07..47cf442a2d5 100644 >>> --- a/gdb/gdbtypes.c >>> +++ b/gdb/gdbtypes.c >>> @@ -2398,10 +2398,21 @@ resolve_dynamic_array_or_string (struct type >>> *type, >>> >>> if (rank == 0) >>> { >>> - /* The dynamic property list juggling below was from the original >>> - patch. I don't understand what this is all about, so I've >>> - commented it out for now and added the following error. */ >>> - error (_("failed to resolve dynamic array rank")); >>> + /* Rank is zero, if a variable is passed as an argument to a >>> + function. In this case the resolved type should not be an >>> + array, but should instead be that of an array element. */ >>> + struct type *dynamic_array_type = type; >>> + type = copy_type (TYPE_TARGET_TYPE (dynamic_array_type)); >>> + struct dynamic_prop_list *prop_list >>> + = TYPE_MAIN_TYPE (dynamic_array_type)->dyn_prop_list; >>> + if (prop_list != nullptr) >>> + { >>> + struct obstack *obstack >>> + = &type->objfile_owner ()->objfile_obstack; >>> + TYPE_MAIN_TYPE (type)->dyn_prop_list >>> + = copy_dynamic_prop_list (obstack, prop_list); >>> + } >>> + return type; >>> } >>> else if (type->code () == TYPE_CODE_STRING && rank != 1) >>> { >>> @@ -5589,7 +5600,7 @@ create_copied_types_hash (struct objfile >>> *objfile) >>> >>> /* Recursively copy (deep copy) a dynamic attribute list of a type. >>> */ >>> >>> -static struct dynamic_prop_list * >>> +struct dynamic_prop_list * >>> copy_dynamic_prop_list (struct obstack *objfile_obstack, >>> struct dynamic_prop_list *list) { >> >>Please leave this as 'static', and just add a forward declaration within the >>gdbtypes.c. >> >>With that change, this is OK to commit. >> >>Thanks, >>Andrew >> >>> diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h index >>> 769328cc9cd..99273d14c1f 100644 >>> --- a/gdb/gdbtypes.h >>> +++ b/gdb/gdbtypes.h >>> @@ -2092,7 +2092,6 @@ extern void allocate_gnat_aux_type (struct type >>> *); #define TYPE_REFERENCE_TYPE(thistype) (thistype)->reference_type >>> #define TYPE_RVALUE_REFERENCE_TYPE(thistype) >>> (thistype)->rvalue_reference_type #define TYPE_CHAIN(thistype) >>> (thistype)->chain -#define TYPE_DYN_PROP(thistype) >>> TYPE_MAIN_TYPE(thistype)->dyn_prop_list >>> /* * Note that if thistype is a TYPEDEF type, you have to call check_typedef. >>> But check_typedef does set the TYPE_LENGTH of the TYPEDEF type, >>> so you only have to call check_typedef once. Since allocate_value >>> @@ -2882,6 +2881,9 @@ extern struct type *copy_type_recursive (struct >>objfile *objfile, >>> struct type *type, >>> htab_t copied_types); >>> >>> +extern struct dynamic_prop_list * copy_dynamic_prop_list >>> + (struct obstack *objfile_obstack, struct dynamic_prop_list *list); >>> + >>> extern struct type *copy_type (const struct type *type); >>> >>> extern bool types_equal (struct type *, struct type *); diff --git >>> a/gdb/testsuite/gdb.fortran/assumedrank.exp >>> b/gdb/testsuite/gdb.fortran/assumedrank.exp >>> index 69cd168125f..e9429b44a9a 100644 >>> --- a/gdb/testsuite/gdb.fortran/assumedrank.exp >>> +++ b/gdb/testsuite/gdb.fortran/assumedrank.exp >>> @@ -58,6 +58,12 @@ while { $test_count < 500 } { >>> } >>> } >>> >>> + # Currently, flang does not support rank0. >>> + if {$test_count == 1 && [test_compiler_info {clang-*}]} { >>> + unsupported "compiler does not support rank 0" >>> + continue >>> + } >>> + >>> if ($found_final_breakpoint) { >>> break >>> } >>> diff --git a/gdb/testsuite/gdb.fortran/assumedrank.f90 >>> b/gdb/testsuite/gdb.fortran/assumedrank.f90 >>> index 7f077c3f014..7f7cf2c1f3e 100644 >>> --- a/gdb/testsuite/gdb.fortran/assumedrank.f90 >>> +++ b/gdb/testsuite/gdb.fortran/assumedrank.f90 >>> @@ -19,16 +19,19 @@ >>> >>> PROGRAM arank >>> >>> + REAL :: array0 >>> REAL :: array1(10) >>> REAL :: array2(1, 2) >>> REAL :: array3(3, 4, 5) >>> REAL :: array4(4, 5, 6, 7) >>> >>> + array0 = 0 >>> array1 = 1.0 >>> array2 = 2.0 >>> array3 = 3.0 >>> array4 = 4.0 >>> >>> + call test_rank (array0) >>> call test_rank (array1) >>> call test_rank (array2) >>> call test_rank (array3) >>> -- >>> 2.17.1 > From 91988817256be685a4b1ec7db7ef408492be6ff6 Mon Sep 17 00:00:00 2001 > From: rupothar > Date: Fri, 8 Apr 2022 16:05:41 +0530 > Subject: [PATCH] gdb/fortran: Support for assumed rank zero > > If a variable is passed to function in FORTRAN as an argument the > variable is treated as an array with rank zero. GDB currently does > not support the case for assumed rank 0. This patch provides support > for assumed rank 0 and updates the testcase as well. > > Without patch: > Breakpoint 1, arank::sub1 (a= failed to resolve dynamic array rank>) at assumedrank.f90:11 > 11 PRINT *, RANK(a) > (gdb) p a > failed to resolve dynamic array rank > (gdb) p rank(a) > failed to resolve dynamic array rank > > With patch: > Breakpoint 1, arank::sub1 (a=0) at assumedrank.f90:11 > 11 PRINT *, RANK(a) > (gdb) p a > $1 = 0 > (gdb) p rank(a) > $2 = 0 > --- > gdb/gdbtypes.c | 22 ++++++++++++++++++---- > gdb/gdbtypes.h | 1 - > gdb/testsuite/gdb.fortran/assumedrank.exp | 6 ++++++ > gdb/testsuite/gdb.fortran/assumedrank.f90 | 3 +++ > 4 files changed, 27 insertions(+), 5 deletions(-) > > diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c > index 49ecb199b07..2a51372a037 100644 > --- a/gdb/gdbtypes.c > +++ b/gdb/gdbtypes.c > @@ -47,6 +47,9 @@ > /* The value of an invalid conversion badness. */ > #define INVALID_CONVERSION 100 > > +static struct dynamic_prop_list * > +copy_dynamic_prop_list (struct obstack *, struct dynamic_prop_list *); > + > /* Initialize BADNESS constants. */ > > const struct rank LENGTH_MISMATCH_BADNESS = {INVALID_CONVERSION,0}; > @@ -2398,10 +2401,21 @@ resolve_dynamic_array_or_string (struct type *type, > > if (rank == 0) > { > - /* The dynamic property list juggling below was from the original > - patch. I don't understand what this is all about, so I've > - commented it out for now and added the following error. */ > - error (_("failed to resolve dynamic array rank")); > + /* Rank is zero, if a variable is passed as an argument to a > + function. In this case the resolved type should not be an > + array, but should instead be that of an array element. */ > + struct type *dynamic_array_type = type; > + type = copy_type (TYPE_TARGET_TYPE (dynamic_array_type)); > + struct dynamic_prop_list *prop_list > + = TYPE_MAIN_TYPE (dynamic_array_type)->dyn_prop_list; > + if (prop_list != nullptr) > + { > + struct obstack *obstack > + = &type->objfile_owner ()->objfile_obstack; > + TYPE_MAIN_TYPE (type)->dyn_prop_list > + = copy_dynamic_prop_list (obstack, prop_list); > + } > + return type; > } > else if (type->code () == TYPE_CODE_STRING && rank != 1) > { > diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h > index 769328cc9cd..7437e1db8ab 100644 > --- a/gdb/gdbtypes.h > +++ b/gdb/gdbtypes.h > @@ -2092,7 +2092,6 @@ extern void allocate_gnat_aux_type (struct type *); > #define TYPE_REFERENCE_TYPE(thistype) (thistype)->reference_type > #define TYPE_RVALUE_REFERENCE_TYPE(thistype) (thistype)->rvalue_reference_type > #define TYPE_CHAIN(thistype) (thistype)->chain > -#define TYPE_DYN_PROP(thistype) TYPE_MAIN_TYPE(thistype)->dyn_prop_list > /* * Note that if thistype is a TYPEDEF type, you have to call check_typedef. > But check_typedef does set the TYPE_LENGTH of the TYPEDEF type, > so you only have to call check_typedef once. Since allocate_value > diff --git a/gdb/testsuite/gdb.fortran/assumedrank.exp b/gdb/testsuite/gdb.fortran/assumedrank.exp > index 69cd168125f..e9429b44a9a 100644 > --- a/gdb/testsuite/gdb.fortran/assumedrank.exp > +++ b/gdb/testsuite/gdb.fortran/assumedrank.exp > @@ -58,6 +58,12 @@ while { $test_count < 500 } { > } > } > > + # Currently, flang does not support rank0. > + if {$test_count == 1 && [test_compiler_info {clang-*}]} { > + unsupported "compiler does not support rank 0" > + continue > + } > + > if ($found_final_breakpoint) { > break > } > diff --git a/gdb/testsuite/gdb.fortran/assumedrank.f90 b/gdb/testsuite/gdb.fortran/assumedrank.f90 > index 7f077c3f014..7f7cf2c1f3e 100644 > --- a/gdb/testsuite/gdb.fortran/assumedrank.f90 > +++ b/gdb/testsuite/gdb.fortran/assumedrank.f90 > @@ -19,16 +19,19 @@ > > PROGRAM arank > > + REAL :: array0 > REAL :: array1(10) > REAL :: array2(1, 2) > REAL :: array3(3, 4, 5) > REAL :: array4(4, 5, 6, 7) > > + array0 = 0 > array1 = 1.0 > array2 = 2.0 > array3 = 3.0 > array4 = 4.0 > > + call test_rank (array0) > call test_rank (array1) > call test_rank (array2) > call test_rank (array3) > -- > 2.17.1