This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [RFA 1/2] mips: Switch inferior function calls to ON_STACK method.
- From: "Maciej W. Rozycki" <macro at codesourcery dot com>
- To: Joel Brobecker <brobecker at adacore dot com>
- Cc: Mark Kettenis <mark dot kettenis at xs4all dot nl>, <gdb-patches at sourceware dot org>
- Date: Mon, 11 Jun 2012 11:14:09 +0100
- Subject: Re: [RFA 1/2] mips: Switch inferior function calls to ON_STACK method.
- References: <201205042118.q44LIh3p018153@glazunov.sibelius.xs4all.nl> <alpine.DEB.1.10.1205050013460.18334@tp.orcam.me.uk> <201205051144.q45Bitv4006357@glazunov.sibelius.xs4all.nl> <alpine.DEB.1.10.1205081550050.18334@tp.orcam.me.uk> <20120508160542.GB15555@adacore.com> <alpine.DEB.1.10.1205081912220.18334@tp.orcam.me.uk> <20120508204257.GC15555@adacore.com> <20120508220805.GD15555@adacore.com> <alpine.DEB.1.10.1205082335590.18334@tp.orcam.me.uk> <201205090823.q498Njc7019605@glazunov.sibelius.xs4all.nl> <20120509143537.GH15555@adacore.com> <alpine.DEB.1.10.1205141013580.11227@tp.orcam.me.uk>
On Mon, 14 May 2012, Maciej W. Rozycki wrote:
> I've lost track, sorry, however here is the promised update I will
> include with the microMIPS change. I used a local variable to hold the
> address of the breakpoint slot after all lest the result be horrible. No
> regressions on mips-sde-elf or mips-linux-gnu, checked the usual set of
> standard MIPS, MIPS16 and microMIPS multilibs.
Hmm, I intended to fold this update into the original microMIPS change
before committing, but somehow I did not. I have checked it now instead.
2012-06-11 Maciej W. Rozycki <macro@codesourcery.com>
gdb/
* mips-tdep.c (mips_push_dummy_code): Handle microMIPS code.
Maciej
gdb-micromips-on-stack.diff
Index: gdb-fsf-trunk-quilt/gdb/mips-tdep.c
===================================================================
--- gdb-fsf-trunk-quilt.orig/gdb/mips-tdep.c 2012-05-12 21:21:38.000000000 +0100
+++ gdb-fsf-trunk-quilt/gdb/mips-tdep.c 2012-05-12 22:45:37.355619042 +0100
@@ -4198,11 +4198,18 @@ mips_push_dummy_code (struct gdbarch *gd
CORE_ADDR *real_pc, CORE_ADDR *bp_addr,
struct regcache *regcache)
{
- CORE_ADDR nop_addr;
static gdb_byte nop_insn[] = { 0, 0, 0, 0 };
+ CORE_ADDR nop_addr;
+ CORE_ADDR bp_slot;
/* Reserve enough room on the stack for our breakpoint instruction. */
- *bp_addr = sp - sizeof (nop_insn);
+ bp_slot = sp - sizeof (nop_insn);
+
+ /* Return to microMIPS mode if calling microMIPS code to avoid
+ triggering an address error exception on processors that only
+ support microMIPS execution. */
+ *bp_addr = (mips_pc_is_micromips (gdbarch, funaddr)
+ ? make_compact_addr (bp_slot) : bp_slot);
/* The breakpoint layer automatically adjusts the address of
breakpoints inserted in a branch delay slot. With enough
@@ -4211,7 +4218,7 @@ mips_push_dummy_code (struct gdbarch *gd
trigger the adjustement, and break the function call entirely.
So, we reserve those 4 bytes and write a nop instruction
to prevent that from happening. */
- nop_addr = *bp_addr - sizeof (nop_insn);
+ nop_addr = bp_slot - sizeof (nop_insn);
write_memory (nop_addr, nop_insn, sizeof (nop_insn));
sp = mips_frame_align (gdbarch, nop_addr);