From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gateway31.websitewelcome.com (gateway31.websitewelcome.com [192.185.143.46]) by sourceware.org (Postfix) with ESMTPS id 6B4583858D28 for ; Tue, 7 Dec 2021 17:23:49 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 6B4583858D28 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 cm14.websitewelcome.com (cm14.websitewelcome.com [100.42.49.7]) by gateway31.websitewelcome.com (Postfix) with ESMTP id 87DE4A1A38 for ; Tue, 7 Dec 2021 11:17:58 -0600 (CST) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id ue6Im2zxvQOwQue6Im5qHr; Tue, 07 Dec 2021 11:17:58 -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-Type:MIME-Version:Message-ID:In-Reply-To:Date:References :Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding: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=8lpHbKaoMp1Z/Fy5SnYoW95JLJaclFscgt9eXDcDWWo=; b=sapY1MB/5phjnhpceCAPwACAOb bJ6AkUX2pGQPpU8exZ4cKGT+9gbZitv2SDaYBOhCbcfIBKf4h2IokJVxmZ2y69X397TuVa3UUsZCn O8apWZCbrENPWxzzmiLgOkNgh; Received: from 97-122-84-67.hlrn.qwest.net ([97.122.84.67]:54268 helo=murgatroyd) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1mue6H-004Hkw-Ua; Tue, 07 Dec 2021 10:17:58 -0700 From: Tom Tromey To: Tom Tromey Cc: gdb-patches@sourceware.org Subject: Re: [PATCH v3 13/33] Add "fullname" handling to file_and_directory References: <20211204203844.1188999-1-tom@tromey.com> <20211204203844.1188999-14-tom@tromey.com> X-Attribution: Tom Date: Tue, 07 Dec 2021 10:17:57 -0700 In-Reply-To: <20211204203844.1188999-14-tom@tromey.com> (Tom Tromey's message of "Sat, 4 Dec 2021 13:38:24 -0700") Message-ID: <877dcg49mi.fsf@tromey.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain 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: 1mue6H-004Hkw-Ua X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 97-122-84-67.hlrn.qwest.net (murgatroyd) [97.122.84.67]:54268 X-Source-Auth: tom+tromey.com X-Email-Count: 1 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-Spam-Status: No, score=-3031.6 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: Tue, 07 Dec 2021 17:23:52 -0000 >>>>> "Tom" == Tom Tromey writes: Tom> This changes the file_and_directory object to be able to compute and Tom> cache the "fullname" in the same way that is done by other code, like Tom> the psymtab reader. This turned out to need another update, to dwarf2_base_index_functions::map_symbol_filenames, to avoid some regressions. I've appended the updated patch. Tom commit 562749e543b72c3999b8e759a5a320a0164c047d Author: Tom Tromey Date: Mon Nov 29 17:56:56 2021 -0700 Add "fullname" handling to file_and_directory 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. diff --git a/gdb/dwarf2/file-and-dir.h b/gdb/dwarf2/file-and-dir.h index c56922ff90d..50a94a90525 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 @@ -90,6 +91,20 @@ struct file_and_directory m_name = m_name_storage.get (); } + /* 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. */ @@ -106,6 +121,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 1ae90088d54..a14c5616e65 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->v.quick->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->v.quick->mark = 1; + continue; + } + } + quick_file_names *file_data = dw2_get_file_names (per_cu.get (), per_objfile); if (file_data == NULL) @@ -4556,6 +4580,24 @@ dwarf2_base_index_functions::map_symbol_filenames if (per_cu->is_debug_types || per_objfile->symtab_set_p (per_cu)) continue; + if (per_cu->fnd != nullptr) + { + file_and_directory *fnd = per_cu->fnd.get (); + + const char *filename = fnd->get_name (); + const char *key = filename; + const char *fullname = nullptr; + + if (need_fullname) + { + fullname = fnd->get_fullname (); + key = fullname; + } + + if (!filenames_cache.seen (key)) + fun (filename, fullname); + } + quick_file_names *file_data = dw2_get_file_names (per_cu, per_objfile); if (file_data == nullptr || qfn_cache.find (file_data) != qfn_cache.end ())