aboutsummaryrefslogtreecommitdiff
path: root/gdb/valarith.c
diff options
context:
space:
mode:
authorKen Werner <ken.werner@de.ibm.com>2010-12-14 10:23:41 +0000
committerKen Werner <ken.werner@de.ibm.com>2010-12-14 10:23:41 +0000
commitcfa6f0541f6a343e4ae51c1b66ab0e3f566cf3ea (patch)
tree2ed804d745f0775a35c60b505087e797b032e679 /gdb/valarith.c
parent043b6510015086daf0b084955c4b1da2ee1f0e24 (diff)
downloadgdb-cfa6f0541f6a343e4ae51c1b66ab0e3f566cf3ea.zip
gdb-cfa6f0541f6a343e4ae51c1b66ab0e3f566cf3ea.tar.gz
gdb-cfa6f0541f6a343e4ae51c1b66ab0e3f566cf3ea.tar.bz2
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/valarith.c')
-rw-r--r--gdb/valarith.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/gdb/valarith.c b/gdb/valarith.c
index 36e937d..6b212b2 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),