From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id sPZ0N2jGnmBOJAAAWB0awg (envelope-from ) for ; Fri, 14 May 2021 14:50:16 -0400 Received: by simark.ca (Postfix, from userid 112) id D42001F11C; Fri, 14 May 2021 14:50:16 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-1.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (server2.sourceware.org [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 B99E41E01F for ; Fri, 14 May 2021 14:50:14 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 5366E385BF9D; Fri, 14 May 2021 18:50:14 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5366E385BF9D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1621018214; bh=fv6vE7m/vp9Wp0k51y4Bt7OUklHjlBYH1g7K+sssbnQ=; h=Subject:To:References:Date:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=JIchIXJBnOOvfpqaX1jnpZcPlvlqrbDOr1RiDNSOaHD6elGN5xXEouxKxDj5yfVvA h7LwquBbmpLaZOyZgJ9wyOGDkefdzuZZIryiWF8qvFo5aukKK4WkGsNSHAq6aiBjIY RuVbWneqfGY743KllGzXXwgRjjd4nxS1L/zVF3yY= Received: from smtp.polymtl.ca (smtp.polymtl.ca [132.207.4.11]) by sourceware.org (Postfix) with ESMTPS id B4D0B385BF9D for ; Fri, 14 May 2021 18:50:11 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org B4D0B385BF9D Received: from simark.ca (simark.ca [158.69.221.121]) (authenticated bits=0) by smtp.polymtl.ca (8.14.7/8.14.7) with ESMTP id 14EIo20Q005086 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 14 May 2021 14:50:07 -0400 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp.polymtl.ca 14EIo20Q005086 Received: from [10.0.0.11] (192-222-157-6.qc.cable.ebox.net [192.222.157.6]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id 933901E01F; Fri, 14 May 2021 14:50:02 -0400 (EDT) Subject: Re: [PATCH] Fix macro info lookup for binaries containing DWARFv5 line table To: "Tomar, Sourabh Singh" , Keith Seitz , "gdb-patches@sourceware.org" References: <20210512171655.9463-1-SourabhSingh.Tomar@amd.com> <22ab603a-35e1-4048-3ccc-6738a13889df@redhat.com> Message-ID: <5ee2be96-e428-2c4d-2be1-8147922c85eb@polymtl.ca> Date: Fri, 14 May 2021 14:50:02 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.10.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Poly-FromMTA: (simark.ca [158.69.221.121]) at Fri, 14 May 2021 18:50:02 +0000 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: Simon Marchi via Gdb-patches Reply-To: Simon Marchi Errors-To: gdb-patches-bounces@sourceware.org Sender: "Gdb-patches" > One thing I noticed that changed is that GCC is now emitting `dir0` entry in line table as per DWARF5. However this still seems > Incomplete to me: > $llvm-dwarfdump --debug-line a.out > ``` > include_directories[ 1] = "/usr/include" // index still starting from `1` even at "-gdwarf-5" > file_names[ 1]: > name: "macro.c" > dir_index: 0 // -> dir 0 mentioned but dir 0 is not present in list of directories, i.e index still starting from 1 > mod_time: 0x00000000 > length: 0x00000000 > file_names[ 2]: > name: "stdc-predef.h" > dir_index: 1 > mod_time: 0x00000000 > length: 0x00000000 > ``` It's not clear how you produced this output (which compiler and which command). What's the version of that section? Because it looks like a DWARF 4 or before section. GCC 10 produces a DWARF 3 .debug_line section, even when using -gdwarf-5. In DWARF 4 and before, a dir_index of 0 referred to the compilation directory, even if there wasn't an explicit dir[0] value. See section 6.2.4, bullet 12, of DWARF4.pdf. So you would look up the DW_AT_comp attribute of the compilation unit, append "macro.c", and that would give you the location of that file. On my side, I see this with gcc 11 (from the Ubuntu 21.04 package): root@bc7daa9a3ffc:/# gcc-11 --version gcc-11 (Ubuntu 11.1.0-1ubuntu1~21.04) 11.1.0 root@bc7daa9a3ffc:/# cat test.c #include #define FOO int main() { } root@bc7daa9a3ffc:/# gcc-11 -gdwarf-5 -g3 test.c root@bc7daa9a3ffc:/# llvm-dwarfdump-12 --debug-line a.out ... include_directories[ 0] = "/usr/include" 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] = "/usr/lib/gcc/x86_64-linux-gnu/11/include" include_directories[ 6] = "/usr/include/x86_64-linux-gnu/bits/types" file_names[ 0]: name: "test.c" dir_index: 0 file_names[ 1]: name: "test.c" dir_index: 0 file_names[ 2]: name: "stdc-predef.h" dir_index: 1 file_names[ 3]: name: "stdio.h" dir_index: 1 So from what I see, GCC 11 generates a dir[0] entry and a file[0] entry. However, the dir[0] value does not look good. It makes it appear as if my source file was at /usr/include/test.c, which it wasn't (it was at /test.c). Simon