aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gdb/arm-tdep.c33
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);
}