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: [ob] remote, add inferior before its threads


On Friday 17 October 2008 02:12:03, Pedro Alves wrote:
> I noticed that a new thread notification was being emited before
> the corresponding new inferior notification.  Doesn't make much
> sense, especially for MI.
> 
> Checked in.
> 

Now see, my 2008-09-22 self was much smarter than my 2008-10-17
self.  The latter self missed that the former self had made it so
the inferior was added after checking if a thread_change_ptid was
needed, since that also updates the matching "struct inferior"'s
pid, resulting in the possibility of leaving a dangling inferior entry
in the inferior list.  The former self wasn't without guilt as well,
since it did add the new inferior after adding its child thread.

Checked in.  Let's see if today's self got it right this time.

-- 
Pedro Alves
2008-11-05  Pedro Alves  <pedro@codesourcery.com>

	* remote.c (notice_new_inferiors): Add a new inferior only when
	we're going to add a new thread.

---
 gdb/remote.c |   14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

Index: src/gdb/remote.c
===================================================================
--- src.orig/gdb/remote.c	2008-11-04 21:17:19.000000000 +0000
+++ src/gdb/remote.c	2008-11-04 21:20:55.000000000 +0000
@@ -1127,13 +1127,6 @@ static ptid_t continue_thread;
 static void
 notice_new_inferiors (ptid_t currthread)
 {
-  /* When connecting to a target remote, or to a target
-     extended-remote which already was debugging an inferior, we may
-     not know about it yet.  Add it before adding its child thread, so
-     notifications are emitted in a sensible order.  */
-  if (!in_inferior_list (ptid_get_pid (currthread)))
-    add_inferior (ptid_get_pid (currthread));
-
   /* If this is a new thread, add it to GDB's thread list.
      If we leave it up to WFI to do this, bad things will happen.  */
 
@@ -1169,6 +1162,13 @@ notice_new_inferiors (ptid_t currthread)
 	  return;
 	}
 
+      /* When connecting to a target remote, or to a target
+	 extended-remote which already was debugging an inferior, we
+	 may not know about it yet.  Add it before adding its child
+	 thread, so notifications are emitted in a sensible order.  */
+      if (!in_inferior_list (ptid_get_pid (currthread)))
+	add_inferior (ptid_get_pid (currthread));
+
       /* This is really a new thread.  Add it.  */
       add_thread (currthread);
     }

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