Adjust byte order variable display/change if DW_AT_endianity is present.
[deliverable/binutils-gdb.git] / gdb / findvar.c
index 9256833ab601976b2f36f03aa241150f599ec10b..95cc58d83f8011f86cf4e9776edc42244ddc0523 100644 (file)
@@ -1,6 +1,6 @@
 /* Find a variable's value in memory, for GDB, the GNU debugger.
 
-   Copyright (C) 1986-2018 Free Software Foundation, Inc.
+   Copyright (C) 1986-2019 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -32,7 +32,7 @@
 #include "objfiles.h"
 #include "language.h"
 #include "dwarf2loc.h"
-#include "selftest.h"
+#include "gdbsupport/selftest.h"
 
 /* Basic byte-swapping routines.  All 'extract' functions return a
    host-format integer from a target-format integer at ADDR which is
@@ -50,7 +50,7 @@ template<typename T, typename>
 T
 extract_integer (const gdb_byte *addr, int len, enum bfd_endian byte_order)
 {
-  T retval = 0;
+  typename std::make_unsigned<T>::type retval = 0;
   const unsigned char *p;
   const unsigned char *startaddr = addr;
   const unsigned char *endaddr = startaddr + len;
@@ -218,7 +218,7 @@ store_typed_address (gdb_byte *buf, struct type *type, CORE_ADDR addr)
    bytes.  If SOURCE_SIZE is greater than DEST_SIZE, then truncate the most
    significant bytes.  If SOURCE_SIZE is less than DEST_SIZE then either sign
    or zero extended according to IS_SIGNED.  Values are stored in memory with
-   endianess BYTE_ORDER.  */
+   endianness BYTE_ORDER.  */
 
 void
 copy_integer_to_size (gdb_byte *dest, int dest_size, const gdb_byte *source,
@@ -267,8 +267,7 @@ value_of_register (int regnum, struct frame_info *frame)
 
   /* User registers lie completely outside of the range of normal
      registers.  Catch them early so that the target never sees them.  */
-  if (regnum >= gdbarch_num_regs (gdbarch)
-               + gdbarch_num_pseudo_regs (gdbarch))
+  if (regnum >= gdbarch_num_cooked_regs (gdbarch))
     return value_of_user_reg (regnum, frame);
 
   reg_val = value_of_register_lazy (frame, regnum);
@@ -287,8 +286,7 @@ value_of_register_lazy (struct frame_info *frame, int regnum)
   struct value *reg_val;
   struct frame_info *next_frame;
 
-  gdb_assert (regnum < (gdbarch_num_regs (gdbarch)
-                       + gdbarch_num_pseudo_regs (gdbarch)));
+  gdb_assert (regnum < gdbarch_num_cooked_regs (gdbarch));
 
   gdb_assert (frame != NULL);
 
@@ -311,7 +309,7 @@ CORE_ADDR
 unsigned_pointer_to_address (struct gdbarch *gdbarch,
                             struct type *type, const gdb_byte *buf)
 {
-  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
+  enum bfd_endian byte_order = type_byte_order (type);
 
   return extract_unsigned_integer (buf, TYPE_LENGTH (type), byte_order);
 }
@@ -320,7 +318,7 @@ CORE_ADDR
 signed_pointer_to_address (struct gdbarch *gdbarch,
                           struct type *type, const gdb_byte *buf)
 {
-  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
+  enum bfd_endian byte_order = type_byte_order (type);
 
   return extract_signed_integer (buf, TYPE_LENGTH (type), byte_order);
 }
@@ -331,7 +329,7 @@ void
 unsigned_address_to_pointer (struct gdbarch *gdbarch, struct type *type,
                             gdb_byte *buf, CORE_ADDR addr)
 {
-  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
+  enum bfd_endian byte_order = type_byte_order (type);
 
   store_unsigned_integer (buf, TYPE_LENGTH (type), byte_order, addr);
 }
@@ -340,7 +338,7 @@ void
 address_to_signed_pointer (struct gdbarch *gdbarch, struct type *type,
                           gdb_byte *buf, CORE_ADDR addr)
 {
-  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
+  enum bfd_endian byte_order = type_byte_order (type);
 
   store_signed_integer (buf, TYPE_LENGTH (type), byte_order, addr);
 }
@@ -448,7 +446,7 @@ follow_static_link (struct frame_info *frame,
       QUIT;
 
       /* If we don't know how to compute FRAME's base address, don't give up:
-        maybe the frame we are looking for is upper in the stace frame.  */
+        maybe the frame we are looking for is upper in the stack frame.  */
       if (framefunc != NULL
          && SYMBOL_BLOCK_OPS (framefunc) != NULL
          && SYMBOL_BLOCK_OPS (framefunc)->get_frame_base != NULL
@@ -622,7 +620,7 @@ default_read_var_value (struct symbol *var, const struct block *var_block,
       /* Put the constant back in target format. */
       v = allocate_value (type);
       store_signed_integer (value_contents_raw (v), TYPE_LENGTH (type),
-                           gdbarch_byte_order (get_type_arch (type)),
+                           type_byte_order (type),
                            (LONGEST) SYMBOL_VALUE (var));
       VALUE_LVAL (v) = not_lval;
       return v;
@@ -632,7 +630,7 @@ default_read_var_value (struct symbol *var, const struct block *var_block,
       v = allocate_value (type);
       if (overlay_debugging)
        {
-         CORE_ADDR addr
+         addr
            = symbol_overlayed_address (SYMBOL_VALUE_ADDRESS (var),
                                        SYMBOL_OBJ_SECTION (symbol_objfile (var),
                                                            var));
@@ -842,7 +840,7 @@ default_value_from_register (struct gdbarch *gdbarch, struct type *type,
      an integral number of registers.  Otherwise, you need to do
      some fiddling with the last register copied here for little
      endian machines.  */
-  if (gdbarch_byte_order (gdbarch) == BFD_ENDIAN_BIG
+  if (type_byte_order (type) == BFD_ENDIAN_BIG
       && len < register_size (gdbarch, regnum))
     /* Big-endian, and we want less than full size.  */
     set_value_offset (value, register_size (gdbarch, regnum) - len);
@@ -957,8 +955,7 @@ address_from_register (int regnum, struct frame_info *frame)
   struct type *type = builtin_type (gdbarch)->builtin_data_ptr;
   struct value *value;
   CORE_ADDR result;
-  int regnum_max_excl = (gdbarch_num_regs (gdbarch)
-                        + gdbarch_num_pseudo_regs (gdbarch));
+  int regnum_max_excl = gdbarch_num_cooked_regs (gdbarch);
 
   if (regnum < 0 || regnum >= regnum_max_excl)
     error (_("Invalid register #%d, expecting 0 <= # < %d"), regnum,
This page took 0.026063 seconds and 4 git commands to generate.