This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Stop threads when attaching to a PID that is the tgid


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]