Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Pedro Alves <pedro@codesourcery.com>
To: gdb-patches@sourceware.org, lgustavo@codesourcery.com
Subject: Re: [PATCH] Stop threads when attaching to a PID that is the tgid
Date: Tue, 23 Aug 2011 17:48:00 -0000	[thread overview]
Message-ID: <201108231848.15068.pedro@codesourcery.com> (raw)
In-Reply-To: <4E53B25B.3030009@codesourcery.com>

On Tuesday 23 August 2011 14:59:55, Luis Machado wrote:
> Hi,
> 

Missing explanation as to _why_ we need this.  Here's one:

On linux/ptrace, a ptracer needs to attach to each
and every thread of a process individually.  Currently, when you
do `gdbserver --attach PID', GDBserver only attaches to the PID thread,
leaving all the other threads of the process running free. This is because
GDBserver relies on thread_db to list the threads of PID, and, in order
to activate thread_db, GDBserver needs to query GDB about some symbols,
which obviously can only work once GDB connects..

To fix this, this patch teaches GDBServer to list threads using /proc,
instead of relying on thread_db, and attach/stop all of them.

> This patch teaches GDBServer how to stop threads from a TID that is also 
> the TGID, without having to rely on GDB to list and stop them upon 
> connection.


>   2011-08-23  Luis Machado  <lgustavo@codesourcery.com>
> 
>         * linux-low.c: Include linux-procfs.h.
>         (linux_attach_lwp_1): Update comments.
>         (linux_attach): Scan for existing threads when attaching to a
>         process that is the tgid.
> 
> --- .pc/stop_threads.diff/gdb/gdbserver/linux-low.c     2011-08-23 10:38:50.653049001 -0300
> +++ gdb/gdbserver/linux-low.c   2011-08-23 10:58:02.817049000 -0300
> @@ -26,6 +26,7 @@
>  #include <sys/param.h>
>  #include <sys/ptrace.h>
>  #include "linux-ptrace.h"
> +#include "linux-procfs.h"

Sorry I missed this before.  This needs an update to the linux-low.o
rule in Makefile.in.  gdbserver doesn't do automatic header
dependencies...  This is okay otherwise.

-- 
Pedro Alves


  reply	other threads:[~2011-08-23 17:48 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-23 14:00 Luis Machado
2011-08-23 17:48 ` Pedro Alves [this message]
2011-08-24 12:22   ` Luis Machado

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=201108231848.15068.pedro@codesourcery.com \
    --to=pedro@codesourcery.com \
    --cc=gdb-patches@sourceware.org \
    --cc=lgustavo@codesourcery.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