[rfa] use allocate_block more

David Carlton
2003-09-11T23:28:36Z

On Tue, 9 Sep 2003 15:51:37 -0400, Elena Zannoni <ezannoni@redhat.com> said:

> I think it would make sense, in a next pass, to have all the creation
> of blocks go through the new function.

Well, I was planning to do that; here's what I came up with instead.
The problem is that mdebugread.c currently doesn't allocate blocks on
an obstack at all! That should presumably be fixed ("rm mdebugread.c"
would be my preferred method), but I didn't feel like doing that
right now; I'd rather leave it up to somebody with access to a machine
using mdebugread.

Tested on i686-pc-linux-gnu, GCC 3.2, DWARF 2; no new regressions. OK
to commit?

David Carlton
carlton@kealia.com

2003-09-11 David Carlton <carlton@kealia.com>

* buildsym.c (finish_block): Use allocate_block to allocate the
block.
* mdebugread.c (new_block): Add FIXME.

Index: buildsym.c
===================================================================
RCS file: /cvs/src/src/gdb/buildsym.c,v
retrieving revision 1.33
diff -u -p -r1.33 buildsym.c
--- buildsym.c 11 Jun 2003 23:29:46 -0000 1.33
+++ buildsym.c 11 Sep 2003 22:58:08 -0000
@@ -231,19 +231,15 @@ finish_block (struct symbol *symbol, str
register struct pending_block *pblock;
struct pending_block *opblock;

- /* Initialize the block's dictionary. */
+ block = allocate_block (&objfile->symbol_obstack);

if (symbol)
{
- block = (struct block *)
- obstack_alloc (&objfile->symbol_obstack, sizeof (struct block));
BLOCK_DICT (block) = dict_create_linear (&objfile->symbol_obstack,
*listhead);
}
else
{
- block = (struct block *)
- obstack_alloc (&objfile->symbol_obstack, sizeof (struct block));
BLOCK_DICT (block) = dict_create_hashed (&objfile->symbol_obstack,
*listhead);
}
Index: mdebugread.c
===================================================================
RCS file: /cvs/src/src/gdb/mdebugread.c,v
retrieving revision 1.47
diff -u -p -r1.47 mdebugread.c
--- mdebugread.c 11 Jun 2003 23:29:47 -0000 1.47
+++ mdebugread.c 11 Sep 2003 22:58:14 -0000
@@ -4696,6 +4696,9 @@ new_bvect (int nblocks)
static struct block *
new_block (enum block_type type)
{
+ /* FIXME: carlton/2003-09-11: This should use allocate_block to
+ allocate the block. Which, in turn, suggests that the block
+ should be allocated on an obstack. */
struct block *retval = xzalloc (sizeof (struct block));

if (type == FUNCTION_BLOCK)