* dictionary.c (struct dict_vtbl): 'add_symbol' field.
(add_symbol_generic): New function.
(free_obstack): New function.
(dict_create_hashed): New function.
(lookup_hashed): New function.
(iterator_first_hashed): New function.
(iterator_hashed_advance): New function.
(iterator_next_hashed): New function.
* dictionary.h: A few more declarations.
* mdebugread.c (parse_symbol): Use dict_iterator when finding
parameters.
* Makefile.in (valops.o): Depend on dictionary_h.
* valops.c (value_of_this): Check empty block via dict_empty.
#include "dictionary.h"
* symfile.c (free_named_symtabs): Check empty block via dict_empty.
* dictionary.h: Declare dict_empty.
* symmisc.c (dump_symtab): Don't print out number of
symbols/buckets.
* printcmd.c (print_frame_args): Delete assertion that block isn't
a hashtable.
* symmisc.c (free_symtab_block): Update to use dictionary
methods.
* symtab.h (struct symtab): Comment on free_contents.
* jv-lang.c (get_java_class_symtab): Set class_symtab->free_code.
* mdebugread.c (add_symbol): Delete 'nsyms' variable.
(fixup_sigtramp): Add symbol via dict_add_symbol_block.
* Makefile.in (mi-cmd-stack.o): Depend on dictionary_h.
* ada-lang.c (symtab_for_sym): Update uses of ALL_BLOCK_SYMBOLS.
(ada_add_block_symbols): Ditto.
(debug_print_block): Ditto.
(fill_in_ada_prototype): Ditto.
* breakpoint.c (get_catch_sals): Ditto.
* coffread.c (patch_opaque_types): Ditto.
* tracepoint.c (add_local_symbols): Ditto.
(scope_info): Ditto.
* symtab.c (find_pc_sect_symtab): Ditto.
(search_symbols): Ditto.
(make_symbol_completion_list): Ditto.
(find_addr_symbol): Ditto.
(make_file_symbol_completion_list): Ditto.
(make_symbol_overload_list): Ditto.
* symmisc.c (dump_symtab): Ditto.
* stack.c (print_block_frame_locals): Ditto.
(print_block_frame_labels): Ditto.
(print_frame_arg_vars): Ditto.
* printcmd.c (print_frame_args): Ditto.
* objfiles.c (objfile_relocate): Ditto.
* mdebugread.c (mylookup_symbol): Ditto.
* Makefile.in (ada-lang.o): Depend on dictionary_h.
* Makefile.in (tracepoint.o): Ditto.
* Makefile.in (symmisc.o): Ditto.
* Makefile.in (stack.o): Ditto.
* Makefile.in (printcmd.o): Ditto.
* Makefile.in (objfiles.o): Ditto.
* Makefile.in (coffread.o): Ditto.
* Makefile.in (breakpoint.o): Ditto.
* ada-lang.c: #include "dictionary.h"
* tracepoint.c: Ditto.
* symmisc.c: Ditto.
* stack.c: Ditto.
* printcmd.c: Ditto.
* objfiles.c: Ditto.
* coffread.c: Ditto.
* breakpoint.c: Ditto.
* symtab.h: Comment out ALL_BLOCK_SYMBOLS. (Moved to
dictionary.h.)
* dictionary.c: Dict_iterator accessor macros.
(struct dict_vtbl): Add iterator_first, iterator_next.
(dict_iterator_first): New function.
(dict_iterator_next): New function.
(iterator_first_block): New function.
(iterator_next_block): New function.
(iterator_block_hashed_advance): New function.
* dictionary.h: Add dict_iterator stuff.
* Makefile.in (symtab.o): Depend on dictionary_h.
* symtab.c: #include "dictionary.h"
* dictionary.c: Move down #include "dictionary.h", for now...
(free_block): Rename from dict_free_block.
(struct dict_vtbl): Add LOOKUP member.
(dict_lookup): New function.
(lookup_block): New function.
* dictionary.h: Declare dict_lookup.
* symtab.c (lookup_block_symbol): Use dict_lookup.
2002-09-23 David Carlton <carlton@math.stanford.edu>
* mi-cmd-stack.c (list_args_or_locals): Update use of
ALL_BLOCK_SYMBOLS.
#include "dictionary.h"
+2002-09-23 David Carlton <carlton@math.stanford.edu>
+
+ * dictionary.c (struct dict_vtbl): 'add_symbol' field.
+ (add_symbol_generic): New function.
+ (free_obstack): New function.
+ (dict_create_hashed): New function.
+ (lookup_hashed): New function.
+ (iterator_first_hashed): New function.
+ (iterator_hashed_advance): New function.
+ (iterator_next_hashed): New function.
+ * dictionary.h: A few more declarations.
+ * mdebugread.c (parse_symbol): Use dict_iterator when finding
+ parameters.
+ * Makefile.in (valops.o): Depend on dictionary_h.
+ * valops.c (value_of_this): Check empty block via dict_empty.
+ #include "dictionary.h"
+ * symfile.c (free_named_symtabs): Check empty block via dict_empty.
+ * dictionary.h: Declare dict_empty.
+ * symmisc.c (dump_symtab): Don't print out number of
+ symbols/buckets.
+ * printcmd.c (print_frame_args): Delete assertion that block isn't
+ a hashtable.
+ * symmisc.c (free_symtab_block): Update to use dictionary
+ methods.
+ * symtab.h (struct symtab): Comment on free_contents.
+ * jv-lang.c (get_java_class_symtab): Set class_symtab->free_code.
+ * mdebugread.c (add_symbol): Delete 'nsyms' variable.
+ (fixup_sigtramp): Add symbol via dict_add_symbol_block.
+ * Makefile.in (mi-cmd-stack.o): Depend on dictionary_h.
+ * ada-lang.c (symtab_for_sym): Update uses of ALL_BLOCK_SYMBOLS.
+ (ada_add_block_symbols): Ditto.
+ (debug_print_block): Ditto.
+ (fill_in_ada_prototype): Ditto.
+ * breakpoint.c (get_catch_sals): Ditto.
+ * coffread.c (patch_opaque_types): Ditto.
+ * tracepoint.c (add_local_symbols): Ditto.
+ (scope_info): Ditto.
+ * symtab.c (find_pc_sect_symtab): Ditto.
+ (search_symbols): Ditto.
+ (make_symbol_completion_list): Ditto.
+ (find_addr_symbol): Ditto.
+ (make_file_symbol_completion_list): Ditto.
+ (make_symbol_overload_list): Ditto.
+ * symmisc.c (dump_symtab): Ditto.
+ * stack.c (print_block_frame_locals): Ditto.
+ (print_block_frame_labels): Ditto.
+ (print_frame_arg_vars): Ditto.
+ * printcmd.c (print_frame_args): Ditto.
+ * objfiles.c (objfile_relocate): Ditto.
+ * mdebugread.c (mylookup_symbol): Ditto.
+ * Makefile.in (ada-lang.o): Depend on dictionary_h.
+ * Makefile.in (tracepoint.o): Ditto.
+ * Makefile.in (symmisc.o): Ditto.
+ * Makefile.in (stack.o): Ditto.
+ * Makefile.in (printcmd.o): Ditto.
+ * Makefile.in (objfiles.o): Ditto.
+ * Makefile.in (coffread.o): Ditto.
+ * Makefile.in (breakpoint.o): Ditto.
+ * ada-lang.c: #include "dictionary.h"
+ * tracepoint.c: Ditto.
+ * symmisc.c: Ditto.
+ * stack.c: Ditto.
+ * printcmd.c: Ditto.
+ * objfiles.c: Ditto.
+ * coffread.c: Ditto.
+ * breakpoint.c: Ditto.
+ * symtab.h: Comment out ALL_BLOCK_SYMBOLS. (Moved to
+ dictionary.h.)
+ * dictionary.c: Dict_iterator accessor macros.
+ (struct dict_vtbl): Add iterator_first, iterator_next.
+ (dict_iterator_first): New function.
+ (dict_iterator_next): New function.
+ (iterator_first_block): New function.
+ (iterator_next_block): New function.
+ (iterator_block_hashed_advance): New function.
+ * dictionary.h: Add dict_iterator stuff.
+ * Makefile.in (symtab.o): Depend on dictionary_h.
+ * symtab.c: #include "dictionary.h"
+ * dictionary.c: Move down #include "dictionary.h", for now...
+ (free_block): Rename from dict_free_block.
+ (struct dict_vtbl): Add LOOKUP member.
+ (dict_lookup): New function.
+ (lookup_block): New function.
+ * dictionary.h: Declare dict_lookup.
+ * symtab.c (lookup_block_symbol): Use dict_lookup.
+
2002-09-20 David Carlton <carlton@math.stanford.edu>
* jv-lang.c (get_java_class_symtab): Use xmalloc to allocate
ada-lang.o: ada-lang.c $(gdb_string_h) $(demangle_h) $(defs_h) $(symtab_h) \
$(gdbtypes_h) $(gdbcmd_h) $(expression_h) $(parser_defs_h) \
$(language_h) $(c_lang_h) $(inferior_h) $(symfile_h) $(objfiles_h) \
- $(breakpoint_h) $(gdbcore_h) $(ada_lang_h) $(ui_out_h)
+ $(breakpoint_h) $(gdbcore_h) $(ada_lang_h) $(dictionary_h) $(ui_out_h)
ada-tasks.o: ada-tasks.c $(defs_h) $(command_h) $(value_h) $(language_h) \
$(inferior_h) $(symtab_h) $(target_h) $(gdbcore_h) $(gregset_h) \
$(ada_lang_h)
$(command_h) $(inferior_h) $(gdbthread_h) $(target_h) $(language_h) \
$(gdb_string_h) $(demangle_h) $(annotate_h) $(symfile_h) \
$(objfiles_h) $(linespec_h) $(completer_h) $(gdb_h) $(ui_out_h) \
- $(cli_script_h) $(gdb_events_h) $(source_h)
+ $(cli_script_h) $(gdb_events_h) $(source_h) $(dictionary_h)
buildsym.o: buildsym.c $(defs_h) $(bfd_h) $(gdb_obstack_h) $(symtab_h) \
$(symfile_h) $(objfiles_h) $(gdbtypes_h) $(complaints_h) \
$(gdb_string_h) $(expression_h) $(language_h) $(bcache_h) \
$(breakpoint_h) $(bfd_h) $(gdb_obstack_h) $(gdb_string_h) \
$(coff_internal_h) $(libcoff_h) $(symfile_h) $(objfiles_h) \
$(buildsym_h) $(gdb_stabs_h) $(stabsread_h) $(complaints_h) \
- $(target_h) $(gdb_assert_h)
+ $(target_h) $(gdb_assert_h) $(dictionary_h)
complaints.o: complaints.c $(defs_h) $(complaints_h) $(gdb_assert_h) \
$(command_h) $(gdbcmd_h)
completer.o: completer.c $(defs_h) $(symtab_h) $(gdbtypes_h) $(expression_h) \
ns32knbsd-tdep.o: ns32knbsd-tdep.c $(defs_h) $(ns32k_tdep_h)
objfiles.o: objfiles.c $(defs_h) $(bfd_h) $(symtab_h) $(symfile_h) \
$(objfiles_h) $(gdb_stabs_h) $(target_h) $(bcache_h) $(gdb_stat_h) \
- $(gdb_obstack_h) $(gdb_string_h) $(breakpoint_h) $(mmalloc_h)
+ $(gdb_obstack_h) $(gdb_string_h) $(breakpoint_h) $(mmalloc_h) \
+ $(dictionary_h)
ocd.o: ocd.c $(defs_h) $(gdbcore_h) $(gdb_string_h) $(frame_h) $(inferior_h) \
$(bfd_h) $(symfile_h) $(target_h) $(gdbcmd_h) $(objfiles_h) \
$(gdb_stabs_h) $(serial_h) $(ocd_h) $(regcache_h)
$(gdbtypes_h) $(value_h) $(language_h) $(expression_h) $(gdbcore_h) \
$(gdbcmd_h) $(target_h) $(breakpoint_h) $(demangle_h) $(valprint_h) \
$(annotate_h) $(symfile_h) $(objfiles_h) $(completer_h) $(ui_out_h) \
- $(gdb_assert_h)
+ $(gdb_assert_h) $(dictionary_h)
proc-api.o: proc-api.c $(defs_h) $(gdbcmd_h) $(completer_h) $(proc_utils_h)
proc-events.o: proc-events.c $(defs_h)
proc-flags.o: proc-flags.c $(defs_h)
stack.o: stack.c $(defs_h) $(gdb_string_h) $(value_h) $(symtab_h) \
$(gdbtypes_h) $(expression_h) $(language_h) $(frame_h) $(gdbcmd_h) \
$(gdbcore_h) $(target_h) $(breakpoint_h) $(demangle_h) $(inferior_h) \
- $(annotate_h) $(ui_out_h) $(source_h)
+ $(annotate_h) $(ui_out_h) $(source_h) $(dictionary_h)
standalone.o: standalone.c $(gdb_stat_h) $(defs_h) $(symtab_h) $(frame_h) \
$(inferior_h) $(gdb_wait_h)
std-regs.o: std-regs.c $(defs_h) $(builtin_regs_h) $(frame_h) $(gdbtypes_h) \
$(gdb_stat_h) $(gdbcore_h)
symmisc.o: symmisc.c $(defs_h) $(symtab_h) $(gdbtypes_h) $(bfd_h) \
$(symfile_h) $(objfiles_h) $(breakpoint_h) $(command_h) \
- $(gdb_obstack_h) $(language_h) $(bcache_h) $(gdb_string_h)
+ $(gdb_obstack_h) $(language_h) $(bcache_h) $(dictionary_h) \
+ $(gdb_string_h)
symtab.o: symtab.c $(defs_h) $(symtab_h) $(gdbtypes_h) $(gdbcore_h) \
- $(frame_h) $(target_h) $(value_h) $(symfile_h) $(objfiles_h) \
+ $(frame_h) $(target_h) $(value_h) $(symfile_h) $(objfiles_h) \
$(gdbcmd_h) $(call_cmds_h) $(gdb_regex_h) $(expression_h) \
- $(language_h) $(demangle_h) $(inferior_h) $(linespec_h) \
- $(filenames_h) $(gdb_obstack_h) $(gdb_string_h) $(gdb_stat_h) \
- $(cp_abi_h) $(source_h)
+ $(language_h) $(demangle_h) $(inferior_h) $(linespec_h) \
+ $(filenames_h) $(dictionary_h) $(gdb_obstack_h) \
+ $(gdb_string_h) $(gdb_stat_h) $(cp_abi_h) $(source_h)
target.o: target.c $(defs_h) $(gdb_string_h) $(target_h) $(gdbcmd_h) \
$(symtab_h) $(inferior_h) $(bfd_h) $(symfile_h) $(objfiles_h) \
$(gdb_wait_h) $(dcache_h) $(regcache_h)
$(expression_h) $(gdbcmd_h) $(value_h) $(target_h) $(language_h) \
$(gdb_string_h) $(inferior_h) $(tracepoint_h) $(remote_h) \
$(linespec_h) $(regcache_h) $(completer_h) $(gdb_events_h) $(ax_h) \
- $(ax_gdb_h)
+ $(ax_gdb_h) $(dictionary_h)
typeprint.o: typeprint.c $(defs_h) $(gdb_obstack_h) $(bfd_h) $(symtab_h) \
$(gdbtypes_h) $(expression_h) $(value_h) $(gdbcore_h) $(command_h) \
$(gdbcmd_h) $(target_h) $(language_h) $(cp_abi_h) $(gdb_string_h)
valops.o: valops.c $(defs_h) $(symtab_h) $(gdbtypes_h) $(value_h) $(frame_h) \
$(inferior_h) $(gdbcore_h) $(target_h) $(demangle_h) $(language_h) \
$(gdbcmd_h) $(regcache_h) $(cp_abi_h) $(gdb_string_h) \
- $(gdb_assert_h)
+ $(gdb_assert_h) $(dictionary_h)
valprint.o: valprint.c $(defs_h) $(gdb_string_h) $(symtab_h) $(gdbtypes_h) \
$(value_h) $(gdbcore_h) $(gdbcmd_h) $(target_h) $(language_h) \
$(annotate_h) $(valprint_h) $(floatformat_h) $(doublest_h)
$(mi_cmds_h) $(mi_getopt_h) $(ui_out_h) $(gdb_string_h)
$(CC) -c $(INTERNAL_CFLAGS) $(srcdir)/mi/mi-cmd-disas.c
mi-cmd-stack.o: $(srcdir)/mi/mi-cmd-stack.c $(defs_h) $(target_h) $(frame_h) \
- $(value_h) $(mi_cmds_h) $(ui_out_h) $(symtab_h)
+ $(value_h) $(mi_cmds_h) $(ui_out_h) $(symtab_h) $(dictionary_h)
$(CC) -c $(INTERNAL_CFLAGS) $(srcdir)/mi/mi-cmd-stack.c
mi-cmd-var.o: $(srcdir)/mi/mi-cmd-var.c $(defs_h) $(mi_cmds_h) $(ui_out_h) \
$(mi_out_h) $(varobj_h) $(value_h) $(gdb_string_h)
#include "breakpoint.h"
#include "gdbcore.h"
#include "ada-lang.h"
+#include "dictionary.h"
#ifdef UI_OUT
#include "ui-out.h"
#endif
struct objfile *objfile;
struct block *b;
struct symbol *tmp_sym;
- int i, j;
+ int j;
+ struct dict_iterator iter;
ALL_SYMTABS (objfile, s)
{
case LOC_BLOCK:
case LOC_CONST_BYTES:
b = BLOCKVECTOR_BLOCK (BLOCKVECTOR (s), GLOBAL_BLOCK);
- ALL_BLOCK_SYMBOLS (b, i, tmp_sym) if (sym == tmp_sym)
- return s;
+ ALL_BLOCK_SYMBOLS (b, iter, tmp_sym)
+ if (sym == tmp_sym)
+ return s;
b = BLOCKVECTOR_BLOCK (BLOCKVECTOR (s), STATIC_BLOCK);
- ALL_BLOCK_SYMBOLS (b, i, tmp_sym) if (sym == tmp_sym)
- return s;
+ ALL_BLOCK_SYMBOLS (b, iter, tmp_sym)
+ if (sym == tmp_sym)
+ return s;
break;
default:
break;
j < BLOCKVECTOR_NBLOCKS (BLOCKVECTOR (s)); j += 1)
{
b = BLOCKVECTOR_BLOCK (BLOCKVECTOR (s), j);
- ALL_BLOCK_SYMBOLS (b, i, tmp_sym) if (sym == tmp_sym)
- return s;
+ ALL_BLOCK_SYMBOLS (b, iter, tmp_sym)
+ if (sym == tmp_sym)
+ return s;
}
break;
default:
namespace_enum namespace, struct objfile *objfile,
int wild)
{
- int i;
+ struct dict_iterator;
int name_len = strlen (name);
/* A matching argument symbol, if any. */
struct symbol *arg_sym;
if (wild)
{
struct symbol *sym;
- ALL_BLOCK_SYMBOLS (block, i, sym)
+ ALL_BLOCK_SYMBOLS (block, iter, sym)
{
if (SYMBOL_NAMESPACE (sym) == namespace &&
wild_match (name, name_len, SYMBOL_NAME (sym)))
}
else
{
- ALL_BLOCK_SYMBOLS (block, i, sym)
+ ALL_BLOCK_SYMBOLS (block, iter, sym)
{
if (SYMBOL_NAMESPACE (sym) == namespace)
{
arg_sym = NULL;
found_sym = 0;
- ALL_BLOCK_SYMBOLS (block, i, sym)
+ ALL_BLOCK_SYMBOLS (block, iter, sym)
{
- struct symbol *sym = BLOCK_SYM (block, i);
-
if (SYMBOL_NAMESPACE (sym) == namespace)
{
int cmp;
{
struct block *b;
int nargs, nsyms;
- int i;
+ struct dict_iterator iter;
struct type *ftype;
struct type *rtype;
size_t max_fields;
max_fields = 8;
TYPE_FIELDS (ftype) =
(struct field *) xmalloc (sizeof (struct field) * max_fields);
- ALL_BLOCK_SYMBOLS (b, i, sym)
+ ALL_BLOCK_SYMBOLS (b, iter, sym)
{
GROW_VECT (TYPE_FIELDS (ftype), max_fields, nargs + 1);
static void
debug_print_block (struct block *b)
{
- int i;
- struct symbol *i;
+ struct dict_iterator iter;
+ struct symbol *sym;
fprintf (stderr, "Block: %p; [0x%lx, 0x%lx]",
b, BLOCK_START (b), BLOCK_END (b));
fprintf (stderr, "\n");
fprintf (stderr, "\t Superblock: %p\n", BLOCK_SUPERBLOCK (b));
fprintf (stderr, "\t Symbols:");
- ALL_BLOCK_SYMBOLS (b, i, sym)
+ ALL_BLOCK_SYMBOLS (b, iter, sym)
{
- if (i > 0 && i % 4 == 0)
- fprintf (stderr, "\n\t\t ");
+ fprintf (stderr, "\n\t\t ");
fprintf (stderr, " %s", SYMBOL_NAME (sym));
}
fprintf (stderr, "\n");
#include "gdb.h"
#include "ui-out.h"
#include "cli/cli-script.h"
+#include "dictionary.h"
#include "gdb-events.h"
if (blocks_searched[index] == 0)
{
struct block *b = BLOCKVECTOR_BLOCK (bl, index);
- register int i;
+ struct dict_iterator iter;
register struct symbol *sym;
- ALL_BLOCK_SYMBOLS (b, i, sym)
+ ALL_BLOCK_SYMBOLS (b, iter, sym)
{
if (STREQ (SYMBOL_NAME (sym), "default"))
{
{
BLOCK_SYM (block, --i) = next->symbol[j];
}
+ BLOCK_DICT (block) = dict_create_block (block);
}
else
{
- int htab_size = BLOCK_HASHTABLE_SIZE (i);
-
block = (struct block *)
- obstack_alloc (&objfile->symbol_obstack,
- (sizeof (struct block) +
- ((htab_size - 1) * sizeof (struct symbol *))));
- for (j = 0; j < htab_size; j++)
- {
- BLOCK_BUCKET (block, j) = 0;
- }
- BLOCK_BUCKETS (block) = htab_size;
- for (next = *listhead; next; next = next->next)
- {
- for (j = next->nsyms - 1; j >= 0; j--)
- {
- struct symbol *sym;
- unsigned int hash_index;
- const char *name = SYMBOL_DEMANGLED_NAME (next->symbol[j]);
- if (name == NULL)
- name = SYMBOL_NAME (next->symbol[j]);
- hash_index = msymbol_hash_iw (name);
- hash_index = hash_index % BLOCK_BUCKETS (block);
- sym = BLOCK_BUCKET (block, hash_index);
- BLOCK_BUCKET (block, hash_index) = next->symbol[j];
- next->symbol[j]->hash_next = sym;
- }
- }
+ obstack_alloc (&objfile->symbol_obstack, sizeof (struct block));
+ BLOCK_DICT (block) = dict_create_hashed (&objfile->symbol_obstack,
+ *listhead);
}
BLOCK_START (block) = start;
BLOCK_END (block) = end;
/* Superblock filled in when containing block is made */
BLOCK_SUPERBLOCK (block) = NULL;
- BLOCK_DICT (block) = dict_create_block (block);
BLOCK_GCC_COMPILED (block) = processing_gcc_compilation;
SYMBOL_BLOCK_VALUE (symbol) = block;
BLOCK_FUNCTION (block) = symbol;
BLOCK_HASHTABLE (block) = 0;
+ struct dict_iterator iter;
if (TYPE_NFIELDS (ftype) <= 0)
{
parameter symbols. */
int nparams = 0, iparams;
struct symbol *sym;
- ALL_BLOCK_SYMBOLS (block, i, sym)
+ ALL_BLOCK_SYMBOLS (block, iter, sym)
{
switch (SYMBOL_CLASS (sym))
{
#include "complaints.h"
#include "target.h"
#include "gdb_assert.h"
+#include "dictionary.h"
extern void _initialize_coffread (void);
patch_opaque_types (struct symtab *s)
{
register struct block *b;
- register int i;
+ struct dict_iterator iter;
register struct symbol *real_sym;
/* Go through the per-file symbols only */
b = BLOCKVECTOR_BLOCK (BLOCKVECTOR (s), STATIC_BLOCK);
- ALL_BLOCK_SYMBOLS (b, i, real_sym)
+ ALL_BLOCK_SYMBOLS (b, iter, real_sym)
{
/* Find completed typedefs to use to fix opaque ones.
Remove syms from the chain when their types are stored,
Boston, MA 02111-1307, USA. */
#include "defs.h"
-#include "dictionary.h"
#include "gdb_obstack.h"
#include "symtab.h"
#include "buildsym.h"
#include "gdb_assert.h"
+#include "dictionary.h"
/* This file implements dictionaries, which are tables that associate
symbols to names. They are represented by an opaque type 'struct
a bit easier; it's not actually used. */
enum dict_type type;
/* The function to free a dictionary. */
- void (*free)(struct dictionary *);
+ void (*free) (struct dictionary *dict);
+ /* The symbol lookup function. */
+ struct symbol *(*lookup) (const struct dictionary *dict,
+ const char *name,
+ const char *mangled_name,
+ const namespace_enum namespace);
+ /* Iterator functions. */
+ struct symbol *(*iterator_first) (const struct dictionary *dict,
+ struct dict_iterator *iterator);
+ struct symbol *(*iterator_next) (struct dict_iterator *iterator);
+ void (*add_symbol) (struct dictionary *dict, struct symbol *sym);
};
/* Now comes the structs used to store the data for different
the common data at the top of their structs, ordered in the same
way. */
+struct dictionary_hashed
+{
+ int nbuckets;
+ struct symbol **buckets;
+};
+
struct dictionary_block
{
struct block *block;
const struct dict_vtbl *vtbl;
union
{
+ struct dictionary_hashed hashed;
struct dictionary_block block;
struct dictionary_block_expandable block_expandable;
}
#define DICT_VTBL(d) (d)->vtbl
+#define DICT_HASHED_NBUCKETS(d) (d)->data.hashed.nbuckets
+#define DICT_HASHED_BUCKETS(d) (d)->data.hashed.buckets
+#define DICT_HASHED_BUCKET(d,i) DICT_HASHED_BUCKETS (d) [i]
+
/* This can be used for block_expandables, too. */
#define DICT_BLOCK_BLOCK(d) (d)->data.block.block
#define DICT_BLOCK_EXPANDABLE_MAXSYMS(d) (d)->data.block_expandable.maxsyms
+/* The initial size of a DICT_HASHED dictionary. */
+
+#define DICT_HASHED_INITIAL_MAXSYMS 10
+#define DICT_BLOCK_EXPANDABLE_INITIAL_MAXSYMS DICT_HASHED_INITIAL_MAXSYMS
+
+/* This calculates the number of buckets we'll use in a hashtable,
+ given the number of symbols that it will contain. */
+
+#define DICT_HASHTABLE_SIZE(n) ((n)/5 + 1)
-#define DICT_BLOCK_EXPANDABLE_INITIAL_MAXSYMS 10
+/* Accessor macros for dict_iterators; they're here rather than
+ dictionary.h because code elsewhere should treat dict_iterators as
+ opaque. */
+
+/* The dictionary that the iterator is associated to. */
+#define DICT_ITERATOR_DICT(iter) (iter)->dict
+/* For linear dictionaries, the index of the last symbol returned; for
+ hashed dictionaries, the bucket of the last symbol returned. */
+#define DICT_ITERATOR_INDEX(iter) (iter)->index
+/* For hashed dictionaries, this points to the last symbol returned;
+ otherwise, this is unused. */
+#define DICT_ITERATOR_CURRENT(iter) (iter)->current
+
+/* Functions to handle some of the common code in dict_iterator_first and
+ dict_iterator_next. */
+
+static struct symbol *iterator_hashed_advance (struct dict_iterator *iter);
+
+static struct symbol *iterator_block_hashed_advance (struct dict_iterator
+ *iter);
/* Declarations of functions for vtbls. */
-static void dict_free_block(struct dictionary *dict);
+/* Functions that might work across a range of dictionary types. */
+
+static void add_symbol_nonexpandable (struct dictionary *dict,
+ struct symbol *sym);
+
+static void free_obstack (struct dictionary *dict);
+
+/* Functions for DICT_HASHED dictionaries. */
+
+static struct symbol *lookup_hashed (const struct dictionary *dict,
+ const char *name,
+ const char *mangled_name,
+ const namespace_enum namespace);
+
+static struct symbol *iterator_first_hashed (const struct dictionary *dict,
+ struct dict_iterator *iterator);
+
+static struct symbol *iterator_next_hashed (struct dict_iterator *iterator);
+
+/* Functions for blocks. */
+
+static struct symbol *lookup_block (const struct dictionary *dict,
+ const char *name,
+ const char *mangled_name,
+ const namespace_enum namespace);
+
+
+static void free_block(struct dictionary *dict);
+
+static struct symbol *iterator_first_block (const struct dictionary *dict,
+ struct dict_iterator *iterator);
+
+static struct symbol *iterator_next_block (struct dict_iterator *iterator);
/* Various vtbls that we'll actually use. */
+const struct dict_vtbl dict_hashed_vtbl =
+ {
+ DICT_HASHED, free_obstack, lookup_hashed, iterator_first_hashed,
+ iterator_next_hashed, add_symbol_nonexpandable,
+ };
+
const struct dict_vtbl dict_block_vtbl =
{
- DICT_BLOCK, dict_free_block,
+ DICT_BLOCK, free_block, lookup_block, iterator_first_block,
+ iterator_next_block, add_symbol_nonexpandable,
};
const struct dict_vtbl dict_block_expandable_vtbl =
{
- DICT_BLOCK_EXPANDABLE, dict_free_block,
+ DICT_BLOCK_EXPANDABLE, free_block, lookup_block, iterator_first_block,
+ iterator_next_block, add_symbol_nonexpandable,
};
/* The creation functions. */
+/* Create a dictionary implemented via a fixed-size hashtable. All
+ memory it uses is allocated on OBSTACK; the environment is
+ initialized from SYMBOL_LIST. */
+
+struct dictionary *
+dict_create_hashed (struct obstack *obstack,
+ const struct pending *symbol_list)
+{
+ struct dictionary *retval;
+ int nsyms, nbuckets, i;
+ struct symbol **buckets;
+ const struct pending *list_counter;
+
+ retval = obstack_alloc (obstack, sizeof (struct dictionary));
+ DICT_VTBL (retval) = &dict_hashed_vtbl;
+
+ /* Calculate the number of symbols, and allocate space for them. */
+ for (nsyms = 0, list_counter = symbol_list;
+ list_counter != NULL;
+ nsyms += list_counter->nsyms, list_counter = list_counter->next)
+ {
+ /* EMPTY */ ;
+ }
+ nbuckets = DICT_HASHTABLE_SIZE (nsyms);
+ DICT_HASHED_NBUCKETS (retval) = nbuckets;
+ buckets = obstack_alloc (obstack, nbuckets * sizeof (struct symbol *));
+ memset (buckets, 0, nbuckets * sizeof (struct symbol *));
+ DICT_HASHED_BUCKETS (retval) = buckets;
+
+ /* Now fill the buckets. */
+ for (list_counter = symbol_list;
+ list_counter != NULL;
+ list_counter = list_counter->next)
+ {
+ for (i = list_counter->nsyms - 1; i >= 0; --i)
+ {
+ struct symbol *sym = list_counter->symbol[i];
+ unsigned int hash_index;
+ const char *name = SYMBOL_DEMANGLED_NAME (sym);
+ if (name == NULL)
+ name = SYMBOL_NAME (sym);
+ hash_index = msymbol_hash_iw (name) % nbuckets;
+ sym->hash_next = buckets[hash_index];
+ buckets[hash_index] = sym;
+ }
+ }
+
+ return retval;
+}
+
+#if 0
+/* Create a dictionary implemented via a fixed-size array. All memory
+ it uses is allocated on OBSTACK; the environment is initialized
+ from the SYMBOL_LIST. The symbols are ordered in the same order
+ that they're found in SYMBOL_LIST. */
+
+struct dictionary *
+dict_create_linear (struct obstack *obstack,
+ const struct pending *symbol_list)
+
+/* Create a dictionary implemented via an array that grows as
+ necessary. The dictionary is initially empty; to add symbols to
+ it, call dict_add_symbol(). Call dict_free() when you're done with
+ it. */
+
+/* FIXME: carlton/2002-09-11: This environment type exists only to
+ make mdebugread.c and jv-lang.c happy. The former should be
+ converted over to the buildsym.c mechanisms (or made obsolete, I
+ suggest in an excess of optimism); the latter should perhaps be
+ rethought. */
+
+struct dictionary *
+dict_create_linear_expandable (void)
+#endif
+
/* Allocate a dictionary in which symbol lookup is implemented via
BLOCK. Needs to be freed by dict_free; I won't worry about that,
however, since this will go away soon. */
+
struct dictionary *
dict_create_block (struct block *block)
{
/* The functions providing the dictionary interface. */
+/* Free the memory used by a dictionary that's not on an obstack. (If
+ any.) */
+
void
dict_free (struct dictionary *dict)
{
(DICT_VTBL (dict))->free (dict);
}
+/* Search DICT for symbol NAME in NAMESPACE.
+
+ If MANGLED_NAME is non-NULL, verify that any symbol we find has this
+ particular mangled name.
+*/
+
+/* FIXME: carlton/2002-09-23: namespace_enum is a typedef in
+ symtab.h... */
+
+struct symbol *
+dict_lookup (const struct dictionary *dict,
+ const char *name,
+ const char *mangled_name,
+ const namespace_enum namespace)
+{
+ return (DICT_VTBL (dict))->lookup (dict, name, mangled_name, namespace);
+}
+
+/* Initialize ITERATOR to point at the first symbol in DICT, and
+ return that first symbol, or NULL if DICT is empty. */
+
+struct symbol *
+dict_iterator_first (const struct dictionary *dict,
+ struct dict_iterator *iterator)
+{
+ return (DICT_VTBL (dict))->iterator_first (dict, iterator);
+}
+
+/* Advance ITERATOR, and return the next symbol, or NULL if there are
+ no more symbols. */
+
+struct symbol *
+dict_iterator_next (struct dict_iterator *iterator)
+{
+ return (DICT_VTBL (DICT_ITERATOR_DICT (iterator)))
+ ->iterator_next (iterator);
+}
+
+/* Test to see if DICT is empty. I could put this in the vtable, but
+ it's easy enough to do generically and doesn't get called a
+ lot. */
+
+extern int
+dict_empty (struct dictionary *dict)
+{
+ struct dict_iterator iter;
+
+ return (dict_iterator_first (dict, &iter) == NULL);
+}
+
+/* Add SYM to DICT. DICT had better be expandable. */
+
+extern void
+dict_add_symbol (struct dictionary *dict, struct symbol *sym)
+{
+ (DICT_VTBL (dict))->add_symbol (dict, sym);
+}
+
+
/* The functions implementing the dictionary interface. */
-/* First, for DICT_BLOCK and DICT_BLOCK_EXPANDABLE. */
+/* Generic functions, where appropriate. */
+
+static void
+free_obstack (struct dictionary *dict)
+{
+ /* Do nothing! */
+}
+
+static void
+add_symbol_nonexpandable (struct dictionary *dict, struct symbol *sym)
+{
+ internal_error (__FILE__, __LINE__,
+ "dict_add_symbol: non-expandable dictionary");
+}
+
+/* Functions for DICT_HASHED. */
+
+static struct symbol *
+lookup_hashed (const struct dictionary *dict,
+ const char *name,
+ const char *mangled_name,
+ const namespace_enum namespace)
+{
+ unsigned int hash_index
+ = msymbol_hash_iw (name) % DICT_HASHED_NBUCKETS (dict);
+ struct symbol *sym;
+
+ for (sym = DICT_HASHED_BUCKET (dict, hash_index);
+ sym;
+ sym = sym->hash_next)
+ {
+ if (SYMBOL_NAMESPACE (sym) == namespace
+ && (mangled_name
+ ? strcmp (SYMBOL_NAME (sym), mangled_name) == 0
+ : SYMBOL_MATCHES_NAME (sym, name)))
+ return sym;
+ }
+
+ return NULL;
+}
+
+static struct symbol *
+iterator_first_hashed (const struct dictionary *dict,
+ struct dict_iterator *iterator)
+{
+ DICT_ITERATOR_DICT (iterator) = dict;
+ DICT_ITERATOR_INDEX (iterator) = -1;
+ return iterator_hashed_advance (iterator);
+}
+
+static struct symbol *
+iterator_next_hashed (struct dict_iterator *iterator)
+{
+ const struct dictionary *dict = DICT_ITERATOR_DICT (iterator);
+ struct symbol *next;
+
+ /* FIXME: carlton/2002-09-23: Should I assert that
+ DICT_ITERATOR_CURRENT (iterator) != NULL? */
+ next = DICT_ITERATOR_CURRENT (iterator)->hash_next;
+
+ if (next == NULL)
+ return iterator_hashed_advance (iterator);
+ else
+ {
+ DICT_ITERATOR_CURRENT (iterator) = next;
+ return next;
+ }
+}
+
+static struct symbol *
+iterator_hashed_advance (struct dict_iterator *iterator)
+{
+ const struct dictionary *dict = DICT_ITERATOR_DICT (iterator);
+ int nbuckets = DICT_HASHED_NBUCKETS (dict);
+ int i;
+
+ for (i = DICT_ITERATOR_INDEX (iterator) + 1; i < nbuckets; ++i)
+ {
+ struct symbol *sym = DICT_HASHED_BUCKET (dict, i);
+
+ if (sym != NULL)
+ {
+ DICT_ITERATOR_INDEX (iterator) = i;
+ DICT_ITERATOR_CURRENT (iterator) = sym;
+ return sym;
+ }
+ }
+
+ return NULL;
+}
+
+/* Functions for DICT_BLOCK and DICT_BLOCK_EXPANDABLE. */
static void
-dict_free_block (struct dictionary *dict)
+free_block (struct dictionary *dict)
{
xfree (dict);
}
+static struct symbol *
+lookup_block (const struct dictionary *dict,
+ const char *name,
+ const char *mangled_name,
+ const namespace_enum namespace)
+{
+ struct block *block = DICT_BLOCK_BLOCK (dict);
+ register int bot, top;
+ register struct symbol *sym;
+ register struct symbol *sym_found = NULL;
+
+ if (BLOCK_HASHTABLE (block))
+ {
+ unsigned int hash_index;
+ hash_index = msymbol_hash_iw (name);
+ hash_index = hash_index % BLOCK_BUCKETS (block);
+ for (sym = BLOCK_BUCKET (block, hash_index); sym; sym = sym->hash_next)
+ {
+ if (SYMBOL_NAMESPACE (sym) == namespace
+ && (mangled_name
+ ? strcmp (SYMBOL_NAME (sym), mangled_name) == 0
+ : SYMBOL_MATCHES_NAME (sym, name)))
+ return sym;
+ }
+ return NULL;
+ }
+ else
+ {
+ /* Note that parameter symbols do not always show up last in the
+ list. This loop makes sure to take anything else other than
+ parameter symbols first; it only uses parameter symbols as a
+ last resort. Note that this only takes up extra computation
+ time on a match. */
+ top = BLOCK_NSYMS (block);
+ bot = 0;
+ while (bot < top)
+ {
+ sym = BLOCK_SYM (block, bot);
+ /* If there is more than one symbol with the right name and
+ namespace, we return the first one; I believe it is now
+ impossible for us to encounter two symbols with the same
+ name and namespace here, because blocks containing
+ argument symbols are no longer sorted. The exception is
+ for C++, where multiple functions (cloned constructors /
+ destructors, in particular) can have the same demangled
+ name. So if we have a particular mangled name to match,
+ try to do so. */
+ if (SYMBOL_NAMESPACE (sym) == namespace
+ && (mangled_name
+ ? strcmp (SYMBOL_NAME (sym), mangled_name) == 0
+ : SYMBOL_MATCHES_NAME (sym, name)))
+ {
+#if 0
+ /* FIXME: carlton/2002-09-11: According to
+ <http://sources.redhat.com/ml/gdb/2002-03/msg00232.html>,
+ the SYMBOL_ALIASES stuff is unused, and it makes
+ the code messier, so I'm #if'ing it out here. */
+
+ /* If SYM has aliases, then use any alias that is active
+ at the current PC. If no alias is active at the current
+ PC, then use the main symbol.
+
+ ?!? Is checking the current pc correct? Is this routine
+ ever called to look up a symbol from another context?
+
+ FIXME: No, it's not correct. If someone sets a
+ conditional breakpoint at an address, then the
+ breakpoint's `struct expression' should refer to the
+ `struct symbol' appropriate for the breakpoint's
+ address, which may not be the PC.
+
+ Even if it were never called from another context,
+ it's totally bizarre for lookup_symbol's behavior to
+ depend on the value of the inferior's current PC. We
+ should pass in the appropriate PC as well as the
+ block. The interface to lookup_symbol should change
+ to require the caller to provide a PC. */
+
+ if (SYMBOL_ALIASES (sym))
+ sym = find_active_alias (sym, read_pc ());
+#endif /* 0 */
+
+ sym_found = sym;
+ if (SYMBOL_CLASS (sym) != LOC_ARG &&
+ SYMBOL_CLASS (sym) != LOC_LOCAL_ARG &&
+ SYMBOL_CLASS (sym) != LOC_REF_ARG &&
+ SYMBOL_CLASS (sym) != LOC_REGPARM &&
+ SYMBOL_CLASS (sym) != LOC_REGPARM_ADDR &&
+ SYMBOL_CLASS (sym) != LOC_BASEREG_ARG)
+ {
+ break;
+ }
+ }
+ bot++;
+ }
+ return (sym_found); /* Will be NULL if not found. */
+ }
+}
+
+static struct symbol *
+iterator_first_block (const struct dictionary *dict,
+ struct dict_iterator *iterator)
+{
+ struct block *block = DICT_BLOCK_BLOCK (dict);
+
+ DICT_ITERATOR_DICT (iterator) = dict;
+
+ if (BLOCK_HASHTABLE (block))
+ {
+ DICT_ITERATOR_INDEX (iterator) = -1;
+ return iterator_block_hashed_advance (iterator);
+ }
+ else
+ {
+ DICT_ITERATOR_INDEX (iterator) = 0;
+ return BLOCK_NSYMS (block) ? BLOCK_SYM (block, 0) : NULL;
+ }
+}
+
+static struct symbol *
+iterator_next_block (struct dict_iterator *iterator)
+{
+ const struct dictionary *dict = DICT_ITERATOR_DICT (iterator);
+ struct block *block = DICT_BLOCK_BLOCK (dict);
+
+ if (BLOCK_HASHTABLE (block))
+ {
+ struct symbol *next = DICT_ITERATOR_CURRENT (iterator)->hash_next;
+
+ if (next == NULL)
+ return iterator_block_hashed_advance (iterator);
+ else
+ {
+ DICT_ITERATOR_CURRENT (iterator) = next;
+ return next;
+ }
+ }
+ else
+ {
+ if (++(DICT_ITERATOR_INDEX (iterator)) >= BLOCK_NSYMS (block))
+ return NULL;
+ else
+ return BLOCK_SYM (block, DICT_ITERATOR_INDEX (iterator));
+ }
+}
+
+/* A helper function for iterator_first_block and
+ iterator_first_block_next_block. Search for the next nonempty
+ bucket; update iterator accordingly, and return it. */
+
+static struct symbol *
+iterator_block_hashed_advance (struct dict_iterator *iterator)
+{
+ struct block *block =
+ DICT_BLOCK_BLOCK (DICT_ITERATOR_DICT (iterator));
+ int nbuckets = BLOCK_BUCKETS (block);
+ int i;
+
+ for (i = DICT_ITERATOR_INDEX (iterator) + 1; i < nbuckets; ++i)
+ {
+ struct symbol *sym = BLOCK_BUCKET (block, i);
+
+ if (sym != NULL)
+ {
+ DICT_ITERATOR_INDEX (iterator) = i;
+ DICT_ITERATOR_CURRENT (iterator) = sym;
+ return sym;
+ }
+ }
+
+ return NULL;
+}
+
/* A special-case function for DICT_BLOCK_EXPANDABLE. */
/* FIXME: carlton/2002-09-20: But some callers use xmmalloc!!!
/* The creation functions for various implementations of
dictionaries. */
-/* Create a DICT_BLOCK dictionary pointing at the given block. */
+/* Create a dictionary implemented via a fixed-size hashtable. All
+ memory it uses is allocated on OBSTACK; the environment is
+ initialized from SYMBOL_LIST. */
+
+extern struct dictionary *dict_create_hashed (struct obstack *obstack,
+ const struct pending
+ *symbol_list);
+
+/* Create a dictionary implemented via a fixed-size array. All memory
+ it uses is allocated on OBSTACK; the environment is initialized
+ from the SYMBOL_LIST. The symbols are ordered in the same order
+ that they're found in SYMBOL_LIST. */
+
+extern struct dictionary *dict_create_linear (struct obstack *obstack,
+ const struct pending
+ *symbol_list);
+
+/* Create a dictionary implemented via an array that grows as
+ necessary. The dictionary is initially empty; to add symbols to
+ it, call dict_add_symbol(). Call dict_free() when you're done with
+ it. */
+
+/* FIXME: carlton/2002-09-11: This environment type exists only to
+ make mdebugread.c and jv-lang.c happy. The former should be
+ converted over to the buildsym.c mechanisms (or made obsolete, I
+ suggest in an excess of optimism); the latter should probably be
+ rethought. */
+
+extern struct dictionary *dict_create_linear_expandable (void);
+
+/* Create a DICT_BLOCK dictionary pointing BLOCK. */
extern struct dictionary *
dict_create_block (struct block *block);
-/* Create a DICT_BLOCK_EXPANDABLE dictionary pointing at the given block. */
+/* Create a DICT_BLOCK_EXPANDABLE dictionary pointing at BLOCK. */
+
extern struct dictionary *
dict_create_block_expandable (struct block *block);
/* The functions providing the interface to dictionaries. */
+/* Search DICT for symbol NAME in NAMESPACE.
+
+ If MANGLED_NAME is non-NULL, verify that any symbol we find has this
+ particular mangled name.
+*/
+
+/* FIXME: carlton/2002-09-23: namespace_enum is a typedef in
+ symtab.h... */
+
+extern struct symbol *dict_lookup (const struct dictionary *dict,
+ const char *name,
+ const char *mangled_name,
+ const namespace_enum namespace);
+
/* Free the memory used by a dictionary that's not on an obstack. (If
any.) */
+
extern void dict_free (struct dictionary *dict);
+/* Add a symbol to an expandable dictionary. */
+
+extern void dict_add_symbol (struct dictionary *dict, struct symbol *sym);
+
+/* Is the dictionary empty? */
+
+extern int dict_empty (struct dictionary *dict);
+
/* Special case. */
extern struct block *dict_add_symbol_block (struct dictionary *dict,
struct symbol *sym);
+
+
+/* A type containing data that is used when iterating over all symbols
+ in a dictionary. */
+
+/* NOTE: carlton/2002-09-11: I originally wanted to make this opaque,
+ but that led to complications. Fortunately, it turned out that all
+ implementations of dictionaries currently need to keep track of the
+ same types of data (though how they interpret that data varies
+ depending on the implementation), so it's really not so bad after
+ all. But code outside of dictionary.c should never examine the
+ innards of a dict_iterator. */
+
+struct dict_iterator
+{
+ /* The dictionary that this iterator is associated to. */
+ const struct dictionary *dict;
+ /* The next two members are data that is used in a way that depends
+ on DICT's implementation type. */
+ int index;
+ struct symbol *current;
+};
+
+/* Initialize ITERATOR to point at the first symbol in DICT, and
+ return that first symbol, or NULL if DICT is empty. */
+
+extern struct symbol *dict_iterator_first (const struct dictionary *dict,
+ struct dict_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 dict_iterator_first or dict_iterator_next on this
+ iteration. */
+
+extern struct symbol *dict_iterator_next (struct dict_iterator *iterator);
+
+/* 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) = dict_iterator_first ((dict), &(iter)); \
+ (sym); \
+ (sym) = dict_iterator_next (&(iter)))
+
+/* For backwards compatibility, I suppose. */
+
+#define ALL_BLOCK_SYMBOLS(block, iter, sym) \
+ ALL_DICT_SYMBOLS (BLOCK_DICT (block), iter, sym)
struct block *bl;
class_symtab = allocate_symtab ("<java-classes>", objfile);
class_symtab->language = language_java;
+ /* FIXME: carlton/2002-09-23: I noticed this wasn't set, so I
+ set it to free_nothing (which is presumably what it would be
+ set to automatically). I _think_ that's the correct value;
+ if somebody more knowledgeable than me agrees, then feel free
+ to delete this comment. */
+ class_symtab->free_code = free_nothing;
bv = (struct blockvector *)
obstack_alloc (&objfile->symbol_obstack, sizeof (struct blockvector));
BLOCKVECTOR_NBLOCKS (bv) = 1;
TYPE_NFIELDS (ftype) = nparams;
TYPE_FIELDS (ftype) = (struct field *)
TYPE_ALLOC (ftype, nparams * sizeof (struct field));
+ struct dict_iterator iter;
- for (i = iparams = 0; iparams < nparams; i++)
+ for (sym = dict_iterator_first (BLOCK_DICT (b), &iter),
+ iparams = 0;
+ iparams < nparams;
+ sym = dict_iterator_next (&iter))
{
- sym = BLOCK_SYM (b, i);
+ gdb_assert (sym != NULL);
switch (SYMBOL_CLASS (sym))
{
case LOC_ARG:
mylookup_symbol (char *name, register struct block *block,
namespace_enum namespace, enum address_class class)
{
- int i, inc;
+ struct dict_iterator iter;
+ int inc;
struct symbol *sym;
inc = name[0];
- ALL_BLOCK_SYMBOLS (block, i, sym)
+ ALL_BLOCK_SYMBOLS (block, iter, sym)
{
if (SYMBOL_NAME (sym)[0] == inc
&& SYMBOL_NAMESPACE (sym) == namespace
static void
add_symbol (struct symbol *s, struct block *b)
{
- int nsyms = BLOCK_NSYMS (b)++;
struct block *newb;
struct parse_stack *stackp;
BLOCK_END (b) = sigtramp_end;
BLOCK_FUNCTION (b) = s;
BLOCK_SUPERBLOCK (b) = BLOCK_SUPERBLOCK (b0);
- add_block (b, st);
- sort_blocks (st);
/* Make a MIPS_EFI_SYMBOL_NAME entry for it */
{
current_objfile = NULL;
}
- BLOCK_SYM (b, BLOCK_NSYMS (b)++) = s;
+ b = dict_add_symbol_block (BLOCK_DICT (b), s);
+ add_block (b, st);
+ sort_blocks (st);
}
#endif /* TM_MIPS_H */
+2002-09-23 David Carlton <carlton@math.stanford.edu>
+
+ * mi-cmd-stack.c (list_args_or_locals): Update use of
+ ALL_BLOCK_SYMBOLS.
+ #include "dictionary.h"
+
2002-09-11 Keith Seitz <keiths@redhat.com>
* mi-main.c (mi_cmd_data_list_register_names): Use cleanups
#include "mi-cmds.h"
#include "ui-out.h"
#include "symtab.h"
+#include "dictionary.h"
/* FIXME: these should go in some .h file but stack.c doesn't have a
corresponding .h file. These wrappers will be obsolete anyway, once
{
struct block *block;
struct symbol *sym;
- int i, nsyms;
+ struct dict_iterator iter;
static struct ui_stream *stb = NULL;
stb = ui_out_stream_new (uiout);
while (block != 0)
{
- ALL_BLOCK_SYMBOLS (block, i, sym)
+ ALL_BLOCK_SYMBOLS (block, iter, sym)
{
int print_me = 0;
#include "gdb_string.h"
#include "breakpoint.h"
+#include "dictionary.h"
/* Prototypes for local functions */
{
struct block *b;
struct symbol *sym;
- int j;
+ struct dict_iterator iter;
b = BLOCKVECTOR_BLOCK (bv, i);
BLOCK_START (b) += ANOFFSET (delta, s->block_line_section);
BLOCK_END (b) += ANOFFSET (delta, s->block_line_section);
- ALL_BLOCK_SYMBOLS (b, j, sym)
+ ALL_BLOCK_SYMBOLS (b, iter, sym)
{
fixup_symbol_section (sym, objfile);
#include "completer.h" /* for completion functions */
#include "ui-out.h"
#include "gdb_assert.h"
+#include "dictionary.h"
extern int asm_demangle; /* Whether to demangle syms in asm printouts */
extern int addressprint; /* Whether to print hex addresses in HLL " */
{
struct block *b = NULL;
int first = 1;
- register int i;
+ struct dict_iterator iter;
register struct symbol *sym;
struct value *val;
/* Offset of next stack argument beyond the one we have seen that is
if (func)
{
b = SYMBOL_BLOCK_VALUE (func);
- /* Function blocks are order sensitive, and thus should not be
- hashed. */
- gdb_assert (BLOCK_HASHTABLE (b) == 0);
- ALL_BLOCK_SYMBOLS (b, i, sym)
+ ALL_BLOCK_SYMBOLS (b, iter, sym)
{
QUIT;
#include "inferior.h"
#include "annotate.h"
#include "ui-out.h"
+#include "dictionary.h"
/* Prototypes for exported functions. */
print_block_frame_locals (struct block *b, register struct frame_info *fi,
int num_tabs, register struct ui_file *stream)
{
- register int i, j;
+ struct dict_iterator iter;
+ register int j;
register struct symbol *sym;
register int values_printed = 0;
- ALL_BLOCK_SYMBOLS (b, i, sym)
+ ALL_BLOCK_SYMBOLS (b, iter, sym)
{
switch (SYMBOL_CLASS (sym))
{
print_block_frame_labels (struct block *b, int *have_default,
register struct ui_file *stream)
{
- register int i;
+ struct dict_iterator iter;
register struct symbol *sym;
register int values_printed = 0;
- ALL_BLOCK_SYMBOLS (b, i, sym)
+ ALL_BLOCK_SYMBOLS (b, iter, sym)
{
if (STREQ (SYMBOL_NAME (sym), "default"))
{
{
struct symbol *func = get_frame_function (fi);
register struct block *b;
- register int i;
+ struct dict_iterator iter;
register struct symbol *sym, *sym2;
register int values_printed = 0;
}
b = SYMBOL_BLOCK_VALUE (func);
- ALL_BLOCK_SYMBOLS (b, i, sym)
+ ALL_BLOCK_SYMBOLS (b, iter, sym)
{
switch (SYMBOL_CLASS (sym))
{
bv = BLOCKVECTOR (s);
if (BLOCKVECTOR_NBLOCKS (bv) > 2
- || BLOCK_NSYMS (BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK))
- || BLOCK_NSYMS (BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK)))
+ || ! dict_empty (BLOCK_DICT (BLOCK_NSYMS (BLOCKVECTOR_BLOCK
+ (bv, GLOBAL_BLOCK))))
+ || ! dict_empty (BLOCK_DICT (BLOCK_NSYMS (BLOCKVECTOR_BLOCK
+ (bv, STATIC_BLOCK)))))
{
complaint (&symfile_complaints, "Replacing old symbols for `%s'",
name);
#include "gdb_obstack.h"
#include "language.h"
#include "bcache.h"
+#include "dictionary.h"
#include "gdb_string.h"
static void
free_symtab_block (struct objfile *objfile, struct block *b)
{
- register int i, n;
- struct symbol *sym, *next_sym;
+ struct dict_iterator iter;
+ struct symbol *sym, *prev_sym;
+
+ prev_sym = dict_iterator_first (BLOCK_DICT (b), &iter);
- n = BLOCK_BUCKETS (b);
- for (i = 0; i < n; i++)
+ /* Make sure there's at least one symbol to free! */
+ if (prev_sym)
{
- for (sym = BLOCK_BUCKET (b, i); sym; sym = next_sym)
+ for (sym = dict_iterator_next (&iter); sym;
+ sym = dict_iterator_next (&iter))
{
- next_sym = sym->hash_next;
- xmfree (objfile->md, SYMBOL_NAME (sym));
- xmfree (objfile->md, (PTR) sym);
+ xmfree (objfile->md, SYMBOL_NAME (prev_sym));
+ xmfree (objfile->md, (PTR) prev_sym);
+ prev_sym = sym;
}
+
+ xmfree (objfile->md, SYMBOL_NAME (prev_sym));
+ xmfree (objfile->md, (PTR) prev_sym);
}
+
+ dict_free (BLOCK_DICT (b));
xmfree (objfile->md, (PTR) b);
}
dump_symtab (struct objfile *objfile, struct symtab *symtab,
struct ui_file *outfile)
{
- register int i, j;
+ register int i;
+ struct dict_iterator iter;
int len, blen;
register struct linetable *l;
struct blockvector *bv;
fprintf_filtered (outfile, " under ");
gdb_print_host_address (BLOCK_SUPERBLOCK (b), outfile);
}
+
+ /* NOTE: carlton/2002-09-23: If there is demand for it, we
+ can cook up something to put in here. */
+#if 0
/* drow/2002-07-10: We could save the total symbols count
even if we're using a hashtable, but nothing else but this message
wants it. */
fprintf_filtered (outfile, ", %d buckets in ", blen);
else
fprintf_filtered (outfile, ", %d syms in ", blen);
+#else
+ fprintf_filtered (outfile, " in ");
+#endif
print_address_numeric (BLOCK_START (b), 1, outfile);
fprintf_filtered (outfile, "..");
print_address_numeric (BLOCK_END (b), 1, outfile);
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, j, sym)
+ ALL_BLOCK_SYMBOLS (b, iter, sym)
{
struct print_symbol_args s;
s.symbol = sym;
#include "linespec.h"
#include "source.h"
#include "filenames.h" /* for FILENAME_CMP */
+#include "dictionary.h"
#include "gdb_obstack.h"
const char *mangled_name,
const namespace_enum namespace)
{
- register int bot, top;
- register struct symbol *sym;
- register struct symbol *sym_found = NULL;
-
- if (BLOCK_HASHTABLE (block))
- {
- unsigned int hash_index;
- hash_index = msymbol_hash_iw (name);
- hash_index = hash_index % BLOCK_BUCKETS (block);
- for (sym = BLOCK_BUCKET (block, hash_index); sym; sym = sym->hash_next)
- {
- if (SYMBOL_NAMESPACE (sym) == namespace
- && (mangled_name
- ? strcmp (SYMBOL_NAME (sym), mangled_name) == 0
- : SYMBOL_MATCHES_NAME (sym, name)))
- return sym;
- }
- return NULL;
- }
- else
- {
- /* Note that parameter symbols do not always show up last in the
- list. This loop makes sure to take anything else other than
- parameter symbols first; it only uses parameter symbols as a
- last resort. Note that this only takes up extra computation
- time on a match. */
- top = BLOCK_NSYMS (block);
- bot = 0;
- while (bot < top)
- {
- sym = BLOCK_SYM (block, bot);
- /* If there is more than one symbol with the right name and
- namespace, we return the first one; I believe it is now
- impossible for us to encounter two symbols with the same
- name and namespace here, because blocks containing
- argument symbols are no longer sorted. The exception is
- for C++, where multiple functions (cloned constructors /
- destructors, in particular) can have the same demangled
- name. So if we have a particular mangled name to match,
- try to do so. */
- if (SYMBOL_NAMESPACE (sym) == namespace
- && (mangled_name
- ? strcmp (SYMBOL_NAME (sym), mangled_name) == 0
- : SYMBOL_MATCHES_NAME (sym, name)))
- {
- /* If SYM has aliases, then use any alias that is active
- at the current PC. If no alias is active at the current
- PC, then use the main symbol.
-
- ?!? Is checking the current pc correct? Is this routine
- ever called to look up a symbol from another context?
-
- FIXME: No, it's not correct. If someone sets a
- conditional breakpoint at an address, then the
- breakpoint's `struct expression' should refer to the
- `struct symbol' appropriate for the breakpoint's
- address, which may not be the PC.
-
- Even if it were never called from another context,
- it's totally bizarre for lookup_symbol's behavior to
- depend on the value of the inferior's current PC. We
- should pass in the appropriate PC as well as the
- block. The interface to lookup_symbol should change
- to require the caller to provide a PC. */
-
- if (SYMBOL_ALIASES (sym))
- sym = find_active_alias (sym, read_pc ());
-
- sym_found = sym;
- if (SYMBOL_CLASS (sym) != LOC_ARG &&
- SYMBOL_CLASS (sym) != LOC_LOCAL_ARG &&
- SYMBOL_CLASS (sym) != LOC_REF_ARG &&
- SYMBOL_CLASS (sym) != LOC_REGPARM &&
- SYMBOL_CLASS (sym) != LOC_REGPARM_ADDR &&
- SYMBOL_CLASS (sym) != LOC_BASEREG_ARG)
- {
- break;
- }
- }
- bot++;
- }
- return (sym_found); /* Will be NULL if not found. */
- }
+ dict_lookup (BLOCK_DICT (block), name, mangled_name, namespace);
}
/* Given a main symbol SYM and ADDR, search through the alias
}
if (section != 0)
{
- int i;
+ struct dict_iterator iter;
struct symbol *sym = NULL;
- ALL_BLOCK_SYMBOLS (b, i, sym)
+ ALL_BLOCK_SYMBOLS (b, iter, sym)
{
fixup_symbol_section (sym, objfile);
if (section == SYMBOL_BFD_SECTION (sym))
break;
}
- if ((i >= BLOCK_BUCKETS (b)) && (sym == NULL))
+ if ((sym == NULL))
continue; /* no symbol in this symtab matches section */
}
distance = BLOCK_END (b) - BLOCK_START (b);
{
struct symtab *symtab, *best_symtab;
struct objfile *objfile;
- register int bot, top;
+ struct dict_iterator iter;
register struct symbol *sym;
register CORE_ADDR sym_addr;
struct block *block;
{
QUIT;
block = BLOCKVECTOR_BLOCK (BLOCKVECTOR (symtab), blocknum);
- ALL_BLOCK_SYMBOLS (block, bot, sym)
+ ALL_BLOCK_SYMBOLS (block, iter, sym)
{
switch (SYMBOL_CLASS (sym))
{
struct blockvector *prev_bv = 0;
register struct block *b;
register int i = 0;
- register int j;
+ struct dict_iterator iter;
register struct symbol *sym;
struct partial_symbol **psym;
struct objfile *objfile;
struct symbol_search *prevtail = tail;
int nfound = 0;
b = BLOCKVECTOR_BLOCK (bv, i);
- ALL_BLOCK_SYMBOLS (b, j, sym)
+ ALL_BLOCK_SYMBOLS (b, iter, sym)
{
QUIT;
if (file_matches (s->filename, files, nfiles)
register struct minimal_symbol *msymbol;
register struct objfile *objfile;
register struct block *b, *surrounding_static_block = 0;
- register int i, j;
+ struct dict_iterator iter;
+ register int j;
struct partial_symbol **psym;
/* The symbol we are completing on. Points in same buffer as text. */
char *sym_text;
/* Also catch fields of types defined in this places which match our
text string. Only complete on types visible from current context. */
- ALL_BLOCK_SYMBOLS (b, i, sym)
+ ALL_BLOCK_SYMBOLS (b, iter, sym)
{
COMPLETION_LIST_ADD_SYMBOL (sym, sym_text, sym_text_len, text, word);
if (SYMBOL_CLASS (sym) == LOC_TYPEDEF)
{
QUIT;
b = BLOCKVECTOR_BLOCK (BLOCKVECTOR (s), GLOBAL_BLOCK);
- ALL_BLOCK_SYMBOLS (b, i, sym)
+ ALL_BLOCK_SYMBOLS (b, iter, sym)
{
COMPLETION_LIST_ADD_SYMBOL (sym, sym_text, sym_text_len, text, word);
}
/* Don't do this block twice. */
if (b == surrounding_static_block)
continue;
- ALL_BLOCK_SYMBOLS (b, i, sym)
+ ALL_BLOCK_SYMBOLS (b, iter, sym)
{
COMPLETION_LIST_ADD_SYMBOL (sym, sym_text, sym_text_len, text, word);
}
register struct symbol *sym;
register struct symtab *s;
register struct block *b;
- register int i;
+ struct dict_iterator iter;
/* The symbol we are completing on. Points in same buffer as text. */
char *sym_text;
/* Length of sym_text. */
symbols which match. */
b = BLOCKVECTOR_BLOCK (BLOCKVECTOR (s), GLOBAL_BLOCK);
- ALL_BLOCK_SYMBOLS (b, i, sym)
+ ALL_BLOCK_SYMBOLS (b, iter, sym)
{
COMPLETION_LIST_ADD_SYMBOL (sym, sym_text, sym_text_len, text, word);
}
b = BLOCKVECTOR_BLOCK (BLOCKVECTOR (s), STATIC_BLOCK);
- ALL_BLOCK_SYMBOLS (b, i, sym)
+ ALL_BLOCK_SYMBOLS (b, iter, sym)
{
COMPLETION_LIST_ADD_SYMBOL (sym, sym_text, sym_text_len, text, word);
}
register struct partial_symtab *ps;
register struct objfile *objfile;
register struct block *b, *surrounding_static_block = 0;
- register int i;
+ struct dict_iterator iter;
/* The name we are completing on. */
char *oload_name = NULL;
/* Length of name. */
/* Also catch fields of types defined in this places which match our
text string. Only complete on types visible from current context. */
- ALL_BLOCK_SYMBOLS (b, i, sym)
+ ALL_BLOCK_SYMBOLS (b, iter, sym)
{
overload_list_add_symbol (sym, oload_name);
}
{
QUIT;
b = BLOCKVECTOR_BLOCK (BLOCKVECTOR (s), GLOBAL_BLOCK);
- ALL_BLOCK_SYMBOLS (b, i, sym)
+ ALL_BLOCK_SYMBOLS (b, iter, sym)
{
overload_list_add_symbol (sym, oload_name);
}
/* Don't do this block twice. */
if (b == surrounding_static_block)
continue;
- ALL_BLOCK_SYMBOLS (b, i, sym)
+ ALL_BLOCK_SYMBOLS (b, iter, sym)
{
overload_list_add_symbol (sym, oload_name);
}
/* Macro used to set the size of a hashtable for N symbols. */
#define BLOCK_HASHTABLE_SIZE(n) ((n)/5 + 1)
+#if 0
/* Macro to loop through all symbols in a block BL, in no particular order.
i counts which bucket we are in, and sym points to the current symbol. */
for ((i) = 0; (i) < BLOCK_BUCKETS ((bl)); (i)++) \
for ((sym) = BLOCK_BUCKET ((bl), (i)); (sym); \
(sym) = (sym)->hash_next)
+#endif
\f
free_linetable => free just the linetable. FIXME: Is this redundant
with the primary field? */
+ /* FIXME: carlton/2002-09-23: free_contents isn't being used right
+ now. */
enum free_code
{
free_nothing, free_contents, free_linetable
echo "Running fast tests."
runtest ${FASTTESTS} 2>&1 | grep -v "^Test Run By" > /tmp/fastout
-diff -u {/tmp/,carlton_}fastout
+diff -u {carlton_,/tmp/}fastout
echo "Running medium tests."
runtest ${MEDTESTS} 2>&1 | grep -v "^Test Run By" > /tmp/medout
-diff -u {/tmp/,carlton_}medout
+diff -u {carlton_,/tmp/}medout
echo "Running slow tests."
runtest ${SLOWTESTS} 2>&1 | grep -v "^Test Run By" > /tmp/slowout
-diff -u {/tmp/,carlton_}slowout
+diff -u {carlton_,/tmp/}slowout
echo "Done."
#include "regcache.h"
#include "completer.h"
#include "gdb-events.h"
+#include "dictionary.h"
#include "ax.h"
#include "ax-gdb.h"
{
struct symbol *sym;
struct block *block;
- int i, count = 0;
+ struct dict_iterator iter;
+ int count = 0;
block = block_for_pc (pc);
while (block != 0)
{
QUIT; /* allow user to bail out with ^C */
- ALL_BLOCK_SYMBOLS (block, i, sym)
+ ALL_BLOCK_SYMBOLS (block, iter, sym)
{
switch (SYMBOL_CLASS (sym))
{
struct minimal_symbol *msym;
struct block *block;
char **canonical, *symname, *save_args = args;
- int i, j, count = 0;
+ struct dict_iterator iter;
+ int j, count = 0;
if (args == 0 || *args == 0)
error ("requires an argument (function, line or *addr) to define a scope");
while (block != 0)
{
QUIT; /* allow user to bail out with ^C */
- ALL_BLOCK_SYMBOLS (block, i, sym)
+ ALL_BLOCK_SYMBOLS (block, iter, sym)
{
QUIT; /* allow user to bail out with ^C */
if (count == 0)
#include "gdbcmd.h"
#include "regcache.h"
#include "cp-abi.h"
+#include "dictionary.h"
#include <errno.h>
#include "gdb_string.h"
}
b = SYMBOL_BLOCK_VALUE (func);
- i = BLOCK_NSYMS (b);
- if (i <= 0)
+ if (dict_empty (BLOCK_DICT (b)))
{
if (complain)
error ("no args, no `this'");