From patchwork Fri Jan 20 21:46:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 63529 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 648BA3881D01 for ; Fri, 20 Jan 2023 21:48:04 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from alt-proxy28.mail.unifiedlayer.com (alt-proxy28.mail.unifiedlayer.com [74.220.216.123]) by sourceware.org (Postfix) with ESMTPS id 24964385840C for ; Fri, 20 Jan 2023 21:46:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 24964385840C Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tromey.com Received: from cmgw12.mail.unifiedlayer.com (unknown [10.0.90.127]) by progateway1.mail.pro1.eigbox.com (Postfix) with ESMTP id 90E151003FBA4 for ; Fri, 20 Jan 2023 21:46:38 +0000 (UTC) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTP id IzDap994uiOW0IzDapygEB; Fri, 20 Jan 2023 21:46:38 +0000 X-Authority-Reason: nr=8 X-Authority-Analysis: v=2.4 cv=S5kcfKgP c=1 sm=1 tr=0 ts=63cb0bbe a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=dLZJa+xiwSxG16/P+YVxDGlgEgI=:19 a=RvmDmJFTN0MA:10:nop_rcvd_month_year a=Qbun_eYptAEA:10:endurance_base64_authed_username_1 a=rZQGfaXeXV2KTLFHH24A:9 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: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=wVBTzlYkn/fdoV+0xJamGK4WE3FDBjf89lEoFnxNoks=; b=K+k/77aYcCwfWBHN4Qw8UGJV2I 6E/5b57gurMTFWihFyElFeX60j6eL45tZNJF9akmDsm8lidDS5ZcOf3givF0yEGdPXHueMx7bRMOE H8Iee3CIqAC1xu8ArSj+LnDzj; Received: from 97-122-76-186.hlrn.qwest.net ([97.122.76.186]:60138 helo=localhost.localdomain) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1pIzDa-001GGF-AR; Fri, 20 Jan 2023 14:46:38 -0700 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 16/27] Store 'name' in block_iterator Date: Fri, 20 Jan 2023 14:46:07 -0700 Message-Id: <20230120214618.3236224-17-tom@tromey.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230120214618.3236224-1-tom@tromey.com> References: <20230120214618.3236224-1-tom@tromey.com> MIME-Version: 1.0 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.76.186 X-Source-L: No X-Exim-ID: 1pIzDa-001GGF-AR X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 97-122-76-186.hlrn.qwest.net (localhost.localdomain) [97.122.76.186]:60138 X-Source-Auth: tom+tromey.com X-Email-Count: 17 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-Spam-Status: No, score=-3027.9 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_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) 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: , Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" This changes the block_iterator to store the 'name' that is used by block_iter_match_next. This avoids any problem where the name could be passed inconsistently, and also makes the subsequent patches easier to understand. --- gdb/ada-lang.c | 2 +- gdb/block.c | 22 ++++++++++++---------- gdb/block.h | 10 ++++++---- 3 files changed, 19 insertions(+), 15 deletions(-) diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index 57676f0de95..c04d75590fb 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -6087,7 +6087,7 @@ ada_add_block_symbols (std::vector &result, found_sym = false; for (sym = block_iter_match_first (block, lookup_name, &iter); sym != NULL; - sym = block_iter_match_next (lookup_name, &iter)) + sym = block_iter_match_next (&iter)) { if (symbol_matches_domain (sym->language (), sym->domain (), domain)) { diff --git a/gdb/block.c b/gdb/block.c index 8aa0e676894..e56c95013b8 100644 --- a/gdb/block.c +++ b/gdb/block.c @@ -453,12 +453,14 @@ get_block_compunit_symtab (const struct block *block) static void initialize_block_iterator (const struct block *block, - struct block_iterator *iter) + struct block_iterator *iter, + const lookup_name_info *name = nullptr) { enum block_enum which; struct compunit_symtab *cu; iter->idx = -1; + iter->name = name; if (block->superblock () == NULL) { @@ -585,7 +587,6 @@ block_iterator_next (struct block_iterator *iterator) static struct symbol * block_iter_match_step (struct block_iterator *iterator, - const lookup_name_info &name, int first) { struct symbol *sym; @@ -605,11 +606,11 @@ block_iter_match_step (struct block_iterator *iterator, return NULL; block = cust->blockvector ()->block (iterator->which); - sym = mdict_iter_match_first (block->multidict (), name, + sym = mdict_iter_match_first (block->multidict (), *iterator->name, &iterator->mdict_iter); } else - sym = mdict_iter_match_next (name, &iterator->mdict_iter); + sym = mdict_iter_match_next (*iterator->name, &iterator->mdict_iter); if (sym != NULL) return sym; @@ -629,25 +630,26 @@ block_iter_match_first (const struct block *block, const lookup_name_info &name, struct block_iterator *iterator) { - initialize_block_iterator (block, iterator); + initialize_block_iterator (block, iterator, &name); if (iterator->which == FIRST_LOCAL_BLOCK) return mdict_iter_match_first (block->multidict (), name, &iterator->mdict_iter); - return block_iter_match_step (iterator, name, 1); + return block_iter_match_step (iterator, 1); } /* See block.h. */ struct symbol * -block_iter_match_next (const lookup_name_info &name, - struct block_iterator *iterator) +block_iter_match_next (struct block_iterator *iterator) { + gdb_assert (iterator->name != nullptr); + if (iterator->which == FIRST_LOCAL_BLOCK) - return mdict_iter_match_next (name, &iterator->mdict_iter); + return mdict_iter_match_next (*iterator->name, &iterator->mdict_iter); - return block_iter_match_step (iterator, name, 0); + return block_iter_match_step (iterator, 0); } /* See block.h. */ diff --git a/gdb/block.h b/gdb/block.h index 9bc80490d7c..5fc41c6df02 100644 --- a/gdb/block.h +++ b/gdb/block.h @@ -449,6 +449,9 @@ struct block_iterator const struct block *block; } d; + /* If we're trying to match a name, this will be non-NULL. */ + const lookup_name_info *name; + /* If we're iterating over a single block, this is always -1. Otherwise, it holds the index of the current "included" symtab in the canonical symtab (that is, d.symtab->includes[idx]), with -1 @@ -493,10 +496,9 @@ extern struct symbol *block_iter_match_first (const struct block *block, symbols. Don't call this if you've previously received NULL from block_iterator_match_first or block_iterator_match_next on this iteration. And don't call it unless ITERATOR was created by a - previous call to block_iter_match_first with the same NAME. */ + previous call to block_iter_match_first. */ -extern struct symbol *block_iter_match_next - (const lookup_name_info &name, struct block_iterator *iterator); +extern struct symbol *block_iter_match_next (struct block_iterator *iterator); /* Return true if symbol A is the best match possible for DOMAIN. */ @@ -574,7 +576,7 @@ extern int block_find_non_opaque_type_preferred (struct symbol *sym, #define ALL_BLOCK_SYMBOLS_WITH_NAME(block, name, iter, sym) \ for ((sym) = block_iter_match_first ((block), (name), &(iter)); \ (sym) != NULL; \ - (sym) = block_iter_match_next ((name), &(iter))) + (sym) = block_iter_match_next (&(iter))) /* Given a vector of pairs, allocate and build an obstack allocated blockranges struct for a block. */