From: Luis Machado luis.machado@arm.com
Make sure we only use the C registers if they have been detected.
gdb/ChangeLog:
YYYY-MM-DD 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 | 6 +++++- gdb/aarch64-tdep.c | 23 ++++++++++++++++++----- 2 files changed, 23 insertions(+), 6 deletions(-)
diff --git a/gdb/aarch64-linux-nat.c b/gdb/aarch64-linux-nat.c index 7e1763e8ea..dc006de7f0 100644 --- a/gdb/aarch64-linux-nat.c +++ b/gdb/aarch64-linux-nat.c @@ -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); diff --git a/gdb/aarch64-tdep.c b/gdb/aarch64-tdep.c index cb6f468363..16c85e3946 100644 --- a/gdb/aarch64-tdep.c +++ b/gdb/aarch64-tdep.c @@ -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) {