From: Joel Brobecker Date: Tue, 23 Nov 2010 01:06:08 +0000 (+0000) Subject: support for mips-irix on-stack trampolines X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=1324a0d9b562a38f4ce23c8835e1dacbbe3b51b9;p=binutils-gdb.git support for mips-irix on-stack trampolines On mips-irix, the debugger has trouble stepping over the following line of code: S: Shape'Class := R; <<<<---- STOP here Here is what happens: (gdb) n warning: GDB can't find the start of the function at 0x7fff2bd8. GDB is unable to find the start of the function at 0x7fff2bd8 and thus can't determine the size of that function's stack frame. This means that GDB may be unable to access that stack frame, or the frames below it. This problem is most likely caused by an invalid program counter or stack pointer. However, if you think GDB should simply search farther back from 0x7fff2bd8 for code which looks like the beginning of a function, you can increase the range of the search using the `set heuristic-fence-post' command. 0x7fff2bd8 in ?? () The program does in fact jump to this code location, which is a trampoline located on the stack (there is an implicit call to a routine internally generated by the Ada expander). As it is on the stack, GDB is naturally unable to find the bounds of the current function, or any debugging information, and is thus unable to continue. This patch adds support for this sort of trampoline. gdb/ChangeLog: * mips-irix-tdep.c (mips_irix_n32_stack_tramp_frame_init): New function. (mips_irix_n32_stack_tramp_frame): New static global. (mips_irix_init_abi): Add mips_irix_n32_stack_tramp_frame to list of unwinder. --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 1462d74e003..559d07c7939 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,11 @@ +2010-11-22 Joel Brobecker + + * mips-irix-tdep.c (mips_irix_n32_stack_tramp_frame_init): New + function. + (mips_irix_n32_stack_tramp_frame): New static global. + (mips_irix_init_abi): Add mips_irix_n32_stack_tramp_frame to + list of unwinder. + 2010-11-22 Jerome Guitton * ada-tasks.c (get_tcb_types_info): Use C lookups to get diff --git a/gdb/mips-irix-tdep.c b/gdb/mips-irix-tdep.c index 19659645d4f..1bb6ea016c4 100644 --- a/gdb/mips-irix-tdep.c +++ b/gdb/mips-irix-tdep.c @@ -227,11 +227,51 @@ static const struct tramp_frame mips_irix_n32_tramp_frame = mips_irix_n32_tramp_frame_init }; +/* Implement the "init" routine in struct tramp_frame for the stack-based + trampolines used on mips-irix. */ + +static void +mips_irix_n32_stack_tramp_frame_init (const struct tramp_frame *self, + struct frame_info *this_frame, + struct trad_frame_cache *this_cache, + CORE_ADDR func) +{ + struct gdbarch *gdbarch = get_frame_arch (this_frame); + const int num_regs = gdbarch_num_regs (gdbarch); + int sp_cooked_regno = num_regs + MIPS_SP_REGNUM; + const CORE_ADDR sp = get_frame_register_signed (this_frame, sp_cooked_regno); + + /* The previous frame's PC is stored in RA. */ + trad_frame_set_reg_realreg (this_cache, gdbarch_pc_regnum (gdbarch), + num_regs + MIPS_RA_REGNUM); + + trad_frame_set_id (this_cache, frame_id_build (sp, func)); +} + +/* A tramp_frame structure describing the stack-based trampoline + used on mips-irix. These trampolines are created on the stack + before being called. */ + +static const struct tramp_frame mips_irix_n32_stack_tramp_frame = +{ + SIGTRAMP_FRAME, + 4, + { + { 0x8f210000, 0xffff0000 }, /* lw at, N(t9) */ + { 0x8f2f0000, 0xffff0000 }, /* lw t3, M(t9) */ + { 0x00200008, 0xffffffff }, /* jr at */ + { 0x0020c82d, 0xffffffff }, /* move t9, at */ + { TRAMP_SENTINEL_INSN, -1 } + }, + mips_irix_n32_stack_tramp_frame_init +}; + static void mips_irix_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) { set_solib_ops (gdbarch, &irix_so_ops); + tramp_frame_prepend_unwinder (gdbarch, &mips_irix_n32_stack_tramp_frame); tramp_frame_prepend_unwinder (gdbarch, &mips_irix_n32_tramp_frame); }