From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5631 invoked by alias); 23 Aug 2011 17:48:38 -0000 Received: (qmail 5619 invoked by uid 22791); 23 Aug 2011 17:48:33 -0000 X-SWARE-Spam-Status: No, hits=-2.2 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mail.codesourcery.com (HELO mail.codesourcery.com) (38.113.113.100) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 23 Aug 2011 17:48:17 +0000 Received: (qmail 3340 invoked from network); 23 Aug 2011 17:48:17 -0000 Received: from unknown (HELO scottsdale.localnet) (pedro@127.0.0.2) by mail.codesourcery.com with ESMTPA; 23 Aug 2011 17:48:17 -0000 From: Pedro Alves 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 User-Agent: KMail/1.13.6 (Linux/2.6.38-11-generic; KDE/4.7.0; x86_64; ; ) References: <4E53B25B.3030009@codesourcery.com> In-Reply-To: <4E53B25B.3030009@codesourcery.com> MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-15" Content-Transfer-Encoding: 7bit Message-Id: <201108231848.15068.pedro@codesourcery.com> X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2011-08/txt/msg00420.txt.bz2 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 > > * 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 > #include > #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