diff options
author | David Carlton <carlton@bactrian.org> | 2003-06-11 23:29:49 +0000 |
---|---|---|
committer | David Carlton <carlton@bactrian.org> | 2003-06-11 23:29:49 +0000 |
commit | de4f826b0f698dc2858f6eda71f2613a89579c50 (patch) | |
tree | 13525aa41c328ee4018f4feb9c45ad204fee014f /gdb/buildsym.c | |
parent | cdfbf930b96d5ae51342f34dd180323a8011f8ef (diff) | |
download | gdb-de4f826b0f698dc2858f6eda71f2613a89579c50.zip gdb-de4f826b0f698dc2858f6eda71f2613a89579c50.tar.gz 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/buildsym.c')
-rw-r--r-- | gdb/buildsym.c | 70 |
1 files changed, 17 insertions, 53 deletions
diff --git a/gdb/buildsym.c b/gdb/buildsym.c index d3c9ddf..f0d75ce 100644 --- a/gdb/buildsym.c +++ b/gdb/buildsym.c @@ -45,6 +45,7 @@ #include "demangle.h" /* Needed by SYMBOL_INIT_DEMANGLED_NAME. */ #include "block.h" #include "cp-support.h" +#include "dictionary.h" /* Ask buildsym.h to define the vars it normally declares `extern'. */ #define EXTERN @@ -229,62 +230,22 @@ finish_block (struct symbol *symbol, struct pending **listhead, register struct block *block; register struct pending_block *pblock; struct pending_block *opblock; - register int i; - register int j; - - /* Count the length of the list of symbols. */ - for (next = *listhead, i = 0; - next; - i += next->nsyms, next = next->next) - { - /* EMPTY */ ; - } - - /* Copy the symbols into the block. */ + /* Initialize the block's dictionary. */ if (symbol) { block = (struct block *) - obstack_alloc (&objfile->symbol_obstack, - (sizeof (struct block) + - ((i - 1) * sizeof (struct symbol *)))); - BLOCK_NSYMS (block) = i; - for (next = *listhead; next; next = next->next) - for (j = next->nsyms - 1; j >= 0; j--) - { - BLOCK_SYM (block, --i) = next->symbol[j]; - } + obstack_alloc (&objfile->symbol_obstack, sizeof (struct block)); + BLOCK_DICT (block) = dict_create_linear (&objfile->symbol_obstack, + *listhead); } 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 = DEPRECATED_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; @@ -300,9 +261,9 @@ finish_block (struct symbol *symbol, struct pending **listhead, if (symbol) { struct type *ftype = SYMBOL_TYPE (symbol); + struct dict_iterator iter; SYMBOL_BLOCK_VALUE (symbol) = block; BLOCK_FUNCTION (block) = symbol; - BLOCK_HASHTABLE (block) = 0; if (TYPE_NFIELDS (ftype) <= 0) { @@ -311,7 +272,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)) { @@ -348,9 +309,12 @@ finish_block (struct symbol *symbol, struct pending **listhead, TYPE_FIELDS (ftype) = (struct field *) TYPE_ALLOC (ftype, nparams * sizeof (struct field)); - for (i = iparams = 0; iparams < nparams; i++) + iparams = 0; + ALL_BLOCK_SYMBOLS (block, iter, sym) { - sym = BLOCK_SYM (block, i); + if (iparams == nparams) + break; + switch (SYMBOL_CLASS (sym)) { case LOC_ARG: @@ -394,7 +358,6 @@ finish_block (struct symbol *symbol, struct pending **listhead, else { BLOCK_FUNCTION (block) = NULL; - BLOCK_HASHTABLE (block) = 1; } /* Now "free" the links of the list, and empty the list. */ @@ -476,6 +439,7 @@ finish_block (struct symbol *symbol, struct pending **listhead, record_pending_block (objfile, block, opblock); } + /* Record BLOCK on the list of all blocks in the file. Put it after OPBLOCK, or at the beginning if opblock is NULL. This puts the block in the list after all its subblocks. @@ -1031,7 +995,7 @@ end_symtab (CORE_ADDR end_addr, struct objfile *objfile, int section) symtab->dirname = NULL; } symtab->free_code = free_linetable; - symtab->free_ptr = NULL; + symtab->free_func = NULL; /* Use whatever language we have been using for this subfile, not the one that was deduced in allocate_symtab |