]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
gdb:
authorKen Werner <ken.werner@de.ibm.com>
Tue, 14 Dec 2010 10:23:41 +0000 (10:23 +0000)
committerKen Werner <ken.werner@de.ibm.com>
Tue, 14 Dec 2010 10:23:41 +0000 (10:23 +0000)
* 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.

ChangeLog
gdb/valarith.c
gdb/valops.c

index bc19a7707b530e1c78af00b2e1cd9d29107099b5..983324dc6283a9958380efe951f1d14312038ee7 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2010-12-14  Ken Werner  <ken.werner@de.ibm.com>
+
+       * 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.
+
 2010-12-10  Ian Lance Taylor  <iant@google.com>
 
        PR bootstrap/46819
index 36e937dcc56ca1bf8d393096380a00b48b5b4cff..6b212b29b0e94855238465422aa630c3a4b634dd 100644 (file)
@@ -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),
index dfadad896d7e5b83edbfa03a2f1dc99025eac6ac..7ea63159c15797ea29a319a27a375d80e6a91a3d 100644 (file)
@@ -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),