summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Jacobowitz <dan@debian.org>2002-05-13 14:21:12 +0000
committerDaniel Jacobowitz <dan@debian.org>2002-05-13 14:21:12 +0000
commitc90ea4e2754360d48b19b334a3861326d593295f (patch)
tree3b898e80a0b903adbe2ff826b371a66a072b2c90
parent4b6afe37dac8f07f5d795d6a3ca86ecbe3285176 (diff)
downloadgdb-c90ea4e2754360d48b19b334a3861326d593295f.tar.gz
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.
-rw-r--r--gdb/ChangeLog31
-rw-r--r--gdb/ax-gdb.c52
-rw-r--r--gdb/c-typeprint.c10
-rw-r--r--gdb/d10v-tdep.c4
-rw-r--r--gdb/dstread.c19
-rw-r--r--gdb/expprint.c2
-rw-r--r--gdb/gdbtypes.c12
-rw-r--r--gdb/gdbtypes.h26
-rw-r--r--gdb/hpread.c51
-rw-r--r--gdb/mdebugread.c4
-rw-r--r--gdb/p-lang.c4
-rw-r--r--gdb/valops.c2
-rw-r--r--gdb/x86-64-tdep.c14
13 files changed, 128 insertions, 103 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 6ec785baa3e..98247ae67fe 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,34 @@
+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
diff --git a/gdb/ax-gdb.c b/gdb/ax-gdb.c
index aa9f92a9610..368b9df12a1 100644
--- a/gdb/ax-gdb.c
+++ b/gdb/ax-gdb.c
@@ -353,7 +353,7 @@ gen_sign_extend (struct agent_expr *ax, struct type *type)
{
/* 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);
}
@@ -363,7 +363,7 @@ gen_sign_extend (struct agent_expr *ax, struct type *type)
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));
}
@@ -381,7 +381,7 @@ gen_fetch (struct agent_expr *ax, struct type *type)
ax_trace_quick (ax, TYPE_LENGTH (type));
}
- switch (type->code)
+ switch (TYPE_CODE (type))
{
case TYPE_CODE_PTR:
case TYPE_CODE_ENUM:
@@ -389,7 +389,7 @@ gen_fetch (struct agent_expr *ax, struct type *type)
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);
@@ -699,7 +699,7 @@ gen_usual_unary (struct agent_expr *ax, struct axs_value *value)
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:
@@ -874,7 +874,7 @@ gen_cast (struct agent_expr *ax, struct axs_value *value, struct type *type)
/* 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
@@ -925,9 +925,9 @@ gen_scale (struct agent_expr *ax, enum agent_op op, struct type *type)
{
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);
}
}
@@ -943,8 +943,8 @@ gen_add (struct agent_expr *ax, struct axs_value *value,
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);
@@ -955,8 +955,8 @@ gen_add (struct agent_expr *ax, struct axs_value *value,
}
/* 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);
@@ -966,8 +966,8 @@ gen_add (struct agent_expr *ax, struct axs_value *value,
/* 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. */
@@ -989,10 +989,10 @@ static void
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);
@@ -1003,7 +1003,7 @@ gen_sub (struct agent_expr *ax, struct axs_value *value,
/* 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))))
{
@@ -1018,8 +1018,8 @@ an integer nor a pointer of the same 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. */
@@ -1044,8 +1044,8 @@ gen_binop (struct agent_expr *ax, struct axs_value *value,
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,
@@ -1092,7 +1092,7 @@ gen_deref (struct agent_expr *ax, struct axs_value *value)
{
/* 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");
@@ -1102,7 +1102,7 @@ gen_deref (struct agent_expr *ax, struct axs_value *value)
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);
}
@@ -1114,7 +1114,7 @@ gen_address_of (struct agent_expr *ax, struct axs_value *value)
/* 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);
@@ -1346,7 +1346,7 @@ gen_struct_ref (struct agent_expr *ax, struct axs_value *value, char *field,
/* 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);
@@ -1410,7 +1410,7 @@ gen_repeat (union exp_element **pc, struct agent_expr *ax,
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)
diff --git a/gdb/c-typeprint.c b/gdb/c-typeprint.c
index 0c460e9dd5f..8436bcadfd2 100644
--- a/gdb/c-typeprint.c
+++ b/gdb/c-typeprint.c
@@ -158,7 +158,7 @@ cp_type_print_method_args (struct type **args, char *prefix, char *varstring,
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)
@@ -169,7 +169,7 @@ cp_type_print_method_args (struct type **args, char *prefix, char *varstring,
fprintf_filtered (stream, " ...");
break;
}
- else if (args[i]->code != TYPE_CODE_VOID)
+ else if (TYPE_CODE (args[i]) != TYPE_CODE_VOID)
{
fprintf_filtered (stream, ", ");
}
@@ -346,7 +346,7 @@ c_type_print_args (struct type *type, struct ui_file *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");
@@ -354,7 +354,7 @@ c_type_print_args (struct type *type, struct ui_file *stream)
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);
@@ -362,7 +362,7 @@ c_type_print_args (struct type *type, struct ui_file *stream)
{
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 (" ");
diff --git a/gdb/d10v-tdep.c b/gdb/d10v-tdep.c
index d5f5b05106f..58600fb92ea 100644
--- a/gdb/d10v-tdep.c
+++ b/gdb/d10v-tdep.c
@@ -1037,7 +1037,7 @@ d10v_push_arguments (int nargs, struct value **args, CORE_ADDR sp,
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)
@@ -1091,7 +1091,7 @@ d10v_extract_return_value (struct type *type, char regbuf[REGISTER_BYTES],
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)
diff --git a/gdb/dstread.c b/gdb/dstread.c
index c3a73f064cd..abcce097a27 100644
--- a/gdb/dstread.c
+++ b/gdb/dstread.c
@@ -705,17 +705,6 @@ dst_sym_addr (dst_sect_ref_t *ref)
+ 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)
{
@@ -865,7 +854,7 @@ decode_dst_structure (struct objfile *objfile, dst_rec_ptr_t entry, int code,
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);
@@ -1306,10 +1295,10 @@ process_dst_function (struct objfile *objfile, dst_rec_ptr_t entry, char *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;
diff --git a/gdb/expprint.c b/gdb/expprint.c
index cb617113971..09e7db69b3a 100644
--- a/gdb/expprint.c
+++ b/gdb/expprint.c
@@ -334,7 +334,7 @@ print_subexp (register struct expression *exp, register int *pos,
(*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
diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c
index 732c92818bf..fff720d4838 100644
--- a/gdb/gdbtypes.c
+++ b/gdb/gdbtypes.c
@@ -936,7 +936,7 @@ lookup_primitive_typename (char *name)
for (p = current_language->la_builtin_type_vector; *p != NULL; p++)
{
- if (STREQ ((**p)->name, name))
+ if (STREQ (TYPE_NAME (**p), name))
{
return (**p);
}
@@ -1081,10 +1081,10 @@ struct type *
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);
@@ -1511,8 +1511,8 @@ add_mangled_type (struct extra *pextras, struct type *t)
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
@@ -2713,7 +2713,7 @@ print_arg_types (struct type **args, int spaces)
while (*args != NULL)
{
recursive_dump_type (*args, spaces + 2);
- if ((*args++)->code == TYPE_CODE_VOID)
+ if (TYPE_CODE (*args++) == TYPE_CODE_VOID)
{
break;
}
diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h
index 0411aaacb62..914d4781126 100644
--- a/gdb/gdbtypes.h
+++ b/gdb/gdbtypes.h
@@ -148,21 +148,21 @@ enum type_code
type is signed (unless TYPE_FLAG_NOSIGN (below) is set). */
#define TYPE_FLAG_UNSIGNED (1 << 0)
-#define TYPE_UNSIGNED(t) ((t)->flags & TYPE_FLAG_UNSIGNED)
+#define TYPE_UNSIGNED(t) (TYPE_FLAGS (t) & TYPE_FLAG_UNSIGNED)
/* No sign for this type. In C++, "char", "signed char", and "unsigned
char" are distinct types; so we need an extra flag to indicate the
absence of a sign! */
#define TYPE_FLAG_NOSIGN (1 << 1)
-#define TYPE_NOSIGN(t) ((t)->flags & TYPE_FLAG_NOSIGN)
+#define TYPE_NOSIGN(t) (TYPE_FLAGS (t) & TYPE_FLAG_NOSIGN)
/* This appears in a type's flags word if it is a stub type (e.g., if
someone referenced a type that wasn't defined in a source file
via (struct sir_not_appearing_in_this_film *)). */
#define TYPE_FLAG_STUB (1 << 2)
-#define TYPE_STUB(t) ((t)->flags & TYPE_FLAG_STUB)
+#define TYPE_STUB(t) (TYPE_FLAGS (t) & TYPE_FLAG_STUB)
/* The target type of this type is a stub type, and this type needs to
be updated if it gets un-stubbed in check_typedef.
@@ -171,7 +171,7 @@ enum type_code
Also, set for TYPE_CODE_TYPEDEF. */
#define TYPE_FLAG_TARGET_STUB (1 << 3)
-#define TYPE_TARGET_STUB(t) ((t)->flags & TYPE_FLAG_TARGET_STUB)
+#define TYPE_TARGET_STUB(t) (TYPE_FLAGS (t) & TYPE_FLAG_TARGET_STUB)
/* Static type. If this is set, the corresponding type had
* a static modifier.
@@ -180,21 +180,21 @@ enum type_code
*/
#define TYPE_FLAG_STATIC (1 << 4)
-#define TYPE_STATIC(t) ((t)->flags & TYPE_FLAG_STATIC)
+#define TYPE_STATIC(t) (TYPE_FLAGS (t) & TYPE_FLAG_STATIC)
/* Constant type. If this is set, the corresponding type has a
* const modifier.
*/
#define TYPE_FLAG_CONST (1 << 5)
-#define TYPE_CONST(t) ((t)->flags & TYPE_FLAG_CONST)
+#define TYPE_CONST(t) (TYPE_FLAGS (t) & TYPE_FLAG_CONST)
/* Volatile type. If this is set, the corresponding type has a
* volatile modifier.
*/
#define TYPE_FLAG_VOLATILE (1 << 6)
-#define TYPE_VOLATILE(t) ((t)->flags & TYPE_FLAG_VOLATILE)
+#define TYPE_VOLATILE(t) (TYPE_FLAGS (t) & TYPE_FLAG_VOLATILE)
/* This is a function type which appears to have a prototype. We need this
@@ -202,7 +202,7 @@ enum type_code
or to just do the standard conversions. This is used with a short field. */
#define TYPE_FLAG_PROTOTYPED (1 << 7)
-#define TYPE_PROTOTYPED(t) ((t)->flags & TYPE_FLAG_PROTOTYPED)
+#define TYPE_PROTOTYPED(t) (TYPE_FLAGS (t) & TYPE_FLAG_PROTOTYPED)
/* This flag is used to indicate that processing for this type
is incomplete.
@@ -213,7 +213,7 @@ enum type_code
the method can be assigned correct types.) */
#define TYPE_FLAG_INCOMPLETE (1 << 8)
-#define TYPE_INCOMPLETE(t) ((t)->flags & TYPE_FLAG_INCOMPLETE)
+#define TYPE_INCOMPLETE(t) (TYPE_FLAGS (t) & TYPE_FLAG_INCOMPLETE)
/* Instruction-space delimited type. This is for Harvard architectures
which have separate instruction and data address spaces (and perhaps
@@ -235,10 +235,10 @@ enum type_code
is instruction space, and for data objects is data memory. */
#define TYPE_FLAG_CODE_SPACE (1 << 9)
-#define TYPE_CODE_SPACE(t) ((t)->flags & TYPE_FLAG_CODE_SPACE)
+#define TYPE_CODE_SPACE(t) (TYPE_FLAGS (t) & TYPE_FLAG_CODE_SPACE)
#define TYPE_FLAG_DATA_SPACE (1 << 10)
-#define TYPE_DATA_SPACE(t) ((t)->flags & TYPE_FLAG_DATA_SPACE)
+#define TYPE_DATA_SPACE(t) (TYPE_FLAGS (t) & TYPE_FLAG_DATA_SPACE)
/* FIXME: Kludge to mark a varargs function type for C++ member
function argument processing. Currently only used in dwarf2read.c,
@@ -246,13 +246,13 @@ enum type_code
another flag. */
#define TYPE_FLAG_VARARGS (1 << 11)
-#define TYPE_VARARGS(t) ((t)->flags & TYPE_FLAG_VARARGS)
+#define TYPE_VARARGS(t) (TYPE_FLAGS (t) & TYPE_FLAG_VARARGS)
/* Identify a vector type. Gcc is handling this by adding an extra
attribute to the array type. We slurp that in as a new flag of a
type. This is used only in dwarf2read.c. */
#define TYPE_FLAG_VECTOR (1 << 12)
-#define TYPE_VECTOR(t) ((t)->flags & TYPE_FLAG_VECTOR)
+#define TYPE_VECTOR(t) (TYPE_FLAGS (t) & TYPE_FLAG_VECTOR)
struct type
diff --git a/gdb/hpread.c b/gdb/hpread.c
index ca153f9ca46..fe3d3438d5f 100644
--- a/gdb/hpread.c
+++ b/gdb/hpread.c
@@ -3230,7 +3230,7 @@ hpread_read_function_type (dnttpointer hp_type, union dnttentry *dn_bufp,
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;
@@ -3407,7 +3407,7 @@ hpread_read_doc_function_type (dnttpointer hp_type, union dnttentry *dn_bufp,
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;
@@ -3968,23 +3968,28 @@ hpread_read_struct_type (dnttpointer hp_type, union dnttentry *dn_bufp,
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
@@ -4428,7 +4433,7 @@ fix_static_member_physnames (struct type *type, char *class_name,
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);
@@ -4465,23 +4470,23 @@ fixup_class_method_type (struct type *class, struct type *method,
/* 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;
@@ -4850,7 +4855,7 @@ hpread_type_lookup (dnttpointer hp_type, struct objfile *objfile)
}
/* 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);
diff --git a/gdb/mdebugread.c b/gdb/mdebugread.c
index c974c9e874a..14d2c0f753e 100644
--- a/gdb/mdebugread.c
+++ b/gdb/mdebugread.c
@@ -832,7 +832,7 @@ parse_symbol (SYMR *sh, union aux_ext *ax, char *ext_sh, int bigend,
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
@@ -1604,7 +1604,7 @@ parse_type (int fd, union aux_ext *ax, unsigned int aux_index, int *bs,
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
diff --git a/gdb/p-lang.c b/gdb/p-lang.c
index 4796da5f17b..8e13b6e860a 100644
--- a/gdb/p-lang.c
+++ b/gdb/p-lang.c
@@ -58,7 +58,7 @@ is_pascal_string_type (struct type *type,int *length_pos,
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)
@@ -76,7 +76,7 @@ is_pascal_string_type (struct type *type,int *length_pos,
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 ?? */
diff --git a/gdb/valops.c b/gdb/valops.c
index cd5d4ca87f8..798e31fc646 100644
--- a/gdb/valops.c
+++ b/gdb/valops.c
@@ -1488,7 +1488,7 @@ hand_function_call (struct value *function, int nargs, struct value **args)
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.
diff --git a/gdb/x86-64-tdep.c b/gdb/x86-64-tdep.c
index 70a5d9cbb0f..94f57a5a539 100644
--- a/gdb/x86-64-tdep.c
+++ b/gdb/x86-64-tdep.c
@@ -372,18 +372,18 @@ classify_argument (struct type *type,
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]);
}
@@ -394,7 +394,7 @@ classify_argument (struct type *type,
{
int num;
- num = classify_argument (type->target_type,
+ num = classify_argument (TYPE_TARGET_TYPE (type),
subclasses, bit_offset);
if (!num)
return 0;
@@ -413,10 +413,10 @@ classify_argument (struct type *type,
{
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;