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/ada-lang.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/ada-lang.c')
-rw-r--r-- | gdb/ada-lang.c | 201 |
1 files changed, 104 insertions, 97 deletions
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index db1d7d4..feb5a68 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -3560,6 +3560,7 @@ symtab_for_sym (sym) struct symtab* s; struct objfile *objfile; struct block *b; + struct symbol *tmp_sym; int i, j; ALL_SYMTABS (objfile, s) @@ -3574,12 +3575,12 @@ symtab_for_sym (sym) case LOC_BLOCK: case LOC_CONST_BYTES: b = BLOCKVECTOR_BLOCK (BLOCKVECTOR (s), GLOBAL_BLOCK); - for (i = 0; i < BLOCK_NSYMS (b); i += 1) - if (sym == BLOCK_SYM (b, i)) + ALL_BLOCK_SYMBOLS (b, i, tmp_sym) + if (sym == tmp_sym) return s; b = BLOCKVECTOR_BLOCK (BLOCKVECTOR (s), STATIC_BLOCK); - for (i = 0; i < BLOCK_NSYMS (b); i += 1) - if (sym == BLOCK_SYM (b, i)) + ALL_BLOCK_SYMBOLS (b, i, tmp_sym) + if (sym == tmp_sym) return s; break; default: @@ -3601,8 +3602,8 @@ symtab_for_sym (sym) j < BLOCKVECTOR_NBLOCKS (BLOCKVECTOR (s)); j += 1) { b = BLOCKVECTOR_BLOCK (BLOCKVECTOR (s), j); - for (i = 0; i < BLOCK_NSYMS (b); i += 1) - if (sym == BLOCK_SYM (b, i)) + ALL_BLOCK_SYMBOLS (b, i, tmp_sym) + if (sym == tmp_sym) return s; } break; @@ -4094,14 +4095,14 @@ ada_add_block_symbols (block, name, namespace, objfile, wild) /* Set true when we find a matching non-argument symbol */ int found_sym; int is_sorted = BLOCK_SHOULD_SORT (block); + struct symbol *sym; arg_sym = NULL; found_sym = 0; if (wild) { - for (i = 0; i < BLOCK_NSYMS (block); i += 1) + struct symbol *sym; + ALL_BLOCK_SYMBOLS (block, i, sym) { - struct symbol *sym = BLOCK_SYM (block, i); - if (SYMBOL_NAMESPACE (sym) == namespace && wild_match (name, name_len, SYMBOL_NAME (sym))) { @@ -4149,44 +4150,46 @@ ada_add_block_symbols (block, name, namespace, objfile, wild) else i = 0; - for (; i < BLOCK_NSYMS (block); i += 1) - { - struct symbol *sym = BLOCK_SYM (block, i); + for (; i < BLOCK_BUCKETS (block); i += 1) + for (sym = BLOCK_BUCKET (block, i); sym != NULL; sym = sym->hash_next) + { + if (SYMBOL_NAMESPACE (sym) == namespace) + { + int cmp = strncmp (name, SYMBOL_NAME (sym), name_len); - if (SYMBOL_NAMESPACE (sym) == namespace) - { - int cmp = strncmp (name, SYMBOL_NAME (sym), name_len); - - if (cmp < 0) - { - if (is_sorted) - break; - } - else if (cmp == 0 - && is_name_suffix (SYMBOL_NAME (sym) + name_len)) - { - switch (SYMBOL_CLASS (sym)) - { - case LOC_ARG: - case LOC_LOCAL_ARG: - case LOC_REF_ARG: - case LOC_REGPARM: - case LOC_REGPARM_ADDR: - case LOC_BASEREG_ARG: - arg_sym = sym; - break; - case LOC_UNRESOLVED: - break; - default: - found_sym = 1; - fill_in_ada_prototype (sym); - add_defn_to_vec (fixup_symbol_section (sym, objfile), - block); - break; - } - } - } - } + if (cmp < 0) + { + if (is_sorted) + { + i = BLOCK_BUCKETS (block); + break; + } + } + else if (cmp == 0 + && is_name_suffix (SYMBOL_NAME (sym) + name_len)) + { + switch (SYMBOL_CLASS (sym)) + { + case LOC_ARG: + case LOC_LOCAL_ARG: + case LOC_REF_ARG: + case LOC_REGPARM: + case LOC_REGPARM_ADDR: + case LOC_BASEREG_ARG: + arg_sym = sym; + break; + case LOC_UNRESOLVED: + break; + default: + found_sym = 1; + fill_in_ada_prototype (sym); + add_defn_to_vec (fixup_symbol_section (sym, objfile), + block); + break; + } + } + } + } } if (! found_sym && arg_sym != NULL) @@ -4219,53 +4222,57 @@ ada_add_block_symbols (block, name, namespace, objfile, wild) else i = 0; - for (; i < BLOCK_NSYMS (block); i += 1) - { - struct symbol *sym = BLOCK_SYM (block, i); + for (; i < BLOCK_BUCKETS (block); i += 1) + for (sym = BLOCK_BUCKET (block, i); sym != NULL; sym = sym->hash_next) + { + struct symbol *sym = BLOCK_SYM (block, i); - if (SYMBOL_NAMESPACE (sym) == namespace) - { - int cmp; + if (SYMBOL_NAMESPACE (sym) == namespace) + { + int cmp; - cmp = (int) '_' - (int) SYMBOL_NAME (sym)[0]; - if (cmp == 0) - { - cmp = strncmp ("_ada_", SYMBOL_NAME (sym), 5); - if (cmp == 0) - cmp = strncmp (name, SYMBOL_NAME (sym) + 5, name_len); - } - - if (cmp < 0) - { - if (is_sorted) - break; - } - else if (cmp == 0 - && is_name_suffix (SYMBOL_NAME (sym) + name_len + 5)) - { - switch (SYMBOL_CLASS (sym)) - { - case LOC_ARG: - case LOC_LOCAL_ARG: - case LOC_REF_ARG: - case LOC_REGPARM: - case LOC_REGPARM_ADDR: - case LOC_BASEREG_ARG: - arg_sym = sym; - break; - case LOC_UNRESOLVED: - break; - default: - found_sym = 1; - fill_in_ada_prototype (sym); - add_defn_to_vec (fixup_symbol_section (sym, objfile), - block); - break; - } - } - } - } - + cmp = (int) '_' - (int) SYMBOL_NAME (sym)[0]; + if (cmp == 0) + { + cmp = strncmp ("_ada_", SYMBOL_NAME (sym), 5); + if (cmp == 0) + cmp = strncmp (name, SYMBOL_NAME (sym) + 5, name_len); + } + + if (cmp < 0) + { + if (is_sorted) + { + i = BLOCK_BUCKETS (block); + break; + } + } + else if (cmp == 0 + && is_name_suffix (SYMBOL_NAME (sym) + name_len + 5)) + { + switch (SYMBOL_CLASS (sym)) + { + case LOC_ARG: + case LOC_LOCAL_ARG: + case LOC_REF_ARG: + case LOC_REGPARM: + case LOC_REGPARM_ADDR: + case LOC_BASEREG_ARG: + arg_sym = sym; + break; + case LOC_UNRESOLVED: + break; + default: + found_sym = 1; + fill_in_ada_prototype (sym); + add_defn_to_vec (fixup_symbol_section (sym, objfile), + block); + break; + } + } + } + } + /* NOTE: This really shouldn't be needed for _ada_ symbols. They aren't parameters, right? */ if (! found_sym && arg_sym != NULL) @@ -4292,6 +4299,7 @@ fill_in_ada_prototype (func) struct type* ftype; struct type* rtype; size_t max_fields; + struct symbol *sym; if (func == NULL || TYPE_CODE (SYMBOL_TYPE (func)) != TYPE_CODE_FUNC @@ -4308,16 +4316,13 @@ fill_in_ada_prototype (func) SYMBOL_TYPE (func) = ftype; b = SYMBOL_BLOCK_VALUE (func); - nsyms = BLOCK_NSYMS (b); nargs = 0; max_fields = 8; TYPE_FIELDS (ftype) = (struct field*) xmalloc (sizeof (struct field) * max_fields); - for (i = 0; i < nsyms; i += 1) + ALL_BLOCK_SYMBOLS (b, i, sym) { - struct symbol *sym = BLOCK_SYM (b, i); - GROW_VECT (TYPE_FIELDS (ftype), max_fields, nargs+1); switch (SYMBOL_CLASS (sym)) @@ -4903,6 +4908,8 @@ debug_print_block (b) struct block* b; { int i; + struct symbol *i; + fprintf (stderr, "Block: %p; [0x%lx, 0x%lx]", b, BLOCK_START(b), BLOCK_END(b)); if (BLOCK_FUNCTION(b) != NULL) @@ -4910,11 +4917,11 @@ debug_print_block (b) fprintf (stderr, "\n"); fprintf (stderr, "\t Superblock: %p\n", BLOCK_SUPERBLOCK(b)); fprintf (stderr, "\t Symbols:"); - for (i = 0; i < BLOCK_NSYMS (b); i += 1) + ALL_BLOCK_SYMBOLS (b, i, sym) { if (i > 0 && i % 4 == 0) fprintf (stderr, "\n\t\t "); - fprintf (stderr, " %s", SYMBOL_NAME (BLOCK_SYM (b, i))); + fprintf (stderr, " %s", SYMBOL_NAME (sym)); } fprintf (stderr, "\n"); } |