diff options
author | Christophe Lyon <christophe.lyon@arm.com> | 2022-04-01 10:22:12 +0100 |
---|---|---|
committer | Christophe Lyon <christophe.lyon@arm.com> | 2022-04-27 15:18:18 +0100 |
commit | 0824193fd31467b6ff39132d0d72aaa9c01cc9aa (patch) | |
tree | bceb91118543082cb157b8d265499be8c43a8119 /gdb/arm-tdep.c | |
parent | 9074667a8583b33ff1b9590232c15e67f2d1d607 (diff) | |
download | gdb-0824193fd31467b6ff39132d0d72aaa9c01cc9aa.zip gdb-0824193fd31467b6ff39132d0d72aaa9c01cc9aa.tar.gz gdb-0824193fd31467b6ff39132d0d72aaa9c01cc9aa.tar.bz2 |
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>
Diffstat (limited to 'gdb/arm-tdep.c')
-rw-r--r-- | gdb/arm-tdep.c | 33 |
1 files changed, 27 insertions, 6 deletions
diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c index 6b4b009..f393a3e 100644 --- a/gdb/arm-tdep.c +++ b/gdb/arm-tdep.c @@ -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); } |