[PATCH v2 21/28] Simplify block_lookup_symbol_primary

Tom Tromey
2025-04-02T23:57:00Z

This simplifies block_lookup_symbol_primary by using
block_iterator_range.
---
gdb/block.c | 10 ++--------
1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/gdb/block.c b/gdb/block.c
index cf7ca6785b0c9ef4f3d809a245261d18ffaf06d8..2c07b38f8f806b8a154eb42adbd3f53a3535c57f 100644
--- a/gdb/block.c
+++ b/gdb/block.c
@@ -721,20 +721,14 @@ struct symbol *
block_lookup_symbol_primary (const struct block *block, const char *name,
const domain_search_flags domain)
{
- struct symbol *sym, *other;
- struct mdict_iterator mdict_iter;
-
lookup_name_info lookup_name (name, symbol_name_match_type::FULL);

/* Verify BLOCK is STATIC_BLOCK or GLOBAL_BLOCK. */
gdb_assert (block->superblock () == NULL
|| block->superblock ()->superblock () == NULL);

- other = NULL;
- for (sym = mdict_iter_match_first (block->multidict (), lookup_name,
- &mdict_iter);
- sym != NULL;
- sym = mdict_iter_match_next (lookup_name, &mdict_iter))
+ symbol *other = nullptr;
+ for (symbol *sym : block_iterator_range (block, &lookup_name))
{
/* With the fix for PR gcc/debug/91507, we get for:
...

--
2.46.1