* value.h (value_subscript, value_subscripted_rvalue,
value_bitstring_subscript, value_ptradd): Use LONGEST instead of value as type of the index argument. (value_ptrsub): Remove. * valarith.c (value_subscript, value_subscripted_rvalue, value_bitstring_subscript, value_ptradd): Use LONGEST instead of value as type of the index argument. (value_ptrsub): Remove. * wrapper.h (gdb_value_subscript): Use LONGEST instead of value as type of the index argument. * wrapper.c (gdb_value_subscript): Likewise. Update calls to gdb_value_subscript, value_subscript, value_subscripted_rvalue, value_bitstring_subscript and value_ptradd to use LONGEST instead of value as index argument type. Use value_ptradd instead of value_ptrsub. * ada-lang.c (ada_value_subscript, ada_value_ptr_subscript, ada_tag_name_2): Update. * ada-tasks.c (read_atcb): Update. * eval.c (evaluate_subexp_standard): Update. * valarith.c (value_subscript): Update. * gnu-v2-abi.c (gnuv2_virtual_fn_field): Update. * gnu-v3-abi.c (gnuv3_get_virtual_fn, gnuv3_baseclass_offset, gnuv3_method_ptr_to_value): Update. * jv-lang.c (evaluate_subexp_java): Update. * m2-lang.c (evaluate_subexp_modula2): Update. * python/python-value.c (valpy_getitem, valpy_binop): Update. * wrapper.c (gdb_value_subscript): Update. * varobj.c (c_describe_child): Update.
This commit is contained in:
parent
0c8b41f1c6
commit
2497b49845
14 changed files with 114 additions and 129 deletions
|
@ -1,3 +1,36 @@
|
|||
2009-06-29 Ulrich Weigand <uweigand@de.ibm.com>
|
||||
|
||||
* value.h (value_subscript, value_subscripted_rvalue,
|
||||
value_bitstring_subscript, value_ptradd): Use LONGEST instead
|
||||
of value as type of the index argument.
|
||||
(value_ptrsub): Remove.
|
||||
* valarith.c (value_subscript, value_subscripted_rvalue,
|
||||
value_bitstring_subscript, value_ptradd): Use LONGEST instead
|
||||
of value as type of the index argument.
|
||||
(value_ptrsub): Remove.
|
||||
|
||||
* wrapper.h (gdb_value_subscript): Use LONGEST instead of
|
||||
value as type of the index argument.
|
||||
* wrapper.c (gdb_value_subscript): Likewise.
|
||||
|
||||
Update calls to gdb_value_subscript, value_subscript,
|
||||
value_subscripted_rvalue, value_bitstring_subscript and
|
||||
value_ptradd to use LONGEST instead of value as index
|
||||
argument type. Use value_ptradd instead of value_ptrsub.
|
||||
* ada-lang.c (ada_value_subscript, ada_value_ptr_subscript,
|
||||
ada_tag_name_2): Update.
|
||||
* ada-tasks.c (read_atcb): Update.
|
||||
* eval.c (evaluate_subexp_standard): Update.
|
||||
* valarith.c (value_subscript): Update.
|
||||
* gnu-v2-abi.c (gnuv2_virtual_fn_field): Update.
|
||||
* gnu-v3-abi.c (gnuv3_get_virtual_fn, gnuv3_baseclass_offset,
|
||||
gnuv3_method_ptr_to_value): Update.
|
||||
* jv-lang.c (evaluate_subexp_java): Update.
|
||||
* m2-lang.c (evaluate_subexp_modula2): Update.
|
||||
* python/python-value.c (valpy_getitem, valpy_binop): Update.
|
||||
* wrapper.c (gdb_value_subscript): Update.
|
||||
* varobj.c (c_describe_child): Update.
|
||||
|
||||
2009-06-29 Ulrich Weigand <uweigand@de.ibm.com>
|
||||
|
||||
* gdbtypes.h (make_function_type): Remove OBJFILE parameter.
|
||||
|
|
|
@ -2273,7 +2273,7 @@ ada_value_subscript (struct value *arr, int arity, struct value **ind)
|
|||
{
|
||||
if (TYPE_CODE (elt_type) != TYPE_CODE_ARRAY)
|
||||
error (_("too many subscripts (%d expected)"), k);
|
||||
elt = value_subscript (elt, value_pos_atr (builtin_type_int32, ind[k]));
|
||||
elt = value_subscript (elt, pos_atr (ind[k]));
|
||||
}
|
||||
return elt;
|
||||
}
|
||||
|
@ -2291,19 +2291,13 @@ ada_value_ptr_subscript (struct value *arr, struct type *type, int arity,
|
|||
for (k = 0; k < arity; k += 1)
|
||||
{
|
||||
LONGEST lwb, upb;
|
||||
struct value *idx;
|
||||
|
||||
if (TYPE_CODE (type) != TYPE_CODE_ARRAY)
|
||||
error (_("too many subscripts (%d expected)"), k);
|
||||
arr = value_cast (lookup_pointer_type (TYPE_TARGET_TYPE (type)),
|
||||
value_copy (arr));
|
||||
get_discrete_bounds (TYPE_INDEX_TYPE (type), &lwb, &upb);
|
||||
idx = value_pos_atr (builtin_type_int32, ind[k]);
|
||||
if (lwb != 0)
|
||||
idx = value_binop (idx, value_from_longest (value_type (idx), lwb),
|
||||
BINOP_SUB);
|
||||
|
||||
arr = value_ptradd (arr, idx);
|
||||
arr = value_ptradd (arr, pos_atr (ind[k]) - lwb);
|
||||
type = TYPE_TARGET_TYPE (type);
|
||||
}
|
||||
|
||||
|
@ -5568,8 +5562,7 @@ ada_tag_name_2 (struct tag_args *args)
|
|||
valp = value_cast (info_type, args->tag);
|
||||
if (valp == NULL)
|
||||
return 0;
|
||||
val = value_ind (value_ptradd (valp,
|
||||
value_from_longest (builtin_type_int8, -1)));
|
||||
val = value_ind (value_ptradd (valp, -1));
|
||||
if (val == NULL)
|
||||
return 0;
|
||||
val = ada_value_struct_elt (val, "expanded_name", 1);
|
||||
|
|
|
@ -548,7 +548,8 @@ read_atcb (CORE_ADDR task_id, struct ada_task_info *task_info)
|
|||
ada_coerce_to_simple_array_ptr (value_field (tcb_value,
|
||||
fieldno.entry_calls));
|
||||
entry_calls_value_element =
|
||||
value_subscript (entry_calls_value, atc_nesting_level_value);
|
||||
value_subscript (entry_calls_value,
|
||||
value_as_long (atc_nesting_level_value));
|
||||
called_task_fieldno =
|
||||
ada_get_field_index (value_type (entry_calls_value_element),
|
||||
"called_task", 0);
|
||||
|
|
68
gdb/eval.c
68
gdb/eval.c
|
@ -1574,7 +1574,7 @@ evaluate_subexp_standard (struct type *expect_type,
|
|||
else
|
||||
{
|
||||
arg2 = evaluate_subexp_with_coercion (exp, pos, noside);
|
||||
return value_subscript (arg1, arg2);
|
||||
return value_subscript (arg1, value_as_long (arg2));
|
||||
}
|
||||
|
||||
case TYPE_CODE_PTR:
|
||||
|
@ -1736,10 +1736,12 @@ evaluate_subexp_standard (struct type *expect_type,
|
|||
op = exp->elts[pc + 1].opcode;
|
||||
if (binop_user_defined_p (op, arg1, arg2))
|
||||
return value_x_binop (arg1, arg2, BINOP_ASSIGN_MODIFY, op, noside);
|
||||
else if (op == BINOP_ADD && ptrmath_type_p (value_type (arg1)))
|
||||
arg2 = value_ptradd (arg1, arg2);
|
||||
else if (op == BINOP_SUB && ptrmath_type_p (value_type (arg1)))
|
||||
arg2 = value_ptrsub (arg1, arg2);
|
||||
else if (op == BINOP_ADD && ptrmath_type_p (value_type (arg1))
|
||||
&& is_integral_type (value_type (arg2)))
|
||||
arg2 = value_ptradd (arg1, value_as_long (arg2));
|
||||
else if (op == BINOP_SUB && ptrmath_type_p (value_type (arg1))
|
||||
&& is_integral_type (value_type (arg2)))
|
||||
arg2 = value_ptradd (arg1, - value_as_long (arg2));
|
||||
else
|
||||
{
|
||||
struct value *tmp = arg1;
|
||||
|
@ -1763,10 +1765,12 @@ evaluate_subexp_standard (struct type *expect_type,
|
|||
goto nosideret;
|
||||
if (binop_user_defined_p (op, arg1, arg2))
|
||||
return value_x_binop (arg1, arg2, op, OP_NULL, noside);
|
||||
else if (ptrmath_type_p (value_type (arg1)))
|
||||
return value_ptradd (arg1, arg2);
|
||||
else if (ptrmath_type_p (value_type (arg2)))
|
||||
return value_ptradd (arg2, arg1);
|
||||
else if (ptrmath_type_p (value_type (arg1))
|
||||
&& is_integral_type (value_type (arg2)))
|
||||
return value_ptradd (arg1, value_as_long (arg2));
|
||||
else if (ptrmath_type_p (value_type (arg2))
|
||||
&& is_integral_type (value_type (arg1)))
|
||||
return value_ptradd (arg2, value_as_long (arg1));
|
||||
else
|
||||
{
|
||||
binop_promote (exp->language_defn, exp->gdbarch, &arg1, &arg2);
|
||||
|
@ -1780,17 +1784,16 @@ evaluate_subexp_standard (struct type *expect_type,
|
|||
goto nosideret;
|
||||
if (binop_user_defined_p (op, arg1, arg2))
|
||||
return value_x_binop (arg1, arg2, op, OP_NULL, noside);
|
||||
else if (ptrmath_type_p (value_type (arg1)))
|
||||
else if (ptrmath_type_p (value_type (arg1))
|
||||
&& ptrmath_type_p (value_type (arg2)))
|
||||
{
|
||||
if (ptrmath_type_p (value_type (arg2)))
|
||||
{
|
||||
/* FIXME -- should be ptrdiff_t */
|
||||
type = builtin_type (exp->gdbarch)->builtin_long;
|
||||
return value_from_longest (type, value_ptrdiff (arg1, arg2));
|
||||
}
|
||||
else
|
||||
return value_ptrsub (arg1, arg2);
|
||||
/* FIXME -- should be ptrdiff_t */
|
||||
type = builtin_type (exp->gdbarch)->builtin_long;
|
||||
return value_from_longest (type, value_ptrdiff (arg1, arg2));
|
||||
}
|
||||
else if (ptrmath_type_p (value_type (arg1))
|
||||
&& is_integral_type (value_type (arg2)))
|
||||
return value_ptradd (arg1, - value_as_long (arg2));
|
||||
else
|
||||
{
|
||||
binop_promote (exp->language_defn, exp->gdbarch, &arg1, &arg2);
|
||||
|
@ -1885,7 +1888,7 @@ evaluate_subexp_standard (struct type *expect_type,
|
|||
if (noside == EVAL_AVOID_SIDE_EFFECTS)
|
||||
return value_zero (TYPE_TARGET_TYPE (type), VALUE_LVAL (arg1));
|
||||
else
|
||||
return value_subscript (arg1, arg2);
|
||||
return value_subscript (arg1, value_as_long (arg2));
|
||||
}
|
||||
|
||||
case BINOP_IN:
|
||||
|
@ -1950,12 +1953,13 @@ evaluate_subexp_standard (struct type *expect_type,
|
|||
case TYPE_CODE_PTR:
|
||||
case TYPE_CODE_ARRAY:
|
||||
case TYPE_CODE_STRING:
|
||||
arg1 = value_subscript (arg1, arg2);
|
||||
arg1 = value_subscript (arg1, value_as_long (arg2));
|
||||
break;
|
||||
|
||||
case TYPE_CODE_BITSTRING:
|
||||
type = language_bool_type (exp->language_defn, exp->gdbarch);
|
||||
arg1 = value_bitstring_subscript (type, arg1, arg2);
|
||||
arg1 = value_bitstring_subscript (type, arg1,
|
||||
value_as_long (arg2));
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -2035,10 +2039,6 @@ evaluate_subexp_standard (struct type *expect_type,
|
|||
offset_item =
|
||||
array_size_array[i - 1] * offset_item + subscript_array[i - 1];
|
||||
|
||||
/* Construct a value node with the value of the offset */
|
||||
|
||||
arg2 = value_from_longest (builtin_type_int32, offset_item);
|
||||
|
||||
/* Let us now play a dirty trick: we will take arg1
|
||||
which is a value node pointing to the topmost level
|
||||
of the multidimensional array-set and pretend
|
||||
|
@ -2047,7 +2047,7 @@ evaluate_subexp_standard (struct type *expect_type,
|
|||
returns the correct type value */
|
||||
|
||||
deprecated_set_value_type (arg1, tmp_type);
|
||||
return value_subscripted_rvalue (arg1, arg2, 0);
|
||||
return value_subscripted_rvalue (arg1, offset_item, 0);
|
||||
}
|
||||
|
||||
case BINOP_LOGICAL_AND:
|
||||
|
@ -2386,12 +2386,12 @@ evaluate_subexp_standard (struct type *expect_type,
|
|||
}
|
||||
else
|
||||
{
|
||||
arg2 = value_from_longest (builtin_type_uint8, (LONGEST) 1);
|
||||
if (ptrmath_type_p (value_type (arg1)))
|
||||
arg2 = value_ptradd (arg1, arg2);
|
||||
arg2 = value_ptradd (arg1, 1);
|
||||
else
|
||||
{
|
||||
struct value *tmp = arg1;
|
||||
arg2 = value_one (value_type (arg1), not_lval);
|
||||
binop_promote (exp->language_defn, exp->gdbarch, &tmp, &arg2);
|
||||
arg2 = value_binop (tmp, arg2, BINOP_ADD);
|
||||
}
|
||||
|
@ -2409,12 +2409,12 @@ evaluate_subexp_standard (struct type *expect_type,
|
|||
}
|
||||
else
|
||||
{
|
||||
arg2 = value_from_longest (builtin_type_uint8, (LONGEST) 1);
|
||||
if (ptrmath_type_p (value_type (arg1)))
|
||||
arg2 = value_ptrsub (arg1, arg2);
|
||||
arg2 = value_ptradd (arg1, -1);
|
||||
else
|
||||
{
|
||||
struct value *tmp = arg1;
|
||||
arg2 = value_one (value_type (arg1), not_lval);
|
||||
binop_promote (exp->language_defn, exp->gdbarch, &tmp, &arg2);
|
||||
arg2 = value_binop (tmp, arg2, BINOP_SUB);
|
||||
}
|
||||
|
@ -2432,12 +2432,12 @@ evaluate_subexp_standard (struct type *expect_type,
|
|||
}
|
||||
else
|
||||
{
|
||||
arg2 = value_from_longest (builtin_type_uint8, (LONGEST) 1);
|
||||
if (ptrmath_type_p (value_type (arg1)))
|
||||
arg2 = value_ptradd (arg1, arg2);
|
||||
arg2 = value_ptradd (arg1, 1);
|
||||
else
|
||||
{
|
||||
struct value *tmp = arg1;
|
||||
arg2 = value_one (value_type (arg1), not_lval);
|
||||
binop_promote (exp->language_defn, exp->gdbarch, &tmp, &arg2);
|
||||
arg2 = value_binop (tmp, arg2, BINOP_ADD);
|
||||
}
|
||||
|
@ -2456,12 +2456,12 @@ evaluate_subexp_standard (struct type *expect_type,
|
|||
}
|
||||
else
|
||||
{
|
||||
arg2 = value_from_longest (builtin_type_uint8, (LONGEST) 1);
|
||||
if (ptrmath_type_p (value_type (arg1)))
|
||||
arg2 = value_ptrsub (arg1, arg2);
|
||||
arg2 = value_ptradd (arg1, -1);
|
||||
else
|
||||
{
|
||||
struct value *tmp = arg1;
|
||||
arg2 = value_one (value_type (arg1), not_lval);
|
||||
binop_promote (exp->language_defn, exp->gdbarch, &tmp, &arg2);
|
||||
arg2 = value_binop (tmp, arg2, BINOP_SUB);
|
||||
}
|
||||
|
|
|
@ -97,8 +97,7 @@ gnuv2_virtual_fn_field (struct value **arg1p, struct fn_field * f, int j,
|
|||
struct value *entry;
|
||||
struct value *vfn;
|
||||
struct value *vtbl;
|
||||
struct value *vi = value_from_longest (builtin_type_int32,
|
||||
(LONGEST) TYPE_FN_FIELD_VOFFSET (f, j));
|
||||
LONGEST vi = (LONGEST) TYPE_FN_FIELD_VOFFSET (f, j);
|
||||
struct type *fcontext = TYPE_FN_FIELD_FCONTEXT (f, j);
|
||||
struct type *context;
|
||||
struct type *context_vptr_basetype;
|
||||
|
|
|
@ -359,7 +359,7 @@ gnuv3_get_virtual_fn (struct gdbarch *gdbarch, struct value *container,
|
|||
|
||||
/* Fetch the appropriate function pointer from the vtable. */
|
||||
vfn = value_subscript (value_field (vtable, vtable_field_virtual_functions),
|
||||
value_from_longest (builtin_type_int32, vtable_index));
|
||||
vtable_index);
|
||||
|
||||
/* If this architecture uses function descriptors directly in the vtable,
|
||||
then the address of the vtable entry is actually a "function pointer"
|
||||
|
@ -419,7 +419,7 @@ gnuv3_baseclass_offset (struct type *type, int index, const bfd_byte *valaddr,
|
|||
struct type *ptr_type;
|
||||
struct value *vtable;
|
||||
struct type *vbasetype;
|
||||
struct value *offset_val, *vbase_array;
|
||||
struct value *vbase_array;
|
||||
CORE_ADDR vtable_address;
|
||||
long int cur_base_offset, base_offset;
|
||||
int vbasetype_vptr_fieldno;
|
||||
|
@ -471,9 +471,8 @@ gnuv3_baseclass_offset (struct type *type, int index, const bfd_byte *valaddr,
|
|||
vtable
|
||||
= value_at_lazy (vtable_type,
|
||||
vtable_address - vtable_address_point_offset (gdbarch));
|
||||
offset_val = value_from_longest (builtin_type_int32, cur_base_offset);
|
||||
vbase_array = value_field (vtable, vtable_field_vcall_and_vbase_offsets);
|
||||
base_offset = value_as_long (value_subscript (vbase_array, offset_val));
|
||||
base_offset = value_as_long (value_subscript (vbase_array, cur_base_offset));
|
||||
return base_offset;
|
||||
}
|
||||
|
||||
|
@ -691,7 +690,6 @@ gnuv3_method_ptr_to_value (struct value **this_p, struct value *method_ptr)
|
|||
CORE_ADDR ptr_value;
|
||||
struct type *domain_type, *final_type, *method_type;
|
||||
LONGEST adjustment;
|
||||
struct value *adjval;
|
||||
int vbit;
|
||||
|
||||
domain_type = TYPE_DOMAIN_TYPE (check_typedef (value_type (method_ptr)));
|
||||
|
@ -723,9 +721,7 @@ gnuv3_method_ptr_to_value (struct value **this_p, struct value *method_ptr)
|
|||
You can provoke this case by casting a Base::* to a Derived::*, for
|
||||
instance. */
|
||||
*this_p = value_cast (builtin_type (gdbarch)->builtin_data_ptr, *this_p);
|
||||
adjval = value_from_longest (builtin_type (gdbarch)->builtin_long,
|
||||
adjustment);
|
||||
*this_p = value_ptradd (*this_p, adjval);
|
||||
*this_p = value_ptradd (*this_p, adjustment);
|
||||
*this_p = value_cast (final_type, *this_p);
|
||||
|
||||
if (vbit)
|
||||
|
|
|
@ -918,7 +918,7 @@ evaluate_subexp_java (struct type *expect_type, struct expression *exp,
|
|||
if (noside == EVAL_AVOID_SIDE_EFFECTS)
|
||||
return value_zero (TYPE_TARGET_TYPE (type), VALUE_LVAL (arg1));
|
||||
else
|
||||
return value_subscript (arg1, arg2);
|
||||
return value_subscript (arg1, value_as_long (arg2));
|
||||
}
|
||||
if (name)
|
||||
error (_("cannot subscript something of type `%s'"), name);
|
||||
|
|
|
@ -253,7 +253,7 @@ evaluate_subexp_modula2 (struct type *expect_type, struct expression *exp,
|
|||
arg1 = value_cast (type, arg1);
|
||||
|
||||
type = check_typedef (value_type (arg1));
|
||||
return value_ind (value_ptradd (arg1, arg2));
|
||||
return value_ind (value_ptradd (arg1, value_as_long (arg2)));
|
||||
}
|
||||
else
|
||||
if (TYPE_CODE (type) != TYPE_CODE_ARRAY)
|
||||
|
@ -268,7 +268,7 @@ evaluate_subexp_modula2 (struct type *expect_type, struct expression *exp,
|
|||
if (noside == EVAL_AVOID_SIDE_EFFECTS)
|
||||
return value_zero (TYPE_TARGET_TYPE (type), VALUE_LVAL (arg1));
|
||||
else
|
||||
return value_subscript (arg1, arg2);
|
||||
return value_subscript (arg1, value_as_long (arg2));
|
||||
|
||||
default:
|
||||
return evaluate_subexp_standard (expect_type, exp, pos, noside);
|
||||
|
|
|
@ -293,7 +293,7 @@ valpy_getitem (PyObject *self, PyObject *key)
|
|||
if (idx == NULL)
|
||||
return NULL;
|
||||
|
||||
res_val = value_subscript (tmp, idx);
|
||||
res_val = value_subscript (tmp, value_as_long (idx));
|
||||
}
|
||||
}
|
||||
if (field)
|
||||
|
@ -413,10 +413,12 @@ valpy_binop (enum valpy_opcode opcode, PyObject *self, PyObject *other)
|
|||
CHECK_TYPEDEF (rtype);
|
||||
rtype = STRIP_REFERENCE (rtype);
|
||||
|
||||
if (TYPE_CODE (ltype) == TYPE_CODE_PTR)
|
||||
res_val = value_ptradd (arg1, arg2);
|
||||
else if (TYPE_CODE (rtype) == TYPE_CODE_PTR)
|
||||
res_val = value_ptradd (arg2, arg1);
|
||||
if (TYPE_CODE (ltype) == TYPE_CODE_PTR
|
||||
&& is_integral_type (rtype))
|
||||
res_val = value_ptradd (arg1, value_as_long (arg2));
|
||||
else if (TYPE_CODE (rtype) == TYPE_CODE_PTR
|
||||
&& is_integral_type (ltype))
|
||||
res_val = value_ptradd (arg2, value_as_long (arg1));
|
||||
else
|
||||
res_val = value_binop (arg1, arg2, BINOP_ADD);
|
||||
}
|
||||
|
@ -431,16 +433,14 @@ valpy_binop (enum valpy_opcode opcode, PyObject *self, PyObject *other)
|
|||
CHECK_TYPEDEF (rtype);
|
||||
rtype = STRIP_REFERENCE (rtype);
|
||||
|
||||
if (TYPE_CODE (ltype) == TYPE_CODE_PTR)
|
||||
{
|
||||
if (TYPE_CODE (rtype) == TYPE_CODE_PTR)
|
||||
/* A ptrdiff_t for the target would be preferable
|
||||
here. */
|
||||
res_val = value_from_longest (builtin_type_pyint,
|
||||
value_ptrdiff (arg1, arg2));
|
||||
else
|
||||
res_val = value_ptrsub (arg1, arg2);
|
||||
}
|
||||
if (TYPE_CODE (ltype) == TYPE_CODE_PTR
|
||||
&& TYPE_CODE (rtype) == TYPE_CODE_PTR)
|
||||
/* A ptrdiff_t for the target would be preferable here. */
|
||||
res_val = value_from_longest (builtin_type_pyint,
|
||||
value_ptrdiff (arg1, arg2));
|
||||
else if (TYPE_CODE (ltype) == TYPE_CODE_PTR
|
||||
&& is_integral_type (rtype))
|
||||
res_val = value_ptradd (arg1, - value_as_long (arg2));
|
||||
else
|
||||
res_val = value_binop (arg1, arg2, BINOP_SUB);
|
||||
}
|
||||
|
|
|
@ -46,7 +46,7 @@ void _initialize_valarith (void);
|
|||
If the pointer type is void *, then return 1.
|
||||
If the target type is incomplete, then error out.
|
||||
This isn't a general purpose function, but just a
|
||||
helper for value_ptrsub & value_ptradd.
|
||||
helper for value_ptradd.
|
||||
*/
|
||||
|
||||
static LONGEST
|
||||
|
@ -85,7 +85,7 @@ find_size_for_pointer_math (struct type *ptr_type)
|
|||
result of C-style pointer arithmetic ARG1 + ARG2. */
|
||||
|
||||
struct value *
|
||||
value_ptradd (struct value *arg1, struct value *arg2)
|
||||
value_ptradd (struct value *arg1, LONGEST arg2)
|
||||
{
|
||||
struct type *valptrtype;
|
||||
LONGEST sz;
|
||||
|
@ -94,33 +94,8 @@ value_ptradd (struct value *arg1, struct value *arg2)
|
|||
valptrtype = check_typedef (value_type (arg1));
|
||||
sz = find_size_for_pointer_math (valptrtype);
|
||||
|
||||
if (!is_integral_type (value_type (arg2)))
|
||||
error (_("Argument to arithmetic operation not a number or boolean."));
|
||||
|
||||
return value_from_pointer (valptrtype,
|
||||
value_as_address (arg1)
|
||||
+ (sz * value_as_long (arg2)));
|
||||
}
|
||||
|
||||
/* Given a pointer ARG1 and an integral value ARG2, return the
|
||||
result of C-style pointer arithmetic ARG1 - ARG2. */
|
||||
|
||||
struct value *
|
||||
value_ptrsub (struct value *arg1, struct value *arg2)
|
||||
{
|
||||
struct type *valptrtype;
|
||||
LONGEST sz;
|
||||
|
||||
arg1 = coerce_array (arg1);
|
||||
valptrtype = check_typedef (value_type (arg1));
|
||||
sz = find_size_for_pointer_math (valptrtype);
|
||||
|
||||
if (!is_integral_type (value_type (arg2)))
|
||||
error (_("Argument to arithmetic operation not a number or boolean."));
|
||||
|
||||
return value_from_pointer (valptrtype,
|
||||
value_as_address (arg1)
|
||||
- (sz * value_as_long (arg2)));
|
||||
value_as_address (arg1) + sz * arg2);
|
||||
}
|
||||
|
||||
/* Given two compatible pointer values ARG1 and ARG2, return the
|
||||
|
@ -162,7 +137,7 @@ an integer nor a pointer of the same type."));
|
|||
verbosity is set, warn about invalid indices (but still use them). */
|
||||
|
||||
struct value *
|
||||
value_subscript (struct value *array, struct value *idx)
|
||||
value_subscript (struct value *array, LONGEST index)
|
||||
{
|
||||
struct value *bound;
|
||||
int c_style = current_language->c_style_arrays;
|
||||
|
@ -179,13 +154,12 @@ value_subscript (struct value *array, struct value *idx)
|
|||
get_discrete_bounds (range_type, &lowerbound, &upperbound);
|
||||
|
||||
if (VALUE_LVAL (array) != lval_memory)
|
||||
return value_subscripted_rvalue (array, idx, lowerbound);
|
||||
return value_subscripted_rvalue (array, index, lowerbound);
|
||||
|
||||
if (c_style == 0)
|
||||
{
|
||||
LONGEST index = value_as_long (idx);
|
||||
if (index >= lowerbound && index <= upperbound)
|
||||
return value_subscripted_rvalue (array, idx, lowerbound);
|
||||
return value_subscripted_rvalue (array, index, lowerbound);
|
||||
/* Emit warning unless we have an array of unknown size.
|
||||
An array of unknown size has lowerbound 0 and upperbound -1. */
|
||||
if (upperbound > -1)
|
||||
|
@ -194,17 +168,12 @@ value_subscript (struct value *array, struct value *idx)
|
|||
c_style = 1;
|
||||
}
|
||||
|
||||
if (lowerbound != 0)
|
||||
{
|
||||
bound = value_from_longest (value_type (idx), (LONGEST) lowerbound);
|
||||
idx = value_binop (idx, bound, BINOP_SUB);
|
||||
}
|
||||
|
||||
index -= lowerbound;
|
||||
array = value_coerce_array (array);
|
||||
}
|
||||
|
||||
if (c_style)
|
||||
return value_ind (value_ptradd (array, idx));
|
||||
return value_ind (value_ptradd (array, index));
|
||||
else
|
||||
error (_("not an array or string"));
|
||||
}
|
||||
|
@ -214,12 +183,11 @@ value_subscript (struct value *array, struct value *idx)
|
|||
to doubles, but no longer does. */
|
||||
|
||||
struct value *
|
||||
value_subscripted_rvalue (struct value *array, struct value *idx, int lowerbound)
|
||||
value_subscripted_rvalue (struct value *array, LONGEST index, 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);
|
||||
struct value *v;
|
||||
|
||||
|
@ -244,11 +212,10 @@ value_subscripted_rvalue (struct value *array, struct value *idx, int lowerbound
|
|||
|
||||
struct value *
|
||||
value_bitstring_subscript (struct type *type,
|
||||
struct value *bitstring, struct value *idx)
|
||||
struct value *bitstring, LONGEST index)
|
||||
{
|
||||
|
||||
struct type *bitstring_type, *range_type;
|
||||
LONGEST index = value_as_long (idx);
|
||||
struct value *v;
|
||||
int offset, byte, bit_index;
|
||||
LONGEST lowerbound, upperbound;
|
||||
|
|
11
gdb/value.h
11
gdb/value.h
|
@ -394,9 +394,7 @@ extern struct value *value_concat (struct value *arg1, struct value *arg2);
|
|||
extern struct value *value_binop (struct value *arg1, struct value *arg2,
|
||||
enum exp_opcode op);
|
||||
|
||||
extern struct value *value_ptradd (struct value *arg1, struct value *arg2);
|
||||
|
||||
extern struct value *value_ptrsub (struct value *arg1, struct value *arg2);
|
||||
extern struct value *value_ptradd (struct value *arg1, LONGEST arg2);
|
||||
|
||||
extern LONGEST value_ptrdiff (struct value *arg1, struct value *arg2);
|
||||
|
||||
|
@ -468,11 +466,11 @@ extern struct value *value_one (struct type *type, enum lval_type lv);
|
|||
|
||||
extern struct value *value_repeat (struct value *arg1, int count);
|
||||
|
||||
extern struct value *value_subscript (struct value *array, struct value *idx);
|
||||
extern struct value *value_subscript (struct value *array, LONGEST index);
|
||||
|
||||
extern struct value *value_bitstring_subscript (struct type *type,
|
||||
struct value *bitstring,
|
||||
struct value *idx);
|
||||
LONGEST index);
|
||||
|
||||
extern struct value *register_value_being_returned (struct type *valtype,
|
||||
struct regcache *retbuf);
|
||||
|
@ -666,7 +664,8 @@ extern struct value *value_allocate_space_in_inferior (int);
|
|||
|
||||
extern struct value *value_of_local (const char *name, int complain);
|
||||
|
||||
extern struct value * value_subscripted_rvalue (struct value *array, struct value *idx, int lowerbound);
|
||||
extern struct value *value_subscripted_rvalue (struct value *array,
|
||||
LONGEST index, int lowerbound);
|
||||
|
||||
/* User function handler. */
|
||||
|
||||
|
|
|
@ -2556,9 +2556,7 @@ c_describe_child (struct varobj *parent, int index,
|
|||
if (cvalue && value)
|
||||
{
|
||||
int real_index = index + TYPE_LOW_BOUND (TYPE_INDEX_TYPE (type));
|
||||
struct value *indval =
|
||||
value_from_longest (builtin_type_int32, (LONGEST) real_index);
|
||||
gdb_value_subscript (value, indval, cvalue);
|
||||
gdb_value_subscript (value, real_index, cvalue);
|
||||
}
|
||||
|
||||
if (ctype)
|
||||
|
|
|
@ -100,14 +100,14 @@ gdb_value_assign (struct value *val1, struct value *val2,
|
|||
}
|
||||
|
||||
int
|
||||
gdb_value_subscript (struct value *val1, struct value *val2,
|
||||
gdb_value_subscript (struct value *val, LONGEST index,
|
||||
struct value **result)
|
||||
{
|
||||
volatile struct gdb_exception except;
|
||||
|
||||
TRY_CATCH (except, RETURN_MASK_ERROR)
|
||||
{
|
||||
*result = value_subscript (val1, val2);
|
||||
*result = value_subscript (val, index);
|
||||
}
|
||||
|
||||
if (except.reason < 0)
|
||||
|
|
|
@ -36,8 +36,7 @@ extern int gdb_value_equal (struct value *, struct value *, int *);
|
|||
|
||||
extern int gdb_value_assign (struct value *, struct value *, struct value **);
|
||||
|
||||
extern int gdb_value_subscript (struct value *, struct value *,
|
||||
struct value **);
|
||||
extern int gdb_value_subscript (struct value *, LONGEST, struct value **);
|
||||
|
||||
extern enum gdb_rc gdb_value_struct_elt (struct ui_out *uiout,
|
||||
struct value **result_ptr,
|
||||
|
|
Loading…
Reference in a new issue