set_block_symtab.
* jit.c (finalize_symtab): Use allocate_global_block,
set_block_symtab.
* buildsym.c (finish_block_internal): New function, from old
finish_block.
(finish_block): Rewrite.
(end_symtab): Use finish_block_internal, set_block_symtab.
* block.h (struct global_block): New.
(allocate_global_block, set_block_symtab): Declare.
* block.c (allocate_global_block, set_block_symtab): New
functions.
+2012-05-10 Tom Tromey <tromey@redhat.com>
+
+ * jv-lang.c (get_java_class_symtab): Use allocate_global_block,
+ set_block_symtab.
+ * jit.c (finalize_symtab): Use allocate_global_block,
+ set_block_symtab.
+ * buildsym.c (finish_block_internal): New function, from old
+ finish_block.
+ (finish_block): Rewrite.
+ (end_symtab): Use finish_block_internal, set_block_symtab.
+ * block.h (struct global_block): New.
+ (allocate_global_block, set_block_symtab): Declare.
+ * block.c (allocate_global_block, set_block_symtab): New
+ functions.
+
2012-05-10 Tom Tromey <tromey@redhat.com>
* psymtab.c (partial_map_expand_apply): Add assertion.
return bl;
}
+/* Allocate a global block. */
+
+struct block *
+allocate_global_block (struct obstack *obstack)
+{
+ struct global_block *bl = OBSTACK_ZALLOC (obstack, struct global_block);
+
+ return &bl->block;
+}
+
+/* Set the symtab of the global block. */
+
+void
+set_block_symtab (struct block *block, struct symtab *symtab)
+{
+ struct global_block *gb;
+
+ gdb_assert (BLOCK_SUPERBLOCK (block) == NULL);
+ gb = (struct global_block *) block;
+ gdb_assert (gb->symtab == NULL);
+ gb->symtab = symtab;
+}
+
\f
/* See block.h. */
language_specific;
};
+/* The global block is singled out so that we can provide a back-link
+ to the primary symtab. */
+
+struct global_block
+{
+ /* The block. */
+
+ struct block block;
+
+ /* This holds a pointer to the primary symtab holding this
+ block. */
+
+ struct symtab *symtab;
+};
+
#define BLOCK_START(bl) (bl)->startaddr
#define BLOCK_END(bl) (bl)->endaddr
#define BLOCK_FUNCTION(bl) (bl)->function
extern struct block *allocate_block (struct obstack *obstack);
+extern struct block *allocate_global_block (struct obstack *obstack);
+
+extern void set_block_symtab (struct block *, struct symtab *);
/* A block iterator. This structure should be treated as though it
were opaque; it is only defined here because we want to support
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. */
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
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
block_iter = NULL;
for (i = 0; i < FIRST_LOCAL_BLOCK; i++)
{
- struct block *new_block = allocate_block (&objfile->objfile_obstack);
+ struct block *new_block;
+
+ new_block = (i == GLOBAL_BLOCK
+ ? allocate_global_block (&objfile->objfile_obstack)
+ : allocate_block (&objfile->objfile_obstack));
BLOCK_DICT (new_block) = dict_create_linear (&objfile->objfile_obstack,
NULL);
BLOCK_SUPERBLOCK (new_block) = block_iter;
BLOCK_END (new_block) = (CORE_ADDR) end;
BLOCKVECTOR_BLOCK (symtab->blockvector, i) = new_block;
+
+ if (i == GLOBAL_BLOCK)
+ set_block_symtab (new_block, symtab);
}
/* Fill up the superblock fields for the real blocks, using the
BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK) = bl;
/* Allocate GLOBAL_BLOCK. */
- bl = allocate_block (&objfile->objfile_obstack);
+ bl = allocate_global_block (&objfile->objfile_obstack);
BLOCK_DICT (bl) = dict_create_hashed_expandable ();
+ set_block_symtab (bl, class_symtab);
BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK) = bl;
/* Arrange to free the dict. */