\f
static int compare_line_numbers (const void *ln1p, const void *ln2p);
+
+static void record_pending_block (struct objfile *objfile,
+ struct block *block,
+ struct pending_block *opblock);
\f
/* Initial sizes of data structures. These are realloc'd larger if
/* Maintain the lists of symbols and blocks. */
-/* Add a pending list to free_pendings. */
-void
-add_free_pendings (struct pending *list)
-{
- struct pending *link = list;
-
- if (list)
- {
- while (link->next) link = link->next;
- link->next = free_pendings;
- free_pendings = list;
- }
-}
-
/* Add a symbol to one of the lists of symbols. */
void
find_symbol_in_list (struct pending *list, char *name, int length)
{
int j;
- char *pp;
+ const char *pp;
while (list != NULL)
{
the order the symbols have in the list (reversed from the input
file). Put the block on the list of pending blocks. */
-struct block *
-finish_block (struct symbol *symbol, struct pending **listhead,
- struct pending_block *old_blocks,
- CORE_ADDR start, CORE_ADDR end,
- struct objfile *objfile)
+static struct block *
+finish_block_internal (struct symbol *symbol, struct pending **listhead,
+ struct pending_block *old_blocks,
+ CORE_ADDR start, CORE_ADDR end,
+ struct objfile *objfile,
+ int is_global)
{
struct gdbarch *gdbarch = get_objfile_arch (objfile);
struct pending *next, *next1;
struct pending_block *pblock;
struct pending_block *opblock;
- block = allocate_block (&objfile->objfile_obstack);
+ block = (is_global
+ ? allocate_global_block (&objfile->objfile_obstack)
+ : allocate_block (&objfile->objfile_obstack));
if (symbol)
{
BLOCK_START (block) = start;
BLOCK_END (block) = end;
- /* Superblock filled in when containing block is made. */
- BLOCK_SUPERBLOCK (block) = NULL;
- BLOCK_NAMESPACE (block) = NULL;
/* Put the block in as the value of the symbol that names it. */
parameter symbols. */
int nparams = 0, iparams;
struct symbol *sym;
- ALL_BLOCK_SYMBOLS (block, iter, sym)
+
+ /* Here we want to directly access the dictionary, because
+ we haven't fully initialized the block yet. */
+ ALL_DICT_SYMBOLS (BLOCK_DICT (block), iter, sym)
{
if (SYMBOL_IS_ARGUMENT (sym))
nparams++;
TYPE_ALLOC (ftype, nparams * sizeof (struct field));
iparams = 0;
- ALL_BLOCK_SYMBOLS (block, iter, sym)
+ /* Here we want to directly access the dictionary, because
+ we haven't fully initialized the block yet. */
+ ALL_DICT_SYMBOLS (BLOCK_DICT (block), iter, sym)
{
if (iparams == nparams)
break;
return block;
}
+struct block *
+finish_block (struct symbol *symbol, struct pending **listhead,
+ struct pending_block *old_blocks,
+ CORE_ADDR start, CORE_ADDR end,
+ struct objfile *objfile)
+{
+ return finish_block_internal (symbol, listhead, old_blocks,
+ start, end, objfile, 0);
+}
/* Record BLOCK on the list of all blocks in the file. Put it after
OPBLOCK, or at the beginning if opblock is NULL. This puts the
Allocate the pending block struct in the objfile_obstack to save
time. This wastes a little space. FIXME: Is it worth it? */
-void
+static void
record_pending_block (struct objfile *objfile, struct block *block,
struct pending_block *opblock)
{
blockvector. */
finish_block (0, &file_symbols, 0, last_source_start_addr,
end_addr, objfile);
- finish_block (0, &global_symbols, 0, last_source_start_addr,
- end_addr, objfile);
+ finish_block_internal (0, &global_symbols, 0, last_source_start_addr,
+ end_addr, objfile, 1);
blockvector = make_blockvector (objfile);
}
if (symtab)
{
symtab->primary = 1;
+
+ if (symtab->blockvector)
+ {
+ struct block *b = BLOCKVECTOR_BLOCK (symtab->blockvector,
+ GLOBAL_BLOCK);
+
+ set_block_symtab (b, symtab);
+ }
}
/* Default any symbols without a specified symtab to the primary
if (SYMBOL_SYMTAB (BLOCK_FUNCTION (block)) == NULL)
SYMBOL_SYMTAB (BLOCK_FUNCTION (block)) = symtab;
- for (sym = dict_iterator_first (BLOCK_DICT (block), &iter);
- sym != NULL;
- sym = dict_iterator_next (&iter))
+ /* Note that we only want to fix up symbols from the local
+ blocks, not blocks coming from included symtabs. */
+ ALL_DICT_SYMBOLS (BLOCK_DICT (block), iter, sym)
if (SYMBOL_SYMTAB (sym) == NULL)
SYMBOL_SYMTAB (sym) = symtab;
}
/* Compute a small integer hash code for the given name. */
int
-hashname (char *name)
+hashname (const char *name)
{
return (hash(name,strlen(name)) % HASHSIZE);
}