* procfs.c (procfs_wait): Losing Unixware can't do poll on /proc
authorStu Grossman <grossman@cygnus>
Sun, 17 Oct 1993 01:02:57 +0000 (01:02 +0000)
committerStu Grossman <grossman@cygnus>
Sun, 17 Oct 1993 01:02:57 +0000 (01:02 +0000)
files.  Use PIOCWSTOP instead.
* corelow.c (add_to_thread_list):  Fix arg to match prototype.

gdb/ChangeLog
gdb/corelow.c
gdb/procfs.c

index cbbb68a..578a35e 100644 (file)
@@ -1,5 +1,9 @@
 Sat Oct 16 15:27:10 1993  Stu Grossman  (grossman at cygnus.com)
 
+       * procfs.c (procfs_wait):  Losing Unixware can't do poll on /proc
+       files.  Use PIOCWSTOP instead.
+       * corelow.c (add_to_thread_list):  Fix arg to match prototype.
+
        * procfs.c (procfs_set_sproc_trap):  Don't use this if sproc
        isn't available.
        * (procfs_notice_signals):  Fix prototype.
index 1e803ef..407940c 100644 (file)
@@ -84,12 +84,13 @@ solib_add_stub (from_tty)
    list of threads in a core file.  */
 
 static void
-add_to_thread_list (abfd, asect, reg_sect)
+add_to_thread_list (abfd, asect, reg_sect_arg)
      bfd *abfd;
      asection *asect;
-     asection *reg_sect;
+     PTR reg_sect_arg;
 {
   int thread_id;
+  asection *reg_sect = reg_sect_arg;
 
   if (strncmp (bfd_section_name (abfd, asect), ".reg/", 5) != 0)
     return;
index fb5970d..a18cc18 100644 (file)
@@ -483,6 +483,24 @@ find_procinfo (pid, okfail)
 
 /*
 
+LOCAL MACRO
+
+       current_procinfo -- convert inferior_pid to a struct procinfo
+
+SYNOPSIS
+
+       static struct procinfo * current_procinfo;
+
+DESCRIPTION
+       
+       Looks up inferior_pid in the procinfo chain.  Always returns a
+       struct procinfo *.  If process can't be found, we error() out.
+ */
+
+#define current_procinfo find_procinfo (inferior_pid, 0)
+
+/*
+
 LOCAL FUNCTION
 
        add_fd -- Add the fd to the poll/select list
@@ -540,23 +558,68 @@ remove_fd (pi)
     }
 }
 
-/*
+#define LOSING_POLL unixware_sux
 
-LOCAL MACRO
+static struct procinfo *
+wait_fd ()
+{
+  struct procinfo *pi;
+  int num_fds;
+  int i;
 
-       current_procinfo -- convert inferior_pid to a struct procinfo
+  if (attach_flag)
+    set_sigint_trap ();        /* Causes SIGINT to be passed on to the
+                          attached process. */
 
-SYNOPSIS
+#ifndef LOSING_POLL
+  num_fds = poll (poll_list, num_poll_list, -1);
+#else
+  pi = current_procinfo;
 
-       static struct procinfo * current_procinfo;
+  if (ioctl (pi->fd, PIOCWSTOP, &pi->prstatus) < 0)
+    {
+      print_sys_errmsg (pi->pathname, errno);
+      error ("PIOCWSTOP failed");
+    }
+#endif  
+  
+  if (attach_flag)
+    clear_sigint_trap();
 
-DESCRIPTION
-       
-       Looks up inferior_pid in the procinfo chain.  Always returns a
-       struct procinfo *.  If process can't be found, we error() out.
- */
+#ifndef LOSING_POLL
 
-#define current_procinfo find_procinfo (inferior_pid, 0)
+  if (num_fds <= 0)
+    {
+      print_sys_errmsg ("poll failed\n", errno);
+      error ("Poll failed, returned %d", num_fds);
+    }
+
+  for (i = 0; i < num_poll_list && num_fds > 0; i++)
+    {
+      if ((poll_list[i].revents & (POLLPRI|POLLERR|POLLHUP|POLLNVAL)) == 0)
+       continue;
+      for (pi = procinfo_list; pi; pi = pi->next)
+       {
+         if (poll_list[i].fd == pi->fd)
+           {
+             if (ioctl (pi->fd, PIOCSTATUS, &pi->prstatus) < 0)
+               {
+                 print_sys_errmsg (pi->pathname, errno);
+                 error ("PIOCSTATUS failed");
+               }
+             num_fds--;
+             pi->had_event = 1;
+             break;
+           }
+       }
+      if (!pi)
+       error ("procfs_wait: Couldn't find procinfo for fd %d\n",
+              poll_list[i].fd);
+    }
+#endif /* LOSING_POLL */
+
+  return pi;
+}
 
 /*
 
@@ -2163,46 +2226,7 @@ procfs_wait (pid, statloc)
 wait_again:
 
   if (!pi)
-    {
-      int num_fds;
-      int i;
-
-      if (attach_flag)
-       set_sigint_trap();      /* Causes SIGINT to be passed on to the
-                                  attached process. */
-
-      num_fds = poll (poll_list, num_poll_list, -1);
-  
-      if (attach_flag)
-       clear_sigint_trap();
-
-      if (num_fds <= 0)
-       {
-         print_sys_errmsg (pi->pathname, errno);
-         error ("poll failed, returned %d\n", num_fds);
-       }
-
-      for (i = 0; i < num_poll_list && num_fds > 0; i++)
-       {
-         if ((poll_list[i].revents & (POLLPRI|POLLERR|POLLHUP|POLLNVAL)) == 0)
-           continue;
-         for (pi = procinfo_list; pi; pi = pi->next)
-           {
-             if (poll_list[i].fd == pi->fd)
-               {
-                 if (ioctl (pi->fd, PIOCSTATUS, &pi->prstatus) < 0)
-                   checkerr++;
-                 /*                perror_with_name (pi->pathname);*/
-                 num_fds--;
-                 pi->had_event = 1;
-                 break;
-               }
-           }
-         if (!pi)
-           error ("procfs_wait: Couldn't find procinfo for fd %d\n",
-                  poll_list[i].fd);
-       }
-    }
+    pi = wait_fd ();
 
   if (pid != -1)
     for (pi = procinfo_list; pi; pi = pi->next)