From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id SzMtB9DP7WdUkSQAWB0awg (envelope-from ) for ; Wed, 02 Apr 2025 20:01:20 -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=c7VrKdzg; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 08C1B1E0C3; Wed, 2 Apr 2025 20:01:20 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-3.8 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_INVALID,DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_BL_SPAMCOP_NET, 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 7E7EA1E0C0 for ; Wed, 2 Apr 2025 20:01:19 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 126FA3858431 for ; Thu, 3 Apr 2025 00:01:19 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 126FA3858431 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=c7VrKdzg Received: from omta40.uswest2.a.cloudfilter.net (omta40.uswest2.a.cloudfilter.net [35.89.44.39]) by sourceware.org (Postfix) with ESMTPS id DDCAF385AC35 for ; Wed, 2 Apr 2025 23:45:16 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org DDCAF385AC35 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 DDCAF385AC35 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=35.89.44.39 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1743637517; cv=none; b=O1AQtDH1rgq6dhEaDYL6aKnYhK4R8izQJGjaal2Vv1aj7Z+YafQlz3hbvPP+4uQBblIodB8HJqyXwbNfxWqhu4QPS34Y6lHnQ2TIUCGpv1rrD1RDsyZNtoAICrcF06DhiJ+7h5rrDX+zMufTF3/UmcbJmUeXxT0+kX+nhg4ZHiY= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1743637517; c=relaxed/simple; bh=vydGgmXsn1ilF3DD3Gglg548DC5Ts8MPdbpeiaXXAxg=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=IbrQ5B3WFqpfbpeY5Gsm2K+wXPf/RjlY3aE4YUvlVqtZ8YNeBDnjAsvD+ZeV9wU30zA77sCG3fb3/yk3quaVOqMC918tuR59whM82HxpAGVLWHFuDSeRkcOrU4VX677GlWhZdJU9qCkh1iQDEqgPHFo3EMINM33EGv4LW3hQyKk= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DDCAF385AC35 Received: from eig-obgw-5010a.ext.cloudfilter.net ([10.0.29.199]) by cmsmtp with ESMTPS id 02xFucU9Jf1UX07lkuFIkq; Wed, 02 Apr 2025 23:45:16 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id 07liuanSOdXyM07ljuXZJz; Wed, 02 Apr 2025 23:45:15 +0000 X-Authority-Analysis: v=2.4 cv=fPw/34ae c=1 sm=1 tr=0 ts=67edcc0b a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=IkcTkHD0fZMA:10 a=XR8D0OoHHMoA:10 a=ItBw4LHWJt0A:10 a=CCpqsmhAAAAA:8 a=Z2cK7l0X-JRCRE6b-vQA: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=nQDJu8ZQoP/tJ7eW7jcAO22RgN4QNyWf7CTWNUrFRDo=; b=c7VrKdzgU0xl7dIgiMT6zYAWsX erKsXvXSbHqene4m8KNyy93qOBE/v7GWUGEYXa7qBGQvYu900RD0lVRvgzE6gWsG124/BY/yqNvVm IylykhU5q6DhFT0/tdNNZp6Ej; 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 1u07li-000000014hd-1Z7D; Wed, 02 Apr 2025 17:45:14 -0600 From: Tom Tromey Date: Wed, 02 Apr 2025 17:45:09 -0600 Subject: [PATCH v2 10/28] Have expand_symtabs_matching work for already-expanded CUs MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20250402-search-in-psyms-v2-10-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: 1u07li-000000014hd-1Z7D 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: 11 X-Org: HG=bhshared;ORG=bluehost; X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfCdVRkbT69cssH6Kx/Uzj73fqTud/pXBo0ftSgR8JDAhj3MVg3dEgBpSAZPWjS8v5k8MqdkZ+yOVn+NVjuUs/Cxm9sqKOIhzHSDzTLn+CVsdPSkNh8qq QwCkeRK5PPxn8ApcL6oB24/YyRnxWj3WjVzgrHr+IY7QYCgJREPQOJLdfW081w0ts7Y5OXjxpjHCWoGUXelXA2dqBPFPj3gVEvY= 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 Currently, gdb will search the already-expanded symtabs in one loop, and then also expand matching symtabs in another loop. However, this is somewhat inefficient -- when searching the already-expanded symtabs, all such symtabs are examined. However, the various "quick" implementations already know which subset of symtabs might have a match. This changes the contract of expand_symtabs_matching to also call the callback for an already-expanded symtab. With this change, the number of searched symtabs should sometimes be reduced. This also cuts down on the amount of redundant code. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=16994 Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=16998 --- gdb/dwarf2/read.c | 42 ++++++++++++++++++++++++++++-------------- gdb/psymtab.c | 3 --- 2 files changed, 28 insertions(+), 17 deletions(-) diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index 4b971173815f439ad26da4f78c6aadd0cd18446b..f1084530221e82f33efb35f542d6d842fe3df2ab 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -1544,6 +1544,23 @@ struct readnow_functions : public dwarf2_base_index_functions domain_search_flags domain, expand_symtabs_lang_matcher lang_matcher) override { + dwarf2_per_objfile *per_objfile = get_dwarf2_per_objfile (objfile); + auto_bool_vector marked; + dw_expand_symtabs_matching_file_matcher (per_objfile, marked, + file_matcher); + + for (const auto &per_cu : per_objfile->per_bfd->all_units) + { + QUIT; + + if (per_cu->is_debug_types) + continue; + if (!dw2_expand_symtabs_matching_one (per_cu.get (), per_objfile, + marked, file_matcher, + expansion_notify, + lang_matcher)) + return false; + } return true; } }; @@ -1931,13 +1948,15 @@ dw2_expand_symtabs_matching_one return true; } - bool symtab_was_null = !per_objfile->symtab_set_p (per_cu); compunit_symtab *symtab = dw2_instantiate_symtab (per_cu, per_objfile, false); gdb_assert (symtab != nullptr); - if (expansion_notify != NULL && symtab_was_null) - return expansion_notify (symtab); + if (expansion_notify != nullptr) + { + marked.set (per_cu->index, true); + return expansion_notify (symtab); + } return true; } @@ -1969,13 +1988,6 @@ dw_expand_symtabs_matching_file_matcher continue; } - /* We only need to look at symtabs not already expanded. */ - if (per_objfile->symtab_set_p (per_cu.get ())) - { - marked.set (per_cu->index, true); - continue; - } - if (per_cu->fnd != nullptr) { file_and_directory *fnd = per_cu->fnd.get (); @@ -4211,6 +4223,12 @@ load_full_comp_unit (dwarf2_per_cu *this_cu, dwarf2_per_objfile *per_objfile, if (reader.is_dummy ()) return; + /* We always need the file names filled in so that + expand_symtabs_matching can match filenames. It's convenient to + do this here. */ + if (!this_cu->files_read) + dw2_get_file_names_reader (reader.cu (), reader.top_level_die ()); + reader.read_all_dies (); /* Save this dwarf2_cu in the per_objfile. The per_objfile owns it @@ -14534,10 +14552,6 @@ cooked_index_functions::expand_symtabs_matching { QUIT; - /* No need to consider symbols from expanded CUs. */ - if (per_objfile->symtab_set_p (entry->per_cu)) - continue; - /* We don't need to consider symbols from some CUs. */ if (marked.is_set (entry->per_cu->index)) continue; diff --git a/gdb/psymtab.c b/gdb/psymtab.c index 28455ba0bc58990a515f0899a873c9995fb4cca8..d12f8f1c5c18018fe96b0d647f3957dfd0f4d594 100644 --- a/gdb/psymtab.c +++ b/gdb/psymtab.c @@ -914,9 +914,6 @@ psymbol_functions::expand_symtabs_matching { QUIT; - if (ps->readin_p (objfile)) - continue; - if (file_matcher) { bool match; -- 2.46.1