]> 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)
committerLuis Machado <luis.machado@linaro.org>
Tue, 8 Dec 2020 18:02:58 +0000 (15:02 -0300)
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/ChangeLog
gdb/aarch64-linux-nat.c
gdb/aarch64-tdep.c

index ea5db55410d52a78a7563c121bfbd5fd32070f0a..98004350a358d64d8bc4a239adc9788064ac6323 100644 (file)
@@ -1,3 +1,12 @@
+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.
+
 2020-10-20  Luis Machado  <luis.machado@arm.com>
 
        * aarch64-linux-tdep.c (aarch64_linux_cregmap)
index 7e1763e8eaca099e4e2706e0b1712124a010926f..dc006de7f0d38cc775adb808a7a0e9909aea9222 100644 (file)
@@ -582,7 +582,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 cb6f4683631afe352e837bc95f0e2942ab4198c3..16c85e394665a7f51dd2df0cd12817bdf9bf9804 100644 (file)
@@ -1401,7 +1401,10 @@ aarch64_prologue_prev_register (struct frame_info *this_frame,
     = aarch64_make_prologue_cache (this_frame, this_cache);
 
   struct gdbarch_tdep *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
@@ -1465,7 +1468,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,
@@ -1611,7 +1616,9 @@ aarch64_dwarf2_prev_register (struct frame_info *this_frame,
   struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
   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)
     {
@@ -1635,8 +1642,14 @@ aarch64_dwarf2_frame_init_reg (struct gdbarch *gdbarch, int regnum,
                               struct frame_info *this_frame)
 {
   struct gdbarch_tdep *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)
     {