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.
> Date: Thu, 3 May 2012 22:08:58 +0100
> From: "Maciej W. Rozycki" <macro@codesourcery.com>
>
> Joel,
>
> > This patch switches the mips code to use the ON_STACK method
> > for function calls instead of AT_SYMBOL, which we want to remove.
>
> Thanks for this work -- can you give me a reference to some background
> information as to why exactly we want to remove the AT_SYMBOL method?
The AT_SYMBOL method relies on a magic symbol being present in the
binarie that's being debugged. There is no guarantee that that magic
symbol is actually present in your binary.
> > Another little detail on the implementation of mips_push_dummy_code.
> > It starts by aligning the stack. AFAIK, the stack is supposed to
> > always be aligned to at least 4 bytes (4 bytes for mips32, 8 bytes
> > for mips64). So, the initial alignment shouldn't be necessary, since
> > that's good enough aligment for our breakpoint instruction. But
> > in the end, I chose to keep it, JIC. We could possibly change the
> > code to align to 4 instead of 16 like mips_frame_align does, if
> > we want to.
>
> For the record: the respective ABIs mandate that the stack is aligned to
> 8 bytes for 32-bit targets and to 16 bytes for 64-bit targets. However
> the user may have fiddled with SP, so I think it's better to stay safe
> and therefore I agree it's better if we prealign the stack and avoid
> crashing the debuggee in this context.
Like I wrote elsewhere, the generic code that calls push_dummy_code()
already alignes the stack, so it isn't necessary to do it again here.
> > /* MIPS version of CALL_DUMMY. */
> >
> > - /* NOTE: cagney/2003-08-05: Eventually call dummy location will be
> > - replaced by a command, and all targets will default to on stack
> > - (regardless of the stack's execute status). */
> > - set_gdbarch_call_dummy_location (gdbarch, AT_SYMBOL);
> > + set_gdbarch_call_dummy_location (gdbarch, ON_STACK);
> > + set_gdbarch_push_dummy_code (gdbarch, mips_push_dummy_code);
> > set_gdbarch_frame_align (gdbarch, mips_frame_align);
> >
> > set_gdbarch_convert_register_p (gdbarch, mips_convert_register_p);
>
> So what if the stack pages are indeed not executable (their page entries
> have the XI aka Execute Inhibit bit set)?
The resulting SIGSEGV will be recognized by GDB and handled
appropriately; see infrun.c:handle_inferior_event().