]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Guard places using Morello C registers
authorLuis Machado <luis.machado@arm.com>
Mon, 9 Nov 2020 20:24:42 +0000 (17:24 -0300)
committerJohn Baldwin <jhb@FreeBSD.org>
Thu, 1 Sep 2022 22:53:22 +0000 (15:53 -0700)
Make sure we only use the C registers if they have been detected.

gdb/ChangeLog:

2020-11-11  Luis Machado  <luis.machado@arm.com>

* aarch64-tdep.c (aarch64_prologue_prev_register): Guard use of
C registers.
(aarch64_dwarf2_prev_register): Likewise.
(aarch64_dwarf2_frame_init_reg): Likewise.
* aarch64-linux-nat.c
(aarch64_linux_nat_target::store_registers): Likewise.

gdb/aarch64-linux-nat.c
gdb/aarch64-tdep.c

index 3b62a8fd503ae643bbb060ea54196d9f81ff8fad..cdf101bad39ad59f78031b02aac6ca99ba45b5c6 100644 (file)
@@ -630,7 +630,11 @@ aarch64_linux_nat_target::store_registers (struct regcache *regcache,
   else if (regno < AARCH64_V0_REGNUM)
     {
       store_gregs_to_thread (regcache);
-      fetch_cregs_from_thread (regcache);
+
+      /* If we have capability registers, refresh them when we store to
+        the general register set.  */
+      if (tdep->has_capability ())
+       fetch_cregs_from_thread (regcache);
     }
   else if (tdep->has_sve ())
     store_sveregs_to_thread (regcache);
index b5f11ebd9c35308f1d988e19856dac2cd0989605..045483b20d1482da919ffb2d379686c0c5ce5f87 100644 (file)
@@ -1441,7 +1441,10 @@ aarch64_prologue_prev_register (struct frame_info *this_frame,
 
   aarch64_gdbarch_tdep *tdep
     = (aarch64_gdbarch_tdep *) gdbarch_tdep (get_frame_arch (this_frame));
-  int pcc_regnum = tdep->cap_reg_base + 31;
+
+  int pcc_regnum = -1;
+  if (tdep->has_capability ())
+    pcc_regnum = tdep->cap_reg_base + 31;
 
   /* If we are asked to unwind the PC, then we need to return the LR
      instead.  The prologue may save PC, but it will point into this
@@ -1504,7 +1507,9 @@ aarch64_prologue_prev_register (struct frame_info *this_frame,
         |          |
         |          |<- SP
         +----------+  */
-  int csp_regnum = tdep->cap_reg_base + 32;
+  int csp_regnum = -1;
+  if (tdep->has_capability ())
+    csp_regnum = tdep->cap_reg_base + 32;
 
   if (prev_regnum == AARCH64_SP_REGNUM || prev_regnum == csp_regnum)
     return frame_unwind_got_constant (this_frame, prev_regnum,
@@ -1652,7 +1657,9 @@ aarch64_dwarf2_prev_register (struct frame_info *this_frame,
   aarch64_gdbarch_tdep *tdep = (aarch64_gdbarch_tdep *) gdbarch_tdep (arch);
   CORE_ADDR lr;
 
-  int pcc_regnum = tdep->cap_reg_base + 31;
+  int pcc_regnum = -1;
+  if (tdep->has_capability ())
+    pcc_regnum = tdep->cap_reg_base + 31;
 
   if (regnum == AARCH64_PC_REGNUM || regnum == pcc_regnum)
     {
@@ -1676,8 +1683,14 @@ aarch64_dwarf2_frame_init_reg (struct gdbarch *gdbarch, int regnum,
                               struct frame_info *this_frame)
 {
   aarch64_gdbarch_tdep *tdep = (aarch64_gdbarch_tdep *) gdbarch_tdep (gdbarch);
-  int pcc_regnum = tdep->cap_reg_base + 31;
-  int csp_regnum = tdep->cap_reg_base + 32;
+  int pcc_regnum = -1;
+  int csp_regnum = -1;
+
+  if (tdep->has_capability ())
+    {
+      pcc_regnum = tdep->cap_reg_base + 31;
+      csp_regnum = tdep->cap_reg_base + 32;
+    }
 
   if (regnum == AARCH64_PC_REGNUM || regnum == pcc_regnum)
     {