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.
+Sun Aug 23 17:10:07 1992 Fred Fish (fnf@cygnus.com)
+
+ * 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.
+
Sun Aug 23 11:04:08 1992 Fred Fish (fnf@cygnus.com)
* breakpoint.c (breakpoint_re_set): Select a default source
{
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);
/* Copy the saved-up fields into the field vector. */
for (n = nfields; list; list = list -> next)
{
type = (struct type *) obstack_alloc (&objfile -> type_obstack,
sizeof (struct type));
}
- memset ((char *)type, 0, sizeof (struct type));
+ memset ((char *) type, 0, sizeof (struct type));
/* Initialize the fields that might not be zero. */
{
ntype = *typeptr;
objfile = TYPE_OBJFILE (ntype);
- memset ((char *)ntype, 0, sizeof (struct type));
+ memset ((char *) ntype, 0, sizeof (struct type));
TYPE_OBJFILE (ntype) = objfile;
}
{
ntype = *typeptr;
objfile = TYPE_OBJFILE (ntype);
- memset ((char *)ntype, 0, sizeof (struct type));
+ memset ((char *) ntype, 0, sizeof (struct type));
TYPE_OBJFILE (ntype) = objfile;
}
{
ntype = *typeptr;
objfile = TYPE_OBJFILE (ntype);
- memset ((char *)ntype, 0, sizeof (struct type));
+ memset ((char *) ntype, 0, sizeof (struct type));
TYPE_OBJFILE (ntype) = objfile;
}
TYPE_LENGTH (result_type) = number * TYPE_LENGTH (element_type);
TYPE_NFIELDS (result_type) = 1;
TYPE_FIELDS (result_type) = (struct field *)
- obstack_alloc (&TYPE_OBJFILE (result_type) -> type_obstack,
- sizeof (struct field));
+ TYPE_ALLOC (result_type, sizeof (struct field));
{
/* Create range type. */
TYPE_NFIELDS (range_type) = 2;
TYPE_FIELDS (range_type) = (struct field *)
- obstack_alloc (&TYPE_OBJFILE (range_type) -> type_obstack,
- 2 * sizeof (struct field));
+ TYPE_ALLOC (range_type, 2 * sizeof (struct field));
TYPE_FIELD_BITPOS (range_type, 0) = 0; /* FIXME */
TYPE_FIELD_BITPOS (range_type, 1) = number-1; /* FIXME */
TYPE_FIELD_TYPE (range_type, 0) = builtin_type_int; /* FIXME */
objfile = TYPE_OBJFILE (type);
- memset ((char *)type, 0, sizeof (struct type));
+ memset ((char *) type, 0, sizeof (struct type));
TYPE_OBJFILE (type) = objfile;
TYPE_TARGET_TYPE (type) = to_type;
TYPE_DOMAIN_TYPE (type) = domain;
objfile = TYPE_OBJFILE (type);
- memset ((char *)type, 0, sizeof (struct type));
+ memset ((char *) type, 0, sizeof (struct type));
TYPE_OBJFILE (type) = objfile;
TYPE_TARGET_TYPE (type) = to_type;
TYPE_DOMAIN_TYPE (type) = domain;
NULL [...] or void [end of arglist]. */
argtypes = (struct type **)
- obstack_alloc (&TYPE_OBJFILE (type) -> type_obstack,
- (argcount+2) * sizeof (struct type *));
+ TYPE_ALLOC (type, (argcount + 2) * sizeof (struct type *));
p = argtypetext;
argtypes[0] = lookup_pointer_type (type);
argcount = 1;
if (!HAVE_CPLUS_STRUCT (type))
{
TYPE_CPLUS_SPECIFIC (type) = (struct cplus_struct_type *)
- obstack_alloc (¤t_objfile -> type_obstack,
- sizeof (struct cplus_struct_type));
+ TYPE_ALLOC (type, sizeof (struct cplus_struct_type));
*(TYPE_CPLUS_SPECIFIC(type)) = cplus_struct_default;
}
}
nbytes = FT_NUM_MEMBERS * sizeof (struct type *);
objfile -> fundamental_types = (struct type **)
obstack_alloc (&objfile -> type_obstack, nbytes);
- memset ((char *)objfile -> fundamental_types, 0, nbytes);
+ memset ((char *) objfile -> fundamental_types, 0, nbytes);
}
typep = objfile -> fundamental_types + typeid;
if ((type = *typep) == NULL)
TYPE_UNSIGNED(t) ? UMIN_OF_SIZE(TYPE_LENGTH(t)) \
: MIN_OF_SIZE(TYPE_LENGTH(t))
+/* Allocate space for storing data associated with a particular type.
+ We ensure that the space is allocated using the same mechanism that
+ was used to allocate the space for the type structure itself. I.E.
+ if the type is on an objfile's type_obstack, then the space for data
+ associated with that type will also be allocated on the type_obstack.
+ If the type is not associated with any particular objfile (such as
+ builtin types), then the data space will be allocated with xmalloc,
+ the same as for the type structure. */
+
+#define TYPE_ALLOC(t,size) \
+ TYPE_OBJFILE (t) != NULL \
+ ? obstack_alloc (&TYPE_OBJFILE (t) -> type_obstack, size) \
+ : xmalloc (size)
+
extern struct type *
alloc_type PARAMS ((struct 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;
#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
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);
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++)
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)
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);
}
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;
{
/* 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;
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;
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;
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.
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)
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;
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;