public inbox for archer@sourceware.org
 help / color / mirror / Atom feed
From: Oleg Nesterov <oleg@redhat.com>
To: Roland McGrath <roland@redhat.com>
Cc: Project Archer <archer@sourceware.org>
Subject: Re: ptrace improvement: PTRACE_O_INHERIT
Date: Thu, 10 Feb 2011 20:00:00 -0000	[thread overview]
Message-ID: <20110210195212.GA3868@redhat.com> (raw)
In-Reply-To: <20110203223905.D0C77180081@magilla.sf.frob.com>

On 02/03, Roland McGrath wrote:
>
> * PTRACE_O_INHERIT
>
> This is a new option bit for PTRACE_SETOPTIONS or the options argument of
> PTRACE_ATTACH_NOSTOP.  Its effect is that clones of the tracee inherit the
> ptrace attachedness and option settings of their parent.

Jan has already reminded about about debug registers.

What else? Say, should TIF_SYSCALL_TRACE be copied? Suppose that we
try adapt strace to this new option.

> This has no other effects, meaning it does not cause
> either the parent or the child to stop for any event.

Somehow I am starting to feel uncomfortable. The debugger traces the
thread and doesn't even know about this fact. And can't know until the
first report. But once again, if this is fine for gdb - please ignore.

> The point of PTRACE_O_INHERIT would be to attach newly-created threads and
> children without causing an event stop and the attendant overhead.

OK, PTRACE_EVENT_FORK stops both, parent and child. But we can implement
PTRACE_O_INHERIT so that only the new child/thread stops. Or this doesn't
help enough?


Or. Suppose that clone() under PTRACE_O_INHERIT notifies the tracer
(sends SIGCHLD), and the new tracee gets the new PTRACE_O_INHERITed
mark. Then we can implement wait(W_WHO_WAS_CLONNED) which clears
PTRACE_O_INHERITed and reports the new tracee (just in case, this
doesn't need the stopped tracee).

Not sure this makes any sense, but how "info treads" can work otherwise?

> Because of this spontaneous report aspect, it could be difficult to figure
> out what's going on with any new thread that is a fork/vfork, or other use
> of clone (oddball applications, or old linuxthreads), rather than a
> CLONE_THREAD case (NPTL pthread_create).  In those cases, si_tgid and
> si_pid are the same and neither matches any process you already know you
> are tracing.  In general, it can be impossible to figure out whose child
> this is, because its parent could exit so its ppid (as seen in
> /proc/pid/status et al) becomes 1.

Not sure I really understand why this is the problem by itself. Yes, if
its ppid == 1, we know that the original parent was traced by us and then
it has gone.

Suppose that we (to simplify the discussion) introduce task->original_ppid,
then we can "solve" the problem and report this pid to gdb. But given that
it has already died, how this can help?

Nevermind,

> So perhaps it would be better to have
> this be just PTRACE_O_THREAD_INHERIT, where it only applies to CLONE_THREAD
> clones.

Or we can have both.

Oleg.

  parent reply	other threads:[~2011-02-10 20:00 UTC|newest]

Thread overview: 57+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-02-03 22:39 ptrace improvement ideas Roland McGrath
2011-02-04 18:56 ` Oleg Nesterov
2011-02-04 18:58   ` Roland McGrath
2011-02-07 21:11 ` Jan Kratochvil
2011-02-08  1:58   ` Roland McGrath
2011-02-08 20:41     ` Jan Kratochvil
2011-02-09  2:48       ` Roland McGrath
2011-02-08 21:07     ` Oleg Nesterov
2011-02-08 23:18       ` hw_breakpoint userland interface Roland McGrath
2011-02-10 21:03         ` Oleg Nesterov
2011-02-10 21:14           ` Roland McGrath
2011-02-11 20:17             ` Oleg Nesterov
2011-02-10 20:00 ` Oleg Nesterov [this message]
2011-02-11 19:24   ` ptrace improvement: PTRACE_O_INHERIT Roland McGrath
2011-02-11 20:46     ` Oleg Nesterov
2011-02-12  0:59       ` Roland McGrath
2011-02-12 19:11         ` Oleg Nesterov
2011-02-14 19:31           ` Roland McGrath
2011-02-14 19:46             ` Oleg Nesterov
2011-02-15  0:36               ` Roland McGrath
2011-02-15 13:16                 ` Oleg Nesterov
2011-02-15 21:43                   ` Jan Kratochvil
2011-02-15 21:56                     ` Roland McGrath
2011-02-16 19:42                       ` Oleg Nesterov
2011-02-16 19:45                         ` Roland McGrath
2011-02-16 20:09                           ` Oleg Nesterov
2011-02-16 20:16                             ` Roland McGrath
2011-02-19 19:48                             ` Jan Kratochvil
2011-02-19 20:37                               ` Oleg Nesterov
2011-02-20  8:18                                 ` Jan Kratochvil
2011-02-20 21:05                                   ` Oleg Nesterov
2011-02-21 19:54                                 ` Roland McGrath
2011-02-22 19:39                                   ` Oleg Nesterov
2011-02-22 20:49                                     ` Roland McGrath
2011-02-22 21:10                                       ` Oleg Nesterov
2011-02-22 22:16                                         ` Roland McGrath
2011-02-21 19:44                               ` Roland McGrath
2011-02-15 22:02                     ` Roland McGrath
2011-02-16 16:02                       ` Jan Kratochvil
2011-02-16 18:28                         ` Roland McGrath
2011-02-16 20:00                           ` Oleg Nesterov
2011-02-16 20:07                             ` Roland McGrath
2011-02-16 20:32                               ` Oleg Nesterov
2011-02-16 19:48                       ` Oleg Nesterov
2011-02-16 20:02                         ` Roland McGrath
2011-02-16 20:15                           ` Oleg Nesterov
2011-02-16 20:31                             ` Roland McGrath
2011-02-16 21:04                               ` Oleg Nesterov
2011-02-16 21:51                                 ` Roland McGrath
2011-02-16 19:38                     ` Oleg Nesterov
2011-02-16 19:40                       ` Roland McGrath
2011-02-15 22:17                   ` Roland McGrath
2011-02-16 20:48                     ` Oleg Nesterov
2011-02-16 11:31 ` ptrace improvement ideas (QPassSignals) Jan Kratochvil
2011-02-16 18:36   ` Roland McGrath
2011-02-16 20:21     ` Oleg Nesterov
2011-02-18 20:24       ` Oleg Nesterov

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=20110210195212.GA3868@redhat.com \
    --to=oleg@redhat.com \
    --cc=archer@sourceware.org \
    --cc=roland@redhat.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).