aboutsummaryrefslogtreecommitdiff
path: root/gdb/symmisc.c
diff options
context:
space:
mode:
authorDavid Carlton <carlton@bactrian.org>2003-06-11 23:29:49 +0000
committerDavid Carlton <carlton@bactrian.org>2003-06-11 23:29:49 +0000
commitde4f826b0f698dc2858f6eda71f2613a89579c50 (patch)
tree13525aa41c328ee4018f4feb9c45ad204fee014f /gdb/symmisc.c
parentcdfbf930b96d5ae51342f34dd180323a8011f8ef (diff)
downloadfsf-binutils-gdb-de4f826b0f698dc2858f6eda71f2613a89579c50.zip
fsf-binutils-gdb-de4f826b0f698dc2858f6eda71f2613a89579c50.tar.gz
fsf-binutils-gdb-de4f826b0f698dc2858f6eda71f2613a89579c50.tar.bz2
2003-06-11 David Carlton <carlton@bactrian.org>
* dictionary.h: New. * dictionary.c: New. * block.h: Add opaque declaration for struct dictionary. (struct block): Add 'dict' member; delete 'hashtable', 'nsyms', 'sym' members. (BLOCK_DICT): New macro. Delete macros BLOCK_HASHTABLE, BLOCK_NSYMS, BLOCK_SYM, BLOCK_BUCKETS, BLOCK_BUCKET, BLOCK_HASHTABLE_SIZE, BLOCK_SHOULD_SORT. (ALL_BLOCK_SYMBOLS): Update definition. * Makefile.in (SFILES): Add dictionary.c. (dictionary_h): New. (COMMON_OBS): Add dictionary.o. (dictionary.o): New. (ada-lang.o): Depend on dictionary_h. (buildsym.o, coffread.o, jv-lang.o, mdebugread.o, objfiles.o) (stack.o, symmisc.o, symtab.o, tracepoint.o, valops.o) (mi-cmd-stack.o): Ditto. (gdbtk-cmds.o): Update dependencies. (gdbtk-stack.o): Ditto. * ada-lang.c: Include dictionary.h. (symtab_for_sym): Update uses of ALL_BLOCK_SYMBOLS. (fill_in_ada_prototype, debug_print_block): Ditto. (ada_add_block_symbols): Update uses of ALL_BLOCK_SYMBOLS; replace explicit iteration by use of ALL_BLOCK_SYMBOLS. Delete variable 'is_sorted'. * mdebugread.c: Include dictionary.h. (struct parse_stack): Delete 'maxsyms' member. (parse_symbol): Update calls to new_block. Delete calls to shrink_block. Use dictionary methods. (psymtab_to_symtab_1): Delete calls to sort_symtab_syms. Update calls to new_symtab. Don't maintain maxsyms data. (mylookup_symbol): Update use of ALL_BLOCK_SYMBOLS. (add_symbol): Just call dict_add_symbol. (new_symtab): Delete 'maxsyms' argument. (new_symtab): Update calls to new_block. (new_block): Delete 'maxsyms' argument; add 'function' argument. (shrink_block): Delete function. (fixup_sigtramp): Update call to new_block. Add symbol via dict_add_symbol. * jv-lang.c: Include dictionary.h. (get_java_class_symtab): Set the BLOCK_DICT of the blocks appropriately. Set class_symtab->free_func. Make sure the blockvector is big enough to hold two blocks. (add_class_symtab_symbol): Use dictionary methods. (free_class_block): New function. (type_from_class): Replace explicit iteration by ALL_BLOCK_SYMBOLS. * symtab.h (struct symtab): Replace 'free_ptr' method by 'free_func'. * dwarf2read.c (psymtab_to_symtab_1): Delete call to sort_symtab_syms. * dwarfread.c (psymtab_to_symtab_1): Delete call to sort_symtab_syms. * coffread.c (coff_symfile_read): Delete call to sort_symtab_syms. Include dictionary.h. (patch_opaque_types): Update use of ALL_BLOCK_SYMBOLS. * dbxread.c (dbx_psymtab_to_symtab_1): Delete call to sort_symtab_syms. * objfiles.c: Include dictionary.h. (objfile_relocate): Update use of ALL_BLOCK_SYMBOLS. * buildsym.c: Include dictionary.h. (finish_block): Use dictionary methods. (end_symtab): Set free_func to NULL, not free_ptr. * tracepoint.c: Include dictionary.h. (add_local_symbols): Update use of ALL_BLOCK_SYMBOLS. (scope_info): Ditto. * stack.c: Include dictionary.h. (print_block_frame_locals): Update use of ALL_BLOCK_SYMBOLS. (print_block_frame_labels, print_frame_arg_vars) (print_frame_args): Ditto. * symmisc.c (free_symtab_block): Use dictionary methods. (dump_symtab): Ditto. (free_symtab): Replace use of 'free_ptr' by 'free_func'. Include dictionary.h. * symfile.h: Delete declarations of sort_block_syms, sort_symtab_syms. * symfile.c (sort_block_syms): Delete. (sort_symtab_syms): Delete. * symtab.c: Include dictionary.h. (lookup_block_symbol): Use dictionary iterators. (find_pc_sect_symtab): Update use of ALL_BLOCK_SYMBOLS. (search_symbols, make_symbol_completion_list): Ditto. (make_symbol_overload_list): Ditto. * valops.c (value_of_local): Use dict_empty. Include dictionary.h. 2003-06-11 David Carlton <carlton@bactrian.org> * generic/gdbtk-stack.c: Include dictionary.h. (gdb_block_vars): Update use of ALL_BLOCK_SYMBOLS. (gdb_get_blocks, gdb_get_vars_command): Ditto. * generic/gdbtk-cmds.c: Include dictionary.h. (gdb_listfuncs): Update use of ALL_BLOCK_SYMBOLS. 2003-06-11 David Carlton <carlton@bactrian.org> * mi-cmd-stack.c: Include dictionary.h. (list_args_or_locals): Update use of ALL_BLOCK_SYMBOLS.
Diffstat (limited to 'gdb/symmisc.c')
-rw-r--r--gdb/symmisc.c43
1 files changed, 21 insertions, 22 deletions
diff --git a/gdb/symmisc.c b/gdb/symmisc.c
index 3b57e5f..c3cd7ab 100644
--- a/gdb/symmisc.c
+++ b/gdb/symmisc.c
@@ -34,6 +34,7 @@
#include "bcache.h"
#include "block.h"
#include "gdb_regex.h"
+#include "dictionary.h"
#include "gdb_string.h"
#include <readline/readline.h>
@@ -87,22 +88,22 @@ static void free_symtab_block (struct objfile *, struct block *);
/* Free a struct block <- B and all the symbols defined in that block. */
+/* FIXME: carlton/2003-04-28: I don't believe this is currently ever
+ used. */
+
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;
- n = BLOCK_BUCKETS (b);
- for (i = 0; i < n; i++)
+ ALL_BLOCK_SYMBOLS (b, iter, sym)
{
- for (sym = BLOCK_BUCKET (b, i); sym; sym = next_sym)
- {
- next_sym = sym->hash_next;
- xmfree (objfile->md, DEPRECATED_SYMBOL_NAME (sym));
- xmfree (objfile->md, sym);
- }
+ xmfree (objfile->md, DEPRECATED_SYMBOL_NAME (sym));
+ xmfree (objfile->md, sym);
}
+
+ dict_free (BLOCK_DICT (b));
xmfree (objfile->md, b);
}
@@ -141,7 +142,7 @@ free_symtab (register struct symtab *s)
/* Also free the linetable. */
case free_linetable:
- /* Everything will be freed either by our `free_ptr'
+ /* Everything will be freed either by our `free_func'
or by some other symtab, except for our linetable.
Free that now. */
if (LINETABLE (s))
@@ -150,8 +151,8 @@ free_symtab (register struct symtab *s)
}
/* If there is a single block of memory to free, free it. */
- if (s->free_ptr != NULL)
- xmfree (s->objfile->md, s->free_ptr);
+ if (s->free_func != NULL)
+ s->free_func (s);
/* Free source-related stuff */
if (s->line_charpos != NULL)
@@ -444,12 +445,13 @@ static void
dump_symtab (struct objfile *objfile, struct symtab *symtab,
struct ui_file *outfile)
{
- register int i, j;
+ int i;
+ struct dict_iterator iter;
int len, blen;
- register struct linetable *l;
+ struct linetable *l;
struct blockvector *bv;
struct symbol *sym;
- register struct block *b;
+ struct block *b;
int depth;
fprintf_filtered (outfile, "\nSymtab for file %s\n", symtab->filename);
@@ -496,11 +498,8 @@ dump_symtab (struct objfile *objfile, struct symtab *symtab,
/* 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. */
- blen = BLOCK_BUCKETS (b);
- if (BLOCK_HASHTABLE (b))
- fprintf_filtered (outfile, ", %d buckets in ", blen);
- else
- fprintf_filtered (outfile, ", %d syms in ", blen);
+ fprintf_filtered (outfile, ", %d syms/buckets in ",
+ dict_size (BLOCK_DICT (b)));
print_address_numeric (BLOCK_START (b), 1, outfile);
fprintf_filtered (outfile, "..");
print_address_numeric (BLOCK_END (b), 1, outfile);
@@ -518,7 +517,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;