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.
This commit is contained in:
Daniel Jacobowitz
2002-07-11 20:46:19 +00:00
parent 7c1f909cd5
commit 261397f84f
12 changed files with 291 additions and 143 deletions

View File

@@ -1328,6 +1328,22 @@ lookup_block_symbol (register const struct block *block, const char *name,
register struct symbol *sym_found = NULL;
register int do_linear_search = 1;
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;
}
/* If the blocks's symbols were sorted, start with a binary search. */
if (BLOCK_SHOULD_SORT (block))
@@ -1582,14 +1598,15 @@ find_pc_sect_symtab (CORE_ADDR pc, asection *section)
if (section != 0)
{
int i;
struct symbol *sym = NULL;
for (i = 0; i < b->nsyms; i++)
ALL_BLOCK_SYMBOLS (b, i, sym)
{
fixup_symbol_section (b->sym[i], objfile);
if (section == SYMBOL_BFD_SECTION (b->sym[i]))
fixup_symbol_section (sym, objfile);
if (section == SYMBOL_BFD_SECTION (sym))
break;
}
if (i >= b->nsyms)
if ((i >= BLOCK_BUCKETS (b)) && (sym == NULL))
continue; /* no symbol in this symtab matches section */
}
distance = BLOCK_END (b) - BLOCK_START (b);
@@ -1661,10 +1678,8 @@ find_addr_symbol (CORE_ADDR addr, struct symtab **symtabp, CORE_ADDR *symaddrp)
{
QUIT;
block = BLOCKVECTOR_BLOCK (BLOCKVECTOR (symtab), blocknum);
top = BLOCK_NSYMS (block);
for (bot = 0; bot < top; bot++)
ALL_BLOCK_SYMBOLS (block, bot, sym)
{
sym = BLOCK_SYM (block, bot);
switch (SYMBOL_CLASS (sym))
{
case LOC_STATIC:
@@ -2795,10 +2810,9 @@ search_symbols (char *regexp, namespace_enum kind, int nfiles, char *files[],
struct symbol_search *prevtail = tail;
int nfound = 0;
b = BLOCKVECTOR_BLOCK (bv, i);
for (j = 0; j < BLOCK_NSYMS (b); j++)
ALL_BLOCK_SYMBOLS (b, j, sym)
{
QUIT;
sym = BLOCK_SYM (b, j);
if (file_matches (s->filename, files, nfiles)
&& ((regexp == NULL || SYMBOL_MATCHES_REGEXP (sym))
&& ((kind == VARIABLES_NAMESPACE && SYMBOL_CLASS (sym) != LOC_TYPEDEF