From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gateway23.websitewelcome.com (gateway23.websitewelcome.com [192.185.50.119]) by sourceware.org (Postfix) with ESMTPS id F3D873858C2C for ; Sat, 4 Dec 2021 20:38:50 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org F3D873858C2C Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=tromey.com Received: from cm13.websitewelcome.com (cm13.websitewelcome.com [100.42.49.6]) by gateway23.websitewelcome.com (Postfix) with ESMTP id 96B774B7D for ; Sat, 4 Dec 2021 14:38:50 -0600 (CST) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id tbo2mv0oS0ESotbo2miKli; Sat, 04 Dec 2021 14:38:50 -0600 X-Authority-Reason: nr=8 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: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=QfjAEs80+SbJii8KSm0/ZXVIee+arW1bjBsEyVkBpJU=; b=iDYNSBWG5B8890cG6kd1VhR9lU IhghHZkBPBTxHeJ3K5FWr1mBETAo5lAA101GO+kX30fjIbahRfGQC2mHwQG6PRCd83ja8ldNYauU+ 2BgaBVa05MAA7O8lGlCtujF6i; Received: from 97-122-84-67.hlrn.qwest.net ([97.122.84.67]:51988 helo=localhost.localdomain) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1mtbo2-000ewu-Cg; Sat, 04 Dec 2021 13:38:50 -0700 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH v3 13/33] Add "fullname" handling to file_and_directory Date: Sat, 4 Dec 2021 13:38:24 -0700 Message-Id: <20211204203844.1188999-14-tom@tromey.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211204203844.1188999-1-tom@tromey.com> References: <20211204203844.1188999-1-tom@tromey.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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.84.67 X-Source-L: No X-Exim-ID: 1mtbo2-000ewu-Cg X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 97-122-84-67.hlrn.qwest.net (localhost.localdomain) [97.122.84.67]:51988 X-Source-Auth: tom+tromey.com X-Email-Count: 14 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-Spam-Status: No, score=-3031.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, JMQ_SPF_NEUTRAL, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_NEUTRAL, TXREP 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: Sat, 04 Dec 2021 20:38:52 -0000 This changes the file_and_directory object to be able to compute and cache the "fullname" in the same way that is done by other code, like the psymtab reader. --- gdb/dwarf2/file-and-dir.h | 18 ++++++++++++++++++ gdb/dwarf2/read.c | 24 ++++++++++++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/gdb/dwarf2/file-and-dir.h b/gdb/dwarf2/file-and-dir.h index 1a9ccf35829..fc6219311ed 100644 --- a/gdb/dwarf2/file-and-dir.h +++ b/gdb/dwarf2/file-and-dir.h @@ -28,6 +28,7 @@ #define GDB_DWARF2_FILE_AND_DIR_H #include "objfiles.h" +#include "source.h" #include /* The return type of find_file_and_directory. Note, the enclosed @@ -89,6 +90,20 @@ struct file_and_directory m_name = name; } + /* Return the full name, computing it if necessary. */ + const char *get_fullname () + { + if (m_fullname == nullptr) + m_fullname = find_source_or_rewrite (get_name (), get_comp_dir ()); + return m_fullname.get (); + } + + /* Forget the full name. */ + void forget_fullname () + { + m_fullname.reset (); + } + private: /* The filename. */ @@ -102,6 +117,9 @@ struct file_and_directory /* The compilation directory, if it needed to be allocated. */ std::string m_comp_dir_storage; + + /* The full name. */ + gdb::unique_xmalloc_ptr m_fullname; }; #endif /* GDB_DWARF2_FILE_AND_DIR_H */ diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index 58a5e228044..37f929f3f5b 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -3139,6 +3139,9 @@ dwarf2_base_index_functions::find_last_source_symtab (struct objfile *objfile) void dwarf2_per_cu_data::free_cached_file_names () { + if (fnd != nullptr) + fnd->forget_fullname (); + if (per_bfd == nullptr || !per_bfd->using_index || v.quick == nullptr) return; @@ -4362,6 +4365,27 @@ dw_expand_symtabs_matching_file_matcher if (per_objfile->symtab_set_p (per_cu.get ())) continue; + if (per_cu->fnd != nullptr) + { + file_and_directory *fnd = per_cu->fnd.get (); + + if (file_matcher (fnd->get_name (), false)) + { + per_cu->mark = 1; + continue; + } + + /* Before we invoke realpath, which can get expensive when many + files are involved, do a quick comparison of the basenames. */ + if ((basenames_may_differ + || file_matcher (lbasename (fnd->get_name ()), true)) + && file_matcher (fnd->get_fullname (), false)) + { + per_cu->mark = 1; + continue; + } + } + quick_file_names *file_data = dw2_get_file_names (per_cu.get (), per_objfile); if (file_data == NULL) -- 2.31.1