* config/nm-linux.h (linux_record_stopped_pid): New prototype.
authorDaniel Jacobowitz <drow@false.org>
Wed, 18 Jun 2003 23:33:31 +0000 (23:33 +0000)
committerDaniel Jacobowitz <drow@false.org>
Wed, 18 Jun 2003 23:33:31 +0000 (23:33 +0000)
* lin-lwp.c (child_wait): Call linux_record_stopped_pid.
(lin_lwp_wait): Likewise.  Update comments.
* linux-nat.c (struct simple_pid_list, add_to_pid_list)
(pull_pid_from_list, linux_record_stopped_pid): New.

gdb/ChangeLog
gdb/config/nm-linux.h
gdb/lin-lwp.c
gdb/linux-nat.c

index b8ed3a1110f50720a981488096e59749d2f6fe9b..d86c33ac144dc0b1c28ef1807962b93e9a9784df 100644 (file)
@@ -1,3 +1,11 @@
+2003-06-18  Daniel Jacobowitz  <drow@mvista.com>
+
+       * config/nm-linux.h (linux_record_stopped_pid): New prototype.
+       * lin-lwp.c (child_wait): Call linux_record_stopped_pid.
+       (lin_lwp_wait): Likewise.  Update comments.
+       * linux-nat.c (struct simple_pid_list, add_to_pid_list)
+       (pull_pid_from_list, linux_record_stopped_pid): New.
+
 2003-06-17  Stephane Carrez  <stcarrez@nerim.fr>
 
        * ada-lang.c (scan_discrim_bound): Name first argument.
index 7e0a076210a185264c2c94d75de9fe9472815662..6890cca56fd3020bb912475c40fca810de8718c9 100644 (file)
@@ -78,6 +78,8 @@ extern int linux_proc_xfer_memory (CORE_ADDR addr, char *myaddr, int len,
                                   int write, struct mem_attrib *attrib,
                                   struct target_ops *target);
 
+extern void linux_record_stopped_pid (int pid);
+
 #define CHILD_INSERT_FORK_CATCHPOINT
 #define CHILD_INSERT_VFORK_CATCHPOINT
 #define CHILD_INSERT_EXEC_CATCHPOINT
index 48fd51673dafd804d1db61b19f6a9530449146a6..25c06eb4a10928327510c1fe063513ae9b9ee19b 100644 (file)
@@ -1109,6 +1109,23 @@ child_wait (ptid_t ptid, struct target_waitstatus *ourstatus)
          save_errno = EINTR;
        }
 
+      /* Check for stop events reported by a process we didn't already
+        know about - in this case, anything other than inferior_ptid.
+
+        If we're expecting to receive stopped processes after fork,
+        vfork, and clone events, then we'll just add the new one to
+        our list and go back to waiting for the event to be reported
+        - the stopped process might be returned from waitpid before
+        or after the event is.  If we want to handle debugging of
+        CLONE_PTRACE processes we need to do more here, i.e. switch
+        to multi-threaded mode.  */
+      if (pid != -1 && WIFSTOPPED (status) && WSTOPSIG (status) == SIGSTOP
+         && pid != GET_PID (inferior_ptid))
+       {
+         pid = -1;
+         save_errno = EINTR;
+       }
+
       clear_sigio_trap ();
       clear_sigint_trap ();
     }
@@ -1272,6 +1289,22 @@ retry:
 
          lp = find_lwp_pid (pid_to_ptid (lwpid));
 
+         /* Check for stop events reported by a process we didn't
+            already know about - anything not already in our LWP
+            list.
+
+            If we're expecting to receive stopped processes after
+            fork, vfork, and clone events, then we'll just add the
+            new one to our list and go back to waiting for the event
+            to be reported - the stopped process might be returned
+            from waitpid before or after the event is.  */
+         if (WIFSTOPPED (status) && !lp)
+           {
+             linux_record_stopped_pid (lwpid);
+             status = 0;
+             continue;
+           }
+
          /* Make sure we don't report an event for the exit of an LWP not in
             our list, i.e.  not part of the current process.  This can happen
             if we detach from a program we original forked and then it
@@ -1282,6 +1315,13 @@ retry:
              continue;
            }
 
+         /* NOTE drow/2003-06-17: This code seems to be meant for debugging
+            CLONE_PTRACE processes which do not use the thread library -
+            otherwise we wouldn't find the new LWP this way.  That doesn't
+            currently work, and the following code is currently unreachable
+            due to the two blocks above.  If it's fixed some day, this code
+            should be broken out into a function so that we can also pick up
+            LWPs from the new interface.  */
          if (!lp)
            {
              lp = add_lwp (BUILD_LWP (lwpid, GET_PID (inferior_ptid)));
index 046544d1d3c6639127140204f4164e2418abc951..bef737b92a9bbcf178d3c059e28bca69b2fe8395 100644 (file)
 #define __WALL          0x40000000 /* Wait for any child.  */
 #endif
 
+struct simple_pid_list
+{
+  int pid;
+  struct simple_pid_list *next;
+};
+struct simple_pid_list *stopped_pids;
+
 /* This variable is a tri-state flag: -1 for unknown, 0 if PTRACE_O_TRACEFORK
    can not be used, 1 if it can.  */
 
 static int linux_supports_tracefork_flag = -1;
 
+\f
+/* Trivial list manipulation functions to keep track of a list of
+   new stopped processes.  */
+static void
+add_to_pid_list (struct simple_pid_list **listp, int pid)
+{
+  struct simple_pid_list *new_pid = xmalloc (sizeof (struct simple_pid_list));
+  new_pid->pid = pid;
+  new_pid->next = *listp;
+  *listp = new_pid;
+}
+
+static int
+pull_pid_from_list (struct simple_pid_list **listp, int pid)
+{
+  struct simple_pid_list **p;
+
+  for (p = listp; *p != NULL; p = &(*p)->next)
+    if ((*p)->pid == pid)
+      {
+       struct simple_pid_list *next = (*p)->next;
+       xfree (*p);
+       *p = next;
+       return 1;
+      }
+  return 0;
+}
+
+void
+linux_record_stopped_pid (int pid)
+{
+  add_to_pid_list (&stopped_pids, pid);
+}
+
 \f
 /* A helper function for linux_test_for_tracefork, called after fork ().  */
 
This page took 0.05986 seconds and 4 git commands to generate.