aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPer Bothner <per@bothner.com>1995-11-30 01:43:37 +0000
committerPer Bothner <per@bothner.com>1995-11-30 01:43:37 +0000
commit940d596798931962895918454d2ca6bd14b83b1b (patch)
tree0b1efd109bb8fe8f038446ea785b2dd91e35ebeb
parentd1f4065e6499c42088b36a058b1de4035d051392 (diff)
downloadgdb-940d596798931962895918454d2ca6bd14b83b1b.zip
gdb-940d596798931962895918454d2ca6bd14b83b1b.tar.gz
gdb-940d596798931962895918454d2ca6bd14b83b1b.tar.bz2
* alpha-tdep.c, c-exp.y, h8500-tdep.c, f-exp.y, f-valprint.c,
findvar.c, hppa-tdep.c, infcmd.c, language.c, printcmd.c, rs6000-tdep.c, symmisc.c, symtab.c: Add check_typedef/CHECK_TYPEDEF as needed.
-rw-r--r--gdb/ChangeLog5
-rw-r--r--gdb/alpha-tdep.c12
-rw-r--r--gdb/c-exp.y1
-rw-r--r--gdb/f-exp.y1
-rw-r--r--gdb/f-valprint.c5
-rw-r--r--gdb/h8500-tdep.c4
-rw-r--r--gdb/hppa-tdep.c17
-rw-r--r--gdb/language.c38
-rw-r--r--gdb/rs6000-tdep.c16
-rw-r--r--gdb/symtab.c10
10 files changed, 69 insertions, 40 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index b064c1c..7c7b994 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -23,6 +23,11 @@ Wed Nov 29 13:35:18 1995 Per Bothner <bothner@kalessin.cygnus.com>
* gdbtypes.c, ch-lang.c, ch-typeprint.c (numerous places):
Add check_typedef/CHECK_TYPEDEF as needed.
+ * alpha-tdep.c, c-exp.y, h8500-tdep.c, f-exp.y, f-valprint.c,
+ findvar.c, hppa-tdep.c, infcmd.c, language.c, printcmd.c,
+ rs6000-tdep.c, symmisc.c, symtab.c:
+ Add check_typedef/CHECK_TYPEDEF as needed.
+
* top.c (command_line_input): Only strip out an initial #-comment.
Looking for internal comments is language-specific (breaks Scheme).
diff --git a/gdb/alpha-tdep.c b/gdb/alpha-tdep.c
index ce1c8ed..622ee44 100644
--- a/gdb/alpha-tdep.c
+++ b/gdb/alpha-tdep.c
@@ -729,21 +729,25 @@ alpha_push_arguments (nargs, args, sp, struct_return, struct_addr)
for (i = 0, m_arg = alpha_args; i < nargs; i++, m_arg++)
{
value_ptr arg = args[i];
+ struct type *arg_type = check_typedef (VALUE_TYPE (arg));
/* Cast argument to long if necessary as the compiler does it too. */
- switch (TYPE_CODE (VALUE_TYPE (arg)))
+ switch (TYPE_CODE (arg_type))
{
case TYPE_CODE_INT:
case TYPE_CODE_BOOL:
case TYPE_CODE_CHAR:
case TYPE_CODE_RANGE:
case TYPE_CODE_ENUM:
- if (TYPE_LENGTH (VALUE_TYPE (arg)) < TYPE_LENGTH (builtin_type_long))
- arg = value_cast (builtin_type_long, arg);
+ if (TYPE_LENGTH (arg_type) < TYPE_LENGTH (builtin_type_long))
+ {
+ arg_type = builtin_type_long;
+ arg = value_cast (arg_type, arg);
+ }
break;
default:
break;
}
- m_arg->len = TYPE_LENGTH (VALUE_TYPE (arg));
+ m_arg->len = TYPE_LENGTH (arg_type);
m_arg->offset = accumulate_size;
accumulate_size = (accumulate_size + m_arg->len + 7) & ~7;
m_arg->contents = VALUE_CONTENTS(arg);
diff --git a/gdb/c-exp.y b/gdb/c-exp.y
index 21096e0..f6bd88f 100644
--- a/gdb/c-exp.y
+++ b/gdb/c-exp.y
@@ -497,6 +497,7 @@ exp : VARIABLE
exp : SIZEOF '(' type ')' %prec UNARY
{ write_exp_elt_opcode (OP_LONG);
write_exp_elt_type (builtin_type_int);
+ CHECK_TYPEDEF ($3);
write_exp_elt_longcst ((LONGEST) TYPE_LENGTH ($3));
write_exp_elt_opcode (OP_LONG); }
;
diff --git a/gdb/f-exp.y b/gdb/f-exp.y
index ee97015..6b6aa98 100644
--- a/gdb/f-exp.y
+++ b/gdb/f-exp.y
@@ -418,6 +418,7 @@ exp : VARIABLE
exp : SIZEOF '(' type ')' %prec UNARY
{ write_exp_elt_opcode (OP_LONG);
write_exp_elt_type (builtin_type_f_integer);
+ CHECK_TYPEDEF ($3);
write_exp_elt_longcst ((LONGEST) TYPE_LENGTH ($3));
write_exp_elt_opcode (OP_LONG); }
;
diff --git a/gdb/f-valprint.c b/gdb/f-valprint.c
index 2b2d47b..1143b9d 100644
--- a/gdb/f-valprint.c
+++ b/gdb/f-valprint.c
@@ -211,7 +211,7 @@ f77_get_dynamic_length_of_aggregate (type)
/* Patch in a valid length value. */
TYPE_LENGTH (type) =
- (upper_bound - lower_bound + 1) * TYPE_LENGTH (TYPE_TARGET_TYPE (type));
+ (upper_bound - lower_bound + 1) * TYPE_LENGTH (check_typedef (TYPE_TARGET_TYPE (type)));
}
/* Function that sets up the array offset,size table for the array
@@ -376,6 +376,7 @@ f_val_print (type, valaddr, address, stream, format, deref_ref, recurse,
LONGEST val;
CORE_ADDR addr;
+ CHECK_TYPEDEF (type);
switch (TYPE_CODE (type))
{
case TYPE_CODE_STRING:
@@ -403,7 +404,7 @@ f_val_print (type, valaddr, address, stream, format, deref_ref, recurse,
else
{
addr = unpack_pointer (type, valaddr);
- elttype = TYPE_TARGET_TYPE (type);
+ elttype = check_typedef (TYPE_TARGET_TYPE (type));
if (TYPE_CODE (elttype) == TYPE_CODE_FUNC)
{
diff --git a/gdb/h8500-tdep.c b/gdb/h8500-tdep.c
index 0eb34ee..38a4859 100644
--- a/gdb/h8500-tdep.c
+++ b/gdb/h8500-tdep.c
@@ -572,14 +572,14 @@ h8500_set_trapped_internalvar (var, newval, bitpos, bitsize, offset)
struct type *type;
enum type_code newval_type_code;
- type = VALUE_TYPE (newval);
+ type = check_typedef (VALUE_TYPE (newval));
newval_type_code = TYPE_CODE (type);
if ((newval_type_code != TYPE_CODE_INT
&& newval_type_code != TYPE_CODE_PTR)
|| TYPE_LENGTH (type) != sizeof (new_regval))
error ("Illegal type (%s) for assignment to $%s\n",
- TYPE_NAME (type), var->name);
+ TYPE_NAME (VALUE_TYPE (newval)), var->name);
new_regval = *(long *) VALUE_CONTENTS_RAW (newval);
diff --git a/gdb/hppa-tdep.c b/gdb/hppa-tdep.c
index 62531a3..27f4eb4 100644
--- a/gdb/hppa-tdep.c
+++ b/gdb/hppa-tdep.c
@@ -1729,27 +1729,28 @@ target_write_pc (v, pid)
alignment required by their fields. */
static int
-hppa_alignof (arg)
- struct type *arg;
+hppa_alignof (type)
+ struct type *type;
{
int max_align, align, i;
- switch (TYPE_CODE (arg))
+ CHECK_TYPEDEf (type);
+ switch (TYPE_CODE (type))
{
case TYPE_CODE_PTR:
case TYPE_CODE_INT:
case TYPE_CODE_FLT:
- return TYPE_LENGTH (arg);
+ return TYPE_LENGTH (type);
case TYPE_CODE_ARRAY:
- return hppa_alignof (TYPE_FIELD_TYPE (arg, 0));
+ return hppa_alignof (TYPE_FIELD_TYPE (type, 0));
case TYPE_CODE_STRUCT:
case TYPE_CODE_UNION:
max_align = 2;
- for (i = 0; i < TYPE_NFIELDS (arg); i++)
+ for (i = 0; i < TYPE_NFIELDS (type); i++)
{
/* Bit fields have no real alignment. */
- if (!TYPE_FIELD_BITPOS (arg, i))
+ if (!TYPE_FIELD_BITPOS (type, i))
{
- align = hppa_alignof (TYPE_FIELD_TYPE (arg, i));
+ align = hppa_alignof (TYPE_FIELD_TYPE (type, i));
max_align = max (max_align, align);
}
}
diff --git a/gdb/language.c b/gdb/language.c
index 6dd066e..2504f86 100644
--- a/gdb/language.c
+++ b/gdb/language.c
@@ -436,24 +436,26 @@ struct type *
binop_result_type (v1, v2)
value_ptr v1, v2;
{
- int l1,l2,size,uns;
+ int size,uns;
+ struct type *t1 = check_typedef (VALUE_TYPE (v1));
+ struct type *t2 = check_typedef (VALUE_TYPE (v2));
- l1 = TYPE_LENGTH(VALUE_TYPE(v1));
- l2 = TYPE_LENGTH(VALUE_TYPE(v2));
+ int l1 = TYPE_LENGTH (t1);
+ int l2 = TYPE_LENGTH (t2);
switch(current_language->la_language)
{
case language_c:
case language_cplus:
- if (TYPE_CODE(VALUE_TYPE(v1))==TYPE_CODE_FLT)
- return TYPE_CODE(VALUE_TYPE(v2)) == TYPE_CODE_FLT && l2 > l1 ?
+ if (TYPE_CODE (t1)==TYPE_CODE_FLT)
+ return TYPE_CODE(t2) == TYPE_CODE_FLT && l2 > l1 ?
VALUE_TYPE(v2) : VALUE_TYPE(v1);
- else if (TYPE_CODE(VALUE_TYPE(v2))==TYPE_CODE_FLT)
- return TYPE_CODE(VALUE_TYPE(v1)) == TYPE_CODE_FLT && l1 > l2 ?
+ else if (TYPE_CODE(t2)==TYPE_CODE_FLT)
+ return TYPE_CODE(t1)) == TYPE_CODE_FLT && l1 > l2 ?
VALUE_TYPE(v1) : VALUE_TYPE(v2);
- else if (TYPE_UNSIGNED(VALUE_TYPE(v1)) && l1 > l2)
+ else if (TYPE_UNSIGNED(t1) && l1 > l2)
return VALUE_TYPE(v1);
- else if (TYPE_UNSIGNED(VALUE_TYPE(v2)) && l2 > l1)
+ else if (TYPE_UNSIGNED(t2) && l2 > l1)
return VALUE_TYPE(v2);
else /* Both are signed. Result is the longer type */
return l1 > l2 ? VALUE_TYPE(v1) : VALUE_TYPE(v2);
@@ -548,6 +550,7 @@ local_decimal_format_custom(pre)
return form;
}
+#if 0
/* This page contains functions that are used in type/range checking.
They all return zero if the type/range check fails.
@@ -569,6 +572,7 @@ int
simple_type(type)
struct type *type;
{
+ CHECK_TYPEDEF (type);
switch (TYPE_CODE (type)) {
case TYPE_CODE_INT:
case TYPE_CODE_CHAR:
@@ -591,6 +595,7 @@ int
ordered_type (type)
struct type *type;
{
+ CHECK_TYPEDEF (type);
switch (TYPE_CODE (type)) {
case TYPE_CODE_INT:
case TYPE_CODE_CHAR:
@@ -609,6 +614,7 @@ int
same_type (arg1, arg2)
struct type *arg1, *arg2;
{
+ CHECK_TYPEDEF (type);
if (structured_type(arg1) ? !structured_type(arg2) : structured_type(arg2))
/* One is structured and one isn't */
return 0;
@@ -627,6 +633,7 @@ int
integral_type (type)
struct type *type;
{
+ CHECK_TYPEDEF (type);
switch(current_language->la_language)
{
case language_c:
@@ -647,6 +654,7 @@ int
numeric_type (type)
struct type *type;
{
+ CHECK_TYPEDEF (type);
switch (TYPE_CODE (type)) {
case TYPE_CODE_INT:
case TYPE_CODE_FLT:
@@ -662,7 +670,8 @@ int
character_type (type)
struct type *type;
{
- switch(current_language->la_language)
+ CHECK_TYPEDEF (type);
+ switch(current_language->la_language)
{
case language_chill:
case language_m2:
@@ -683,7 +692,8 @@ int
string_type (type)
struct type *type;
{
- switch(current_language->la_language)
+ CHECK_TYPEDEF (type);
+ switch(current_language->la_language)
{
case language_chill:
case language_m2:
@@ -703,6 +713,7 @@ int
boolean_type (type)
struct type *type;
{
+ CHECK_TYPEDEF (type);
if (TYPE_CODE (type) == TYPE_CODE_BOOL)
return 1;
switch(current_language->la_language)
@@ -724,7 +735,8 @@ int
float_type (type)
struct type *type;
{
- return TYPE_CODE(type) == TYPE_CODE_FLT;
+ CHECK_TYPEDEF (type);
+ return TYPE_CODE(type) == TYPE_CODE_FLT;
}
/* Returns non-zero if the value is a pointer type */
@@ -741,6 +753,7 @@ int
structured_type(type)
struct type *type;
{
+ CHECK_TYPEDEF (type);
switch(current_language->la_language)
{
case language_c:
@@ -758,6 +771,7 @@ structured_type(type)
return (0);
}
}
+#endif
/* This page contains functions that return info about
(struct value) values used in GDB. */
diff --git a/gdb/rs6000-tdep.c b/gdb/rs6000-tdep.c
index 30702c6..dfbe488 100644
--- a/gdb/rs6000-tdep.c
+++ b/gdb/rs6000-tdep.c
@@ -694,8 +694,9 @@ push_arguments (nargs, args, sp, struct_return, struct_addr)
int argno; /* current argument number */
int argbytes; /* current argument byte */
char tmp_buffer [50];
- value_ptr arg;
int f_argno = 0; /* current floating point argno */
+ value_ptr arg;
+ struct type *type;
CORE_ADDR saved_sp, pc;
@@ -715,9 +716,10 @@ push_arguments (nargs, args, sp, struct_return, struct_addr)
for (argno=0, argbytes=0; argno < nargs && ii<8; ++ii) {
arg = args[argno];
- len = TYPE_LENGTH (VALUE_TYPE (arg));
+ type = check_typedef (VALUE_TYPE (arg);
+ len = TYPE_LENGTH (type);
- if (TYPE_CODE (VALUE_TYPE (arg)) == TYPE_CODE_FLT) {
+ if (TYPE_CODE (type) == TYPE_CODE_FLT) {
/* floating point arguments are passed in fpr's, as well as gpr's.
There are 13 fpr's reserved for passing parameters. At this point
@@ -769,7 +771,6 @@ ran_out_of_registers_for_arguments:
if ((argno < nargs) || argbytes) {
int space = 0, jj;
- value_ptr val;
if (argbytes) {
space += ((len - argbytes + 3) & -4);
@@ -779,7 +780,7 @@ ran_out_of_registers_for_arguments:
jj = argno;
for (; jj < nargs; ++jj) {
- val = args[jj];
+ value_ptr val = args[jj];
space += ((TYPE_LENGTH (VALUE_TYPE (val))) + 3) & -4;
}
@@ -808,11 +809,12 @@ ran_out_of_registers_for_arguments:
for (; argno < nargs; ++argno) {
arg = args[argno];
- len = TYPE_LENGTH (VALUE_TYPE (arg));
+ type = check_typedef (VALUE_TYPE (arg));
+ len = TYPE_LENGTH (type);
/* float types should be passed in fpr's, as well as in the stack. */
- if (TYPE_CODE (VALUE_TYPE (arg)) == TYPE_CODE_FLT && f_argno < 13) {
+ if (TYPE_CODE (type) == TYPE_CODE_FLT && f_argno < 13) {
if (len > 8)
printf_unfiltered (
diff --git a/gdb/symtab.c b/gdb/symtab.c
index ea2d60f..2b4037d 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -1636,7 +1636,7 @@ total_number_of_methods (type)
int n;
int count;
- check_stub_type (type);
+ CHECK_TYPEDEF (type);
count = TYPE_NFN_FIELDS_TOTAL (type);
for (n = 0; n < TYPE_N_BASECLASSES (type); n++)
@@ -1673,7 +1673,7 @@ find_methods (t, name, sym_arr)
(struct symtab **)NULL)))
{
int method_counter;
- /* FIXME: Shouldn't this just be check_stub_type (t)? */
+ /* FIXME: Shouldn't this just be CHECK_TYPEDEF (t)? */
t = SYMBOL_TYPE (sym_class);
for (method_counter = TYPE_NFN_FIELDS (t) - 1;
method_counter >= 0;
@@ -1960,8 +1960,9 @@ decode_line_1 (argptr, funfirstline, default_symtab, default_line, canonical)
(struct symtab **)NULL);
if (sym_class &&
- ( TYPE_CODE (SYMBOL_TYPE (sym_class)) == TYPE_CODE_STRUCT
- || TYPE_CODE (SYMBOL_TYPE (sym_class)) == TYPE_CODE_UNION))
+ (t = check_typedef (SYMBOL_TYPE (sym_class)),
+ (TYPE_CODE (t) == TYPE_CODE_STRUCT
+ || TYPE_CODE (t) == TYPE_CODE_UNION)))
{
/* Arg token is not digits => try it as a function name
Find the next token(everything up to end or next blank). */
@@ -2015,7 +2016,6 @@ decode_line_1 (argptr, funfirstline, default_symtab, default_line, canonical)
sym = 0;
i1 = 0; /* counter for the symbol array */
- t = SYMBOL_TYPE (sym_class);
sym_arr = (struct symbol **) alloca(total_number_of_methods (t)
* sizeof(struct symbol *));