[21/28] Simplify block_lookup_symbol_primary

Message ID 20250311-search-in-psyms-v1-21-d73d9be20983@tromey.com
State New
Headers
Series Search symbols via quick API |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_gdb_build--master-aarch64 fail Patch failed to apply
linaro-tcwg-bot/tcwg_gdb_build--master-arm fail Patch failed to apply

Commit Message

Tom Tromey March 11, 2025, 2:12 p.m. UTC
  This simplifies block_lookup_symbol_primary by using
block_iterator_range.
---
 gdb/block.c | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)
  

Patch

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:
 	 ...