26 #if defined (HAVE_POLL_H)
28 #elif defined (HAVE_SYS_POLL_H)
33 #include <sys/types.h>
41 #define GDB_READABLE (1<<1)
42 #define GDB_WRITABLE (1<<2)
43 #define GDB_EXCEPTION (1<<3)
273 static int event_source_head = 0;
274 const int number_of_sources = 3;
285 for (current = 0; current < number_of_sources; current++)
289 switch (event_source_head)
306 "unexpected event_source_head %d",
311 if (event_source_head == number_of_sources)
312 event_source_head = 0;
368 (*after_char_processing_hook) ();
404 if (poll (&fds, 1, 0) == 1 && (fds.revents & POLLNVAL))
408 _(
"use_poll without HAVE_POLL"));
417 _(
"use_poll without HAVE_POLL"));
447 for (file_ptr =
gdb_notifier.first_file_handler; file_ptr != NULL;
450 if (file_ptr->
fd == fd)
456 if (file_ptr == NULL)
472 * sizeof (
struct pollfd)));
475 (
struct pollfd *)
xmalloc (
sizeof (
struct pollfd));
481 _(
"use_poll without HAVE_POLL"));
506 file_ptr->
proc = proc;
508 file_ptr->
mask = mask;
545 struct pollfd *new_poll_fds;
550 for (file_ptr =
gdb_notifier.first_file_handler; file_ptr != NULL;
553 if (file_ptr->
fd == fd)
557 if (file_ptr == NULL)
566 new_poll_fds = (
struct pollfd *)
573 (new_poll_fds + j)->fd = (
gdb_notifier.poll_fds + i)->fd;
574 (new_poll_fds + j)->events = (
gdb_notifier.poll_fds + i)->events;
575 (new_poll_fds + j)->revents
585 _(
"use_poll without HAVE_POLL"));
671 error_mask = POLLHUP | POLLERR | POLLNVAL;
672 mask = ready_mask & (file_ptr->
mask | error_mask);
674 if ((mask & (POLLERR | POLLNVAL)) != 0)
690 _(
"use_poll without HAVE_POLL"));
698 "on fd %d\n"), file_ptr->
fd);
703 mask = ready_mask & file_ptr->
mask;
751 if (num_found == -1 && errno != EINTR)
755 _(
"use_poll without HAVE_POLL"));
760 struct timeval select_timeout;
761 struct timeval *timeout_p;
768 memset (&select_timeout, 0,
sizeof (select_timeout));
838 _(
"use_poll without HAVE_POLL"));
880 async_handler_ptr->
ready = 0;
882 async_handler_ptr->
proc = proc;
889 return async_handler_ptr;
908 async_handler_ptr->
ready = 1;
916 async_handler_ptr->
ready = 0;
924 return async_handler_ptr->
ready;
940 async_handler_ptr != NULL;
943 if (async_handler_ptr->
ready)
946 if (async_handler_ptr == NULL)
949 async_handler_ptr->
ready = 0;
972 while (prev_ptr && prev_ptr->
next_handler != (*async_handler_ptr))
979 xfree ((*async_handler_ptr));
980 (*async_handler_ptr) = NULL;
1013 async_handler_ptr->
ready = 1;
1021 async_handler_ptr->
ready = 0;
1033 async_handler_ptr != NULL;
1036 if (async_handler_ptr->
ready)
1038 async_handler_ptr->
ready = 0;
1057 = (*async_handler_ptr)->next_handler;
1064 while (prev_ptr && prev_ptr->
next_handler != *async_handler_ptr)
1071 xfree (*async_handler_ptr);
1072 *async_handler_ptr = NULL;
1083 struct gdb_timer *timer_ptr, *timer_index, *prev_timer;
1084 struct timeval time_now, delta;
1087 delta.tv_sec = milliseconds / 1000;
1089 delta.tv_usec = (milliseconds % 1000) * 1000;
1091 gettimeofday (&time_now, NULL);
1094 timer_ptr->
when.tv_sec = time_now.tv_sec + delta.tv_sec;
1095 timer_ptr->
when.tv_usec = time_now.tv_usec + delta.tv_usec;
1097 if (timer_ptr->
when.tv_usec >= 1000000)
1099 timer_ptr->
when.tv_sec += 1;
1100 timer_ptr->
when.tv_usec -= 1000000;
1111 timer_index != NULL;
1112 timer_index = timer_index->
next)
1116 if ((timer_index->
when.tv_sec > timer_ptr->
when.tv_sec)
1117 || ((timer_index->
when.tv_sec == timer_ptr->
when.tv_sec)
1118 && (timer_index->
when.tv_usec > timer_ptr->
when.tv_usec)))
1131 prev_timer->
next != timer_index;
1132 prev_timer = prev_timer->
next)
1135 prev_timer->
next = timer_ptr;
1136 timer_ptr->
next = timer_index;
1148 struct gdb_timer *timer_ptr, *prev_timer = NULL;
1152 for (timer_ptr =
timer_list.first_timer; timer_ptr != NULL;
1153 timer_ptr = timer_ptr->
next)
1159 if (timer_ptr == NULL)
1167 prev_timer->
next != timer_ptr;
1168 prev_timer = prev_timer->
next)
1170 prev_timer->
next = timer_ptr->
next;
1183 struct timeval time_now, delta;
1187 gettimeofday (&time_now, NULL);
1188 delta.tv_sec =
timer_list.first_timer->when.tv_sec - time_now.tv_sec;
1189 delta.tv_usec =
timer_list.first_timer->when.tv_usec - time_now.tv_usec;
1191 if (delta.tv_usec < 0)
1194 delta.tv_usec += 1000000;
1199 if (
timer_list.first_timer->when.tv_sec < time_now.tv_sec
1200 || (
timer_list.first_timer->when.tv_sec == time_now.tv_sec
1201 &&
timer_list.first_timer->when.tv_usec < time_now.tv_usec))
1215 _(
"use_poll without HAVE_POLL"));
1225 if (delta.tv_sec == 0 && delta.tv_usec == 0)
1257 (
proc) (client_data);
void( sig_handler_func)(gdb_client_data)
void( event_handler_func)(event_data)
void start_event_loop(void)
void( timer_handler_func)(gdb_client_data)
void(* after_char_processing_hook)(void)
async_event_handler_func * proc
void clear_async_signal_handler(async_signal_handler *async_handler_ptr)
static void handle_file_event(file_handler *file_ptr, int ready_mask)
async_signal_handler * last_handler
file_handler * next_file_handler
void async_enable_stdin(void)
void mark_async_signal_handler(async_signal_handler *async_handler_ptr)
struct gdb_timer * first_timer
static struct @65 gdb_notifier
struct ui_file * gdb_stdout
void call_async_signal_handler(struct async_signal_handler *handler)
void internal_error(const char *file, int line, const char *fmt,...)
void delete_async_event_handler(async_event_handler **async_handler_ptr)
struct file_handler * next_file
static struct @68 async_event_handler_list
void mark_async_event_handler(async_event_handler *async_handler_ptr)
void( async_event_handler_func)(gdb_client_data)
static int update_wait_timeout(void)
void add_file_handler(int fd, handler_func *proc, gdb_client_data client_data)
struct timeval select_timeout
static file_handler * get_next_file_handler_to_handle_and_advance(void)
#define CATCH(EXCEPTION, MASK)
file_handler * first_file_handler
int async_signal_handler_is_marked(async_signal_handler *async_handler_ptr)
void exception_print(struct ui_file *file, struct gdb_exception e)
static unsigned char use_poll
async_event_handler * create_async_event_handler(async_event_handler_func *proc, gdb_client_data client_data)
static int gdb_wait_for_event(int)
struct gdb_event * gdb_event_p
event_handler_func * proc
async_signal_handler * create_async_signal_handler(sig_handler_func *proc, gdb_client_data client_data)
int gdb_select(int n, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout)
static int poll_timers(void)
void printf_unfiltered(const char *format,...)
struct file_handler file_handler
struct async_signal_handler * next_handler
PTR xrealloc(PTR ptr, size_t size)
void( handler_func)(int, gdb_client_data)
static void create_file_handler(int fd, int mask, handler_func *proc, gdb_client_data client_data)
int create_timer(int milliseconds, timer_handler_func *proc, gdb_client_data client_data)
void void void void void void void void void perror_with_name(const char *string) ATTRIBUTE_NORETURN
gdb_client_data client_data
struct async_event_handler * next_handler
int gdb_do_one_event(void)
struct ui_file * gdb_stderr
static int invoke_async_signal_handlers(void)
async_signal_handler * first_handler
struct async_signal_handler async_signal_handler
gdb_client_data client_data
void delete_timer(int id)
union event_data event_data
void clear_async_event_handler(async_event_handler *async_handler_ptr)
void observer_notify_command_error(void)
timer_handler_func * proc
void gdb_flush(struct ui_file *file)
static int check_async_event_handlers(void)
void delete_async_signal_handler(async_signal_handler **async_handler_ptr)
gdb_client_data client_data
void delete_file_handler(int fd)
gdb_client_data client_data
struct async_event_handler async_event_handler
static struct @67 sighandler_list
static struct @66 timer_list