2012-03-02 Pedro Alves <palves@redhat.com>
authorPedro Alves <palves@redhat.com>
Fri, 2 Mar 2012 16:23:42 +0000 (16:23 +0000)
committerPedro Alves <palves@redhat.com>
Fri, 2 Mar 2012 16:23:42 +0000 (16:23 +0000)
* inferiors.c (add_pid_to_list, pull_pid_from_list): Delete.
* linux-low.c (struct simple_pid_list): New.
(stopped_pids): New a struct simple_pid_list pointer.
(add_to_pid_list, pull_pid_from_list): New.
(handle_extended_wait): Don't assume the first signal new children
report is SIGSTOP.  Adjust call to pull_pid_from_list.
(linux_wait_for_lwp): Adjust.

gdb/gdbserver/ChangeLog
gdb/gdbserver/inferiors.c
gdb/gdbserver/linux-low.c
gdb/gdbserver/server.h

index 2b9558b3e427c57ff6dbe713f6c2eba4454d533e..c1baa9f5b3cbac93ea928124b560a2d6589154bf 100644 (file)
@@ -1,3 +1,13 @@
+2012-03-02  Pedro Alves  <palves@redhat.com>
+
+       * inferiors.c (add_pid_to_list, pull_pid_from_list): Delete.
+       * linux-low.c (struct simple_pid_list): New.
+       (stopped_pids): New a struct simple_pid_list pointer.
+       (add_to_pid_list, pull_pid_from_list): New.
+       (handle_extended_wait): Don't assume the first signal new children
+       report is SIGSTOP.  Adjust call to pull_pid_from_list.
+       (linux_wait_for_lwp): Adjust.
+
 2012-03-02  Yao Qi  <yao@codesourcery.com>
 
        * tracepoint.c (do_action_at_tracepoint): Write `stop_pc' in
index ba5cb10c29603e772c81d8a3424ef7a725426eee..2b9169a3e44fc8a04b43d1af4d3c447d69545074 100644 (file)
@@ -239,35 +239,6 @@ clear_inferiors (void)
   current_inferior = NULL;
 }
 
-/* Two utility functions for a truly degenerate inferior_list: a simple
-   PID listing.  */
-
-void
-add_pid_to_list (struct inferior_list *list, unsigned long pid)
-{
-  struct inferior_list_entry *new_entry;
-
-  new_entry = xmalloc (sizeof (struct inferior_list_entry));
-  new_entry->id = pid_to_ptid (pid);
-  add_inferior_to_list (list, new_entry);
-}
-
-int
-pull_pid_from_list (struct inferior_list *list, unsigned long pid)
-{
-  struct inferior_list_entry *new_entry;
-
-  new_entry = find_inferior_id (list, pid_to_ptid (pid));
-  if (new_entry == NULL)
-    return 0;
-  else
-    {
-      remove_inferior (list, new_entry);
-      free (new_entry);
-      return 1;
-    }
-}
-
 struct process_info *
 add_process (int pid, int attached)
 {
index bc14ec317f33267738acd1b119b79707a95fc1a7..7638ca334d45ba2fd0c85a5700e242f395cd7671 100644 (file)
 
 struct inferior_list all_lwps;
 
-/* A list of all unknown processes which receive stop signals.  Some other
-   process will presumably claim each of these as forked children
-   momentarily.  */
+/* A list of all unknown processes which receive stop signals.  Some
+   other process will presumably claim each of these as forked
+   children momentarily.  */
 
-struct inferior_list stopped_pids;
+struct simple_pid_list
+{
+  /* The process ID.  */
+  int pid;
+
+  /* The status as reported by waitpid.  */
+  int status;
+
+  /* Next in chain.  */
+  struct simple_pid_list *next;
+};
+struct simple_pid_list *stopped_pids;
+
+/* 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, int status)
+{
+  struct simple_pid_list *new_pid = xmalloc (sizeof (struct simple_pid_list));
+
+  new_pid->pid = pid;
+  new_pid->status = status;
+  new_pid->next = *listp;
+  *listp = new_pid;
+}
+
+static int
+pull_pid_from_list (struct simple_pid_list **listp, int pid, int *statusp)
+{
+  struct simple_pid_list **p;
+
+  for (p = listp; *p != NULL; p = &(*p)->next)
+    if ((*p)->pid == pid)
+      {
+       struct simple_pid_list *next = (*p)->next;
+
+       *statusp = (*p)->status;
+       xfree (*p);
+       *p = next;
+       return 1;
+      }
+  return 0;
+}
 
 /* FIXME this is a bit of a hack, and could be removed.  */
 int stopping_threads;
@@ -353,12 +396,12 @@ handle_extended_wait (struct lwp_info *event_child, int wstat)
     {
       ptid_t ptid;
       unsigned long new_pid;
-      int ret, status = W_STOPCODE (SIGSTOP);
+      int ret, status;
 
       ptrace (PTRACE_GETEVENTMSG, lwpid_of (event_child), 0, &new_pid);
 
       /* If we haven't already seen the new PID stop, wait for it now.  */
-      if (! pull_pid_from_list (&stopped_pids, new_pid))
+      if (!pull_pid_from_list (&stopped_pids, new_pid, &status))
        {
          /* The new child has a pending SIGSTOP.  We can't affect it until it
             hits the SIGSTOP, but we're already attached.  */
@@ -1170,7 +1213,7 @@ retry:
      was reported to us by the kernel.  Save its PID.  */
   if (child == NULL && WIFSTOPPED (*wstatp))
     {
-      add_pid_to_list (&stopped_pids, ret);
+      add_to_pid_list (&stopped_pids, ret, *wstatp);
       goto retry;
     }
   else if (child == NULL)
index 30d608cec07c1d0a5780824300f464d4a56356e4..22b3125485401a851ce95774f0862973eac57607 100644 (file)
@@ -279,8 +279,6 @@ void *inferior_target_data (struct thread_info *);
 void set_inferior_target_data (struct thread_info *, void *);
 void *inferior_regcache_data (struct thread_info *);
 void set_inferior_regcache_data (struct thread_info *, void *);
-void add_pid_to_list (struct inferior_list *list, unsigned long pid);
-int pull_pid_from_list (struct inferior_list *list, unsigned long pid);
 
 void loaded_dll (const char *name, CORE_ADDR base_addr);
 void unloaded_dll (const char *name, CORE_ADDR base_addr);
This page took 0.033472 seconds and 4 git commands to generate.