From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2043.outbound.protection.outlook.com [40.107.92.43]) by sourceware.org (Postfix) with ESMTPS id 21E9E3858CDA for ; Mon, 12 Sep 2022 05:21:15 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 21E9E3858CDA ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZE3hQ2tILGBK0SxAimyJv1ciLrEHEFeJ5tqfO08ls11kYSpCzLUfZr5N91Bn6oxLXHKqRcIs2QUtPOUlwOlVEygumprchJC5rPZbuZQmKtYX1JryqBqvRe12maS11XesdCCayL/YHQIR++bH8wRZJWvj5sQ+7eNLF2mUB2us4zA3g0dNYz1IVof2fAwFFhF1p/UhdDzgdaomXqQXy7GytT23Pq3fFljr5hdOJqHh2CltEpGU7X6X0uA8n2Yhe0Mp2jeKNkLciyUmu62pFbI4KkTb9/0teeKlR2tqYac0damUUt2PfxkDKQdj3/cZj8qKhDpyVoYsOUjJIf159j/HWA== 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=wR+16+/7oE/4wmLtx82rropiPVCBTsh3jyscXARbp1M=; b=NzXEcughqFl9VKNSK60raXunxNf84BkbvOgZYphN3PqzPE7REiLQ1Ycm8LNljntKXG36qXqcRF8LM/wYK2lPQ0pMLIP0OzUWODzK1h4DEwZN1NQGpN0Q1qvYgYU4iyttoYMevB69HCwFg6glZsrJQ+fGjOaSit/d5AL6Dq4vYOrQe17UZKY8feqDjVcWha3kjN9WqaLKQzmsj7bkgIep+tp/d6/N/FZXnjmNBA5111Cx1j95E8HGgiXgnRVu3tGtm2gqpWFJ7lhx8mJETnFxw3JH75EbUKIEX9M19ux5mLq2sSqrYdBjiuAkytU44v8wZ0oZA+EferLoIq4HS7A/rw== 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 CH0PR12MB5073.namprd12.prod.outlook.com (2603:10b6:610:e0::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5612.14; Mon, 12 Sep 2022 05:21:12 +0000 Received: from CO6PR12MB5491.namprd12.prod.outlook.com ([fe80::b194:dfa5:dfc2:e860]) by CO6PR12MB5491.namprd12.prod.outlook.com ([fe80::b194:dfa5:dfc2:e860%5]) with mapi id 15.20.5612.022; Mon, 12 Sep 2022 05:21:12 +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+6eDMBxZwF4u3YgAT5N8sABicXIMALDby1AArN7JQA= Date: Mon, 12 Sep 2022 05:21:12 +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-09-12T05:21:11Z 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: b6bcadf6-7f49-4012-a4fe-8423ba414187 msip_label_d4243a53-6221-4f75-8154-e4b33a5707a1_contentbits: 0 x-ms-publictraffictype: Email x-ms-traffictypediagnostic: CO6PR12MB5491:EE_|CH0PR12MB5073:EE_ x-ms-office365-filtering-correlation-id: f6ccba1d-dd90-4899-da00-08da947e9bd6 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: E8NXn8wC4ItdamcHDLSpUd+Ukt8+tHKg4gS3AFsVPB3zf9VXhF0t3PcxDdtohtmUsLBVdxdHKJtZo/q5hsvGShIcELjhIL96MBIhUK7GA7ZFsJxYpRFvUNlvLHYBwfNLnR8j3wR9nJKO3JTOGwoQQDuLXa5cr9Bs/3xa/Ayuyh04uwdGj3ByT/+hhVhQRMv7wamt8YKxySmvxhLpprj7+kHvGdUB4AbhPo7M3jgP38AeAcQgsxQLMZapFkNxCy0xPNA/6UdQTJkhShEJHL9NBYiJ3r/Hvk2ZO5CAs/hWBZL2LUZ2e2vFMqMeDk179WrIUVh8KZTkSHfAHn+llgqutbpqligP0l1mqdlG/z7T5v0/XLnsfs/l46zCV5ljVZKkYAheCH4tbxS0a29XhAxEgaM+75Ms3bHXhWyjG6cjl+5EUIz6OsV3jIoeh9+FwaRmp2qstSjof4HQgwN+CldhksxGRdpXHLJcskYrABVOGo0OC2doLgNXotTtNbo0boqhz9G8q9rHxUvBY4l4rS75mT9GbXzIAK0e9TGESlVx4nIBilh45aV4Jt8aVVq0mzkZH4WgLY3M6TkhpahfYhtGIVHpa6Ut0uhR0y7DszXeurCPCUug6LSScN5D68AclyZj7rt32YrYbvuMXXKPjnrOlYLgta0CqBTNabBgCMOlie6kX4j66FvY7YnJtPRB7z1U5WuSKA8xvuoJzSpmKPw1x7wn5xE/aZ/oWKCWvKkMoHfQekM8ooewAwYyHF6tEcql 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)(136003)(396003)(366004)(376002)(39860400002)(6506007)(186003)(76116006)(5660300002)(2906002)(8936002)(52536014)(4326008)(64756008)(66446008)(66556008)(66476007)(66946007)(8676002)(7696005)(9686003)(53546011)(33656002)(86362001)(83380400001)(55016003)(41300700001)(26005)(478600001)(38070700005)(122000001)(6916009)(71200400001)(38100700002)(316002); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?yVsSy/4MJrknCoLa2JI5dvWTLP2q0y7aM4/0MgFK9JxPMrycKoS9mb9X8/2q?= =?us-ascii?Q?3xblBu0jm/zJn+r3HQ+VU1YN75vDjIksjPyisKR7yzPCzHyn9PalhCv+u8wU?= =?us-ascii?Q?9PSdkZS/4H5EWGYpgoNurSz8CEJmhcw6LYj9ICoU6YYKd8ifpxIagI4JApq1?= =?us-ascii?Q?jk1lA55uV16bGOxRqdOmvHw/wyDAd0YlSRiaLA+QY8K6GY4owq/2ko+WzfRc?= =?us-ascii?Q?PQBEEEGFFRxGOlVfXa74ypbvzaom72qgLs3Q5BnSUotv0ZZsQgqNch44MUkN?= =?us-ascii?Q?jDTYL3w062cB7lt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us-ascii?Q?kMqd22y0Gqea50TUZVnbfkVVZ8o4UjKbSVYcioIbXKb2oYLfdTP6iMu22k/U?= =?us-ascii?Q?zZxDxxmezzmHtd6y2lWt0kNgP1KTljidix2/ce775ilOKNNVUsu2u7UPmB8O?= =?us-ascii?Q?R0dawUI2vrhO4SPlo8NGD6PIOGNzIlGXI9SqCX9NB6r40K2XHimcy9eIzPQU?= =?us-ascii?Q?ZYuqWUh6zsF6ctluRFBGzbxFiwPZKdbto5WnZ9ZS8iCH3sYQev/6fdWKDL6j?= =?us-ascii?Q?jLBkGjRfCUL6OMmwrtPWnsdEaldtfTGflycYFJATT87zwSRZFaoyW96LKNP6?= =?us-ascii?Q?ffEXPK4gS6/DwYKVszmDaR6RETBLFhyefKJ9bW6ohK9DY4Sd813Am7rud4F+?= =?us-ascii?Q?PrUa2oq5DLO+o7Vli+A=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: f6ccba1d-dd90-4899-da00-08da947e9bd6 X-MS-Exchange-CrossTenant-originalarrivaltime: 12 Sep 2022 05:21:12.7060 (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: XsIDSthTjiI0NtMpXRksFYdBoTN5Snf4hqvm7Ezau/66Jnw88GnNnWDMD+HFa8xH5JGeFgiUyeeaj6OWh/SnYQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR12MB5073 X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FORGED_SPF_HELO, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE 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, 12 Sep 2022 05:21:17 -0000 [Public] Gentle reminder - 5 !!! Regards, Alok -----Original Message----- From: Sharma, Alok Kumar=20 Sent: Monday, August 29, 2022 4:54 PM To: 'gdb-patches@sourceware.org' ; Andrew Burge= ss ; Tom Tromey Cc: George, Jini Susan Subject: RE: [PATCH] Enable Access to containing scope variables from neste= d inlined function [Public] Gentle Reminder - 4 !!! Hi Andrew, Tom, May I request you to have a look at it ? Regards, Alok -----Original Message----- From: Sharma, Alok Kumar=20 Sent: Monday, August 15, 2022 3:16 PM To: 'gdb-patches@sourceware.org' Cc: George, Jini Susan Subject: RE: [PATCH] Enable Access to containing scope variables from neste= d inlined function [Public] Gentle Reminder - 3 !!! Regards, Alok -----Original Message----- From: Sharma, Alok Kumar=20 Sent: Sunday, August 7, 2022 8:35 PM To: 'gdb-patches@sourceware.org' Cc: George, Jini Susan Subject: RE: [PATCH] Enable Access to containing scope variables from neste= d inlined function [Public] Gentle Reminder - 2 !!! Regards, Alok -----Original Message----- From: Sharma, Alok Kumar=20 Sent: Monday, August 1, 2022 11:27 AM To: 'gdb-patches@sourceware.org' Cc: George, Jini Susan Subject: RE: [PATCH] Enable Access to containing scope variables from neste= d inlined function [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