From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id 6R1PAE/dvWgUlzAAWB0awg (envelope-from ) for ; Sun, 07 Sep 2025 15:30:23 -0400 Authentication-Results: simark.ca; dkim=fail reason="signature verification failed" (768-bit key; unprotected) header.d=tromey.com header.i=@tromey.com header.a=rsa-sha256 header.s=default header.b=rBcL4GBq; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id EF7FB1E0BA; Sun, 07 Sep 2025 15:30:22 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-0.5 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_INVALID,DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_LOW, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED autolearn=no autolearn_force=no version=4.0.1 Received: from server2.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 ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id C7E3D1E047 for ; Sun, 07 Sep 2025 15:30:21 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 6E8863858C42 for ; Sun, 7 Sep 2025 19:30:21 +0000 (GMT) Received: from omta036.useast.a.cloudfilter.net (omta036.useast.a.cloudfilter.net [44.202.169.35]) by sourceware.org (Postfix) with ESMTPS id ED2DD3858D29 for ; Sun, 7 Sep 2025 19:29:16 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org ED2DD3858D29 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tromey.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org ED2DD3858D29 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=44.202.169.35 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1757273365; cv=none; b=tSMtVmOg0K23UQkkO63jIMGFSAQGeAYBS7ESbxKGu9veJZCHTuNJVPMZReyLulTaiLbGUFFPQt02crEQGzB3SJwDRgdHYM6NVfg3QVYyPKGKuN75kHv8djh5rCuVoQ2pWX2HezEco6FsEce1MvwKnug5TSFDrDT9uJV4cGQuSzM= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1757273365; c=relaxed/simple; bh=xYtoZM1G73fCbpTb5EchpUWBNgtbCpWbExK0Aex+tE4=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=tLMJSJBitLBlsDhiTZN1IDWwO7AWQrfBtfp8BONFgpdX2q8w1osC8+BoFtZnk1eviu4cgS670CiJct7I0xFK2t24l4b9JFAEZfyleStwrcGOvbmoCOLW6yTDcIP7uHMymC0lFlShKulTv9u3MCfcSOz337KUbx40ar1OgGB6cds= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org ED2DD3858D29 Authentication-Results: sourceware.org; dkim=policy reason="signing key too small" (768-bit key, unprotected) header.d=tromey.com header.i=@tromey.com header.a=rsa-sha256 header.s=default header.b=rBcL4GBq Received: from eig-obgw-5002b.ext.cloudfilter.net ([10.0.29.226]) by cmsmtp with ESMTPS id vIkGuJfouKXDJvL4eubZv1; Sun, 07 Sep 2025 19:29:16 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id vL4duVqXZcGiCvL4duWswk; Sun, 07 Sep 2025 19:29:16 +0000 X-Authority-Analysis: v=2.4 cv=V8590fni c=1 sm=1 tr=0 ts=68bddd0c a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=IkcTkHD0fZMA:10 a=yJojWOMRYYMA:10 a=ItBw4LHWJt0A:10 a=i_hEsjKl1RF4gYiBDSIA:9 a=QEXdDO2ut3YA:10 a=VS4QxaUSPT0UtbFnIvSC:22 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Cc:To:In-Reply-To:References:Message-Id: Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date:From:Sender: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=/5dGcE79EoBsBRSpJh2suZwGXWlGZkD8vd71/rQZkS0=; b=rBcL4GBqoN1Kn/jkOVenHW9Cug wQIulzmLSI7gj8Gdio/wDCmqjHNA7QlhH+I27ebNIx1XD1HGo1V8VAtudjzcEj5G8t8CoMBTNuult 3jW0/bob+Gwk81gKu3HBSldU/; Received: from 97-122-110-68.hlrn.qwest.net ([97.122.110.68]:43620 helo=[192.168.0.17]) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.1) (envelope-from ) id 1uvL4d-00000003nLh-18Tc; Sun, 07 Sep 2025 13:29:15 -0600 From: Tom Tromey Date: Sun, 07 Sep 2025 13:29:14 -0600 Subject: [PATCH 2/7] Move compute_include_file_name earlier MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20250907-breakpoint-cu-expand-v1-2-dd2beef9d475@tromey.com> References: <20250907-breakpoint-cu-expand-v1-0-dd2beef9d475@tromey.com> In-Reply-To: <20250907-breakpoint-cu-expand-v1-0-dd2beef9d475@tromey.com> To: gdb-patches@sourceware.org Cc: Tom Tromey X-Mailer: b4 0.14.2 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - box5379.bluehost.com X-AntiAbuse: Original Domain - sourceware.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - tromey.com X-BWhitelist: no X-Source-IP: 97.122.110.68 X-Source-L: No X-Exim-ID: 1uvL4d-00000003nLh-18Tc X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 97-122-110-68.hlrn.qwest.net ([192.168.0.17]) [97.122.110.68]:43620 X-Source-Auth: tom+tromey.com X-Email-Count: 3 X-Org: HG=bhshared;ORG=bluehost; X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfJLHvmGDxpSEBlKfWQMP4xX5NC1Nxk4r5QEpLtVn1gH+9L1wocpIGmvGL6jLKQt/RLUNlS2cYOMYY2q7UHnx47p1tOSRNkJmgZMIyVCdvrJ4qetFdRsc ROtC/lL2QFgsq6fW2sJZzNiCxvWZaExoMXpH6MlXl18pdWf5kVquyCTxI0BOfT3iyJA6Yo+QFH2UblqDSQI/ph7LknZ2eorcExU= X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org I noticed that the compute_include_file_name intro comment was slightly wrong, and while looking at this, I also noticed that it has a single caller. This patch hoists it slightly so that a forward declaration isn't needed. --- gdb/dwarf2/read.c | 144 ++++++++++++++++++++++++++---------------------------- 1 file changed, 69 insertions(+), 75 deletions(-) diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index efff522d9b36f70fb7f37d426ab744bb6d4085b3..30a0141b65d01e6f280a57ffb0350b94aae7ed91 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -1037,12 +1037,6 @@ dwarf2_per_cu_deleter::operator() (dwarf2_per_cu *data) delete data; } -static const char *compute_include_file_name - (const struct line_header *lh, - const file_entry &fe, - const file_and_directory &cu_info, - std::string &name_holder); - static struct dwo_unit *lookup_dwo_unit_in_dwp (dwarf2_per_bfd *per_bfd, struct dwp_file *dwp_file, const char *comp_dir, ULONGEST signature, int is_debug_types); @@ -1692,6 +1686,75 @@ dwarf2_per_bfd::allocate_signatured_type (dwarf2_section_info *section, return result; } +/* Subroutine of dw2_get_file_names_reader to simplify it. + Return the file name for the given file_entry. + CU_INFO describes the CU's DW_AT_name and DW_AT_comp_dir. + If space for the result is malloc'd, *NAME_HOLDER will be set. + Returns NULL if FILE_INDEX should be ignored, i.e., it is + equivalent to CU_INFO. */ + +static const char * +compute_include_file_name (const struct line_header *lh, const file_entry &fe, + const file_and_directory &cu_info, + std::string &name_holder) +{ + const char *include_name = fe.name; + const char *include_name_to_compare = include_name; + + const char *dir_name = fe.include_dir (lh); + + std::string hold_compare; + if (!IS_ABSOLUTE_PATH (include_name) + && (dir_name != nullptr || cu_info.get_comp_dir () != nullptr)) + { + /* Avoid creating a duplicate name for CU_INFO. + We do this by comparing INCLUDE_NAME and CU_INFO. + Before we do the comparison, however, we need to account + for DIR_NAME and COMP_DIR. + First prepend dir_name (if non-NULL). If we still don't + have an absolute path prepend comp_dir (if non-NULL). + However, the directory we record in the include-file's + psymtab does not contain COMP_DIR (to match the + corresponding symtab(s)). + + Example: + + bash$ cd /tmp + bash$ gcc -g ./hello.c + include_name = "hello.c" + dir_name = "." + DW_AT_comp_dir = comp_dir = "/tmp" + DW_AT_name = "./hello.c" + + */ + + if (dir_name != NULL) + { + name_holder = path_join (dir_name, include_name); + include_name = name_holder.c_str (); + include_name_to_compare = include_name; + } + if (!IS_ABSOLUTE_PATH (include_name) + && cu_info.get_comp_dir () != nullptr) + { + hold_compare = path_join (cu_info.get_comp_dir (), include_name); + include_name_to_compare = hold_compare.c_str (); + } + } + + std::string copied_name; + const char *cu_filename = cu_info.get_name (); + if (!IS_ABSOLUTE_PATH (cu_filename) && cu_info.get_comp_dir () != nullptr) + { + copied_name = path_join (cu_info.get_comp_dir (), cu_filename); + cu_filename = copied_name.c_str (); + } + + if (FILENAME_CMP (include_name_to_compare, cu_filename) == 0) + return nullptr; + return include_name; +} + /* die_reader_func for dw2_get_file_names. */ static void @@ -15793,75 +15856,6 @@ dwarf_decode_line_header (sect_offset sect_off, struct dwarf2_cu *cu, comp_dir); } -/* Subroutine of dwarf_decode_lines to simplify it. - Return the file name for the given file_entry. - CU_INFO describes the CU's DW_AT_name and DW_AT_comp_dir. - If space for the result is malloc'd, *NAME_HOLDER will be set. - Returns NULL if FILE_INDEX should be ignored, i.e., it is - equivalent to CU_INFO. */ - -static const char * -compute_include_file_name (const struct line_header *lh, const file_entry &fe, - const file_and_directory &cu_info, - std::string &name_holder) -{ - const char *include_name = fe.name; - const char *include_name_to_compare = include_name; - - const char *dir_name = fe.include_dir (lh); - - std::string hold_compare; - if (!IS_ABSOLUTE_PATH (include_name) - && (dir_name != nullptr || cu_info.get_comp_dir () != nullptr)) - { - /* Avoid creating a duplicate name for CU_INFO. - We do this by comparing INCLUDE_NAME and CU_INFO. - Before we do the comparison, however, we need to account - for DIR_NAME and COMP_DIR. - First prepend dir_name (if non-NULL). If we still don't - have an absolute path prepend comp_dir (if non-NULL). - However, the directory we record in the include-file's - psymtab does not contain COMP_DIR (to match the - corresponding symtab(s)). - - Example: - - bash$ cd /tmp - bash$ gcc -g ./hello.c - include_name = "hello.c" - dir_name = "." - DW_AT_comp_dir = comp_dir = "/tmp" - DW_AT_name = "./hello.c" - - */ - - if (dir_name != NULL) - { - name_holder = path_join (dir_name, include_name); - include_name = name_holder.c_str (); - include_name_to_compare = include_name; - } - if (!IS_ABSOLUTE_PATH (include_name) - && cu_info.get_comp_dir () != nullptr) - { - hold_compare = path_join (cu_info.get_comp_dir (), include_name); - include_name_to_compare = hold_compare.c_str (); - } - } - - std::string copied_name; - const char *cu_filename = cu_info.get_name (); - if (!IS_ABSOLUTE_PATH (cu_filename) && cu_info.get_comp_dir () != nullptr) - { - copied_name = path_join (cu_info.get_comp_dir (), cu_filename); - cu_filename = copied_name.c_str (); - } - - if (FILENAME_CMP (include_name_to_compare, cu_filename) == 0) - return nullptr; - return include_name; -} - /* See dwarf2/read.h. */ void -- 2.49.0