aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2023-01-20 07:12:02 -0700
committerTom Tromey <tom@tromey.com>2023-02-19 12:51:06 -0700
commit44bb9f9e7a7adc13f0b944ed76ddc459d5bb21f7 (patch)
tree29a6801bde95b2bc83c001e8e71041ec394aae57
parent69fb3874a70c8860d5eb6f2506cce673fced8ee6 (diff)
downloadgdb-44bb9f9e7a7adc13f0b944ed76ddc459d5bb21f7.zip
gdb-44bb9f9e7a7adc13f0b944ed76ddc459d5bb21f7.tar.gz
gdb-44bb9f9e7a7adc13f0b944ed76ddc459d5bb21f7.tar.bz2
Use 'new' for block and global_block
This changes block and global_block to add initializers, and then to use 'new' for allocation.
-rw-r--r--gdb/block.c6
-rw-r--r--gdb/block.h20
2 files changed, 12 insertions, 14 deletions
diff --git a/gdb/block.c b/gdb/block.c
index 0870793..8f15cdf 100644
--- a/gdb/block.c
+++ b/gdb/block.c
@@ -389,9 +389,7 @@ block::global_block () const
struct block *
allocate_block (struct obstack *obstack)
{
- struct block *bl = OBSTACK_ZALLOC (obstack, struct block);
-
- return bl;
+ return new (obstack) struct block;
}
/* Allocate a global block. */
@@ -399,7 +397,7 @@ allocate_block (struct obstack *obstack)
struct block *
allocate_global_block (struct obstack *obstack)
{
- struct global_block *bl = OBSTACK_ZALLOC (obstack, struct global_block);
+ struct global_block *bl = new (obstack) struct global_block;
return &bl->block;
}
diff --git a/gdb/block.h b/gdb/block.h
index 6ccf376..9a60140 100644
--- a/gdb/block.h
+++ b/gdb/block.h
@@ -105,7 +105,7 @@ struct blockranges
This implies that within the body of one function
the blocks appear in the order of a depth-first tree walk. */
-struct block
+struct block : public allocate_on_obstack
{
/* Return this block's start address. */
CORE_ADDR start () const
@@ -273,13 +273,13 @@ struct block
/* Addresses in the executable code that are in this block. */
- CORE_ADDR m_start;
- CORE_ADDR m_end;
+ CORE_ADDR m_start = 0;
+ CORE_ADDR m_end = 0;
/* The symbol that names this block, if the block is the body of a
function (real or inlined); otherwise, zero. */
- struct symbol *m_function;
+ struct symbol *m_function = nullptr;
/* The `struct block' for the containing block, or 0 if none.
@@ -287,22 +287,22 @@ struct block
case of C) is the STATIC_BLOCK. The superblock of the
STATIC_BLOCK is the GLOBAL_BLOCK. */
- const struct block *m_superblock;
+ const struct block *m_superblock = nullptr;
/* This is used to store the symbols in the block. */
- struct multidictionary *m_multidict;
+ struct multidictionary *m_multidict = nullptr;
/* Contains information about namespace-related info relevant to this block:
using directives and the current namespace scope. */
- struct block_namespace_info *m_namespace_info;
+ struct block_namespace_info *m_namespace_info = nullptr;
/* Address ranges for blocks with non-contiguous ranges. If this
is NULL, then there is only one range which is specified by
startaddr and endaddr above. */
- struct blockranges *m_ranges;
+ struct blockranges *m_ranges = nullptr;
private:
@@ -314,7 +314,7 @@ private:
/* The global block is singled out so that we can provide a back-link
to the compunit symtab. */
-struct global_block
+struct global_block : public allocate_on_obstack
{
/* The block. */
@@ -322,7 +322,7 @@ struct global_block
/* This holds a pointer to the compunit symtab holding this block. */
- struct compunit_symtab *compunit_symtab;
+ struct compunit_symtab *compunit_symtab = nullptr;
};
struct blockvector