multidictionary *multidict () const
{ return m_multidict; }
+ /* Return an iterator range for this block's multidict. */
+ iterator_range<mdict_iterator_wrapper> multidict_symbols () const
+ { return iterator_range<mdict_iterator_wrapper> (m_multidict); }
+
/* Set this block's multidict. */
void set_multidict (multidictionary *multidict)
{ m_multidict = multidict; }
if (symbol)
{
struct type *ftype = symbol->type ();
- struct mdict_iterator miter;
symbol->set_value_block (block);
symbol->set_section_index (SECT_OFF_TEXT (m_objfile));
block->set_function (symbol);
function's type. Set that from the type of the
parameter symbols. */
int nparams = 0, iparams;
- struct symbol *sym;
/* Here we want to directly access the dictionary, because
we haven't fully initialized the block yet. */
- ALL_DICT_SYMBOLS (block->multidict (), miter, sym)
+ for (struct symbol *sym : block->multidict_symbols ())
{
if (sym->is_argument ())
nparams++;
iparams = 0;
/* Here we want to directly access the dictionary, because
we haven't fully initialized the block yet. */
- ALL_DICT_SYMBOLS (block->multidict (), miter, sym)
+ for (struct symbol *sym : block->multidict_symbols ())
{
if (iparams == nparams)
break;
for (block_i = 0; block_i < blockvector->num_blocks (); block_i++)
{
struct block *block = blockvector->block (block_i);
- struct symbol *sym;
- struct mdict_iterator miter;
/* Inlined functions may have symbols not in the global or
static symbol lists. */
block->function ()->set_symtab (symtab);
/* Note that we only want to fix up symbols from the local
- blocks, not blocks coming from included symtabs. That is why
- we use ALL_DICT_SYMBOLS here and not a block iterator. */
- ALL_DICT_SYMBOLS (block->multidict (), miter, sym)
+ blocks, not blocks coming from included symtabs. That is
+ why we use an mdict iterator here and not a block
+ iterator. */
+ for (struct symbol *sym : block->multidict_symbols ())
if (sym->symtab () == NULL)
sym->set_symtab (symtab);
}
extern int mdict_size (const struct multidictionary *mdict);
-/* Macro to loop through all symbols in a dictionary DICT, in no
- particular order. ITER is a struct dict_iterator (NOTE: __not__ a
- struct dict_iterator *), and SYM points to the current symbol.
-
- It's implemented as a single loop, so you can terminate the loop
- early by a break if you desire. */
-
-#define ALL_DICT_SYMBOLS(dict, iter, sym) \
- for ((sym) = mdict_iterator_first ((dict), &(iter)); \
- (sym); \
- (sym) = mdict_iterator_next (&(iter)))
+/* An iterator that wraps an mdict_iterator. The naming here is
+ unfortunate, but mdict_iterator was named before gdb switched to
+ C++. */
+struct mdict_iterator_wrapper
+{
+ typedef mdict_iterator_wrapper self_type;
+ typedef struct symbol *value_type;
+
+ explicit mdict_iterator_wrapper (const struct multidictionary *mdict)
+ : m_sym (mdict_iterator_first (mdict, &m_iter))
+ {
+ }
+
+ mdict_iterator_wrapper ()
+ : m_sym (nullptr)
+ {
+ }
+
+ value_type operator* () const
+ {
+ return m_sym;
+ }
+
+ bool operator== (const self_type &other) const
+ {
+ return m_sym == other.m_sym;
+ }
+
+ bool operator!= (const self_type &other) const
+ {
+ return m_sym != other.m_sym;
+ }
+
+ self_type &operator++ ()
+ {
+ m_sym = mdict_iterator_next (&m_iter);
+ return *this;
+ }
+
+private:
+
+ struct symbol *m_sym;
+ struct mdict_iterator m_iter;
+};
#endif /* DICTIONARY_H */
for (block *b : bv->blocks ())
{
- struct symbol *sym;
- struct mdict_iterator miter;
-
b->set_start (b->start () + delta[block_line_section]);
b->set_end (b->end () + delta[block_line_section]);
/* We only want to iterate over the local symbols, not any
symbols in included symtabs. */
- ALL_DICT_SYMBOLS (b->multidict (), miter, sym)
- {
- relocate_one_symbol (sym, objfile, delta);
- }
+ for (struct symbol *sym : b->multidict_symbols ())
+ relocate_one_symbol (sym, objfile, delta);
}
}
{
struct objfile *objfile = symtab->compunit ()->objfile ();
struct gdbarch *gdbarch = objfile->arch ();
- struct mdict_iterator miter;
const struct linetable *l;
- struct symbol *sym;
int depth;
gdb_printf (outfile, "\nSymtab for file %s at %s\n",
/* Now print each symbol in this block (in no particular order, if
we're using a hashtable). Note that we only want this
block, not any blocks from included symtabs. */
- ALL_DICT_SYMBOLS (b->multidict (), miter, sym)
+ for (struct symbol *sym : b->multidict_symbols ())
{
try
{