+2021-01-19 Luis Machado <luis.machado@linaro.org>
+
+ * trad-frame.h (trad_frame_saved_reg) <set_value_bytes>: Allocate
+ memory and save data.
+ (trad_frame_set_value, trad_frame_set_realreg, trad_frame_set_addr)
+ (trad_frame_set_unknown, trad_frame_set_value_bytes)
+ (trad_frame_value_p, trad_frame_addr_p, trad_frame_realreg_p)
+ (trad_frame_value_bytes_p): Remove.
+ (trad_frame_reset_saved_regs): Adjust documentation.
+ * trad-frame.c (trad_frame_alloc_saved_regs): Initialize via a
+ constructor and reset the state of the registers.
+ (trad_frame_value_p, trad_frame_addr_p, trad_frame_realreg_p)
+ (trad_frame_value_bytes_p, trad_frame_set_value)
+ (trad_frame_set_realreg, trad_frame_set_addr)
+ (trad_frame_set_unknown, trad_frame_set_value_bytes): Remove.
+ (trad_frame_set_reg_realreg): Update to call member function.
+ (trad_frame_set_reg_addr, trad_frame_set_reg_value_bytes): Likewise.
+ (trad_frame_get_prev_register): Likewise.
+
+ * aarch64-tdep.c (aarch64_analyze_prologue)
+ (aarch64_analyze_prologue_test, aarch64_make_prologue_cache_1)
+ (aarch64_prologue_prev_register): Update to use member functions.
+ * alpha-mdebug-tdep.c (alpha_mdebug_frame_unwind_cache): Likewise.
+ * alpha-tdep.c (alpha_heuristic_frame_unwind_cache): Likewise.
+ * arc-tdep.c (arc_print_frame_cache, arc_make_frame_cache): Likewise.
+ * arm-tdep.c (arm_make_prologue_cache, arm_exidx_fill_cache)
+ (arm_make_epilogue_frame_cache): Likewise.
+ * avr-tdep.c (avr_frame_unwind_cache)
+ (avr_frame_prev_register): Likewise.
+ * cris-tdep.c (cris_scan_prologue): Likewise.
+ * csky-tdep.c (csky_frame_unwind_cache): Likewise.
+ * frv-tdep.c (frv_analyze_prologue): Likewise.
+ * hppa-tdep.c (hppa_frame_cache, hppa_fallback_frame_cache): Likewise.
+ * lm32-tdep.c (lm32_frame_cache): Likewise.
+ * m32r-tdep.c (m32r_frame_unwind_cache): Likewise.
+ * m68hc11-tdep.c (m68hc11_frame_unwind_cache): Likewise.
+ * mips-tdep.c (set_reg_offset, mips_insn16_frame_cache)
+ (mips_micro_frame_cache, mips_insn32_frame_cache): Likewise.
+ (reset_saved_regs): Adjust to set realreg.
+ * riscv-tdep.c (riscv_scan_prologue, riscv_frame_cache): Adjust to
+ call member functions.
+ * rs6000-tdep.c (rs6000_frame_cache, rs6000_epilogue_frame_cache)
+ * s390-tdep.c (s390_prologue_frame_unwind_cache)
+ (s390_backchain_frame_unwind_cache): Likewise.
+ * score-tdep.c (score7_analyze_prologue)
+ (score3_analyze_prologue, score_make_prologue_cache): Likewise.
+ * sparc-netbsd-tdep.c (sparc32nbsd_sigcontext_saved_regs): Likewise.
+ * sparc-sol2-tdep.c (sparc32_sol2_sigtramp_frame_cache): Likewise.
+ * sparc64-netbsd-tdep.c (sparc64nbsd_sigcontext_saved_regs): Likewise.
+ * sparc64-sol2-tdep.c (sparc64_sol2_sigtramp_frame_cache): Likewise.
+ * tilegx-tdep.c (tilegx_analyze_prologue)
+ (tilegx_frame_cache): Likewise.
+ * v850-tdep.c (v850_frame_cache): Likewise.
+ * vax-tdep.c (vax_frame_cache): Likewise.
+
2021-01-19 Luis Machado <luis.machado@linaro.org>
* frame.h (get_frame_register_bytes): Pass a gdb::array_view instead
}
if (tdep->has_pauth () && cache != nullptr)
- trad_frame_set_value (cache->saved_regs,
- tdep->pauth_ra_state_regnum,
- ra_state_val);
+ {
+ int regnum = tdep->pauth_ra_state_regnum;
+ cache->saved_regs[regnum].set_value (ra_state_val);
+ }
}
else
{
else if (i == AARCH64_LR_REGNUM)
SELF_CHECK (cache.saved_regs[i].addr () == -264);
else
- SELF_CHECK (cache.saved_regs[i].is_realreg ());
+ SELF_CHECK (cache.saved_regs[i].is_realreg ()
+ && cache.saved_regs[i].realreg () == i);
}
for (int i = 0; i < AARCH64_D_REGISTER_COUNT; i++)
{
- int regnum = gdbarch_num_regs (gdbarch);
+ int num_regs = gdbarch_num_regs (gdbarch);
+ int regnum = i + num_regs + AARCH64_D0_REGNUM;
- SELF_CHECK (cache.saved_regs[i + regnum
- + AARCH64_D0_REGNUM].is_realreg ());
+ SELF_CHECK (cache.saved_regs[regnum].is_realreg ()
+ && cache.saved_regs[regnum].realreg () == regnum);
}
}
else if (i == 19)
SELF_CHECK (cache.saved_regs[i].addr () == -48);
else
- SELF_CHECK (cache.saved_regs[i].is_realreg ());
+ SELF_CHECK (cache.saved_regs[i].is_realreg ()
+ && cache.saved_regs[i].realreg () == i);
}
for (int i = 0; i < AARCH64_D_REGISTER_COUNT; i++)
{
- int regnum = gdbarch_num_regs (gdbarch);
+ int num_regs = gdbarch_num_regs (gdbarch);
+ int regnum = i + num_regs + AARCH64_D0_REGNUM;
+
if (i == 0)
- SELF_CHECK (cache.saved_regs[i + regnum
- + AARCH64_D0_REGNUM].addr ()
- == -24);
+ SELF_CHECK (cache.saved_regs[regnum].addr () == -24);
else
- SELF_CHECK (cache.saved_regs[i + regnum
- + AARCH64_D0_REGNUM].is_realreg ());
+ SELF_CHECK (cache.saved_regs[regnum].is_realreg ()
+ && cache.saved_regs[regnum].realreg () == regnum);
}
}
else if (i == AARCH64_LR_REGNUM)
SELF_CHECK (cache.saved_regs[i].addr () == -40);
else
- SELF_CHECK (cache.saved_regs[i].is_realreg ());
+ SELF_CHECK (cache.saved_regs[i].is_realreg ()
+ && cache.saved_regs[i].realreg () == i);
}
if (tdep->has_pauth ())
{
- SELF_CHECK (trad_frame_value_p (cache.saved_regs,
- tdep->pauth_ra_state_regnum));
- SELF_CHECK (cache.saved_regs[tdep->pauth_ra_state_regnum].addr ()
- == 1);
+ int regnum = tdep->pauth_ra_state_regnum;
+ SELF_CHECK (cache.saved_regs[regnum].is_value ());
}
}
}
/* Calculate actual addresses of saved registers using offsets
determined by aarch64_analyze_prologue. */
for (reg = 0; reg < gdbarch_num_regs (get_frame_arch (this_frame)); reg++)
- if (trad_frame_addr_p (cache->saved_regs, reg))
+ if (cache->saved_regs[reg].is_addr ())
cache->saved_regs[reg].set_addr (cache->saved_regs[reg].addr ()
+ cache->prev_sp);
lr = frame_unwind_register_unsigned (this_frame, AARCH64_LR_REGNUM);
if (tdep->has_pauth ()
- && trad_frame_value_p (cache->saved_regs,
- tdep->pauth_ra_state_regnum))
+ && cache->saved_regs[tdep->pauth_ra_state_regnum].is_value ())
lr = aarch64_frame_unmask_lr (tdep, this_frame, lr);
return frame_unwind_got_constant (this_frame, prev_regnum, lr);
/* The stack pointer of the previous frame is computed by popping
the current stack frame. */
- if (!trad_frame_addr_p (info->saved_regs, ALPHA_SP_REGNUM))
- trad_frame_set_value (info->saved_regs, ALPHA_SP_REGNUM, vfp);
+ if (!info->saved_regs[ALPHA_SP_REGNUM].is_addr ())
+ info->saved_regs[ALPHA_SP_REGNUM].set_value (vfp);
return info;
}
All it says is that the function we are scanning reused
that register for some computation of its own, and is now
saving its result. */
- if (trad_frame_addr_p(info->saved_regs, reg))
+ if (info->saved_regs[reg].is_addr ())
continue;
if (reg == 31)
/* Convert offsets to absolute addresses. See above about adding
one to the offsets to make all detected offsets non-zero. */
for (reg = 0; reg < ALPHA_NUM_REGS; ++reg)
- if (trad_frame_addr_p(info->saved_regs, reg))
+ if (info->saved_regs[reg].is_addr ())
info->saved_regs[reg].set_addr (info->saved_regs[reg].addr ()
+ val - 1);
/* The stack pointer of the previous frame is computed by popping
the current stack frame. */
- if (!trad_frame_addr_p (info->saved_regs, ALPHA_SP_REGNUM))
- trad_frame_set_value (info->saved_regs, ALPHA_SP_REGNUM, info->vfp);
+ if (!info->saved_regs[ALPHA_SP_REGNUM].is_addr ())
+ info->saved_regs[ALPHA_SP_REGNUM].set_value (info->vfp);
return info;
}
for (int i = 0; i <= ARC_BLINK_REGNUM; i++)
{
- if (trad_frame_addr_p (cache->saved_regs, i))
+ if (cache->saved_regs[i].is_addr ())
arc_debug_printf ("saved register %s at %s %s",
gdbarch_register_name (gdbarch, i),
(addresses_known) ? "address" : "offset",
for (int i = 0; i <= ARC_LAST_CORE_REGNUM; i++)
{
- if (trad_frame_addr_p (cache->saved_regs, i))
+ if (cache->saved_regs[i].is_addr ())
cache->saved_regs[i].set_addr (cache->saved_regs[i].addr ()
+ cache->prev_sp);
}
/* Calculate actual addresses of saved registers using offsets
determined by arm_scan_prologue. */
for (reg = 0; reg < gdbarch_num_regs (get_frame_arch (this_frame)); reg++)
- if (trad_frame_addr_p (cache->saved_regs, reg))
+ if (cache->saved_regs[reg].is_addr ())
cache->saved_regs[reg].set_addr (cache->saved_regs[reg].addr ()
+ cache->prev_sp);
actual value in the current frame. */
if (!vsp_valid)
{
- if (trad_frame_realreg_p (cache->saved_regs, ARM_SP_REGNUM))
+ if (cache->saved_regs[ARM_SP_REGNUM].is_realreg ())
{
int reg = cache->saved_regs[ARM_SP_REGNUM].realreg ();
vsp = get_frame_register_unsigned (this_frame, reg);
{
/* We could only have updated PC by popping into it; if so, it
will show up as address. Otherwise, copy LR into PC. */
- if (!trad_frame_addr_p (cache->saved_regs, ARM_PC_REGNUM))
+ if (!cache->saved_regs[ARM_PC_REGNUM].is_addr ())
cache->saved_regs[ARM_PC_REGNUM]
= cache->saved_regs[ARM_LR_REGNUM];
/* If we restore SP from a register, assume this was the frame register.
Otherwise just fall back to SP as frame register. */
- if (trad_frame_realreg_p (cache->saved_regs, ARM_SP_REGNUM))
+ if (cache->saved_regs[ARM_SP_REGNUM].is_realreg ())
cache->framereg = cache->saved_regs[ARM_SP_REGNUM].realreg ();
else
cache->framereg = ARM_SP_REGNUM;
/* Calculate actual addresses of saved registers using offsets
determined by arm_scan_prologue. */
for (reg = 0; reg < gdbarch_num_regs (get_frame_arch (this_frame)); reg++)
- if (trad_frame_addr_p (cache->saved_regs, reg))
+ if (cache->saved_regs[reg].is_addr ())
cache->saved_regs[reg].set_addr (cache->saved_regs[reg].addr ()
+ cache->prev_sp);
/* The previous frame's SP needed to be computed. Save the computed
value. */
tdep = gdbarch_tdep (gdbarch);
- trad_frame_set_value (info->saved_regs, AVR_SP_REGNUM,
- info->prev_sp - 1 + tdep->call_length);
+ info->saved_regs[AVR_SP_REGNUM].set_value (info->prev_sp
+ - 1 + tdep->call_length);
return info;
}
if (regnum == AVR_PC_REGNUM || regnum == AVR_PSEUDO_PC_REGNUM)
{
- if (trad_frame_addr_p (info->saved_regs, AVR_PC_REGNUM))
+ if (info->saved_regs[AVR_PC_REGNUM].is_addr ())
{
/* Reading the return PC from the PC register is slightly
abnormal. register_size(AVR_PC_REGNUM) says it is 4 bytes,
/* The previous frame's SP needed to be computed. Save the computed
value. */
- trad_frame_set_value (info->saved_regs,
- gdbarch_sp_regnum (gdbarch), info->prev_sp);
+ info->saved_regs[gdbarch_sp_regnum (gdbarch)].set_value (info->prev_sp);
if (!info->leaf_function)
{
func_end, this_frame, cache, lr_type);
/* gdbarch_sp_regnum contains the value and not the address. */
- trad_frame_set_value (cache->saved_regs, sp_regnum, cache->prev_sp);
+ cache->saved_regs[sp_regnum].set_value (cache->prev_sp);
return cache;
}
info->saved_regs[pc_regnum] = info->saved_regs[lr_regnum];
/* Save the previous frame's computed SP value. */
- trad_frame_set_value (info->saved_regs, sp_regnum, info->prev_sp);
+ info->saved_regs[sp_regnum].set_value (info->prev_sp);
}
return last_prologue_pc;
paddress (gdbarch, cache->base));
}
else if (u->Save_SP
- && trad_frame_addr_p (cache->saved_regs, HPPA_SP_REGNUM))
+ && cache->saved_regs[HPPA_SP_REGNUM].is_addr ())
{
/* Both we're expecting the SP to be saved and the SP has been
saved. The entry SP value is saved at this frame's SP
paddress (gdbarch, cache->base));
}
- trad_frame_set_value (cache->saved_regs, HPPA_SP_REGNUM, cache->base);
+ cache->saved_regs[HPPA_SP_REGNUM].set_value (cache->base);
}
/* The PC is found in the "return register", "Millicode" uses "r31"
as the return register while normal code uses "rp". */
if (u->Millicode)
{
- if (trad_frame_addr_p (cache->saved_regs, 31))
+ if (cache->saved_regs[31].is_addr ())
{
cache->saved_regs[HPPA_PCOQ_HEAD_REGNUM] = cache->saved_regs[31];
if (hppa_debug)
else
{
ULONGEST r31 = get_frame_register_unsigned (this_frame, 31);
- trad_frame_set_value (cache->saved_regs, HPPA_PCOQ_HEAD_REGNUM, r31);
+ cache->saved_regs[HPPA_PCOQ_HEAD_REGNUM].set_value (r31);
if (hppa_debug)
fprintf_unfiltered (gdb_stdlog, " (pc=r31) [frame] } ");
}
}
else
{
- if (trad_frame_addr_p (cache->saved_regs, HPPA_RP_REGNUM))
+ if (cache->saved_regs[HPPA_RP_REGNUM].is_addr ())
{
cache->saved_regs[HPPA_PCOQ_HEAD_REGNUM] =
cache->saved_regs[HPPA_RP_REGNUM];
{
ULONGEST rp = get_frame_register_unsigned (this_frame,
HPPA_RP_REGNUM);
- trad_frame_set_value (cache->saved_regs, HPPA_PCOQ_HEAD_REGNUM, rp);
+ cache->saved_regs[HPPA_PCOQ_HEAD_REGNUM].set_value (rp);
if (hppa_debug)
fprintf_unfiltered (gdb_stdlog, " (pc=rp) [frame] } ");
}
on the stack, but it's been overwritten. The prologue analyzer will
set fp_in_r1 when it sees the copy insn so we know to get the value
from r1 instead. */
- if (u->Save_SP && !trad_frame_addr_p (cache->saved_regs, HPPA_FP_REGNUM)
+ if (u->Save_SP && !cache->saved_regs[HPPA_FP_REGNUM].is_addr ()
&& fp_in_r1)
{
ULONGEST r1 = get_frame_register_unsigned (this_frame, 1);
- trad_frame_set_value (cache->saved_regs, HPPA_FP_REGNUM, r1);
+ cache->saved_regs[HPPA_FP_REGNUM].set_value (r1);
}
{
int reg;
for (reg = 0; reg < gdbarch_num_regs (gdbarch); reg++)
{
- if (trad_frame_addr_p (cache->saved_regs, reg))
+ if (cache->saved_regs[reg].is_addr ())
cache->saved_regs[reg].set_addr (cache->saved_regs[reg].addr ()
+ cache->base);
}
cache->base = get_frame_register_unsigned (this_frame, HPPA_SP_REGNUM);
cache->base -= frame_size;
- trad_frame_set_value (cache->saved_regs, HPPA_SP_REGNUM, cache->base);
+ cache->saved_regs[HPPA_SP_REGNUM].set_value (cache->base);
- if (trad_frame_addr_p (cache->saved_regs, HPPA_RP_REGNUM))
+ if (cache->saved_regs[HPPA_RP_REGNUM].is_addr ())
{
cache->saved_regs[HPPA_RP_REGNUM].set_addr (cache->saved_regs[HPPA_RP_REGNUM].addr ()
+ cache->base);
{
ULONGEST rp;
rp = get_frame_register_unsigned (this_frame, HPPA_RP_REGNUM);
- trad_frame_set_value (cache->saved_regs, HPPA_PCOQ_HEAD_REGNUM, rp);
+ cache->saved_regs[HPPA_PCOQ_HEAD_REGNUM].set_value (rp);
}
return cache;
/* Convert callee save offsets into addresses. */
for (i = 0; i < gdbarch_num_regs (get_frame_arch (this_frame)) - 1; i++)
{
- if (trad_frame_addr_p (info->saved_regs, i))
+ if (info->saved_regs[i].is_addr ())
info->saved_regs[i].set_addr (this_base + info->saved_regs[i].addr ());
}
/* The previous frame's SP needed to be computed. Save the computed
value. */
- trad_frame_set_value (info->saved_regs, SIM_LM32_SP_REGNUM, prev_sp);
+ info->saved_regs[SIM_LM32_SP_REGNUM].set_value (prev_sp);
return info;
}
/* Adjust all the saved registers so that they contain addresses and
not offsets. */
for (i = 0; i < gdbarch_num_regs (get_frame_arch (this_frame)) - 1; i++)
- if (trad_frame_addr_p (info->saved_regs, i))
+ if (info->saved_regs[i].is_addr ())
info->saved_regs[i].set_addr (info->prev_sp
+ info->saved_regs[i].addr ());
/* The previous frame's SP needed to be computed. Save the computed
value. */
- trad_frame_set_value (info->saved_regs, M32R_SP_REGNUM, prev_sp);
+ info->saved_regs[M32R_SP_REGNUM].set_value (prev_sp);
return info;
}
/* Adjust all the saved registers so that they contain addresses and not
offsets. */
for (i = 0; i < gdbarch_num_cooked_regs (gdbarch); i++)
- if (trad_frame_addr_p (info->saved_regs, i))
+ if (info->saved_regs[i].is_addr ())
{
info->saved_regs[i].set_addr (info->saved_regs[i].addr () + this_base);
}
/* The previous frame's SP needed to be computed. Save the computed
value. */
- trad_frame_set_value (info->saved_regs, HARD_SP_REGNUM, info->prev_sp);
+ info->saved_regs[HARD_SP_REGNUM].set_value (info->prev_sp);
return info;
}
int regnum, CORE_ADDR offset)
{
if (this_cache != NULL
- && this_cache->saved_regs[regnum].is_realreg ())
+ && this_cache->saved_regs[regnum].is_realreg ()
+ && this_cache->saved_regs[regnum].realreg () == regnum)
{
this_cache->saved_regs[regnum + 0
* gdbarch_num_regs (gdbarch)].set_addr (offset);
}
/* gdbarch_sp_regnum contains the value and not the address. */
- trad_frame_set_value (cache->saved_regs,
- gdbarch_num_regs (gdbarch) + MIPS_SP_REGNUM,
- cache->base);
+ cache->saved_regs[gdbarch_num_regs (gdbarch)
+ + MIPS_SP_REGNUM].set_value (cache->base);
return (struct mips_frame_cache *) (*this_cache);
}
}
/* gdbarch_sp_regnum contains the value and not the address. */
- trad_frame_set_value (cache->saved_regs,
- gdbarch_num_regs (gdbarch) + MIPS_SP_REGNUM,
- cache->base);
+ cache->saved_regs[gdbarch_num_regs (gdbarch)
+ + MIPS_SP_REGNUM].set_value (cache->base);
return (struct mips_frame_cache *) (*this_cache);
}
const int num_regs = gdbarch_num_regs (gdbarch);
int i;
+ /* Reset the register values to their default state. Register i's value
+ is in register i. */
for (i = 0; i < num_regs; i++)
- this_cache->saved_regs[i].set_addr (-1);
+ this_cache->saved_regs[i].set_realreg (i);
}
}
}
/* gdbarch_sp_regnum contains the value and not the address. */
- trad_frame_set_value (cache->saved_regs,
- gdbarch_num_regs (gdbarch) + MIPS_SP_REGNUM,
- cache->base);
+ cache->saved_regs[gdbarch_num_regs (gdbarch)
+ + MIPS_SP_REGNUM].set_value (cache->base);
return (struct mips_frame_cache *) (*this_cache);
}
gdbarch_register_name (gdbarch, i),
plongest ((LONGEST) offset));
}
- trad_frame_set_addr (cache->regs, i, offset);
+ cache->regs[i].set_addr (offset);
}
}
}
numregs = gdbarch_num_regs (gdbarch) + gdbarch_num_pseudo_regs (gdbarch);
for (regno = 0; regno < numregs; ++regno)
{
- if (trad_frame_addr_p (cache->regs, regno))
+ if (cache->regs[regno].is_addr ())
cache->regs[regno].set_addr (cache->regs[regno].addr ()
+ cache->frame_base);
}
The previous $ra value is gone, this would have been stored be the
previous frame if required. */
cache->regs[gdbarch_pc_regnum (gdbarch)] = cache->regs[RISCV_RA_REGNUM];
- trad_frame_set_unknown (cache->regs, RISCV_RA_REGNUM);
+ cache->regs[RISCV_RA_REGNUM].set_unknown ();
/* Build the frame id. */
cache->this_id = frame_id_build (cache->frame_base, start_addr);
/* The previous $sp value is the frame base value. */
- trad_frame_set_value (cache->regs, gdbarch_sp_regnum (gdbarch),
- cache->frame_base);
+ cache->regs[gdbarch_sp_regnum (gdbarch)].set_value (cache->frame_base);
return cache;
}
cache->base = (CORE_ADDR) backchain;
}
- trad_frame_set_value (cache->saved_regs,
- gdbarch_sp_regnum (gdbarch), cache->base);
+ cache->saved_regs[gdbarch_sp_regnum (gdbarch)].set_value (cache->base);
/* if != -1, fdata.saved_fpr is the smallest number of saved_fpr.
All fpr's from saved_fpr to fp31 are saved. */
cache->base = sp;
cache->initial_sp = sp;
- trad_frame_set_value (cache->saved_regs,
- gdbarch_pc_regnum (gdbarch), lr);
+ cache->saved_regs[gdbarch_pc_regnum (gdbarch)].set_value (lr);
}
catch (const gdb_exception_error &ex)
{
/* Set up ABI call-saved/call-clobbered registers. */
for (i = 0; i < S390_NUM_REGS; i++)
if (!s390_register_call_saved (gdbarch, i))
- trad_frame_set_unknown (info->saved_regs, i);
+ info->saved_regs[i].set_unknown ();
/* CC is always call-clobbered. */
- trad_frame_set_unknown (info->saved_regs, S390_PSWM_REGNUM);
+ info->saved_regs[S390_PSWM_REGNUM].set_unknown ();
/* Record the addresses of all register spill slots the prologue parser
has recognized. Consider only registers defined as call-saved by the
save area, use that -- we might only think the function frameless
because we're in the middle of the prologue ... */
if (size == 0
- && !trad_frame_addr_p (info->saved_regs, S390_PSWA_REGNUM))
+ && !info->saved_regs[S390_PSWA_REGNUM].is_addr ())
{
info->saved_regs[S390_PSWA_REGNUM].set_realreg (S390_RETADDR_REGNUM);
}
libc's thread_start routine. */
if (size > 0)
{
- if (!trad_frame_addr_p (info->saved_regs, S390_SP_REGNUM)
- || !trad_frame_addr_p (info->saved_regs, S390_PSWA_REGNUM))
+ if (!info->saved_regs[S390_SP_REGNUM].is_addr ()
+ || !info->saved_regs[S390_PSWA_REGNUM].is_addr ())
prev_sp = -1;
}
/* Set up ABI call-saved/call-clobbered registers. */
for (i = 0; i < S390_NUM_REGS; i++)
if (!s390_register_call_saved (gdbarch, i))
- trad_frame_set_unknown (info->saved_regs, i);
+ info->saved_regs[i].set_unknown ();
/* CC is always call-clobbered. */
- trad_frame_set_unknown (info->saved_regs, S390_PSWM_REGNUM);
+ info->saved_regs[S390_PSWM_REGNUM].set_unknown ();
/* Get the backchain. */
reg = get_frame_register_unsigned (this_frame, S390_SP_REGNUM);
/* Save RA. */
if (ra_offset_p == 1)
{
- if (this_cache->saved_regs[SCORE_PC_REGNUM].is_realreg ())
+ if (this_cache->saved_regs[SCORE_PC_REGNUM].is_realreg ()
+ && this_cache->saved_regs[SCORE_PC_REGNUM].realreg ()
+ == SCORE_PC_REGNUM)
this_cache->saved_regs[SCORE_PC_REGNUM].set_addr (sp + sp_offset
- ra_offset);
}
/* Save FP. */
if (fp_offset_p == 1)
{
- if (this_cache->saved_regs[SCORE_FP_REGNUM].is_realreg ())
+ if (this_cache->saved_regs[SCORE_FP_REGNUM].is_realreg ()
+ && this_cache->saved_regs[SCORE_FP_REGNUM].realreg ()
+ == SCORE_FP_REGNUM)
this_cache->saved_regs[SCORE_FP_REGNUM].set_addr (sp + sp_offset
- fp_offset);
}
/* Save RA. */
if (ra_offset_p == 1)
{
- if (this_cache->saved_regs[SCORE_PC_REGNUM].is_realreg ())
+ if (this_cache->saved_regs[SCORE_PC_REGNUM].is_realreg ()
+ && this_cache->saved_regs[SCORE_PC_REGNUM].realreg ()
+ == SCORE_PC_REGNUM)
this_cache->saved_regs[SCORE_PC_REGNUM].set_addr (sp + sp_offset
- ra_offset);
}
/* Save FP. */
if (fp_offset_p == 1)
{
- if (this_cache->saved_regs[SCORE_FP_REGNUM].is_realreg ())
+ if (this_cache->saved_regs[SCORE_FP_REGNUM].is_realreg ()
+ && this_cache->saved_regs[SCORE_FP_REGNUM].realreg ()
+ == SCORE_FP_REGNUM)
this_cache->saved_regs[SCORE_FP_REGNUM].set_addr (sp + sp_offset
- fp_offset);
}
}
/* Save SP. */
- trad_frame_set_value (cache->saved_regs, SCORE_SP_REGNUM, cache->base);
+ cache->saved_regs[SCORE_SP_REGNUM].set_value (cache->base);
return (struct score_frame_cache *) (*this_cache);
}
addr = saved_regs[SPARC_I7_REGNUM].addr ();
i7 = get_frame_memory_unsigned (this_frame, addr, 4);
- trad_frame_set_value (saved_regs, SPARC_I7_REGNUM, i7 ^ wcookie);
+ saved_regs[SPARC_I7_REGNUM].set_value (i7 ^ wcookie);
}
}
{
/* The register windows haven't been flushed. */
for (regnum = SPARC_L0_REGNUM; regnum <= SPARC_I7_REGNUM; regnum++)
- trad_frame_set_unknown (cache->saved_regs, regnum);
+ cache->saved_regs[regnum].set_unknown ();
}
else
{
addr = saved_regs[SPARC_I7_REGNUM].addr ();
i7 = get_frame_memory_unsigned (this_frame, addr, 8);
- trad_frame_set_value (saved_regs, SPARC_I7_REGNUM, i7 ^ wcookie);
+ saved_regs[SPARC_I7_REGNUM].set_value (i7 ^ wcookie);
}
}
{
/* The register windows haven't been flushed. */
for (regnum = SPARC_L0_REGNUM; regnum <= SPARC_I7_REGNUM; regnum++)
- trad_frame_set_unknown (cache->saved_regs, regnum);
+ cache->saved_regs[regnum].set_unknown ();
}
else
{
unsigned saved_register
= (unsigned) reverse_frame[operands[1]].value;
- /* realreg >= 0 and addr != -1 indicates that the
- value of saved_register is in memory location
- saved_address. The value of realreg is not
- meaningful in this case but it must be >= 0.
- See trad-frame.h. */
- cache->saved_regs[saved_register].set_realreg (saved_register);
cache->saved_regs[saved_register].set_addr (saved_address);
}
else if (cache
new_reverse_frame[i].state = REVERSE_STATE_VALUE;
new_reverse_frame[i].value
= cache->saved_regs[hopefully_sp].addr ();
- trad_frame_set_value (cache->saved_regs,
- hopefully_sp, prev_sp_value);
+ cache->saved_regs[hopefully_sp].set_value (prev_sp_value);
}
else
{
unsigned saved_register = (unsigned) reverse_frame[i].value;
cache->saved_regs[saved_register].set_realreg (i);
- cache->saved_regs[saved_register].set_addr ((LONGEST) -1);
}
}
}
if (lr_saved_on_stack_p)
{
- cache->saved_regs[TILEGX_LR_REGNUM].set_realreg (TILEGX_LR_REGNUM);
- cache->saved_regs[TILEGX_LR_REGNUM].set_addr (cache->saved_regs[TILEGX_SP_REGNUM].addr ());
+ CORE_ADDR addr = cache->saved_regs[TILEGX_SP_REGNUM].addr ();
+ cache->saved_regs[TILEGX_LR_REGNUM].set_addr (addr);
}
return prolog_end;
current_pc = get_frame_pc (this_frame);
cache->base = get_frame_register_unsigned (this_frame, TILEGX_SP_REGNUM);
- trad_frame_set_value (cache->saved_regs, TILEGX_SP_REGNUM, cache->base);
+ cache->saved_regs[TILEGX_SP_REGNUM].set_value (cache->base);
if (cache->start_pc)
tilegx_analyze_prologue (gdbarch, cache->start_pc, current_pc,
trad_frame_saved_reg *this_saved_regs
= FRAME_OBSTACK_CALLOC (numregs, trad_frame_saved_reg);
+ /* For backwards compatibility, initialize all the register values to
+ REALREG, with register 0 stored in 0, register 1 stored in 1 and so
+ on. */
trad_frame_reset_saved_regs (gdbarch, this_saved_regs);
+
return this_saved_regs;
}
return trad_frame_alloc_saved_regs (gdbarch);
}
-int
-trad_frame_value_p (trad_frame_saved_reg this_saved_regs[], int regnum)
-{
- return this_saved_regs[regnum].is_value ();
-}
-
-int
-trad_frame_addr_p (trad_frame_saved_reg this_saved_regs[], int regnum)
-{
- return this_saved_regs[regnum].is_addr ();
-}
-
-int
-trad_frame_realreg_p (trad_frame_saved_reg this_saved_regs[],
- int regnum)
-{
- return this_saved_regs[regnum].is_realreg ();
-}
-
-/* See trad-frame.h. */
-
-bool
-trad_frame_value_bytes_p (trad_frame_saved_reg this_saved_regs[],
- int regnum)
-{
- return this_saved_regs[regnum].is_value_bytes ();
-}
-
-void
-trad_frame_set_value (trad_frame_saved_reg this_saved_regs[],
- int regnum, LONGEST val)
-{
- this_saved_regs[regnum].set_value (val);
-}
-
-/* See trad-frame.h. */
-
-void
-trad_frame_set_realreg (trad_frame_saved_reg this_saved_regs[],
- int regnum, int realreg)
-{
- this_saved_regs[regnum].set_realreg (realreg);
-}
-
-/* See trad-frame.h. */
-
-void
-trad_frame_set_addr (trad_frame_saved_reg this_saved_regs[],
- int regnum, CORE_ADDR addr)
-{
- this_saved_regs[regnum].set_addr (addr);
-}
-
void
trad_frame_set_reg_value (struct trad_frame_cache *this_trad_cache,
int regnum, LONGEST val)
{
/* External interface for users of trad_frame_cache
(who cannot access the prev_regs object directly). */
- trad_frame_set_value (this_trad_cache->prev_regs, regnum, val);
+ this_trad_cache->prev_regs[regnum].set_value (val);
}
void
trad_frame_set_reg_realreg (struct trad_frame_cache *this_trad_cache,
int regnum, int realreg)
{
- trad_frame_set_realreg (this_trad_cache->prev_regs, regnum, realreg);
+ this_trad_cache->prev_regs[regnum].set_realreg (realreg);
}
void
trad_frame_set_reg_addr (struct trad_frame_cache *this_trad_cache,
int regnum, CORE_ADDR addr)
{
- trad_frame_set_addr (this_trad_cache->prev_regs, regnum, addr);
+ this_trad_cache->prev_regs[regnum].set_addr (addr);
}
void
}
}
-void
-trad_frame_set_unknown (trad_frame_saved_reg this_saved_regs[],
- int regnum)
-{
- this_saved_regs[regnum].set_unknown ();
-}
-
-/* See trad-frame.h. */
-
-void
-trad_frame_set_value_bytes (trad_frame_saved_reg this_saved_regs[],
- int regnum,
- gdb::array_view<const gdb_byte> bytes)
-{
- /* Allocate the space and copy the data bytes. */
- gdb_byte *data = FRAME_OBSTACK_CALLOC (bytes.size (), gdb_byte);
- memcpy (data, bytes.data (), bytes.size ());
- this_saved_regs[regnum].set_value_bytes (data);
-}
-
/* See trad-frame.h. */
void
{
/* External interface for users of trad_frame_cache
(who cannot access the prev_regs object directly). */
- trad_frame_set_value_bytes (this_trad_cache->prev_regs, regnum, bytes);
+ this_trad_cache->prev_regs[regnum].set_value_bytes (bytes);
}
trad_frame_saved_reg this_saved_regs[],
int regnum)
{
- if (trad_frame_addr_p (this_saved_regs, regnum))
+ if (this_saved_regs[regnum].is_addr ())
/* The register was saved in memory. */
return frame_unwind_got_memory (this_frame, regnum,
this_saved_regs[regnum].addr ());
- else if (trad_frame_realreg_p (this_saved_regs, regnum))
+ else if (this_saved_regs[regnum].is_realreg ())
return frame_unwind_got_register (this_frame, regnum,
this_saved_regs[regnum].realreg ());
- else if (trad_frame_value_p (this_saved_regs, regnum))
+ else if (this_saved_regs[regnum].is_value ())
/* The register's value is available. */
return frame_unwind_got_constant (this_frame, regnum,
this_saved_regs[regnum].value ());
- else if (trad_frame_value_bytes_p (this_saved_regs, regnum))
+ else if (this_saved_regs[regnum].is_value_bytes ())
/* The register's value is available as a sequence of bytes. */
return frame_unwind_got_bytes (this_frame, regnum,
this_saved_regs[regnum].value_bytes ());
/* Encode that the saved register's value is stored as a sequence of bytes.
This is useful when the value is larger than what primitive types
can hold. */
- void set_value_bytes (const gdb_byte *value_bytes)
+ void set_value_bytes (gdb::array_view<const gdb_byte> bytes)
{
+ /* Allocate the space and copy the data bytes. */
+ gdb_byte *data = FRAME_OBSTACK_CALLOC (bytes.size (), gdb_byte);
+ memcpy (data, bytes.data (), bytes.size ());
+
m_kind = trad_frame_saved_reg_kind::VALUE_BYTES;
- m_reg.value_bytes = value_bytes;
+ m_reg.value_bytes = data;
}
/* Getters */
} m_reg;
};
-/* Encode REGNUM value in the trad-frame. */
-void trad_frame_set_value (trad_frame_saved_reg this_saved_regs[],
- int regnum, LONGEST val);
-
-/* Encode REGNUM is in REALREG in the trad-frame. */
-void trad_frame_set_realreg (trad_frame_saved_reg this_saved_regs[],
- int regnum, int realreg);
-
-/* Encode REGNUM is at address ADDR in the trad-frame. */
-void trad_frame_set_addr (trad_frame_saved_reg this_trad_cache[],
- int regnum, CORE_ADDR addr);
-
-/* Mark REGNUM as unknown. */
-void trad_frame_set_unknown (trad_frame_saved_reg this_saved_regs[],
- int regnum);
-
-/* Encode REGNUM value in the trad-frame as a sequence of bytes. This is
- useful when the value is larger than what primitive types can hold. */
-void trad_frame_set_value_bytes (trad_frame_saved_reg this_saved_regs[],
- int regnum,
- gdb::array_view<const gdb_byte> bytes);
-
-/* Convenience functions, return non-zero if the register has been
- encoded as specified. */
-int trad_frame_value_p (trad_frame_saved_reg this_saved_regs[],
- int regnum);
-int trad_frame_addr_p (trad_frame_saved_reg this_saved_regs[],
- int regnum);
-int trad_frame_realreg_p (trad_frame_saved_reg this_saved_regs[],
- int regnum);
-
-/* Return TRUE if REGNUM is stored as a sequence of bytes, and FALSE
- otherwise. */
-bool trad_frame_value_bytes_p (trad_frame_saved_reg this_saved_regs[],
- int regnum);
-
-/* Reset the saved regs cache, setting register values to -1. */
+/* Reset the saved regs cache, setting register values to REALREG. */
void trad_frame_reset_saved_regs (struct gdbarch *gdbarch,
trad_frame_saved_reg *regs);
/* Now that we have the base address for the stack frame we can
calculate the value of sp in the calling frame. */
- trad_frame_set_value (cache->saved_regs, E_SP_REGNUM,
- cache->base - cache->sp_offset);
+ cache->saved_regs[E_SP_REGNUM].set_value (cache->base - cache->sp_offset);
/* Adjust all the saved registers such that they contain addresses
instead of offsets. */
for (i = 0; i < gdbarch_num_regs (gdbarch); i++)
- if (trad_frame_addr_p (cache->saved_regs, i))
+ if (cache->saved_regs[i].is_addr ())
cache->saved_regs[i].set_addr (cache->saved_regs[i].addr ()
+ cache->base);
}
/* Bits 1:0 of the stack pointer were saved in the control bits. */
- trad_frame_set_value (cache->saved_regs, VAX_SP_REGNUM, addr + (mask >> 14));
+ cache->saved_regs[VAX_SP_REGNUM].set_value (addr + (mask >> 14));
return cache;
}