2004-08-12 Andrew Cagney <cagney@gnu.org>
[deliverable/binutils-gdb.git] / gdb / block.c
index 09c51b69c47b266284b14336c47163134355c706..28b1181ffe861596f87edf08dacecb1e341a5841 100644 (file)
@@ -44,7 +44,7 @@ static void block_initialize_namespace (struct block *block,
    Return zero otherwise. */
 
 int
-contained_in (struct block *a, struct block *b)
+contained_in (const struct block *a, const struct block *b)
 {
   if (!a || !b)
     return 0;
@@ -57,7 +57,7 @@ contained_in (struct block *a, struct block *b)
    lexical block, described by a struct block BL.  */
 
 struct symbol *
-block_function (struct block *bl)
+block_function (const struct block *bl)
 {
   while (BLOCK_FUNCTION (bl) == 0 && BLOCK_SUPERBLOCK (bl) != 0)
     bl = BLOCK_SUPERBLOCK (bl);
@@ -71,7 +71,7 @@ block_function (struct block *bl)
    is NULL, we don't pass this information back to the caller.  */
 
 struct blockvector *
-blockvector_for_pc_sect (CORE_ADDR pc, struct sec *section,
+blockvector_for_pc_sect (CORE_ADDR pc, struct bfd_section *section,
                         int *pindex, struct symtab *symtab)
 {
   struct block *b;
@@ -136,7 +136,7 @@ blockvector_for_pc (CORE_ADDR pc, int *pindex)
    in the specified section, or 0 if there is none.  */
 
 struct block *
-block_for_pc_sect (CORE_ADDR pc, struct sec *section)
+block_for_pc_sect (CORE_ADDR pc, struct bfd_section *section)
 {
   struct blockvector *bl;
   int index;
@@ -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;
+}
This page took 0.025664 seconds and 4 git commands to generate.