From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id MGWPNanN7WfNjiQAWB0awg (envelope-from ) for ; Wed, 02 Apr 2025 19:52:09 -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=lpwrSv6Y; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id D5F001E0C3; Wed, 2 Apr 2025 19:52:09 -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 44D411E0C0 for ; Wed, 2 Apr 2025 19:52:09 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D6002385B527 for ; Wed, 2 Apr 2025 23:52:08 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D6002385B527 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=lpwrSv6Y Received: from omta036.useast.a.cloudfilter.net (omta036.useast.a.cloudfilter.net [44.202.169.35]) by sourceware.org (Postfix) with ESMTPS id 6FFB1385B527 for ; Wed, 2 Apr 2025 23:45:19 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6FFB1385B527 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 6FFB1385B527 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=44.202.169.35 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1743637519; cv=none; b=TjHg3d8ldFC3aDOS14khNvSozPV2I2STLPePITbLcwq74jt85LBKUS4ncP5xaLS8VLxGKXR4jwFkdK/CxjCv2k462erSV8ziL71OOfn6Mpj/hoYvWwb9E65fmmnu5hPUq8B9biN4OaXlVlKAEz4Ayt/+9CuMlTTghSBVTLhbkB4= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1743637519; c=relaxed/simple; bh=oJTXoxVFH3rnVBF5gOxNyPn92R+H210ae/f3iSgwC/Y=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=gez/QCy+POxyQ2oYV1R1DYPeYCfU9pqCdGJMuNbqnpeGtXdnYM6G92Q5aTOMpYtxB76VeeqpuzUcWWj1dQDVm463hlZCYFrH1P+97IYXoTUydoZfGIVRInGANc0H9bo0cQvBx7G6oZIziEj/F7XXtDHarkIm8xzJmXqVM64YCSE= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6FFB1385B527 Received: from eig-obgw-6002a.ext.cloudfilter.net ([10.0.30.222]) by cmsmtp with ESMTPS id 067xunG63zZPa07lnuJzDx; Wed, 02 Apr 2025 23:45:19 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id 07lmuYz2L1vNy07lmuVSEE; Wed, 02 Apr 2025 23:45:18 +0000 X-Authority-Analysis: v=2.4 cv=VMQWnMPX c=1 sm=1 tr=0 ts=67edcc0e a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=IkcTkHD0fZMA:10 a=XR8D0OoHHMoA:10 a=ItBw4LHWJt0A:10 a=CCpqsmhAAAAA:8 a=u-wF06XqGp4xlL6K_RQA: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=sdjgI7XsC+giliiD/Mjgu67moJC36mdna2L1f3+I2TQ=; b=lpwrSv6YUqe4QUOo9Act5NKA4f Hcvfzdbwfehe8v06DRLzWdV9/roQWGpRFnlYQ6a255R+phA5R9jMDgXlGWTCqcd7JyRz9eoXlSvCw fjKly/uHWGTvYmghS9rdcWgZB; 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 1u07lm-000000014hd-0fZi; Wed, 02 Apr 2025 17:45:18 -0600 From: Tom Tromey Date: Wed, 02 Apr 2025 17:45:17 -0600 Subject: [PATCH v2 18/28] Simplify basic_lookup_transparent_type MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20250402-search-in-psyms-v2-18-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: 1u07lm-000000014hd-0fZi 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: 19 X-Org: HG=bhshared;ORG=bluehost; X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfISDXkTKAU81XvScgbARoGWmWCn0l9EdbYQwzXuC944nitWEsbgcE2m5Im8GhYBE1hgCoRVB485xnx3tmpuI5QqYQaSxVom4VcBISwuSLmSkQnSU06QF netK7qn+zAGftuFmZ6/opb4/wJolVHiVMCkDgGcP5nqmjZeUKBM8xwVVOfPxkPuAd064UYkg+L3Mree/pZVYC9Zvs26AlHkNki0= 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 patch changes basic_lookup_transparent_type to always work via the "quick" API -- that is, no separate search of the already-expanded symtabs is needed. This is more efficient when many CUs have already been expanded. It also makes the lookup more consistent, as the result is no longer dependent on the order in which CUs were previously expanded. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=16994 Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=16998 --- gdb/symtab.c | 60 +++--------------------------------------------------------- 1 file changed, 3 insertions(+), 57 deletions(-) diff --git a/gdb/symtab.c b/gdb/symtab.c index b52fa07da8737c39d39d5c86bb380beb8c81ea62..508374f1358e92108db7546246e2323c5d7b5905 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -2776,35 +2776,6 @@ basic_lookup_transparent_type_quick (struct objfile *objfile, return sym->type (); } -/* Subroutine of basic_lookup_transparent_type to simplify it. - Look up the non-opaque definition of NAME in BLOCK_INDEX of OBJFILE. - BLOCK_INDEX is either GLOBAL_BLOCK or STATIC_BLOCK. */ - -static struct type * -basic_lookup_transparent_type_1 (struct objfile *objfile, - enum block_enum block_index, - domain_search_flags flags, - const lookup_name_info &name) -{ - const struct blockvector *bv; - const struct block *block; - const struct symbol *sym; - - for (compunit_symtab *cust : objfile->compunits ()) - { - bv = cust->blockvector (); - block = bv->block (block_index); - sym = block_find_symbol (block, name, flags, nullptr); - if (sym != nullptr) - { - gdb_assert (!TYPE_IS_OPAQUE (sym->type ())); - return sym->type (); - } - } - - return NULL; -} - /* The standard implementation of lookup_transparent_type. This code was modeled on lookup_symbol -- the parts not relevant to looking up types were just left out. In particular it's assumed here that @@ -2818,19 +2789,7 @@ basic_lookup_transparent_type (const char *name, domain_search_flags flags) lookup_name_info lookup_name (name, symbol_name_match_type::FULL); - /* Now search all the global symbols. Do the symtab's first, then - check the psymtab's. If a psymtab indicates the existence - of the desired name as a global, then do psymtab-to-symtab - conversion on the fly and return the found symbol. */ - - for (objfile *objfile : current_program_space->objfiles ()) - { - t = basic_lookup_transparent_type_1 (objfile, GLOBAL_BLOCK, - flags, lookup_name); - if (t) - return t; - } - + /* Search all the global symbols. */ for (objfile *objfile : current_program_space->objfiles ()) { t = basic_lookup_transparent_type_quick (objfile, GLOBAL_BLOCK, @@ -2839,21 +2798,8 @@ basic_lookup_transparent_type (const char *name, domain_search_flags flags) return t; } - /* Now search the static file-level symbols. - Not strictly correct, but more useful than an error. - Do the symtab's first, then - check the psymtab's. If a psymtab indicates the existence - of the desired name as a file-level static, then do psymtab-to-symtab - conversion on the fly and return the found symbol. */ - - for (objfile *objfile : current_program_space->objfiles ()) - { - t = basic_lookup_transparent_type_1 (objfile, STATIC_BLOCK, - flags, lookup_name); - if (t) - return t; - } - + /* Now search the static file-level symbols. Not strictly correct, + but more useful than an error. */ for (objfile *objfile : current_program_space->objfiles ()) { t = basic_lookup_transparent_type_quick (objfile, STATIC_BLOCK, -- 2.46.1