]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
2002-09-23 David Carlton <carlton@math.stanford.edu>
authorDavid Carlton <carlton@bactrian.org>
Tue, 24 Sep 2002 00:04:53 +0000 (00:04 +0000)
committerDavid Carlton <carlton@bactrian.org>
Tue, 24 Sep 2002 00:04:53 +0000 (00:04 +0000)
* 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"

22 files changed:
gdb/ChangeLog
gdb/Makefile.in
gdb/ada-lang.c
gdb/breakpoint.c
gdb/buildsym.c
gdb/coffread.c
gdb/dictionary.c
gdb/dictionary.h
gdb/jv-lang.c
gdb/mdebugread.c
gdb/mi/ChangeLog
gdb/mi/mi-cmd-stack.c
gdb/objfiles.c
gdb/printcmd.c
gdb/stack.c
gdb/symfile.c
gdb/symmisc.c
gdb/symtab.c
gdb/symtab.h
gdb/testsuite/carlton_runtest
gdb/tracepoint.c
gdb/valops.c

index 448fa9f167c8117215174feaf63408238d458444..c615c5cc3a3bba620a3a908e03b70026f8cc441f 100644 (file)
@@ -1,3 +1,89 @@
+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
index ef01b59b80ca1ec0978794e7f0c808460bce725a..458f1487c5bc647f4de691a7678c422a3c02bc3d 100644 (file)
@@ -1483,7 +1483,7 @@ abug-rom.o: abug-rom.c $(defs_h) $(gdbcore_h) $(target_h) $(monitor_h) \
 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)
@@ -1552,7 +1552,7 @@ breakpoint.o: breakpoint.c $(defs_h) $(symtab_h) $(frame_h) $(breakpoint_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) \
@@ -1583,7 +1583,7 @@ coffread.o: coffread.c $(defs_h) $(symtab_h) $(gdbtypes_h) $(demangle_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) \
@@ -1955,7 +1955,8 @@ ns32knbsd-nat.o: ns32knbsd-nat.c $(defs_h) $(inferior_h) $(target_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)
@@ -2003,7 +2004,7 @@ printcmd.o: printcmd.c $(defs_h) $(gdb_string_h) $(frame_h) $(symtab_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)
@@ -2192,7 +2193,7 @@ stabsread.o: stabsread.c $(defs_h) $(gdb_string_h) $(bfd_h) $(gdb_obstack_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) \
@@ -2210,13 +2211,14 @@ symm-tdep.o: symm-tdep.c $(defs_h) $(frame_h) $(inferior_h) $(symtab_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)
@@ -2237,7 +2239,7 @@ tracepoint.o: tracepoint.c $(defs_h) $(symtab_h) $(frame_h) $(gdbtypes_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)
@@ -2262,7 +2264,7 @@ valarith.o: valarith.c $(defs_h) $(value_h) $(symtab_h) $(gdbtypes_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)
@@ -2434,7 +2436,7 @@ mi-cmd-disas.o: $(srcdir)/mi/mi-cmd-disas.c $(defs_h) $(target_h) $(value_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)
index 647f2c24487c0c23023cae9127acac4201374fe1..b38c5deb3eaa8d9c246fce5a69ae8e9086783aaf 100644 (file)
@@ -36,6 +36,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
 #include "breakpoint.h"
 #include "gdbcore.h"
 #include "ada-lang.h"
+#include "dictionary.h"
 #ifdef UI_OUT
 #include "ui-out.h"
 #endif
@@ -3431,7 +3432,8 @@ symtab_for_sym (struct symbol *sym)
   struct objfile *objfile;
   struct block *b;
   struct symbol *tmp_sym;
-  int i, j;
+  int j;
+  struct dict_iterator iter;
 
   ALL_SYMTABS (objfile, s)
   {
@@ -3445,11 +3447,13 @@ symtab_for_sym (struct symbol *sym)
       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;
@@ -3470,8 +3474,9 @@ symtab_for_sym (struct symbol *sym)
             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:
@@ -3943,7 +3948,7 @@ ada_add_block_symbols (struct block *block, const char *name,
                       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;
@@ -3956,7 +3961,7 @@ ada_add_block_symbols (struct block *block, const char *name,
   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)))
