From 7c5d526e1f7183353e8ede9612ca7edd0b06b1ce Mon Sep 17 00:00:00 2001 From: Stu Grossman Date: Sun, 17 Oct 1993 01:02:57 +0000 Subject: [PATCH] * 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. --- gdb/ChangeLog | 4 ++ gdb/corelow.c | 5 +- gdb/procfs.c | 126 ++++++++++++++++++++++++++++++-------------------- 3 files changed, 82 insertions(+), 53 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index cbbb68a0c22..578a35e67cf 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -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. diff --git a/gdb/corelow.c b/gdb/corelow.c index 1e803efea3a..407940c961f 100644 --- a/gdb/corelow.c +++ b/gdb/corelow.c @@ -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; diff --git a/gdb/procfs.c b/gdb/procfs.c index fb5970d666f..a18cc181430 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) -- 2.30.2