* lib/mi-support.exp (mi_gdb_load): Fix typo.
[deliverable/binutils-gdb.git] / gdb / block.c
index 3396c8aa96c442903c09be8036f8e0793ce91996..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,17 +71,18 @@ block_function (struct block *bl)
    is NULL, we don't pass this information back to the caller.  */
 
 struct blockvector *
-blockvector_for_pc_sect (register CORE_ADDR pc, struct sec *section,
+blockvector_for_pc_sect (CORE_ADDR pc, struct bfd_section *section,
                         int *pindex, struct symtab *symtab)
 {
-  register struct block *b;
-  register int bot, top, half;
+  struct block *b;
+  int bot, top, half;
   struct blockvector *bl;
 
   if (symtab == 0)             /* if no symtab specified by caller */
     {
       /* First search all symtabs for one whose file contains our pc */
-      if ((symtab = find_pc_sect_symtab (pc, section)) == 0)
+      symtab = find_pc_sect_symtab (pc, section);
+      if (symtab == 0)
        return 0;
     }
 
@@ -125,7 +126,7 @@ blockvector_for_pc_sect (register CORE_ADDR pc, struct sec *section,
    Backward compatibility, no section.  */
 
 struct blockvector *
-blockvector_for_pc (register CORE_ADDR pc, int *pindex)
+blockvector_for_pc (CORE_ADDR pc, int *pindex)
 {
   return blockvector_for_pc_sect (pc, find_pc_mapped_section (pc),
                                  pindex, NULL);
@@ -135,9 +136,9 @@ blockvector_for_pc (register CORE_ADDR pc, int *pindex)
    in the specified section, or 0 if there is none.  */
 
 struct block *
-block_for_pc_sect (register CORE_ADDR pc, struct sec *section)
+block_for_pc_sect (CORE_ADDR pc, struct bfd_section *section)
 {
-  register struct blockvector *bl;
+  struct blockvector *bl;
   int index;
 
   bl = blockvector_for_pc_sect (pc, section, &index, NULL);
@@ -150,7 +151,7 @@ block_for_pc_sect (register CORE_ADDR pc, struct sec *section)
    or 0 if there is none.  Backward compatibility, no section.  */
 
 struct block *
-block_for_pc (register CORE_ADDR pc)
+block_for_pc (CORE_ADDR pc)
 {
   return block_for_pc_sect (pc, find_pc_mapped_section (pc));
 }
@@ -267,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.028586 seconds and 4 git commands to generate.