public inbox for archer@sourceware.org
 help / color / mirror / Atom feed
From: Roland McGrath <roland@redhat.com>
To: Oleg Nesterov <oleg@redhat.com>
Cc: archer@sourceware.org, utrace-devel@redhat.com
Subject: Re: gdbstub initial code, v8 && ptrace
Date: Wed, 13 Oct 2010 07:14:00 -0000	[thread overview]
Message-ID: <20101013071359.A789A401B2@magilla.sf.frob.com> (raw)
In-Reply-To: Oleg Nesterov's message of  Friday, 10 September 2010 21:07:25 +0200 <20100910190725.GC27699@redhat.com>

> But. Suppose we have to attached engines. The first engine gets
> UTRACE_SIGNAL_REPORT and returns "UTRACE_STOP | UTRACE_SIGNAL_IGN".

Right, that's what it would do.  I see, you're saying that the
report.result passed on to the next engine would appear like it had
been a real signal that the previous engine decided to ignore (or
whose sa_handler==SIG_IGN or default action was to ignore).  Hmm.

Well, it's also distinguished by having orig_ka==NULL in the callback.
Any real signal has a non-null orig_ka argument.

> or yes, it returns UTRACE_SIGNAL_DELIVER after gdb does "signal XX".
> 
> Now. The second engine gets UTRACE_SIGNAL_DELIVER or UTRACE_SIGNAL_IGN,
> not UTRACE_SIGNAL_REPORT.

At least in the UTRACE_SIGNAL_DELIVER case, that's really the true
thing for it to see.  The previous engine decided to do a signal
delivery (as directed by return_ka), so the next engine needs to see
this to know what the prevailing state of play is now.

> That is why ugdb_signal_report(UTRACE_SIGNAL_REPORT) tries to return
> UTRACE_STOP | utrace_signal_action(action) to not change report->result
> (passed to the next tracee) inside the reporting loop.

Well, it *can* do that.  If UTRACE_SIGNAL_REPORT (or anything else
random) is the ultimate report.result from the whole callback loop, we
treat it just like UTRACE_SIGNAL_IGN.

> The worst case is UTRACE_SIGNAL_HANDLER. Single-stepping should know
> about this case. This means that any engine should always return
> UTRACE_resume_action | UTRACE_SIGNAL_HANDLER.

I see.  This is indeed the only way for any engine to know that it's
getting the UTRACE_SIGNAL_HANDLER specific notification rather than
some random fallout of someone else's UTRACE_REPORT request or whatnot.

> > > Probably we can check orig_ka != NULL and treat orig_ka == NULL as
> > > UTRACE_SIGNAL_REPORT. Hopefully this can't be confused with
> > > UTRACE_SIGNAL_HANDLER.
> >
> > I'm not really sure what you mean here.
> 
> If ->report_signal(orig_ka) was calles with orig_ka == NULL, then,
> whatever utrace_signal_action(action) we see, originally it was
> either UTRACE_SIGNAL_HANDLER or UTRACE_SIGNAL_REPORT but another engine
> returned, say, UTRACE_SIGNAL_DELIVER/UTRACE_SIGNAL_IGN to deliver/stop.

Right.  But this is in fact just the same for either
UTRACE_SIGNAL_REPORT or UTRACE_SIGNAL_HANDLER.

> > > Not sure about UTRACE_SIGNAL_HOLD, but this is very unlikely race.
> >
> > You probably don't want to use that, but I'm not entirely sure.  ptrace
> > doesn't use it, and the signal interception model is pretty much the same.
> 
> Yes, agreed. But there is one corner case. Until we generalize
> utrace_stop()->ptrace_notify_stop() hook, the tracee can be reported as
> stopped to gdb, but before it actually stops it can recieve a signal.

I don't follow this.  If we're stopping, then we don't "receive"
(dequeue) any other signal until we get resumed.  That should be fine
from gdb's point of view.  The next signal is just pending for later.
The signal that we just reported was a) in fact reported to gdb and
b) is still sitting in the siginfo_t on stack and the engine can
examine/modify that before letting the thread resume.  (The kerneldoc
paragraph about @report_signal in utrace.h makes this guarantee.)


Thanks,
Roland

  reply	other threads:[~2010-10-13  7:14 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-09-03 22:44 gdbstub initial code, v8 Oleg Nesterov
2010-09-05 19:41 ` Jan Kratochvil
2010-09-06 18:21   ` Oleg Nesterov
2010-09-06 18:31     ` Jan Kratochvil
2010-09-06 20:48       ` Oleg Nesterov
2010-09-07  2:59         ` Frank Ch. Eigler
2010-09-08 19:24           ` Oleg Nesterov
2010-09-10 10:02           ` Roland McGrath
2010-09-06 18:27 ` gdbstub initial code, v8 && ptrace Oleg Nesterov
2010-09-06 19:45   ` Oleg Nesterov
2010-09-06 21:02     ` Oleg Nesterov
2010-09-10 10:10       ` Roland McGrath
2010-09-10 19:10         ` Oleg Nesterov
2010-10-13  7:14           ` Roland McGrath [this message]
2010-10-15 13:57             ` 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=20101013071359.A789A401B2@magilla.sf.frob.com \
    --to=roland@redhat.com \
    --cc=archer@sourceware.org \
    --cc=oleg@redhat.com \
    --cc=utrace-devel@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).