diff options
author | Tom Tromey <tom@tromey.com> | 2023-01-19 18:41:21 -0700 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2023-02-19 12:51:06 -0700 |
commit | 81326ac076332230286e23d69978cc2698d004b9 (patch) | |
tree | c3120542cfdd4f6d797ddc145930db077076635c /gdb/block.c | |
parent | 0688bf443c618be0a4a22cbc7ffb802dd771801c (diff) | |
download | gdb-81326ac076332230286e23d69978cc2698d004b9.zip gdb-81326ac076332230286e23d69978cc2698d004b9.tar.gz gdb-81326ac076332230286e23d69978cc2698d004b9.tar.bz2 |
Combine both styles of block iterator
This merges the two styles of block iterator, having the
initialization API decide which to use based on an optional parameter.
Diffstat (limited to 'gdb/block.c')
-rw-r--r-- | gdb/block.c | 54 |
1 files changed, 22 insertions, 32 deletions
diff --git a/gdb/block.c b/gdb/block.c index e56c950..e7a51af 100644 --- a/gdb/block.c +++ b/gdb/block.c @@ -556,31 +556,6 @@ block_iterator_step (struct block_iterator *iterator, int first) } } -/* See block.h. */ - -struct symbol * -block_iterator_first (const struct block *block, - struct block_iterator *iterator) -{ - initialize_block_iterator (block, iterator); - - if (iterator->which == FIRST_LOCAL_BLOCK) - return mdict_iterator_first (block->multidict (), &iterator->mdict_iter); - - return block_iterator_step (iterator, 1); -} - -/* See block.h. */ - -struct symbol * -block_iterator_next (struct block_iterator *iterator) -{ - if (iterator->which == FIRST_LOCAL_BLOCK) - return mdict_iterator_next (&iterator->mdict_iter); - - return block_iterator_step (iterator, 0); -} - /* Perform a single step for a "match" block iterator, iterating across symbol tables as needed. Returns the next symbol, or NULL when iteration is complete. */ @@ -626,14 +601,23 @@ block_iter_match_step (struct block_iterator *iterator, /* See block.h. */ struct symbol * -block_iter_match_first (const struct block *block, - const lookup_name_info &name, - struct block_iterator *iterator) +block_iterator_first (const struct block *block, + struct block_iterator *iterator, + const lookup_name_info *name) { - initialize_block_iterator (block, iterator, &name); + initialize_block_iterator (block, iterator, name); + + if (name == nullptr) + { + if (iterator->which == FIRST_LOCAL_BLOCK) + return mdict_iterator_first (block->multidict (), + &iterator->mdict_iter); + + return block_iterator_step (iterator, 1); + } if (iterator->which == FIRST_LOCAL_BLOCK) - return mdict_iter_match_first (block->multidict (), name, + return mdict_iter_match_first (block->multidict (), *name, &iterator->mdict_iter); return block_iter_match_step (iterator, 1); @@ -642,9 +626,15 @@ block_iter_match_first (const struct block *block, /* See block.h. */ struct symbol * -block_iter_match_next (struct block_iterator *iterator) +block_iterator_next (struct block_iterator *iterator) { - gdb_assert (iterator->name != nullptr); + if (iterator->name == nullptr) + { + if (iterator->which == FIRST_LOCAL_BLOCK) + return mdict_iterator_next (&iterator->mdict_iter); + + return block_iterator_step (iterator, 0); + } if (iterator->which == FIRST_LOCAL_BLOCK) return mdict_iter_match_next (*iterator->name, &iterator->mdict_iter); |