From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2084.outbound.protection.outlook.com [40.107.92.84]) by sourceware.org (Postfix) with ESMTPS id 8C6B73858D1E for ; Fri, 11 Feb 2022 16:39:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 8C6B73858D1E ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ELFcLxiVciMQ7t+GcL23DNiSbZtfGoC39G6YwTb2VWv/CRFpGRXho8HSRNrXI1bYQQETI/7sj4pfFzsdCh1NvCJlk4tWBbfullYlDPNBpvfOcY4StpFLmKUumyvilRUPJ4haVFR0tQJ3YzutryTdGUU9M7/LQCcwUAXYYjCJCICACX1c/5aTaId/ZfLX+wMcUKccbUVaM7SW3rNjlkeTo+6MR8vWFy78bxxUuOiyY2nYlhK13wXfG64B5TfA/LwtXNflrORK18qWvKY5knQXXgYhG7rNu8OVV+SrZsOulGb7mGIhUi/sboqRqaMZLHyGxghPOxptMyWEK4Sdxi9mTQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=mDy/4fQoOk2jUHUYU4+6WAO7vVzAk7qZj7lbRRmUV+A=; b=l4WNdSyGk2+HkOROi639pB18CXE7P6ljg6ZQvxuDvu9XIx3oC3X1AD+T82J74sy8F3mrk0VNHk3XkWKzM6YYuW/w2bVYDNitXCz5bEhrE0dAvhMRZmTX+bKs3AqE16iKIMHcGeSjwvcc/+pl85e1u/Ig4h8Lgw2rlycQozMdXo2p551xKUCQe9iQWkUVX1Zk2CwYdjied+Ng92sPIEytS7RSQ6zvz/rOr+EuXB4RPcXKX/SOG3kqQ8EaNNpfIS5euOJnNJ/XbHO2iy6aZTq/riE7NxfS9BRr2CASARHe3xg1ArczR6Y2pAxptsNOYrjLNUh98m9CXjIaDWKuZPpPag== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none Received: from MW2PR12MB4684.namprd12.prod.outlook.com (2603:10b6:302:13::29) by BL1PR12MB5238.namprd12.prod.outlook.com (2603:10b6:208:31e::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4975.11; Fri, 11 Feb 2022 16:39:31 +0000 Received: from MW2PR12MB4684.namprd12.prod.outlook.com ([fe80::a56d:39af:d0ea:fdfd]) by MW2PR12MB4684.namprd12.prod.outlook.com ([fe80::a56d:39af:d0ea:fdfd%4]) with mapi id 15.20.4951.019; Fri, 11 Feb 2022 16:39:31 +0000 From: "Kumar N, Bhuvanendra" To: Andrew Burgess CC: "George, Jini Susan" , "Achra, Nitika" , "Sharma, Alok Kumar" , "gdb-patches@sourceware.org" , Joel Brobecker Subject: RE: [PATCH] Fix ptype and print commands for namelist variables(a fortran feature) Thread-Topic: [PATCH] Fix ptype and print commands for namelist variables(a fortran feature) Thread-Index: AdeYyESNFilxiCvkSRWjYmJPezxZtgVO2csAAGpd/AACxzmqgAA84QAgCGPfWdAAAOU2MALESQhwACv/V4ABM5CGMAHgE0kAAKyP/yAFgSX1oALFtceAAMBxxuAAzOSvAAAAjlTg Date: Fri, 11 Feb 2022 16:39:30 +0000 Message-ID: References: <20220203184357.GB1474789@redhat.com> <20220211162058.GD2571@redhat.com> In-Reply-To: <20220211162058.GD2571@redhat.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: msip_labels: MSIP_Label_88914ebd-7e6c-4e12-a031-a9906be2db14_Enabled=true; MSIP_Label_88914ebd-7e6c-4e12-a031-a9906be2db14_SetDate=2022-02-11T16:39:25Z; MSIP_Label_88914ebd-7e6c-4e12-a031-a9906be2db14_Method=Standard; MSIP_Label_88914ebd-7e6c-4e12-a031-a9906be2db14_Name=AMD Official Use Only-AIP 2.0; MSIP_Label_88914ebd-7e6c-4e12-a031-a9906be2db14_SiteId=3dd8961f-e488-4e60-8e11-a82d994e183d; MSIP_Label_88914ebd-7e6c-4e12-a031-a9906be2db14_ActionId=8b37ed64-1b2b-424d-b9fa-1b55bfdff354; MSIP_Label_88914ebd-7e6c-4e12-a031-a9906be2db14_ContentBits=1 msip_label_88914ebd-7e6c-4e12-a031-a9906be2db14_enabled: true msip_label_88914ebd-7e6c-4e12-a031-a9906be2db14_setdate: 2022-02-11T16:39:25Z msip_label_88914ebd-7e6c-4e12-a031-a9906be2db14_method: Standard msip_label_88914ebd-7e6c-4e12-a031-a9906be2db14_name: AMD Official Use Only-AIP 2.0 msip_label_88914ebd-7e6c-4e12-a031-a9906be2db14_siteid: 3dd8961f-e488-4e60-8e11-a82d994e183d msip_label_88914ebd-7e6c-4e12-a031-a9906be2db14_actionid: af8987ce-4002-44a2-9796-5ec008d5c09e msip_label_88914ebd-7e6c-4e12-a031-a9906be2db14_contentbits: 0 x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: ec7bb193-e294-4ca5-3cf1-08d9ed7d13e8 x-ms-traffictypediagnostic: BL1PR12MB5238:EE_ x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:219; x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: HgXqDr1UTEp8Nu7t52jEBAVmRJwE7YehiyORGx3jX5d9ufJmXnD4GcAsn86D7k6xG9xh77b18q0aaCeJL+Y7g8LSLMJL5pCYnylHDCgoW3gN6vdIJANydtIWaLIWX10n3wwdzL+HWF5sPhiiMBCVjAmyX2siygGIJ5D91DqxHj5zioXHqPNEbTlP2h2e66ZXjOlqfqpWFZLccWWjblL3+pKlFIot6HZZpjqISAnJzFKILCRu3kPfq177eI3gzC6HmQ+vkfEOoRyz2u0l51YGVonpWDKJTzbPCNH1jcMMB2Da2fOWipqJJuvVQ5Fr77FzFtvCFQgYwJLKqBlJ3foihVMZVMf6cM2zd4k3qMdmeC8E4W8ZEeKjUBujo5NNBkHN22FNzxTIO96ui6AjsOmEsLNVDZommPg8PSq17Ib38zYJeJZMgtvwbQZ9u9HEiWlEnszQk5EJwjPbAFhYa1jjGpsKjQz76c38o2qYDaxln7nqvhD9uvS41ECVOOXZk/iqxbgdIJspPUjawqrlVeiM1yt27S5ylQO2QQBIMXxygqjs7OR0Pb/HZzAFwogZU9htJZIHBAtjHGb5LjroX9/M9oO1T8UmXy5H/eYKh6Qb/Vih9aoIqiwzhWQDsNIa5OOdaG/YNhMjNqp3T6EdRprsUd8v/vwa2du0p1n60wBYtfq7HgIg9t0VCmBRae/Twd2vzIwDpP/sFh34U6xgTNcYwr/QbFihJcwCSK7rYBbJrT0RacF4QTJJUIzpeRWaiueoTJVQb1dCVylULQhlpaAEslW9qLgRy92cnv+ZKcu1wZ+jcNFaK+7v6NJEsE40NPhl x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:MW2PR12MB4684.namprd12.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(4636009)(366004)(55016003)(122000001)(316002)(26005)(186003)(86362001)(9686003)(71200400001)(6506007)(7696005)(55236004)(33656002)(6916009)(54906003)(38100700002)(30864003)(83380400001)(4326008)(53546011)(76116006)(66476007)(66946007)(8676002)(8936002)(64756008)(508600001)(5660300002)(66556008)(2906002)(66446008)(52536014)(38070700005)(2004002); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?HdO8quyHpUTCGMtySfjH2sWj/FPajYastKXzvHNo00BIyWNPH2+X8UoJ5yrX?= =?us-ascii?Q?DnMu1xT4rUcIwB/FZ4hyPN4jIYpdxU+2iqVhDus9sPZeS3CjX7Dof/baGeQR?= =?us-ascii?Q?976OPITjCtp+ncrZrUU88RdxWibWK7AdUyvIQ59nGnEsI8TeaW6pR9BGxBAw?= =?us-ascii?Q?/RyGq1krCaQVI9dapY6i2NasoxHKsok0z8uYi4+KiftaoaLUmAREXjZyz+TB?= =?us-ascii?Q?fTU9OivYDTmjAEa28mzeT+hBYf3mvjrg8TMffcwovr4GMCWqa/Vl9mqZssHJ?= =?us-ascii?Q?/KaXeaTA0GOuFMSSFBkpe6j15Zgw6WFi8hHd08E++z7KNqnBKXoSfrgybMUb?= =?us-ascii?Q?jR89k1PL1NwMm4LlvODZXMxF1mui4aHekwp0jQbtXQsjFKS+XozZtOw89i5d?= =?us-ascii?Q?TfSCiiE2mFgd1Ym8OiAnD3k6U1GPyBS/L7WKNyftS2tgBJS3Uomorj2JR91V?= =?us-ascii?Q?E+Xrc8Rqh3T0Qh2cAhrhsnNP05lzVdAKmObzbHb+Uhp8UqdCLotZAuUjGg5I?= =?us-ascii?Q?y8+542ihpNC18qIywek6FlEOjgWuJXn9akhGbvTculBlJ0jdJLrZvdPmZC4V?= =?us-ascii?Q?UAp9PlzZObblLopdf+MUJ/4zY3w0502+MY+41jKbMFTEZNHpa53+0F1YAX/J?= =?us-ascii?Q?kQSSSznmasMG28MjsuiSxWaCKWPd5asX5+pPf3egtUoXiKb9F4q6LYavqn+F?= =?us-ascii?Q?CgCDyGk6oZbI4RgKt6wbpU4W4vX/TWnA0OlCQdznWuLCGobGFBL+etgUFHH/?= =?us-ascii?Q?xLHkMze41N/6hE63UjUZwawKkvCgKs2oq8scEDYhnq+vhVtZt9wFLzv9uWMg?= =?us-ascii?Q?UpOkYzd3rb292eiJSQplxqVHtO5dDy9YeXVhmU0SG0Eo3qnn2zDkC1/cKfF/?= =?us-ascii?Q?qa+6KSnI7YuA52wNUFfxxblZz2wmsF2YL+jVi5/SrqhtSbOl7aQSepGbhp4y?= =?us-ascii?Q?Pfi5l7Zz48hNwqtTS4veqJYAm5KjivHZdyKj+FYq8gPBf9hcDCc7hU0tBsd8?= =?us-ascii?Q?P1FHF10DdETBiBIUwRT+H/Ke7sIIXogvRyVA6v2Cci5jcLNeuaHKHGxTboR1?= =?us-ascii?Q?t8oBZYEpO8kVrLDJOqHZoXGgKhHdnTz/YT6DOOOwfKk9Xmjer/Yo4XFvjVwv?= =?us-ascii?Q?KM8W83w6Xwm6Vhup2mRkX/8LjqKpOQ7tBdBNqij6bzcG37bDo51rFKFQbYTl?= =?us-ascii?Q?3SnUPZFa2kB1TGcSKKJ6KyoABM89btr75YetmLPfVXIp3QwjiWrfr39A6lz1?= =?us-ascii?Q?o+uY7ZOrvX8Iehp1VoxlT2HlA601iUQGrriZIXGIgRRJPchiaqdh3TzrgwSd?= =?us-ascii?Q?vinFYradud1Ureqdvw5W1lznLywaet8o0yHTzKxMJJCu17yLJwmg+9pVeWx4?= =?us-ascii?Q?SU2lXVeqFH50M5ANJizey0c63SfgASrSj0nGh/GTPQ2eYHJnOc6T/fP4pS9L?= =?us-ascii?Q?JIyH81acXquD15C1K89CEK/E3J8BVhkhevMMTTZGE/Sz/QdjDvquDLpiO7mY?= =?us-ascii?Q?OcIhakg1shxwd67OFPz8aAl6iru1lDb4IT/+1KrKeR6pll4kf8beanHelfLx?= =?us-ascii?Q?zyqUVHJZssc++Ag64jdeftITho3/Dpf77XkTF0loOusTf9XLV0qCNXVmtb/w?= =?us-ascii?Q?Mw=3D=3D?= Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: MW2PR12MB4684.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: ec7bb193-e294-4ca5-3cf1-08d9ed7d13e8 X-MS-Exchange-CrossTenant-originalarrivaltime: 11 Feb 2022 16:39:30.9067 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: 63S9SiFLaH/8HGhfWEsiHUxOl32HBsRCmUpDu7UDRGJxFa5ACGjJL/nOdT1kFuoG2u5cVKqCbKqv3tQY9n0fHw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL1PR12MB5238 X-Spam-Status: No, score=-11.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, KAM_STOCKGEN, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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: Fri, 11 Feb 2022 16:39:37 -0000 [AMD Official Use Only] Thanks a lot Andrew and Joel for the valuable review comments regards, bhuvan -----Original Message----- From: Andrew Burgess =20 Sent: Friday, February 11, 2022 9:51 PM To: Kumar N, Bhuvanendra Cc: George, Jini Susan ; Achra, Nitika ; Sharma, Alok Kumar ; gdb-patches@so= urceware.org; Joel Brobecker Subject: Re: [PATCH] Fix ptype and print commands for namelist variables(a = fortran feature) [CAUTION: External Email] * Kumar N, Bhuvanendra via Gdb-patches [2022-0= 2-07 14:41:09 +0000]: > [AMD Official Use Only] > > Hi Andrew, > > Thanks for the revised patch and suggestions, I looked at your code chang= es (rearranging the code in f-valprint.c), the changes looks fine and also = unit and regression tested the changes. Also tested with -D_GLIBCXX_DEBUG= =3D1, even though we are not calling value_field() for namelist now. > > Please let me know how to proceed further, thanks again Thanks, I pushed this patch. Andrew > > Regards, > bhuvan > > -----Original Message----- > From: Andrew Burgess > Sent: Friday, February 4, 2022 12:14 AM > To: Kumar N, Bhuvanendra > Cc: Joel Brobecker ; George, Jini Susan=20 > ; Achra, Nitika ;=20 > Sharma, Alok Kumar ;=20 > gdb-patches@sourceware.org; E, Nagajyothi > Subject: Re: [PATCH] Fix ptype and print commands for namelist=20 > variables(a fortran feature) > > [CAUTION: External Email] > > * Kumar N, Bhuvanendra via Gdb-patches [2022= -01-20 16:20:46 +0000]: > > > [AMD Official Use Only] > > > > Hi all, > > > > Sorry for the delay in sharing the revised patch, I was occupied with s= ome other work. Please find the revised patch with all the details and also= patch is inlined below. > > > > Reason for the assert failure when GDB is built with > > -D_GLIBCXX_DEBUG=3D1 is, the size or length(TYPE_LENGTH) of the=20 > > namelist variable type was not populated, it was zero, hence assert=20 > > was failing in gdbsupport/array-view.h. Now this is fixed and I=20 > > could test with > > -D_GLIBCXX_DEBUG=3D1 > > > > Compiler is not emitting the size of the namelist variable type,=20 > > hence GDB is calculating it. In similar types like=20 > > DW_TAG_structure_type, DW_AT_byte_size attribute is emitted by=20 > > compiler and GDB uses it with TYPE_LENGTH. It's not the case with=20 > > DW_TAG_namelist. Hence size of the namelist variable type is=20 > > calculated in GDB. Also unlike DW_TAG_structure_type, namelist items=20 > > are not allocated in continuous memory, they are spread across,=20 > > hence for each namelist item symbol table lookup is done before=20 > > printing its value. This way making sure namelist items printing is int= act. > > Hi Bhuvan, > > Thanks for continuing to work on this feature, and sorry for the slow tur= n around on reviews. > > I took a look at the changes you made in the latest version, and I wasn't= completely convinced. Setting the type length seems like a bad idea, give= n that these namelists don't have a valid address, and don't actually live = in memory in a contiguous block. I assume this is why you ended up adding = the change in value.c too. > > I think if we just reorder the code in f-valprint.c a little, then we can= avoid the need to compute the type length. Could you test the patch below= please, and let me know if you see any problems. > > This is basically your work with some whitespace clean up in dwarf2/read.= c, the value.c change reverted, and f-valprint.c reworked a little. Oh, an= d I updated the copyright year in the testsuite files. > > Let me know what you think. > > Thanks, > Andrew > > --- > > commit 3b365631ef31051210b7ad26463aaccd3501cbfd > Author: Bhuvanendra Kumar N > Date: Wed Feb 2 17:52:27 2022 +0000 > > gdb/fortran: support ptype and print commands for namelist=20 > variables > > Gfortran supports namelists (a Fortran feature); it emits > DW_TAG_namelist and DW_TAG_namelist_item dies. But gdb does not > process these dies and does not support 'print' or 'ptype' commands o= n > namelist variables. > > An attempt to print namelist variables results in gdb bailing out wit= h > the error message as shown below. > > (gdb) print nml > No symbol "nml" in current context. > > This commit is to make the print and ptype commands work for namelist > variables and its items. Sample output of these commands is shared > below, with fixed gdb. > > (gdb) ptype nml > type =3D Type nml > integer(kind=3D4) :: a > integer(kind=3D4) :: b > End Type nml > (gdb) print nml > $1 =3D ( a =3D 10, b =3D 20 ) > > diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index=20 > 1a749eac334..056ba97ee91 100644 > --- a/gdb/dwarf2/read.c > +++ b/gdb/dwarf2/read.c > @@ -9694,6 +9694,7 @@ process_die (struct die_info *die, struct dwarf2_cu= *cu) > case DW_TAG_interface_type: > case DW_TAG_structure_type: > case DW_TAG_union_type: > + case DW_TAG_namelist: > process_structure_scope (die, cu); > break; > case DW_TAG_enumeration_type: > @@ -14556,8 +14557,21 @@ dwarf2_add_field (struct field_info *fip,=20 > struct die_info *die, > > fp =3D &new_field->field; > > - if (die->tag =3D=3D DW_TAG_member && ! die_is_declaration (die, cu)) > - { > + if ((die->tag =3D=3D DW_TAG_member || die->tag =3D=3D DW_TAG_namelist_= item) > + && !die_is_declaration (die, cu)) > + { > + if (die->tag =3D=3D DW_TAG_namelist_item) > + { > + /* Typically, DW_TAG_namelist_item are references to namelist i= tems. > + If so, follow that reference. */ > + struct attribute *attr1 =3D dwarf2_attr (die, DW_AT_namelist_it= em, cu); > + struct die_info *item_die =3D nullptr; > + struct dwarf2_cu *item_cu =3D cu; > + if (attr1->form_is_ref ()) > + item_die =3D follow_die_ref (die, attr1, &item_cu); > + if (item_die !=3D nullptr) > + die =3D item_die; > + } > /* Data member other than a C++ static data member. */ > > /* Get type of field. */ > @@ -15615,6 +15629,10 @@ read_structure_type (struct die_info *die, struc= t dwarf2_cu *cu) > { > type->set_code (TYPE_CODE_UNION); > } > + else if (die->tag =3D=3D DW_TAG_namelist) > + { > + type->set_code (TYPE_CODE_NAMELIST); > + } > else > { > type->set_code (TYPE_CODE_STRUCT); @@ -15817,7 +15835,8 @@ handle_= struct_member_die (struct die_info *child_die, struct type *type, > struct dwarf2_cu *cu) { > if (child_die->tag =3D=3D DW_TAG_member > - || child_die->tag =3D=3D DW_TAG_variable) > + || child_die->tag =3D=3D DW_TAG_variable > + || child_die->tag =3D=3D DW_TAG_namelist_item) > { > /* NOTE: carlton/2002-11-05: A C++ static data member > should be a DW_TAG_member that is a declaration, but @@ -15860,8= +15879,10 @@ handle_struct_member_die (struct die_info *child_die, struct = type *type, > handle_variant (child_die, type, fi, template_args, cu); } > > -/* Finish creating a structure or union type, including filling in > - its members and creating a symbol for it. */ > +/* Finish creating a structure or union type, including filling in its > + members and creating a symbol for it. This function also handles Fort= ran > + namelist variables, their items or members and creating a symbol for > + them. */ > > static void > process_structure_scope (struct die_info *die, struct dwarf2_cu *cu) @@ = -21963,9 +21984,17 @@ new_symbol (struct die_info *die, struct type *type, = struct dwarf2_cu *cu, > case DW_TAG_union_type: > case DW_TAG_set_type: > case DW_TAG_enumeration_type: > - SYMBOL_ACLASS_INDEX (sym) =3D LOC_TYPEDEF; > - SYMBOL_DOMAIN (sym) =3D STRUCT_DOMAIN; > - > + case DW_TAG_namelist: > + if (die->tag =3D=3D DW_TAG_namelist) > + { > + SYMBOL_ACLASS_INDEX (sym) =3D LOC_STATIC; > + SYMBOL_DOMAIN (sym) =3D VAR_DOMAIN; > + } > + else > + { > + SYMBOL_ACLASS_INDEX (sym) =3D LOC_TYPEDEF; > + SYMBOL_DOMAIN (sym) =3D STRUCT_DOMAIN; > + } > { > /* NOTE: carlton/2003-11-10: C++ class symbols shouldn't > really ever be static objects: otherwise, if you try @@ -2= 2902,6 +22931,7 @@ dwarf2_name (struct die_info *die, struct dwarf2_cu *cu) > && die->tag !=3D DW_TAG_class_type > && die->tag !=3D DW_TAG_interface_type > && die->tag !=3D DW_TAG_structure_type > + && die->tag !=3D DW_TAG_namelist > && die->tag !=3D DW_TAG_union_type) > return NULL; > > @@ -22926,6 +22956,7 @@ dwarf2_name (struct die_info *die, struct dwarf2_= cu *cu) > case DW_TAG_interface_type: > case DW_TAG_structure_type: > case DW_TAG_union_type: > + case DW_TAG_namelist: > /* Some GCC versions emit spurious DW_AT_name attributes for unnam= ed > structures or unions. These were of the form "._%d" in GCC 4.1, > or simply "" or "" in GCC=20 > 4.3 diff --git a/gdb/f-typeprint.c b/gdb/f-typeprint.c index=20 > 6fd3d519c86..3b26bf74b61 100644 > --- a/gdb/f-typeprint.c > +++ b/gdb/f-typeprint.c > @@ -121,6 +121,7 @@ f_language::f_type_print_varspec_prefix (struct type = *type, > case TYPE_CODE_UNDEF: > case TYPE_CODE_STRUCT: > case TYPE_CODE_UNION: > + case TYPE_CODE_NAMELIST: > case TYPE_CODE_ENUM: > case TYPE_CODE_INT: > case TYPE_CODE_FLT: > @@ -261,6 +262,7 @@ f_language::f_type_print_varspec_suffix (struct type = *type, > case TYPE_CODE_UNDEF: > case TYPE_CODE_STRUCT: > case TYPE_CODE_UNION: > + case TYPE_CODE_NAMELIST: > case TYPE_CODE_ENUM: > case TYPE_CODE_INT: > case TYPE_CODE_FLT: > @@ -305,7 +307,8 @@ f_language::f_type_print_base (struct type *type, str= uct ui_file *stream, > const char *prefix =3D ""; > if (type->code () =3D=3D TYPE_CODE_UNION) > prefix =3D "Type, C_Union :: "; > - else if (type->code () =3D=3D TYPE_CODE_STRUCT) > + else if (type->code () =3D=3D TYPE_CODE_STRUCT > + || type->code () =3D=3D TYPE_CODE_NAMELIST) > prefix =3D "Type "; > fprintf_filtered (stream, "%*s%s%s", level, "", prefix, type->name= ()); > return; > @@ -391,6 +394,7 @@ f_language::f_type_print_base (struct type *type,=20 > struct ui_file *stream, > > case TYPE_CODE_STRUCT: > case TYPE_CODE_UNION: > + case TYPE_CODE_NAMELIST: > if (type->code () =3D=3D TYPE_CODE_UNION) > fprintf_filtered (stream, "%*sType, C_Union :: ", level, ""); > else > diff --git a/gdb/f-valprint.c b/gdb/f-valprint.c index=20 > 3d13eb11fb0..10dfcaf7c41 100644 > --- a/gdb/f-valprint.c > +++ b/gdb/f-valprint.c > @@ -512,24 +512,38 @@ f_language::value_print_inner (struct value=20 > *val, struct ui_file *stream, > > case TYPE_CODE_STRUCT: > case TYPE_CODE_UNION: > + case TYPE_CODE_NAMELIST: > /* Starting from the Fortran 90 standard, Fortran supports derived > types. */ > fprintf_filtered (stream, "( "); > for (index =3D 0; index < type->num_fields (); index++) > { > - struct value *field =3D value_field (val, index); > - > - struct type *field_type =3D check_typedef (type->field (index).= type ()); > - > + struct type *field_type > + =3D check_typedef (type->field (index).type ()); > > if (field_type->code () !=3D TYPE_CODE_FUNC) > { > - const char *field_name; > + const char *field_name =3D type->field (index).name (); > + struct value *field; > + > + if (type->code () =3D=3D TYPE_CODE_NAMELIST) > + { > + /* While printing namelist items, fetch the appropriate > + value field before printing its value. */ > + struct block_symbol sym > + =3D lookup_symbol (field_name, get_selected_block (nu= llptr), > + VAR_DOMAIN, nullptr); > + if (sym.symbol =3D=3D nullptr) > + error (_("failed to find symbol for name list compone= nt %s"), > + field_name); > + field =3D value_of_variable (sym.symbol, sym.block); > + } > + else > + field =3D value_field (val, index); > > if (printed_field > 0) > fputs_filtered (", ", stream); > > - field_name =3D type->field (index).name (); > if (field_name !=3D NULL) > { > fputs_styled (field_name, variable_name_style.style=20 > (), diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h index=20 > 7238873e4db..5072dc24bfa 100644 > --- a/gdb/gdbtypes.h > +++ b/gdb/gdbtypes.h > @@ -196,6 +196,19 @@ enum type_code > > /* * Fixed Point type. */ > TYPE_CODE_FIXED_POINT, > + > + /* * Fortran namelist is a group of variables or arrays that can be > + read or written. > + > + Namelist syntax: NAMELIST / groupname / namelist_items ... > + NAMELIST statement assign a group name to a collection of variabl= es > + called as namelist items. The namelist items can be of any data t= ype > + and can be variables or arrays. > + > + Compiler emit DW_TAG_namelist for group name and DW_TAG_namelist_= item > + for each of the namelist items. GDB process these namelist dies > + and print namelist variables during print and ptype commands. */ > + TYPE_CODE_NAMELIST, > }; > > /* * Some bits for the type's instance_flags word. See the macros=20 > diff --git a/gdb/testsuite/gdb.fortran/namelist.exp=20 > b/gdb/testsuite/gdb.fortran/namelist.exp > new file mode 100644 > index 00000000000..d6263e12fec > --- /dev/null > +++ b/gdb/testsuite/gdb.fortran/namelist.exp > @@ -0,0 +1,50 @@ > +# Copyright (C) 2021-2022 Free Software Foundation, Inc. > + > +# This program is free software; you can redistribute it and/or=20 > +modify # it under the terms of the GNU General Public License as=20 > +published by # the Free Software Foundation; either version 3 of the=20 > +License, or # (at your option) any later version. > +# > +# This program is distributed in the hope that it will be useful, #=20 > +but WITHOUT ANY WARRANTY; without even the implied warranty of #=20 > +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU=20 > +General Public License for more details. > +# > +# You should have received a copy of the GNU General Public License #=20 > +along with this program. If not, see . > + > +# This file is part of the gdb testsuite. It contains tests for=20 > +fortran # namelist. > + > +if { [skip_fortran_tests] } { return -1 } > + > +standard_testfile .f90 > +load_lib "fortran.exp" > + > +if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug f= 90}]} { > + return -1 > +} > + > +if ![fortran_runto_main] then { > + perror "couldn't run to main" > + continue > +} > + > +# Depending on the compiler being used, the type names can be printed=20 > +# differently. > +set int [fortran_int4] > + > +gdb_breakpoint [gdb_get_line_number "Display namelist"]=20 > +gdb_continue_to_breakpoint "Display namelist" > + > +if {[test_compiler_info {gcc-*}]} { > + gdb_test "ptype nml" \ > + "type =3D Type nml\r\n *$int :: a\r\n *$int :: b\r\n *End Type n= ml" > + gdb_test "print nml" \ > + "\\$\[0-9\]+ =3D \\( a =3D 10, b =3D 20 \\)" > +} else { > + gdb_test "ptype nml" \ > + "No symbol \"nml\" in current context\\." > + gdb_test "print nml" \ > + "No symbol \"nml\" in current context\\." > +} > diff --git a/gdb/testsuite/gdb.fortran/namelist.f90=20 > b/gdb/testsuite/gdb.fortran/namelist.f90 > new file mode 100644 > index 00000000000..9e2ba0489d2 > --- /dev/null > +++ b/gdb/testsuite/gdb.fortran/namelist.f90 > @@ -0,0 +1,27 @@ > +! Copyright (C) 2021-2022 Free Software Foundation, Inc. > +! > +! This program is free software; you can redistribute it and/or=20 > +modify ! it under the terms of the GNU General Public License as=20 > +published by ! the Free Software Foundation; either version 3 of the Lic= ense, or ! > +(at your option) any later version. > +! > +! This program is distributed in the hope that it will be useful, !=20 > +but WITHOUT ANY WARRANTY; without even the implied warranty of ! > +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ! GNU=20 > +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 . > +! > +! This file is the Fortran source file for namelist.exp. > + > +program main > + > + integer :: a, b > + namelist /nml/ a, b > + > + a =3D 10 > + b =3D 20 > + Write(*,nml) ! Display namelist > + > +end program main > diff --git a/include/dwarf2.def b/include/dwarf2.def index=20 > 4214c80907a..530c6f849f9 100644 > --- a/include/dwarf2.def > +++ b/include/dwarf2.def > @@ -289,7 +289,7 @@ DW_AT (DW_AT_frame_base, 0x40) DW_AT=20 > (DW_AT_friend, 0x41) DW_AT (DW_AT_identifier_case, 0x42) DW_AT=20 > (DW_AT_macro_info, 0x43) -DW_AT (DW_AT_namelist_items, 0x44) > +DW_AT (DW_AT_namelist_item, 0x44) > DW_AT (DW_AT_priority, 0x45) > DW_AT (DW_AT_segment, 0x46) > DW_AT (DW_AT_specification, 0x47)