From: Denys Vlasenko <vda.linux@googlemail.com>
To: Tejun Heo <tj@kernel.org>
Cc: Oleg Nesterov <oleg@redhat.com>,
Roland McGrath <roland@redhat.com>,
jan.kratochvil@redhat.com, linux-kernel@vger.kernel.org,
torvalds@linux-foundation.org, akpm@linux-foundation.org
Subject: Re: [RFC] Proposal for ptrace improvements
Date: Wed, 2 Mar 2011 00:16:23 +0100 [thread overview]
Message-ID: <AANLkTi=cUM9S5M7h0unMfbQ88CzqhoDN9CUEVf_9HrdS@mail.gmail.com> (raw)
In-Reply-To: <20110301152457.GE26074@htj.dyndns.org>
On Tue, Mar 1, 2011 at 4:24 PM, Tejun Heo <tj@kernel.org> wrote:
> PROPOSAL
> --------
> ...
> P5. "^Z" and "fg" for tracees
>
> A ptracer, as it currently stands and proposed here, has full control
> over the execution state of its tracee. The tracer is notified
> whenever the tracee stops and can always resume its execution;
> however, there is one missing piece.
>
> As proposed, when a tracee enters jctl stop, it enters TASK_TRACED
> from which emission of SIGCONT can't resume the tracee. This makes it
> impossible for a tracer to become transparent with respect to jctl.
> For example, after strace(1) is attached to a task, the task can be
> ^Z'd but then can't be fg'd.
>
> One approach to this problem is somehow making it work implicitly from
> the kernel - as in putting the tracee into TASK_STOPPED or somehow
> handling TASK_TRACED for jctl stop differently; however, I think such
> approach is cumbersome in both concept and implementation. Instead of
> being able to say "while ptraced, a tracee's execution is fully under
> the control of its tracer", subtle and fragile exceptions need to be
> introduced.
>
> A better way to solve this is simply giving the tracer the capability
> to listen for the end of jctl stop. That way, the problem is solved
> in a manner which is consistent, may not be to everyone's liking but
> nonetheless consistent, with the rest of ptrace. Execution state of
> the tracee is always under the control of the tracer. The only thing
> which changes is that the tracer now can find out when jctl stop ends,
> which also could be an additional useful debugging feature.
>
> It would be most fitting to use wait(2) for delivery of this
> notification. WCONTINUED is the obvious candidate but I think it is
> better to use STOPPED notification because the task is not really
> resumed. Only its mode of stop changes. What state the tracee is in
> can be determined by retriving siginfo using PTRACE_GETSIGINFO.
>
> This also effectively makes the notification level-triggered instead
> of edge-triggered, which is a big plus. No matter which state the
> tracee is in, a jctl stopped notification is guaranteed to happen
> after the lastest event and the tracer can always find out the latest
> state with PTRACE_GETSIGINFO.
>
> Using stopped notification also makes the new addition harmless to the
> existing users. It's just another stopped notification. Both
> strace(1) and gdb(1) don't distinguish the signal delivery and jctl
> stop notifications and react the same way by resuming the tracee
> unconditionally. One more stopped notification on SIGCONT emission
> doesn't change much.
Let's spell this out in detail. Please correct me if
I misunderstood your proposal:
We have a stopped task under ptrace.
(More precisely: debugger got a WSTOPPED notification via waitpid.
Debugger decided to emulate the job control stop, therefore it
keeps tracee stopped, therefore it just waits on waitpid
without doing any PTRACE_CONTs).
Another task sends SIGCONT to the tracee.
Debugger gets waitpid notification of the
WSTOPPED, WSTOPSIG == SIGCONT form.
Debugger can check PTRACE_GETSIGINFO, which succeeds.
Debugger now knows it's a signal delivery notification.
(This step looks optional, since currently
WSTOPPED, WSTOPSIG == SIGCONT combination is only possible
on signal delivery, unlike, for example,
WSTOPPED, WSTOPSIG == SIGSTOP, which is ambiguous).
Debugger performs PTRACE_CONT(SIGCONT) - it injects the signal.
[Question: what if debugger doesn't? IOW: is it possible
for debugger to suppress SIGCONTs, or not?
IOW2: what should happen if debugger
(a) does not do any PTRACE_CONT at all? or
(b) does PTRACE_CONT(<other_sig>)? or
(c) does PTRACE_CONT(0)?
]
Debugger gets WCONTINUED waitpid notification.
[question: do we need this?]
--
vda
next prev parent reply other threads:[~2011-03-01 23:16 UTC|newest]
Thread overview: 73+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-03-01 15:24 [RFC] Proposal for ptrace improvements Tejun Heo
2011-03-01 16:57 ` Denys Vlasenko
2011-03-01 17:09 ` Tejun Heo
2011-03-01 17:12 ` Tejun Heo
2011-03-01 17:21 ` Denys Vlasenko
2011-03-01 18:34 ` Tejun Heo
2011-03-01 23:51 ` Denys Vlasenko
2011-03-02 7:10 ` Tejun Heo
2011-03-02 5:07 ` Indan Zupancic
2011-03-02 7:44 ` Tejun Heo
2011-03-02 11:32 ` Indan Zupancic
2011-03-02 11:52 ` Denys Vlasenko
2011-03-02 14:50 ` Tejun Heo
2011-03-02 13:32 ` Oleg Nesterov
2011-03-03 0:47 ` Indan Zupancic
2011-03-03 1:30 ` Denys Vlasenko
2011-03-03 1:55 ` Indan Zupancic
2011-03-03 7:03 ` Tejun Heo
2011-03-01 19:06 ` Jan Kratochvil
2011-03-01 22:14 ` Denys Vlasenko
2011-03-02 7:28 ` Tejun Heo
2011-03-02 10:58 ` Denys Vlasenko
2011-03-04 16:14 ` Jan Kratochvil
2011-03-04 16:41 ` Denys Vlasenko
2011-03-04 17:07 ` Oleg Nesterov
2011-03-04 18:12 ` Jan Kratochvil
2011-03-05 8:47 ` Tejun Heo
2011-03-01 22:59 ` Denys Vlasenko
2011-03-02 7:32 ` Tejun Heo
2011-03-02 11:02 ` Denys Vlasenko
2011-03-02 11:23 ` Tejun Heo
2011-03-03 19:26 ` Oleg Nesterov
2011-03-01 23:16 ` Denys Vlasenko [this message]
2011-03-02 7:37 ` Tejun Heo
2011-03-02 11:21 ` Denys Vlasenko
2011-03-02 11:27 ` Tejun Heo
2011-03-02 11:48 ` Denys Vlasenko
2011-03-02 14:43 ` Tejun Heo
2011-03-02 15:16 ` Denys Vlasenko
2011-03-02 15:25 ` Tejun Heo
2011-03-03 17:34 ` Oleg Nesterov
2011-03-03 20:22 ` Oleg Nesterov
2011-03-04 8:23 ` Tejun Heo
2011-03-04 18:16 ` Oleg Nesterov
2011-03-05 8:33 ` Tejun Heo
2011-03-04 13:01 ` Denys Vlasenko
2011-03-04 13:41 ` Tejun Heo
2011-03-04 13:59 ` Denys Vlasenko
2011-03-04 14:07 ` Tejun Heo
2011-03-04 14:31 ` Denys Vlasenko
2011-03-04 14:40 ` Tejun Heo
2011-03-04 17:05 ` Denys Vlasenko
2011-03-04 17:12 ` Linus Torvalds
2011-03-04 18:59 ` Denys Vlasenko
2011-03-04 19:24 ` Linus Torvalds
2011-03-04 16:13 ` Oleg Nesterov
2011-03-04 16:30 ` Oleg Nesterov
2011-03-04 8:44 ` Tejun Heo
2011-03-04 16:01 ` Oleg Nesterov
2011-03-04 16:15 ` Tejun Heo
2011-03-04 16:26 ` Oleg Nesterov
2011-03-07 15:08 ` PTRACE_SEIZE/INTERRUPT: " Oleg Nesterov
2011-03-09 9:41 ` Tejun Heo
2011-03-09 17:30 ` Oleg Nesterov
2011-03-07 20:43 ` Roland McGrath
2011-03-09 10:28 ` Tejun Heo
2011-03-10 18:33 ` Steven Rostedt
2011-03-11 8:13 ` Tejun Heo
2011-03-11 8:22 ` Ingo Molnar
2011-03-11 9:35 ` Srikar Dronamraju
2011-03-11 9:43 ` Ingo Molnar
2011-03-14 1:03 ` Frank Ch. Eigler
2011-03-10 15:55 ` Steven Rostedt
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='AANLkTi=cUM9S5M7h0unMfbQ88CzqhoDN9CUEVf_9HrdS@mail.gmail.com' \
--to=vda.linux@googlemail.com \
--cc=akpm@linux-foundation.org \
--cc=jan.kratochvil@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=oleg@redhat.com \
--cc=roland@redhat.com \
--cc=tj@kernel.org \
--cc=torvalds@linux-foundation.org \
/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;
as well as URLs for NNTP newsgroup(s).