diff mbox series

[RFC,v4,05/15] gdbserver: nat/aarch64: Only check Z registers for extra contents if they can have it

Message ID 20241102025635.586759-6-thiago.bauermann@linaro.org
State New
Headers show
Series gdbserver improvements for AArch64 SVE support | expand

Commit Message

Thiago Jung Bauermann Nov. 2, 2024, 2:56 a.m. UTC
The bottom 128 bits of Z registers overlap with the V registers.  If the
vector length is 128 bits, then they have no extra contents and in that
case this code will hit the gdb_assert (offset < regbuf.size ()); in
gdbserver's regcache::raw_compare ().

Therefore in that case we need to skip the meaningless comparison.
---
 gdb/nat/aarch64-scalable-linux-ptrace.c | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)
diff mbox series

Patch

diff --git a/gdb/nat/aarch64-scalable-linux-ptrace.c b/gdb/nat/aarch64-scalable-linux-ptrace.c
index 0f1bedf78002..ac375b78541a 100644
--- a/gdb/nat/aarch64-scalable-linux-ptrace.c
+++ b/gdb/nat/aarch64-scalable-linux-ptrace.c
@@ -745,15 +745,16 @@  aarch64_sve_regs_copy_from_reg_buf (int tid,
       /* Check in the reg_buf if any of the Z registers are set after the
 	 first 128 bits, or if any of the other SVE registers are set.  */
       bool has_sve_state = false;
-      for (int i = 0; i < AARCH64_SVE_Z_REGS_NUM; i++)
-	{
-	  if (!reg_buf->raw_compare (AARCH64_SVE_Z0_REGNUM + i, reg,
-				     V_REGISTER_SIZE))
-	    {
-	      has_sve_state = true;
-	      break;
-	    }
-	}
+      if (reg_buf->register_size (AARCH64_SVE_Z0_REGNUM) > V_REGISTER_SIZE)
+	for (int i = 0; i < AARCH64_SVE_Z_REGS_NUM; i++)
+	  {
+	    if (!reg_buf->raw_compare (AARCH64_SVE_Z0_REGNUM + i, reg,
+				       V_REGISTER_SIZE))
+	      {
+		has_sve_state = true;
+		break;
+	      }
+	  }
 
       if (!has_sve_state)
 	for (int i = 0; i < AARCH64_SVE_P_REGS_NUM; i++)