* fork-child.c (startup_inferior): Only set threads not-executing
authorPedro Alves <palves@redhat.com>
Fri, 24 Oct 2008 22:01:25 +0000 (22:01 +0000)
committerPedro Alves <palves@redhat.com>
Fri, 24 Oct 2008 22:01:25 +0000 (22:01 +0000)
after getting all the pending execs.  On TARGET_WAITKIND_IGNORE,
keep waiting, don't resume.  On all other cases but
TARGET_WAITKIND_SIGNALLED and TARGET_WAITKIND_EXITED, switch to
the event ptid.

gdb/ChangeLog
gdb/fork-child.c

index e4fec8733b3713f32b572ba0326a9666e2d47528..3e807417e4e4c9c4c0311f1eb4f180a579bdf238 100644 (file)
@@ -1,3 +1,11 @@
+2008-10-24  Pedro Alves  <pedro@codesourcery.com>
+
+       * fork-child.c (startup_inferior): Only set threads not-executing
+       after getting all the pending execs.  On TARGET_WAITKIND_IGNORE,
+       keep waiting, don't resume.  On all other cases but
+       TARGET_WAITKIND_SIGNALLED and TARGET_WAITKIND_EXITED, switch to
+       the event ptid.
+
 2008-10-24  Pedro Alves  <pedro@codesourcery.com>
 
        Remote non-stop mode support.
index 86c5e9116936e505fa0e68b361280e333f5f900b..ec6d8cf8bc3c5e0bc18b73dee57c2d71efc7c139 100644 (file)
@@ -434,21 +434,18 @@ startup_inferior (int ntraps)
     {
       int resume_signal = TARGET_SIGNAL_0;
       ptid_t resume_ptid;
+      ptid_t event_ptid;
 
       struct target_waitstatus ws;
       memset (&ws, 0, sizeof (ws));
-      resume_ptid = target_wait (pid_to_ptid (-1), &ws);
+      event_ptid = target_wait (pid_to_ptid (-1), &ws);
 
-      /* Mark all threads non-executing.  */
-      set_executing (pid_to_ptid (-1), 0);
-
-      /* In all-stop mode, resume all threads.  */
-      if (!non_stop)
-       resume_ptid = pid_to_ptid (-1);
+      if (ws.kind == TARGET_WAITKIND_IGNORE)
+       /* The inferior didn't really stop, keep waiting.  */
+       continue;
 
       switch (ws.kind)
        {
-         case TARGET_WAITKIND_IGNORE:
          case TARGET_WAITKIND_SPURIOUS:
          case TARGET_WAITKIND_LOADED:
          case TARGET_WAITKIND_FORKED:
@@ -456,6 +453,7 @@ startup_inferior (int ntraps)
          case TARGET_WAITKIND_SYSCALL_ENTRY:
          case TARGET_WAITKIND_SYSCALL_RETURN:
            /* Ignore gracefully during startup of the inferior.  */
+           switch_to_thread (event_ptid);
            break;
 
          case TARGET_WAITKIND_SIGNALLED:
@@ -480,13 +478,21 @@ startup_inferior (int ntraps)
            /* Handle EXEC signals as if they were SIGTRAP signals.  */
            xfree (ws.value.execd_pathname);
            resume_signal = TARGET_SIGNAL_TRAP;
+           switch_to_thread (event_ptid);
            break;
 
          case TARGET_WAITKIND_STOPPED:
            resume_signal = ws.value.sig;
+           switch_to_thread (event_ptid);
            break;
        }
 
+      /* In all-stop mode, resume all threads.  */
+      if (!non_stop)
+       resume_ptid = pid_to_ptid (-1);
+      else
+       resume_ptid = event_ptid;
+
       if (resume_signal != TARGET_SIGNAL_TRAP)
        {
          /* Let shell child handle its own signals in its own way.  */
@@ -519,6 +525,11 @@ startup_inferior (int ntraps)
          target_resume (resume_ptid, 0, TARGET_SIGNAL_0);
        }
     }
+
+  /* Mark all threads non-executing.  */
+  set_executing (pid_to_ptid (-1), 0);
+
+  stop_pc = read_pc ();
 }
 
 /* Implement the "unset exec-wrapper" command.  */