+2012-05-10 Tom Tromey <tromey@redhat.com>
+
+ * tracepoint.c (scope_info): Update.
+ * symtab.c (lookup_block_symbol, iterate_over_symbols)
+ (find_pc_sect_symtab, search_symbols)
+ (default_make_symbol_completion_list_break_on)
+ (make_file_symbol_completion_list): Update.
+ * symmisc.c (dump_symtab_1): Update.
+ * stack.c (print_frame_args, iterate_over_block_locals)
+ (print_frame_labels, iterate_over_block_arg_vars): Update.
+ * python/py-block.c (block_object) <dict>: Remove.
+ <block>: New field.
+ <iter>: Change type.
+ (blpy_iter): Update.
+ (blpy_block_syms_iternext): Update.
+ * psymtab.c (map_block): Use block iterators.
+ * objfiles.c (objfile_relocate1): Use ALL_DICT_SYMBOLS.
+ * mi/mi-cmd-stack.c (list_args_or_locals): Update.
+ * mdebugread.c (parse_symbol, mylookup_symbol): Update.
+ * infrun.c (check_exception_resume): Update.
+ * cp-support.c (make_symbol_overload_list_block): Update.
+ * coffread.c (patch_opaque_types): Update.
+ * buildsym.c (finish_block, end_symtab): Use ALL_DICT_SYMBOLS.
+ * block.h (struct block_iterator): New.
+ (block_iterator_first, block_iterator_next, block_iter_name_first)
+ (block_iter_name_next, block_iter_match_first)
+ (block_iter_match_next): Declare.
+ (ALL_BLOCK_SYMBOLS): Redefine.
+ * block.c (block_iterator_first, block_iterator_next)
+ (block_iter_name_first, block_iter_name_next)
+ (block_iter_match_first, block_iter_match_next): New functions.
+ * ada-lang.c (ada_add_block_symbols)
+ (ada_make_symbol_completion_list): Use block iterator.
+
2012-05-10 Tom Tromey <tromey@redhat.com>
* psymtab.c (PSYMTAB_TO_SYMTAB): Remove.
domain_enum domain, struct objfile *objfile,
int wild)
{
- struct dict_iterator iter;
+ struct block_iterator iter;
int name_len = strlen (name);
/* A matching argument symbol, if any. */
struct symbol *arg_sym;
found_sym = 0;
if (wild)
{
- for (sym = dict_iter_match_first (BLOCK_DICT (block), name,
- wild_match, &iter);
- sym != NULL; sym = dict_iter_match_next (name, wild_match, &iter))
+ for (sym = block_iter_match_first (block, name, wild_match, &iter);
+ sym != NULL; sym = block_iter_match_next (name, wild_match, &iter))
{
if (symbol_matches_domain (SYMBOL_LANGUAGE (sym),
SYMBOL_DOMAIN (sym), domain)
}
else
{
- for (sym = dict_iter_match_first (BLOCK_DICT (block), name,
- full_match, &iter);
- sym != NULL; sym = dict_iter_match_next (name, full_match, &iter))
+ for (sym = block_iter_match_first (block, name, full_match, &iter);
+ sym != NULL; sym = block_iter_match_next (name, full_match, &iter))
{
if (symbol_matches_domain (SYMBOL_LANGUAGE (sym),
SYMBOL_DOMAIN (sym), domain))
struct objfile *objfile;
struct block *b, *surrounding_static_block = 0;
int i;
- struct dict_iterator iter;
+ struct block_iterator iter;
if (text0[0] == '<')
{
return bl;
}
+
+\f
+
+/* See block.h. */
+
+struct symbol *
+block_iterator_first (const struct block *block,
+ struct block_iterator *iterator)
+{
+ return dict_iterator_first (block->dict, &iterator->dict_iter);
+}
+
+/* See block.h. */
+
+struct symbol *
+block_iterator_next (struct block_iterator *iterator)
+{
+ return dict_iterator_next (&iterator->dict_iter);
+}
+
+/* See block.h. */
+
+struct symbol *
+block_iter_name_first (const struct block *block,
+ const char *name,
+ struct block_iterator *iterator)
+{
+ return dict_iter_name_first (block->dict, name, &iterator->dict_iter);
+}
+
+/* See block.h. */
+
+struct symbol *
+block_iter_name_next (const char *name, struct block_iterator *iterator)
+{
+ return dict_iter_name_next (name, &iterator->dict_iter);
+}
+
+/* See block.h. */
+
+struct symbol *
+block_iter_match_first (const struct block *block,
+ const char *name,
+ symbol_compare_ftype *compare,
+ struct block_iterator *iterator)
+{
+ return dict_iter_match_first (block->dict, name, compare,
+ &iterator->dict_iter);
+}
+
+/* See block.h. */
+
+struct symbol *
+block_iter_match_next (const char *name,
+ symbol_compare_ftype *compare,
+ struct block_iterator *iterator)
+{
+ return dict_iter_match_next (name, compare, &iterator->dict_iter);
+}
#ifndef BLOCK_H
#define BLOCK_H
+#include "dictionary.h"
+
/* Opaque declarations. */
struct symbol;
struct block_namespace_info;
struct using_direct;
struct obstack;
-struct dictionary;
struct addrmap;
/* All of the name-scope contours of the program
#define BLOCK_DICT(bl) (bl)->dict
#define BLOCK_NAMESPACE(bl) (bl)->language_specific.cplus_specific.namespace
-/* Macro to loop through all symbols in a block BL, in no particular
- order. ITER helps keep track of the iteration, and should be a
- struct dict_iterator. SYM points to the current symbol. */
-
-#define ALL_BLOCK_SYMBOLS(block, iter, sym) \
- ALL_DICT_SYMBOLS (BLOCK_DICT (block), iter, sym)
-
struct blockvector
{
/* Number of blocks in the list. */
extern struct block *allocate_block (struct obstack *obstack);
+
+/* A block iterator. This structure should be treated as though it
+ were opaque; it is only defined here because we want to support
+ stack allocation of iterators. */
+
+struct block_iterator
+{
+ /* The underlying dictionary iterator. */
+
+ struct dict_iterator dict_iter;
+};
+
+/* Initialize ITERATOR to point at the first symbol in BLOCK, and
+ return that first symbol, or NULL if BLOCK is empty. */
+
+extern struct symbol *block_iterator_first (const struct block *block,
+ struct block_iterator *iterator);
+
+/* Advance ITERATOR, and return the next symbol, or NULL if there are
+ no more symbols. Don't call this if you've previously received
+ NULL from block_iterator_first or block_iterator_next on this
+ iteration. */
+
+extern struct symbol *block_iterator_next (struct block_iterator *iterator);
+
+/* Initialize ITERATOR to point at the first symbol in BLOCK whose
+ SYMBOL_SEARCH_NAME is NAME (as tested using strcmp_iw), and return
+ that first symbol, or NULL if there are no such symbols. */
+
+extern struct symbol *block_iter_name_first (const struct block *block,
+ const char *name,
+ struct block_iterator *iterator);
+
+/* Advance ITERATOR to point at the next symbol in BLOCK whose
+ SYMBOL_SEARCH_NAME is NAME (as tested using strcmp_iw), or NULL if
+ there are no more such symbols. Don't call this if you've
+ previously received NULL from block_iterator_first or
+ block_iterator_next on this iteration. And don't call it unless
+ ITERATOR was created by a previous call to block_iter_name_first
+ with the same NAME. */
+
+extern struct symbol *block_iter_name_next (const char *name,
+ struct block_iterator *iterator);
+
+/* Initialize ITERATOR to point at the first symbol in BLOCK whose
+ SYMBOL_SEARCH_NAME is NAME, as tested using COMPARE (which must use
+ the same conventions as strcmp_iw and be compatible with any
+ block hashing function), and return that first symbol, or NULL
+ if there are no such symbols. */
+
+extern struct symbol *block_iter_match_first (const struct block *block,
+ const char *name,
+ symbol_compare_ftype *compare,
+ struct block_iterator *iterator);
+
+/* Advance ITERATOR to point at the next symbol in BLOCK whose
+ SYMBOL_SEARCH_NAME is NAME, as tested using COMPARE (see
+ block_iter_match_first), or NULL if there are no more such symbols.
+ Don't call this if you've previously received NULL from
+ block_iterator_match_first or block_iterator_match_next on this
+ iteration. And don't call it unless ITERATOR was created by a
+ previous call to block_iter_match_first with the same NAME and COMPARE. */
+
+extern struct symbol *block_iter_match_next (const char *name,
+ symbol_compare_ftype *compare,
+ struct block_iterator *iterator);
+
+/* Macro to loop through all symbols in a block BL, in no particular
+ order. ITER helps keep track of the iteration, and should be a
+ struct block_iterator. SYM points to the current symbol. */
+
+#define ALL_BLOCK_SYMBOLS(block, iter, sym) \
+ for ((sym) = block_iterator_first ((block), &(iter)); \
+ (sym); \
+ (sym) = block_iterator_next (&(iter)))
+
#endif /* BLOCK_H */
parameter symbols. */
int nparams = 0, iparams;
struct symbol *sym;
- ALL_BLOCK_SYMBOLS (block, iter, sym)
+
+ /* Here we want to directly access the dictionary, because
+ we haven't fully initialized the block yet. */
+ ALL_DICT_SYMBOLS (BLOCK_DICT (block), iter, sym)
{
if (SYMBOL_IS_ARGUMENT (sym))
nparams++;
TYPE_ALLOC (ftype, nparams * sizeof (struct field));
iparams = 0;
- ALL_BLOCK_SYMBOLS (block, iter, sym)
+ /* Here we want to directly access the dictionary, because
+ we haven't fully initialized the block yet. */
+ ALL_DICT_SYMBOLS (BLOCK_DICT (block), iter, sym)
{
if (iparams == nparams)
break;
if (SYMBOL_SYMTAB (BLOCK_FUNCTION (block)) == NULL)
SYMBOL_SYMTAB (BLOCK_FUNCTION (block)) = symtab;
- for (sym = dict_iterator_first (BLOCK_DICT (block), &iter);
- sym != NULL;
- sym = dict_iterator_next (&iter))
+ /* Note that we only want to fix up symbols from the local
+ blocks, not blocks coming from included symtabs. */
+ ALL_DICT_SYMBOLS (BLOCK_DICT (block), iter, sym)
if (SYMBOL_SYMTAB (sym) == NULL)
SYMBOL_SYMTAB (sym) = symtab;
}
patch_opaque_types (struct symtab *s)
{
struct block *b;
- struct dict_iterator iter;
+ struct block_iterator iter;
struct symbol *real_sym;
/* Go through the per-file symbols only. */
make_symbol_overload_list_block (const char *name,
const struct block *block)
{
- struct dict_iterator iter;
+ struct block_iterator iter;
struct symbol *sym;
- const struct dictionary *dict = BLOCK_DICT (block);
-
- for (sym = dict_iter_name_first (dict, name, &iter);
+ for (sym = block_iter_name_first (block, name, &iter);
sym != NULL;
- sym = dict_iter_name_next (name, &iter))
+ sym = block_iter_name_next (name, &iter))
overload_list_add_symbol (sym, name);
}
TRY_CATCH (e, RETURN_MASK_ERROR)
{
struct block *b;
- struct dict_iterator iter;
+ struct block_iterator iter;
struct symbol *sym;
int argno = 0;
if (nparams > 0)
{
- struct dict_iterator iter;
+ struct block_iterator iter;
TYPE_NFIELDS (ftype) = nparams;
TYPE_FIELDS (ftype) = (struct field *)
mylookup_symbol (char *name, struct block *block,
domain_enum domain, enum address_class class)
{
- struct dict_iterator iter;
+ struct block_iterator iter;
int inc;
struct symbol *sym;
{
struct block *block;
struct symbol *sym;
- struct dict_iterator iter;
+ struct block_iterator iter;
struct cleanup *cleanup_list;
struct type *type;
char *name_of_result;
BLOCK_START (b) += ANOFFSET (delta, s->block_line_section);
BLOCK_END (b) += ANOFFSET (delta, s->block_line_section);
- ALL_BLOCK_SYMBOLS (b, iter, sym)
+ /* We only want to iterate over the local symbols, not any
+ symbols in included symtabs. */
+ ALL_DICT_SYMBOLS (BLOCK_DICT (b), iter, sym)
{
relocate_one_symbol (sym, objfile, delta);
}
int (*callback) (struct block *, struct symbol *, void *),
void *data, symbol_compare_ftype *match)
{
- struct dict_iterator iter;
+ struct block_iterator iter;
struct symbol *sym;
- for (sym = dict_iter_match_first (BLOCK_DICT (block), name, match, &iter);
- sym != NULL; sym = dict_iter_match_next (name, match, &iter))
+ for (sym = block_iter_match_first (block, name, match, &iter);
+ sym != NULL; sym = block_iter_match_next (name, match, &iter))
{
if (symbol_matches_domain (SYMBOL_LANGUAGE (sym),
SYMBOL_DOMAIN (sym), namespace))
typedef struct {
PyObject_HEAD
- /* The block dictionary of symbols. */
- struct dictionary *dict;
- /* The iterator for that dictionary. */
- struct dict_iterator iter;
+ /* The block. */
+ const struct block *block;
+ /* The iterator for that block. */
+ struct block_iterator iter;
/* Has the iterator been initialized flag. */
int initialized_p;
/* Pointer back to the original source block object. Needed to
if (block_iter_obj == NULL)
return NULL;
- block_iter_obj->dict = BLOCK_DICT (block);
+ block_iter_obj->block = block;
block_iter_obj->initialized_p = 0;
Py_INCREF (self);
block_iter_obj->source = (block_object *) self;
if (!iter_obj->initialized_p)
{
- sym = dict_iterator_first (iter_obj->dict, &(iter_obj->iter));
+ sym = block_iterator_first (iter_obj->block, &(iter_obj->iter));
iter_obj->initialized_p = 1;
}
else
- sym = dict_iterator_next (&(iter_obj->iter));
+ sym = block_iterator_next (&(iter_obj->iter));
if (sym == NULL)
{
if (func)
{
struct block *b = SYMBOL_BLOCK_VALUE (func);
- struct dict_iterator iter;
+ struct block_iterator iter;
struct symbol *sym;
ALL_BLOCK_SYMBOLS (b, iter, sym)
iterate_over_block_arg_local_vars_cb cb,
void *cb_data)
{
- struct dict_iterator iter;
+ struct block_iterator iter;
struct symbol *sym;
ALL_BLOCK_SYMBOLS (b, iter, sym)
print_block_frame_labels (struct gdbarch *gdbarch, struct block *b,
int *have_default, struct ui_file *stream)
{
- struct dict_iterator iter;
+ struct block_iterator iter;
struct symbol *sym;
int values_printed = 0;
iterate_over_block_arg_local_vars_cb cb,
void *cb_data)
{
- struct dict_iterator iter;
+ struct block_iterator iter;
struct symbol *sym, *sym2;
ALL_BLOCK_SYMBOLS (b, iter, sym)
}
fprintf_filtered (outfile, "\n");
/* Now print each symbol in this block (in no particular order, if
- we're using a hashtable). */
- ALL_BLOCK_SYMBOLS (b, iter, sym)
+ we're using a hashtable). Note that we only want this
+ block, not any blocks from included symtabs. */
+ ALL_DICT_SYMBOLS (BLOCK_DICT (b), iter, sym)
{
struct print_symbol_args s;
lookup_block_symbol (const struct block *block, const char *name,
const domain_enum domain)
{
- struct dict_iterator iter;
+ struct block_iterator iter;
struct symbol *sym;
if (!BLOCK_FUNCTION (block))
{
- for (sym = dict_iter_name_first (BLOCK_DICT (block), name, &iter);
+ for (sym = block_iter_name_first (block, name, &iter);
sym != NULL;
- sym = dict_iter_name_next (name, &iter))
+ sym = block_iter_name_next (name, &iter))
{
if (symbol_matches_domain (SYMBOL_LANGUAGE (sym),
SYMBOL_DOMAIN (sym), domain))
struct symbol *sym_found = NULL;
- for (sym = dict_iter_name_first (BLOCK_DICT (block), name, &iter);
+ for (sym = block_iter_name_first (block, name, &iter);
sym != NULL;
- sym = dict_iter_name_next (name, &iter))
+ sym = block_iter_name_next (name, &iter))
{
if (symbol_matches_domain (SYMBOL_LANGUAGE (sym),
SYMBOL_DOMAIN (sym), domain))
{
while (block)
{
- struct dict_iterator iter;
+ struct block_iterator iter;
struct symbol *sym;
- for (sym = dict_iter_name_first (BLOCK_DICT (block), name, &iter);
+ for (sym = block_iter_name_first (block, name, &iter);
sym != NULL;
- sym = dict_iter_name_next (name, &iter))
+ sym = block_iter_name_next (name, &iter))
{
if (symbol_matches_domain (SYMBOL_LANGUAGE (sym),
SYMBOL_DOMAIN (sym), domain))
}
if (section != 0)
{
- struct dict_iterator iter;
+ struct block_iterator iter;
struct symbol *sym = NULL;
ALL_BLOCK_SYMBOLS (b, iter, sym)
struct blockvector *bv;
struct block *b;
int i = 0;
- struct dict_iterator iter;
+ struct block_iterator iter;
struct symbol *sym;
struct objfile *objfile;
struct minimal_symbol *msymbol;
struct objfile *objfile;
struct block *b;
const struct block *surrounding_static_block, *surrounding_global_block;
- struct dict_iterator iter;
+ struct block_iterator iter;
/* The symbol we are completing on. Points in same buffer as text. */
char *sym_text;
/* Length of sym_text. */
struct symbol *sym;
struct symtab *s;
struct block *b;
- struct dict_iterator iter;
+ struct block_iterator iter;
/* The symbol we are completing on. Points in same buffer as text. */
char *sym_text;
/* Length of sym_text. */
struct block *block;
const char *symname;
char *save_args = args;
- struct dict_iterator iter;
+ struct block_iterator iter;
int j, count = 0;
struct gdbarch *gdbarch;
int regno;