From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id fFbgInkBCWAkdgAAWB0awg (envelope-from ) for ; Wed, 20 Jan 2021 23:22:17 -0500 Received: by simark.ca (Postfix, from userid 112) id 7FBC31EF80; Wed, 20 Jan 2021 23:22:17 -0500 (EST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,RDNS_NONE, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.2 Received: from sourceware.org (unknown [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 177B01E945 for ; Wed, 20 Jan 2021 23:22:17 -0500 (EST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 6D1C63851C07; Thu, 21 Jan 2021 04:22:16 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6D1C63851C07 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1611202936; bh=NJ7LAcfq20sdVmWfuuqUGF32+PRLJ75DonhwQE6bK9g=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=W8+Wc0CwJQ9Fr25n6TqaYKBR/SsdUcWq8z79TrcRWvfd+8b7n+pbSTJvBy7FWq94T 4cG4HnmOMcEQlNGDTh5FnhI1rXfmKVa8n/BiE7w9WqIrc/ferMJqlZGdxlVa5bPZMq 4aJktbhYbG9aHePYcj8HVPKD71A7sa9rMP45RJLQ= Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2086.outbound.protection.outlook.com [40.107.220.86]) by sourceware.org (Postfix) with ESMTPS id 735D83851C07 for ; Thu, 21 Jan 2021 04:22:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 735D83851C07 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=A0wiOJx+TQ8B4An2yikx8oGzNapS7Wl6jYG4a1Uqil0J7N3EMhgl8nBp5MW5BYSsPDXe1bazcY3t3NEvkdNeA4P82LqjqTpvX6SinWzQOXTcf5xy9V6MDq4OsE1ce/FL7FytHhuV6Y1mo+ILJlfndElbUpKD3OJsmnb+hKeeFlga+ldeorG3wHaQeGscmlfiUJnnGiWr/9LHiBrtxXuQiVTP+Vsl948b4WmU2LW2yPuCBH/CgBeyMcNCE0lkwHZP25wGXa4k5UX4GHglUad3VyIr+i6WFBi+sQdB4DWFANjM6TqKNUjaqX5/rIbsCRSLLaPHM4PaP+8+jC+OC6cRtw== 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=NJ7LAcfq20sdVmWfuuqUGF32+PRLJ75DonhwQE6bK9g=; b=KY3L2INdreIk5uwm+QWlGTt1WgEqcqBVkKLEGWRHuANQ++EjGBAwvmSYxIhtwiT+vkHNazUUNGMpm4Fa2c4wmmpEIK9+zzE0UEXN+Q/o9j34pUEyG5B7zfU+kfMLYOZTHXCeRWLpZ9MF+yhXYAvPrQpm1nLAJaBuNszoKtgcVWPSNOnQM1ftus+MqvMX+2k0Uf9PE7DfcxNUHb4OFVr0Lc2yishv2RFtFyq/Oc0TQB2fW5E3pnvbctMJIjmFxDv48SdeXDCsGu7/7UFAAAS1buhnW4q3zhsL17jDGcxyBcaD9uXIxRknOOLYPYbE8QXuddQ45OJi9VWX08hNP4SSAA== 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 MN2PR12MB3039.namprd12.prod.outlook.com (2603:10b6:208:c9::27) by MN2PR12MB3086.namprd12.prod.outlook.com (2603:10b6:208:c7::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3763.9; Thu, 21 Jan 2021 04:22:10 +0000 Received: from MN2PR12MB3039.namprd12.prod.outlook.com ([fe80::8ddd:f51c:8e99:f9af]) by MN2PR12MB3039.namprd12.prod.outlook.com ([fe80::8ddd:f51c:8e99:f9af%6]) with mapi id 15.20.3784.013; Thu, 21 Jan 2021 04:22:10 +0000 To: gdb-patches@sourceware.org Subject: [PATCH] DWARFv5: Fix for the filename complaint when printing macro. Date: Thu, 21 Jan 2021 09:51:54 +0530 Message-Id: <20210121042154.23274-1-Nitika.Achra@amd.com> X-Mailer: git-send-email 2.17.1 Content-Type: text/plain X-Originating-IP: [165.204.156.251] X-ClientProxiedBy: MA1PR0101CA0061.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:20::23) To MN2PR12MB3039.namprd12.prod.outlook.com (2603:10b6:208:c9::27) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from bglcomp-haswell-105.amd.com (165.204.156.251) by MA1PR0101CA0061.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:20::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3784.11 via Frontend Transport; Thu, 21 Jan 2021 04:22:08 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: d11aa457-b3ea-4187-4bdc-08d8bdc41e71 X-MS-TrafficTypeDiagnostic: MN2PR12MB3086: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:9508; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: KvHQ0PyeWr9uezB2w5VF9ghCUkQ94UBq2d4AhnzRXbC/6QqRR/JngVFV5ylo8WZHjiup2l3s4KvS7Q/Sone9876akOeMUgI1nq8IJmVvjXdieMQRyIPCJswkYj3vclGW5QnhLYhy8ATolv1CG8687/XZ2Un/seIGOIZtjtYrcbkrJPGoDKzRIXEdFE4mag8Tdq3nQYk2thh0QLhcRGujoTm4H6HwiWzyERUk+f2aHNoSbeHpigKECNU+aonE4OeJJYs1CHhjQhmN55zymf8Uhpn49km83qH/omXLIpvd6DhDbMRs9fN4I3Jq2f0QkO4PAcylkF3YPfjKrm9ARPpcqS5IzHVZTsX9C4e7hwZkwGnoQsmwBxt9JgloImmyu87Qdz1NnSzdGAlUMom02mUPQMBGzuwOFz2U3/FsidYHaUoNKdyy5WH7Y9j6BLrhfPNm X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:MN2PR12MB3039.namprd12.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(346002)(136003)(396003)(39860400002)(376002)(16526019)(316002)(7696005)(6916009)(36756003)(186003)(26005)(2906002)(5660300002)(6666004)(478600001)(956004)(8936002)(6486002)(83380400001)(1076003)(8676002)(86362001)(52116002)(66476007)(4326008)(9686003)(66556008)(2616005)(66946007)(403724002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: =?us-ascii?Q?4XbPjN4yPZDa3sxlYBp9uGonPiFg+GPfzJ6gcGhwUQwqNT0Qem6BRzw/TbOU?= =?us-ascii?Q?rWAC50taINOfiAQgiVVKAluzPqrhZiXNVmoeHh3ICvdCyHD5nbutiamkEg4p?= =?us-ascii?Q?8qpI0o0lZxNfdd5sBzLcnwvMug3UdR1kLElkrklReqK7ofLxzX6aw4JgoyEY?= =?us-ascii?Q?l7IkrjpQNc4+40bhDFwiKfp4sWWmkWjuIlbhm4i3N3MWYq4TPgPJIPECooMl?= =?us-ascii?Q?auXD7bageQbMU/xAi//s0nFy9xahWiyZQjkOPotzs7T9Pd1uig5A/VEpfylB?= =?us-ascii?Q?uciHT6x9vFTcDSTbibWS21CMVwZSFgtf+p0p8ZaM7PxUZ4gmDnKtpbS6SpM3?= =?us-ascii?Q?7/TfJK8XnsgGHUUFHADfMtvrocN3SJIXZKIMR0nftkT6Xu0qLixtH5loq26c?= =?us-ascii?Q?YjAOjOeYXzO1grTPLywIVi/+KMlsIcaszMBIThJ7qmi/rKzcfytwRrEowexJ?= =?us-ascii?Q?q8LcXohulYA2ooXfYUgh04PcMmv4IQjGfU/CI9x8veVqIxvKspUj3rdGUQur?= =?us-ascii?Q?rGHPB4/nZaC+by4GKdXs+dUuj7XyhndQIUpkQl7KWH8aNvc60aAf+XfvUfg2?= =?us-ascii?Q?1ETXGjohb546K2t0spUZF5P/rItI7VpYl4w+aRK10d/KGZ7a320xKw9POcFB?= =?us-ascii?Q?CW+dsaOIUNPq7hFNeCno+YTZloJimZwwssdearIxFttnbuIVPeSP36jK1WnK?= =?us-ascii?Q?vDEgo+u666c+CzOZz2mUE5tRJ0L4Osa6a1WWFlBZUraC9ERR14q7YYvWPxMs?= =?us-ascii?Q?Sn4OSwXHUq0MosPWztB6xk5xCXT8zI6H/ouvDJ3/jXcX1h0osXMJ7rJceO01?= =?us-ascii?Q?M0YceaF6Z9HVVzQHfbIOJINHhmmsMbF7Bi91cekL5Qfe4GXGgS+h/k/Uy7o7?= =?us-ascii?Q?Zl2EZDmeFmvjJ7/08syZ9CJKgwpH2WWPg53qw6Ge2WCNDjjMD921lZpHmm8N?= =?us-ascii?Q?GMWb50KH+esGKSwVypsrdfcExAqAPsAArJ1pXmwBOBMiata3lw6uhV51WS/L?= =?us-ascii?Q?/AKpDcbgQtQpQ4jmoD67QQk1cb0HSHmErJ0nsGEjRZQWzVr+CNcDiV0JaRfJ?= =?us-ascii?Q?OVaOHig2xya8I8zfSIfadWWJNZeB0g=3D=3D?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: d11aa457-b3ea-4187-4bdc-08d8bdc41e71 X-MS-Exchange-CrossTenant-AuthSource: MN2PR12MB3039.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Jan 2021 04:22:10.2102 (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: kdfcON+rluw64ovsdyByXymq3inYssTE4sgELIjB+mkyf76F0AJA/C2CJnwF4UmlAKYjEkeWnt/prP6L6/6gYw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB3086 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: , From: "Nitika.Achra--- via Gdb-patches" Reply-To: Nitika.Achra@amd.com Cc: JiniSusan.George@amd.com, nitachra Errors-To: gdb-patches-bounces@sourceware.org Sender: "Gdb-patches" From: nitachra A gentle reminder! Regards, Nitika --- GDB complaints "During symbol reading: symtab found for file, but that file is not covered in the compilation unit's macro information. No symbol "MAX_SIZE" in the current context" when printing the macro with the testcase file macro.c given below. This patch fixes this and prints the correct value. When gdb reads file number from DW_MACRO_start_file data in .debug_macro section, it will do name lookup in file_names and include_directories index table of .debug_line section. A snippet of .debug_macro is as follows- DW_MACRO_start_file - lineno: 0 filenum: 1 DW_MACRO_define_strx - lineno: 3 macro: MAX_SIZE 10 DW_MACRO_end_file Index of the file for the lookup in file_names table in .debug_line is (filenum - 1) A snippet of .debug_line is as follows- file_names[ 0]: name: "macro.c" dir_index: 0 md5_checksum: 0ee310711170f2dd9844b522e844207d dir_index will be used to lookup the path in include_directories table- include_directories[ 0] = "/home/nitika/workspace" include_directories[ 1] = "/usr/include" include_directories[ 2] = "/usr/include/x86_64-linux-gnu/bits" include_directories[ 3] = "/usr/include/x86_64-linux-gnu/sys" include_directories[ 4] = "/usr/include/x86_64-linux-gnu/gnu" include_directories[ 5] = "up_llvm/llvm-project/build/lib/clang/11.0.0/include" include_directories[ 6] = "/usr/include/x86_64-linux-gnu/bits/types" Prior to DWARFv5 include_directories[0] has no info, so a lookup at that index will return NULL and we have file name "macro.c". But in dwarfv5, current directory is explicitly represented at index 0 (as shown in the snippet above), hence after lookup you get "/home/nitika/workspace/macro.c". (compilation directory is /home/nitika/workspace) Test case used (macro.c): #define MAX_SIZE 10 int main(void) { int size = 0; size = size + MAX_SIZE; printf("\n The value of size is [%d]\n",size); return 0; } clang -gdwarf-5 -fdebug-macro macro.c -o macro.out Before the patch: gdb -q macro.out -ex "start" -ex "set complaints 1" -ex "p MAX_SIZE" Reading symbols from macro.out... Temporary breakpoint 1 at 0x4004df: file macro.c, line 7. Starting program: /home/nitika/workspace/macro.out Temporary breakpoint 1, main () at macro.c:7 7 int size = 0; During symbol reading: symtab found for 'macro.c', but that file is not covered in the compilation unit's macro information. No symbol "MAX_SIZE" in current context. After the patch: gdb -q macro.out -ex "start" -ex "p MAX_SIZE" Reading symbols from macro.out... Temporary breakpoint 1 at 0x4004df: file macro.c, line 7. Starting program: /home/nitika/workspace/macro.out Temporary breakpoint 1, main () at macro.c:7 7 int size = 0; $1 = 10 Tested by running the testsuite before and after the patch with -gdwarf-5 and there is no increase in the number of test cases that fails. Used clang 11.0.0. gdb/ChangeLog: * macrotab.c (macro_lookup_inclusion): In DWARF version 5, macro filename includes the full directory path. Changing the if condition to include the comparison for full filename. * macrotab.h (macro_lookup_inclusion): Changing the definition, symtab as parameter instead of only the filename. * macroscope.c (sal_macro_scope): Passing the symtab instead of filename while calling macro_lookup_inclusion. * dwarf2/line-header.c (file_file_name): As per the comment in its definition in line-header.h, it should return file name relative to the compilation directory of file number I in this object's file name table. --- gdb/dwarf2/line-header.c | 8 -------- gdb/macroscope.c | 2 +- gdb/macrotab.c | 7 ++++--- gdb/macrotab.h | 2 +- 4 files changed, 6 insertions(+), 13 deletions(-) diff --git a/gdb/dwarf2/line-header.c b/gdb/dwarf2/line-header.c index 7575297f96..8975a03285 100644 --- a/gdb/dwarf2/line-header.c +++ b/gdb/dwarf2/line-header.c @@ -69,14 +69,6 @@ line_header::file_file_name (int file) const { const file_entry *fe = file_name_at (file); - if (!IS_ABSOLUTE_PATH (fe->name)) - { - const char *dir = fe->include_dir (this); - if (dir != NULL) - return gdb::unique_xmalloc_ptr (concat (dir, SLASH_STRING, - fe->name, - (char *) NULL)); - } return make_unique_xstrdup (fe->name); } else diff --git a/gdb/macroscope.c b/gdb/macroscope.c index e2abdd1bdd..a994068003 100644 --- a/gdb/macroscope.c +++ b/gdb/macroscope.c @@ -50,7 +50,7 @@ sal_macro_scope (struct symtab_and_line sal) gdb::unique_xmalloc_ptr ms (XNEW (struct macro_scope)); main_file = macro_main (COMPUNIT_MACRO_TABLE (cust)); - inclusion = macro_lookup_inclusion (main_file, sal.symtab->filename); + inclusion = macro_lookup_inclusion (main_file, sal.symtab); if (inclusion) { diff --git a/gdb/macrotab.c b/gdb/macrotab.c index 96b29e345a..fae14b3c3c 100644 --- a/gdb/macrotab.c +++ b/gdb/macrotab.c @@ -504,10 +504,11 @@ macro_include (struct macro_source_file *source, struct macro_source_file * -macro_lookup_inclusion (struct macro_source_file *source, const char *name) +macro_lookup_inclusion (struct macro_source_file *source, struct symtab *symtab) { /* Is SOURCE itself named NAME? */ - if (filename_cmp (name, source->filename) == 0) + if (filename_cmp (symtab->filename, source->filename) == 0 || + filename_cmp (symtab->fullname, macro_source_fullname(source).c_str()) == 0) return source; /* It's not us. Try all our children, and return the lowest. */ @@ -519,7 +520,7 @@ macro_lookup_inclusion (struct macro_source_file *source, const char *name) for (child = source->includes; child; child = child->next_included) { struct macro_source_file *result - = macro_lookup_inclusion (child, name); + = macro_lookup_inclusion (child, symtab); if (result) { diff --git a/gdb/macrotab.h b/gdb/macrotab.h index ea539e872e..6cbd3bc474 100644 --- a/gdb/macrotab.h +++ b/gdb/macrotab.h @@ -235,7 +235,7 @@ void macro_define_special (struct macro_table *table); least-nested inclusion --- the one closest to the main source file. */ struct macro_source_file *macro_lookup_inclusion (struct macro_source_file *source, - const char *name); + struct symtab *symtab); /* Record an object-like #definition (i.e., one with no parameter list). -- 2.17.1