From a1b294260f4e43cfb7edb2a917accb82945ed310 Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Thu, 19 Jan 2023 20:21:10 -0700 Subject: Remove ALL_BLOCK_SYMBOLS_WITH_NAME This removes ALL_BLOCK_SYMBOLS_WITH_NAME in favor of foreach. --- gdb/python/py-block.c | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) (limited to 'gdb/python/py-block.c') diff --git a/gdb/python/py-block.c b/gdb/python/py-block.c index bd2ce7f..da33d4c 100644 --- a/gdb/python/py-block.c +++ b/gdb/python/py-block.c @@ -265,24 +265,18 @@ blpy_getitem (PyObject *self, PyObject *key) lookup_name_info lookup_name (name.get(), symbol_name_match_type::FULL); - /* We use ALL_BLOCK_SYMBOLS_WITH_NAME instead of block_lookup_symbol so - that we can look up symbols irrespective of the domain, matching the - iterator. It would be confusing if the iterator returns symbols you - can't find via getitem. */ - struct block_iterator iter; - struct symbol *sym = nullptr; - ALL_BLOCK_SYMBOLS_WITH_NAME (block, lookup_name, iter, sym) + /* We use an iterator instead of block_lookup_symbol so that we can + look up symbols irrespective of the domain, matching the + iterator. It would be confusing if the iterator returns symbols + you can't find via getitem. */ + for (struct symbol *sym : block_iterator_range (block, &lookup_name)) { /* Just stop at the first match */ - break; + return symbol_to_symbol_object (sym); } - if (sym == nullptr) - { - PyErr_SetObject (PyExc_KeyError, key); - return nullptr; - } - return symbol_to_symbol_object (sym); + PyErr_SetObject (PyExc_KeyError, key); + return nullptr; } static void -- cgit v1.1