From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-oln040092073041.outbound.protection.outlook.com [40.92.73.41]) by sourceware.org (Postfix) with ESMTPS id 1C7E2399E038 for ; Wed, 28 Jul 2021 15:26:59 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 1C7E2399E038 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=hotmail.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=hotmail.de ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CoD/kpggiTjv5zNjmp8Dcr8J5ZwYp6EwWgaKf2XNr3W/4betLJsDx1BHZZ4X4/bmIDLIKQn3FLOqdZUfnAIkuDGiLmBHNofi7ogxgcOG5PV/qDqaP5Yo8JV+mId93fepunk2b1gCvi0zG4lzzJ/cI89OZ1EB6xs98/wwhrPgXKRU18xD+mHXD3UB9U8YkvzyGaUEc+ki2eORCYDrKKxFQhnqNTB8ySWpi/Qi66S0OjlSzD3fAHK9bWQ11tB8jNlPN//Q6jAdpCgqAMbw2xvg33CY1wXy7KLKBdUxVyrsHg356stpwfF/jVFV4MiHHYdZ+sCp3FkHrcA+f/MYJ/ILKg== 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-SenderADCheck; bh=mGi8Wdd1SEsFRjiau6Ymvz2VWVLZKCPrtpDktcXLESk=; b=Mb8ZIWshH6YkDhravU+5QMYrweUxpsy5ZEQqL4wHz917JmzMvjS+i4BzID8lXf2CIEsTZOiQ5gPZGpdDwuYyptCn0P5CjhKiaAaWKVuu2kd9HUK6ZHs67Duvku0hiRxi+nRj6P9qvf3vlFm6CvJpskIxrh2HxknK0sp5iqPPiFKlomx5sUiTHnGS5Co98wv1LW+k8kzIHOsZlpub1ig2J5sME5qepf/5EEfsYDYNpwN+10uwR6FsqC1CBstLsCxGDZA2Zt+bttv1G59KQBKDjR2H0PZWGz+k4H2WdQavsAaif+Dq7McQEsknmcQT38q+fE6KSqdmO4U9S68ZhQapLQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none Received: from DB3EUR04FT017.eop-eur04.prod.protection.outlook.com (2a01:111:e400:7e0c::40) by DB3EUR04HT045.eop-eur04.prod.protection.outlook.com (2a01:111:e400:7e0c::320) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4373.18; Wed, 28 Jul 2021 15:26:57 +0000 Received: from AM8PR10MB4708.EURPRD10.PROD.OUTLOOK.COM (2a01:111:e400:7e0c::43) by DB3EUR04FT017.mail.protection.outlook.com (2a01:111:e400:7e0c::280) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4373.18 via Frontend Transport; Wed, 28 Jul 2021 15:26:57 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:C7916F8E3B9AAE0CFC2664A234A325FD625649FAE016FD6A9BFAB4A9976AB9A8; UpperCasedChecksum:FFBAA4BEA7BD5B5F1658F395EA5637E39E96B110AA705B64A838D91282018F33; SizeAsReceived:8014; Count:48 Received: from AM8PR10MB4708.EURPRD10.PROD.OUTLOOK.COM ([fe80::3d30:d151:570a:8a16]) by AM8PR10MB4708.EURPRD10.PROD.OUTLOOK.COM ([fe80::3d30:d151:570a:8a16%9]) with mapi id 15.20.4373.020; Wed, 28 Jul 2021 15:26:57 +0000 Subject: Re: [PATCH 1/2] Fix debug info for ignored decls at start of assembly To: Richard Biener Cc: "gcc-patches@gcc.gnu.org" , Eric Botcazou , Arnaud Charlet References: From: Bernd Edlinger Message-ID: Date: Wed, 28 Jul 2021 17:26:54 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 In-Reply-To: Content-Type: text/plain; charset=windows-1252 Content-Language: en-US Content-Transfer-Encoding: 7bit X-TMN: [zNhXLEooBS5zPL7j/6i8YIIcQ9YKGDif] X-ClientProxiedBy: PR3P193CA0008.EURP193.PROD.OUTLOOK.COM (2603:10a6:102:50::13) To AM8PR10MB4708.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:20b:364::23) X-Microsoft-Original-Message-ID: MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from [192.168.1.101] (88.76.118.196) by PR3P193CA0008.EURP193.PROD.OUTLOOK.COM (2603:10a6:102:50::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4373.19 via Frontend Transport; Wed, 28 Jul 2021 15:26:56 +0000 X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 48 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: 1c9aa7b8-2532-4b79-cfc4-08d951dc22d0 X-MS-TrafficTypeDiagnostic: DB3EUR04HT045: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: glBx1X6xI0mulPTPBKAMtOJ1Fvui2YXN+8PiiNX792dMs/nkkl6P9NVJulivovPgidURlfU44BOAuXpdQihqJq1ykHNxzFv2pf6oYWovyz6FsnOdFHkR2kJ1aTR5qYuqmbiV+Jc6IxlO37xl4D+zXi0kcKjZsmcM9uEUe/7UcVgao7sdBUNk3pLUshn/LkKoIpahyUuA5DV7ZyEuBhvOomCadU6qYp5vy1nv40BbkRnzZnyUT16L/J3wk0VYFQFYW4Ulk4BhR4yK1R35ResmP62fWxFmrc3zsd/ZeM9fbNGpYwzbkTXWJ+pw5xaX9zhyCT25dvcDxScW+EPASIwsh4IzyKz6S3FRUu7Rj3A3sADk1ZupOjL8N5ksNG9G3QwMkzEqXkjtkXl/xCBxWrhV4DUk9JXmg4zimnsQKLRt3M9bjA6bQvRnqk2NDEZTG1Xicp5apU1x5kOOVc+5x7f32TrrMJUP90sXXYR49aNaU8w= X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: fSvI3tW88130B+xA5+Mj9bcxc4E4V07WgdYYOHJJkwgZPOVJFF4FBrCsgUVkI7ZeHow9FpVA5f5oTHcoCW1y5beJ4BKyrKwVXkCTutNpoGizfIw0Ymh/58ST9KoFSO1qqhxnOtCMH97rk13ccWWfKA== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1c9aa7b8-2532-4b79-cfc4-08d951dc22d0 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Jul 2021 15:26:57.2363 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-AuthSource: DB3EUR04FT017.eop-eur04.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: Internet X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB3EUR04HT045 X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00, FORGED_MUA_MOZILLA, FREEMAIL_FROM, GIT_PATCH_0, KAM_DMARC_STATUS, MSGID_FROM_MTA_HEADER, NICE_REPLY_A, RCVD_IN_BARRACUDACENTRAL, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_PASS, TXREP 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: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 28 Jul 2021 15:27:00 -0000 On 7/28/21 2:51 PM, Richard Biener wrote: > On Mon, 26 Jul 2021, Bernd Edlinger wrote: > >> Ignored functions decls that are compiled at the start of >> the assembly have bogus line numbers until the first .file >> directive, as reported in PR101575. >> >> The work around for this issue is to emit a dummy .file >> directive when the first function is DECL_IGNORED_P, when >> that is not already done, mostly for -fdwarf-4. > > I wonder if it makes sense to unconditionally announce the > TU with a .file directive at the beginning. ISTR this is > what we now do with -gdwarf-5. > Yes, that would work, even when the file name is not guessed correctly. Initially I had "" unconditionally here, and it did not really hurt, except that it is visible with readelf. > Note get_AT_string (comp_unit_die (), DW_AT_name) doesn't > work with LTO, you'll get then. > Yeah, that's why I wanted to restrict that to the case where it's absolutely necessary. > Is the dwarf assembler bug reported/fixed? Can you include > a reference please? > I've just added a bug report, it's unlikely to be fixed IMHO: https://sourceware.org/bugzilla/show_bug.cgi?id=28149 I will add that to the patch description: Ignored functions decls that are compiled at the start of the assembly have bogus line numbers until the first .file directive, as reported in PR101575. The corresponding binutils bug report is https://sourceware.org/bugzilla/show_bug.cgi?id=28149 The work around for this issue is to emit a dummy .file directive when the first function is DECL_IGNORED_P, when that is not already done, mostly for -fdwarf-4. Thanks Bernd. > Thanks, > Richard. > >> 2021-07-24 Bernd Edlinger >> >> PR ada/101575 >> * dwarf2out.c (dwarf2out_begin_prologue): Move init >> of fde->ignored_debug to dwarf2out_set_ignored_loc. >> (dwarf2out_set_ignored_loc): This is now also called >> when no .loc statement is to be generated, in that case >> we emit a dummy .file statement when needed. >> * final.c (final_start_function_1, >> final_scan_insn_1): Call debug_hooks->set_ignored_loc >> for all DECL_IGNORED_P functions. >> --- >> gcc/dwarf2out.c | 29 +++++++++++++++++++++++++---- >> gcc/final.c | 5 ++--- >> 2 files changed, 27 insertions(+), 7 deletions(-) >> >> diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c >> index 884f1e1..8de0d6f 100644 >> --- a/gcc/dwarf2out.c >> +++ b/gcc/dwarf2out.c >> @@ -1115,7 +1115,6 @@ dwarf2out_begin_prologue (unsigned int line ATTRIBUTE_UNUSED, >> fde->dw_fde_current_label = dup_label; >> fde->in_std_section = (fnsec == text_section >> || (cold_text_section && fnsec == cold_text_section)); >> - fde->ignored_debug = DECL_IGNORED_P (current_function_decl); >> in_text_section_p = fnsec == text_section; >> >> /* We only want to output line number information for the genuine dwarf2 >> @@ -28546,10 +28545,32 @@ dwarf2out_set_ignored_loc (unsigned int line, unsigned int column, >> { >> dw_fde_ref fde = cfun->fde; >> >> - fde->ignored_debug = false; >> - set_cur_line_info_table (function_section (fde->decl)); >> + if (filename) >> + { >> + set_cur_line_info_table (function_section (fde->decl)); >> + >> + dwarf2out_source_line (line, column, filename, 0, true); >> + } >> + else >> + { >> + fde->ignored_debug = true; >> + >> + /* Work around for PR101575: output a dummy .file directive. */ >> + if (in_first_function_p >> + && debug_info_level >= DINFO_LEVEL_TERSE >> + && dwarf_debuginfo_p () >> +#if defined(HAVE_AS_GDWARF_5_DEBUG_FLAG) && defined(HAVE_AS_WORKING_DWARF_N_FLAG) >> + && dwarf_version <= 4 >> +#endif >> + && output_asm_line_debug_info ()) >> + { >> + const char *filename0 = get_AT_string (comp_unit_die (), DW_AT_name); >> >> - dwarf2out_source_line (line, column, filename, 0, true); >> + if (filename0 == NULL) >> + filename0 = ""; >> + maybe_emit_file (lookup_filename (filename0)); >> + } >> + } >> } >> >> /* Record the beginning of a new source file. */ >> diff --git a/gcc/final.c b/gcc/final.c >> index ac6892d..82a5767 100644 >> --- a/gcc/final.c >> +++ b/gcc/final.c >> @@ -1725,7 +1725,7 @@ final_start_function_1 (rtx_insn **firstp, FILE *file, int *seen, >> if (!dwarf2_debug_info_emitted_p (current_function_decl)) >> dwarf2out_begin_prologue (0, 0, NULL); >> >> - if (DECL_IGNORED_P (current_function_decl) && last_linenum && last_filename) >> + if (DECL_IGNORED_P (current_function_decl)) >> debug_hooks->set_ignored_loc (last_linenum, last_columnnum, last_filename); >> >> #ifdef LEAF_REG_REMAP >> @@ -2205,8 +2205,7 @@ final_scan_insn_1 (rtx_insn *insn, FILE *file, int optimize_p ATTRIBUTE_UNUSED, >> } >> else if (!DECL_IGNORED_P (current_function_decl)) >> debug_hooks->switch_text_section (); >> - if (DECL_IGNORED_P (current_function_decl) && last_linenum >> - && last_filename) >> + if (DECL_IGNORED_P (current_function_decl)) >> debug_hooks->set_ignored_loc (last_linenum, last_columnnum, >> last_filename); >> >> >