* [PATCH] ptrace_signal subroutine
@ 2008-04-18 1:44 Roland McGrath
2008-04-18 2:00 ` Kyle McMartin
0 siblings, 1 reply; 2+ messages in thread
From: Roland McGrath @ 2008-04-18 1:44 UTC (permalink / raw)
To: Andrew Morton, Linus Torvalds; +Cc: linux-kernel
This breaks out the ptrace handling from get_signal_to_deliver
into a new subroutine. The actual code there doesn't change, and
it gets inlined into nearly identical compiled code. This makes
the function substantially shorter and thus easier to read, and
it nicely isolates the ptrace magic.
Signed-off-by: Roland McGrath <roland@redhat.com>
---
kernel/signal.c | 71 ++++++++++++++++++++++++++++++++----------------------
1 files changed, 42 insertions(+), 29 deletions(-)
diff --git a/kernel/signal.c b/kernel/signal.c
index 977b3cd..144590c 100644
--- a/kernel/signal.c
+++ b/kernel/signal.c
@@ -1757,6 +1757,45 @@ static int do_signal_stop(int signr)
return 1;
}
+static int ptrace_signal(int signr, siginfo_t *info,
+ struct pt_regs *regs, void *cookie)
+{
+ if (!(current->ptrace & PT_PTRACED))
+ return signr;
+
+ ptrace_signal_deliver(regs, cookie);
+
+ /* Let the debugger run. */
+ ptrace_stop(signr, 0, info);
+
+ /* We're back. Did the debugger cancel the sig? */
+ signr = current->exit_code;
+ if (signr == 0)
+ return signr;
+
+ current->exit_code = 0;
+
+ /* Update the siginfo structure if the signal has
+ changed. If the debugger wanted something
+ specific in the siginfo structure then it should
+ have updated *info via PTRACE_SETSIGINFO. */
+ if (signr != info->si_signo) {
+ info->si_signo = signr;
+ info->si_errno = 0;
+ info->si_code = SI_USER;
+ info->si_pid = task_pid_vnr(current->parent);
+ info->si_uid = current->parent->uid;
+ }
+
+ /* If the (new) signal is now blocked, requeue it. */
+ if (sigismember(¤t->blocked, signr)) {
+ specific_send_sig_info(signr, info, current);
+ signr = 0;
+ }
+
+ return signr;
+}
+
int get_signal_to_deliver(siginfo_t *info, struct k_sigaction *return_ka,
struct pt_regs *regs, void *cookie)
{
@@ -1785,36 +1824,10 @@ relock:
if (!signr)
break; /* will return 0 */
- if ((current->ptrace & PT_PTRACED) && signr != SIGKILL) {
- ptrace_signal_deliver(regs, cookie);
-
- /* Let the debugger run. */
- ptrace_stop(signr, 0, info);
-
- /* We're back. Did the debugger cancel the sig? */
- signr = current->exit_code;
- if (signr == 0)
- continue;
-
- current->exit_code = 0;
-
- /* Update the siginfo structure if the signal has
- changed. If the debugger wanted something
- specific in the siginfo structure then it should
- have updated *info via PTRACE_SETSIGINFO. */
- if (signr != info->si_signo) {
- info->si_signo = signr;
- info->si_errno = 0;
- info->si_code = SI_USER;
- info->si_pid = task_pid_vnr(current->parent);
- info->si_uid = current->parent->uid;
- }
-
- /* If the (new) signal is now blocked, requeue it. */
- if (sigismember(¤t->blocked, signr)) {
- specific_send_sig_info(signr, info, current);
+ if (signr != SIGKILL) {
+ signr = ptrace_signal(signr, info, regs, cookie);
+ if (!signr)
continue;
- }
}
ka = ¤t->sighand->action[signr-1];
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] ptrace_signal subroutine
2008-04-18 1:44 [PATCH] ptrace_signal subroutine Roland McGrath
@ 2008-04-18 2:00 ` Kyle McMartin
0 siblings, 0 replies; 2+ messages in thread
From: Kyle McMartin @ 2008-04-18 2:00 UTC (permalink / raw)
To: Roland McGrath; +Cc: Andrew Morton, Linus Torvalds, linux-kernel
On Thu, Apr 17, 2008 at 06:44:38PM -0700, Roland McGrath wrote:
> This breaks out the ptrace handling from get_signal_to_deliver
> into a new subroutine. The actual code there doesn't change, and
> it gets inlined into nearly identical compiled code. This makes
> the function substantially shorter and thus easier to read, and
> it nicely isolates the ptrace magic.
>
> Signed-off-by: Roland McGrath <roland@redhat.com>
Nice clean up.
cheers, Kyle
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2008-04-18 2:00 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-04-18 1:44 [PATCH] ptrace_signal subroutine Roland McGrath
2008-04-18 2:00 ` Kyle McMartin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome