/* Block-related functions for the GNU debugger, GDB.
- Copyright 2003 Free Software Foundation, Inc.
+ Copyright (C) 2003 Free Software Foundation, Inc.
This file is part of GDB.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA. */
+ Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA. */
#include "defs.h"
#include "block.h"
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;
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);
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;
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;
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;
+}