gdb/arm: Introduce arm_cache_init

This patch is a preparation for the rest of the series and adds two
arm_cache_init helper functions. It updates every place that updates
cache->saved_regs to call the helper instead.

Signed-off-by: Torbjörn Svensson <torbjorn.svensson@st.com>
Signed-off-by: Christophe Lyon <christophe.lyon@foss.st.com>
Signed-off-by: Christophe Lyon <christophe.lyon@arm.com>
This commit is contained in:
Christophe Lyon
2022-04-01 10:22:12 +01:00
parent 9074667a85
commit 0824193fd3

View File

@ -292,8 +292,29 @@ struct arm_prologue_cache
/* Saved register offsets. */
trad_frame_saved_reg *saved_regs;
arm_prologue_cache() = default;
};
/* Initialize CACHE fields for which zero is not adequate (CACHE is
expected to have been ZALLOC'ed before calling this function). */
static void
arm_cache_init (struct arm_prologue_cache *cache, struct gdbarch *gdbarch)
{
cache->saved_regs = trad_frame_alloc_saved_regs (gdbarch);
}
/* Similar to the previous function, but extracts GDBARCH from FRAME. */
static void
arm_cache_init (struct arm_prologue_cache *cache, struct frame_info *frame)
{
struct gdbarch *gdbarch = get_frame_arch (frame);
arm_cache_init (cache, gdbarch);
}
namespace {
/* Abstract class to read ARM instructions from memory. */
@ -1981,7 +2002,7 @@ arm_make_prologue_cache (struct frame_info *this_frame)
CORE_ADDR unwound_fp;
cache = FRAME_OBSTACK_ZALLOC (struct arm_prologue_cache);
cache->saved_regs = trad_frame_alloc_saved_regs (this_frame);
arm_cache_init (cache, this_frame);
arm_scan_prologue (this_frame, cache);
@ -2454,7 +2475,7 @@ arm_exidx_fill_cache (struct frame_info *this_frame, gdb_byte *entry)
struct arm_prologue_cache *cache;
cache = FRAME_OBSTACK_ZALLOC (struct arm_prologue_cache);
cache->saved_regs = trad_frame_alloc_saved_regs (this_frame);
arm_cache_init (cache, this_frame);
for (;;)
{
@ -2848,7 +2869,7 @@ arm_make_epilogue_frame_cache (struct frame_info *this_frame)
int reg;
cache = FRAME_OBSTACK_ZALLOC (struct arm_prologue_cache);
cache->saved_regs = trad_frame_alloc_saved_regs (this_frame);
arm_cache_init (cache, this_frame);
/* Still rely on the offset calculated from prologue. */
arm_scan_prologue (this_frame, cache);
@ -3009,7 +3030,7 @@ arm_make_stub_cache (struct frame_info *this_frame)
struct arm_prologue_cache *cache;
cache = FRAME_OBSTACK_ZALLOC (struct arm_prologue_cache);
cache->saved_regs = trad_frame_alloc_saved_regs (this_frame);
arm_cache_init (cache, this_frame);
cache->prev_sp = get_frame_register_unsigned (this_frame, ARM_SP_REGNUM);
@ -3087,7 +3108,7 @@ arm_m_exception_cache (struct frame_info *this_frame)
uint32_t secure_stack_used;
cache = FRAME_OBSTACK_ZALLOC (struct arm_prologue_cache);
cache->saved_regs = trad_frame_alloc_saved_regs (this_frame);
arm_cache_init (cache, this_frame);
/* ARMv7-M Architecture Reference "B1.5.6 Exception entry behavior"
describes which bits in LR that define which stack was used prior
@ -13851,7 +13872,7 @@ arm_analyze_prologue_test ()
test_arm_instruction_reader mem_reader (insns);
arm_prologue_cache cache;
cache.saved_regs = trad_frame_alloc_saved_regs (gdbarch);
arm_cache_init (&cache, gdbarch);
arm_analyze_prologue (gdbarch, 0, sizeof (insns) - 1, &cache, mem_reader);
}