diff options
author | kwerner <kwerner> | 2010-12-14 10:23:40 +0000 |
---|---|---|
committer | kwerner <kwerner> | 2010-12-14 10:23:40 +0000 |
commit | 9ece7f002e466d35387177497d5991e55ddd04d6 (patch) | |
tree | 6a3894b06cdd43b85d24ad6a7764c10f29f0f4c0 /gdb | |
parent | 8a65048726d8ceba13dfd089a76b3893562dfc1c (diff) | |
download | gdb-9ece7f002e466d35387177497d5991e55ddd04d6.tar.gz |
gdb:
* valops.c (value_one): 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 (value_complement, value_neg): Likewise.
Diffstat (limited to 'gdb')
-rw-r--r-- | gdb/valarith.c | 16 | ||||
-rw-r--r-- | gdb/valops.c | 8 |
2 files changed, 18 insertions, 6 deletions
diff --git a/gdb/valarith.c b/gdb/valarith.c index 36e937dcc56..6b212b29b0e 100644 --- a/gdb/valarith.c +++ b/gdb/valarith.c @@ -1766,9 +1766,13 @@ value_neg (struct value *arg1) { struct value *tmp, *val = allocate_value (type); struct type *eltype = check_typedef (TYPE_TARGET_TYPE (type)); - int i, n = TYPE_LENGTH (type) / TYPE_LENGTH (eltype); + int i; + LONGEST low_bound, high_bound; - for (i = 0; i < n; i++) + if (!get_array_bounds (type, &low_bound, &high_bound)) + error (_("Could not determine the vector bounds")); + + for (i = 0; i < high_bound - low_bound + 1; i++) { tmp = value_neg (value_subscript (arg1, i)); memcpy (value_contents_writeable (val) + i * TYPE_LENGTH (eltype), @@ -1798,10 +1802,14 @@ value_complement (struct value *arg1) { struct value *tmp; struct type *eltype = check_typedef (TYPE_TARGET_TYPE (type)); - int i, n = TYPE_LENGTH (type) / TYPE_LENGTH (eltype); + int i; + LONGEST low_bound, high_bound; + + if (!get_array_bounds (type, &low_bound, &high_bound)) + error (_("Could not determine the vector bounds")); val = allocate_value (type); - for (i = 0; i < n; i++) + for (i = 0; i < high_bound - low_bound + 1; i++) { tmp = value_complement (value_subscript (arg1, i)); memcpy (value_contents_writeable (val) + i * TYPE_LENGTH (eltype), diff --git a/gdb/valops.c b/gdb/valops.c index dfadad896d7..7ea63159c15 100644 --- a/gdb/valops.c +++ b/gdb/valops.c @@ -877,11 +877,15 @@ value_one (struct type *type, enum lval_type lv) else if (TYPE_CODE (type1) == TYPE_CODE_ARRAY && TYPE_VECTOR (type1)) { struct type *eltype = check_typedef (TYPE_TARGET_TYPE (type1)); - int i, n = TYPE_LENGTH (type1) / TYPE_LENGTH (eltype); + int i; + LONGEST low_bound, high_bound; struct value *tmp; + if (!get_array_bounds (type1, &low_bound, &high_bound)) + error (_("Could not determine the vector bounds")); + val = allocate_value (type); - for (i = 0; i < n; i++) + for (i = 0; i < high_bound - low_bound + 1; i++) { tmp = value_one (eltype, lv); memcpy (value_contents_writeable (val) + i * TYPE_LENGTH (eltype), |