From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20377 invoked by alias); 18 Aug 2008 22:44:28 -0000 Received: (qmail 20358 invoked by uid 22791); 18 Aug 2008 22:44:27 -0000 X-Spam-Check-By: sourceware.org Received: from mail.codesourcery.com (HELO mail.codesourcery.com) (65.74.133.4) by sourceware.org (qpsmtpd/0.31) with ESMTP; Mon, 18 Aug 2008 22:43:46 +0000 Received: (qmail 15915 invoked from network); 18 Aug 2008 22:43:44 -0000 Received: from unknown (HELO orlando.local) (pedro@127.0.0.2) by mail.codesourcery.com with ESMTPA; 18 Aug 2008 22:43:44 -0000 From: Pedro Alves To: gdb-patches@sourceware.org Subject: Re: [1/7] Register the main thread/task in fork-child.c Date: Mon, 18 Aug 2008 22:44:00 -0000 User-Agent: KMail/1.9.9 References: <200808080233.48834.pedro@codesourcery.com> <200808082145.m78LjqWQ012096@brahms.sibelius.xs4all.nl> <200808182341.38872.pedro@codesourcery.com> In-Reply-To: <200808182341.38872.pedro@codesourcery.com> MIME-Version: 1.0 Content-Type: Multipart/Mixed; boundary="Boundary-00=_6sfqI/5EGBYv5oa" Message-Id: <200808182344.10761.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: 2008-08/txt/msg00505.txt.bz2 --Boundary-00=_6sfqI/5EGBYv5oa Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Content-Disposition: inline Content-length: 489 On Monday 18 August 2008 23:41:38, Pedro Alves wrote: > On Friday 08 August 2008 22:45:52, Mark Kettenis wrote: > > The observer makes sense to me too. So the overall answer is yes! > > Thanks! > > I took the liberty of splitting this patch in two, as there > are other patches that are ready to be checked in, that > depended on thread_change_ptid, but which do not depend on > fork-child.c. > Attached is what I checked in. And this is what I haven't checked in yet. -- Pedro Alves --Boundary-00=_6sfqI/5EGBYv5oa Content-Type: text/x-diff; charset="utf-8"; name="001-always_a_thread_fork.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="001-always_a_thread_fork.diff" Content-length: 2097 2008-08-18 Pedro Alves * linux-nat.c (linux_nat_wait): Update inferior_ptid's ptid with thread_change_ptid. Don't add or mark the main thread as running and executing here. * fork-child.c (fork_inferior): Add the main thread here, and set it running and executing. --- gdb/fork-child.c | 6 ++++++ gdb/linux-nat.c | 11 +++++------ 2 files changed, 11 insertions(+), 6 deletions(-) Index: src/gdb/linux-nat.c =================================================================== --- src.orig/gdb/linux-nat.c 2008-08-18 23:24:09.000000000 +0100 +++ src/gdb/linux-nat.c 2008-08-18 23:36:32.000000000 +0100 @@ -2722,14 +2722,13 @@ linux_nat_wait (ptid_t ptid, struct targ { gdb_assert (!is_lwp (inferior_ptid)); - inferior_ptid = BUILD_LWP (GET_PID (inferior_ptid), - GET_PID (inferior_ptid)); + /* Upgrade the main thread's ptid. */ + thread_change_ptid (inferior_ptid, + BUILD_LWP (GET_PID (inferior_ptid), + GET_PID (inferior_ptid))); + lp = add_lwp (inferior_ptid); lp->resumed = 1; - /* Add the main thread to GDB's thread list. */ - add_thread_silent (lp->ptid); - set_running (lp->ptid, 1); - set_executing (lp->ptid, 1); } /* Block events while we're here. */ Index: src/gdb/fork-child.c =================================================================== --- src.orig/gdb/fork-child.c 2008-08-18 23:24:09.000000000 +0100 +++ src/gdb/fork-child.c 2008-08-18 23:36:32.000000000 +0100 @@ -397,6 +397,12 @@ fork_inferior (char *exec_file_arg, char /* Needed for wait_for_inferior stuff below. */ inferior_ptid = pid_to_ptid (pid); + /* We have something that executes now. We'll be running through + the shell at this point, but the pid shouldn't change. Targets + supporting MT should fill this task's ptid with more data as soon + as they can. */ + add_thread_silent (inferior_ptid); + /* Now that we have a child process, make it our target, and initialize anything target-vector-specific that needs initializing. */ --Boundary-00=_6sfqI/5EGBYv5oa--