lkml.org 
[lkml]   [2011]   [May]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCHSET ptrace] ptrace: implement PTRACE_SEIZE/INTERRUPT and group stop notification
Hello,

On Mon, May 09, 2011 at 12:27:41AM +0200, Denys Vlasenko wrote:
> > After PTRACE_SEIZE, tracee will trap.
>
> So which is it? Does PTRACE_SEIZE trap or not?

PTRACE_SEIZE attaches to a new tracee and traps it. INTERRUPT traps
already attached tracee.

> > * Group stop notification is implemented as sticky INTERRUPT trap
> > which gets cleared on PTRACE_GETSIGINFO and notifies both start and
> > end of group stops.
> > ...
> > * The trap condition is sticky until GETSIGINFO. This is necessary
> > because generation of the event may race with CONT and ptracer may
> > miss the trap.
>
> As a userspace guy, I find this explanation unclear.
>
> What is "sticky" exactly? siginfo.si_pt_flags contents?
>
> What exactly "sticky" means? If PTRACE_GETSIGINFO is not queried
> by userspace after it observed ptrace stop, what will happen?

It means that INTERRUPT trap will happen repeatedly until the
condition is cleared by PTRACE_GETSIGINFO.

> Real world users of ptrace, such as strace, will likely avoid
> PTRACE_GETSIGINFO'ing on every stop - they will examine wait status,
> and query PTRACE_GETSIGINFO only if they know they have to -
> such as when they see a job stop signal (SIGSTOP/SIGTSTP/etc),
> not SIGTRAP.
>
> Is it still possible, or PTRACE_GETSIGINFO will be a mandatory call
> after each ptrace stop for any userspace usage which wants to track
> job stop status of the tracee?

You can tell INTERRUPT trap from the exit_code stored in si_status
(si_code CLD_TRAPPED and si_status SIGTRAP | (PTRACE_EVENT_INTERRUPT
<< 8)), so you can call GETSIGINFO only after INTERRUPT traps, which
should be enough for job control notifications, but you would also
have to do GETSIGINFO to discern signal delivery and actual group stop
traps (si_code zero and si_status is the signo for both).
> I don't know the status of ptrace test suite after I stopped working
> on strace (did the suite bit rot, or is it maintained and still
> relevant?). If it is still in use, I can adapt these tests and add
> them to it.

I have no idea but am planning write more complete example program.
The ones included in the commit messages are mostly just to show that
the basic functionality implemented by the commit works, so they
aren't necessarily good examples.

Thank you.

--
tejun


\
 
 \ /
  Last update: 2011-05-09 11:51    [from the cache]
©2003-2014 Jasper Spaans. Advertise on this site