aboutsummaryrefslogtreecommitdiff
path: root/gdb/mdebugread.c
diff options
context:
space:
mode:
authorDavid Carlton <carlton@bactrian.org>2003-06-11 23:29:49 +0000
committerDavid Carlton <carlton@bactrian.org>2003-06-11 23:29:49 +0000
commitde4f826b0f698dc2858f6eda71f2613a89579c50 (patch)
tree13525aa41c328ee4018f4feb9c45ad204fee014f /gdb/mdebugread.c
parentcdfbf930b96d5ae51342f34dd180323a8011f8ef (diff)
downloadgdb-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/mdebugread.c')
-rw-r--r--gdb/mdebugread.c143
1 files changed, 41 insertions, 102 deletions
diff --git a/gdb/mdebugread.c b/gdb/mdebugread.c
index 787b95b..1bb1e05 100644
--- a/gdb/mdebugread.c
+++ b/gdb/mdebugread.c
@@ -54,6 +54,7 @@
#include "demangle.h"
#include "gdb_assert.h"
#include "block.h"
+#include "dictionary.h"
/* These are needed if the tm.h file does not contain the necessary
mips specific definitions. */
@@ -284,9 +285,11 @@ static struct symbol *new_symbol (char *);
static struct type *new_type (char *);
-static struct block *new_block (int);
+enum block_type { FUNCTION_BLOCK, NON_FUNCTION_BLOCK };
-static struct symtab *new_symtab (char *, int, int, struct objfile *);
+static struct block *new_block (enum block_type);
+
+static struct symtab *new_symtab (char *, int, struct objfile *);
static struct linetable *new_linetable (int);
@@ -298,8 +301,6 @@ static struct type *parse_type (int, union aux_ext *, unsigned int, int *,
static struct symbol *mylookup_symbol (char *, struct block *, domain_enum,
enum address_class);
-static struct block *shrink_block (struct block *, struct symtab *);
-
static void sort_blocks (struct symtab *);
static struct partial_symtab *new_psymtab (char *, struct objfile *);
@@ -483,7 +484,6 @@ static struct parse_stack
int blocktype;
- int maxsyms; /* Max symbols in this block. */
struct type *cur_type; /* Type we parse fields for. */
int cur_field; /* Field number in cur_type. */
CORE_ADDR procadr; /* Start addres of this procedure */
@@ -834,7 +834,7 @@ parse_symbol (SYMR *sh, union aux_ext *ax, char *ext_sh, int bigend,
TYPE_FLAGS (SYMBOL_TYPE (s)) |= TYPE_FLAG_PROTOTYPED;
/* Create and enter a new lexical context */
- b = new_block (top_stack->maxsyms);
+ b = new_block (FUNCTION_BLOCK);
SYMBOL_BLOCK_VALUE (s) = b;
BLOCK_FUNCTION (b) = s;
BLOCK_START (b) = BLOCK_END (b) = sh->value;
@@ -1169,7 +1169,7 @@ parse_symbol (SYMR *sh, union aux_ext *ax, char *ext_sh, int bigend,
}
top_stack->blocktype = stBlock;
- b = new_block (top_stack->maxsyms);
+ b = new_block (NON_FUNCTION_BLOCK);
BLOCK_START (b) = sh->value + top_stack->procadr;
BLOCK_SUPERBLOCK (b) = top_stack->cur_block;
top_stack->cur_block = b;
@@ -1189,7 +1189,7 @@ parse_symbol (SYMR *sh, union aux_ext *ax, char *ext_sh, int bigend,
/* Finished with procedure */
struct blockvector *bv = BLOCKVECTOR (top_stack->cur_st);
struct mips_extra_func_info *e;
- struct block *b;
+ struct block *b = top_stack->cur_block;
struct type *ftype = top_stack->cur_type;
int i;
@@ -1209,9 +1209,6 @@ parse_symbol (SYMR *sh, union aux_ext *ax, char *ext_sh, int bigend,
e->pdr.framereg = -1;
add_symbol (s, top_stack->cur_block);
- /* Reallocate symbols, saving memory */
- b = shrink_block (top_stack->cur_block, top_stack->cur_st);
-
/* f77 emits proc-level with address bounds==[0,0],
So look for such child blocks, and patch them. */
for (i = 0; i < BLOCKVECTOR_NBLOCKS (bv); i++)
@@ -1236,13 +1233,17 @@ parse_symbol (SYMR *sh, union aux_ext *ax, char *ext_sh, int bigend,
if (nparams > 0)
{
+ struct dict_iterator iter;
TYPE_NFIELDS (ftype) = nparams;
TYPE_FIELDS (ftype) = (struct field *)
TYPE_ALLOC (ftype, nparams * sizeof (struct field));
- for (i = iparams = 0; iparams < nparams; i++)
+ iparams = 0;
+ ALL_BLOCK_SYMBOLS (b, iter, sym)
{
- sym = BLOCK_SYM (b, i);
+ if (iparams == nparams)
+ break;
+
switch (SYMBOL_CLASS (sym))
{
case LOC_ARG:
@@ -1266,7 +1267,6 @@ parse_symbol (SYMR *sh, union aux_ext *ax, char *ext_sh, int bigend,
displacement from the procedure`s start address of the
end of this block. */
BLOCK_END (top_stack->cur_block) = sh->value + top_stack->procadr;
- shrink_block (top_stack->cur_block, top_stack->cur_st);
}
else if (sh->sc == scText && top_stack->blocktype == stNil)
{
@@ -4061,19 +4061,15 @@ psymtab_to_symtab_1 (struct partial_symtab *pst, char *filename)
int maxlines;
EXTR *ext_ptr;
- /* How many symbols will we need */
- /* FIXME, this does not count enum values. */
- f_max = pst->n_global_syms + pst->n_static_syms;
if (fh == 0)
{
maxlines = 0;
- st = new_symtab ("unknown", f_max, 0, pst->objfile);
+ st = new_symtab ("unknown", 0, pst->objfile);
}
else
{
- f_max += fh->csym + fh->cpd;
maxlines = 2 * fh->cline;
- st = new_symtab (pst->filename, 2 * f_max, maxlines, pst->objfile);
+ st = new_symtab (pst->filename, maxlines, pst->objfile);
/* The proper language was already determined when building
the psymtab, use it. */
@@ -4093,7 +4089,6 @@ psymtab_to_symtab_1 (struct partial_symtab *pst, char *filename)
BLOCK_START (top_stack->cur_block) = pst->textlow;
BLOCK_END (top_stack->cur_block) = 0;
top_stack->blocktype = stFile;
- top_stack->maxsyms = 2 * f_max;
top_stack->cur_type = 0;
top_stack->procadr = 0;
top_stack->numargs = 0;
@@ -4177,10 +4172,6 @@ psymtab_to_symtab_1 (struct partial_symtab *pst, char *filename)
top_stack->cur_block = BLOCKVECTOR_BLOCK (BLOCKVECTOR (top_stack->cur_st),
GLOBAL_BLOCK);
top_stack->blocktype = stFile;
- top_stack->maxsyms
- = (debug_info->symbolic_header.isymMax
- + debug_info->symbolic_header.ipdMax
- + debug_info->symbolic_header.iextMax);
ext_ptr = PST_PRIVATE (pst)->extern_tab;
for (i = PST_PRIVATE (pst)->extern_count; --i >= 0; ext_ptr++)
@@ -4450,11 +4441,12 @@ static struct symbol *
mylookup_symbol (char *name, register struct block *block,
domain_enum domain, enum address_class class)
{
- int i, inc;
+ struct dict_iterator iter;
+ int inc;
struct symbol *sym;
inc = name[0];
- ALL_BLOCK_SYMBOLS (block, i, sym)
+ ALL_BLOCK_SYMBOLS (block, iter, sym)
{
if (DEPRECATED_SYMBOL_NAME (sym)[0] == inc
&& SYMBOL_DOMAIN (sym) == domain
@@ -4470,41 +4462,12 @@ mylookup_symbol (char *name, register struct block *block,
}
-/* Add a new symbol S to a block B.
- Infrequently, we will need to reallocate the block to make it bigger.
- We only detect this case when adding to top_stack->cur_block, since
- that's the only time we know how big the block is. FIXME. */
+/* Add a new symbol S to a block B. */
static void
add_symbol (struct symbol *s, struct block *b)
{
- int nsyms = BLOCK_NSYMS (b)++;
- struct block *origb;
- struct parse_stack *stackp;
-
- if (b == top_stack->cur_block &&
- nsyms >= top_stack->maxsyms)
- {
- complaint (&symfile_complaints, "block containing %s overfilled",
- DEPRECATED_SYMBOL_NAME (s));
- /* In this case shrink_block is actually grow_block, since
- BLOCK_NSYMS(b) is larger than its current size. */
- origb = b;
- b = shrink_block (top_stack->cur_block, top_stack->cur_st);
-
- /* Now run through the stack replacing pointers to the
- original block. shrink_block has already done this
- for the blockvector and BLOCK_FUNCTION. */
- for (stackp = top_stack; stackp; stackp = stackp->next)
- {
- if (stackp->cur_block == origb)
- {
- stackp->cur_block = b;
- stackp->maxsyms = BLOCK_NSYMS (b);
- }
- }
- }
- BLOCK_SYM (b, nsyms) = s;
+ dict_add_symbol (BLOCK_DICT (b), s);
}
/* Add a new block B to a symtab S */
@@ -4626,11 +4589,11 @@ sort_blocks (struct symtab *s)
/* Constructor/restructor/destructor procedures */
-/* Allocate a new symtab for NAME. Needs an estimate of how many symbols
- MAXSYMS and linenumbers MAXLINES we'll put in it */
+/* Allocate a new symtab for NAME. Needs an estimate of how many
+ linenumbers MAXLINES we'll put in it */
static struct symtab *
-new_symtab (char *name, int maxsyms, int maxlines, struct objfile *objfile)
+new_symtab (char *name, int maxlines, struct objfile *objfile)
{
struct symtab *s = allocate_symtab (name, objfile);
@@ -4638,8 +4601,10 @@ new_symtab (char *name, int maxsyms, int maxlines, struct objfile *objfile)
/* All symtabs must have at least two blocks */
BLOCKVECTOR (s) = new_bvect (2);
- BLOCKVECTOR_BLOCK (BLOCKVECTOR (s), GLOBAL_BLOCK) = new_block (maxsyms);
- BLOCKVECTOR_BLOCK (BLOCKVECTOR (s), STATIC_BLOCK) = new_block (maxsyms);
+ BLOCKVECTOR_BLOCK (BLOCKVECTOR (s), GLOBAL_BLOCK)
+ = new_block (NON_FUNCTION_BLOCK);
+ BLOCKVECTOR_BLOCK (BLOCKVECTOR (s), STATIC_BLOCK)
+ = new_block (NON_FUNCTION_BLOCK);
BLOCK_SUPERBLOCK (BLOCKVECTOR_BLOCK (BLOCKVECTOR (s), STATIC_BLOCK)) =
BLOCKVECTOR_BLOCK (BLOCKVECTOR (s), GLOBAL_BLOCK);
@@ -4723,48 +4688,22 @@ new_bvect (int nblocks)
return bv;
}
-/* Allocate and zero a new block of MAXSYMS symbols */
+/* Allocate and zero a new block, and set its BLOCK_DICT. If function
+ is non-zero, assume the block is associated to a function, and make
+ sure that the symbols are stored linearly; otherwise, store them
+ hashed. */
static struct block *
-new_block (int maxsyms)
+new_block (enum block_type type)
{
- int size = sizeof (struct block) + (maxsyms - 1) * sizeof (struct symbol *);
-
- return (struct block *) xzalloc (size);
-}
+ struct block *retval = xzalloc (sizeof (struct block));
-/* Ooops, too big. Shrink block B in symtab S to its minimal size.
- Shrink_block can also be used by add_symbol to grow a block. */
-
-static struct block *
-shrink_block (struct block *b, struct symtab *s)
-{
- struct block *new;
- struct blockvector *bv = BLOCKVECTOR (s);
- int i;
+ if (type == FUNCTION_BLOCK)
+ BLOCK_DICT (retval) = dict_create_linear_expandable ();
+ else
+ BLOCK_DICT (retval) = dict_create_hashed_expandable ();
- /* Just reallocate it and fix references to the old one */
-
- new = (struct block *) xrealloc ((void *) b,
- (sizeof (struct block)
- + ((BLOCK_NSYMS (b) - 1)
- * sizeof (struct symbol *))));
-
- /* FIXME: Not worth hashing this block as it's built. */
- /* All callers should have created the block with new_block (), which
- would mean it was not previously hashed. Make sure. */
- gdb_assert (BLOCK_HASHTABLE (new) == 0);
-
- /* Should chase pointers to old one. Fortunately, that`s just
- the block`s function and inferior blocks */
- if (BLOCK_FUNCTION (new) && SYMBOL_BLOCK_VALUE (BLOCK_FUNCTION (new)) == b)
- SYMBOL_BLOCK_VALUE (BLOCK_FUNCTION (new)) = new;
- for (i = 0; i < BLOCKVECTOR_NBLOCKS (bv); i++)
- if (BLOCKVECTOR_BLOCK (bv, i) == b)
- BLOCKVECTOR_BLOCK (bv, i) = new;
- else if (BLOCK_SUPERBLOCK (BLOCKVECTOR_BLOCK (bv, i)) == b)
- BLOCK_SUPERBLOCK (BLOCKVECTOR_BLOCK (bv, i)) = new;
- return new;
+ return retval;
}
/* Create a new symbol with printname NAME */
@@ -4901,7 +4840,7 @@ fixup_sigtramp (void)
TYPE_TARGET_TYPE (SYMBOL_TYPE (s)) = mdebug_type_void;
/* Need a block to allocate MIPS_EFI_SYMBOL_NAME in */
- b = new_block (1);
+ b = new_block (NON_FUNCTION_BLOCK);
SYMBOL_BLOCK_VALUE (s) = b;
BLOCK_START (b) = sigtramp_address;
BLOCK_END (b) = sigtramp_end;
@@ -4944,7 +4883,7 @@ fixup_sigtramp (void)
current_objfile = NULL;
}
- BLOCK_SYM (b, BLOCK_NSYMS (b)++) = s;
+ dict_add_symbol (BLOCK_DICT (b), s);
}
#endif /* TM_MIPS_H */