/* Allocate a new GDBARCH-associated type structure and fill it
with some defaults. Space for the type structure is allocated
- on the heap. */
+ on the obstack associated with GDBARCH. */
struct type *
alloc_type_arch (struct gdbarch *gdbarch)
/* Alloc the structure and start off with all fields zeroed. */
- type = XCNEW (struct type);
- TYPE_MAIN_TYPE (type) = XCNEW (struct main_type);
+ type = GDBARCH_OBSTACK_ZALLOC (gdbarch, struct type);
+ TYPE_MAIN_TYPE (type) = GDBARCH_OBSTACK_ZALLOC (gdbarch, struct main_type);
TYPE_OBJFILE_OWNED (type) = 0;
TYPE_OWNER (type).gdbarch = gdbarch;
return type;
}
+/* See gdbtypes.h. */
+
+unsigned int
+type_length_units (struct type *type)
+{
+ struct gdbarch *arch = get_type_arch (type);
+ int unit_size = gdbarch_addressable_memory_unit_size (arch);
+
+ return TYPE_LENGTH (type) / unit_size;
+}
+
/* Alloc a new type instance structure, fill it with some defaults,
and point it at OLDTYPE. Allocate the new type instance from the
same place as OLDTYPE. */
struct type *type;
sym = lookup_symbol_in_language (name, block, VAR_DOMAIN,
- language->la_language, NULL);
+ language->la_language, NULL).symbol;
if (sym != NULL && SYMBOL_CLASS (sym) == LOC_TYPEDEF)
return SYMBOL_TYPE (sym);
{
struct symbol *sym;
- sym = lookup_symbol (name, block, STRUCT_DOMAIN, 0);
+ sym = lookup_symbol (name, block, STRUCT_DOMAIN, 0).symbol;
if (sym == NULL)
{
struct symbol *sym;
struct type *t;
- sym = lookup_symbol (name, block, STRUCT_DOMAIN, 0);
+ sym = lookup_symbol (name, block, STRUCT_DOMAIN, 0).symbol;
if (sym == NULL)
error (_("No union type named %s."), name);
{
struct symbol *sym;
- sym = lookup_symbol (name, block, STRUCT_DOMAIN, 0);
+ sym = lookup_symbol (name, block, STRUCT_DOMAIN, 0).symbol;
if (sym == NULL)
{
error (_("No enum type named %s."), name);
strcat (nam, TYPE_NAME (type));
strcat (nam, " >"); /* FIXME, extra space still introduced in gcc? */
- sym = lookup_symbol (nam, block, VAR_DOMAIN, 0);
+ sym = lookup_symbol (nam, block, VAR_DOMAIN, 0).symbol;
if (sym == NULL)
{
gdb_assert (TYPE_CODE (dyn_range_type) == TYPE_CODE_RANGE);
prop = &TYPE_RANGE_DATA (dyn_range_type)->low;
- if (dwarf2_evaluate_property (prop, addr_stack, &value))
+ if (dwarf2_evaluate_property (prop, NULL, addr_stack, &value))
{
low_bound.kind = PROP_CONST;
low_bound.data.const_val = value;
}
prop = &TYPE_RANGE_DATA (dyn_range_type)->high;
- if (dwarf2_evaluate_property (prop, addr_stack, &value))
+ if (dwarf2_evaluate_property (prop, NULL, addr_stack, &value))
{
high_bound.kind = PROP_CONST;
high_bound.data.const_val = value;
ary_dim = check_typedef (TYPE_TARGET_TYPE (elt_type));
if (ary_dim != NULL && TYPE_CODE (ary_dim) == TYPE_CODE_ARRAY)
- elt_type = resolve_dynamic_array (TYPE_TARGET_TYPE (type), addr_stack);
+ elt_type = resolve_dynamic_array (ary_dim, addr_stack);
else
elt_type = TYPE_TARGET_TYPE (type);
/* Resolve data_location attribute. */
prop = TYPE_DATA_LOCATION (resolved_type);
- if (prop != NULL && dwarf2_evaluate_property (prop, addr_stack, &value))
+ if (prop != NULL
+ && dwarf2_evaluate_property (prop, NULL, addr_stack, &value))
{
TYPE_DYN_PROP_ADDR (prop) = value;
TYPE_DYN_PROP_KIND (prop) = PROP_CONST;
stub_noname_complaint ();
return make_qualified_type (type, instance_flags, NULL);
}
- sym = lookup_symbol (name, 0, STRUCT_DOMAIN, 0);
+ sym = lookup_symbol (name, 0, STRUCT_DOMAIN, 0).symbol;
if (sym)
TYPE_TARGET_TYPE (type) = SYMBOL_TYPE (sym);
else /* TYPE_CODE_UNDEF */
stub_noname_complaint ();
return make_qualified_type (type, instance_flags, NULL);
}
- sym = lookup_symbol (name, 0, STRUCT_DOMAIN, 0);
+ sym = lookup_symbol (name, 0, STRUCT_DOMAIN, 0).symbol;
if (sym)
{
/* Same as above for opaque types, we can replace the stub
struct value **args, int nargs)
{
int i;
- struct badness_vector *bv;
+ struct badness_vector *bv = XNEW (struct badness_vector);
int min_len = nparms < nargs ? nparms : nargs;
- bv = xmalloc (sizeof (struct badness_vector));
bv->length = nargs + 1; /* add 1 for the length-match rank. */
bv->rank = XNEWVEC (struct rank, nargs + 1);
}
/* Recursively copy (deep copy) TYPE, if it is associated with
- OBJFILE. Return a new type allocated using malloc, a saved type if
- we have already visited TYPE (using COPIED_TYPES), or TYPE if it is
- not associated with OBJFILE. */
+ OBJFILE. Return a new type owned by the gdbarch associated with the type, a
+ saved type if we have already visited TYPE (using COPIED_TYPES), or TYPE if
+ it is not associated with OBJFILE. */
struct type *
copy_type_recursive (struct objfile *objfile,
/* We must add the new type to the hash table immediately, in case
we encounter this type again during a recursive call below. */
- stored
- = obstack_alloc (&objfile->objfile_obstack, sizeof (struct type_pair));
+ stored = XOBNEW (&objfile->objfile_obstack, struct type_pair);
stored->old = type;
stored->newobj = new_type;
*slot = stored;
/* For range types, copy the bounds information. */
if (TYPE_CODE (type) == TYPE_CODE_RANGE)
{
- TYPE_RANGE_DATA (new_type) = xmalloc (sizeof (struct range_bounds));
+ TYPE_RANGE_DATA (new_type) = XNEW (struct range_bounds);
*TYPE_RANGE_DATA (new_type) = *TYPE_RANGE_DATA (type);
}
TYPE_LENGTH (type) = length;
if (name)
- TYPE_NAME (type) = xstrdup (name);
+ TYPE_NAME (type) = gdbarch_obstack_strdup (gdbarch, name);
return type;
}