From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2060.outbound.protection.outlook.com [40.107.93.60]) by sourceware.org (Postfix) with ESMTPS id AF1733858D32 for ; Mon, 29 Aug 2022 11:23:50 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org AF1733858D32 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=b2wv5KqyIKBKDfdd3ih8s9oGn7yuSlLdO5yN4TppMI3/hupYFa4oAGqIe7HbanI4tIqQHhBAgzLw0ppzFp/re8HQ0pkDe2p6QXuBDGOi83tKV7KbdFqG1VwTTehHCx47isOxy3XKdZ2cXe9uBPSh5+7xR/qGLLSdryNCbesEvUS/4MgzLw2xS+EWW1NOD9N+hmhwnAqUGZMc9xgP3OGisEq94OA4tjN3VrhwoPgK1602gmfWwrmmc2g1JimWM+T6fbBcx6xY5oAtfdw/Nezl1YjdbPOrUMb/wzjLvuUOrmk+40xaSf6pE0AMqLgL+seYVgeDDFVPSW+9y7erPiZETg== 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=+EolVCE2dDcN3MOF3E+ygkfSOWd9Aa6ISxA/8bX2Iec=; b=ayiDK0+o9f9zHMyerZTYjXYJlPMUFXxa06LgCKQX/VGEZOph6kHemdOlge8DcAdWUJmHWsEfUn77oEgYc4Nq/PRJkU76FqUFJ/coxCo0U1YWlNi5yT9qMUN3GFZDm/wGZrWC0gJ26vbHPcJDwSiM3rE9tq1uT7xTlh5VzgWhJAEMlpDwfkdWE2Txmdr6hsVSmQAIvjUDRejCmRxabiGr4sHIgwPiNL4+l+A0wdok/l5oElnIkzbHFiRgjbAiL5qQ+HpYPlQ8UDhk+Ff8NWHkVo1Ktgo2n6DeO6jQw4JzINUJd631FqpeZqkRdQzzD3UyfibwLh69tsVGzMHyFguxNA== 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 BY5PR12MB4020.namprd12.prod.outlook.com (2603:10b6:a03:196::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5566.14; Mon, 29 Aug 2022 11:23:42 +0000 Received: from CO6PR12MB5491.namprd12.prod.outlook.com ([fe80::9d61:8887:4f9d:3d9c]) by CO6PR12MB5491.namprd12.prod.outlook.com ([fe80::9d61:8887:4f9d:3d9c%7]) with mapi id 15.20.5566.021; Mon, 29 Aug 2022 11:23:41 +0000 From: "Sharma, Alok Kumar" To: "gdb-patches@sourceware.org" , Andrew Burgess , Tom Tromey 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+6eDMBxZwF4u3YgAT5N8sABicXIMALDby1A Date: Mon, 29 Aug 2022 11:23:41 +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-29T11:23:35Z 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: 14a26c07-9a98-4a1e-8ce7-303694d2a19f msip_label_d4243a53-6221-4f75-8154-e4b33a5707a1_contentbits: 0 x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 082dea8f-244f-425c-ffa3-08da89b0ed80 x-ms-traffictypediagnostic: BY5PR12MB4020:EE_ x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: OqOVJPZ+qx801Tx3cmliG+FZ8Ebyt74Q9TLupsdeUg5BwTm/OpshIfkpvKX4aA+F8RqWIb7p3KzeWBcrYUPyx8vnz7a0v2cqFLvs9CxSaULWUPMAeYQRMIPN+D1xdeyFTKeKs48oBCp9Va1HlWnYPsQcNBRKmWZrZ3d17QOYMYYUlSmORIZnV5GcpurBNB2npjZyvT0EO3WFoz7FRP8cqFp9JBCjZWndwzouEn237z3Pg4pOA3BUJ/i6aAEJQh6YmWjEgG5n6wAXarDQiLEyKddx9f8E/haebzBqriGlRYAkKF3A+PynUWN8tmYZrdZqfQo+StoZa1XF9HQ84wNU185V24IM3dBVpYq8gq4Zo4jnJEvYjdIEvLtOnq25H5SfCOae/FaTnwayEy1D/1b6Pr349QrWYimujzyKng5+qCuwwPdfA+/i8vWVw0oPVC6KZyVNTQJSGEnpwfFxp0gcfq0ExNRr0g5WLcexil/nRCQICAxVlzM7TDW+RdIPZyiRFHhr9StHlcF0nkF0Dkn/MYIxpJhCizEpKND1/d00fz5P30LAAxbMpcF1Fujpcd+dxP1GC2JBniBXzhK3zI1DZOpW/N/LM91i6X//JkZ9/j01rBndM5zU0Ubs4h938L7TtNq1t5PgAmJB70Ex86VFePuiJB0VwKlYRdJ5Z0x6bAhTAQYllNTpgyaTa3KgevNt1/UEVikfIh8cbYgDGSm5C5Pxczocc08GHX3YactNkEMUYqrnm6OVlA2pqIAUqFisHKecZOYZSgtn3BASeEOHRQ== 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)(39860400002)(346002)(376002)(366004)(396003)(136003)(66446008)(66556008)(76116006)(66946007)(33656002)(64756008)(2906002)(41300700001)(53546011)(52536014)(7696005)(6506007)(8676002)(8936002)(478600001)(4326008)(55016003)(186003)(83380400001)(5660300002)(86362001)(66476007)(38070700005)(9686003)(122000001)(26005)(38100700002)(71200400001)(110136005)(316002); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?rI78BDmjtZqKA+wLQHsNGaZuDENgz44dNqdQh4LUgkR765iJhDCsal/cySpl?= =?us-ascii?Q?66FjKaIA6Q6tKwUApq/KYnIxS7Chpq2ZfRz/U3EvARa4ih1WS8cK06GXFLYp?= =?us-ascii?Q?WElXYdBqlnjfJUoS6F0UQpUIUApAdstuaoqloRm1Cegk1ephKFlIIgZDsoWY?= =?us-ascii?Q?L69NqjEjYMI9LR7+DjKNeOe18vQBwK5vxk/iFmstWb0qc6mwLoQv+7dsqKDJ?= =?us-ascii?Q?/0hfvDnAtxBq9JG7CPGMbemzyl3WKIBCAjDQeAXDuL8K7egSEfINw/kiP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tk3ISe9s0S/7orASyXGCZXKl3vesZCoZyJTzJ8A?= =?us-ascii?Q?WxQs4PlIOS/G9VkD8WsBaz/7+4A0AUbyDUY90UZv20hLR/R4WsTqCElp2I/t?= =?us-ascii?Q?hMCXKc6OR73hgVBqXLBHjgWmsgrBf70FdLAdTztXlhQq5jyT2W7gctAKxQUg?= =?us-ascii?Q?1e1+HK/neZFJxgLu7b76jadkuSnrUbrcefdH4BwK2i9kmvwugS9RibudC0+a?= =?us-ascii?Q?iIxHibgqnOdF6tZdnswqy2SEdI+hCAqfMFs3BIdLx8wkqYsN2rX2AZwaYyGf?= =?us-ascii?Q?5+LF8obeiQ6nMsonzNJ0PjPH7ZjWVNoyhfIDiuve6wqK4CC8RMzcfLbWgfOc?= =?us-ascii?Q?rjbBh+QFQW+BdvCvhnOajTeRhCYj5etSKXUAQR8umI6oALwhjt+gi2Xo5MpD?= =?us-ascii?Q?G0HSeDmGzIlbpbdnxOhIcoSc8tywDBKmHyaghgui?= 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: 082dea8f-244f-425c-ffa3-08da89b0ed80 X-MS-Exchange-CrossTenant-originalarrivaltime: 29 Aug 2022 11:23:41.7625 (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: EMGaGhUXzZ0qTs36HTa6engtyg1JAV8hllA9OVrDATuUFhHswaWWWWxnJrFL8zL/NcWfZH1tWSGc8nJlxrehhA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR12MB4020 X-Spam-Status: No, score=-2.4 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, 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, 29 Aug 2022 11:24:03 -0000 [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