@@ -3984,7 +3989,7 @@ ada_add_block_symbols (struct block *block, const char *name,
     }
   else
     {
-      ALL_BLOCK_SYMBOLS (block, i, sym)
+      ALL_BLOCK_SYMBOLS (block, iter, sym)
          {
            if (SYMBOL_NAMESPACE (sym) == namespace)
              {
@@ -4028,10 +4033,8 @@ ada_add_block_symbols (struct block *block, const char *name,
       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;
@@ -4091,7 +4094,7 @@ fill_in_ada_prototype (struct symbol *func)
 {
   struct block *b;
   int nargs, nsyms;
-  int i;
+  struct dict_iterator iter;
   struct type *ftype;
   struct type *rtype;
   size_t max_fields;
@@ -4117,7 +4120,7 @@ fill_in_ada_prototype (struct symbol *func)
   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);
 
@@ -4687,8 +4690,8 @@ debug_print_lines (struct linetable *lt)
 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));
@@ -4697,10 +4700,9 @@ debug_print_block (struct block *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");
index caa8f1c1106039f1ce2a12cc3c0d999487aa3876..adc3956e0c7c53fbfaa7ce391496c167a271224a 100644 (file)
@@ -47,6 +47,7 @@
 #include "gdb.h"
 #include "ui-out.h"
 #include "cli/cli-script.h"
+#include "dictionary.h"
 
 #include "gdb-events.h"
 
@@ -5803,10 +5804,10 @@ get_catch_sals (int this_level_only)
          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"))
                    {
index c7d54b4727a07b055ba512fa1f3c4165ff3594bb..ea934f5edc1f3a3234e084920d34cb7302c061fb 100644 (file)
@@ -259,43 +259,20 @@ finish_block (struct symbol *symbol, struct pending **listhead,
          {
            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;
 
@@ -307,6 +284,7 @@ finish_block (struct symbol *symbol, struct pending **listhead,
       SYMBOL_BLOCK_VALUE (symbol) = block;
       BLOCK_FUNCTION (block) = symbol;
       BLOCK_HASHTABLE (block) = 0;
+      struct dict_iterator iter;
 
       if (TYPE_NFIELDS (ftype) <= 0)
        {
@@ -315,7 +293,7 @@ finish_block (struct symbol *symbol, struct pending **listhead,
             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))
                {
index 4e71dac5549af00dfb2342f34a0b4f8578c8bbc2..fee392f3c4e28e3ebabd586429043a44ad09f2a0 100644 (file)
@@ -44,6 +44,7 @@
 #include "complaints.h"
 #include "target.h"
 #include "gdb_assert.h"
+#include "dictionary.h"
 
 extern void _initialize_coffread (void);
 
@@ -1413,12 +1414,12 @@ static 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,
index 37a73154ec6da654422fc7ae04b8e4b67d79c959..22a7643f9a9831822f68cb43a1fd8fc8fbdd9c27 100644 (file)
    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
@@ -74,7 +74,17 @@ struct dict_vtbl
      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
@@ -82,6 +92,12 @@ struct dict_vtbl
    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;
@@ -100,6 +116,7 @@ struct dictionary
   const struct dict_vtbl *vtbl;
   union
   {
+    struct dictionary_hashed hashed;
     struct dictionary_block block;
     struct dictionary_block_expandable block_expandable;
   }
@@ -110,36 +127,184 @@ struct dictionary
 
 #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)
 {
@@ -166,22 +331,348 @@ dict_create_block_expandable (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!!!
index 46137b6146ebe6f0796f7a5c9d9a46d016ddefa9..082e528bc15560e469f1a6023958d42ef7170d02 100644 (file)
@@ -37,23 +37,129 @@ struct block;
 /* 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)
index 8dc6c4f3d34292707f0d080ede5e5e11b91855e8..d352ec85e58fa7045f7bb336cb260bd1ae3075ac 100644 (file)
@@ -96,6 +96,12 @@ get_java_class_symtab (void)
       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;
index d72737de2a802ff479e6e0fe0bb9ccf36608fa10..8f440f49d7ea49204d0ac6ddb6a635cba4e103af 100644 (file)
@@ -1225,10 +1225,14 @@ parse_symbol (SYMR *sh, union aux_ext *ax, char *ext_sh, int bigend,
                  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:
@@ -4388,11 +4392,12 @@ static struct symbol *
 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
@@ -4413,7 +4418,6 @@ mylookup_symbol (char *name, register struct block *block,
 static void
 add_symbol (struct symbol *s, struct block *b)
 {
-  int nsyms = BLOCK_NSYMS (b)++;
   struct block *newb;
   struct parse_stack *stackp;
 
@@ -4806,8 +4810,6 @@ fixup_sigtramp (void)
   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 */
   {
@@ -4843,7 +4845,9 @@ fixup_sigtramp (void)
     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 */
index 51d99735fc185b2cfae85b5d483da76444649160..d3f86c82b5ae13ffcfd920fa0676d24cb153c267 100644 (file)
@@ -1,3 +1,9 @@
+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
index b4bae47716dcbfe960150223004efdde1ee1cb3e..f89ff2babb0c512fa8be0108edaa9028e63c51d6 100644 (file)
@@ -26,6 +26,7 @@
 #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
@@ -213,7 +214,7 @@ list_args_or_locals (int locals, int values, struct frame_info *fi)
 {
   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);
@@ -224,7 +225,7 @@ list_args_or_locals (int locals, int values, struct frame_info *fi)
 
   while (block != 0)
     {
-      ALL_BLOCK_SYMBOLS (block, i, sym)
+      ALL_BLOCK_SYMBOLS (block, iter, sym)
        {
           int print_me = 0;
 
index 9c5e49fde608a42ff6ec62d7efeb4f361892a9ac..88003e62d5940f58d13a2da5867458e0b855a6dc 100644 (file)
@@ -41,6 +41,7 @@
 #include "gdb_string.h"
 
 #include "breakpoint.h"
+#include "dictionary.h"
 
 /* Prototypes for local functions */
 
@@ -569,13 +570,13 @@ objfile_relocate (struct objfile *objfile, struct section_offsets *new_offsets)
        {
          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);
 
index 8542b8a9a5b3464b4b538edbe4c4e30e89a27ec6..ade4b18e5b2f2e3db2c2a6f20d2e65c80d4eea87 100644 (file)
@@ -41,6 +41,7 @@
 #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 " */
@@ -1767,7 +1768,7 @@ print_frame_args (struct symbol *func, struct frame_info *fi, int num,
 {
   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
@@ -1786,11 +1787,8 @@ print_frame_args (struct symbol *func, struct frame_info *fi, int num,
   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;
 
index 4f41531189a80210ed073ed23f99368cfaeb2533..72374ed653b9e85a6d69bd8d544803f396f93a53 100644 (file)
@@ -39,6 +39,7 @@
 #include "inferior.h"
 #include "annotate.h"
 #include "ui-out.h"
+#include "dictionary.h"
 
 /* Prototypes for exported functions. */
 
@@ -1220,11 +1221,12 @@ static int
 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))
        {
@@ -1255,11 +1257,11 @@ static int
 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"))
        {
@@ -1437,7 +1439,7 @@ print_frame_arg_vars (register struct frame_info *fi,
 {
   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;
 
@@ -1448,7 +1450,7 @@ print_frame_arg_vars (register struct frame_info *fi,
     }
 
   b = SYMBOL_BLOCK_VALUE (func);
-  ALL_BLOCK_SYMBOLS (b, i, sym)
+  ALL_BLOCK_SYMBOLS (b, iter, sym)
     {
       switch (SYMBOL_CLASS (sym))
        {
index 51b1acf9cde2bb0a9a4e9214786e9cc6b963965c..b03f0b0b9aa18fd074e05760db2d59cb366a088e 100644 (file)
@@ -2255,8 +2255,10 @@ again2:
 
       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);
index 4273b856bc202f7df169b799eed1752b9c0f1c76..6cea2f1aeb089b179304e73c0a41c0d2e78e7790 100644 (file)
@@ -32,6 +32,7 @@
 #include "gdb_obstack.h"
 #include "language.h"
 #include "bcache.h"
+#include "dictionary.h"
 
 #include "gdb_string.h"
 
@@ -87,19 +88,27 @@ static void free_symtab_block (struct objfile *, struct block *);
 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);
 }
 
@@ -416,7 +425,8 @@ static void
 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;
@@ -465,6 +475,10 @@ dump_symtab (struct objfile *objfile, struct symtab *symtab,
              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.  */
@@ -473,6 +487,9 @@ dump_symtab (struct objfile *objfile, struct symtab *symtab,
            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);
@@ -490,7 +507,7 @@ dump_symtab (struct objfile *objfile, struct symtab *symtab,
          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;
index 0c299b472a6514a1d18dfd8c9508596a31228fb7..19983397819a3870330194a04cb710f1173b9e63 100644 (file)
@@ -40,6 +40,7 @@
 #include "linespec.h"
 #include "source.h"
 #include "filenames.h"         /* for FILENAME_CMP */
+#include "dictionary.h"
 
 #include "gdb_obstack.h"
 
@@ -1335,89 +1336,7 @@ lookup_block_symbol (register const struct block *block, const char *name,
                     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
@@ -1532,16 +1451,16 @@ find_pc_sect_symtab (CORE_ADDR pc, asection *section)
          }
        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);
@@ -1592,7 +1511,7 @@ find_addr_symbol (CORE_ADDR addr, struct symtab **symtabp, CORE_ADDR *symaddrp)
 {
   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;
@@ -1613,7 +1532,7 @@ find_addr_symbol (CORE_ADDR addr, struct symtab **symtabp, CORE_ADDR *symaddrp)
       {
        QUIT;
        block = BLOCKVECTOR_BLOCK (BLOCKVECTOR (symtab), blocknum);
-       ALL_BLOCK_SYMBOLS (block, bot, sym)
+       ALL_BLOCK_SYMBOLS (block, iter, sym)
          {
            switch (SYMBOL_CLASS (sym))
              {
@@ -2564,7 +2483,7 @@ search_symbols (char *regexp, namespace_enum kind, int nfiles, char *files[],
   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;
@@ -2745,7 +2664,7 @@ search_symbols (char *regexp, namespace_enum kind, int nfiles, char *files[],
          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)
@@ -3150,7 +3069,8 @@ make_symbol_completion_list (char *text, char *word)
   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;
@@ -3271,7 +3191,7 @@ make_symbol_completion_list (char *text, char *word)
       /* 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)
@@ -3301,7 +3221,7 @@ make_symbol_completion_list (char *text, char *word)
   {
     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);
       }
@@ -3314,7 +3234,7 @@ make_symbol_completion_list (char *text, char *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);
       }
@@ -3332,7 +3252,7 @@ make_file_symbol_completion_list (char *text, char *word, char *srcfile)
   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.  */
@@ -3419,13 +3339,13 @@ make_file_symbol_completion_list (char *text, char *word, char *srcfile)
      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);
     }
@@ -3776,7 +3696,7 @@ make_symbol_overload_list (struct symbol *fsym)
   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.  */
@@ -3848,7 +3768,7 @@ make_symbol_overload_list (struct symbol *fsym)
       /* 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);
        }
@@ -3861,7 +3781,7 @@ make_symbol_overload_list (struct symbol *fsym)
   {
     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);
       }
@@ -3874,7 +3794,7 @@ make_symbol_overload_list (struct symbol *fsym)
     /* 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);
       }
index d664a92c65910ca29e075e4648a7721d7d4352d2..d09d5ff8b5a91442c7ba5ac7d297b87fe800629f 100644 (file)
@@ -439,6 +439,7 @@ struct block
 /* 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.  */
 
@@ -446,6 +447,7 @@ struct block
        for ((i) = 0; (i) < BLOCK_BUCKETS ((bl)); (i)++)        \
          for ((sym) = BLOCK_BUCKET ((bl), (i)); (sym);         \
               (sym) = (sym)->hash_next)
+#endif
 
 \f
 
@@ -868,6 +870,8 @@ struct symtab
      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
index de1d950bfa07095162edce8299b064abee721abd..fb982c2fd09e25f92a5da71dfa685d6286241c8e 100755 (executable)
@@ -47,12 +47,12 @@ SLOWTESTS="gdb.base/callfuncs.exp \
 
 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."
index 2d12f31d57bc884566a3382eba59bacc648e9f37..7716eaf148b76916f28d6739c9cbefabfce13b6d 100644 (file)
@@ -37,6 +37,7 @@
 #include "regcache.h"
 #include "completer.h"
 #include "gdb-events.h"
+#include "dictionary.h"
 
 #include "ax.h"
 #include "ax-gdb.h"
@@ -1298,13 +1299,14 @@ add_local_symbols (struct collection_list *collect, CORE_ADDR pc,
 {
   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))
            {
@@ -2341,7 +2343,8 @@ scope_info (char *args, int from_tty)
   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");
@@ -2357,7 +2360,7 @@ scope_info (char *args, int from_tty)
   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)
index eaf429531082beeebfc4aa7a6a60aafdfec1a4da..20866d115e8fc631f809e3f50889dfcfdb296a18 100644 (file)
@@ -33,6 +33,7 @@
 #include "gdbcmd.h"
 #include "regcache.h"
 #include "cp-abi.h"
+#include "dictionary.h"
 
 #include <errno.h>
 #include "gdb_string.h"
@@ -3337,8 +3338,7 @@ value_of_this (int complain)
     }
 
   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'");