aboutsummaryrefslogtreecommitdiff
path: root/gdb/stabsread.c
diff options
context:
space:
mode:
authorFred Fish <fnf@specifix.com>1992-08-24 00:13:11 +0000
committerFred Fish <fnf@specifix.com>1992-08-24 00:13:11 +0000
commitdac9734e5892a69910e8bc28f0983b05d99b6e3f (patch)
treefdce425624908bc728e0e9c6f580970a124293e7 /gdb/stabsread.c
parentca8820f938c1f65dbd767cd52a6df212b34f4ca3 (diff)
downloadgdb-dac9734e5892a69910e8bc28f0983b05d99b6e3f.zip
gdb-dac9734e5892a69910e8bc28f0983b05d99b6e3f.tar.gz
gdb-dac9734e5892a69910e8bc28f0983b05d99b6e3f.tar.bz2
* coffread.c (decode_type): Call alloc_type to alloc new
types. * stabsread.c (read_array_type, read_range_type, define_symbol): Call alloc_type to alloc new types. * stabsread.c (define_symbol): Move dbl_valu symbol field data from type_obstack to symbol_obstack. * stabsread.c (define_symbol): Move typedef_sym from type_obstack to symbol_obstack. * gdbtypes.h (TYPE_ALLOC): New macro to allocate space for data associated with a type, using the same mechanism as was used to allocate space for the type structure itself. * coffread.c (patch_type, coff_read_struct_type, coff_read_enum_type): Use TYPE_ALLOC. * dwarfread.c (struct_type): Use TYPE_ALLOC. * gdbtypes.c (create_array_type, check_stub_method, allocate_cplus_struct_type): Use TYPE_ALLOC. * mipsread.c (parse_symbol, parse_type): Use TYPE_ALLOC. * stabsread.c (read_struct_type, read_array_type, read_enum_type, read_range_type): Use TYPE_ALLOC.
Diffstat (limited to 'gdb/stabsread.c')
-rw-r--r--gdb/stabsread.c41
1 files changed, 15 insertions, 26 deletions
diff --git a/gdb/stabsread.c b/gdb/stabsread.c
index 79a4d08..f74e435 100644
--- a/gdb/stabsread.c
+++ b/gdb/stabsread.c
@@ -491,7 +491,7 @@ define_symbol (valu, string, desc, type, objfile)
SYMBOL_TYPE (sym) = lookup_fundamental_type (objfile,
FT_DBL_PREC_FLOAT);
dbl_valu = (char *)
- obstack_alloc (&objfile -> type_obstack, sizeof (double));
+ obstack_alloc (&objfile -> symbol_obstack, sizeof (double));
memcpy (dbl_valu, &d, sizeof (double));
SWAP_TARGET_AND_HOST (dbl_valu, sizeof (double));
SYMBOL_VALUE_BYTES (sym) = dbl_valu;
@@ -602,8 +602,7 @@ define_symbol (valu, string, desc, type, objfile)
#if 0
/* This code doesn't work -- it needs to realloc and can't. */
/* Attempt to set up to record a function prototype... */
- struct type *new = (struct type *)
- obstack_alloc (&objfile -> type_obstack, sizeof (struct type));
+ struct type *new = alloc_type (objfile);
/* Generate a template for the type of this function. The
types of the arguments will be added as we read the symbol
@@ -830,7 +829,7 @@ define_symbol (valu, string, desc, type, objfile)
if (synonym)
{
register struct symbol *typedef_sym = (struct symbol *)
- obstack_alloc (&objfile -> type_obstack, sizeof (struct symbol));
+ obstack_alloc (&objfile -> symbol_obstack, sizeof (struct symbol));
memset (typedef_sym, 0, sizeof (struct symbol));
SYMBOL_NAME (typedef_sym) = SYMBOL_NAME (sym);
SYMBOL_TYPE (typedef_sym) = SYMBOL_TYPE (sym);
@@ -1351,7 +1350,7 @@ read_struct_type (pp, type, objfile)
n_baseclasses = read_number (pp, ',');
TYPE_FIELD_VIRTUAL_BITS (type) = (B_TYPE *)
- obstack_alloc (&objfile -> type_obstack, B_BYTES (n_baseclasses));
+ TYPE_ALLOC (type, B_BYTES (n_baseclasses));
B_CLRALL (TYPE_FIELD_VIRTUAL_BITS (type), n_baseclasses);
for (i = 0; i < n_baseclasses; i++)
@@ -1619,7 +1618,7 @@ read_struct_type (pp, type, objfile)
TYPE_NFIELDS (type) = nfields;
TYPE_FIELDS (type) = (struct field *)
- obstack_alloc (&objfile -> type_obstack, sizeof (struct field) * nfields);
+ TYPE_ALLOC (type, sizeof (struct field) * nfields);
memset (TYPE_FIELDS (type), 0, sizeof (struct field) * nfields);
if (non_public_fields)
@@ -1627,11 +1626,11 @@ read_struct_type (pp, type, objfile)
ALLOCATE_CPLUS_STRUCT_TYPE (type);
TYPE_FIELD_PRIVATE_BITS (type) = (B_TYPE *)
- obstack_alloc (&objfile -> type_obstack, B_BYTES (nfields));
+ TYPE_ALLOC (type, B_BYTES (nfields));
B_CLRALL (TYPE_FIELD_PRIVATE_BITS (type), nfields);
TYPE_FIELD_PROTECTED_BITS (type) = (B_TYPE *)
- obstack_alloc (&objfile -> type_obstack, B_BYTES (nfields));
+ TYPE_ALLOC (type, B_BYTES (nfields));
B_CLRALL (TYPE_FIELD_PROTECTED_BITS (type), nfields);
}
@@ -1879,8 +1878,7 @@ read_struct_type (pp, type, objfile)
if (nfn_fields)
{
TYPE_FN_FIELDLISTS (type) = (struct fn_fieldlist *)
- obstack_alloc (&objfile -> type_obstack,
- sizeof (struct fn_fieldlist) * nfn_fields);
+ TYPE_ALLOC (type, sizeof (struct fn_fieldlist) * nfn_fields);
memset (TYPE_FN_FIELDLISTS (type), 0,
sizeof (struct fn_fieldlist) * nfn_fields);
TYPE_NFN_FIELDS (type) = nfn_fields;
@@ -2059,10 +2057,7 @@ read_array_type (pp, type, objfile)
{
/* Create range type. */
- range_type = (struct type *)
- obstack_alloc (&objfile -> type_obstack, sizeof (struct type));
- memset (range_type, 0, sizeof (struct type));
- TYPE_OBJFILE (range_type) = objfile;
+ range_type = alloc_type (objfile);
TYPE_CODE (range_type) = TYPE_CODE_RANGE;
TYPE_TARGET_TYPE (range_type) = index_type;
@@ -2071,7 +2066,7 @@ read_array_type (pp, type, objfile)
TYPE_NFIELDS (range_type) = 2;
TYPE_FIELDS (range_type) = (struct field *)
- obstack_alloc (&objfile -> type_obstack, 2 * sizeof (struct field));
+ TYPE_ALLOC (range_type, 2 * sizeof (struct field));
memset (TYPE_FIELDS (range_type), 0, 2 * sizeof (struct field));
TYPE_FIELD_BITPOS (range_type, 0) = lower;
TYPE_FIELD_BITPOS (range_type, 1) = upper;
@@ -2082,7 +2077,7 @@ read_array_type (pp, type, objfile)
TYPE_LENGTH (type) = (upper - lower + 1) * TYPE_LENGTH (element_type);
TYPE_NFIELDS (type) = 1;
TYPE_FIELDS (type) = (struct field *)
- obstack_alloc (&objfile -> type_obstack, sizeof (struct field));
+ TYPE_ALLOC (type, sizeof (struct field));
memset (TYPE_FIELDS (type), 0, sizeof (struct field));
TYPE_FIELD_TYPE (type, 0) = range_type;
@@ -2161,7 +2156,7 @@ read_enum_type (pp, type, objfile)
TYPE_FLAGS (type) &= ~TYPE_FLAG_STUB;
TYPE_NFIELDS (type) = nsyms;
TYPE_FIELDS (type) = (struct field *)
- obstack_alloc (&objfile -> type_obstack, sizeof (struct field) * nsyms);
+ TYPE_ALLOC (type, sizeof (struct field) * nsyms);
memset (TYPE_FIELDS (type), 0, sizeof (struct field) * nsyms);
/* Find the symbols for the values and put them into the type.
@@ -2505,10 +2500,7 @@ read_range_type (pp, typenums, objfile)
if (got_signed || got_unsigned)
{
- result_type = (struct type *)
- obstack_alloc (&objfile -> type_obstack, sizeof (struct type));
- memset (result_type, 0, sizeof (struct type));
- TYPE_OBJFILE (result_type) = objfile;
+ result_type = alloc_type (objfile);
TYPE_LENGTH (result_type) = nbits / TARGET_CHAR_BIT;
TYPE_CODE (result_type) = TYPE_CODE_INT;
if (got_unsigned)
@@ -2617,10 +2609,7 @@ read_range_type (pp, typenums, objfile)
if (self_subrange)
return error_type (pp);
- result_type = (struct type *)
- obstack_alloc (&objfile -> type_obstack, sizeof (struct type));
- memset (result_type, 0, sizeof (struct type));
- TYPE_OBJFILE (result_type) = objfile;
+ result_type = alloc_type (objfile);
TYPE_CODE (result_type) = TYPE_CODE_RANGE;
@@ -2632,7 +2621,7 @@ read_range_type (pp, typenums, objfile)
TYPE_NFIELDS (result_type) = 2;
TYPE_FIELDS (result_type) = (struct field *)
- obstack_alloc (&objfile -> type_obstack, 2 * sizeof (struct field));
+ TYPE_ALLOC (result_type, 2 * sizeof (struct field));
memset (TYPE_FIELDS (result_type), 0, 2 * sizeof (struct field));
TYPE_FIELD_BITPOS (result_type, 0) = n2;
TYPE_FIELD_BITPOS (result_type, 1) = n3;