From f23631e4447c390d81cd0dcf027b34077d2125b9 Mon Sep 17 00:00:00 2001 From: Andrew Cagney Date: Fri, 4 Jan 2002 05:20:09 +0000 Subject: [PATCH] s/value_ptr/struct value */ --- gdb/ChangeLog | 8 ++ gdb/doc/ChangeLog | 5 + gdb/doc/gdbint.texinfo | 4 +- gdb/scm-lang.c | 4 +- gdb/valarith.c | 87 +++++++-------- gdb/valops.c | 227 ++++++++++++++++++++------------------- gdb/value.h | 237 +++++++++++++++++++++-------------------- gdb/values.c | 136 +++++++++++------------ 8 files changed, 367 insertions(+), 341 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 0e46e9ba183..c7539f838ce 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,11 @@ +2002-01-03 Andrew Cagney + + * valarith.c: Replace value_ptr with struct value pointer. Remove + register attribute from value declarations. + * valops.c: Ditto. + * value.h: Ditto. + * scm-lang.c (scm_lookup_name): Ditto. + 2002-01-01 Mark Kettenis * i386-tdep.h (struct gdbarch_tdep): Add `os_ident' member. diff --git a/gdb/doc/ChangeLog b/gdb/doc/ChangeLog index 600d0a7fd0f..981b8500ef3 100644 --- a/gdb/doc/ChangeLog +++ b/gdb/doc/ChangeLog @@ -1,3 +1,8 @@ +2002-01-03 Andrew Cagney + + * gdbint.texinfo (Target Architecture Definition): Replace + value_ptr with struct value pointer. + 2002-01-02 Eli Zaretskii * gdb.texinfo (Free Software): Fix wording. diff --git a/gdb/doc/gdbint.texinfo b/gdb/doc/gdbint.texinfo index 3a2108d23cd..8ffdf526a0c 100644 --- a/gdb/doc/gdbint.texinfo +++ b/gdb/doc/gdbint.texinfo @@ -8,7 +8,7 @@ @ifinfo This file documents the internals of the GNU debugger @value{GDBN}. -Copyright 1990,1991,1992,1993,1994,1996,1998,1999,2000,2001 +Copyright 1990,1991,1992,1993,1994,1996,1998,1999,2000,2001,2002 Free Software Foundation, Inc. Contributed by Cygnus Solutions. Written by John Gilmore. Second Edition by Stan Shebs. @@ -2425,7 +2425,7 @@ If @var{type} is not a pointer or reference type, then this function will signal an internal error. @end deftypefun -@deftypefun CORE_ADDR value_as_address (value_ptr @var{val}) +@deftypefun CORE_ADDR value_as_address (struct value *@var{val}) Assuming that @var{val} is a pointer, return the address it represents, as appropriate for the current architecture. diff --git a/gdb/scm-lang.c b/gdb/scm-lang.c index ab71c831b0d..4f1295c2df3 100644 --- a/gdb/scm-lang.c +++ b/gdb/scm-lang.c @@ -1,5 +1,5 @@ /* Scheme/Guile language support routines for GDB, the GNU debugger. - Copyright 1995, 1996, 1998, 2000, 2001 + Copyright 1995, 1996, 1998, 2000, 2001, 2002 Free Software Foundation, Inc. This file is part of GDB. @@ -150,7 +150,7 @@ in_eval_c (void) static struct value * scm_lookup_name (char *str) { - value_ptr args[3]; + struct value *args[3]; int len = strlen (str); struct value *func; struct value *val; diff --git a/gdb/valarith.c b/gdb/valarith.c index 0696b322a47..d91f326787c 100644 --- a/gdb/valarith.c +++ b/gdb/valarith.c @@ -1,6 +1,6 @@ /* Perform arithmetic and other operations on values, for GDB. - Copyright 1986, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, - 1997, 1998, 1999, 2000 + Copyright 1986, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, + 1996, 1997, 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc. This file is part of GDB. @@ -38,15 +38,16 @@ #define TRUNCATION_TOWARDS_ZERO ((-5 / 2) == -2) #endif -static value_ptr value_subscripted_rvalue (value_ptr, value_ptr, int); +static struct value *value_subscripted_rvalue (struct value *, struct value *, int); void _initialize_valarith (void); -value_ptr -value_add (value_ptr arg1, value_ptr arg2) +struct value * +value_add (struct value *arg1, struct value *arg2) { - register value_ptr valint, valptr; + struct value *valint; + struct value *valptr; register int len; struct type *type1, *type2, *valptrtype; @@ -62,7 +63,7 @@ value_add (value_ptr arg1, value_ptr arg2) || TYPE_CODE (type2) == TYPE_CODE_INT)) /* Exactly one argument is a pointer, and one is an integer. */ { - value_ptr retval; + struct value *retval; if (TYPE_CODE (type1) == TYPE_CODE_PTR) { @@ -89,8 +90,8 @@ value_add (value_ptr arg1, value_ptr arg2) return value_binop (arg1, arg2, BINOP_ADD); } -value_ptr -value_sub (value_ptr arg1, value_ptr arg2) +struct value * +value_sub (struct value *arg1, struct value *arg2) { struct type *type1, *type2; COERCE_NUMBER (arg1); @@ -135,10 +136,10 @@ an integer nor a pointer of the same type."); FIXME: Perhaps we should validate that the index is valid and if verbosity is set, warn about invalid indices (but still use them). */ -value_ptr -value_subscript (value_ptr array, value_ptr idx) +struct value * +value_subscript (struct value *array, struct value *idx) { - value_ptr bound; + struct value *bound; int c_style = current_language->c_style_arrays; struct type *tarray; @@ -179,7 +180,7 @@ value_subscript (value_ptr array, value_ptr idx) { struct type *range_type = TYPE_INDEX_TYPE (tarray); LONGEST index = value_as_long (idx); - value_ptr v; + struct value *v; int offset, byte, bit_index; LONGEST lowerbound, upperbound; get_discrete_bounds (range_type, &lowerbound, &upperbound); @@ -211,15 +212,15 @@ value_subscript (value_ptr array, value_ptr idx) (eg, a vector register). This routine used to promote floats to doubles, but no longer does. */ -static value_ptr -value_subscripted_rvalue (value_ptr array, value_ptr idx, int lowerbound) +static struct value * +value_subscripted_rvalue (struct value *array, struct value *idx, int lowerbound) { struct type *array_type = check_typedef (VALUE_TYPE (array)); struct type *elt_type = check_typedef (TYPE_TARGET_TYPE (array_type)); unsigned int elt_size = TYPE_LENGTH (elt_type); LONGEST index = value_as_long (idx); unsigned int elt_offs = elt_size * longest_to_int (index - lowerbound); - value_ptr v; + struct value *v; if (index < lowerbound || elt_offs >= TYPE_LENGTH (array_type)) error ("no such vector element"); @@ -246,7 +247,7 @@ value_subscripted_rvalue (value_ptr array, value_ptr idx, int lowerbound) For now, we do not overload the `=' operator. */ int -binop_user_defined_p (enum exp_opcode op, value_ptr arg1, value_ptr arg2) +binop_user_defined_p (enum exp_opcode op, struct value *arg1, struct value *arg2) { struct type *type1, *type2; if (op == BINOP_ASSIGN || op == BINOP_CONCAT) @@ -268,7 +269,7 @@ binop_user_defined_p (enum exp_opcode op, value_ptr arg1, value_ptr arg2) For now, we do not overload the `&' operator. */ int -unop_user_defined_p (enum exp_opcode op, value_ptr arg1) +unop_user_defined_p (enum exp_opcode op, struct value *arg1) { struct type *type1; if (op == UNOP_ADDR) @@ -294,11 +295,11 @@ unop_user_defined_p (enum exp_opcode op, value_ptr arg1) is the opcode saying how to modify it. Otherwise, OTHEROP is unused. */ -value_ptr -value_x_binop (value_ptr arg1, value_ptr arg2, enum exp_opcode op, +struct value * +value_x_binop (struct value *arg1, struct value *arg2, enum exp_opcode op, enum exp_opcode otherop, enum noside noside) { - value_ptr *argvec; + struct value **argvec; char *ptr; char tstr[13]; int static_memfuncp; @@ -314,7 +315,7 @@ value_x_binop (value_ptr arg1, value_ptr arg2, enum exp_opcode op, if (TYPE_CODE (check_typedef (VALUE_TYPE (arg1))) != TYPE_CODE_STRUCT) error ("Can't do that binary op on that type"); /* FIXME be explicit */ - argvec = (value_ptr *) alloca (sizeof (value_ptr) * 4); + argvec = (struct value **) alloca (sizeof (struct value *) * 4); argvec[1] = value_addr (arg1); argvec[2] = arg2; argvec[3] = 0; @@ -457,10 +458,10 @@ value_x_binop (value_ptr arg1, value_ptr arg2, enum exp_opcode op, and return that value (where '@' is (almost) any unary operator which is legal for GNU C++). */ -value_ptr -value_x_unop (value_ptr arg1, enum exp_opcode op, enum noside noside) +struct value * +value_x_unop (struct value *arg1, enum exp_opcode op, enum noside noside) { - value_ptr *argvec; + struct value **argvec; char *ptr, *mangle_ptr; char tstr[13], mangle_tstr[13]; int static_memfuncp; @@ -474,7 +475,7 @@ value_x_unop (value_ptr arg1, enum exp_opcode op, enum noside noside) if (TYPE_CODE (check_typedef (VALUE_TYPE (arg1))) != TYPE_CODE_STRUCT) error ("Can't do that unary op on that type"); /* FIXME be explicit */ - argvec = (value_ptr *) alloca (sizeof (value_ptr) * 3); + argvec = (struct value **) alloca (sizeof (struct value *) * 3); argvec[1] = value_addr (arg1); argvec[2] = 0; @@ -557,10 +558,12 @@ value_x_unop (value_ptr arg1, enum exp_opcode op, enum noside noside) string values of length 1. */ -value_ptr -value_concat (value_ptr arg1, value_ptr arg2) +struct value * +value_concat (struct value *arg1, struct value *arg2) { - register value_ptr inval1, inval2, outval = NULL; + struct value *inval1; + struct value *inval2; + struct value *outval = NULL; int inval1len, inval2len; int count, idx; char *ptr; @@ -690,10 +693,10 @@ value_concat (value_ptr arg1, value_ptr arg2) Does not support addition and subtraction on pointers; use value_add or value_sub if you want to handle those possibilities. */ -value_ptr -value_binop (value_ptr arg1, value_ptr arg2, enum exp_opcode op) +struct value * +value_binop (struct value *arg1, struct value *arg2, enum exp_opcode op) { - register value_ptr val; + struct value *val; struct type *type1, *type2; COERCE_REF (arg1); @@ -1114,7 +1117,7 @@ value_binop (value_ptr arg1, value_ptr arg2, enum exp_opcode op) /* Simulate the C operator ! -- return 1 if ARG1 contains zero. */ int -value_logical_not (value_ptr arg1) +value_logical_not (struct value *arg1) { register int len; register char *p; @@ -1142,7 +1145,7 @@ value_logical_not (value_ptr arg1) necessarily null terminated) based on their length */ static int -value_strcmp (register value_ptr arg1, register value_ptr arg2) +value_strcmp (struct value *arg1, struct value *arg2) { int len1 = TYPE_LENGTH (VALUE_TYPE (arg1)); int len2 = TYPE_LENGTH (VALUE_TYPE (arg2)); @@ -1172,7 +1175,7 @@ value_strcmp (register value_ptr arg1, register value_ptr arg2) iff ARG1 and ARG2 have equal contents. */ int -value_equal (register value_ptr arg1, register value_ptr arg2) +value_equal (struct value *arg1, struct value *arg2) { register int len; register char *p1, *p2; @@ -1231,7 +1234,7 @@ value_equal (register value_ptr arg1, register value_ptr arg2) iff ARG1's contents are less than ARG2's. */ int -value_less (register value_ptr arg1, register value_ptr arg2) +value_less (struct value *arg1, struct value *arg2) { register enum type_code code1; register enum type_code code2; @@ -1272,8 +1275,8 @@ value_less (register value_ptr arg1, register value_ptr arg2) /* The unary operators - and ~. Both free the argument ARG1. */ -value_ptr -value_neg (register value_ptr arg1) +struct value * +value_neg (struct value *arg1) { register struct type *type; register struct type *result_type = VALUE_TYPE (arg1); @@ -1301,8 +1304,8 @@ value_neg (register value_ptr arg1) } } -value_ptr -value_complement (register value_ptr arg1) +struct value * +value_complement (struct value *arg1) { register struct type *type; register struct type *result_type = VALUE_TYPE (arg1); @@ -1349,8 +1352,8 @@ value_bit_index (struct type *type, char *valaddr, int index) return (word >> rel_index) & 1; } -value_ptr -value_in (value_ptr element, value_ptr set) +struct value * +value_in (struct value *element, struct value *set) { int member; struct type *settype = check_typedef (VALUE_TYPE (set)); diff --git a/gdb/valops.c b/gdb/valops.c index 4e14b095e17..cfc6937da00 100644 --- a/gdb/valops.c +++ b/gdb/valops.c @@ -1,6 +1,7 @@ /* Perform non-arithmetic operations on values, for GDB. - Copyright 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, - 1996, 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc. + Copyright 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, + 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002 + Free Software Foundation, Inc. This file is part of GDB. @@ -43,28 +44,28 @@ extern int hp_som_som_object_present; extern int overload_debug; /* Local functions. */ -static int typecmp (int staticp, struct type *t1[], value_ptr t2[]); +static int typecmp (int staticp, struct type *t1[], struct value *t2[]); -static CORE_ADDR find_function_addr (value_ptr, struct type **); -static value_ptr value_arg_coerce (value_ptr, struct type *, int); +static CORE_ADDR find_function_addr (struct value *, struct type **); +static struct value *value_arg_coerce (struct value *, struct type *, int); -static CORE_ADDR value_push (CORE_ADDR, value_ptr); +static CORE_ADDR value_push (CORE_ADDR, struct value *); -static value_ptr search_struct_field (char *, value_ptr, int, +static struct value *search_struct_field (char *, struct value *, int, struct type *, int); -static value_ptr search_struct_method (char *, value_ptr *, - value_ptr *, +static struct value *search_struct_method (char *, struct value **, + struct value **, int, int *, struct type *); static int check_field_in (struct type *, const char *); static CORE_ADDR allocate_space_in_inferior (int); -static value_ptr cast_into_complex (struct type *, value_ptr); +static struct value *cast_into_complex (struct type *, struct value *); -static struct fn_field *find_method_list (value_ptr * argp, char *method, +static struct fn_field *find_method_list (struct value ** argp, char *method, int offset, int *static_memfuncp, struct type *type, int *num_fns, struct type **basetype, @@ -91,7 +92,7 @@ int unwind_on_signal_p = 0; /* Find the address of function name NAME in the inferior. */ -value_ptr +struct value * find_function_in_inferior (char *name) { register struct symbol *sym; @@ -131,11 +132,11 @@ find_function_in_inferior (char *name) /* Allocate NBYTES of space in the inferior using the inferior's malloc and return a value that is a pointer to the allocated space. */ -value_ptr +struct value * value_allocate_space_in_inferior (int len) { - value_ptr blocklen; - register value_ptr val = find_function_in_inferior ("malloc"); + struct value *blocklen; + struct value *val = find_function_in_inferior ("malloc"); blocklen = value_from_longest (builtin_type_int, (LONGEST) len); val = call_function_by_hand (val, 1, &blocklen); @@ -160,8 +161,8 @@ allocate_space_in_inferior (int len) and if ARG2 is an lvalue it can be cast into anything at all. */ /* In C++, casts may change pointer or object representations. */ -value_ptr -value_cast (struct type *type, register value_ptr arg2) +struct value * +value_cast (struct type *type, struct value *arg2) { register enum type_code code1; register enum type_code code2; @@ -241,7 +242,7 @@ value_cast (struct type *type, register value_ptr arg2) /* Look in the type of the source to see if it contains the type of the target as a superclass. If so, we'll need to offset the object in addition to changing its type. */ - value_ptr v = search_struct_field (type_name_no_tag (type), + struct value *v = search_struct_field (type_name_no_tag (type), arg2, 0, type2, 1); if (v) { @@ -261,7 +262,7 @@ value_cast (struct type *type, register value_ptr arg2) (code2 == TYPE_CODE_PTR)) { unsigned int *ptr; - value_ptr retvalp; + struct value *retvalp; switch (TYPE_CODE (TYPE_TARGET_TYPE (type2))) { @@ -331,7 +332,7 @@ value_cast (struct type *type, register value_ptr arg2) && TYPE_CODE (t2) == TYPE_CODE_STRUCT && !value_logical_not (arg2)) { - value_ptr v; + struct value *v; /* Look in the type of the source to see if it contains the type of the target as a superclass. If so, we'll need to @@ -358,7 +359,7 @@ value_cast (struct type *type, register value_ptr arg2) value_zero (t1, not_lval), 0, t1, 1); if (v) { - value_ptr v2 = value_ind (arg2); + struct value *v2 = value_ind (arg2); VALUE_ADDRESS (v2) -= VALUE_ADDRESS (v) + VALUE_OFFSET (v); @@ -383,7 +384,7 @@ value_cast (struct type *type, register value_ptr arg2) else if (chill_varying_type (type)) { struct type *range1, *range2, *eltype1, *eltype2; - value_ptr val; + struct value *val; int count1, count2; LONGEST low_bound, high_bound; char *valaddr, *valaddr_data; @@ -441,10 +442,10 @@ value_cast (struct type *type, register value_ptr arg2) /* Create a value of type TYPE that is zero, and return it. */ -value_ptr +struct value * value_zero (struct type *type, enum lval_type lv) { - register value_ptr val = allocate_value (type); + struct value *val = allocate_value (type); memset (VALUE_CONTENTS (val), 0, TYPE_LENGTH (check_typedef (type))); VALUE_LVAL (val) = lv; @@ -464,10 +465,10 @@ value_zero (struct type *type, enum lval_type lv) Note: value_at does *NOT* handle embedded offsets; perform such adjustments before or after calling it. */ -value_ptr +struct value * value_at (struct type *type, CORE_ADDR addr, asection *sect) { - register value_ptr val; + struct value *val; if (TYPE_CODE (check_typedef (type)) == TYPE_CODE_VOID) error ("Attempt to dereference a generic pointer."); @@ -485,10 +486,10 @@ value_at (struct type *type, CORE_ADDR addr, asection *sect) /* Return a lazy value with type TYPE located at ADDR (cf. value_at). */ -value_ptr +struct value * value_at_lazy (struct type *type, CORE_ADDR addr, asection *sect) { - register value_ptr val; + struct value *val; if (TYPE_CODE (check_typedef (type)) == TYPE_CODE_VOID) error ("Attempt to dereference a generic pointer."); @@ -516,7 +517,7 @@ value_at_lazy (struct type *type, CORE_ADDR addr, asection *sect) value is ignored. */ int -value_fetch_lazy (register value_ptr val) +value_fetch_lazy (struct value *val) { CORE_ADDR addr = VALUE_ADDRESS (val) + VALUE_OFFSET (val); int length = TYPE_LENGTH (VALUE_ENCLOSING_TYPE (val)); @@ -533,11 +534,11 @@ value_fetch_lazy (register value_ptr val) /* Store the contents of FROMVAL into the location of TOVAL. Return a new value with the location of TOVAL and contents of FROMVAL. */ -value_ptr -value_assign (register value_ptr toval, register value_ptr fromval) +struct value * +value_assign (struct value *toval, struct value *fromval) { register struct type *type; - register value_ptr val; + struct value *val; char *raw_buffer = (char*) alloca (MAX_REGISTER_RAW_SIZE); int use_buffer = 0; @@ -798,10 +799,10 @@ value_assign (register value_ptr toval, register value_ptr fromval) /* Extend a value VAL to COUNT repetitions of its type. */ -value_ptr -value_repeat (value_ptr arg1, int count) +struct value * +value_repeat (struct value *arg1, int count) { - register value_ptr val; + struct value *val; if (VALUE_LVAL (arg1) != lval_memory) error ("Only values in memory can be extended with '@'."); @@ -819,10 +820,10 @@ value_repeat (value_ptr arg1, int count) return val; } -value_ptr +struct value * value_of_variable (struct symbol *var, struct block *b) { - value_ptr val; + struct value *val; struct frame_info *frame = NULL; if (!b) @@ -871,8 +872,8 @@ value_of_variable (struct symbol *var, struct block *b) the coercion to pointer type. */ -value_ptr -value_coerce_array (value_ptr arg1) +struct value * +value_coerce_array (struct value *arg1) { register struct type *type = check_typedef (VALUE_TYPE (arg1)); @@ -886,10 +887,10 @@ value_coerce_array (value_ptr arg1) /* Given a value which is a function, return a value which is a pointer to it. */ -value_ptr -value_coerce_function (value_ptr arg1) +struct value * +value_coerce_function (struct value *arg1) { - value_ptr retval; + struct value *retval; if (VALUE_LVAL (arg1) != lval_memory) error ("Attempt to take address of value not located in memory."); @@ -902,10 +903,10 @@ value_coerce_function (value_ptr arg1) /* Return a pointer value for the object for which ARG1 is the contents. */ -value_ptr -value_addr (value_ptr arg1) +struct value * +value_addr (struct value *arg1) { - value_ptr arg2; + struct value *arg2; struct type *type = check_typedef (VALUE_TYPE (arg1)); if (TYPE_CODE (type) == TYPE_CODE_REF) @@ -940,11 +941,11 @@ value_addr (value_ptr arg1) /* Given a value of a pointer type, apply the C unary * operator to it. */ -value_ptr -value_ind (value_ptr arg1) +struct value * +value_ind (struct value *arg1) { struct type *base_type; - value_ptr arg2; + struct value *arg2; COERCE_ARRAY (arg1); @@ -1043,7 +1044,7 @@ push_bytes (CORE_ADDR sp, char *buffer, int len) it to be an argument to a function. */ static CORE_ADDR -value_push (register CORE_ADDR sp, value_ptr arg) +value_push (register CORE_ADDR sp, struct value *arg) { register int len = TYPE_LENGTH (VALUE_ENCLOSING_TYPE (arg)); register int container_len = len; @@ -1081,7 +1082,7 @@ value_push (register CORE_ADDR sp, value_ptr arg) #endif CORE_ADDR -default_push_arguments (int nargs, value_ptr *args, CORE_ADDR sp, +default_push_arguments (int nargs, struct value **args, CORE_ADDR sp, int struct_return, CORE_ADDR struct_addr) { /* ASSERT ( !struct_return); */ @@ -1140,8 +1141,8 @@ standard_coerce_float_to_double (struct type *formal, struct type *actual) If PARAM_TYPE is non-NULL, it is the expected parameter type. IS_PROTOTYPED is non-zero if the function declaration is prototyped. */ -static value_ptr -value_arg_coerce (value_ptr arg, struct type *param_type, int is_prototyped) +static struct value * +value_arg_coerce (struct value *arg, struct type *param_type, int is_prototyped) { register struct type *arg_type = check_typedef (VALUE_TYPE (arg)); register struct type *type @@ -1217,7 +1218,7 @@ value_arg_coerce (value_ptr arg, struct type *param_type, int is_prototyped) Calls error() if the function is not valid for calling. */ static CORE_ADDR -find_function_addr (value_ptr function, struct type **retval_type) +find_function_addr (struct value *function, struct type **retval_type) { register struct type *ftype = check_typedef (VALUE_TYPE (function)); register enum type_code code = TYPE_CODE (ftype); @@ -1283,10 +1284,8 @@ find_function_addr (value_ptr function, struct type **retval_type) ARGS is modified to contain coerced values. */ -static value_ptr hand_function_call (value_ptr function, int nargs, - value_ptr * args); -static value_ptr -hand_function_call (value_ptr function, int nargs, value_ptr *args) +static struct value * +hand_function_call (struct value *function, int nargs, struct value **args) { register CORE_ADDR sp; register int i; @@ -1777,15 +1776,15 @@ the function call).", name); #ifdef VALUE_RETURNED_FROM_STACK if (struct_return) - return (value_ptr) VALUE_RETURNED_FROM_STACK (value_type, struct_addr); + return (struct value *) VALUE_RETURNED_FROM_STACK (value_type, struct_addr); #endif return value_being_returned (value_type, retbuf, struct_return); } } -value_ptr -call_function_by_hand (value_ptr function, int nargs, value_ptr *args) +struct value * +call_function_by_hand (struct value *function, int nargs, struct value **args) { if (CALL_DUMMY_P) { @@ -1809,13 +1808,13 @@ call_function_by_hand (value_ptr function, int nargs, value_ptr *args) first element, and all elements must have the same size (though we don't currently enforce any restriction on their types). */ -value_ptr -value_array (int lowbound, int highbound, value_ptr *elemvec) +struct value * +value_array (int lowbound, int highbound, struct value **elemvec) { int nelem; int idx; unsigned int typelength; - value_ptr val; + struct value *val; struct type *rangetype; struct type *arraytype; CORE_ADDR addr; @@ -1881,10 +1880,10 @@ value_array (int lowbound, int highbound, value_ptr *elemvec) zero and an upper bound of LEN - 1. Also note that the string may contain embedded null bytes. */ -value_ptr +struct value * value_string (char *ptr, int len) { - value_ptr val; + struct value *val; int lowbound = current_language->string_lower_bound; struct type *rangetype = create_range_type ((struct type *) NULL, builtin_type_int, @@ -1911,10 +1910,10 @@ value_string (char *ptr, int len) return (val); } -value_ptr +struct value * value_bitstring (char *ptr, int len) { - value_ptr val; + struct value *val; struct type *domain_type = create_range_type (NULL, builtin_type_int, 0, len - 1); struct type *type = create_set_type ((struct type *) NULL, domain_type); @@ -1940,7 +1939,7 @@ value_bitstring (char *ptr, int len) requested operation is type secure, shouldn't we? FIXME. */ static int -typecmp (int staticp, struct type *t1[], value_ptr t2[]) +typecmp (int staticp, struct type *t1[], struct value *t2[]) { int i; @@ -2012,8 +2011,8 @@ typecmp (int staticp, struct type *t1[], value_ptr t2[]) If LOOKING_FOR_BASECLASS, then instead of looking for struct fields, look for a baseclass named NAME. */ -static value_ptr -search_struct_field (char *name, register value_ptr arg1, int offset, +static struct value * +search_struct_field (char *name, struct value *arg1, int offset, register struct type *type, int looking_for_baseclass) { int i; @@ -2028,7 +2027,7 @@ search_struct_field (char *name, register value_ptr arg1, int offset, if (t_field_name && (strcmp_iw (t_field_name, name) == 0)) { - value_ptr v; + struct value *v; if (TYPE_FIELD_STATIC (type, i)) v = value_static_field (type, i); else @@ -2056,7 +2055,7 @@ search_struct_field (char *name, register value_ptr arg1, int offset, Each is represented as a struct, with a member for each . */ - value_ptr v; + struct value *v; int new_offset = offset; /* This is pretty gross. In G++, the offset in an anonymous @@ -2079,7 +2078,7 @@ search_struct_field (char *name, register value_ptr arg1, int offset, for (i = 0; i < nbases; i++) { - value_ptr v; + struct value *v; struct type *basetype = check_typedef (TYPE_BASECLASS (type, i)); /* If we are looking for baseclasses, this is what we get when we hit them. But it could happen that the base part's member name @@ -2091,7 +2090,7 @@ search_struct_field (char *name, register value_ptr arg1, int offset, if (BASETYPE_VIA_VIRTUAL (type, i)) { int boffset; - value_ptr v2 = allocate_value (basetype); + struct value *v2 = allocate_value (basetype); boffset = baseclass_offset (type, i, VALUE_CONTENTS (arg1) + offset, @@ -2173,7 +2172,7 @@ find_rt_vbase_offset (struct type *type, struct type *basetype, char *valaddr, int index; /* displacement to use in virtual table */ int skip; - value_ptr vp; + struct value *vp; CORE_ADDR vtbl; /* the virtual table pointer */ struct type *pbc; /* the primary base class */ @@ -2241,13 +2240,13 @@ find_rt_vbase_offset (struct type *type, struct type *basetype, char *valaddr, If found, return value, else if name matched and args not return (value)-1, else return NULL. */ -static value_ptr -search_struct_method (char *name, register value_ptr *arg1p, - register value_ptr *args, int offset, +static struct value * +search_struct_method (char *name, struct value **arg1p, + struct value **args, int offset, int *static_memfuncp, register struct type *type) { int i; - value_ptr v; + struct value *v; int name_matched = 0; char dem_opname[64]; @@ -2346,7 +2345,7 @@ search_struct_method (char *name, register value_ptr *arg1p, } v = search_struct_method (name, arg1p, args, base_offset + offset, static_memfuncp, TYPE_BASECLASS (type, i)); - if (v == (value_ptr) - 1) + if (v == (struct value *) - 1) { name_matched = 1; } @@ -2358,7 +2357,7 @@ search_struct_method (char *name, register value_ptr *arg1p, } } if (name_matched) - return (value_ptr) - 1; + return (struct value *) - 1; else return NULL; } @@ -2377,12 +2376,12 @@ search_struct_method (char *name, register value_ptr *arg1p, ERR is an error message to be printed in case the field is not found. */ -value_ptr -value_struct_elt (register value_ptr *argp, register value_ptr *args, +struct value * +value_struct_elt (struct value **argp, struct value **args, char *name, int *static_memfuncp, char *err) { register struct type *t; - value_ptr v; + struct value *v; COERCE_ARRAY (*argp); @@ -2428,7 +2427,7 @@ value_struct_elt (register value_ptr *argp, register value_ptr *args, v = search_struct_method (name, argp, args, 0, static_memfuncp, t); - if (v == (value_ptr) - 1) + if (v == (struct value *) - 1) error ("Cannot take address of a method"); else if (v == 0) { @@ -2466,7 +2465,7 @@ value_struct_elt (register value_ptr *argp, register value_ptr *args, else v = search_struct_method (name, argp, args, 0, static_memfuncp, t); - if (v == (value_ptr) - 1) + if (v == (struct value *) - 1) { error ("One of the arguments you tried to pass to %s could not be converted to what the function wants.", name); } @@ -2497,7 +2496,7 @@ value_struct_elt (register value_ptr *argp, register value_ptr *args, * BOFFSET is the offset of the base subobject where the method is found */ static struct fn_field * -find_method_list (value_ptr *argp, char *method, int offset, +find_method_list (struct value **argp, char *method, int offset, int *static_memfuncp, struct type *type, int *num_fns, struct type **basetype, int *boffset) { @@ -2574,7 +2573,7 @@ find_method_list (value_ptr *argp, char *method, int offset, * BOFFSET is the offset of the base subobject which defines the method */ struct fn_field * -value_find_oload_method_list (value_ptr *argp, char *method, int offset, +value_find_oload_method_list (struct value **argp, char *method, int offset, int *static_memfuncp, int *num_fns, struct type **basetype, int *boffset) { @@ -2637,8 +2636,8 @@ value_find_oload_method_list (value_ptr *argp, char *method, int offset, int find_overload_match (struct type **arg_types, int nargs, char *name, int method, - int lax, value_ptr obj, struct symbol *fsym, - value_ptr *valp, struct symbol **symp, int *staticp) + int lax, struct value *obj, struct symbol *fsym, + struct value **valp, struct symbol **symp, int *staticp) { int nparms; struct type **parm_types; @@ -2654,7 +2653,7 @@ find_overload_match (struct type **arg_types, int nargs, char *name, int method, struct badness_vector *bv; /* A measure of how good an overloaded instance is */ struct badness_vector *oload_champ_bv = NULL; /* The measure for the current best match */ - value_ptr temp = obj; + struct value *temp = obj; struct fn_field *fns_ptr = NULL; /* For methods, the list of overloaded methods */ struct symbol **oload_syms = NULL; /* For non-methods, the list of overloaded function symbols */ int num_fns = 0; /* Number of overloaded instances being considered */ @@ -2942,7 +2941,7 @@ check_field_in (register struct type *type, const char *name) target structure/union is defined, otherwise, return 0. */ int -check_field (register value_ptr arg1, const char *name) +check_field (struct value *arg1, const char *name) { register struct type *t; @@ -2977,14 +2976,14 @@ check_field (register value_ptr arg1, const char *name) "pointers to member functions". This function is used to resolve user expressions of the form "DOMAIN::NAME". */ -value_ptr +struct value * value_struct_elt_for_reference (struct type *domain, int offset, struct type *curtype, char *name, struct type *intype) { register struct type *t = curtype; register int i; - value_ptr v; + struct value *v; if (TYPE_CODE (t) != TYPE_CODE_STRUCT && TYPE_CODE (t) != TYPE_CODE_UNION) @@ -3092,7 +3091,7 @@ value_struct_elt_for_reference (struct type *domain, int offset, } for (i = TYPE_N_BASECLASSES (t) - 1; i >= 0; i--) { - value_ptr v; + struct value *v; int base_offset; if (BASETYPE_VIA_VIRTUAL (t, i)) @@ -3117,9 +3116,9 @@ value_struct_elt_for_reference (struct type *domain, int offset, and refer to the values computed for the object pointed to. */ struct type * -value_rtti_target_type (value_ptr v, int *full, int *top, int *using_enc) +value_rtti_target_type (struct value *v, int *full, int *top, int *using_enc) { - value_ptr target; + struct value *target; target = value_ind (v); @@ -3136,15 +3135,15 @@ value_rtti_target_type (value_ptr v, int *full, int *top, int *using_enc) they can be supplied and a second call to value_rtti_type() is avoided. (Pass RTYPE == NULL if they're not available */ -value_ptr -value_full_object (value_ptr argp, struct type *rtype, int xfull, int xtop, +struct value * +value_full_object (struct value *argp, struct type *rtype, int xfull, int xtop, int xusing_enc) { struct type *real_type; int full = 0; int top = -1; int using_enc = 0; - value_ptr new_val; + struct value *new_val; if (rtype) { @@ -3195,14 +3194,14 @@ value_full_object (value_ptr argp, struct type *rtype, int xfull, int xtop, Flag COMPLAIN signals an error if the request is made in an inappropriate context. */ -value_ptr +struct value * value_of_this (int complain) { struct symbol *func, *sym; struct block *b; int i; static const char funny_this[] = "this"; - value_ptr this; + struct value *this; if (selected_frame == 0) { @@ -3252,12 +3251,12 @@ value_of_this (int complain) long, starting at LOWBOUND. The result has the same lower bound as the original ARRAY. */ -value_ptr -value_slice (value_ptr array, int lowbound, int length) +struct value * +value_slice (struct value *array, int lowbound, int length) { struct type *slice_range_type, *slice_type, *range_type; LONGEST lowerbound, upperbound, offset; - value_ptr slice; + struct value *slice; struct type *array_type; array_type = check_typedef (VALUE_TYPE (array)); COERCE_VARYING_ARRAY (array, array_type); @@ -3331,8 +3330,8 @@ value_slice (value_ptr array, int lowbound, int length) /* Assuming chill_varying_type (VARRAY) is true, return an equivalent value as a fixed-length array. */ -value_ptr -varying_to_slice (value_ptr varray) +struct value * +varying_to_slice (struct value *varray) { struct type *vtype = check_typedef (VALUE_TYPE (varray)); LONGEST length = unpack_long (TYPE_FIELD_TYPE (vtype, 0), @@ -3347,10 +3346,10 @@ varying_to_slice (value_ptr varray) that figures out precision inteligently as opposed to assuming doubles. FIXME: fmb */ -value_ptr -value_literal_complex (value_ptr arg1, value_ptr arg2, struct type *type) +struct value * +value_literal_complex (struct value *arg1, struct value *arg2, struct type *type) { - register value_ptr val; + struct value *val; struct type *real_type = TYPE_TARGET_TYPE (type); val = allocate_value (type); @@ -3366,15 +3365,15 @@ value_literal_complex (value_ptr arg1, value_ptr arg2, struct type *type) /* Cast a value into the appropriate complex data type. */ -static value_ptr -cast_into_complex (struct type *type, register value_ptr val) +static struct value * +cast_into_complex (struct type *type, struct value *val) { struct type *real_type = TYPE_TARGET_TYPE (type); if (TYPE_CODE (VALUE_TYPE (val)) == TYPE_CODE_COMPLEX) { struct type *val_real_type = TYPE_TARGET_TYPE (VALUE_TYPE (val)); - value_ptr re_val = allocate_value (val_real_type); - value_ptr im_val = allocate_value (val_real_type); + struct value *re_val = allocate_value (val_real_type); + struct value *im_val = allocate_value (val_real_type); memcpy (VALUE_CONTENTS_RAW (re_val), VALUE_CONTENTS (val), TYPE_LENGTH (val_real_type)); diff --git a/gdb/value.h b/gdb/value.h index 041933117a8..006ec111715 100644 --- a/gdb/value.h +++ b/gdb/value.h @@ -1,6 +1,6 @@ /* Definitions for values of C expressions, for GDB. - Copyright 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, - 1996, 1997, 1998, 1999, 2000, 2001 + Copyright 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, + 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc. This file is part of GDB. @@ -202,7 +202,7 @@ typedef struct value *value_ptr; VALUE_CONTENTS_ALL_RAW(val)) -extern int value_fetch_lazy (value_ptr val); +extern int value_fetch_lazy (struct value *val); #define VALUE_LVAL(val) (val)->lval #define VALUE_ADDRESS(val) (val)->location.address @@ -266,7 +266,7 @@ struct internalvar { struct internalvar *next; char *name; - value_ptr value; + struct value *value; }; /* Pointer to member function. Depends on compiler implementation. */ @@ -285,11 +285,11 @@ struct fn_field; extern void print_address_demangle (CORE_ADDR, struct ui_file *, int); -extern LONGEST value_as_long (value_ptr val); +extern LONGEST value_as_long (struct value *val); -extern DOUBLEST value_as_double (value_ptr val); +extern DOUBLEST value_as_double (struct value *val); -extern CORE_ADDR value_as_address (value_ptr val); +extern CORE_ADDR value_as_address (struct value *val); extern LONGEST unpack_long (struct type *type, char *valaddr); @@ -300,138 +300,144 @@ extern CORE_ADDR unpack_pointer (struct type *type, char *valaddr); extern LONGEST unpack_field_as_long (struct type *type, char *valaddr, int fieldno); -extern value_ptr value_from_longest (struct type *type, LONGEST num); +extern struct value *value_from_longest (struct type *type, LONGEST num); -extern value_ptr value_from_pointer (struct type *type, CORE_ADDR addr); +extern struct value *value_from_pointer (struct type *type, CORE_ADDR addr); -extern value_ptr value_from_double (struct type *type, DOUBLEST num); +extern struct value *value_from_double (struct type *type, DOUBLEST num); -extern value_ptr value_from_string (char *string); +extern struct value *value_from_string (char *string); -extern value_ptr value_at (struct type *type, CORE_ADDR addr, - asection * sect); +extern struct value *value_at (struct type *type, CORE_ADDR addr, + asection * sect); -extern value_ptr value_at_lazy (struct type *type, CORE_ADDR addr, - asection * sect); +extern struct value *value_at_lazy (struct type *type, CORE_ADDR addr, + asection * sect); -extern value_ptr value_from_register (struct type *type, int regnum, - struct frame_info *frame); +extern struct value *value_from_register (struct type *type, int regnum, + struct frame_info *frame); -extern value_ptr value_of_variable (struct symbol *var, struct block *b); +extern struct value *value_of_variable (struct symbol *var, struct block *b); -extern value_ptr value_of_register (int regnum); +extern struct value *value_of_register (int regnum); extern int symbol_read_needs_frame (struct symbol *); -extern value_ptr read_var_value (struct symbol *var, - struct frame_info *frame); +extern struct value *read_var_value (struct symbol *var, + struct frame_info *frame); -extern value_ptr locate_var_value (struct symbol *var, - struct frame_info *frame); +extern struct value *locate_var_value (struct symbol *var, + struct frame_info *frame); -extern value_ptr allocate_value (struct type *type); +extern struct value *allocate_value (struct type *type); -extern value_ptr allocate_repeat_value (struct type *type, int count); +extern struct value *allocate_repeat_value (struct type *type, int count); -extern value_ptr value_change_enclosing_type (value_ptr val, struct type *new_type); +extern struct value *value_change_enclosing_type (struct value *val, + struct type *new_type); -extern value_ptr value_mark (void); +extern struct value *value_mark (void); -extern void value_free_to_mark (value_ptr mark); +extern void value_free_to_mark (struct value *mark); -extern value_ptr value_string (char *ptr, int len); -extern value_ptr value_bitstring (char *ptr, int len); +extern struct value *value_string (char *ptr, int len); +extern struct value *value_bitstring (char *ptr, int len); -extern value_ptr value_array (int lowbound, int highbound, - value_ptr * elemvec); +extern struct value *value_array (int lowbound, int highbound, + struct value ** elemvec); -extern value_ptr value_concat (value_ptr arg1, value_ptr arg2); +extern struct value *value_concat (struct value *arg1, struct value *arg2); -extern value_ptr value_binop (value_ptr arg1, value_ptr arg2, - enum exp_opcode op); +extern struct value *value_binop (struct value *arg1, struct value *arg2, + enum exp_opcode op); -extern value_ptr value_add (value_ptr arg1, value_ptr arg2); +extern struct value *value_add (struct value *arg1, struct value *arg2); -extern value_ptr value_sub (value_ptr arg1, value_ptr arg2); +extern struct value *value_sub (struct value *arg1, struct value *arg2); -extern value_ptr value_coerce_array (value_ptr arg1); +extern struct value *value_coerce_array (struct value *arg1); -extern value_ptr value_coerce_function (value_ptr arg1); +extern struct value *value_coerce_function (struct value *arg1); -extern value_ptr value_ind (value_ptr arg1); +extern struct value *value_ind (struct value *arg1); -extern value_ptr value_addr (value_ptr arg1); +extern struct value *value_addr (struct value *arg1); -extern value_ptr value_assign (value_ptr toval, value_ptr fromval); +extern struct value *value_assign (struct value *toval, struct value *fromval); -extern value_ptr value_neg (value_ptr arg1); +extern struct value *value_neg (struct value *arg1); -extern value_ptr value_complement (value_ptr arg1); +extern struct value *value_complement (struct value *arg1); -extern value_ptr value_struct_elt (value_ptr * argp, value_ptr * args, - char *name, - int *static_memfuncp, char *err); +extern struct value *value_struct_elt (struct value **argp, + struct value **args, + char *name, int *static_memfuncp, + char *err); -extern value_ptr value_struct_elt_for_reference (struct type *domain, - int offset, - struct type *curtype, - char *name, - struct type *intype); +extern struct value *value_struct_elt_for_reference (struct type *domain, + int offset, + struct type *curtype, + char *name, + struct type *intype); -extern value_ptr value_static_field (struct type *type, int fieldno); +extern struct value *value_static_field (struct type *type, int fieldno); -extern struct fn_field *value_find_oload_method_list (value_ptr *, char *, +extern struct fn_field *value_find_oload_method_list (struct value **, char *, int, int *, int *, struct type **, int *); extern int find_overload_match (struct type **arg_types, int nargs, char *name, int method, int lax, - value_ptr obj, struct symbol *fsym, - value_ptr * valp, struct symbol **symp, + struct value *obj, struct symbol *fsym, + struct value **valp, struct symbol **symp, int *staticp); -extern value_ptr value_field (value_ptr arg1, int fieldno); +extern struct value *value_field (struct value *arg1, int fieldno); -extern value_ptr value_primitive_field (value_ptr arg1, int offset, - int fieldno, struct type *arg_type); +extern struct value *value_primitive_field (struct value *arg1, int offset, + int fieldno, + struct type *arg_type); -extern struct type *value_rtti_target_type (value_ptr, int *, int *, int *); +extern struct type *value_rtti_target_type (struct value *, int *, int *, + int *); -extern value_ptr value_full_object (value_ptr, struct type *, int, int, int); +extern struct value *value_full_object (struct value *, struct type *, int, + int, int); -extern value_ptr value_cast (struct type *type, value_ptr arg2); +extern struct value *value_cast (struct type *type, struct value *arg2); -extern value_ptr value_zero (struct type *type, enum lval_type lv); +extern struct value *value_zero (struct type *type, enum lval_type lv); -extern value_ptr value_repeat (value_ptr arg1, int count); +extern struct value *value_repeat (struct value *arg1, int count); -extern value_ptr value_subscript (value_ptr array, value_ptr idx); +extern struct value *value_subscript (struct value *array, struct value *idx); -extern value_ptr value_from_vtable_info (value_ptr arg, struct type *type); +extern struct value *value_from_vtable_info (struct value *arg, + struct type *type); -extern value_ptr value_being_returned (struct type *valtype, - char *retbuf, int struct_return); +extern struct value *value_being_returned (struct type *valtype, + char *retbuf, int struct_return); -extern value_ptr value_in (value_ptr element, value_ptr set); +extern struct value *value_in (struct value *element, struct value *set); extern int value_bit_index (struct type *type, char *addr, int index); -extern int using_struct_return (value_ptr function, CORE_ADDR funcaddr, +extern int using_struct_return (struct value *function, CORE_ADDR funcaddr, struct type *value_type, int gcc_p); -extern void set_return_value (value_ptr val); +extern void set_return_value (struct value *val); -extern value_ptr evaluate_expression (struct expression *exp); +extern struct value *evaluate_expression (struct expression *exp); -extern value_ptr evaluate_type (struct expression *exp); +extern struct value *evaluate_type (struct expression *exp); -extern value_ptr evaluate_subexp_with_coercion (struct expression *, - int *, enum noside); +extern struct value *evaluate_subexp_with_coercion (struct expression *, + int *, enum noside); -extern value_ptr parse_and_eval (char *exp); +extern struct value *parse_and_eval (char *exp); -extern value_ptr parse_to_comma_and_eval (char **expp); +extern struct value *parse_to_comma_and_eval (char **expp); extern struct type *parse_and_eval_type (char *p, int length); @@ -441,43 +447,44 @@ extern CORE_ADDR parse_and_eval_address_1 (char **expptr); extern LONGEST parse_and_eval_long (char *exp); -extern value_ptr access_value_history (int num); +extern struct value *access_value_history (int num); -extern value_ptr value_of_internalvar (struct internalvar *var); +extern struct value *value_of_internalvar (struct internalvar *var); -extern void set_internalvar (struct internalvar *var, value_ptr val); +extern void set_internalvar (struct internalvar *var, struct value *val); extern void set_internalvar_component (struct internalvar *var, int offset, int bitpos, int bitsize, - value_ptr newvalue); + struct value *newvalue); extern struct internalvar *lookup_internalvar (char *name); -extern int value_equal (value_ptr arg1, value_ptr arg2); +extern int value_equal (struct value *arg1, struct value *arg2); -extern int value_less (value_ptr arg1, value_ptr arg2); +extern int value_less (struct value *arg1, struct value *arg2); -extern int value_logical_not (value_ptr arg1); +extern int value_logical_not (struct value *arg1); /* C++ */ -extern value_ptr value_of_this (int complain); +extern struct value *value_of_this (int complain); -extern value_ptr value_x_binop (value_ptr arg1, value_ptr arg2, - enum exp_opcode op, - enum exp_opcode otherop, enum noside noside); +extern struct value *value_x_binop (struct value *arg1, struct value *arg2, + enum exp_opcode op, + enum exp_opcode otherop, + enum noside noside); -extern value_ptr value_x_unop (value_ptr arg1, enum exp_opcode op, - enum noside noside); +extern struct value *value_x_unop (struct value *arg1, enum exp_opcode op, + enum noside noside); -extern value_ptr value_fn_field (value_ptr * arg1p, struct fn_field *f, - int j, struct type *type, int offset); +extern struct value *value_fn_field (struct value ** arg1p, struct fn_field *f, + int j, struct type *type, int offset); -extern int binop_user_defined_p (enum exp_opcode op, - value_ptr arg1, value_ptr arg2); +extern int binop_user_defined_p (enum exp_opcode op, struct value *arg1, + struct value *arg2); -extern int unop_user_defined_p (enum exp_opcode op, value_ptr arg1); +extern int unop_user_defined_p (enum exp_opcode op, struct value *arg1); extern int destructor_name_p (const char *name, const struct type *type); @@ -485,9 +492,9 @@ extern int destructor_name_p (const char *name, const struct type *type); extern void free_all_values (void); -extern void release_value (value_ptr val); +extern void release_value (struct value *val); -extern int record_latest_value (value_ptr val); +extern int record_latest_value (struct value *val); extern void modify_field (char *addr, LONGEST fieldval, int bitpos, int bitsize); @@ -495,8 +502,8 @@ modify_field (char *addr, LONGEST fieldval, int bitpos, int bitsize); extern void type_print (struct type * type, char *varstring, struct ui_file * stream, int show); -extern char *baseclass_addr (struct type *type, int index, - char *valaddr, value_ptr * valuep, int *errp); +extern char *baseclass_addr (struct type *type, int index, char *valaddr, + struct value **valuep, int *errp); extern void print_longest (struct ui_file * stream, int format, int use_local, LONGEST val); @@ -504,15 +511,14 @@ extern void print_longest (struct ui_file * stream, int format, extern void print_floating (char *valaddr, struct type * type, struct ui_file * stream); -extern int value_print (value_ptr val, struct ui_file *stream, int format, +extern int value_print (struct value *val, struct ui_file *stream, int format, enum val_prettyprint pretty); -extern void value_print_array_elements (value_ptr val, - struct ui_file *stream, - int format, +extern void value_print_array_elements (struct value *val, + struct ui_file *stream, int format, enum val_prettyprint pretty); -extern value_ptr value_release_to_mark (value_ptr mark); +extern struct value *value_release_to_mark (struct value *mark); extern int val_print (struct type * type, char *valaddr, int embedded_offset, CORE_ADDR address, @@ -526,7 +532,7 @@ extern void print_variable_value (struct symbol * var, struct frame_info * frame, struct ui_file *stream); -extern int check_field (value_ptr, const char *); +extern int check_field (struct value *, const char *); extern void typedef_print (struct type * type, struct symbol * news, struct ui_file * stream); @@ -539,34 +545,35 @@ extern void clear_internalvars (void); /* From values.c */ -extern value_ptr value_copy (value_ptr); +extern struct value *value_copy (struct value *); extern int baseclass_offset (struct type *, int, char *, CORE_ADDR); /* From valops.c */ -extern value_ptr varying_to_slice (value_ptr); +extern struct value *varying_to_slice (struct value *); -extern value_ptr value_slice (value_ptr, int, int); +extern struct value *value_slice (struct value *, int, int); -extern value_ptr call_function_by_hand (value_ptr, int, value_ptr *); +extern struct value *call_function_by_hand (struct value *, int, + struct value **); extern int default_coerce_float_to_double (struct type *, struct type *); extern int standard_coerce_float_to_double (struct type *, struct type *); -extern value_ptr value_literal_complex (value_ptr, value_ptr, struct type *); +extern struct value *value_literal_complex (struct value *, struct value *, + struct type *); extern void find_rt_vbase_offset (struct type *, struct type *, char *, int, int *, int *); -extern value_ptr find_function_in_inferior (char *); +extern struct value *find_function_in_inferior (char *); -extern value_ptr value_allocate_space_in_inferior (int); +extern struct value *value_allocate_space_in_inferior (int); -extern CORE_ADDR default_push_arguments (int nargs, value_ptr * args, - CORE_ADDR sp, - int struct_return, +extern CORE_ADDR default_push_arguments (int nargs, struct value ** args, + CORE_ADDR sp, int struct_return, CORE_ADDR struct_addr); #endif /* !defined (VALUE_H) */ diff --git a/gdb/values.c b/gdb/values.c index cc90caacd7a..45466226fbd 100644 --- a/gdb/values.c +++ b/gdb/values.c @@ -1,6 +1,6 @@ /* Low level packing and unpacking of values for GDB, the GNU Debugger. - Copyright 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, - 1996, 1997, 1998, 1999, 2000 + Copyright 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, + 1995, 1996, 1997, 1998, 1999, 2000, 2002. Free Software Foundation, Inc. This file is part of GDB. @@ -41,7 +41,7 @@ void _initialize_values (void); /* Prototypes for local functions. */ -static value_ptr value_headof (value_ptr, struct type *, struct type *); +static struct value *value_headof (struct value *, struct type *, struct type *); static void show_values (char *, int); @@ -59,7 +59,7 @@ static void show_convenience (char *, int); struct value_history_chunk { struct value_history_chunk *next; - value_ptr values[VALUE_HISTORY_CHUNK]; + struct value *values[VALUE_HISTORY_CHUNK]; }; /* Chain of chunks now in use. */ @@ -72,14 +72,14 @@ static int value_history_count; /* Abs number of last entry stored */ (except for those released by calls to release_value) This is so they can be freed after each command. */ -static value_ptr all_values; +static struct value *all_values; /* Allocate a value that has the correct length for type TYPE. */ -value_ptr +struct value * allocate_value (struct type *type) { - register value_ptr val; + struct value *val; struct type *atype = check_typedef (type); val = (struct value *) xmalloc (sizeof (struct value) + TYPE_LENGTH (atype)); @@ -106,7 +106,7 @@ allocate_value (struct type *type) /* Allocate a value that has the correct length for COUNT repetitions type TYPE. */ -value_ptr +struct value * allocate_repeat_value (struct type *type, int count) { int low_bound = current_language->string_lower_bound; /* ??? */ @@ -124,7 +124,7 @@ allocate_repeat_value (struct type *type, int count) /* Return a mark in the value chain. All values allocated after the mark is obtained (except for those released) are subject to being freed if a subsequent value_free_to_mark is passed the mark. */ -value_ptr +struct value * value_mark (void) { return all_values; @@ -133,9 +133,10 @@ value_mark (void) /* Free all values allocated since MARK was obtained by value_mark (except for those released). */ void -value_free_to_mark (value_ptr mark) +value_free_to_mark (struct value *mark) { - value_ptr val, next; + struct value *val; + struct value *next; for (val = all_values; val && val != mark; val = next) { @@ -151,7 +152,8 @@ value_free_to_mark (value_ptr mark) void free_all_values (void) { - register value_ptr val, next; + struct value *val; + struct value *next; for (val = all_values; val; val = next) { @@ -166,9 +168,9 @@ free_all_values (void) so it will not be freed automatically. */ void -release_value (register value_ptr val) +release_value (struct value *val) { - register value_ptr v; + struct value *v; if (all_values == val) { @@ -187,10 +189,11 @@ release_value (register value_ptr val) } /* Release all values up to mark */ -value_ptr -value_release_to_mark (value_ptr mark) +struct value * +value_release_to_mark (struct value *mark) { - value_ptr val, next; + struct value *val; + struct value *next; for (val = next = all_values; next; next = VALUE_NEXT (next)) if (VALUE_NEXT (next) == mark) @@ -207,11 +210,11 @@ value_release_to_mark (value_ptr mark) It contains the same contents, for same memory address, but it's a different block of storage. */ -value_ptr -value_copy (value_ptr arg) +struct value * +value_copy (struct value *arg) { register struct type *encl_type = VALUE_ENCLOSING_TYPE (arg); - register value_ptr val = allocate_value (encl_type); + struct value *val = allocate_value (encl_type); VALUE_TYPE (val) = VALUE_TYPE (arg); VALUE_LVAL (val) = VALUE_LVAL (arg); VALUE_ADDRESS (val) = VALUE_ADDRESS (arg); @@ -243,7 +246,7 @@ value_copy (value_ptr arg) value history index of this new item. */ int -record_latest_value (value_ptr val) +record_latest_value (struct value *val) { int i; @@ -265,7 +268,7 @@ record_latest_value (value_ptr val) i = value_history_count % VALUE_HISTORY_CHUNK; if (i == 0) { - register struct value_history_chunk *new + struct value_history_chunk *new = (struct value_history_chunk *) xmalloc (sizeof (struct value_history_chunk)); memset (new->values, 0, sizeof new->values); @@ -283,10 +286,10 @@ record_latest_value (value_ptr val) /* Return a copy of the value in the history with sequence number NUM. */ -value_ptr +struct value * access_value_history (int num) { - register struct value_history_chunk *chunk; + struct value_history_chunk *chunk; register int i; register int absnum = num; @@ -324,9 +327,9 @@ access_value_history (int num) void clear_value_history (void) { - register struct value_history_chunk *next; + struct value_history_chunk *next; register int i; - register value_ptr val; + struct value *val; while (value_history_chain) { @@ -344,7 +347,7 @@ static void show_values (char *num_exp, int from_tty) { register int i; - register value_ptr val; + struct value *val; static int num = 1; if (num_exp) @@ -415,10 +418,10 @@ lookup_internalvar (char *name) return var; } -value_ptr +struct value * value_of_internalvar (struct internalvar *var) { - register value_ptr val; + struct value *val; #ifdef IS_TRAPPED_INTERNALVAR if (IS_TRAPPED_INTERNALVAR (var->name)) @@ -435,7 +438,7 @@ value_of_internalvar (struct internalvar *var) void set_internalvar_component (struct internalvar *var, int offset, int bitpos, - int bitsize, value_ptr newval) + int bitsize, struct value *newval) { register char *addr = VALUE_CONTENTS (var->value) + offset; @@ -452,9 +455,9 @@ set_internalvar_component (struct internalvar *var, int offset, int bitpos, } void -set_internalvar (struct internalvar *var, value_ptr val) +set_internalvar (struct internalvar *var, struct value *val) { - value_ptr newval; + struct value *newval; #ifdef IS_TRAPPED_INTERNALVAR if (IS_TRAPPED_INTERNALVAR (var->name)) @@ -538,7 +541,7 @@ use \"set\" as in \"set $foo = 5\" to define them.\n"); Does not deallocate the value. */ LONGEST -value_as_long (register value_ptr val) +value_as_long (struct value *val) { /* This coerces arrays and functions, which is necessary (e.g. in disassemble_command). It also dereferences references, which @@ -548,7 +551,7 @@ value_as_long (register value_ptr val) } DOUBLEST -value_as_double (register value_ptr val) +value_as_double (struct value *val) { DOUBLEST foo; int inv; @@ -562,7 +565,7 @@ value_as_double (register value_ptr val) Note that val's type may not actually be a pointer; value_as_long handles all the cases. */ CORE_ADDR -value_as_address (value_ptr val) +value_as_address (struct value *val) { /* Assume a CORE_ADDR can fit in a LONGEST (for now). Not sure whether we want this to be true eventually. */ @@ -784,7 +787,7 @@ unpack_pointer (struct type *type, char *valaddr) /* Get the value of the FIELDN'th field (which must be static) of TYPE. */ -value_ptr +struct value * value_static_field (struct type *type, int fieldno) { CORE_ADDR addr; @@ -836,8 +839,8 @@ value_static_field (struct type *type, int fieldno) than the old enclosing type, you have to allocate more space for the data. The return value is a pointer to the new version of this value structure. */ -value_ptr -value_change_enclosing_type (value_ptr val, struct type *new_encl_type) +struct value * +value_change_enclosing_type (struct value *val, struct type *new_encl_type) { if (TYPE_LENGTH (new_encl_type) <= TYPE_LENGTH (VALUE_ENCLOSING_TYPE (val))) { @@ -846,10 +849,10 @@ value_change_enclosing_type (value_ptr val, struct type *new_encl_type) } else { - value_ptr new_val; - register value_ptr prev; + struct value *new_val; + struct value *prev; - new_val = (value_ptr) xrealloc (val, sizeof (struct value) + TYPE_LENGTH (new_encl_type)); + new_val = (struct value *) xrealloc (val, sizeof (struct value) + TYPE_LENGTH (new_encl_type)); /* We have to make sure this ends up in the same place in the value chain as the original copy, so it's clean-up behavior is the same. @@ -877,11 +880,11 @@ value_change_enclosing_type (value_ptr val, struct type *new_encl_type) extract and return the value of one of its (non-static) fields. FIELDNO says which field. */ -value_ptr -value_primitive_field (register value_ptr arg1, int offset, +struct value * +value_primitive_field (struct value *arg1, int offset, register int fieldno, register struct type *arg_type) { - register value_ptr v; + struct value *v; register struct type *type; CHECK_TYPEDEF (arg_type); @@ -947,8 +950,8 @@ value_primitive_field (register value_ptr arg1, int offset, extract and return the value of one of its (non-static) fields. FIELDNO says which field. */ -value_ptr -value_field (register value_ptr arg1, register int fieldno) +struct value * +value_field (struct value *arg1, register int fieldno) { return value_primitive_field (arg1, 0, fieldno, VALUE_TYPE (arg1)); } @@ -961,11 +964,11 @@ value_field (register value_ptr arg1, register int fieldno) full symbol or a minimal symbol. */ -value_ptr -value_fn_field (value_ptr *arg1p, struct fn_field *f, int j, struct type *type, +struct value * +value_fn_field (struct value **arg1p, struct fn_field *f, int j, struct type *type, int offset) { - register value_ptr v; + struct value *v; register struct type *ftype = TYPE_FN_FIELD_TYPE (f, j); char *physname = TYPE_FN_FIELD_PHYSNAME (f, j); struct symbol *sym; @@ -1022,11 +1025,12 @@ value_fn_field (value_ptr *arg1p, struct fn_field *f, int j, struct type *type, by value_rtti_type efficiently. Consider it gone for 5.1. */ -static value_ptr -value_headof (value_ptr in_arg, struct type *btype, struct type *dtype) +static struct value * +value_headof (struct value *in_arg, struct type *btype, struct type *dtype) { /* First collect the vtables we must look at for this object. */ - value_ptr arg, vtbl; + struct value *arg; + struct value *vtbl; struct symbol *sym; char *demangled_name; struct minimal_symbol *msymbol; @@ -1083,8 +1087,8 @@ value_headof (value_ptr in_arg, struct type *btype, struct type *dtype) of its baseclasses) to figure out the most derived type that ARG could actually be a pointer to. */ -value_ptr -value_from_vtable_info (value_ptr arg, struct type *type) +struct value * +value_from_vtable_info (struct value *arg, struct type *type) { /* Take care of preliminaries. */ if (TYPE_VPTR_FIELDNO (type) < 0) @@ -1290,10 +1294,10 @@ modify_field (char *addr, LONGEST fieldval, int bitpos, int bitsize) /* Convert C numbers into newly allocated values */ -value_ptr +struct value * value_from_longest (struct type *type, register LONGEST num) { - register value_ptr val = allocate_value (type); + struct value *val = allocate_value (type); register enum type_code code; register int len; retry: @@ -1327,10 +1331,10 @@ retry: /* Create a value representing a pointer of type TYPE to the address ADDR. */ -value_ptr +struct value * value_from_pointer (struct type *type, CORE_ADDR addr) { - value_ptr val = allocate_value (type); + struct value *val = allocate_value (type); store_typed_address (VALUE_CONTENTS_RAW (val), type, addr); return val; } @@ -1341,10 +1345,10 @@ value_from_pointer (struct type *type, CORE_ADDR addr) This is analogous to value_from_longest, which also does not use inferior memory. String shall NOT contain embedded nulls. */ -value_ptr +struct value * value_from_string (char *ptr) { - value_ptr val; + struct value *val; int len = strlen (ptr); int lowbound = current_language->string_lower_bound; struct type *rangetype = @@ -1361,10 +1365,10 @@ value_from_string (char *ptr) return val; } -value_ptr +struct value * value_from_double (struct type *type, DOUBLEST num) { - register value_ptr val = allocate_value (type); + struct value *val = allocate_value (type); struct type *base_type = check_typedef (type); register enum type_code code = TYPE_CODE (base_type); register int len = TYPE_LENGTH (base_type); @@ -1394,10 +1398,10 @@ value_from_double (struct type *type, DOUBLEST num) means returning pointer to where structure is vs. returning value). */ /* ARGSUSED */ -value_ptr +struct value * value_being_returned (struct type *valtype, char *retbuf, int struct_return) { - register value_ptr val; + struct value *val; CORE_ADDR addr; /* If this is not defined, just use EXTRACT_RETURN_VALUE instead. */ @@ -1451,7 +1455,7 @@ generic_use_struct_convention (int gcc_p, struct type *value_type) /* ARGSUSED */ int -using_struct_return (value_ptr function, CORE_ADDR funcaddr, +using_struct_return (struct value *function, CORE_ADDR funcaddr, struct type *value_type, int gcc_p) { register enum type_code code = TYPE_CODE (value_type); @@ -1473,7 +1477,7 @@ using_struct_return (value_ptr function, CORE_ADDR funcaddr, function wants to return. */ void -set_return_value (value_ptr val) +set_return_value (struct value *val) { struct type *type = check_typedef (VALUE_TYPE (val)); register enum type_code code = TYPE_CODE (type); -- 2.30.2