Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Michael Snyder <msnyder@vmware.com>
To: Doug Evans <dje@google.com>
Cc: "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>
Subject: Re: [RFA] add some comments to linux-low.c:linux_attach_lwp
Date: Thu, 18 Dec 2008 19:47:00 -0000	[thread overview]
Message-ID: <494AA75A.1060607@vmware.com> (raw)
In-Reply-To: <20081213212631.C563D1C7A0F@localhost>

Seems fine.

Doug Evans wrote:
> Hi.
> 
> Until things are fixed, I'd like to record some knowledge so
> I don't forget.  This also does a better job (IMO) of enumerating
> all the cases that need to be handled here.
> 
> Ok to check in?
> 
> 2008-12-13  Doug Evans  <dje@google.com>
> 
> 	* linux-low.c (linux_attach_lwp): Add some comments/fixmes.
> 
> Index: linux-low.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/gdbserver/linux-low.c,v
> retrieving revision 1.84
> diff -u -p -r1.84 linux-low.c
> --- linux-low.c	12 Dec 2008 23:14:28 -0000	1.84
> +++ linux-low.c	13 Dec 2008 21:24:00 -0000
> @@ -326,6 +326,8 @@ linux_attach_lwp (unsigned long pid)
>  	       strerror (errno), errno);
>      }
>  
> +  /* FIXME: This intermittently fails.
> +     We need to wait for SIGSTOP first.  */
>    ptrace (PTRACE_SETOPTIONS, pid, 0, PTRACE_O_TRACECLONE);
>  
>    new_process = (struct process_info *) add_process (pid);
> @@ -333,15 +335,36 @@ linux_attach_lwp (unsigned long pid)
>    new_thread_notify (thread_id_to_gdb_id (new_process->lwpid));
>  
>    /* The next time we wait for this LWP we'll see a SIGSTOP as PTRACE_ATTACH
> -     brings it to a halt.  We should ignore that SIGSTOP and resume the process
> -     (unless this is the first process, in which case the flag will be cleared
> -     in linux_attach).
> +     brings it to a halt.
> +
> +     There are several cases to consider here:
> +
> +     1) gdbserver has already attached to the process and is being notified
> +        of a new thread that is being created.
> +        In this case we should ignore that SIGSTOP and resume the process.
> +        This is handled below by setting stop_expected = 1.
> +
> +     2) This is the first thread (the process thread), and we're attaching
> +        to it via attach_inferior.
> +        In this case we want the process thread to stop.
> +        This is handled by having linux_attach clear stop_expected after
> +        we return.
> +        ??? If the process already has several threads we leave the other
> +        threads running.
> +
> +     3) GDB is connecting to gdbserver and is requesting an enumeration of all
> +        existing threads.
> +        In this case we want the thread to stop.
> +        FIXME: This case is currently not properly handled.
> +        We should wait for the SIGSTOP but don't.  Things work apparently
> +        because enough time passes between when we ptrace (ATTACH) and when
> +        gdb makes the next ptrace call on the thread.
>  
>       On the other hand, if we are currently trying to stop all threads, we
>       should treat the new thread as if we had sent it a SIGSTOP.  This works
> -     because we are guaranteed that add_process added us to the end of the
> -     list, and so the new thread has not yet reached wait_for_sigstop (but
> -     will).  */
> +     because we are guaranteed that the add_process call above added us to the
> +     end of the list, and so the new thread has not yet reached
> +     wait_for_sigstop (but will).  */
>    if (! stopping_threads)
>      new_process->stop_expected = 1;
>  }


      reply	other threads:[~2008-12-18 19:47 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-12-13 21:27 Doug Evans
2008-12-18 19:47 ` Michael Snyder [this message]

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=494AA75A.1060607@vmware.com \
    --to=msnyder@vmware.com \
    --cc=dje@google.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