summaryrefslogtreecommitdiff
path: root/gdb/sparc64nbsd-tdep.c
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/sparc64nbsd-tdep.c')
-rw-r--r--gdb/sparc64nbsd-tdep.c94
1 files changed, 52 insertions, 42 deletions
diff --git a/gdb/sparc64nbsd-tdep.c b/gdb/sparc64nbsd-tdep.c
index 58b87b3d597..8e7987008e7 100644
--- a/gdb/sparc64nbsd-tdep.c
+++ b/gdb/sparc64nbsd-tdep.c
@@ -88,76 +88,86 @@ sparc64nbsd_pc_in_sigtramp (CORE_ADDR pc, char *name)
return nbsd_pc_in_sigtramp (pc, name);
}
-static struct sparc_frame_cache *
-sparc64nbsd_sigcontext_frame_cache (struct frame_info *next_frame,
- void **this_cache)
+struct trad_frame_saved_reg *
+sparc64nbsd_sigcontext_saved_regs (CORE_ADDR sigcontext_addr,
+ struct frame_info *next_frame)
{
- struct sparc_frame_cache *cache;
- CORE_ADDR addr, sigcontext_addr, sp;
- LONGEST fprs;
+ struct trad_frame_saved_reg *saved_regs;
+ CORE_ADDR addr, sp;
int regnum, delta;
- if (*this_cache)
- return *this_cache;
-
- cache = sparc_frame_cache (next_frame, this_cache);
- gdb_assert (cache == *this_cache);
+ saved_regs = trad_frame_alloc_saved_regs (next_frame);
/* The registers are saved in bits and pieces scattered all over the
place. The code below records their location on the assumption
that the part of the signal trampoline that saves the state has
been executed. */
- /* If we couldn't find the frame's function, we're probably dealing
- with an on-stack signal trampoline. */
- if (cache->pc == 0)
- {
- cache->pc = sparc64nbsd_sigtramp_start;
-
- /* Since we couldn't find the frame's function, the cache was
- initialized under the assumption that we're frameless. */
- cache->frameless_p = 0;
- addr = frame_unwind_register_unsigned (next_frame, SPARC_FP_REGNUM);
- cache->base = addr;
- }
-
- cache->saved_regs = trad_frame_alloc_saved_regs (next_frame);
-
- /* We find the appropriate instance of `struct sigcontext' at a
- fixed offset in the signal frame. */
- sigcontext_addr = cache->base + BIAS + 128 + 8;
-
- cache->saved_regs[SPARC_SP_REGNUM].addr = sigcontext_addr + 8;
- cache->saved_regs[SPARC64_PC_REGNUM].addr = sigcontext_addr + 16;
- cache->saved_regs[SPARC64_NPC_REGNUM].addr = sigcontext_addr + 24;
- cache->saved_regs[SPARC64_STATE_REGNUM].addr = sigcontext_addr + 32;
- cache->saved_regs[SPARC_G1_REGNUM].addr = sigcontext_addr + 40;
- cache->saved_regs[SPARC_O0_REGNUM].addr = sigcontext_addr + 48;
+ saved_regs[SPARC_SP_REGNUM].addr = sigcontext_addr + 8;
+ saved_regs[SPARC64_PC_REGNUM].addr = sigcontext_addr + 16;
+ saved_regs[SPARC64_NPC_REGNUM].addr = sigcontext_addr + 24;
+ saved_regs[SPARC64_STATE_REGNUM].addr = sigcontext_addr + 32;
+ saved_regs[SPARC_G1_REGNUM].addr = sigcontext_addr + 40;
+ saved_regs[SPARC_O0_REGNUM].addr = sigcontext_addr + 48;
/* The remaining `global' registers and %y are saved in the `local'
registers. */
delta = SPARC_L0_REGNUM - SPARC_G0_REGNUM;
for (regnum = SPARC_G2_REGNUM; regnum <= SPARC_G7_REGNUM; regnum++)
- cache->saved_regs[regnum].realreg = regnum + delta;
- cache->saved_regs[SPARC64_Y_REGNUM].realreg = SPARC_L1_REGNUM;
+ saved_regs[regnum].realreg = regnum + delta;
+ saved_regs[SPARC64_Y_REGNUM].realreg = SPARC_L1_REGNUM;
/* The remaining `out' registers can be found in the current frame's
`in' registers. */
delta = SPARC_I0_REGNUM - SPARC_O0_REGNUM;
for (regnum = SPARC_O1_REGNUM; regnum <= SPARC_O5_REGNUM; regnum++)
- cache->saved_regs[regnum].realreg = regnum + delta;
- cache->saved_regs[SPARC_O7_REGNUM].realreg = SPARC_I7_REGNUM;
+ saved_regs[regnum].realreg = regnum + delta;
+ saved_regs[SPARC_O7_REGNUM].realreg = SPARC_I7_REGNUM;
/* The `local' and `in' registers have been saved in the register
save area. */
- addr = cache->saved_regs[SPARC_SP_REGNUM].addr;
+ addr = saved_regs[SPARC_SP_REGNUM].addr;
sp = get_frame_memory_unsigned (next_frame, addr, 8);
for (regnum = SPARC_L0_REGNUM, addr = sp + BIAS;
regnum <= SPARC_I7_REGNUM; regnum++, addr += 8)
- cache->saved_regs[regnum].addr = addr;
+ saved_regs[regnum].addr = addr;
/* TODO: Handle the floating-point registers. */
+ return saved_regs;
+}
+
+static struct sparc_frame_cache *
+sparc64nbsd_sigcontext_frame_cache (struct frame_info *next_frame,
+ void **this_cache)
+{
+ struct sparc_frame_cache *cache;
+ CORE_ADDR addr;
+
+ if (*this_cache)
+ return *this_cache;
+
+ cache = sparc_frame_cache (next_frame, this_cache);
+ gdb_assert (cache == *this_cache);
+
+ /* If we couldn't find the frame's function, we're probably dealing
+ with an on-stack signal trampoline. */
+ if (cache->pc == 0)
+ {
+ cache->pc = sparc64nbsd_sigtramp_start;
+
+ /* Since we couldn't find the frame's function, the cache was
+ initialized under the assumption that we're frameless. */
+ cache->frameless_p = 0;
+ addr = frame_unwind_register_unsigned (next_frame, SPARC_FP_REGNUM);
+ cache->base = addr;
+ }
+
+ /* We find the appropriate instance of `struct sigcontext' at a
+ fixed offset in the signal frame. */
+ addr = cache->base + BIAS + 128 + 8;
+ cache->saved_regs = sparc64nbsd_sigcontext_saved_regs (addr, next_frame);
+
return cache;
}