Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Yao Qi <qiyaoltc@gmail.com>
To: Sandra Loosemore <sandra@codesourcery.com>
Cc: <gdb-patches@sourceware.org>
Subject: Re: [patch 3/3, nios2] fixes for new implementation of signal handler trampolines
Date: Tue, 28 Apr 2015 12:11:00 -0000	[thread overview]
Message-ID: <86618gwjoq.fsf@gmail.com> (raw)
In-Reply-To: <5539412B.2020101@codesourcery.com> (Sandra Loosemore's message	of "Thu, 23 Apr 2015 12:59:55 -0600")

Sandra Loosemore <sandra@codesourcery.com> writes:

> Earlier versions of the nios2 kernel used to allocate code for signal
> handler trampolines on the stack, but when the port was accepted
> upstream it was changed to instead put the trampoline at a fixed
> address in low memory (0x1044).
>
> Moving the code off the stack changed the layout of the stack frame,
> so the first part of this fix involves updating the offset to the
> register save area.  This is not an exported interface from the
> kernel; I noticed e.g. the existing aarch64 gdb support includes a
> huge block of comments explaining the kernel's signal handler stack
> frame layout but ultimately also relies on using magic numbers to
> access the register save area.  I used a somewhat smaller block of
> comments for nios2 but I think now it is clear where the magic numbers
> come from and what kernel code this corresponds to.

We can make this magic number less magic by documenting how it is
calculated.  We did something similar in
tic6x-linux-tdep.c:tic6x_linux_rt_sigreturn_init,

  /* The base of struct sigcontext is computed by examining the definition of
     struct rt_sigframe in linux kernel source arch/c6x/kernel/signal.c.  */
  CORE_ADDR base = (sp + TIC6X_SP_RT_SIGFRAME
		    /* Pointer type *pinfo and *puc in struct rt_sigframe.  */
		    + 4 + 4
		    + TIC6X_SIGINFO_SIZE
		    + 4 + 4 /* uc_flags and *uc_link in struct ucontext.  */
		    + TIC6X_STACK_T_SIZE);

>
> The second problem is that the trampoline is not writable by user
> processes so GDB cannot set software breakpoints there.  I've tried to
> deal with that in the single-step hook by having it effectively step
> over the trampoline by setting the breakpoint on its return address,
> but for operations like "finish" or "advance" that use the stack
> unwinder to get the location to set the breakpoint, it seems like
> there is nothing to do but kfail the tests.

Could you address this in a separated patch?

-- 
Yao (齐尧)


  parent reply	other threads:[~2015-04-28 11:56 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-23 18:49 [patch 0/3, nios2] unbreak nios2-linux-gnu GDB Sandra Loosemore
2015-04-23 18:53 ` [patch 1/3, nios2] revert to using "trap 31" for breakpoints Sandra Loosemore
2015-04-28 11:18   ` Yao Qi
2015-04-23 18:55 ` [patch 2/3, nios2] use PTRACE_GETREGSET/SETREGSET in gdbserver Sandra Loosemore
2015-04-28 11:29   ` Yao Qi
2015-04-28 11:31     ` Pedro Alves
2015-04-28 15:27       ` Sandra Loosemore
2015-04-23 19:01 ` [patch 3/3, nios2] fixes for new implementation of signal handler trampolines Sandra Loosemore
2015-04-23 19:11   ` Sandra Loosemore
2015-04-28 12:11   ` Yao Qi [this message]
2015-04-28 15:47     ` Sandra Loosemore
2015-04-28 11:15 ` [patch 0/3, nios2] unbreak nios2-linux-gnu GDB Yao Qi
2015-04-28 15:14   ` Sandra Loosemore

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=86618gwjoq.fsf@gmail.com \
    --to=qiyaoltc@gmail.com \
    --cc=gdb-patches@sourceware.org \
    --cc=sandra@codesourcery.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox