diff options
author | Daniel Jacobowitz <drow@false.org> | 2002-07-11 20:46:19 +0000 |
---|---|---|
committer | Daniel Jacobowitz <drow@false.org> | 2002-07-11 20:46:19 +0000 |
commit | 261397f84f0369d189de8ddf4c331f282a59ed89 (patch) | |
tree | d1128ec86122474bb8fc28de99f4d902e3092e09 /gdb/buildsym.c | |
parent | 7c1f909cd5369d517b431f176f33dc4aef79f4a7 (diff) | |
download | gdb-261397f84f0369d189de8ddf4c331f282a59ed89.zip gdb-261397f84f0369d189de8ddf4c331f282a59ed89.tar.gz gdb-261397f84f0369d189de8ddf4c331f282a59ed89.tar.bz2 |
2002-07-11 Daniel Jacobowitz <drow@mvista.com>
Based on patch from Daniel Berlin <dberlin@dberlin.org>.
* buildsym.c: Include "demangle.h" for SYMBOL_INIT_DEMANGLED_NAME.
(finish_block) For non-function blocks, hash the symbol table. For
function blocks, mark the symbol table as unhashed.
* minsyms.c (msymbol_hash): Return hash value without taking modulus.
(msymbol_hash_iw): Likewise.
(add_minsym_to_hash_table): Take modulus of msymbol_hash's return
value.
(add_minsym_to_demangled_hash_table): Likewise for msymbol_hash_iw.
(lookup_minimal_symbol): Likewise for both.
* symtab.h (struct block): Add `hashtable' flag. Comment the
hashtable.
(BLOCK_HASHTABLE, BLOCK_BUCKETS, BLOCK_BUCKET): New macro.
(ALL_BLOCK_SYMBOLS): Update.
(BLOCK_SHOULD_SORT): Do not sort hashed blocks.
(struct symbol): Add `hash_next' pointer.
* symtab.c (lookup_block_symbol): Search using the hash table when
possible.
(find_pc_sect_symtab): Use ALL_BLOCK_SYMBOLS.
(search_symbols, find_addr_symbol): Likewise.
* dstread.c (process_dst_block): Clear hashtable bit for new block.
(read_dst_symtab): Likewise.
* jv-lang.c (get_java_class_symtab): Likewise.
* mdebugread.c: Include "gdb_assert.h".
(shrink_block): Assert that the block being modified is not hashed.
* coffread.c (patch_opaque_types): Use ALL_BLOCK_SYMBOLS.
* symmisc.c (free_symtab_block): Walk the hash table when freeing
symbols.
(dump_symtab): Recognize hashed blocks.
* printcmd.c (print_frame_args): Assert that function blocks do not
have hashed symbol tables.
* ada-lang.c (symtab_for_sym): Use ALL_BLOCK_SYMBOLS.
(fill_in_ada_prototype, debug_print_block): Likewise.
(ada_add_block_symbols): Use ALL_BLOCK_SYMBOLS. Handle hash tables.
Diffstat (limited to 'gdb/buildsym.c')
-rw-r--r-- | gdb/buildsym.c | 49 |
1 files changed, 42 insertions, 7 deletions
diff --git a/gdb/buildsym.c b/gdb/buildsym.c index 5078935..f62ecad 100644 --- a/gdb/buildsym.c +++ b/gdb/buildsym.c @@ -40,6 +40,7 @@ #include "bcache.h" #include "filenames.h" /* For DOSish file names */ #include "macrotab.h" +#include "demangle.h" /* Needed by SYMBOL_INIT_DEMANGLED_NAME. */ /* Ask buildsym.h to define the vars it normally declares `extern'. */ #define EXTERN /**/ @@ -243,17 +244,49 @@ finish_block (struct symbol *symbol, struct pending **listhead, /* EMPTY */ ; } - block = (struct block *) obstack_alloc (&objfile->symbol_obstack, - (sizeof (struct block) + ((i - 1) * sizeof (struct symbol *)))); - /* Copy the symbols into the block. */ - BLOCK_NSYMS (block) = i; - for (next = *listhead; next; next = next->next) + 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]; + } + } + else { - for (j = next->nsyms - 1; j >= 0; j--) + 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) { - BLOCK_SYM (block, --i) = next->symbol[j]; + 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; + } } } @@ -271,6 +304,7 @@ finish_block (struct symbol *symbol, struct pending **listhead, struct type *ftype = SYMBOL_TYPE (symbol); SYMBOL_BLOCK_VALUE (symbol) = block; BLOCK_FUNCTION (block) = symbol; + BLOCK_HASHTABLE (block) = 0; if (TYPE_NFIELDS (ftype) <= 0) { @@ -352,6 +386,7 @@ 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. */ |