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.
This commit is contained in:
parent
27dee630aa
commit
dbc98a8b6e
12 changed files with 127 additions and 96 deletions
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue