From: Luis Machado Date: Mon, 9 Nov 2020 20:24:42 +0000 (-0300) Subject: Guard places using Morello C registers X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=02ff4fb458030b2c2b8ce377a5c1efe19ec9a48e;p=thirdparty%2Fbinutils-gdb.git Guard places using Morello C registers Make sure we only use the C registers if they have been detected. gdb/ChangeLog: 2020-11-11 Luis Machado * 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. --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index ea5db55410d..98004350a35 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,12 @@ +2020-11-11 Luis Machado + + * 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 * aarch64-linux-tdep.c (aarch64_linux_cregmap) diff --git a/gdb/aarch64-linux-nat.c b/gdb/aarch64-linux-nat.c index 7e1763e8eac..dc006de7f0d 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 cb6f4683631..16c85e39466 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) {