Change regcache list to be an hash map
[deliverable/binutils-gdb.git] / gdb / valarith.c
index 3a59ada2d56d55adb5f8ae838990f9bc53116bd0..887acc86751078ad3f5944b2b6119d414edccd29 100644 (file)
@@ -1,6 +1,6 @@
 /* Perform arithmetic and other operations on values, for GDB.
 
-   Copyright (C) 1986-2018 Free Software Foundation, Inc.
+   Copyright (C) 1986-2019 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -26,7 +26,8 @@
 #include "language.h"
 #include "target-float.h"
 #include "infcall.h"
-#include "common/byte-vector.h"
+#include "gdbsupport/byte-vector.h"
+#include "gdbarch.h"
 
 /* Define whether or not the C operator '/' truncates towards zero for
    differently signed operands (truncation direction is undefined in C).  */
@@ -182,11 +183,22 @@ value_subscript (struct value *array, LONGEST index)
    to doubles, but no longer does.  */
 
 struct value *
-value_subscripted_rvalue (struct value *array, LONGEST index, int lowerbound)
+value_subscripted_rvalue (struct value *array, LONGEST index, LONGEST lowerbound)
 {
   struct type *array_type = check_typedef (value_type (array));
   struct type *elt_type = check_typedef (TYPE_TARGET_TYPE (array_type));
   ULONGEST elt_size = type_length_units (elt_type);
+
+  /* Fetch the bit stride and convert it to a byte stride, assuming 8 bits
+     in a byte.  */
+  LONGEST stride = TYPE_ARRAY_BIT_STRIDE (array_type);
+  if (stride != 0)
+    {
+      struct gdbarch *arch = get_type_arch (elt_type);
+      int unit_size = gdbarch_addressable_memory_unit_size (arch);
+      elt_size = stride / (unit_size * 8);
+    }
+
   ULONGEST elt_offs = elt_size * (index - lowerbound);
 
   if (index < lowerbound
@@ -334,7 +346,7 @@ value_user_defined_op (struct value **argp, gdb::array_view<value *> args,
    arg1.operator @ (arg1,arg2) and return that value (where '@' is any
    binary operator which is legal for GNU C++).
 
-   OP is the operatore, and if it is BINOP_ASSIGN_MODIFY, then OTHEROP
+   OP is the operator, and if it is BINOP_ASSIGN_MODIFY, then OTHEROP
    is the opcode saying how to modify it.  Otherwise, OTHEROP is
    unused.  */
 
@@ -554,13 +566,11 @@ value_x_unop (struct value *arg1, enum exp_opcode op, enum noside noside)
     case UNOP_POSTINCREMENT:
       strcpy (ptr, "++");
       argvec[2] = value_from_longest (builtin_type (gdbarch)->builtin_int, 0);
-      argvec[3] = 0;
       nargs ++;
       break;
     case UNOP_POSTDECREMENT:
       strcpy (ptr, "--");
       argvec[2] = value_from_longest (builtin_type (gdbarch)->builtin_int, 0);
-      argvec[3] = 0;
       nargs ++;
       break;
     case UNOP_LOGICAL_NOT:
@@ -989,7 +999,7 @@ scalar_binop (struct value *arg1, struct value *arg2, enum exp_opcode op)
       val = allocate_value (result_type);
       store_signed_integer (value_contents_raw (val),
                            TYPE_LENGTH (result_type),
-                           gdbarch_byte_order (get_type_arch (result_type)),
+                           type_byte_order (result_type),
                            v);
     }
   else
@@ -1137,8 +1147,7 @@ scalar_binop (struct value *arg1, struct value *arg2, enum exp_opcode op)
          val = allocate_value (result_type);
          store_unsigned_integer (value_contents_raw (val),
                                  TYPE_LENGTH (value_type (val)),
-                                 gdbarch_byte_order
-                                   (get_type_arch (result_type)),
+                                 type_byte_order (result_type),
                                  v);
        }
       else
@@ -1267,8 +1276,7 @@ scalar_binop (struct value *arg1, struct value *arg2, enum exp_opcode op)
          val = allocate_value (result_type);
          store_signed_integer (value_contents_raw (val),
                                TYPE_LENGTH (value_type (val)),
-                               gdbarch_byte_order
-                                 (get_type_arch (result_type)),
+                               type_byte_order (result_type),
                                v);
        }
     }
@@ -1713,9 +1721,9 @@ value_bit_index (struct type *type, const gdb_byte *valaddr, int index)
     return -1;
   rel_index = index - low_bound;
   word = extract_unsigned_integer (valaddr + (rel_index / TARGET_CHAR_BIT), 1,
-                                  gdbarch_byte_order (gdbarch));
+                                  type_byte_order (type));
   rel_index %= TARGET_CHAR_BIT;
-  if (gdbarch_bits_big_endian (gdbarch))
+  if (gdbarch_byte_order (gdbarch) == BFD_ENDIAN_BIG)
     rel_index = TARGET_CHAR_BIT - 1 - rel_index;
   return (word >> rel_index) & 1;
 }
@@ -1742,8 +1750,3 @@ value_in (struct value *element, struct value *set)
     error (_("First argument of 'IN' not in range"));
   return member;
 }
-
-void
-_initialize_valarith (void)
-{
-}
This page took 0.025294 seconds and 4 git commands to generate.