mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-06-19 00:59:15 +08:00
Store 'name' in block_iterator
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.
This commit is contained in:
@ -6081,7 +6081,7 @@ ada_add_block_symbols (std::vector<struct block_symbol> &result,
|
|||||||
found_sym = false;
|
found_sym = false;
|
||||||
for (sym = block_iter_match_first (block, lookup_name, &iter);
|
for (sym = block_iter_match_first (block, lookup_name, &iter);
|
||||||
sym != NULL;
|
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))
|
if (symbol_matches_domain (sym->language (), sym->domain (), domain))
|
||||||
{
|
{
|
||||||
|
24
gdb/block.c
24
gdb/block.c
@ -453,12 +453,14 @@ get_block_compunit_symtab (const struct block *block)
|
|||||||
|
|
||||||
static void
|
static void
|
||||||
initialize_block_iterator (const struct block *block,
|
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;
|
enum block_enum which;
|
||||||
struct compunit_symtab *cu;
|
struct compunit_symtab *cu;
|
||||||
|
|
||||||
iter->idx = -1;
|
iter->idx = -1;
|
||||||
|
iter->name = name;
|
||||||
|
|
||||||
if (block->superblock () == NULL)
|
if (block->superblock () == NULL)
|
||||||
{
|
{
|
||||||
@ -585,7 +587,6 @@ block_iterator_next (struct block_iterator *iterator)
|
|||||||
|
|
||||||
static struct symbol *
|
static struct symbol *
|
||||||
block_iter_match_step (struct block_iterator *iterator,
|
block_iter_match_step (struct block_iterator *iterator,
|
||||||
const lookup_name_info &name,
|
|
||||||
int first)
|
int first)
|
||||||
{
|
{
|
||||||
struct symbol *sym;
|
struct symbol *sym;
|
||||||
@ -605,11 +606,11 @@ block_iter_match_step (struct block_iterator *iterator,
|
|||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
block = cust->blockvector ()->block (iterator->which);
|
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);
|
&iterator->mdict_iter);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
sym = mdict_iter_match_next (name, &iterator->mdict_iter);
|
sym = mdict_iter_match_next (*iterator->name, &iterator->mdict_iter);
|
||||||
|
|
||||||
if (sym != NULL)
|
if (sym != NULL)
|
||||||
return sym;
|
return sym;
|
||||||
@ -629,25 +630,26 @@ block_iter_match_first (const struct block *block,
|
|||||||
const lookup_name_info &name,
|
const lookup_name_info &name,
|
||||||
struct block_iterator *iterator)
|
struct block_iterator *iterator)
|
||||||
{
|
{
|
||||||
initialize_block_iterator (block, iterator);
|
initialize_block_iterator (block, iterator, &name);
|
||||||
|
|
||||||
if (iterator->which == FIRST_LOCAL_BLOCK)
|
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);
|
&iterator->mdict_iter);
|
||||||
|
|
||||||
return block_iter_match_step (iterator, name, 1);
|
return block_iter_match_step (iterator, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* See block.h. */
|
/* See block.h. */
|
||||||
|
|
||||||
struct symbol *
|
struct symbol *
|
||||||
block_iter_match_next (const lookup_name_info &name,
|
block_iter_match_next (struct block_iterator *iterator)
|
||||||
struct block_iterator *iterator)
|
|
||||||
{
|
{
|
||||||
if (iterator->which == FIRST_LOCAL_BLOCK)
|
gdb_assert (iterator->name != nullptr);
|
||||||
return mdict_iter_match_next (name, &iterator->mdict_iter);
|
|
||||||
|
|
||||||
return block_iter_match_step (iterator, name, 0);
|
if (iterator->which == FIRST_LOCAL_BLOCK)
|
||||||
|
return mdict_iter_match_next (*iterator->name, &iterator->mdict_iter);
|
||||||
|
|
||||||
|
return block_iter_match_step (iterator, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* See block.h. */
|
/* See block.h. */
|
||||||
|
10
gdb/block.h
10
gdb/block.h
@ -449,6 +449,9 @@ struct block_iterator
|
|||||||
const struct block *block;
|
const struct block *block;
|
||||||
} d;
|
} 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.
|
/* If we're iterating over a single block, this is always -1.
|
||||||
Otherwise, it holds the index of the current "included" symtab in
|
Otherwise, it holds the index of the current "included" symtab in
|
||||||
the canonical symtab (that is, d.symtab->includes[idx]), with -1
|
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
|
symbols. Don't call this if you've previously received NULL from
|
||||||
block_iterator_match_first or block_iterator_match_next on this
|
block_iterator_match_first or block_iterator_match_next on this
|
||||||
iteration. And don't call it unless ITERATOR was created by a
|
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
|
extern struct symbol *block_iter_match_next (struct block_iterator *iterator);
|
||||||
(const lookup_name_info &name, struct block_iterator *iterator);
|
|
||||||
|
|
||||||
/* Return true if symbol A is the best match possible for DOMAIN. */
|
/* 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) \
|
#define ALL_BLOCK_SYMBOLS_WITH_NAME(block, name, iter, sym) \
|
||||||
for ((sym) = block_iter_match_first ((block), (name), &(iter)); \
|
for ((sym) = block_iter_match_first ((block), (name), &(iter)); \
|
||||||
(sym) != NULL; \
|
(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
|
/* Given a vector of pairs, allocate and build an obstack allocated
|
||||||
blockranges struct for a block. */
|
blockranges struct for a block. */
|
||||||
|
Reference in New Issue
Block a user