From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp.polymtl.ca (smtp.polymtl.ca [132.207.4.11]) by sourceware.org (Postfix) with ESMTPS id 7C5E93855002 for ; Tue, 22 Jun 2021 20:52:23 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 7C5E93855002 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 15MKqGE1026341 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 22 Jun 2021 16:52:21 -0400 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp.polymtl.ca 15MKqGE1026341 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 3EEEB1E54D; Tue, 22 Jun 2021 16:52:16 -0400 (EDT) Subject: Re: [RFC] PING [Re: [PATCH] Fix macro info lookup for binaries containing DWARFv5 line table] To: Keith Seitz , "gdb-patches@sourceware.org" References: <20210512171655.9463-1-SourabhSingh.Tomar@amd.com> <22ab603a-35e1-4048-3ccc-6738a13889df@redhat.com> From: Simon Marchi Message-ID: <1548db86-0c06-79f5-979f-aa5526203464@polymtl.ca> Date: Tue, 22 Jun 2021 16:52:15 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/mixed; boundary="------------F33B0A42EF15D99AD3823B53" Content-Language: en-US X-Poly-FromMTA: (simark.ca [158.69.221.121]) at Tue, 22 Jun 2021 20:52:16 +0000 X-Spam-Status: No, score=-10.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, NICE_REPLY_A, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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: Tue, 22 Jun 2021 20:52:25 -0000 This is a multi-part message in MIME format. --------------F33B0A42EF15D99AD3823B53 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit On 2021-06-22 1:01 p.m., Keith Seitz via Gdb-patches wrote: > I think this might be something we should consider including in gdb-11. > > Keith > > On 6/8/21 11:48 AM, Keith Seitz via Gdb-patches wrote: >> RFC ping >> >> Anyone at all have an opinion on this direction? >> >> Keith >> >> On 5/24/21 11:47 AM, Keith Seitz via Gdb-patches wrote: >>> On 5/24/21 4:36 AM, Tomar, Sourabh Singh wrote: >>>> [AMD Public Use] >>>> >>>> Hello Keith, >>>> >>>> Could you please share your plan WRT to this patch. >>>> Do you want to take it forward ? or you want me to take this forward. >>>> >>> >>> I can pursue this... >>> >>> In that vein, does anyone (maintainers?) have an input on my "counterpatch" >>> (reposted below) that removes this IS_ABSOLUTE_PREFIX stuff and copies the >>> symtab's filename? >>> >>> I haven't officially submitted this as a patch because I'm curious whether >>> my reading of this is correct/complete. Maybe the documentation/comments >>> are incorrect or no longer valid? >>> >>> FWIW, I've tested that patch on native x86_64 Fedora 34 with no regressions. Hi Keith, It's a bit hard to tell whether this will always work, because different compilers do things slightly differently. Factor in different version, DWARF4 vs DWARF5, that's a lot of combinations. I wrote a little script to test as many combinations as possible, and with your patch it all looks good, in the sense that I can print the macros in all cases. I'll attach it to this message if you want to play with it. The axis are: - the compiler - DWARF5 vs DWARF4 - how the source file is specified on the command line How the source file is specified on the command line can be: - foo.c - ../foo.c - dir/foo.c (while PWD is the parent directory) - /absolute/path/to/dir/foo.c (while PWD is `dir`) - /absolute/path/to/dir/foo.c (while PWD is the parent directory) They all produce slightly different debug info that could lead to something going wrong. The important thing is that it's well tested, so ensure that as many of these ways to specify a file on the command line are tested. Test with one macro in the main source file and one macro in an included file. I don't know if we can have a DWARF4 vs DWARF5 axis in the test, but if so it would be nice. And add any another possible variation you can think of. One more comment below... >>> >>> Keith >>> >>> Patch under discussion: >>> >>> gdb/ChangeLog >>> >>> * dwarf2/line-header.c (line_header::file_file_name): Copy >>> the symtab's filename. >>> >>> diff --git a/gdb/dwarf2/line-header.c b/gdb/dwarf2/line-header.c >>> index 7575297f966..117c5a42cc5 100644 >>> --- a/gdb/dwarf2/line-header.c >>> +++ b/gdb/dwarf2/line-header.c >>> @@ -69,15 +69,10 @@ 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); >>> + /* macro_source_file requires: "This filename is relative to the >>> + compilation directory, it exactly matches the symtab->filename >>> + content." */ >>> + return make_unique_xstrdup (fe->symtab->filename); If I understand correctly, the contract of file_file_name is that it should never return an absolute path. Therefore, should we be able to stick a gdb_assert (!IS_ABSOLUTE_PATH (fe->symtab->filename)) in there? If I do, it catches at least one case where it returns an absolute path, in test-gcc-9-dwarf-4-std. (top-gdb) p fe.symtab.filename $1 = 0x62100003e960 "/home/smarchi/build/binutils-gdb/macro-test/test.c" Printing the macros still work, but I wonder if that's expected or not. Simon --------------F33B0A42EF15D99AD3823B53 Content-Type: application/x-compressed-tar; name="macro-test.tgz" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="macro-test.tgz" H4sIAAAAAAAAA+2WS4/aMBDHueJPMWU5LFsZ8iKoQhzaQ69Iva5WlYmdxBJ5KDFdqqrfvXYe QGFZqors9jE/ge3Yk8w/nozthAVFRpUo1aTXFZZmNpua2p5N7cO6pWd7lu95nj/13J5lu5Zt 9WDamaIDNqViBUCvTFgRxPKs3aXxv5RkH39TjIMOfJgA+753Nv627TTxd/2p6+v4e7bj98Dq QMsJ/3n8b2QarDdcwKAKfzwg5IaLUKYCPi6X4DiEyFSRhMn09ksm+Yh8IwCFUJsirSzewof3 n+bkO3ntN0F+h+P8L+Pr+7iw/jvuzGvXf2/m2Cb/XdfC/H8Jbt5MVjKdrFgZE1IKBXRbV4KQ MCsgyJJcrkUBMoUoCOi7qrSturKrKpIKgjVLI9PRNJy24c6BZ3rJkCHc38Nw97zFAu4qkzt4 eJiDikWqrQCqD/JzlqsFDblYbSJa9eixUBJTalH80cjhj6wIqdfU08ZPbZEIFWfcWJWK6wGl f5CzQqQK2Ko0f1pf7m6rJcKwuXUBA33rAFpt/b10Gg21Ahq52rhVC3RpAc3AJBHdmVJtSI2C em9t/Ij1sada4DWcNa86Hk9Odvaz3uuJOPCeb8qY62f8qo4jV0eSmmk/1dPPs5yfVaVDdI0J MdEe3haCrXOm4iYQo+e80o7nY+/iUNjJ9IyO5qcUpC+2OtXspkvng6l4lgrSVFXxfN5eTNQO E0x/lRFfmT/QdAuUcqYY5bIQgcqKr4tm/Ofep4LaBoyKLZj1W1WtQW5OJIO2rc8lur1iKoif nqjXXnv/BI4/uw62/4vnf321P/97TnX+dz3c/1+C9rCvkwVcF1MCQRAEQRAEQRAEQRAEQRAE Qf4FfgC2h4IJACgAAA== --------------F33B0A42EF15D99AD3823B53--