diff options
Diffstat (limited to 'gdb/ada-lang.c')
-rw-r--r-- | gdb/ada-lang.c | 100 |
1 files changed, 19 insertions, 81 deletions
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index c403af2c02d..eaa528124f7 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -40,6 +40,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "ui-out.h" #include "block.h" #include "infcall.h" +#include "dictionary.h" struct cleanup *unresolved_names; @@ -3433,7 +3434,8 @@ symtab_for_sym (struct symbol *sym) struct objfile *objfile; struct block *b; struct symbol *tmp_sym; - int i, j; + struct dict_iterator iter; + int j; ALL_SYMTABS (objfile, s) { @@ -3447,10 +3449,10 @@ symtab_for_sym (struct symbol *sym) case LOC_BLOCK: case LOC_CONST_BYTES: b = BLOCKVECTOR_BLOCK (BLOCKVECTOR (s), GLOBAL_BLOCK); - ALL_BLOCK_SYMBOLS (b, i, tmp_sym) if (sym == tmp_sym) + ALL_BLOCK_SYMBOLS (b, iter, tmp_sym) if (sym == tmp_sym) return s; b = BLOCKVECTOR_BLOCK (BLOCKVECTOR (s), STATIC_BLOCK); - ALL_BLOCK_SYMBOLS (b, i, tmp_sym) if (sym == tmp_sym) + ALL_BLOCK_SYMBOLS (b, iter, tmp_sym) if (sym == tmp_sym) return s; break; default: @@ -3474,7 +3476,7 @@ symtab_for_sym (struct symbol *sym) j < BLOCKVECTOR_NBLOCKS (BLOCKVECTOR (s)); j += 1) { b = BLOCKVECTOR_BLOCK (BLOCKVECTOR (s), j); - ALL_BLOCK_SYMBOLS (b, i, tmp_sym) if (sym == tmp_sym) + ALL_BLOCK_SYMBOLS (b, iter, tmp_sym) if (sym == tmp_sym) return s; } break; @@ -3947,13 +3949,12 @@ ada_add_block_symbols (struct block *block, const char *name, domain_enum domain, struct objfile *objfile, int wild) { - int i; + struct dict_iterator iter; int name_len = strlen (name); /* A matching argument symbol, if any. */ struct symbol *arg_sym; /* 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; @@ -3961,7 +3962,7 @@ ada_add_block_symbols (struct block *block, const char *name, if (wild) { struct symbol *sym; - ALL_BLOCK_SYMBOLS (block, i, sym) + ALL_BLOCK_SYMBOLS (block, iter, sym) { if (SYMBOL_DOMAIN (sym) == domain && wild_match (name, name_len, DEPRECATED_SYMBOL_NAME (sym))) @@ -3990,45 +3991,14 @@ ada_add_block_symbols (struct block *block, const char *name, } else { - if (is_sorted) - { - int U; - i = 0; - U = BLOCK_NSYMS (block) - 1; - while (U - i > 4) - { - int M = (U + i) >> 1; - struct symbol *sym = BLOCK_SYM (block, M); - if (DEPRECATED_SYMBOL_NAME (sym)[0] < name[0]) - i = M + 1; - else if (DEPRECATED_SYMBOL_NAME (sym)[0] > name[0]) - U = M - 1; - else if (strcmp (DEPRECATED_SYMBOL_NAME (sym), name) < 0) - i = M + 1; - else - U = M; - } - } - else - i = 0; - - for (; i < BLOCK_BUCKETS (block); i += 1) - for (sym = BLOCK_BUCKET (block, i); sym != NULL; sym = sym->hash_next) + ALL_BLOCK_SYMBOLS (block, iter, sym) { if (SYMBOL_DOMAIN (sym) == domain) { int cmp = strncmp (name, DEPRECATED_SYMBOL_NAME (sym), name_len); - if (cmp < 0) - { - if (is_sorted) - { - i = BLOCK_BUCKETS (block); - break; - } - } - else if (cmp == 0 - && is_name_suffix (DEPRECATED_SYMBOL_NAME (sym) + name_len)) + if (cmp == 0 + && is_name_suffix (DEPRECATED_SYMBOL_NAME (sym) + name_len)) { switch (SYMBOL_CLASS (sym)) { @@ -4065,30 +4035,8 @@ ada_add_block_symbols (struct block *block, const char *name, { arg_sym = NULL; found_sym = 0; - if (is_sorted) - { - int U; - i = 0; - U = BLOCK_NSYMS (block) - 1; - while (U - i > 4) - { - int M = (U + i) >> 1; - struct symbol *sym = BLOCK_SYM (block, M); - if (DEPRECATED_SYMBOL_NAME (sym)[0] < '_') - i = M + 1; - else if (DEPRECATED_SYMBOL_NAME (sym)[0] > '_') - U = M - 1; - else if (strcmp (DEPRECATED_SYMBOL_NAME (sym), "_ada_") < 0) - i = M + 1; - else - U = M; - } - } - else - i = 0; - for (; i < BLOCK_BUCKETS (block); i += 1) - for (sym = BLOCK_BUCKET (block, i); sym != NULL; sym = sym->hash_next) + ALL_BLOCK_SYMBOLS (block, iter, sym) { struct symbol *sym = BLOCK_SYM (block, i); @@ -4104,16 +4052,8 @@ ada_add_block_symbols (struct block *block, const char *name, cmp = strncmp (name, DEPRECATED_SYMBOL_NAME (sym) + 5, name_len); } - if (cmp < 0) - { - if (is_sorted) - { - i = BLOCK_BUCKETS (block); - break; - } - } - else if (cmp == 0 - && is_name_suffix (DEPRECATED_SYMBOL_NAME (sym) + name_len + 5)) + if (cmp == 0 + && is_name_suffix (DEPRECATED_SYMBOL_NAME (sym) + name_len + 5)) { switch (SYMBOL_CLASS (sym)) { @@ -4160,7 +4100,7 @@ fill_in_ada_prototype (struct symbol *func) { struct block *b; int nargs, nsyms; - int i; + struct dict_iterator iter; struct type *ftype; struct type *rtype; size_t max_fields; @@ -4186,7 +4126,7 @@ fill_in_ada_prototype (struct symbol *func) max_fields = 8; TYPE_FIELDS (ftype) = (struct field *) xmalloc (sizeof (struct field) * max_fields); - ALL_BLOCK_SYMBOLS (b, i, sym) + ALL_BLOCK_SYMBOLS (b, iter, sym) { GROW_VECT (TYPE_FIELDS (ftype), max_fields, nargs + 1); @@ -4759,8 +4699,8 @@ debug_print_lines (struct linetable *lt) static void debug_print_block (struct block *b) { - int i; - struct symbol *i; + struct dict_iterator iter; + struct symbol *sym; fprintf (stderr, "Block: %p; [0x%lx, 0x%lx]", b, BLOCK_START (b), BLOCK_END (b)); @@ -4769,10 +4709,8 @@ debug_print_block (struct block *b) fprintf (stderr, "\n"); fprintf (stderr, "\t Superblock: %p\n", BLOCK_SUPERBLOCK (b)); fprintf (stderr, "\t Symbols:"); - ALL_BLOCK_SYMBOLS (b, i, sym) + ALL_BLOCK_SYMBOLS (b, iter, sym) { - if (i > 0 && i % 4 == 0) - fprintf (stderr, "\n\t\t "); fprintf (stderr, " %s", DEPRECATED_SYMBOL_NAME (sym)); } fprintf (stderr, "\n"); |