Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Pedro Alves <pedro@codesourcery.com>
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	[thread overview]
Message-ID: <200808182344.10761.pedro@codesourcery.com> (raw)
In-Reply-To: <200808182341.38872.pedro@codesourcery.com>

[-- Attachment #1: Type: text/plain, Size: 489 bytes --]

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

[-- Attachment #2: 001-always_a_thread_fork.diff --]
[-- Type: text/x-diff, Size: 2097 bytes --]

2008-08-18  Pedro Alves  <pedro@codesourcery.com>

	* 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.  */

  reply	other threads:[~2008-08-18 22:44 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-08-08  1:33 Pedro Alves
2008-08-08 21:47 ` Mark Kettenis
2008-08-18 22:41   ` Pedro Alves
2008-08-18 22:44     ` Pedro Alves [this message]
2008-08-18 23:23       ` Daniel Jacobowitz
2008-08-18 23:30         ` Pedro Alves

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=200808182344.10761.pedro@codesourcery.com \
    --to=pedro@codesourcery.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