diff options
Diffstat (limited to 'gdb/block.c')
-rw-r--r-- | gdb/block.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/gdb/block.c b/gdb/block.c index 98b6ccbb84b..8729a24b576 100644 --- a/gdb/block.c +++ b/gdb/block.c @@ -268,3 +268,28 @@ block_global_block (const struct block *block) return block; } + +/* Allocate a block on OBSTACK, and initialize its elements to + zero/NULL. This is useful for creating "dummy" blocks that don't + correspond to actual source files. + + Warning: it sets the block's BLOCK_DICT to NULL, which isn't a + valid value. If you really don't want the block to have a + dictionary, then you should subsequently set its BLOCK_DICT to + dict_create_linear (obstack, NULL). */ + +struct block * +allocate_block (struct obstack *obstack) +{ + struct block *bl = obstack_alloc (obstack, sizeof (struct block)); + + BLOCK_START (bl) = 0; + BLOCK_END (bl) = 0; + BLOCK_FUNCTION (bl) = NULL; + BLOCK_SUPERBLOCK (bl) = NULL; + BLOCK_DICT (bl) = NULL; + BLOCK_NAMESPACE (bl) = NULL; + BLOCK_GCC_COMPILED (bl) = 0; + + return bl; +} |