aboutsummaryrefslogtreecommitdiff
path: root/gdb/procfs.c
diff options
context:
space:
mode:
authorStu Grossman <grossman@cygnus>1993-10-17 01:02:57 +0000
committerStu Grossman <grossman@cygnus>1993-10-17 01:02:57 +0000
commit7c5d526e1f7183353e8ede9612ca7edd0b06b1ce (patch)
treec82d531c3c04782e5ef8fea6706412c1f712b42a /gdb/procfs.c
parent952a820e43deb9f8c794bbd3d8349fdaddfed2da (diff)
downloadfsf-binutils-gdb-7c5d526e1f7183353e8ede9612ca7edd0b06b1ce.zip
fsf-binutils-gdb-7c5d526e1f7183353e8ede9612ca7edd0b06b1ce.tar.gz
fsf-binutils-gdb-7c5d526e1f7183353e8ede9612ca7edd0b06b1ce.tar.bz2
* 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.
Diffstat (limited to 'gdb/procfs.c')
-rw-r--r--gdb/procfs.c126
1 files changed, 75 insertions, 51 deletions
diff --git a/gdb/procfs.c b/gdb/procfs.c
index fb5970d..a18cc18 100644
--- a/gdb/procfs.c
+++ b/gdb/procfs.c
@@ -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)