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 F1BB13858407 for ; Thu, 7 Apr 2022 16:44:44 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org F1BB13858407 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 237GiTAk026632 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 7 Apr 2022 12:44:34 -0400 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp.polymtl.ca 237GiTAk026632 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 B98951E787; Thu, 7 Apr 2022 12:44:28 -0400 (EDT) Message-ID: <37276133-bfc5-43df-dea7-9e8188a8e5a9@polymtl.ca> Date: Thu, 7 Apr 2022 12:44:28 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.7.0 Subject: Re: [PATCH 5/6] gdb: prepend comp_dir to symtab name in buildsym_compunit Content-Language: en-US To: Eli Zaretskii Cc: gdb-patches@sourceware.org References: <20220407015159.1734834-1-simon.marchi@polymtl.ca> <20220407015159.1734834-6-simon.marchi@polymtl.ca> <835ynlctmb.fsf@gnu.org> From: Simon Marchi In-Reply-To: <835ynlctmb.fsf@gnu.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Poly-FromMTA: (simark.ca [158.69.221.121]) at Thu, 7 Apr 2022 16:44:29 +0000 X-Spam-Status: No, score=-3034.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, NICE_REPLY_A, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_PASS, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE 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: 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: Thu, 07 Apr 2022 16:44:46 -0000 On 2022-04-07 02:09, Eli Zaretskii wrote: >> Date: Wed, 6 Apr 2022 21:51:58 -0400 >> From: Simon Marchi via Gdb-patches >> >> + if (!IS_ABSOLUTE_PATH (name) && m_comp_dir != nullptr) >> + { >> + name_copy = string_printf ("%s/%s", m_comp_dir.get (), name); > > Is it really the best idea to concatenate the directory and the file > this way? What is 'name' includes "./" or "../" components? what if > m_comp_dir ends in a slash or a backslash (for example, if it's just > "/")? etc. etc. It might not look pretty, but it should still yield a valid path. > > Shouldn't we use a more sophisticated API here that has some knowledge > about the semantics of file names? > > Thanks. The concatenation mimics what is done here, in dwarf2_start_subfile: https://gitlab.com/gnutools/binutils-gdb/-/blob/591cc9fbbfd6d51131c0f1d4a92e7893edcc7a28/gdb/dwarf2/read.c#L21658= and here in line_header::file_file_name: https://gitlab.com/gnutools/binutils-gdb/-/blob/591cc9fbbfd6d51131c0f1d4a92e7893edcc7a28/gdb/dwarf2/line-header.c#L76= Given that our symtab / macro_source_file lookup system is (for the moment) based on looking up paths, the path for a given source file must be built exactly the same way at the different points for things to work. It's not ideal, but that's the way it works right now. I am open to doing more changes later, like doing some path normalization, but I feel it's out of scope for this patch. This patch brings one area of GDB "on par" with other areas. Simon