mirror of
https://sourceware.org/git/binutils-gdb.git
synced 2024-11-23 18:14:13 +08:00
2004-11-10 Andrew Cagney <cagney@gnu.org>
* value.h (COERCE_REF, COERCE_ARRAY, COERCE_NUMBER, COERCE_ENUM) (coerce_ref, coerce_array, coerce_number, coerce_enum): Replace macros with function declarations. * value.c (coerce_ref, coerce_array, coerce_number) (coerce_enum): New functions. (value_as_long, value_as_address): Update. * ada-lang.c (ada_coerce_ref, ada_value_binop) (ada_evaluate_subexp, ada_value_assign, ada_value_struct_elt): Update. * jv-lang.c (evaluate_subexp_java): Update. * valarith.c (value_less, value_neg, value_complement) (value_binop, value_add, value_subscript, value_x_binop) (value_logical_not, value_sub): Update. * valops.c (check_field, value_struct_elt, value_ind) (value_find_oload_method_list, value_cast, value_assign): Update. * eval.c (evaluate_subexp_standard): Update.
This commit is contained in:
parent
06987e6431
commit
994b921186
@ -1,3 +1,21 @@
|
||||
2004-11-10 Andrew Cagney <cagney@gnu.org>
|
||||
|
||||
* value.h (COERCE_REF, COERCE_ARRAY, COERCE_NUMBER, COERCE_ENUM)
|
||||
(coerce_ref, coerce_array, coerce_number, coerce_enum): Replace
|
||||
macros with function declarations.
|
||||
* value.c (coerce_ref, coerce_array, coerce_number)
|
||||
(coerce_enum): New functions.
|
||||
(value_as_long, value_as_address): Update.
|
||||
* ada-lang.c (ada_coerce_ref, ada_value_binop)
|
||||
(ada_evaluate_subexp, ada_value_assign, ada_value_struct_elt): Update.
|
||||
* jv-lang.c (evaluate_subexp_java): Update.
|
||||
* valarith.c (value_less, value_neg, value_complement)
|
||||
(value_binop, value_add, value_subscript, value_x_binop)
|
||||
(value_logical_not, value_sub): Update.
|
||||
* valops.c (check_field, value_struct_elt, value_ind)
|
||||
(value_find_oload_method_list, value_cast, value_assign): Update.
|
||||
* eval.c (evaluate_subexp_standard): Update.
|
||||
|
||||
2004-11-10 Mark Kettenis <kettenis@gnu.org>
|
||||
|
||||
* mips-tdep.c (mips32_relative_offset): Change return type to
|
||||
|
@ -2006,7 +2006,7 @@ ada_value_assign (struct value *toval, struct value *fromval)
|
||||
if (!toval->modifiable)
|
||||
error ("Left operand of assignment is not a modifiable lvalue.");
|
||||
|
||||
COERCE_REF (toval);
|
||||
toval = coerce_ref (toval);
|
||||
|
||||
if (VALUE_LVAL (toval) == lval_memory
|
||||
&& bits > 0
|
||||
@ -5479,7 +5479,7 @@ ada_value_struct_elt (struct value *arg, char *name, char *err)
|
||||
t1 = ada_check_typedef (t1);
|
||||
if (TYPE_CODE (t1) == TYPE_CODE_PTR)
|
||||
{
|
||||
COERCE_REF (arg);
|
||||
arg = coerce_ref (arg);
|
||||
t = t1;
|
||||
}
|
||||
}
|
||||
@ -5766,7 +5766,7 @@ ada_coerce_ref (struct value *val0)
|
||||
if (TYPE_CODE (VALUE_TYPE (val0)) == TYPE_CODE_REF)
|
||||
{
|
||||
struct value *val = val0;
|
||||
COERCE_REF (val);
|
||||
val = coerce_ref (val);
|
||||
val = unwrap_value (val);
|
||||
return ada_to_fixed_value (val);
|
||||
}
|
||||
@ -7030,8 +7030,8 @@ ada_value_binop (struct value *arg1, struct value *arg2, enum exp_opcode op)
|
||||
struct type *type1, *type2;
|
||||
LONGEST v, v1, v2;
|
||||
|
||||
COERCE_REF (arg1);
|
||||
COERCE_REF (arg2);
|
||||
arg1 = coerce_ref (arg1);
|
||||
arg2 = coerce_ref (arg2);
|
||||
type1 = base_type (ada_check_typedef (VALUE_TYPE (arg1)));
|
||||
type2 = base_type (ada_check_typedef (VALUE_TYPE (arg2)));
|
||||
|
||||
@ -7406,8 +7406,8 @@ ada_evaluate_subexp (struct type *expect_type, struct expression *exp,
|
||||
evaluate_subexp (NULL_TYPE, exp, pos, noside);
|
||||
LONGEST low_bound;
|
||||
LONGEST high_bound;
|
||||
COERCE_REF (low_bound_val);
|
||||
COERCE_REF (high_bound_val);
|
||||
low_bound_val = coerce_ref (low_bound_val);
|
||||
high_bound_val = coerce_ref (high_bound_val);
|
||||
low_bound = pos_atr (low_bound_val);
|
||||
high_bound = pos_atr (high_bound_val);
|
||||
|
||||
|
@ -1532,7 +1532,7 @@ evaluate_subexp_standard (struct type *expect_type,
|
||||
array or pointer type (like a plain int variable for example),
|
||||
then report this as an error. */
|
||||
|
||||
COERCE_REF (arg1);
|
||||
arg1 = coerce_ref (arg1);
|
||||
type = check_typedef (VALUE_TYPE (arg1));
|
||||
if (TYPE_CODE (type) != TYPE_CODE_ARRAY
|
||||
&& TYPE_CODE (type) != TYPE_CODE_PTR)
|
||||
|
@ -867,7 +867,7 @@ evaluate_subexp_java (struct type *expect_type, struct expression *exp,
|
||||
array or pointer type (like a plain int variable for example),
|
||||
then report this as an error. */
|
||||
|
||||
COERCE_REF (arg1);
|
||||
arg1 = coerce_ref (arg1);
|
||||
type = check_typedef (VALUE_TYPE (arg1));
|
||||
if (TYPE_CODE (type) == TYPE_CODE_PTR)
|
||||
type = check_typedef (TYPE_TARGET_TYPE (type));
|
||||
|
@ -91,8 +91,8 @@ value_add (struct value *arg1, struct value *arg2)
|
||||
LONGEST sz;
|
||||
struct type *type1, *type2, *valptrtype;
|
||||
|
||||
COERCE_ARRAY (arg1);
|
||||
COERCE_ARRAY (arg2);
|
||||
arg1 = coerce_array (arg1);
|
||||
arg2 = coerce_array (arg2);
|
||||
type1 = check_typedef (VALUE_TYPE (arg1));
|
||||
type2 = check_typedef (VALUE_TYPE (arg2));
|
||||
|
||||
@ -132,8 +132,8 @@ struct value *
|
||||
value_sub (struct value *arg1, struct value *arg2)
|
||||
{
|
||||
struct type *type1, *type2;
|
||||
COERCE_ARRAY (arg1);
|
||||
COERCE_ARRAY (arg2);
|
||||
arg1 = coerce_array (arg1);
|
||||
arg2 = coerce_array (arg2);
|
||||
type1 = check_typedef (VALUE_TYPE (arg1));
|
||||
type2 = check_typedef (VALUE_TYPE (arg2));
|
||||
|
||||
@ -182,7 +182,7 @@ value_subscript (struct value *array, struct value *idx)
|
||||
int c_style = current_language->c_style_arrays;
|
||||
struct type *tarray;
|
||||
|
||||
COERCE_REF (array);
|
||||
array = coerce_ref (array);
|
||||
tarray = check_typedef (VALUE_TYPE (array));
|
||||
|
||||
if (TYPE_CODE (tarray) == TYPE_CODE_ARRAY
|
||||
@ -346,10 +346,10 @@ value_x_binop (struct value *arg1, struct value *arg2, enum exp_opcode op,
|
||||
char tstr[13];
|
||||
int static_memfuncp;
|
||||
|
||||
COERCE_REF (arg1);
|
||||
COERCE_REF (arg2);
|
||||
COERCE_ENUM (arg1);
|
||||
COERCE_ENUM (arg2);
|
||||
arg1 = coerce_ref (arg1);
|
||||
arg2 = coerce_ref (arg2);
|
||||
arg1 = coerce_enum (arg1);
|
||||
arg2 = coerce_enum (arg2);
|
||||
|
||||
/* now we know that what we have to do is construct our
|
||||
arg vector and find the right function to call it with. */
|
||||
@ -508,8 +508,8 @@ value_x_unop (struct value *arg1, enum exp_opcode op, enum noside noside)
|
||||
char tstr[13], mangle_tstr[13];
|
||||
int static_memfuncp, nargs;
|
||||
|
||||
COERCE_REF (arg1);
|
||||
COERCE_ENUM (arg1);
|
||||
arg1 = coerce_ref (arg1);
|
||||
arg1 = coerce_enum (arg1);
|
||||
|
||||
/* now we know that what we have to do is construct our
|
||||
arg vector and find the right function to call it with. */
|
||||
@ -747,8 +747,8 @@ value_binop (struct value *arg1, struct value *arg2, enum exp_opcode op)
|
||||
struct value *val;
|
||||
struct type *type1, *type2;
|
||||
|
||||
COERCE_REF (arg1);
|
||||
COERCE_REF (arg2);
|
||||
arg1 = coerce_ref (arg1);
|
||||
arg2 = coerce_ref (arg2);
|
||||
type1 = check_typedef (VALUE_TYPE (arg1));
|
||||
type2 = check_typedef (VALUE_TYPE (arg2));
|
||||
|
||||
@ -1155,7 +1155,7 @@ value_logical_not (struct value *arg1)
|
||||
char *p;
|
||||
struct type *type1;
|
||||
|
||||
COERCE_NUMBER (arg1);
|
||||
arg1 = coerce_number (arg1);
|
||||
type1 = check_typedef (VALUE_TYPE (arg1));
|
||||
|
||||
if (TYPE_CODE (type1) == TYPE_CODE_FLT)
|
||||
@ -1216,8 +1216,8 @@ value_equal (struct value *arg1, struct value *arg2)
|
||||
enum type_code code2;
|
||||
int is_int1, is_int2;
|
||||
|
||||
COERCE_ARRAY (arg1);
|
||||
COERCE_ARRAY (arg2);
|
||||
arg1 = coerce_array (arg1);
|
||||
arg2 = coerce_array (arg2);
|
||||
|
||||
type1 = check_typedef (VALUE_TYPE (arg1));
|
||||
type2 = check_typedef (VALUE_TYPE (arg2));
|
||||
@ -1275,8 +1275,8 @@ value_less (struct value *arg1, struct value *arg2)
|
||||
struct type *type1, *type2;
|
||||
int is_int1, is_int2;
|
||||
|
||||
COERCE_ARRAY (arg1);
|
||||
COERCE_ARRAY (arg2);
|
||||
arg1 = coerce_array (arg1);
|
||||
arg2 = coerce_array (arg2);
|
||||
|
||||
type1 = check_typedef (VALUE_TYPE (arg1));
|
||||
type2 = check_typedef (VALUE_TYPE (arg2));
|
||||
@ -1317,7 +1317,7 @@ value_neg (struct value *arg1)
|
||||
struct type *type;
|
||||
struct type *result_type = VALUE_TYPE (arg1);
|
||||
|
||||
COERCE_REF (arg1);
|
||||
arg1 = coerce_ref (arg1);
|
||||
|
||||
type = check_typedef (VALUE_TYPE (arg1));
|
||||
|
||||
@ -1345,7 +1345,7 @@ value_complement (struct value *arg1)
|
||||
struct type *type;
|
||||
struct type *result_type = VALUE_TYPE (arg1);
|
||||
|
||||
COERCE_REF (arg1);
|
||||
arg1 = coerce_ref (arg1);
|
||||
|
||||
type = check_typedef (VALUE_TYPE (arg1));
|
||||
|
||||
|
16
gdb/valops.c
16
gdb/valops.c
@ -212,7 +212,7 @@ value_cast (struct type *type, struct value *arg2)
|
||||
|
||||
CHECK_TYPEDEF (type);
|
||||
code1 = TYPE_CODE (type);
|
||||
COERCE_REF (arg2);
|
||||
arg2 = coerce_ref (arg2);
|
||||
type2 = check_typedef (VALUE_TYPE (arg2));
|
||||
|
||||
/* A cast to an undetermined-length array_type, such as (TYPE [])OBJECT,
|
||||
@ -524,13 +524,13 @@ value_assign (struct value *toval, struct value *fromval)
|
||||
if (!toval->modifiable)
|
||||
error ("Left operand of assignment is not a modifiable lvalue.");
|
||||
|
||||
COERCE_REF (toval);
|
||||
toval = coerce_ref (toval);
|
||||
|
||||
type = VALUE_TYPE (toval);
|
||||
if (VALUE_LVAL (toval) != lval_internalvar)
|
||||
fromval = value_cast (type, fromval);
|
||||
else
|
||||
COERCE_ARRAY (fromval);
|
||||
fromval = coerce_array (fromval);
|
||||
CHECK_TYPEDEF (type);
|
||||
|
||||
/* Since modifying a register can trash the frame chain, and modifying memory
|
||||
@ -896,7 +896,7 @@ value_ind (struct value *arg1)
|
||||
struct type *base_type;
|
||||
struct value *arg2;
|
||||
|
||||
COERCE_ARRAY (arg1);
|
||||
arg1 = coerce_array (arg1);
|
||||
|
||||
base_type = check_typedef (VALUE_TYPE (arg1));
|
||||
|
||||
@ -1589,7 +1589,7 @@ value_struct_elt (struct value **argp, struct value **args,
|
||||
struct type *t;
|
||||
struct value *v;
|
||||
|
||||
COERCE_ARRAY (*argp);
|
||||
*argp = coerce_array (*argp);
|
||||
|
||||
t = check_typedef (VALUE_TYPE (*argp));
|
||||
|
||||
@ -1600,7 +1600,7 @@ value_struct_elt (struct value **argp, struct value **args,
|
||||
*argp = value_ind (*argp);
|
||||
/* Don't coerce fn pointer to fn and then back again! */
|
||||
if (TYPE_CODE (VALUE_TYPE (*argp)) != TYPE_CODE_FUNC)
|
||||
COERCE_ARRAY (*argp);
|
||||
*argp = coerce_array (*argp);
|
||||
t = check_typedef (VALUE_TYPE (*argp));
|
||||
}
|
||||
|
||||
@ -1799,7 +1799,7 @@ value_find_oload_method_list (struct value **argp, char *method, int offset,
|
||||
*argp = value_ind (*argp);
|
||||
/* Don't coerce fn pointer to fn and then back again! */
|
||||
if (TYPE_CODE (VALUE_TYPE (*argp)) != TYPE_CODE_FUNC)
|
||||
COERCE_ARRAY (*argp);
|
||||
*argp = coerce_array (*argp);
|
||||
t = check_typedef (VALUE_TYPE (*argp));
|
||||
}
|
||||
|
||||
@ -2320,7 +2320,7 @@ check_field (struct value *arg1, const char *name)
|
||||
{
|
||||
struct type *t;
|
||||
|
||||
COERCE_ARRAY (arg1);
|
||||
arg1 = coerce_array (arg1);
|
||||
|
||||
t = VALUE_TYPE (arg1);
|
||||
|
||||
|
43
gdb/value.c
43
gdb/value.c
@ -526,7 +526,7 @@ value_as_long (struct value *val)
|
||||
/* This coerces arrays and functions, which is necessary (e.g.
|
||||
in disassemble_command). It also dereferences references, which
|
||||
I suspect is the most logical thing to do. */
|
||||
COERCE_ARRAY (val);
|
||||
val = coerce_array (val);
|
||||
return unpack_long (VALUE_TYPE (val), VALUE_CONTENTS (val));
|
||||
}
|
||||
|
||||
@ -597,7 +597,7 @@ value_as_address (struct value *val)
|
||||
|| TYPE_CODE (VALUE_TYPE (val)) == TYPE_CODE_METHOD)
|
||||
return VALUE_ADDRESS (val);
|
||||
|
||||
COERCE_ARRAY (val);
|
||||
val = coerce_array (val);
|
||||
|
||||
/* Some architectures (e.g. Harvard), map instruction and data
|
||||
addresses onto a single large unified address space. For
|
||||
@ -1197,6 +1197,45 @@ value_from_double (struct type *type, DOUBLEST num)
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
struct value *
|
||||
coerce_ref (struct value *arg)
|
||||
{
|
||||
struct type *value_type_arg_tmp = check_typedef (VALUE_TYPE (arg));
|
||||
if (TYPE_CODE (value_type_arg_tmp) == TYPE_CODE_REF)
|
||||
arg = value_at_lazy (TYPE_TARGET_TYPE (value_type_arg_tmp),
|
||||
unpack_pointer (VALUE_TYPE (arg),
|
||||
VALUE_CONTENTS (arg)));
|
||||
return arg;
|
||||
}
|
||||
|
||||
struct value *
|
||||
coerce_array (struct value *arg)
|
||||
{
|
||||
arg = coerce_ref (arg);
|
||||
if (current_language->c_style_arrays
|
||||
&& TYPE_CODE (VALUE_TYPE (arg)) == TYPE_CODE_ARRAY)
|
||||
arg = value_coerce_array (arg);
|
||||
if (TYPE_CODE (VALUE_TYPE (arg)) == TYPE_CODE_FUNC)
|
||||
arg = value_coerce_function (arg);
|
||||
return arg;
|
||||
}
|
||||
|
||||
struct value *
|
||||
coerce_number (struct value *arg)
|
||||
{
|
||||
arg = coerce_array (arg);
|
||||
arg = coerce_enum (arg);
|
||||
return arg;
|
||||
}
|
||||
|
||||
struct value *
|
||||
coerce_enum (struct value *arg)
|
||||
{
|
||||
if (TYPE_CODE (check_typedef (VALUE_TYPE (arg))) == TYPE_CODE_ENUM)
|
||||
arg = value_cast (builtin_type_unsigned_int, arg);
|
||||
return arg;
|
||||
}
|
||||
|
||||
|
||||
/* Should we use DEPRECATED_EXTRACT_STRUCT_VALUE_ADDRESS instead of
|
||||
|
29
gdb/value.h
29
gdb/value.h
@ -226,14 +226,7 @@ extern int value_fetch_lazy (struct value *val);
|
||||
|
||||
/* Convert a REF to the object referenced. */
|
||||
|
||||
#define COERCE_REF(arg) \
|
||||
do { \
|
||||
struct type *value_type_arg_tmp = check_typedef (VALUE_TYPE (arg)); \
|
||||
if (TYPE_CODE (value_type_arg_tmp) == TYPE_CODE_REF) \
|
||||
arg = value_at_lazy (TYPE_TARGET_TYPE (value_type_arg_tmp), \
|
||||
unpack_pointer (VALUE_TYPE (arg), \
|
||||
VALUE_CONTENTS (arg))); \
|
||||
} while (0)
|
||||
extern struct value *coerce_ref (struct value *value);
|
||||
|
||||
/* If ARG is an array, convert it to a pointer.
|
||||
If ARG is an enum, convert it to an integer.
|
||||
@ -241,26 +234,12 @@ extern int value_fetch_lazy (struct value *val);
|
||||
|
||||
References are dereferenced. */
|
||||
|
||||
#define COERCE_ARRAY(arg) \
|
||||
do { \
|
||||
COERCE_REF(arg); \
|
||||
if (current_language->c_style_arrays \
|
||||
&& TYPE_CODE (VALUE_TYPE (arg)) == TYPE_CODE_ARRAY) \
|
||||
arg = value_coerce_array (arg); \
|
||||
if (TYPE_CODE (VALUE_TYPE (arg)) == TYPE_CODE_FUNC) \
|
||||
arg = value_coerce_function (arg); \
|
||||
} while (0)
|
||||
|
||||
#define COERCE_NUMBER(arg) \
|
||||
do { COERCE_ARRAY(arg); COERCE_ENUM(arg); } while (0)
|
||||
extern struct value *coerce_array (struct value *value);
|
||||
extern struct value *coerce_number (struct value *value);
|
||||
|
||||
/* If ARG is an enum, convert it to an integer. */
|
||||
|
||||
#define COERCE_ENUM(arg) \
|
||||
do { \
|
||||
if (TYPE_CODE (check_typedef (VALUE_TYPE (arg))) == TYPE_CODE_ENUM) \
|
||||
arg = value_cast (builtin_type_unsigned_int, arg); \
|
||||
} while (0)
|
||||
extern struct value *coerce_enum (struct value *value);
|
||||
|
||||
/* Internal variables (variables for convenience of use of debugger)
|
||||
are recorded as a chain of these structures. */
|
||||
|
Loading…
Reference in New Issue
Block a user