]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Use gdb::array_view for setting value bytes in trad-frame
authorLuis Machado <luis.machado@linaro.org>
Wed, 23 Dec 2020 19:06:11 +0000 (16:06 -0300)
committerLuis Machado <luis.machado@linaro.org>
Tue, 19 Jan 2021 13:26:52 +0000 (10:26 -0300)
This patch updates the functions setting value bytes in trad-frame to use
a gdb::array_view instead of passing a buffer and a size.

gdb/ChangeLog:

2021-01-19  Luis Machado  <luis.machado@linaro.org>

* aarch64-linux-tdep.c (aarch64_linux_restore_vreg): Pass in an
array_view.
* trad-frame.c (trad_frame_set_value_bytes): Use gdb::array_view
instead of buffer and size.
(trad_frame_set_reg_value_bytes): Likewise.
* trad-frame.h (trad_frame_set_reg_value_bytes): Likewise.
(trad_frame_set_value_bytes): Likewise.

gdb/ChangeLog
gdb/aarch64-linux-tdep.c
gdb/trad-frame.c
gdb/trad-frame.h

index 136893036a5abb72d62428b9d17c8a110effdf2b..e31ed4321872bcd2c04256ff2764c786139c53f9 100644 (file)
@@ -1,3 +1,13 @@
+2021-01-19  Luis Machado  <luis.machado@linaro.org>
+
+       * aarch64-linux-tdep.c (aarch64_linux_restore_vreg): Pass in an
+       array_view.
+       * trad-frame.c (trad_frame_set_value_bytes): Use gdb::array_view
+       instead of buffer and size.
+       (trad_frame_set_reg_value_bytes): Likewise.
+       * trad-frame.h (trad_frame_set_reg_value_bytes): Likewise.
+       (trad_frame_set_value_bytes): Likewise.
+
 2021-01-18  Mike Frysinger  <vapier@gentoo.org>
 
        * copyright.py (NOT_FSF_LIST): Delete sim/testsuite/sim/bfin/s21.s.
index 4c2caf8e05b1d1f905b84891baabe1b333eedc24..954b05ca74065d07a423516e9fbd6f7e4715d3b8 100644 (file)
@@ -222,27 +222,27 @@ aarch64_linux_restore_vreg (struct trad_frame_cache *cache, int num_regs,
 
          /* Now we can store the correct bytes for the V register.  */
          trad_frame_set_reg_value_bytes (cache, AARCH64_V0_REGNUM + vreg_num,
-                                         buf, V_REGISTER_SIZE);
+                                         {buf, V_REGISTER_SIZE});
          trad_frame_set_reg_value_bytes (cache,
                                          num_regs + AARCH64_Q0_REGNUM
-                                         + vreg_num, buf, Q_REGISTER_SIZE);
+                                         + vreg_num, {buf, Q_REGISTER_SIZE});
          trad_frame_set_reg_value_bytes (cache,
                                          num_regs + AARCH64_D0_REGNUM
-                                         + vreg_num, buf, D_REGISTER_SIZE);
+                                         + vreg_num, {buf, D_REGISTER_SIZE});
          trad_frame_set_reg_value_bytes (cache,
                                          num_regs + AARCH64_S0_REGNUM
-                                         + vreg_num, buf, S_REGISTER_SIZE);
+                                         + vreg_num, {buf, S_REGISTER_SIZE});
          trad_frame_set_reg_value_bytes (cache,
                                          num_regs + AARCH64_H0_REGNUM
-                                         + vreg_num, buf, H_REGISTER_SIZE);
+                                         + vreg_num, {buf, H_REGISTER_SIZE});
          trad_frame_set_reg_value_bytes (cache,
                                          num_regs + AARCH64_B0_REGNUM
-                                         + vreg_num, buf, B_REGISTER_SIZE);
+                                         + vreg_num, {buf, B_REGISTER_SIZE});
 
          if (has_sve)
            trad_frame_set_reg_value_bytes (cache,
                                            num_regs + AARCH64_SVE_V0_REGNUM
-                                           + vreg_num, buf, V_REGISTER_SIZE);
+                                           + vreg_num, {buf, V_REGISTER_SIZE});
        }
       return;
     }
index 3284c4523175dc5e706fdc64f014c7282b8c2ccf..53bd097a2b34b2abceec1f972cebf8f3721dceef 100644 (file)
@@ -229,12 +229,12 @@ trad_frame_set_unknown (trad_frame_saved_reg this_saved_regs[],
 
 void
 trad_frame_set_value_bytes (trad_frame_saved_reg this_saved_regs[],
-                           int regnum, const gdb_byte *bytes,
-                           size_t size)
+                           int regnum,
+                           gdb::array_view<const gdb_byte> bytes)
 {
   /* Allocate the space and copy the data bytes.  */
-  gdb_byte *data = FRAME_OBSTACK_CALLOC (size, gdb_byte);
-  memcpy (data, bytes, size);
+  gdb_byte *data = FRAME_OBSTACK_CALLOC (bytes.size (), gdb_byte);
+  memcpy (data, bytes.data (), bytes.size ());
   this_saved_regs[regnum].set_value_bytes (data);
 }
 
@@ -242,13 +242,12 @@ trad_frame_set_value_bytes (trad_frame_saved_reg this_saved_regs[],
 
 void
 trad_frame_set_reg_value_bytes (struct trad_frame_cache *this_trad_cache,
-                               int regnum, const gdb_byte *bytes,
-                               size_t size)
+                               int regnum,
+                               gdb::array_view<const gdb_byte> bytes)
 {
   /* External interface for users of trad_frame_cache
      (who cannot access the prev_regs object directly).  */
-  trad_frame_set_value_bytes (this_trad_cache->prev_regs, regnum, bytes,
-                             size);
+  trad_frame_set_value_bytes (this_trad_cache->prev_regs, regnum, bytes);
 }
 
 
index cdc937cfa29db3412007d636673b298d75c9c68f..dc29bab979721f3e4a9af22a686c1ab05968c282 100644 (file)
@@ -55,8 +55,8 @@ void trad_frame_set_reg_value (struct trad_frame_cache *this_cache,
 /* Given the cache in THIS_TRAD_CACHE, set the value of REGNUM to the bytes
    contained in BYTES with size SIZE.  */
 void trad_frame_set_reg_value_bytes (struct trad_frame_cache *this_trad_cache,
-                                    int regnum, const gdb_byte *bytes,
-                                    size_t size);
+                                    int regnum,
+                                    gdb::array_view<const gdb_byte> bytes);
 
 struct value *trad_frame_get_register (struct trad_frame_cache *this_trad_cache,
                                       struct frame_info *this_frame,
@@ -204,8 +204,8 @@ void trad_frame_set_unknown (trad_frame_saved_reg this_saved_regs[],
 /* Encode REGNUM value in the trad-frame as a sequence of bytes.  This is
    useful when the value is larger than what primitive types can hold.  */
 void trad_frame_set_value_bytes (trad_frame_saved_reg this_saved_regs[],
-                                int regnum, const gdb_byte *bytes,
-                                size_t size);
+                                int regnum,
+                                gdb::array_view<const gdb_byte> bytes);
 
 /* Convenience functions, return non-zero if the register has been
    encoded as specified.  */