public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Pedro Alves <palves@redhat.com>
To: Joel Brobecker <brobecker@adacore.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [RFA/Linux] Ask kernel to kill inferior when GDB terminates
Date: Mon, 15 Dec 2014 21:17:00 -0000	[thread overview]
Message-ID: <548F4FFC.8060509@redhat.com> (raw)
In-Reply-To: <20141215204323.GE5457@adacore.com>

On 12/15/2014 08:43 PM, Joel Brobecker wrote:

> GDB with signal 9. After GDB is killed, the inferior still remains
> in "interruptible sleep (waiting for an event to complete)" state.

This makes it sound like "interruptible sleep" is some kind of wedged
state waiting for a debugger.  But, this simply means your process is just
running as normal, and your test's case, normal means idling.  Most likely,
your test program had a "sleep" call in it.  IOW, it'd be in sleep state
even if had been started outside gdb.  Another test program could go
to "T (stopped)", "R (running)", etc.

> -/* Determine ptrace features available on this target.  */
> +/* Determine ptrace features available on this target.
> +   ATTACHED should be nonzero iff we've attached to the inferior.  */
>
>  static void
> -linux_check_ptrace_features (void)
> +linux_check_ptrace_features (int attached)
>  {
>    int child_pid, ret, status;
>
> @@ -338,6 +340,9 @@ linux_check_ptrace_features (void)
>
>    linux_test_for_tracefork (child_pid);
>
> +  if (!attached)
> +    linux_test_for_exitkill (child_pid);

This test must be called unconditionally.  current_ptrace_options is
only initialized once:

 void
 linux_enable_event_reporting (pid_t pid)
 {
   /* Check if we have initialized the ptrace features for this
      target.  If not, do it now.  */
   if (current_ptrace_options == -1)
     linux_check_ptrace_features ();

so if the first process gdbserver debugs is an "attach" process,
but the second one is not, you'll miss setting PTRACE_O_EXITKILL on
the second process.

Instead, always call linux_test_for_exitkill, and then in
linux_enable_event_reporting mask out PTRACE_O_EXITKILL
from current_ptrace_options if 'attached' is false.

Thanks,
Pedro Alves

  reply	other threads:[~2014-12-15 21:17 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-14 16:54 Joel Brobecker
2014-11-14 17:09 ` Pedro Alves
2014-11-14 17:33   ` Joel Brobecker
2014-11-19  9:25     ` Joel Brobecker
2014-11-19  9:58       ` Pedro Alves
2014-12-13 16:28         ` Joel Brobecker
2014-12-15 13:22           ` Pedro Alves
2014-12-15 20:43             ` Joel Brobecker
2014-12-15 21:17               ` Pedro Alves [this message]
2014-12-16  0:39                 ` Joel Brobecker
2014-12-16  9:46                   ` Pedro Alves
2014-12-16 12:58                     ` pushed: " Joel Brobecker

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=548F4FFC.8060509@redhat.com \
    --to=palves@redhat.com \
    --cc=brobecker@adacore.com \
    --cc=gdb-patches@sourceware.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 read-only IMAP folder(s) and NNTP newsgroup(s).