From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id SHRgJFHO7WdRjyQAWB0awg (envelope-from ) for ; Wed, 02 Apr 2025 19:54:57 -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=iiuEq75V; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 9072F1E0C3; Wed, 2 Apr 2025 19:54:57 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-5.1 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_INVALID,DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham 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 EEAF71E0C0 for ; Wed, 2 Apr 2025 19:54:56 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A2D0C3856DEB for ; Wed, 2 Apr 2025 23:54:48 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A2D0C3856DEB Authentication-Results: sourceware.org; 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=iiuEq75V Received: from omta36.uswest2.a.cloudfilter.net (omta36.uswest2.a.cloudfilter.net [35.89.44.35]) by sourceware.org (Postfix) with ESMTPS id 349783857013 for ; Wed, 2 Apr 2025 23:45:16 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 349783857013 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 349783857013 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=35.89.44.35 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1743637516; cv=none; b=nkkONNQNgVXNLiZ/y49ynGNi+VKIZea3qVZEFLkclmUYtipOohwRuxBgb/3jke7x7eCse3WIGSfYbmLxC02Ayf3kiBxjLOlYMwYnUNVUHeZqM2wcF1iwwZLum9frSgoC7ChLItqV94YUxjdE45TcjRbJ/YfWIe24ol/aVQW8/0U= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1743637516; c=relaxed/simple; bh=xRreVvn3kKX9ELqrSHVXDlVa6y18bIH0A6E3a8cgsGc=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=ce6q+4BmAWIej3ZtSqmyVTC1/RfNLgqzbjLUnNr/AzaKgU87QEYC0GNIsXh2uGAkubQMKST8fIZTDhTwHQTVhU60+hgW0GYDRayiGh4PbEkFR8WwUqKP3Xec0LKTL3GPkAaa1jofl4ngBuyk3wLfLdLHlnew8WxhQZHs9cWUP0I= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 349783857013 Received: from eig-obgw-5006a.ext.cloudfilter.net ([10.0.29.179]) by cmsmtp with ESMTPS id zzdEtoDsCMETl07ljuq3Mq; Wed, 02 Apr 2025 23:45:15 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id 07liuw6rKnOa107liuC37A; Wed, 02 Apr 2025 23:45:14 +0000 X-Authority-Analysis: v=2.4 cv=Z83qHmRA c=1 sm=1 tr=0 ts=67edcc0a a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=IkcTkHD0fZMA:10 a=XR8D0OoHHMoA:10 a=ItBw4LHWJt0A:10 a=CCpqsmhAAAAA:8 a=33IiyaYLD9JH7cLCfyAA:9 a=QEXdDO2ut3YA:10 a=ul9cdbp4aOFLsgKbc677:22 a=6Ogn3jAGHLSNbaov7Orx: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=xygkk0hdOupojTsNncDE09nsi9NMHg5wRR3KcfhEuL8=; b=iiuEq75VS+o6kW5j9Lzv6+c1cP 5iyJd8FvDQQac0gVzoAQieQgH9Qswudh3UHpXSmy4hlNARalCoYxaEb9g9ecJ5ZQR8D1sjeGWP9I7 C2gxWJLLPIlojLqvSPRPFrsmq; Received: from 97-122-123-18.hlrn.qwest.net ([97.122.123.18]:56394 helo=prentzel.local) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.1) (envelope-from ) id 1u07lh-000000014hd-3CkE; Wed, 02 Apr 2025 17:45:13 -0600 From: Tom Tromey Date: Wed, 02 Apr 2025 17:45:08 -0600 Subject: [PATCH v2 09/28] Remove dwarf2_per_cu_data::mark MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20250402-search-in-psyms-v2-9-ea91704487cb@tromey.com> References: <20250402-search-in-psyms-v2-0-ea91704487cb@tromey.com> In-Reply-To: <20250402-search-in-psyms-v2-0-ea91704487cb@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.123.18 X-Source-L: No X-Exim-ID: 1u07lh-000000014hd-3CkE X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 97-122-123-18.hlrn.qwest.net (prentzel.local) [97.122.123.18]:56394 X-Source-Auth: tom+tromey.com X-Email-Count: 10 X-Org: HG=bhshared;ORG=bluehost; X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfLXqDJxyojI0immkxrSjby7aZARGPgxRNjAfqPq4AdmAisNhmoZmiZBia5/5xLGK7r38PZrTHhwtri9WEL7eiDh1AIW8/XQXhkt2Djo6ycIXtBhUe7lC 59fPEnUWGc2txI3ua1Bgs6bDWvpujoVfmDhXukTMnkEm8/YBDD92cRm3xNBKjxBcqi983oX9x4vBJl8iDbxrJGfHqiTfUoJ70gQ= 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 This removes dwarf2_per_cu_data::mark, replacing it with a locally-allocated boolean vector. It also inverts the sense of the flag -- now, the flag is true when a CU should be skipped, and false when the CU should be further examined. Also, the validity of the flag is no longer dependent on 'file_matcher != NULL'. This patch makes the subsequent patch to searching a bit simpler, so I've separated it out. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=16994 Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=16998 --- gdb/dwarf2/read-gdb-index.c | 14 +++++----- gdb/dwarf2/read.c | 64 ++++++++++++++++++++++++++------------------- gdb/dwarf2/read.h | 35 +++++++++++++++++++++---- 3 files changed, 75 insertions(+), 38 deletions(-) diff --git a/gdb/dwarf2/read-gdb-index.c b/gdb/dwarf2/read-gdb-index.c index eeaa38a502c09a0acdd1b60a1c0b8403843aa9fe..7bcf50d347609f0b27068228cd78633dd57e1556 100644 --- a/gdb/dwarf2/read-gdb-index.c +++ b/gdb/dwarf2/read-gdb-index.c @@ -1030,6 +1030,7 @@ dwarf2_gdb_index::dump (struct objfile *objfile) static bool dw2_expand_marked_cus (dwarf2_per_objfile *per_objfile, offset_type idx, + auto_bool_vector &marked, expand_symtabs_file_matcher file_matcher, expand_symtabs_expansion_listener expansion_notify, block_search_flags search_flags, @@ -1114,9 +1115,9 @@ dw2_expand_marked_cus (dwarf2_per_objfile *per_objfile, offset_type idx, } dwarf2_per_cu *per_cu = per_objfile->per_bfd->get_cu (cu_index); - - if (!dw2_expand_symtabs_matching_one (per_cu, per_objfile, file_matcher, - expansion_notify, lang_matcher)) + if (!dw2_expand_symtabs_matching_one (per_cu, per_objfile, marked, + file_matcher, expansion_notify, + lang_matcher)) return false; } @@ -1136,7 +1137,8 @@ dwarf2_gdb_index::expand_symtabs_matching { dwarf2_per_objfile *per_objfile = get_dwarf2_per_objfile (objfile); - dw_expand_symtabs_matching_file_matcher (per_objfile, file_matcher); + auto_bool_vector marked; + dw_expand_symtabs_matching_file_matcher (per_objfile, marked, file_matcher); /* This invariant is documented in quick-functions.h. */ gdb_assert (lookup_name != nullptr || symbol_matcher == nullptr); @@ -1147,7 +1149,7 @@ dwarf2_gdb_index::expand_symtabs_matching QUIT; if (!dw2_expand_symtabs_matching_one (per_cu, per_objfile, - file_matcher, + marked, file_matcher, expansion_notify, lang_matcher)) return false; @@ -1164,7 +1166,7 @@ dwarf2_gdb_index::expand_symtabs_matching symbol_matcher, [&] (offset_type idx) { - if (!dw2_expand_marked_cus (per_objfile, idx, file_matcher, + if (!dw2_expand_marked_cus (per_objfile, idx, marked, file_matcher, expansion_notify, search_flags, domain, lang_matcher)) return false; diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index ae8369266be1b1d7e5cc99cb1f44966a2392ec2b..4b971173815f439ad26da4f78c6aadd0cd18446b 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -1913,11 +1913,13 @@ bool dw2_expand_symtabs_matching_one (dwarf2_per_cu *per_cu, dwarf2_per_objfile *per_objfile, + auto_bool_vector &marked, expand_symtabs_file_matcher file_matcher, expand_symtabs_expansion_listener expansion_notify, expand_symtabs_lang_matcher lang_matcher) { - if (file_matcher != nullptr && !per_cu->mark) + /* Already visited, or intentionally skipped. */ + if (marked.is_set (per_cu->index)) return true; if (lang_matcher != nullptr) @@ -1944,7 +1946,9 @@ dw2_expand_symtabs_matching_one void dw_expand_symtabs_matching_file_matcher - (dwarf2_per_objfile *per_objfile, expand_symtabs_file_matcher file_matcher) + (dwarf2_per_objfile *per_objfile, + auto_bool_vector &marked, + expand_symtabs_file_matcher file_matcher) { if (file_matcher == NULL) return; @@ -1960,54 +1964,57 @@ dw_expand_symtabs_matching_file_matcher QUIT; if (per_cu->is_debug_types) - continue; - per_cu->mark = 0; + { + marked.set (per_cu->index, true); + continue; + } /* We only need to look at symtabs not already expanded. */ if (per_objfile->symtab_set_p (per_cu.get ())) - continue; + { + marked.set (per_cu->index, true); + 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; - } + 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; - } + continue; } quick_file_names *file_data = dw2_get_file_names (per_cu.get (), per_objfile); if (file_data == NULL) - continue; + { + marked.set (per_cu->index, true); + continue; + } if (visited_not_found.contains (file_data)) - continue; - else if (visited_found.contains (file_data)) { - per_cu->mark = 1; + marked.set (per_cu->index, true); continue; } + else if (visited_found.contains (file_data)) + continue; + bool matched = false; for (int j = 0; j < file_data->num_file_names; ++j) { const char *this_real_name; if (file_matcher (file_data->file_names[j], false)) { - per_cu->mark = 1; + matched = true; break; } @@ -2021,15 +2028,18 @@ dw_expand_symtabs_matching_file_matcher this_real_name = dw2_get_real_path (per_objfile, file_data, j); if (file_matcher (this_real_name, false)) { - per_cu->mark = 1; + matched = true; break; } } - if (per_cu->mark) + if (matched) visited_found.insert (file_data); else - visited_not_found.insert (file_data); + { + marked.set (per_cu->index, true); + visited_not_found.insert (file_data); + } } } @@ -14435,7 +14445,8 @@ cooked_index_functions::expand_symtabs_matching cooked_index *table = wait (objfile, true); - dw_expand_symtabs_matching_file_matcher (per_objfile, file_matcher); + auto_bool_vector marked; + dw_expand_symtabs_matching_file_matcher (per_objfile, marked, file_matcher); /* This invariant is documented in quick-functions.h. */ gdb_assert (lookup_name != nullptr || symbol_matcher == nullptr); @@ -14446,7 +14457,7 @@ cooked_index_functions::expand_symtabs_matching QUIT; if (!dw2_expand_symtabs_matching_one (per_cu, per_objfile, - file_matcher, + marked, file_matcher, expansion_notify, lang_matcher)) return false; @@ -14527,9 +14538,8 @@ cooked_index_functions::expand_symtabs_matching if (per_objfile->symtab_set_p (entry->per_cu)) continue; - /* If file-matching was done, we don't need to consider - symbols from unmarked CUs. */ - if (file_matcher != nullptr && !entry->per_cu->mark) + /* We don't need to consider symbols from some CUs. */ + if (marked.is_set (entry->per_cu->index)) continue; /* See if the symbol matches the type filter. */ @@ -14614,7 +14624,7 @@ cooked_index_functions::expand_symtabs_matching } if (!dw2_expand_symtabs_matching_one (entry->per_cu, per_objfile, - file_matcher, + marked, file_matcher, expansion_notify, nullptr)) return false; } diff --git a/gdb/dwarf2/read.h b/gdb/dwarf2/read.h index c39945d7da4e5a4bd33292849437bcbe396fbb0a..6cc08993a3ce7cdfa8b80350e8f0b965ed69b3e3 100644 --- a/gdb/dwarf2/read.h +++ b/gdb/dwarf2/read.h @@ -125,7 +125,6 @@ struct dwarf2_per_cu lto_artificial (false), queued (false), m_header_read_in (false), - mark (false), files_read (false), scanned (false), section (section), @@ -193,10 +192,6 @@ struct dwarf2_per_cu it private at the moment. */ mutable packed m_header_read_in; - /* A temporary mark bit used when iterating over all CUs in - expand_symtabs_matching. */ - packed mark; - /* True if we've tried to read the file table. There will be no point in trying to read it again next time. */ packed files_read; @@ -1179,6 +1174,34 @@ struct dwarf2_base_index_functions : public quick_symbol_functions bool need_fullname) override; }; +/* This is used to track whether a CU has already been visited during + symbol expansion. It is an auto-resizing bool vector. */ +class auto_bool_vector +{ +public: + + auto_bool_vector () = default; + + /* Return true if element I is set. */ + bool is_set (size_t i) const + { + if (i < m_vec.size ()) + return m_vec[i]; + return false; + } + + /* Set a value in this vector, growing it automatically. */ + void set (size_t i, bool value) + { + if (m_vec.size () < i + 1) + m_vec.resize (i + 1); + m_vec[i] = value; + } + +private: + std::vector m_vec; +}; + /* If FILE_MATCHER is NULL or if PER_CU has dwarf2_per_cu_quick_data::MARK set (see dw_expand_symtabs_matching_file_matcher), expand the CU and call @@ -1187,6 +1210,7 @@ struct dwarf2_base_index_functions : public quick_symbol_functions extern bool dw2_expand_symtabs_matching_one (dwarf2_per_cu *per_cu, dwarf2_per_objfile *per_objfile, + auto_bool_vector &marked, expand_symtabs_file_matcher file_matcher, expand_symtabs_expansion_listener expansion_notify, expand_symtabs_lang_matcher lang_matcher); @@ -1197,6 +1221,7 @@ extern bool dw2_expand_symtabs_matching_one extern void dw_expand_symtabs_matching_file_matcher (dwarf2_per_objfile *per_objfile, + auto_bool_vector &marked, expand_symtabs_file_matcher file_matcher); /* Return pointer to string at .debug_str offset STR_OFFSET. */ -- 2.46.1