diff options
author | Tom de Vries <tdevries@suse.de> | 2024-11-12 11:37:50 +0100 |
---|---|---|
committer | Tom de Vries <tdevries@suse.de> | 2024-11-12 11:37:50 +0100 |
commit | a4a5f05266b69ebe8172433217d47cc7a737e51d (patch) | |
tree | 6d9411eb6ea8c52aa4c2f67bb6bc5033693a6c7c /gdb | |
parent | 510fa4aadb1c6509ebbbe55b901231c45039efd8 (diff) | |
download | gdb-a4a5f05266b69ebe8172433217d47cc7a737e51d.zip gdb-a4a5f05266b69ebe8172433217d47cc7a737e51d.tar.gz gdb-a4a5f05266b69ebe8172433217d47cc7a737e51d.tar.bz2 |
[gdb/tdep] Use raw_supply_part_zeroed for AArch64
In gdb/aarch64-linux-tdep.c we find:
...
gdb::byte_vector za_zeroed (za_bytes, 0);
regcache->raw_supply (tdep->sme_za_regnum, za_zeroed);
...
We can't use reg_buffer::raw_supply_zeroed here because only part of the
register is written.
Add raw_supply_part_zeroed, and use it instead.
Likewise elsewhere in AArch64 tdep code.
Tested on aarch64-linux.
Approved-By: Luis Machado <luis.machado@arm.com>
Diffstat (limited to 'gdb')
-rw-r--r-- | gdb/aarch64-linux-tdep.c | 5 | ||||
-rw-r--r-- | gdb/nat/aarch64-scalable-linux-ptrace.c | 8 | ||||
-rw-r--r-- | gdb/regcache.c | 10 | ||||
-rw-r--r-- | gdb/regcache.h | 3 |
4 files changed, 17 insertions, 9 deletions
diff --git a/gdb/aarch64-linux-tdep.c b/gdb/aarch64-linux-tdep.c index c608a84..0937659 100644 --- a/gdb/aarch64-linux-tdep.c +++ b/gdb/aarch64-linux-tdep.c @@ -1297,10 +1297,7 @@ aarch64_linux_supply_za_regset (const struct regset *regset, regcache->raw_supply (tdep->sme_za_regnum, buf); } else - { - gdb::byte_vector za_zeroed (za_bytes, 0); - regcache->raw_supply (tdep->sme_za_regnum, za_zeroed); - } + regcache->raw_supply_part_zeroed (tdep->sme_za_regnum, 0, za_bytes); } /* Collect register REGNUM from REGCACHE to BUF, using the register diff --git a/gdb/nat/aarch64-scalable-linux-ptrace.c b/gdb/nat/aarch64-scalable-linux-ptrace.c index 0f1bedf..1d226b4 100644 --- a/gdb/nat/aarch64-scalable-linux-ptrace.c +++ b/gdb/nat/aarch64-scalable-linux-ptrace.c @@ -920,8 +920,7 @@ aarch64_za_regs_copy_to_reg_buf (int tid, struct reg_buffer_common *reg_buf, else { size_t za_bytes = header->vl * header->vl; - gdb::byte_vector za_zeroed (za_bytes, 0); - reg_buf->raw_supply (za_regnum, za_zeroed); + reg_buf->raw_supply_part_zeroed (za_regnum, 0, za_bytes); } /* Handle the svg and svcr registers separately. We need to calculate @@ -1000,7 +999,7 @@ aarch64_za_regs_copy_from_reg_buf (int tid, in the thread with the ZA contents from the register cache, and they will differ in size. */ if (svg_changed) - reg_buf->raw_supply (za_regnum, za_zeroed); + reg_buf->raw_supply_part_zeroed (za_regnum, 0, za_bytes); /* When we update svg, we don't automatically initialize the ZA buffer. If we have no ZA state and the ZA register contents in the register cache are @@ -1078,8 +1077,7 @@ aarch64_zt_regs_copy_to_reg_buf (int tid, struct reg_buffer_common *reg_buf, else { /* Zero out ZT. */ - gdb::byte_vector zt_zeroed (AARCH64_SME2_ZT0_SIZE, 0); - reg_buf->raw_supply (zt_regnum, zt_zeroed.data ()); + reg_buf->raw_supply_part_zeroed (zt_regnum, 0, AARCH64_SME2_ZT0_SIZE); } /* The register buffer should now contain the updated copy of the NT_ARM_ZT diff --git a/gdb/regcache.c b/gdb/regcache.c index f04354d..ab3f616 100644 --- a/gdb/regcache.c +++ b/gdb/regcache.c @@ -1190,6 +1190,16 @@ reg_buffer::raw_supply_zeroed (int regnum) /* See gdbsupport/common-regcache.h. */ void +reg_buffer::raw_supply_part_zeroed (int regnum, int offset, size_t size) +{ + gdb::array_view<gdb_byte> dst = register_buffer (regnum).slice (offset, size); + memset (dst.data (), 0, dst.size ()); + m_register_status[regnum] = REG_VALID; +} + +/* See gdbsupport/common-regcache.h. */ + +void reg_buffer::raw_collect (int regnum, gdb::array_view<gdb_byte> dst) const { gdb::array_view<const gdb_byte> src = register_buffer (regnum); diff --git a/gdb/regcache.h b/gdb/regcache.h index 2f4b7d9..8d026e0 100644 --- a/gdb/regcache.h +++ b/gdb/regcache.h @@ -243,6 +243,9 @@ public: unavailable). */ void raw_supply_zeroed (int regnum); + /* See gdbsupport/common-regcache.h. */ + void raw_supply_part_zeroed (int regnum, int offset, size_t size) override; + /* Supply part of register REGNUM to this register buffer. Start at OFFSET in the register. The size is given by the size of SRC. The rest of the register left untouched. */ |