From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2049.outbound.protection.outlook.com [40.107.243.49]) by sourceware.org (Postfix) with ESMTPS id 25E033858412 for ; Mon, 1 Aug 2022 05:56:35 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 25E033858412 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iiGGFih3o4FiwT+vbEwWDFwKNOS+ig34++APM+X6AH2bPeVSSeKdyabCKyWacVVjwSv++Ob3mxdcfJUGzazbn6AFid+led+GNZ1LEdYk8WgA8s41uCBWpUfI511Ro+YZANguW6XDGBMr8j5m6h31qehpxLZH/53xKXpagc+YrZa1qDA0oAxRbDZozq2uHG/dIRhnHVr+OURRfIae5G6IobdJ2K6Ybvlbc+NqO/zv57WQPgnbrhYHU2THId1fm0KveWz+PTowIFlwW0zaQ29lsxWfGjTRSgQo26p6pj8odd09Go3CE23JgRHmUfoTv4laPc3BDuJuSzRFembMBO3TQw== 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=OLF8Q+Qtl2xXCkxtiICWugvFxxssSGbut/HbFUKxbMU=; b=YKQIpH8NfRy7PGS4TkG3ebIF1r7zLuhk47v332ud7f6XSyDH7xV4+YSVgilqVpqCZEW8NIimtCOHugxqJR6nn3DaHg27qhHZh5Trk/F1C0t1cUoGEGB97/neE0tZXYZvuk4gD9GF3X/JzL9JGC7LOUKlA93OOps/S7juVBMGu9/uDQ1kM7WpiVBVj28EJmpr4YMSWtPX4BHRxIt7aaM6vzaUvdno8P7bX640zn2bbeliK2FTRIxSyb+HLqwnIHUClDXwprQW8j4DvXF5zLik/K6dJuI3e3enEcICYC5quDg6jGWVdV564nzHQd6tpShZ3nf/IUoNkDtsJ41u6i8esA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none Received: from CO6PR12MB5491.namprd12.prod.outlook.com (2603:10b6:303:13b::8) by SJ0PR12MB5609.namprd12.prod.outlook.com (2603:10b6:a03:42c::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5482.15; Mon, 1 Aug 2022 05:56:32 +0000 Received: from CO6PR12MB5491.namprd12.prod.outlook.com ([fe80::788e:63e2:12a7:855c]) by CO6PR12MB5491.namprd12.prod.outlook.com ([fe80::788e:63e2:12a7:855c%9]) with mapi id 15.20.5482.016; Mon, 1 Aug 2022 05:56:32 +0000 From: "Sharma, Alok Kumar" To: "gdb-patches@sourceware.org" CC: "George, Jini Susan" Subject: RE: [PATCH] Enable Access to containing scope variables from nested inlined function Thread-Topic: [PATCH] Enable Access to containing scope variables from nested inlined function Thread-Index: AdifiG4v+p6eTZ/3TAWVx+6eDMBxZwF4u3Yg Date: Mon, 1 Aug 2022 05:56:31 +0000 Message-ID: References: In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: msip_labels: MSIP_Label_d4243a53-6221-4f75-8154-e4b33a5707a1_Enabled=true; MSIP_Label_d4243a53-6221-4f75-8154-e4b33a5707a1_SetDate=2022-07-24T18:07:24Z; MSIP_Label_d4243a53-6221-4f75-8154-e4b33a5707a1_Method=Privileged; MSIP_Label_d4243a53-6221-4f75-8154-e4b33a5707a1_Name=Public-AIP 2.0; MSIP_Label_d4243a53-6221-4f75-8154-e4b33a5707a1_SiteId=3dd8961f-e488-4e60-8e11-a82d994e183d; MSIP_Label_d4243a53-6221-4f75-8154-e4b33a5707a1_ActionId=2ab2b2ad-6dda-411b-9c7e-4fcd93ad4840; MSIP_Label_d4243a53-6221-4f75-8154-e4b33a5707a1_ContentBits=1 msip_label_d4243a53-6221-4f75-8154-e4b33a5707a1_enabled: true msip_label_d4243a53-6221-4f75-8154-e4b33a5707a1_setdate: 2022-08-01T05:56:28Z msip_label_d4243a53-6221-4f75-8154-e4b33a5707a1_method: Privileged msip_label_d4243a53-6221-4f75-8154-e4b33a5707a1_name: Public-AIP 2.0 msip_label_d4243a53-6221-4f75-8154-e4b33a5707a1_siteid: 3dd8961f-e488-4e60-8e11-a82d994e183d msip_label_d4243a53-6221-4f75-8154-e4b33a5707a1_actionid: 276f0487-1911-4c88-8450-4d737cbbe47b msip_label_d4243a53-6221-4f75-8154-e4b33a5707a1_contentbits: 0 x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: f8a7a684-88b0-4043-516c-08da738295ab x-ms-traffictypediagnostic: SJ0PR12MB5609:EE_ x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: 6yrm/G7X2dSjpnj6+6VCXO7E49YQkuZot+62J68kOHTkFo+x8TN8TWnRhuhRWF7u964DmwVVn8h0iZllvPNZ8gAZ+f3pxs/PEXkUR0mevG/joZQCQvEX388PNN/2aQog/ChvUkS0KWQo7IkaDIVosEsd+v4I5oyoIxW4R1DUBc4h/y2RoH81UIi6ycdn5LSpNCnV4gI2FwxzIHZUjYG8TTZO8B7FmWg8SW1+Z3/PBgi4OJElsw+jqCeJFVcit1uh1hec7WKKJ7D/TAT3NkB/yFV4IlO1Cc0rgQzHyQGFmRpDkO2rZBnbo4jg4IF7oDUbuVzH1uJgDgIMCVitcTuNOvsv71whgXAeHAQtWDXWhs2BmV9MBhjTHrULPigW6DOWwJ96oNMeImubcjB+0i9KJ4wMpMRC9n3W6EgSsk7QZZ5GgcbiP9X1ZlAi+8mXLWzvqHEu6EOPmAgU29R+0HnG1Es30A9P9oEwAaCXL2b3Z11oMRZhT+ftHLV5hQd5PjVR6dVUBf+neGJRyUZHZb54vhpr8XyeV5lSZXJglJ5TVZjSj97Jfn03qA9JDTxQ0R09HaSyASjuDixOd78FeDLLmppicCc+5wiQc5Oh0WWDM4Q6x61h376X48tnmeHBx0WLkYZfmIxTgI8KwDHELPHvT6xjUMfkjJuLRTP/PVaJ9BkqShWH6UsNUCFQkHDXDbAjTy8h/ty55oSkxo7Lg83CjOYtBsomY4YC3vCDWE20xGtJd9Xmp1ry2eDTnNCX2Xou0Z7/S4EE9/n6lafc2kgsRnnZlHrmIgHx8LUL02mOuLE= x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:CO6PR12MB5491.namprd12.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230016)(4636009)(346002)(39860400002)(376002)(396003)(366004)(136003)(6916009)(478600001)(71200400001)(86362001)(38070700005)(41300700001)(9686003)(7696005)(6506007)(26005)(53546011)(316002)(186003)(38100700002)(66946007)(76116006)(64756008)(2906002)(4326008)(66446008)(55016003)(66556008)(8676002)(66476007)(8936002)(5660300002)(52536014)(83380400001)(33656002)(122000001); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?V5E4y9Cwleito60vCZhEVmZRSFpk53Jw+jzWULVS3+KmArO9BSsoX7OoY3Ok?= =?us-ascii?Q?tPzuKybWRtY2zdSjCT8vVgt7tBfLODXIovmqPG8M1cVGjXZaymspr4WyfP2U?= =?us-ascii?Q?O2fmxXJiepQyJL2gvCDOtONCsvwupChLxJHilfQaFnMn7XB9W5E6aSG0AbRk?= =?us-ascii?Q?TIUOUkLdCXNaMxEEDXYfpNWQeJYUSFMIiBUfoH5DyPYMoZe9s1otQ9qj0ogF?= =?us-ascii?Q?SX5kekpX+b4qfHiwssK+XPnm8N8V1bgLVvB75byILD/MsoBK9ujy+7AKb5zT?= =?us-ascii?Q?tr3+3gVNxM0/wyHg1a7Wd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q?wJqo2hflIiZ08mwdRHeqvsV5Ad8QdIYlh192MV8SrbKe//A2iXkhW5bL2M0I?= =?us-ascii?Q?EUfvmXgV0QjSu56d/jlGx/a4WGkehEZGtJ7zm+i8n9VdZmOkLRsnD7RRfY3T?= =?us-ascii?Q?stLIzN8H3dWobiu3RcIVoltE9HAfe2Sob9t0OXAtKATwFFE/xjpP1vQSLKAh?= =?us-ascii?Q?jo0nvu9zup4UgrFx3bnBacEBhRtDPHG+PqyCWO6J2hlTBt36bPVNShQHXSEJ?= =?us-ascii?Q?3eTUjxqkZ3czojrxBeNQrEeGvMnxajdVMEmVJT3WrDPUMSpyqVZCqFAHtyzH?= =?us-ascii?Q?SLRSid7mCqiKQcKlWsTMtC0K99rCMAzM3J78pdGOQ5yvmTMYhRpQPIVmzS0Y?= =?us-ascii?Q?uwlCMNQOOKavIYSmjfs=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: CO6PR12MB5491.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: f8a7a684-88b0-4043-516c-08da738295ab X-MS-Exchange-CrossTenant-originalarrivaltime: 01 Aug 2022 05:56:32.0009 (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: AuyDiwTqVRFBcLj8TlyKMyqUqa1lVtp7fcKdo2FeuL7IvDh+Tejz6DW8WbrJmHSguPj9ZbjJ3jFRlBNCEo0sSg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR12MB5609 X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=no 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: Mon, 01 Aug 2022 05:56:37 -0000 [Public] Gentle Reminder -1 !!! Regards, Alok -----Original Message----- From: Sharma, Alok Kumar=20 Sent: Sunday, July 24, 2022 11:46 PM To: gdb-patches@sourceware.org Cc: George, Jini Susan Subject: [PATCH] Enable Access to containing scope variables from nested in= lined function [Public] Hi all, Currently inlined functions are barred from accessing any containing local = scope variable, which makes sense for global scoped functions. The gcc compiler supports nested (local scoped) function for end user, the = Clang compiler does not allow nested function for end user but compiler its= elf generates such artificial functions internally ( in case of Openmp). Ge= neral barrier by gdb reduces debug experience, current patch enhances debug= ging in such cases. Please consider below program --------------------- 1 #include 2 3 __attribute__((always_inline)) inline int outer_fun (int arg) { 4 // Inlined at (A) or not, this function should not have access to 5 // variables caller_fun_var, caller_fun_other_var in non containi= ng 6 // scoped function caller_fun. 7 int outer_local =3D 5; 8 outer_local =3D arg; 9 printf("Value of outer_local =3D %d\n", outer_local); 10 } 11 12 void caller_fun() { 13 static int caller_fun_var =3D 9; 14 volatile int caller_fun_other_var =3D 7; 15 __attribute__((always_inline)) inline void called_fun (int arg) { 16 // Inlined at (B) or not, this function should have access to 17 // containing scope variables caller_fun_var, caller_fun_other_va= r 18 int local =3D 0; 19 local =3D arg; 20 printf("Value of local =3D %d\n", local); 21 } 22 23 outer_fun(caller_fun_other_var); // <--- (A) 24 called_fun(caller_fun_other_var); // <--- (B) 25 return; 26 } 27 28 int main() { 29 caller_fun(); 30 return 0; 31 } ----------------------- Which produces DWARF as below ----------------------- 0x00000094: DW_TAG_subprogram DW_AT_name ("main") 0x000000b2: DW_TAG_subprogram DW_AT_name ("caller_fun") 0x000000d0: DW_TAG_variable DW_AT_name ("caller_fun_var") 0x000000dd: DW_TAG_variable DW_AT_name ("caller_fun_other_var") 0x000000ec: DW_TAG_subprogram DW_AT_name ("called_fun") 0x00000112: DW_TAG_inlined_subroutine DW_AT_abstract_origin (0x00000169 "outer_fun") 0x0000013f: DW_TAG_inlined_subroutine DW_AT_abstract_origin (0x000000ec "called_fun") 0x00000169: DW_TAG_subprogram DW_AT_external (true) DW_AT_name ("outer_fun") ----------------------- Please note concrete instances of abstract functions "called_fun" (0x000000= ec) and "outer_fun" (0x00000169) are DIE:0x00000112 and DIE:0x0000013f. Bot= h have DWARF tag DW_TAG_inlined_subroutine. To stop "outer_fun" (0x00000112) from accessing scope of "caller_fun", gdb = generalize barrier for DW_TAG_inlined_subroutine. GDB should instead check DW_AT_abstract_origin attribute to check actual sc= ope of corresponding abstract functions and allow "called_fun" to access sc= ope of "caller_fun". Current patch stores this information into data structure DIE_BLOCK and use= s that to compute actual containing scope. Please review the patch and let me know your comments. Regards, Alok