From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by sourceware.org (Postfix) with ESMTPS id 6165C38582BC for ; Wed, 13 Jul 2022 09:38:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 6165C38582BC X-IronPort-AV: E=McAfee;i="6400,9594,10406"; a="286298518" X-IronPort-AV: E=Sophos;i="5.92,267,1650956400"; d="scan'208";a="286298518" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Jul 2022 02:38:54 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.92,267,1650956400"; d="scan'208";a="737810617" Received: from fmsmsx604.amr.corp.intel.com ([10.18.126.84]) by fmsmga001.fm.intel.com with ESMTP; 13 Jul 2022 02:38:53 -0700 Received: from fmsmsx608.amr.corp.intel.com (10.18.126.88) by fmsmsx604.amr.corp.intel.com (10.18.126.84) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.27; Wed, 13 Jul 2022 02:38:53 -0700 Received: from fmsedg602.ED.cps.intel.com (10.1.192.136) by fmsmsx608.amr.corp.intel.com (10.18.126.88) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.27 via Frontend Transport; Wed, 13 Jul 2022 02:38:53 -0700 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (104.47.59.168) by edgegateway.intel.com (192.55.55.71) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2308.27; Wed, 13 Jul 2022 02:38:30 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VkFMUMHxjU4wGnXHRH/felzTaIzVBHSXTdMd0ndnWbG9OEgVT8FahSskQJJDoh0mMoP3ItqFLhO1aQbSivA+scX4jDkJ3L1xO5No20RWA2EtKPKFqzoZtjY+3R76t8DmXWuJHOp4JihjlEaeU3YBTPXKDYQnYTeWgSma3vESkpPYUHPZ1jQfikEMhbmiCszLkH/FbwrKNff739WSp1mNcdIxWu4syReLdUZHx7O/ZYoluUy2x4ZNsrE0Iuuj2PdrORAvz1cb2YWkr9EKMsSXPpN7dA5xTvv9d7wD+pWhn/u2kmCr6yR9m3eedmIIZlsABl4qV7m0RdvpFfUbLsULGg== 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=ZzI6FMOGYSqPygB93a5kwSvwIXq3N8hyk7LVqdUqpB8=; b=FmInAsiebgKQ/YBitkR7cJzEC2PyWJymPsMBWT5T5u9KLXHQ7TXE0AVTBkh+Y3BM0X5jSALO1UJV1IuwYBDz46BjVlrUJMkaZPcJd7RdlcL+DYyTYIgUqAdproRytMhgAOEkrWf8eg8SDVILHv2b8YuFa+7litNSUL5WiJgub2IJDWEbkLrvPfemJs58E7aawlH5C69Z+KG8IqciNCm2eJNoi6ns7RSH9cIP8kdmMOq09wNOYl1iDWY5YmnzcKiORuaZOkxsSMnTbiWSAO7DJXwcUojgo0jFQEi8Sd4wFtadx2Vogr7kZ8gWyCd21R+xTapLmUimFtEuPSscRImwQQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Received: from CY4PR1101MB2071.namprd11.prod.outlook.com (2603:10b6:910:1a::10) by DM4PR11MB5453.namprd11.prod.outlook.com (2603:10b6:5:398::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5417.20; Wed, 13 Jul 2022 09:38:24 +0000 Received: from CY4PR1101MB2071.namprd11.prod.outlook.com ([fe80::b5b1:e930:177e:adc4]) by CY4PR1101MB2071.namprd11.prod.outlook.com ([fe80::b5b1:e930:177e:adc4%5]) with mapi id 15.20.5417.021; Wed, 13 Jul 2022 09:38:24 +0000 From: "Kempke, Nils-Christian" To: Andrew Burgess , "gdb-patches@sourceware.org" CC: "jinisusan.george@amd.com" , "tom@tromey.com" Subject: RE: [PATCH v3 1/1] dwarf, fortran: add support for DW_TAG_entry_point Thread-Topic: [PATCH v3 1/1] dwarf, fortran: add support for DW_TAG_entry_point Thread-Index: AQHYkdypPKosRBVm4kqEErh8Y2TzLa15KTyAgALTKbA= Date: Wed, 13 Jul 2022 09:38:23 +0000 Message-ID: References: <20220707083606.1531583-1-nils-christian.kempke@intel.com> <20220707083606.1531583-2-nils-christian.kempke@intel.com> <87k08ju7iw.fsf@redhat.com> In-Reply-To: <87k08ju7iw.fsf@redhat.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 66d52e16-0116-4f44-9e18-08da64b36e69 x-ms-traffictypediagnostic: DM4PR11MB5453:EE_ x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: rEQ9KOcfnEqP0f4tjZuIvADI2J1G/hBx6XuAgpEPOtiLFQoK8N2YWAFyXte4UKkB6zp/rDdaCmj/G6yORcMHThVPXAD8ngftmiLkvALtegPet4vzqgiTR5cZnWir6l+QHEJ43UDlBeweF0T2yfjgQxNtANjr4lcUfcfZ4k69z/mm96WBNKxjUNxwe+M1ADI90SyDsHZjrqD6us6z3WxMNb++JLuhWl0Ilw8YMiJK7k/CpQ/DZ7eDW/2j1bZJCo/dyC68DFJr2WAZt96qA0hgdPatOKDsKtxAEVfG8imFE0lIMGAKvnDjZpNTQy8TySZaCopehyirwEb7mFSQmZ5JSTyb05JnWcRl7L6d+q0gCT0IwvrFbCpLcwmbcOTr1yj3Cz5HWDKvAFc3Kc8xAnTAbecOWTWgHXZA/FRqLwAlBLG3Od628QbqJ3A6ruQSLxpir4V8LDgYoYhHC5r95zDjAdgnFMoN5REfo0ICoOWhhBI2KqZ4Y1QxDKn6/q9SwXvHKokY8YIRrSgtg97/pP+OS5j5fbI5c5foaYGkQARV1kIELVssRjUP6eW6H0z+FQBabQ3tE0uzevrHSFMWE77lKqjJ4vTQW0h+alqL+KqWE+oaLNBiEjBJ/AJoxNsNhu+L78s/63BSX0GNC1TRwOdT/nKFN3ReeN35k7PP8NsI8RiDct7EMfQrB4wNJqp41Hku+U5YAFBIh7pBrFWD88wZYpR05ghjofHG808jjX5OH2yysq41R/Tvbb8BRauQN0C9dgGNkBtYsqVzozxcp2echCgZfPEUKcXO6br2K0WJGkuP9yXy7ueLXh4dxwW92+8/djZUVCWf7J5rpDgj+Rrv9TevXNtJKnL5P67TfLibuuzee22zyw8BRhpFQezF2r/Jdv48xfCOUsXPaBlNSPDIeg== x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:CY4PR1101MB2071.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230016)(396003)(366004)(376002)(39860400002)(346002)(136003)(2906002)(86362001)(83380400001)(54906003)(30864003)(82960400001)(15974865002)(966005)(55016003)(52536014)(5660300002)(186003)(110136005)(478600001)(33656002)(64756008)(6506007)(45080400002)(53546011)(38070700005)(71200400001)(9686003)(7696005)(122000001)(8936002)(66446008)(66946007)(316002)(76116006)(66556008)(38100700002)(41300700001)(8676002)(4326008)(26005)(66476007)(2004002)(579004)(559001); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?VQbTbu5jVbLwAzQqL6AnjcCqNgSPEphmd2weOpbZ8ZMmQTMvCfKoAMfHDebw?= =?us-ascii?Q?Pf3XuxL+Ds9eXRNznSgFRyiebGEUSPKigPerbTcPxAS5jJQu8QP9ihkAJiJY?= =?us-ascii?Q?MKnR/wnNGOQeiCfd7x305mRm1fVtK53YDKAZVhR5472F0YsEbm36h1ZDFK9O?= =?us-ascii?Q?F7WWcRiSB3UMOB63sd2r/hKHfqAUVX/Bprwola0NSgCVimKj1Ws36/ksEWVR?= =?us-ascii?Q?SDULtPvTl6A9FILq8nQcG9DnE+/lN2FS+ToVW4ohMI8t1KvbpN+r6vpynRmJ?= =?us-ascii?Q?8GQEJwJw8N8oXRoGeP7Yp2OF4Sjx7NlNuY+P5itfn0LlwRhelwyKA+Dxh5UR?= =?us-ascii?Q?HLoY93PlOfKa6UrmCvp2aMldfOPxcfMqvAf+YpcLBfrZjiAfoEAyabeewC5F?= =?us-ascii?Q?2bjnNYz1PNo+j3yQMPptwQb8R/qQyN5+H9VcL5HFRuITNoahL4HYK7Ur/hcP?= =?us-ascii?Q?I5gvtodYowlJLi4Ju22LJGwZppAEwxyJwJJ3LvREnn2V2rHxvsYm6tmiwIiA?= =?us-ascii?Q?rwEmJ6Te5YcQA8tOTPj9i6ANLQTL+klM5pGFVNic0ILiOOumMTcpxIPzaq10?= =?us-ascii?Q?q+iQ/YnRCbxgq0/7MmHLwMPyGEDEIChiHRg39FbdcYo99zPLA8lnNDIsSN/e?= =?us-ascii?Q?o1gF1i6OJhjgnDo/KjplyIN8wdnwf5b6826TiWSgL9ZfuCxmdMRjHfGHz3fT?= =?us-ascii?Q?1qESRk3REZQv2C2WrCxfSbvm8BPBla2DV8YRQ6C3NG2YqRYZ1A5iW4+Eq08v?= =?us-ascii?Q?GmpLZPoPWqI6NkI7mBgnMKRH/UBIdKngGkwfbXeUh93o/ymBAuTg2YyqJ29a?= =?us-ascii?Q?vPNwmFZCa9bGP0bmZw86Q7a1i2qGCLA1bCF6QdwlocbkuTEvkIeJNmNlAvTD?= =?us-ascii?Q?t/U10Dc3tzpHG3jIpNeNSRLVpy6PFrfpJXzqTDhaNKg5JioYzUEE9kzymJ35?= =?us-ascii?Q?ixTl1YY5yexhHXDjELPndrRtHlKSkftLRmzKD2E7wCR+EEWCxwcsqThKcBm3?= =?us-ascii?Q?PhSZ59DGjeMlcTHip4DkWNsWZwJ9TGwJYjwSgGcY1Hs+1mhgY/JNM2M5sfnK?= =?us-ascii?Q?4SVY/MW9geNwc4vdM2fRO9maWmHMN2/HuBpfq2c/n8B0chzyslOzuuzqE7HI?= =?us-ascii?Q?keqkpLFHgO+k0cyhQKmwLa5tMtONcDfmxCidTtIoREasiShLlE70Ik83ZNHs?= =?us-ascii?Q?0N6TWCIsVosXLWXFlQb61kGlV4+k8wrAVdVKCa6nxO+n/6DcfFrctQqmoDTI?= =?us-ascii?Q?fhR+lx2ik3I36Ynk2swUeV6HC1QLIpd+w8m+2sX6QbxngErBmX/Np2N1gUw4?= =?us-ascii?Q?o//cN/78bZQq8mJ9XMBdn/sHryUmoDfQ/dfn/BEIcad5wiPBUxs2TgusVHP/?= =?us-ascii?Q?flwrkUdDUprEB2qdDZyHUQcLDtfqtDT0+rBvFiBe2VQpjFNq5zHN0HX/2mjK?= =?us-ascii?Q?AlQJ+ki+YPaUoAfMvKfHlUhAOLZPVPAyd6N8Wa+cBlioQ5V5t21wvhUMlCyf?= =?us-ascii?Q?Lx2MXTKhJ7RZdGngV4Cm3bTbDLDKbLJgQZBVWq1op2nPsiQ1r0tPMKQcaTyN?= =?us-ascii?Q?8EbUE8cqH0HJ2MdaAxPDCZ1rglRUM02ZKtXI6beRb3GiqQeMk2VMRNvsq2HC?= =?us-ascii?Q?4A=3D=3D?= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: CY4PR1101MB2071.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 66d52e16-0116-4f44-9e18-08da64b36e69 X-MS-Exchange-CrossTenant-originalarrivaltime: 13 Jul 2022 09:38:24.0216 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: xYuheXyUC/cZic7BybvXTnN3JC2w7bgnF8wxd0euyxCEUtVhow9s+JzxzwsrDYL5gMgBmYOyvE5DL4q2mw7gPrECP7p69/HHALnG7B6qdCo= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR11MB5453 X-OriginatorOrg: intel.com Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-10.7 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, KAM_STOCKGEN, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) 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: Wed, 13 Jul 2022 09:39:00 -0000 Hi Andrew, Thanks for the feedback! I inlined my comments and will send a v4 soon. Cheers, Nils > -----Original Message----- > From: Andrew Burgess > Sent: Monday, July 11, 2022 3:03 PM > To: Kempke, Nils-Christian ; gdb- > patches@sourceware.org > Cc: Bernhard Heckel ; Tim Wiederhake > ; jinisusan.george@amd.com; > tom@tromey.com > Subject: Re: [PATCH v3 1/1] dwarf, fortran: add support for > DW_TAG_entry_point > = > Nils-Christian Kempke via Gdb-patches > writes: > = > > Fortran provides additional entry points for subroutines and functions. > > These entry points may use only a subset (or a different set) of the > > parameters of the original subroutine. The entry points may be describ= ed > > via the DWARF tag DW_TAG_entry_point. > > > > This commit adds support for parsing the DW_TAG_entry_point DWARF > tag. > > Currently, between ifx/ifort/gfortran, only ifort is actually emitting > > this tag. Both, ifx and gfortran use the DW_TAG_subprogram tag as > > workaround/alternative. Thus, this patch really only adds more ifort > > support. Even so, some of the attached tests still fail for ifort, due > > to some wrong line info generated for the entry points in ifort. > > > > After this patch it is possible to set a breakpoint in gdb with the > > ifort compiled example at the entry points 'foo' and 'foobar', which wa= s not > > possible before. > > > > As gcc and ifx do not emit the tag I also added a test to gdb.dwarf2 > > which uses some underlying c compiled code and adds some Fortran style > DWARF > > to it emitting the DW_TAG_entry_point. Before this patch it was not > > possible to actually define breakpoint at the entry point tags. > > > > For gfortran there actually exists a bug on bugzilla, asking for the use > > of DW_TAG_entry_point over DW_TAG_subprogram: > > > > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D37134 > > > > This patch was originally posted here > > > > https://sourceware.org/legacy-ml/gdb-patches/2017-07/msg00317.html > > > > but its review/pinging got lost after a while. I reworked it to fit the > > current GDB. > = > Thanks for the revisions. I took a look through as I have an interest > in Fortran support, and I had some pretty minor feedback. I'm no expert > on the DWARF indexes and CU expansion in GDB, but that side of things > looks reasonable to me - at least I'd be happy to debug this code if > anything came up later. > = > Anyway, my feedback is inline below. > = > Thanks, > Andrew > = > > > > Co-authored-by: Bernhard Heckel > > Co-authored-by: Tim Wiederhake > > --- > > gdb/dwarf2/abbrev.c | 1 + > > gdb/dwarf2/cooked-index.h | 3 +- > > gdb/dwarf2/index-write.c | 3 +- > > gdb/dwarf2/read.c | 72 +++++- > > gdb/testsuite/gdb.dwarf2/dw2-entry-points.c | 39 ++++ > > gdb/testsuite/gdb.dwarf2/dw2-entry-points.exp | 215 > ++++++++++++++++++ > > gdb/testsuite/gdb.fortran/entry-point.exp | 84 +++++++ > > gdb/testsuite/gdb.fortran/entry-point.f90 | 67 ++++++ > > 8 files changed, 481 insertions(+), 3 deletions(-) > > create mode 100644 gdb/testsuite/gdb.dwarf2/dw2-entry-points.c > > create mode 100644 gdb/testsuite/gdb.dwarf2/dw2-entry-points.exp > > create mode 100644 gdb/testsuite/gdb.fortran/entry-point.exp > > create mode 100644 gdb/testsuite/gdb.fortran/entry-point.f90 > > > > diff --git a/gdb/dwarf2/abbrev.c b/gdb/dwarf2/abbrev.c > > index 4ca27eaa7e0..f9f87203e3e 100644 > > --- a/gdb/dwarf2/abbrev.c > > +++ b/gdb/dwarf2/abbrev.c > > @@ -88,6 +88,7 @@ tag_interesting_for_index (dwarf_tag tag) > > case DW_TAG_base_type: > > case DW_TAG_class_type: > > case DW_TAG_constant: > > + case DW_TAG_entry_point: > > case DW_TAG_enumeration_type: > > case DW_TAG_enumerator: > > case DW_TAG_imported_declaration: > > diff --git a/gdb/dwarf2/cooked-index.h b/gdb/dwarf2/cooked-index.h > > index 439cbb19fa7..e63d3001d2a 100644 > > --- a/gdb/dwarf2/cooked-index.h > > +++ b/gdb/dwarf2/cooked-index.h > > @@ -113,7 +113,8 @@ struct cooked_index_entry : public > allocate_on_obstack > > || tag =3D=3D DW_TAG_constant > > || tag =3D=3D DW_TAG_enumerator); > > case FUNCTIONS_DOMAIN: > > - return tag =3D=3D DW_TAG_subprogram; > > + return (tag =3D=3D DW_TAG_subprogram > > + || tag =3D=3D DW_TAG_entry_point); > > case TYPES_DOMAIN: > > return tag_is_type (tag); > > case MODULES_DOMAIN: > > diff --git a/gdb/dwarf2/index-write.c b/gdb/dwarf2/index-write.c > > index c3aad8dd999..a819fd49032 100644 > > --- a/gdb/dwarf2/index-write.c > > +++ b/gdb/dwarf2/index-write.c > > @@ -1128,7 +1128,8 @@ write_cooked_index (cooked_index_vector > *table, > > const char *name =3D entry->full_name (&symtab->m_string_obstack= ); > > > > gdb_index_symbol_kind kind; > > - if (entry->tag =3D=3D DW_TAG_subprogram) > > + if (entry->tag =3D=3D DW_TAG_subprogram > > + || entry->tag =3D=3D DW_TAG_entry_point) > > kind =3D GDB_INDEX_SYMBOL_KIND_FUNCTION; > > else if (entry->tag =3D=3D DW_TAG_variable > > || entry->tag =3D=3D DW_TAG_constant > > diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c > > index 23fe5679cbd..64a255c6487 100644 > > --- a/gdb/dwarf2/read.c > > +++ b/gdb/dwarf2/read.c > > @@ -8607,6 +8607,7 @@ process_die (struct die_info *die, struct > dwarf2_cu *cu) > > && die->parent->tag =3D=3D DW_TAG_subprogram) > > cu->processing_has_namespace_info =3D true; > > /* Fall through. */ > > + case DW_TAG_entry_point: > > case DW_TAG_inlined_subroutine: > > read_func_scope (die, cu); > > break; > > @@ -8723,6 +8724,7 @@ die_needs_namespace (struct die_info *die, > struct dwarf2_cu *cu) > > case DW_TAG_enumerator: > > case DW_TAG_subprogram: > > case DW_TAG_inlined_subroutine: > > + case DW_TAG_entry_point: > > case DW_TAG_member: > > case DW_TAG_imported_declaration: > > return 1; > > @@ -12994,6 +12996,53 @@ dwarf2_ranges_read_low_addrs (unsigned > offset, struct dwarf2_cu *cu, > > }); > > } > > > > +/* Determine the low and high pc of a DW_TAG_entry_point. */ > > + > > +static pc_bounds_kind > > +dwarf2_get_pc_bounds_entry_point (die_info *die, CORE_ADDR *lowpc, > > + CORE_ADDR *highpc, dwarf2_cu *cu) > > +{ > > + CORE_ADDR low =3D 0; > > + CORE_ADDR high =3D 0; > > + > > + if (die->parent->tag !=3D DW_TAG_subprogram) > > + { > > + complaint (_("DW_TAG_entry_point not embedded in > DW_TAG_subprogram")); > > + return PC_BOUNDS_INVALID; > > + } > > + > > + /* A DW_TAG_entry_point is embedded in an subprogram. Therefore, > we can use > > + the highpc from its enveloping subprogram and get the lowpc from > > + DWARF. */ > > + const enum pc_bounds_kind bounds_kind =3D dwarf2_get_pc_bounds > (die->parent, > > + &low, &high, > > + cu, nullptr, > > + nullptr); > > + if (bounds_kind =3D=3D PC_BOUNDS_INVALID || bounds_kind =3D=3D > PC_BOUNDS_NOT_PRESENT) > > + return PC_BOUNDS_INVALID; > = > Is there a reason why PC_BOUNDS_NOT_PRESENT is transformed to > PC_BOUNDS_INVALID here? I guess I would have expected 'return > bounds_kind' instead. > = No, this was a mistake in v2 I think when Jini made me aware of a problem at that same spot in the first place. The should be correct in the new pat= ch series (as an result of the outsourcing as well). > > + > > + attribute *attr_low =3D dwarf2_attr (die, DW_AT_low_pc, cu); > > + if (!attr_low) > > + { > > + complaint (_("DW_TAG_entry_point is missing DW_AT_low_pc")); > > + return PC_BOUNDS_INVALID; > > + } > > + low =3D attr_low->as_address (); > > + if (high <=3D low) > > + return PC_BOUNDS_INVALID; > > + if (low =3D=3D 0 && !cu->per_objfile->per_bfd->has_section_at_zero) > > + return PC_BOUNDS_INVALID; > > + > > + if (lowpc) > > + *lowpc =3D low; > > + if (highpc) > > + *highpc =3D high; > = > These should be 'lowpc !=3D nullptr' and 'highpc !=3D nullptr'. We don't > make use of automatic pointer to bool conversion in GDB. Ah, I stole this from the dwarf2_get_pc_bounds - yes. I corrected it in v4 for what remains of dwarf2_get_pc_bounds. > = > Also, I'm suspicious of the conditional write to *lowpc. There's only > one call to dwarf2_get_pc_bounds_entry_point, from > dwarf2_get_pc_bounds, > and that function seems to write unconditionally to lowpc. I'd be more > inclined to just add a 'gdb_assert (lowpc !=3D nullptr)' and then > unconditional write to *lowpc, like dwarf2_get_pc_bounds does. The function dwarf2_get_pc_bounds should probably also have this assert. In v4 I added it. > = > With that change done, I notice that everything after 'if (high <=3D low)' > is duplicated between dwarf2_get_pc_bounds_entry_point and > dwarf2_get_pc_bounds, so I wonder if there's any scope to have more code > sharing, I'm thinking something like this: > = > static enum pc_bounds_kind > dwarf2_get_pc_bounds ( .... ) > { > ... > enum pc_bounds_kind ret; > = > if (die->tag =3D=3D DW_TAG_entry_point) > ret =3D dwarf2_get_pc_bounds_entry_point (die, lowpc, highpc, cu); > else > ret =3D dwarf2_get_pc_bounds_???? ( .... ); > = > /* partial_die_info::read has also the strict LOW < HIGH requirement.= */ > if (high <=3D low) > return PC_BOUNDS_INVALID; > = > ... etc ... > } > = > That's a pretty iffy explanation, but hopefully you can see what I'm thin= king. Yes, so all of this is correct - I outsourced the get_pc_bounds code now in= to a function I called dwarf_get_pc_bounds_ranges_or_highlow_pc for now. I do not really know a nicer name - this one at least seems to describe a bit wh= at the function does - it get the pc bounds using ranges or high/low pc attrib= utes. I now also added an assert 'gdb_assert (lowpc !=3D nullptr);' as you indica= ted for dwarf2_get_pc_bounds_entry_point to dwarf2_get_pc_bounds - this has a bit more impact on GDB in general but should be fine. I found that these changes made the patch a bit convoluted and so I split t= his patch into 3 now - one oursourcing the code in get_pc_bounds, one adding the assert to get_pc_bounds and one introducing the DW_TAG_entry_point. > > + > > + /* Return PC_BOUNDS_RANGES/PC_BOUNDS_HIGH_LOW depending > on the parent > > + die's bounds kind. */ > > + return bounds_kind; > > +} > > + > > /* Get low and high pc attributes from a die. See enum pc_bounds_kind > > definition for the return value. *LOWPC and *HIGHPC are set iff > > neither PC_BOUNDS_NOT_PRESENT nor PC_BOUNDS_INVALID are > returned. */ > > @@ -13010,6 +13059,9 @@ dwarf2_get_pc_bounds (struct die_info *die, > CORE_ADDR *lowpc, > > CORE_ADDR high =3D 0; > > enum pc_bounds_kind ret; > > > > + if (die->tag =3D=3D DW_TAG_entry_point) > > + return dwarf2_get_pc_bounds_entry_point (die, lowpc, highpc, cu); > > + > > attr_high =3D dwarf2_attr (die, DW_AT_high_pc, cu); > > if (attr_high) > > { > > @@ -20760,6 +20812,20 @@ new_symbol (struct die_info *die, struct type > *type, struct dwarf2_cu *cu, > > sym->set_domain (LABEL_DOMAIN); > > add_symbol_to_list (sym, cu->list_in_scope); > > break; > > + case DW_TAG_entry_point: > > + /* SYMBOL_BLOCK_VALUE (sym) will be filled in later by > > + finish_block. */ > > + sym->set_aclass_index (LOC_BLOCK); > > + /* DW_TAG_entry_point provides an additional entry_point to an > > + existing sub_program. Therefore, we inherit the "external" > > + attribute from the sub_program to which the entry_point > > + belongs to. */ > > + attr2 =3D dwarf2_attr (die->parent, DW_AT_external, cu); > > + if (attr2 !=3D nullptr && attr2->as_boolean ()) > > + list_to_add =3D cu->get_builder ()->get_global_symbols (); > > + else > > + list_to_add =3D cu->list_in_scope; > > + break; > > case DW_TAG_subprogram: > > /* SYMBOL_BLOCK_VALUE (sym) will be filled in later by > > finish_block. */ > > @@ -21464,6 +21530,7 @@ read_type_die_1 (struct die_info *die, struct > dwarf2_cu *cu) > > case DW_TAG_enumeration_type: > > this_type =3D read_enumeration_type (die, cu); > > break; > > + case DW_TAG_entry_point: > > case DW_TAG_subprogram: > > case DW_TAG_subroutine_type: > > case DW_TAG_inlined_subroutine: > > @@ -21783,12 +21850,15 @@ determine_prefix (struct die_info *die, > struct dwarf2_cu *cu) > > return ""; > > case DW_TAG_subprogram: > > /* Nested subroutines in Fortran get a prefix with the name > > - of the parent's subroutine. */ > > + of the parent's subroutine. Entry points are prefixed by the > > + parent's namespace. */ > > if (cu->per_cu->lang () =3D=3D language_fortran) > > { > > if ((die->tag =3D=3D DW_TAG_subprogram) > > && (dwarf2_name (parent, cu) !=3D NULL)) > > return dwarf2_name (parent, cu); > > + else if (die->tag =3D=3D DW_TAG_entry_point) > > + return determine_prefix (parent, cu); > > } > > return ""; > > case DW_TAG_enumeration_type: > > diff --git a/gdb/testsuite/gdb.dwarf2/dw2-entry-points.c > b/gdb/testsuite/gdb.dwarf2/dw2-entry-points.c > > new file mode 100644 > > index 00000000000..e8c99d1f52e > > --- /dev/null > > +++ b/gdb/testsuite/gdb.dwarf2/dw2-entry-points.c > > @@ -0,0 +1,39 @@ > > +/* Copyright 2022 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 . > */ > > + > > +/* In the generated DWARF, we'll use the locations of foo_entry_label > and > > + foobar_entry_label as the low_pc's of our entry point TAGs. */ > > + > > +int I =3D 0; > > +int J =3D 0; > > +int K =3D 0; > > + > > +__attribute__((noinline)) > > +void bar_helper () { > = > I think GNU coding standard should be followed here, and throughout this > source, unless the test requires that standard to be broken. So: > = > void > bar_helper (void) > { > = > etc. Yes, indeed .. Fixed in v4. > = > > + __asm__("bar_helper_label: .globl bar_helper_label"); > = > I notice you used '__asm__' while all the other tests seem to use just > 'asm'. Is there a reason for this difference? Also there should be a > space before the '('. Actually, I think both exists in the tests - there are some that use '__asm= __' and some that use 'asm'. When writing the test I actually thought that '__asm__' was used more often but I think I was be wrong here. For gcc it seems that asm is the standard way and __asm__ an alternative wh= en compiling with -ansi or -std: https://gcc.gnu.org/onlinedocs/gcc/Extended-Asm.html While the gcc documentation says that __asm__ might not work with other C compilers, I've not found this to be the case with icx/icc/clang. For Inte= l icx/icc I think the __asm__ option is preferred as it holds some safeguard when also using Microsoft style asm (which is not the case here obviously). Act= ually, here https://en.cppreference.com/w/c/language/asm it says that clang and gcc prefer __asm__ over asm when using options like -std=3Dc++11. I don't really know which one to prefer - as said, there exist both within = the testsuite. I for now changed this to be 'asm'. I also added the spaces. > = > > + I++; > > + J++; > > + __asm__("foo_entry_label: .globl foo_entry_label"); > > + J++; > > + K++; > > + __asm__("foobar_entry_label: .globl foobar_entry_label"); > > +} > > + > > +int main() { > > + __asm__("main_label: .globl main_label"); > > + bar_helper (); > > + > > + return 0; > > +} > > diff --git a/gdb/testsuite/gdb.dwarf2/dw2-entry-points.exp > b/gdb/testsuite/gdb.dwarf2/dw2-entry-points.exp > > new file mode 100644 > > index 00000000000..1b5ae52fd8a > > --- /dev/null > > +++ b/gdb/testsuite/gdb.dwarf2/dw2-entry-points.exp > > @@ -0,0 +1,215 @@ > > +# Copyright 2022 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 that the DW_TAG_entry_point is handled properly by GDB and that > we can > > +# set breakpoints on function entry points. > > + > > +load_lib dwarf.exp > > + > > +# This test can only be run on targets that support DWARF-2 and use > > +# gas. > > +if {![dwarf2_support]} { > > + return 0 > > +} > > + > > +standard_testfile .c -dw.S > > + > > +if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile}] = } { > > + return -1 > > +} > > + > > +set int_size [get_sizeof "int" 4] > = > I don't think 'int_size' is used, but maybe it should be? Right now, > I/J/K are defined as 4 bytes, but declared as 'int'. You could maybe > declard I/J/K as 'int32_t' and stick with the DWARF hard-coded to 4, or > maybe make use of $int_size to adjust the DWARF for I/J/K... > = Yes, int_size was intended to be the size of the I/J/K - I changed the two "int" types to be of size $int_size. > > + > > +# Make some DWARF for the test. > > +set asm_file [standard_output_file $srcfile2] > > +Dwarf::assemble $asm_file { > > + global srcfile > > + declare_labels int_label int2_label > > + > > + get_func_info main > > + get_func_info bar_helper > > + > > + set prog_line 1 > > + set bar_line 2 > > + set foo_line 3 > > + set foobar_line 4 > > + > > + set global_I [gdb_target_symbol I] > > + set global_J [gdb_target_symbol J] > > + set global_K [gdb_target_symbol K] > > + > > + cu {} { > > + compile_unit { > > + {language @DW_LANG_Fortran90} > > + {name dw2-entry-points.f90} > > + {comp_dir /tmp} > > + } { > > + int_label: base_type { > > + {name "int"} > > + {byte_size 4 sdata} > > + {encoding @DW_ATE_signed} > > + } > > + subprogram { > > + {name prog} > > + {decl_file 1 data1} > > + {decl_line $prog_line data1} > > + {low_pc $main_start addr} > > + {high_pc "$main_start + $main_len" addr} > > + {external 1 flag} > > + {main_subprogram 1 flag} > > + } > > + subprogram { > > + {name bar} > > + {decl_file 1 data1} > > + {decl_line $bar_line data1} > > + {external 1 flag} > > + {low_pc $bar_helper_start addr} > > + {high_pc "$bar_helper_start + $bar_helper_len" addr} > > + } { > > + formal_parameter { > > + {name I} > > + {type :$int_label} > > + {location {addr $global_I} SPECIAL_expr} > > + } > > + formal_parameter { > > + {name J} > > + {type :$int_label} > > + {location {addr $global_J} SPECIAL_expr} > > + } > > + entry_point { > > + {name foo} > > + {decl_file 1 data1} > > + {decl_line $foo_line data1} > > + {low_pc foo_entry_label addr} > > + } { > > + formal_parameter { > > + {name J} > > + {type :$int_label} > > + {location {addr $global_J} SPECIAL_expr} > > + } > > + formal_parameter { > > + {name K} > > + {type :$int_label} > > + {location {addr $global_K} SPECIAL_expr} > > + } > > + } > > + entry_point { > > + {name foobar} > > + {decl_file 1 data1} > > + {decl_line $foobar_line data1} > > + {low_pc foobar_entry_label addr} > > + } { > > + formal_parameter { > > + {name J} > > + {type :$int_label} > > + {location {addr $global_J} SPECIAL_expr} > > + } > > + } > > + } > > + } > > + } > > + > > + cu {} { > > + compile_unit { > > + {language @DW_LANG_Fortran90} > > + {name dw2-entry-points-2.f90} > > + {comp_dir /tmp} > > + } { > > + int2_label: base_type { > > + {name "int"} > > + {byte_size 4 sdata} > > + {encoding @DW_ATE_signed} > > + } > > + subprogram { > > + {name barso} > > + {decl_file 1 data1} > > + {decl_line $bar_line data1} > > + {external 1 flag} > > + {low_pc $bar_helper_start addr} > > + {high_pc "$bar_helper_start + $bar_helper_len" addr} > > + } { > > + formal_parameter { > > + {name I} > > + {type :$int2_label} > > + {location {addr $global_I} SPECIAL_expr} > > + } > > + formal_parameter { > > + {name J} > > + {type :$int2_label} > > + {location {addr $global_J} SPECIAL_expr} > > + } > > + entry_point { > > + {name fooso} > > + {decl_file 1 data1} > > + {decl_line $foo_line data1} > > + {low_pc foo_entry_label addr} > > + } { > > + formal_parameter { > > + {name J} > > + {type :$int2_label} > > + {location {addr $global_J} SPECIAL_expr} > > + } > > + formal_parameter { > > + {name K} > > + {type :$int2_label} > > + {location {addr $global_K} SPECIAL_expr} > > + } > > + } > > + } > > + } > > + } > > +} > > + > > +if {[prepare_for_testing "failed to prepare" ${testfile} \ > > + [list $srcfile $asm_file] {nodebug}]} { > > + return -1 > > +} > > + > > +if ![runto_main] { > > + return -1 > > +} > > + > > +# Try whether we can set and hit breakpoints at the entry_points. > > +gdb_breakpoint "foo" > > +gdb_breakpoint "foobar" > > + > > +# Now hit the entry_point break point and check their call-stack. > > +gdb_continue_to_breakpoint "foo" > > +gdb_test "bt" [multi_line \ > > + "#0.*${hex} in foo \\(J=3D1, K=3D0\\).*" \ > > + "#1.*${hex} in prog \\(\\).*" \ > > + ] "bt foo" > > + > > +gdb_continue_to_breakpoint "foobar" > > +gdb_test "bt" [multi_line \ > > + "#0.*${hex} in foobar \\(J=3D2\\).*" \ > > + "#1.*${hex} in prog \\(\\).*" \ > > + ] "bt foobar" > > + > > +# Now try whether we can also set breakpoints on entry_points from > other CUs. > > + > > +clean_restart ${testfile} > > + > > +if ![runto_main] { > > + return -1 > > +} > > + > > +gdb_breakpoint "fooso" > > +gdb_continue_to_breakpoint "foo_so" > > + > > +gdb_test "bt" [multi_line \ > > + "#0.*${hex} in foo \\(J=3D1, K=3D0\\).*" \ > > + "#1.*${hex} in prog \\(\\).*" \ > > +] "bt fooso" > > diff --git a/gdb/testsuite/gdb.fortran/entry-point.exp > b/gdb/testsuite/gdb.fortran/entry-point.exp > > new file mode 100644 > > index 00000000000..679191f79f8 > > --- /dev/null > > +++ b/gdb/testsuite/gdb.fortran/entry-point.exp > > @@ -0,0 +1,84 @@ > > +# Copyright 2022 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 Fortran entry points for subroutines. > > + > > +if { [skip_fortran_tests] } { return -1 } > > + > > +standard_testfile .f90 > > +load_lib "fortran.exp" > > + > > +if { [prepare_for_testing $testfile.exp $testfile $srcfile {debug f90}= ] } { > > + return -1 > > +} > > + > > +if { ![fortran_runto_main] } { > > + untested "could not run to main" > > + return -1 > > +} > > + > > +# Test if we can set a breakpoint via the entry-point name. > > +set entry_point_name "foo" > > +gdb_breakpoint $entry_point_name > > +gdb_continue_to_breakpoint "continue to breakpoint: > $entry_point_name" \ > > + ".*entry foo\\(J,K,L,I1\\).*" > > + > > +gdb_test "print j" "=3D 11" "print j, entered via $entry_point_name" > > +gdb_test "print k" "=3D 22" "print k, entered via $entry_point_name" > > +gdb_test "print l" "=3D 33" "print l, entered via $entry_point_name" > > +gdb_test "print i1" "=3D 44" "print i1, entered via $entry_point_name" > > +gdb_test "info args" \ > > + [multi_line "j =3D 11" \ > > + "k =3D 22" \ > > + "l =3D 33" \ > > + "i1 =3D 44"] \ > > + "info args, entered via $entry_point_name" > > + > > +# Test if we can set a breakpoint via the function name. > > +set entry_point_name "bar" > > +gdb_breakpoint $entry_point_name > > +gdb_continue_to_breakpoint "continue to breakpoint: > $entry_point_name" \ > > + ".*subroutine bar\\(I,J,K,I1\\).*" > > + > > +gdb_test "print i" "=3D 444" "print i, entered via $entry_point_name" > > +gdb_test "print j" "=3D 555" "print j, entered via $entry_point_name" > > +gdb_test "print k" "=3D 666" "print k, entered via $entry_point_name" > > +gdb_test "print i1" "=3D 777" "print i1, entered via $entry_point_name" > > + > > +# Test a second entry point. > > +set entry_point_name "foobar" > > +gdb_breakpoint $entry_point_name > > +gdb_continue_to_breakpoint "continue to breakpoint: > $entry_point_name" \ > > + ".* entry foobar\\(J\\).*" > > + > > +gdb_test "print j" "=3D 1" "print j, entered via $entry_point_name" > > +gdb_test "info args" "j =3D 1" "info args, entered via $entry_point_na= me" > > + > > +# Test breaking at the entrypoint defined inside the module mod via its > > +# scoped name. > > +set entry_point_name "mod::mod_foo" > > + > > +# GCC moves subroutines with entry points out of the module scope into > the > > +# compile unit scope. > > +if {[test_compiler_info {gcc-*}]} { > > + setup_xfail "gcc/105272" *-*-* > > +} > > +gdb_breakpoint $entry_point_name > > + > > +if {[test_compiler_info {gcc-*}]} { > > + setup_xfail "gcc/105272" *-*-* > > +} > > +gdb_continue_to_breakpoint "continue to breakpoint: > $entry_point_name" \ > > + ".* entry mod_foo\\(\\).*" > > diff --git a/gdb/testsuite/gdb.fortran/entry-point.f90 > b/gdb/testsuite/gdb.fortran/entry-point.f90 > > new file mode 100644 > > index 00000000000..12a0557e787 > > --- /dev/null > > +++ b/gdb/testsuite/gdb.fortran/entry-point.f90 > > @@ -0,0 +1,67 @@ > > +! Copyright 2022 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 . > > + > > +module mod > > +implicit none > > + > > +contains > > + subroutine mod_bar > > + integer :: I =3D 3 > > + > > + goto 100 > > + > > + entry mod_foo > > + I =3D 33 > > + > > +100 print *, I > > + end subroutine mod_bar > > +end module mod > > + > > + > > +subroutine bar(I,J,K,I1) > > + integer :: I,J,K,L,I1 > > + integer :: A > > + real :: C > > + > > + A =3D 0 > > + C =3D 0.0 > > + > > + A =3D I + K + I1 > > + goto 300 > > + > > + entry foo(J,K,L,I1) > > + A =3D J + K + L + I1 > > + > > +200 C =3D J > > + goto 300 > > + > > + entry foobar(J) > > + goto 200 > > + > > +300 A =3D C + 1 > > + C =3D J * 1.5 > > + > > + return > > +end subroutine > > + > > +program TestEntryPoint > > + use mod > > + > > + call foo(11,22,33,44) > > + call bar(444,555,666,777) > > + call foobar(1) > > + > > + call mod_foo() > > +end program TestEntryPoint > > -- > > 2.25.1 > > > > Intel Deutschland GmbH > > Registered Address: Am Campeon 10, 85579 Neubiberg, Germany > > Tel: +49 89 99 8853-0, www.intel.de > > Managing Directors: Christin Eisenschmid, Sharon Heck, Tiffany Doon Sil= va > > Chairperson of the Supervisory Board: Nicole Lau > > Registered Office: Munich > > Commercial Register: Amtsgericht Muenchen HRB 186928 Intel Deutschland GmbH Registered Address: Am Campeon 10, 85579 Neubiberg, Germany Tel: +49 89 99 8853-0, www.intel.de Managing Directors: Christin Eisenschmid, Sharon Heck, Tiffany Doon Silva = Chairperson of the Supervisory Board: Nicole Lau Registered Office: Munich Commercial Register: Amtsgericht Muenchen HRB 186928