From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id iCnpHpjR7WcdkiQAWB0awg (envelope-from ) for ; Wed, 02 Apr 2025 20:08:56 -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=LrH1trDr; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 7B0D11E0C3; Wed, 2 Apr 2025 20:08:56 -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 F31401E0C0 for ; Wed, 2 Apr 2025 20:08:55 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id AAE59385AC29 for ; Thu, 3 Apr 2025 00:08:55 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AAE59385AC29 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=LrH1trDr Received: from omta38.uswest2.a.cloudfilter.net (omta38.uswest2.a.cloudfilter.net [35.89.44.37]) by sourceware.org (Postfix) with ESMTPS id 7DD7B38560AB for ; Wed, 2 Apr 2025 23:45:22 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 7DD7B38560AB 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 7DD7B38560AB Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=35.89.44.37 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1743637522; cv=none; b=kiUyvIB2MB7dvvXaJtiAZZrhsQ7gCiwBDxj3z/pnU9Fq1K6ySfuu1eZPNseB3uOft/TweU6cDInqMJ+UvsLF5bqWOUxOPmH3gmG6VE+ILJk0eSZJAAw1j1l8CEny6xW2TntVWttF0muzEuqVyPwwmZnGDDJCjKFwYIDqBZYuKr4= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1743637522; c=relaxed/simple; bh=aw+Sal6gWr8NoKHwMoUa5KGvUqcsFQoP6qTcjMpGbeg=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=GlX8Nl1tafXy5fsz73BNMJ7NykQpmqBBts3jl8yRBAVWbEIgjusevvxyDcnqe4pN06SxvzYW/VJmmY6tVWBUSO80ZpHw79Rbk9apX9WHe1OxPj3PeGakQPdc5Y25pePNumx7ciDaWMgqQeF8JpgnEsYPele2cCjCPB2GLBSxlLs= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7DD7B38560AB Received: from eig-obgw-5008a.ext.cloudfilter.net ([10.0.29.246]) by cmsmtp with ESMTPS id 027Gu6OJyAfjw07lpuUDW3; Wed, 02 Apr 2025 23:45:21 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id 07louMC7DoAm007lpuObSN; Wed, 02 Apr 2025 23:45:21 +0000 X-Authority-Analysis: v=2.4 cv=A/FqPbWG c=1 sm=1 tr=0 ts=67edcc11 a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=IkcTkHD0fZMA:10 a=XR8D0OoHHMoA:10 a=ItBw4LHWJt0A:10 a=CCpqsmhAAAAA:8 a=JPLvegEKUnYSeKm9d-QA: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=kumMFaPp5S7att59zddIUvs783Nc5Z9GIWK5PpeKDFA=; b=LrH1trDrdURe+Zig86cmHDyubN EYHINTt1ow1yBYmyjBaadQzK67aS9ykg9lJd8yp0b66fYVfAt/gDbLWNWDXoFOtBsLb2NUCRX113u w6kQqEkdwd+BtfznXL3k8jvPU; 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 1u07lo-000000014hd-1w1F; Wed, 02 Apr 2025 17:45:20 -0600 From: Tom Tromey Date: Wed, 02 Apr 2025 17:45:24 -0600 Subject: [PATCH v2 25/28] Convert lookup_symbol_via_quick_fns MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20250402-search-in-psyms-v2-25-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: 1u07lo-000000014hd-1w1F 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: 26 X-Org: HG=bhshared;ORG=bluehost; X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfNyOgJ0weY1tDWF2S/DT43NFrDPSO7CecexkBRdhO+yDXwlfoqtbAqiXkc1cgP21xJOQxUHeqaqmDgdzwiSgS/3ERRd3+fdFwcbVBBXhTwjLnvpwlvBd CtNXW0wB6ERfbiR8puSLx++VRTUmqP8fB79MRWGpEH43t2BoUEF7sh6L00BFLrKp1lkXPARZHtnoOXAucp/E9niuH5bGQBPNwb0= 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 converts lookup_symbol_via_quick_fns to the callback approach, merging the search loop and the call to expand_symtabs_matching. Note that this changes lookup_symbol_via_quick_fns to use a best_symbol_tracker. Before this patch there was a discrepancy here between the two search functions. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=16994 Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=16998 --- gdb/symtab.c | 39 ++++++++++++++++++++++----------------- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/gdb/symtab.c b/gdb/symtab.c index 8961e117348b8fe2b2ebf6b73ad1ca0fe9edbe35..511dfd884bf41d61a475e953d0f68a2031bc2ca3 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -2458,11 +2458,6 @@ lookup_symbol_via_quick_fns (struct objfile *objfile, enum block_enum block_index, const char *name, const domain_search_flags domain) { - struct compunit_symtab *cust; - const struct blockvector *bv; - const struct block *block; - struct block_symbol result; - symbol_lookup_debug_printf_v ("lookup_symbol_via_quick_fns (%s, %s, %s, %s)", objfile_debug_name (objfile), @@ -2470,27 +2465,37 @@ lookup_symbol_via_quick_fns (struct objfile *objfile, name, domain_name (domain).c_str ()); lookup_name_info lookup_name (name, symbol_name_match_type::FULL); - cust = objfile->lookup_symbol (block_index, lookup_name, domain); - if (cust == NULL) + best_symbol_tracker accum; + auto searcher = [&] (compunit_symtab *symtab) + { + const struct blockvector *bv = symtab->blockvector (); + const struct block *block = bv->block (block_index); + /* If the accumulator finds a best symbol, end the search by + returning false; otherwise keep going by returning true. */ + return !accum.search (symtab, block, lookup_name, domain); + }; + + objfile->expand_symtabs_matching (nullptr, &lookup_name, nullptr, + searcher, + block_index == GLOBAL_BLOCK + ? SEARCH_GLOBAL_BLOCK + : SEARCH_STATIC_BLOCK, + domain); + if (accum.best_symtab == nullptr) { symbol_lookup_debug_printf_v ("lookup_symbol_via_quick_fns (...) = NULL"); return {}; } - - bv = cust->blockvector (); - block = bv->block (block_index); - result.symbol = block_lookup_symbol (block, lookup_name, domain); - if (result.symbol == NULL) - error_in_psymtab_expansion (block_index, name, cust); + if (accum.currently_best.symbol == nullptr) + error_in_psymtab_expansion (block_index, name, accum.best_symtab); symbol_lookup_debug_printf_v ("lookup_symbol_via_quick_fns (...) = %s (block %s)", - host_address_to_string (result.symbol), - host_address_to_string (block)); + host_address_to_string (accum.currently_best.symbol), + host_address_to_string (accum.currently_best.block)); - result.block = block; - return result; + return accum.currently_best; } /* See language.h. */ -- 2.46.1