+2002-05-13 Daniel Jacobowitz <drow@mvista.com>
+
+ * ax-gdb.c (gen_sign_extend, gen_fetch, gen_usual_unary)
+ (gen_cast, gen_scale, gen_add, gen_sub, gen_binop, gen_deref)
+ (gen_address_of, gen_struct_ref, gen_repeat): Use type
+ access macros.
+ * c-typeprint.c (cp_type_print_method_args): Likewise.
+ (c_type_print_args): Likewise.
+ * d10v-tdep.c (d10v_push_arguments): Likewise.
+ (d10v_extract_return_value): Likewise.
+ * expprint.c (print_subexp): Likewise.
+ * gdbtypes.c (lookup_primitive_typename): Likewise.
+ (lookup_template_type, add_mangled_type, print_arg_types): Likewise.
+ * gdbtypes.h (TYPE_UNSIGNED, TYPE_NOSIGN, TYPE_STUB)
+ (TYPE_TARGET_STUB, TYPE_STATIC, TYPE_CONST, TYPE_VOLATILE)
+ (TYPE_PROTOTYPED, TYPE_INCOMPLETE, TYPE_CODE_SPACE, TYPE_VARARGS)
+ (TYPE_VECTOR): Likewise.
+ * hpread.c (hpread_read_struct_type)
+ (fix_static_member_physnames, fixup_class_method_type)
+ (hpread_type_lookup): Likewise.
+ * mdebugread.c (parse_symbol, parse_type): Likewise.
+ * p-lang.c (is_pascal_string_type): Likewise.
+ * valops.c (hand_function_call): Likewise.
+ * x86-64-tdep.c (classify_argument): Likewise.
+
+ * hpread.c (hpread_read_function_type)
+ (hpread_read_doc_function_type): Call replace_type.
+ * dstread.c (create_new_type): Delete.
+ (decode_dst_structure, process_dst_function): Call alloc_type.
+ Use type access macros.
+
2002-05-12 Mark Kettenis <kettenis@gnu.org>
* i387-tdep.c (i387_supply_fxsave): Skip the SSE registers if
{
/* Do we need to sign-extend this? */
if (!TYPE_UNSIGNED (type))
- ax_ext (ax, type->length * TARGET_CHAR_BIT);
+ ax_ext (ax, TYPE_LENGTH (type) * TARGET_CHAR_BIT);
}
static void
gen_extend (struct agent_expr *ax, struct type *type)
{
- int bits = type->length * TARGET_CHAR_BIT;
+ int bits = TYPE_LENGTH (type) * TARGET_CHAR_BIT;
/* I just had to. */
((TYPE_UNSIGNED (type) ? ax_zero_ext : ax_ext) (ax, bits));
}
ax_trace_quick (ax, TYPE_LENGTH (type));
}
- switch (type->code)
+ switch (TYPE_CODE (type))
{
case TYPE_CODE_PTR:
case TYPE_CODE_ENUM:
case TYPE_CODE_CHAR:
/* It's a scalar value, so we know how to dereference it. How
many bytes long is it? */
- switch (type->length)
+ switch (TYPE_LENGTH (type))
{
case 8 / TARGET_CHAR_BIT:
ax_simple (ax, aop_ref8);
the stack. Should we tweak the type? */
/* Some types require special handling. */
- switch (value->type->code)
+ switch (TYPE_CODE (value->type))
{
/* Functions get converted to a pointer to the function. */
case TYPE_CODE_FUNC:
/* Dereference typedefs. */
type = check_typedef (type);
- switch (type->code)
+ switch (TYPE_CODE (type))
{
case TYPE_CODE_PTR:
/* It's implementation-defined, and I'll bet this is what GCC
{
struct type *element = TYPE_TARGET_TYPE (type);
- if (element->length != 1)
+ if (TYPE_LENGTH (element) != 1)
{
- ax_const_l (ax, element->length);
+ ax_const_l (ax, TYPE_LENGTH (element));
ax_simple (ax, op);
}
}
struct axs_value *value1, struct axs_value *value2, char *name)
{
/* Is it INT+PTR? */
- if (value1->type->code == TYPE_CODE_INT
- && value2->type->code == TYPE_CODE_PTR)
+ if (TYPE_CODE (value1->type) == TYPE_CODE_INT
+ && TYPE_CODE (value2->type) == TYPE_CODE_PTR)
{
/* Swap the values and proceed normally. */
ax_simple (ax, aop_swap);
}
/* Is it PTR+INT? */
- else if (value1->type->code == TYPE_CODE_PTR
- && value2->type->code == TYPE_CODE_INT)
+ else if (TYPE_CODE (value1->type) == TYPE_CODE_PTR
+ && TYPE_CODE (value2->type) == TYPE_CODE_INT)
{
gen_scale (ax, aop_mul, value1->type);
ax_simple (ax, aop_add);
/* Must be number + number; the usual binary conversions will have
brought them both to the same width. */
- else if (value1->type->code == TYPE_CODE_INT
- && value2->type->code == TYPE_CODE_INT)
+ else if (TYPE_CODE (value1->type) == TYPE_CODE_INT
+ && TYPE_CODE (value2->type) == TYPE_CODE_INT)
{
ax_simple (ax, aop_add);
gen_extend (ax, value1->type); /* Catch overflow. */
gen_sub (struct agent_expr *ax, struct axs_value *value,
struct axs_value *value1, struct axs_value *value2)
{
- if (value1->type->code == TYPE_CODE_PTR)
+ if (TYPE_CODE (value1->type) == TYPE_CODE_PTR)
{
/* Is it PTR - INT? */
- if (value2->type->code == TYPE_CODE_INT)
+ if (TYPE_CODE (value2->type) == TYPE_CODE_INT)
{
gen_scale (ax, aop_mul, value1->type);
ax_simple (ax, aop_sub);
/* Is it PTR - PTR? Strictly speaking, the types ought to
match, but this is what the normal GDB expression evaluator
tests for. */
- else if (value2->type->code == TYPE_CODE_PTR
+ else if (TYPE_CODE (value2->type) == TYPE_CODE_PTR
&& (TYPE_LENGTH (TYPE_TARGET_TYPE (value1->type))
== TYPE_LENGTH (TYPE_TARGET_TYPE (value2->type))))
{
}
/* Must be number + number. */
- else if (value1->type->code == TYPE_CODE_INT
- && value2->type->code == TYPE_CODE_INT)
+ else if (TYPE_CODE (value1->type) == TYPE_CODE_INT
+ && TYPE_CODE (value2->type) == TYPE_CODE_INT)
{
ax_simple (ax, aop_sub);
gen_extend (ax, value1->type); /* Catch overflow. */
enum agent_op op_unsigned, int may_carry, char *name)
{
/* We only handle INT op INT. */
- if ((value1->type->code != TYPE_CODE_INT)
- || (value2->type->code != TYPE_CODE_INT))
+ if ((TYPE_CODE (value1->type) != TYPE_CODE_INT)
+ || (TYPE_CODE (value2->type) != TYPE_CODE_INT))
error ("Illegal combination of types in %s.", name);
ax_simple (ax,
{
/* The caller should check the type, because several operators use
this, and we don't know what error message to generate. */
- if (value->type->code != TYPE_CODE_PTR)
+ if (TYPE_CODE (value->type) != TYPE_CODE_PTR)
internal_error (__FILE__, __LINE__,
"gen_deref: expected a pointer");
T" to "T", and mark the value as an lvalue in memory. Leave it
to the consumer to actually dereference it. */
value->type = check_typedef (TYPE_TARGET_TYPE (value->type));
- value->kind = ((value->type->code == TYPE_CODE_FUNC)
+ value->kind = ((TYPE_CODE (value->type) == TYPE_CODE_FUNC)
? axs_rvalue : axs_lvalue_memory);
}
/* Special case for taking the address of a function. The ANSI
standard describes this as a special case, too, so this
arrangement is not without motivation. */
- if (value->type->code == TYPE_CODE_FUNC)
+ if (TYPE_CODE (value->type) == TYPE_CODE_FUNC)
/* The value's already an rvalue on the stack, so we just need to
change the type. */
value->type = lookup_pointer_type (value->type);
/* Follow pointers until we reach a non-pointer. These aren't the C
semantics, but they're what the normal GDB evaluator does, so we
should at least be consistent. */
- while (value->type->code == TYPE_CODE_PTR)
+ while (TYPE_CODE (value->type) == TYPE_CODE_PTR)
{
gen_usual_unary (ax, value);
gen_deref (ax, value);
if (!v)
error ("Right operand of `@' must be a constant, in agent expressions.");
- if (v->type->code != TYPE_CODE_INT)
+ if (TYPE_CODE (v->type) != TYPE_CODE_INT)
error ("Right operand of `@' must be an integer.");
length = value_as_long (v);
if (length <= 0)
fprintf_symbol_filtered (stream, prefix, language_cplus, DMGL_ANSI);
fprintf_symbol_filtered (stream, varstring, language_cplus, DMGL_ANSI);
fputs_filtered ("(", stream);
- if (args && args[!staticp] && args[!staticp]->code != TYPE_CODE_VOID)
+ if (args && args[!staticp] && TYPE_CODE (args[!staticp]) != TYPE_CODE_VOID)
{
i = !staticp; /* skip the class variable */
while (1)
fprintf_filtered (stream, " ...");
break;
}
- else if (args[i]->code != TYPE_CODE_VOID)
+ else if (TYPE_CODE (args[i]) != TYPE_CODE_VOID)
{
fprintf_filtered (stream, ", ");
}
{
fprintf_filtered (stream, "...");
}
- else if ((args[1]->code == TYPE_CODE_VOID) &&
+ else if ((TYPE_CODE (args[1]) == TYPE_CODE_VOID) &&
(current_language->la_language == language_cplus))
{
fprintf_filtered (stream, "void");
else
{
for (i = 1;
- args[i] != NULL && args[i]->code != TYPE_CODE_VOID;
+ args[i] != NULL && TYPE_CODE (args[i]) != TYPE_CODE_VOID;
i++)
{
c_print_type (args[i], "", stream, -1, 0);
{
fprintf_filtered (stream, "...");
}
- else if (args[i + 1]->code != TYPE_CODE_VOID)
+ else if (TYPE_CODE (args[i + 1]) != TYPE_CODE_VOID)
{
fprintf_filtered (stream, ",");
wrap_here (" ");
struct type *type = check_typedef (VALUE_TYPE (arg));
char *contents = VALUE_CONTENTS (arg);
int len = TYPE_LENGTH (type);
- /* printf ("push: type=%d len=%d\n", type->code, len); */
+ /* printf ("push: type=%d len=%d\n", TYPE_CODE (type), len); */
{
int aligned_regnum = (regnum + 1) & ~1;
if (len <= 2 && regnum <= ARGN_REGNUM)
char *valbuf)
{
int len;
- /* printf("RET: TYPE=%d len=%d r%d=0x%x\n",type->code, TYPE_LENGTH (type), RET1_REGNUM - R0_REGNUM, (int) extract_unsigned_integer (regbuf + REGISTER_BYTE(RET1_REGNUM), REGISTER_RAW_SIZE (RET1_REGNUM))); */
+ /* printf("RET: TYPE=%d len=%d r%d=0x%x\n", TYPE_CODE (type), TYPE_LENGTH (type), RET1_REGNUM - R0_REGNUM, (int) extract_unsigned_integer (regbuf + REGISTER_BYTE(RET1_REGNUM), REGISTER_RAW_SIZE (RET1_REGNUM))); */
{
len = TYPE_LENGTH (type);
if (len == 1)
+ ref->sect_offset;
}
-static struct type *
-create_new_type (struct objfile *objfile)
-{
- struct type *type;
-
- type = (struct type *)
- obstack_alloc (&objfile->symbol_obstack, sizeof (struct type));
- memset (type, 0, sizeof (struct type));
- return type;
-}
-
static struct symbol *
create_new_symbol (struct objfile *objfile, char *name)
{
xfree (name);
return type;
}
- type = create_new_type (objfile);
+ type = alloc_type (objfile);
TYPE_NAME (type) = obstack_copy0 (&objfile->symbol_obstack,
name, strlen (name));
xfree (name);
if (!type->function_type)
{
- ftype = create_new_type (objfile);
+ ftype = alloc_type (objfile);
type->function_type = ftype;
- ftype->target_type = type;
- ftype->code = TYPE_CODE_FUNC;
+ TYPE_TARGET_TYPE (ftype) = type;
+ TYPE_CODE (ftype) = TYPE_CODE_FUNC;
}
SYMBOL_TYPE (sym) = type->function_type;
(*pos) += 2;
if ((int) prec > (int) PREC_PREFIX)
fputs_filtered ("(", stream);
- if (exp->elts[pc + 1].type->code == TYPE_CODE_FUNC &&
+ if (TYPE_CODE (exp->elts[pc + 1].type) == TYPE_CODE_FUNC &&
exp->elts[pc + 3].opcode == OP_LONG)
{
/* We have a minimal symbol fn, probably. It's encoded
for (p = current_language->la_builtin_type_vector; *p != NULL; p++)
{
- if (STREQ ((**p)->name, name))
+ if (STREQ (TYPE_NAME (**p), name))
{
return (**p);
}
lookup_template_type (char *name, struct type *type, struct block *block)
{
struct symbol *sym;
- char *nam = (char *) alloca (strlen (name) + strlen (type->name) + 4);
+ char *nam = (char *) alloca (strlen (name) + strlen (TYPE_NAME (type)) + 4);
strcpy (nam, name);
strcat (nam, "<");
- strcat (nam, type->name);
+ strcat (nam, TYPE_NAME (type));
strcat (nam, " >"); /* FIXME, extra space still introduced in gcc? */
sym = lookup_symbol (nam, block, VAR_NAMESPACE, 0, (struct symtab **) NULL);
complain (&msg, tcode);
}
}
- if (t->target_type)
- add_mangled_type (pextras, t->target_type);
+ if (TYPE_TARGET_TYPE (t))
+ add_mangled_type (pextras, TYPE_TARGET_TYPE (t));
}
#if 0
while (*args != NULL)
{
recursive_dump_type (*args, spaces + 2);
- if ((*args++)->code == TYPE_CODE_VOID)
+ if (TYPE_CODE (*args++) == TYPE_CODE_VOID)
{
break;
}
else /* expect DNTT_TYPE_FUNC_TEMPLATE */
type1 = lookup_function_type (hpread_type_lookup (dn_bufp->dfunc_template.retval,
objfile));
- memcpy ((char *) type, (char *) type1, sizeof (struct type));
+ replace_type (type, type1);
/* Mark it -- in the middle of processing */
TYPE_FLAGS (type) |= TYPE_FLAG_INCOMPLETE;
dn_bufp->dblock.kind == DNTT_TYPE_DOC_MEMFUNC)
type1 = lookup_function_type (hpread_type_lookup (dn_bufp->ddocfunc.retval,
objfile));
- memcpy ((char *) type, (char *) type1, sizeof (struct type));
+ replace_type (type, type1);
/* Mark it -- in the middle of processing */
TYPE_FLAGS (type) |= TYPE_FLAG_INCOMPLETE;
fn_p->field.fn_fields[ix].type = memtype;
/* The argument list */
- fn_p->field.fn_fields[ix].type->type_specific.arg_types =
- (struct type **) obstack_alloc (&objfile->type_obstack,
- sizeof (struct type *) * (memtype->nfields + 1));
- for (i = 0; i < memtype->nfields; i++)
- fn_p->field.fn_fields[ix].type->type_specific.arg_types[i] = memtype->fields[i].type;
+ TYPE_TYPE_SPECIFIC (fn_p->field.fn_fields[ix].type).arg_types
+ = (struct type **) obstack_alloc (&objfile->type_obstack,
+ (sizeof (struct type *)
+ * (TYPE_NFIELDS (memtype)
+ + 1)));
+ for (i = 0; i < TYPE_NFIELDS (memtype); i++)
+ TYPE_TYPE_SPECIFIC (fn_p->field.fn_fields[ix].type)
+ .arg_types[i] = TYPE_FIELDS (memtype)[i].type;
/* void termination */
- fn_p->field.fn_fields[ix].type->type_specific.arg_types[memtype->nfields] = builtin_type_void;
+ TYPE_TYPE_SPECIFIC (fn_p->field.fn_fields[ix].type)
+ .arg_types[TYPE_NFIELDS (memtype)] = builtin_type_void;
/* pai: It's not clear why this args field has to be set. Perhaps
* it should be eliminated entirely. */
fn_p->field.fn_fields[ix].args =
(struct type **) obstack_alloc (&objfile->type_obstack,
- sizeof (struct type *) * (memtype->nfields + 1));
- for (i = 0; i < memtype->nfields; i++)
- fn_p->field.fn_fields[ix].args[i] = memtype->fields[i].type;
+ sizeof (struct type *) * (TYPE_NFIELDS (memtype) + 1));
+ for (i = 0; i < TYPE_NFIELDS (memtype); i++)
+ fn_p->field.fn_fields[ix].args[i]
+ = TYPE_FIELDS (memtype)[i].type;
/* null-terminated, unlike arg_types above e */
- fn_p->field.fn_fields[ix].args[memtype->nfields] = NULL;
+ fn_p->field.fn_fields[ix].args[TYPE_NFIELDS (memtype)] = NULL;
}
/* For virtual functions, fill in the voffset field with the
* virtual table offset. (This is just copied over from the
if (TYPE_FIELD_STATIC_PHYSNAME (type, i))
return; /* physnames are already set */
- SET_FIELD_PHYSNAME (type->fields[i],
+ SET_FIELD_PHYSNAME (TYPE_FIELDS (type)[i],
obstack_alloc (&objfile->type_obstack,
strlen (class_name) + strlen (TYPE_FIELD_NAME (type, i)) + 3));
strcpy (TYPE_FIELD_STATIC_PHYSNAME (type, i), class_name);
/* Set the method type */
TYPE_FN_FIELD_TYPE (TYPE_FN_FIELDLIST1 (class, i), j) = method;
/* The argument list */
- (TYPE_FN_FIELD_TYPE (TYPE_FN_FIELDLIST1 (class, i), j))->type_specific.arg_types
+ TYPE_TYPE_SPECIFIC (TYPE_FN_FIELD_TYPE (TYPE_FN_FIELDLIST1 (class, i), j)).arg_types
= (struct type **) obstack_alloc (&objfile->type_obstack,
- sizeof (struct type *) * (method->nfields + 1));
- for (k = 0; k < method->nfields; k++)
- (TYPE_FN_FIELD_TYPE (TYPE_FN_FIELDLIST1 (class, i), j))->type_specific.arg_types[k] = method->fields[k].type;
+ sizeof (struct type *) * (TYPE_NFIELDS (method) + 1));
+ for (k = 0; k < TYPE_NFIELDS (method); k++)
+ TYPE_TYPE_SPECIFIC (TYPE_FN_FIELD_TYPE (TYPE_FN_FIELDLIST1 (class, i), j)).arg_types[k] = TYPE_FIELDS (method)[k].type;
/* void termination */
- (TYPE_FN_FIELD_TYPE (TYPE_FN_FIELDLIST1 (class, i), j))->type_specific.arg_types[method->nfields] = builtin_type_void;
+ TYPE_TYPE_SPECIFIC (TYPE_FN_FIELD_TYPE (TYPE_FN_FIELDLIST1 (class, i), j)).arg_types[TYPE_NFIELDS (method)] = builtin_type_void;
/* pai: It's not clear why this args field has to be set. Perhaps
* it should be eliminated entirely. */
(TYPE_FN_FIELD (TYPE_FN_FIELDLIST1 (class, i), j)).args
= (struct type **) obstack_alloc (&objfile->type_obstack,
- sizeof (struct type *) * (method->nfields + 1));
- for (k = 0; k < method->nfields; k++)
- (TYPE_FN_FIELD (TYPE_FN_FIELDLIST1 (class, i), j)).args[k] = method->fields[k].type;
+ sizeof (struct type *) * (TYPE_NFIELDS (method) + 1));
+ for (k = 0; k < TYPE_NFIELDS (method); k++)
+ (TYPE_FN_FIELD (TYPE_FN_FIELDLIST1 (class, i), j)).args[k] = TYPE_FIELDS (method)[k].type;
/* null-terminated, unlike arg_types above */
- (TYPE_FN_FIELD (TYPE_FN_FIELDLIST1 (class, i), j)).args[method->nfields] = NULL;
+ (TYPE_FN_FIELD (TYPE_FN_FIELDLIST1 (class, i), j)).args[TYPE_NFIELDS (method)] = NULL;
/* Break out of both loops -- only one method to fix up in a class */
goto finish;
}
/* Build the correct name. */
- structtype->name
+ TYPE_NAME (structtype)
= (char *) obstack_alloc (&objfile->type_obstack,
strlen (prefix) + strlen (suffix) + 1);
TYPE_NAME (structtype) = strcpy (TYPE_NAME (structtype), prefix);
else
{
t = parse_type (cur_fd, ax, sh->index + 1, 0, bigend, name);
- if (STREQ (name, "malloc") && t->code == TYPE_CODE_VOID)
+ if (STREQ (name, "malloc") && TYPE_CODE (t) == TYPE_CODE_VOID)
{
/* I don't know why, but, at least under Alpha GNU/Linux,
when linking against a malloc without debugging
dereference them. */
while (TYPE_CODE (tp) == TYPE_CODE_PTR
|| TYPE_CODE (tp) == TYPE_CODE_ARRAY)
- tp = tp->target_type;
+ tp = TYPE_TARGET_TYPE (tp);
/* Make sure that TYPE_CODE(tp) has an expected type code.
Any type may be returned from cross_ref if file indirect entries
if (length_pos)
*length_pos = TYPE_FIELD_BITPOS (type, 0) / TARGET_CHAR_BIT;
if (length_size)
- *length_size = TYPE_FIELD_TYPE (type, 0)->length;
+ *length_size = TYPE_LENGTH (TYPE_FIELD_TYPE (type, 0));
if (string_pos)
*string_pos = TYPE_FIELD_BITPOS (type, 1) / TARGET_CHAR_BIT;
if (char_size)
if (length_pos)
*length_pos = TYPE_FIELD_BITPOS (type, 1) / TARGET_CHAR_BIT;
if (length_size)
- *length_size = TYPE_FIELD_TYPE (type, 1)->length;
+ *length_size = TYPE_LENGTH (TYPE_FIELD_TYPE (type, 1));
if (string_pos)
*string_pos = TYPE_FIELD_BITPOS (type, 2) / TARGET_CHAR_BIT;
/* FIXME: how can I detect wide chars in GPC ?? */
if (param_type)
/* if this parameter is a pointer to function */
if (TYPE_CODE (param_type) == TYPE_CODE_PTR)
- if (TYPE_CODE (param_type->target_type) == TYPE_CODE_FUNC)
+ if (TYPE_CODE (TYPE_TARGET_TYPE (param_type)) == TYPE_CODE_FUNC)
/* elz: FIXME here should go the test about the compiler used
to compile the target. We want to issue the error
message only if the compiler used was HP's aCC.
case TYPE_CODE_STRUCT:
{
int j;
- for (j = 0; j < type->nfields; ++j)
+ for (j = 0; j < TYPE_NFIELDS (type); ++j)
{
- int num = classify_argument (type->fields[j].type,
+ int num = classify_argument (TYPE_FIELDS (type)[j].type,
subclasses,
- (type->fields[j].loc.bitpos
+ (TYPE_FIELDS (type)[j].loc.bitpos
+ bit_offset) % 256);
if (!num)
return 0;
for (i = 0; i < num; i++)
{
int pos =
- (type->fields[j].loc.bitpos + bit_offset) / 8 / 8;
+ (TYPE_FIELDS (type)[j].loc.bitpos + bit_offset) / 8 / 8;
classes[i + pos] =
merge_classes (subclasses[i], classes[i + pos]);
}
{
int num;
- num = classify_argument (type->target_type,
+ num = classify_argument (TYPE_TARGET_TYPE (type),
subclasses, bit_offset);
if (!num)
return 0;
{
int j;
{
- for (j = 0; j < type->nfields; ++j)
+ for (j = 0; j < TYPE_NFIELDS (type); ++j)
{
int num;
- num = classify_argument (type->fields[j].type,
+ num = classify_argument (TYPE_FIELDS (type)[j].type,
subclasses, bit_offset);
if (!num)
return 0;