aboutsummaryrefslogtreecommitdiff
path: root/gdb/valarith.c
diff options
context:
space:
mode:
authorKen Werner <ken.werner@de.ibm.com>2010-11-03 14:21:58 +0000
committerKen Werner <ken.werner@de.ibm.com>2010-11-03 14:21:58 +0000
commitdbc98a8b6eb97ea7315e04103cdfec5add47f3c4 (patch)
tree767338cf124ded0f5c63ea6521f6a72b84095488 /gdb/valarith.c
parent27dee630aae66dd61eb20135e7b8384088b1a496 (diff)
downloadgdb-dbc98a8b6eb97ea7315e04103cdfec5add47f3c4.zip
gdb-dbc98a8b6eb97ea7315e04103cdfec5add47f3c4.tar.gz
gdb-dbc98a8b6eb97ea7315e04103cdfec5add47f3c4.tar.bz2
gdb:
* dwarf2read.c (read_array_type): Read the DW_AT_byte_size from the DIE and set the length of the type. * gdbtypes.h (get_array_bounds): Move here from valprint.h. * gdbtypes.c (get_array_bounds): Move here from valprint.c and return 0 if the corresponding bounds of the type are undefined. * valprint.h (get_array_bounds): Move declaration to gdbtypes.h. * valprint.c (get_array_bounds): Move implementation to gdbtypes.c. (val_print_array_elements): Use get_array_bounds to compute the number of array elements instead of dividing the length of the array by the length of the element types. * valarith.c (vector_binop): Likewise. * valops.c (value_cast): Likewise. * c-valprint.c (c_val_print): Likewise. * c-typeprint.c (c_type_print_varspec_suffix): Likewise. gdb/testsuite: * gdb.base/gnu_vector.exp: Adjust expect messages.
Diffstat (limited to 'gdb/valarith.c')
-rw-r--r--gdb/valarith.c21
1 files changed, 11 insertions, 10 deletions
diff --git a/gdb/valarith.c b/gdb/valarith.c
index f6e3a05..7c553d1 100644
--- a/gdb/valarith.c
+++ b/gdb/valarith.c
@@ -1394,7 +1394,8 @@ vector_binop (struct value *val1, struct value *val2, enum exp_opcode op)
{
struct value *val, *tmp, *mark;
struct type *type1, *type2, *eltype1, *eltype2, *result_type;
- int t1_is_vec, t2_is_vec, elsize, n, i;
+ int t1_is_vec, t2_is_vec, elsize, i;
+ LONGEST low_bound1, high_bound1, low_bound2, high_bound2;
type1 = check_typedef (value_type (val1));
type2 = check_typedef (value_type (val2));
@@ -1407,23 +1408,23 @@ vector_binop (struct value *val1, struct value *val2, enum exp_opcode op)
if (!t1_is_vec || !t2_is_vec)
error (_("Vector operations are only supported among vectors"));
+ if (!get_array_bounds (type1, &low_bound1, &high_bound1)
+ || !get_array_bounds (type2, &low_bound2, &high_bound2))
+ error (_("Could not determine the vector bounds"));
+
eltype1 = check_typedef (TYPE_TARGET_TYPE (type1));
eltype2 = check_typedef (TYPE_TARGET_TYPE (type2));
+ elsize = TYPE_LENGTH (eltype1);
if (TYPE_CODE (eltype1) != TYPE_CODE (eltype2)
- || TYPE_LENGTH (eltype1) != TYPE_LENGTH (eltype2)
- || TYPE_UNSIGNED (eltype1) != TYPE_UNSIGNED (eltype2))
+ || elsize != TYPE_LENGTH (eltype2)
+ || TYPE_UNSIGNED (eltype1) != TYPE_UNSIGNED (eltype2)
+ || low_bound1 != low_bound2 || high_bound1 != high_bound2)
error (_("Cannot perform operation on vectors with different types"));
- elsize = TYPE_LENGTH (eltype1);
- n = TYPE_LENGTH (type1) / elsize;
-
- if (n != TYPE_LENGTH (type2) / TYPE_LENGTH (eltype2))
- error (_("Cannot perform operation on vectors with different sizes"));
-
val = allocate_value (type1);
mark = value_mark ();
- for (i = 0; i < n; i++)
+ for (i = 0; i < high_bound1 - low_bound1 + 1; i++)
{
tmp = value_binop (value_subscript (val1, i),
value_subscript (val2, i), op);