public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [RFC 00/17] Merge event loop implementations
@ 2019-02-24 16:51 Tom Tromey
  2019-02-24 16:52 ` [RFC 13/17] Switch gdbserver to common event loop Tom Tromey
                   ` (18 more replies)
  0 siblings, 19 replies; 52+ messages in thread
From: Tom Tromey @ 2019-02-24 16:51 UTC (permalink / raw)
  To: gdb-patches

This series merges the gdb and gdbserver forks of event-loop.[ch].

This is an RFC because there are a few possibly unresolved issues.

Most of the patches are straightforward.  The series begins by tidying
up the gdb event-loop code, removing things that are specific to gdb.
Then, the code is moved.  After this, gdbserver is switched to use the
common code; and finally, a few cleanups are applied.

I initially attempted something more ambitious here: unifying the
async event and async signal code in event-loop (as I do not
understand the reason for the difference); and then further handling
the async signal code using the same code path as ordinary file
descriptors.

However, this didn't work, and since it was not directly important to
my goal of merging event loops, I dropped it.  I think it may be worth
reviving.  For example I think th async event code suffers from the
same race that led Pedro to change the async signal code to use a the
self-pipe trick.

Another related possible to-do item is changing the ser-event code to
maintain just a single self-pipe.  It seems to me that there's never a
reason to need more than one.

create_file_handler may have a latent bug where the global select
masks are not updated if it is called a second time for the same file
descriptor.  Both versions of the event loop have this issue; I didn't
try to verify it, so perhaps I'm just misunderstanding the code here.

The final patch simplifies the rather convoluted handling of "serial"
(meaning remote protocol) input in gdbserver.  It passes testing, but
I wonder whether there's some subtle reason that the code is written
the way it is.  This is one of the unresolved issues I mentioned.

The second unresolved issue involves the USE_WIN32API code.  Before
this series, gdbserver used gdb_fildes_t, defined like:

    #if USE_WIN32API
    #include <winsock2.h>
    typedef SOCKET gdb_fildes_t;
    #else
    typedef int gdb_fildes_t;
    #endif

gdb did not use this approach, but does have a separate gdb_select
implementation in mingw-hdep.c, which gdbserver does not.

I don't know much about Windows, so I don't know why these things are
needed.  I did a build using " --host=i686-w64-mingw32
--target=i686-w64-mingw32", and everything built just fine using a
POSIX-style API.

Given that, I removed gdb_fildes_t in this series.  However, perhaps
it is still needed and this series needs some more work.  I could use
some advice here -- when is this code actually needed and is there a
way I can reproduce any problems?  I don't have a Windows host, so I'm
hoping for some sort of compile-time error using a mingw cross.

Regression tested by the buildbot.

Tom


^ permalink raw reply	[flat|nested] 52+ messages in thread

* [RFC 13/17] Switch gdbserver to common event loop
  2019-02-24 16:51 [RFC 00/17] Merge event loop implementations Tom Tromey
@ 2019-02-24 16:52 ` Tom Tromey
  2019-02-24 16:52 ` [RFC 15/17] Move gdb_notifier comment Tom Tromey
                   ` (17 subsequent siblings)
  18 siblings, 0 replies; 52+ messages in thread
From: Tom Tromey @ 2019-02-24 16:52 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This changes gdbserver to use the common event loop, removing the
ancient fork.

gdb/gdbserver/ChangeLog
2019-02-24  Tom Tromey  <tom@tromey.com>

	* server.h (handle_serial_event, handle_target_event): Update.
	* server.c: Don't call initialize_event_loop.
	(handle_serial_event): Return void.  Call stop_event_loop.
	(handle_target_event): Return void.
	* remote-utils.c (handle_accept_event): Return void.
	(reset_readchar): Use delete_timer.
	(process_remaining): Return void.
	(reschedule): Use create_timer.
	* event-loop.h: Remove.
	* event-loop.c: Remove.
	* Makefile.in (OBS): Use common/event-loop.o, not event-loop.o.
---
 gdb/gdbserver/ChangeLog      |  14 +
 gdb/gdbserver/Makefile.in    |   2 +-
 gdb/gdbserver/event-loop.c   | 567 -----------------------------------
 gdb/gdbserver/event-loop.h   |  36 ---
 gdb/gdbserver/remote-utils.c |  18 +-
 gdb/gdbserver/server.c       |  14 +-
 gdb/gdbserver/server.h       |   6 +-
 7 files changed, 29 insertions(+), 628 deletions(-)
 delete mode 100644 gdb/gdbserver/event-loop.c
 delete mode 100644 gdb/gdbserver/event-loop.h

diff --git a/gdb/gdbserver/Makefile.in b/gdb/gdbserver/Makefile.in
index f5fc55034ee..66a5940b4ce 100644
--- a/gdb/gdbserver/Makefile.in
+++ b/gdb/gdbserver/Makefile.in
@@ -250,6 +250,7 @@ OBS = \
 	common/common-utils.o \
 	common/errors.o \
 	common/environ.o \
+	common/event-loop.o \
 	common/fileio.o \
 	common/filestuff.o \
 	common/format.o \
@@ -268,7 +269,6 @@ OBS = \
 	common/xml-utils.o \
 	debug.o \
 	dll.o \
-	event-loop.o \
 	hostio.o \
 	inferiors.o \
 	mem-break.o \
diff --git a/gdb/gdbserver/event-loop.c b/gdb/gdbserver/event-loop.c
deleted file mode 100644
index 0442680c237..00000000000
--- a/gdb/gdbserver/event-loop.c
+++ /dev/null
@@ -1,567 +0,0 @@
-/* Event loop machinery for the remote server for GDB.
-   Copyright (C) 1999-2019 Free Software Foundation, Inc.
-
-   This file is part of GDB.
-
-   This program is free software; you can redistribute it and/or modify
-   it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 3 of the License, or
-   (at your option) any later version.
-
-   This program is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-   GNU General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program.  If not, see <http://www.gnu.org/licenses/>. */
-
-/* Based on src/gdb/event-loop.c.  */
-
-#include "server.h"
-
-#include <sys/types.h>
-#include "common/gdb_sys_time.h"
-
-#ifdef USE_WIN32API
-#include <windows.h>
-#include <io.h>
-#endif
-
-#include <unistd.h>
-#include <queue>
-
-typedef int (event_handler_func) (gdb_fildes_t);
-
-/* Tell create_file_handler what events we are interested in.  */
-
-#define GDB_READABLE	(1<<1)
-#define GDB_WRITABLE	(1<<2)
-#define GDB_EXCEPTION	(1<<3)
-
-/* Events are queued by on the event_queue and serviced later
-   on by do_one_event.  An event can be, for instance, a file
-   descriptor becoming ready to be read.  Servicing an event simply
-   means that the procedure PROC will be called.  We have 2 queues,
-   one for file handlers that we listen to in the event loop, and one
-   for the file handlers+events that are ready.  The procedure PROC
-   associated with each event is always the same (handle_file_event).
-   Its duty is to invoke the handler associated with the file
-   descriptor whose state change generated the event, plus doing other
-   cleanups and such.  */
-
-struct gdb_event
-  {
-    /* Procedure to call to service this event.  */
-    event_handler_func *proc;
-
-    /* File descriptor that is ready.  */
-    gdb_fildes_t fd;
-  };
-
-/* Information about each file descriptor we register with the event
-   loop.  */
-
-typedef struct file_handler
-  {
-    /* File descriptor.  */
-    gdb_fildes_t fd;
-
-    /* Events we want to monitor.  */
-    int mask;
-
-    /* Events that have been seen since the last time.  */
-    int ready_mask;
-
-    /* Procedure to call when fd is ready.  */
-    handler_func *proc;
-
-    /* Argument to pass to proc.  */
-    gdb_client_data client_data;
-
-    /* Was an error detected on this fd?  */
-    int error;
-
-    /* Next registered file descriptor.  */
-    struct file_handler *next_file;
-  }
-file_handler;
-
-typedef gdb::unique_xmalloc_ptr<gdb_event> gdb_event_up;
-
-static std::queue<gdb_event_up, std::list<gdb_event_up>> event_queue;
-
-/* Gdb_notifier is just a list of file descriptors gdb is interested
-   in.  These are the input file descriptor, and the target file
-   descriptor.  Each of the elements in the gdb_notifier list is
-   basically a description of what kind of events gdb is interested
-   in, for each fd.  */
-
-static struct
-  {
-    /* Ptr to head of file handler list.  */
-    file_handler *first_file_handler;
-
-    /* Masks to be used in the next call to select.  Bits are set in
-       response to calls to create_file_handler.  */
-    fd_set check_masks[3];
-
-    /* What file descriptors were found ready by select.  */
-    fd_set ready_masks[3];
-
-    /* Number of valid bits (highest fd value + 1). (for select) */
-    int num_fds;
-  }
-gdb_notifier;
-
-/* Callbacks are just routines that are executed before waiting for the
-   next event.  In GDB this is struct gdb_timer.  We don't need timers
-   so rather than copy all that complexity in gdbserver, we provide what
-   we need, but we do so in a way that if/when the day comes that we need
-   that complexity, it'll be easier to add - replace callbacks with timers
-   and use a delta of zero (which is all gdb currently uses timers for anyway).
-
-   PROC will be executed before gdbserver goes to sleep to wait for the
-   next event.  */
-
-struct callback_event
-  {
-    int id;
-    callback_handler_func *proc;
-    gdb_client_data data;
-    struct callback_event *next;
-  };
-
-/* Table of registered callbacks.  */
-
-static struct
-  {
-    struct callback_event *first;
-    struct callback_event *last;
-
-    /* Id of the last callback created.  */
-    int num_callbacks;
-  }
-callback_list;
-
-void
-initialize_event_loop (void)
-{
-}
-
-/* Process one event.  If an event was processed, 1 is returned
-   otherwise 0 is returned.  Scan the queue from head to tail,
-   processing therefore the high priority events first, by invoking
-   the associated event handler procedure.  */
-
-static int
-process_event (void)
-{
-  /* Let's get rid of the event from the event queue.  We need to
-     do this now because while processing the event, since the
-     proc function could end up jumping out to the caller of this
-     function.  In that case, we would have on the event queue an
-     event which has been processed, but not deleted.  */
-  if (!event_queue.empty ())
-    {
-      gdb_event_up event_ptr = std::move (event_queue.front ());
-      event_queue.pop ();
-
-      event_handler_func *proc = event_ptr->proc;
-      gdb_fildes_t fd = event_ptr->fd;
-
-      /* Now call the procedure associated with the event.  */
-      if ((*proc) (fd))
-	return -1;
-      return 1;
-    }
-
-  /* This is the case if there are no event on the event queue.  */
-  return 0;
-}
-
-/* Append PROC to the callback list.
-   The result is the "id" of the callback that can be passed back to
-   delete_callback_event.  */
-
-int
-append_callback_event (callback_handler_func *proc, gdb_client_data data)
-{
-  struct callback_event *event_ptr = XNEW (struct callback_event);
-
-  event_ptr->id = callback_list.num_callbacks++;
-  event_ptr->proc = proc;
-  event_ptr->data = data;
-  event_ptr->next = NULL;
-  if (callback_list.first == NULL)
-    callback_list.first = event_ptr;
-  if (callback_list.last != NULL)
-    callback_list.last->next = event_ptr;
-  callback_list.last = event_ptr;
-  return event_ptr->id;
-}
-
-/* Delete callback ID.
-   It is not an error callback ID doesn't exist.  */
-
-void
-delete_callback_event (int id)
-{
-  struct callback_event **p;
-
-  for (p = &callback_list.first; *p != NULL; p = &(*p)->next)
-    {
-      struct callback_event *event_ptr = *p;
-
-      if (event_ptr->id == id)
-	{
-	  *p = event_ptr->next;
-	  if (event_ptr == callback_list.last)
-	    callback_list.last = NULL;
-	  free (event_ptr);
-	  break;
-	}
-    }
-}
-
-/* Run the next callback.
-   The result is 1 if a callback was called and event processing
-   should continue, -1 if the callback wants the event loop to exit,
-   and 0 if there are no more callbacks.  */
-
-static int
-process_callback (void)
-{
-  struct callback_event *event_ptr;
-
-  event_ptr = callback_list.first;
-  if (event_ptr != NULL)
-    {
-      callback_handler_func *proc = event_ptr->proc;
-      gdb_client_data data = event_ptr->data;
-
-      /* Remove the event before calling PROC,
-	 more events may get added by PROC.  */
-      callback_list.first = event_ptr->next;
-      if (callback_list.first == NULL)
-	callback_list.last = NULL;
-      free  (event_ptr);
-      if ((*proc) (data))
-	return -1;
-      return 1;
-    }
-
-  return 0;
-}
-
-/* Add a file handler/descriptor to the list of descriptors we are
-   interested in.  FD is the file descriptor for the file/stream to be
-   listened to.  MASK is a combination of READABLE, WRITABLE,
-   EXCEPTION.  PROC is the procedure that will be called when an event
-   occurs for FD.  CLIENT_DATA is the argument to pass to PROC.  */
-
-static void
-create_file_handler (gdb_fildes_t fd, int mask, handler_func *proc,
-		     gdb_client_data client_data)
-{
-  file_handler *file_ptr;
-
-  /* Do we already have a file handler for this file? (We may be
-     changing its associated procedure).  */
-  for (file_ptr = gdb_notifier.first_file_handler;
-       file_ptr != NULL;
-       file_ptr = file_ptr->next_file)
-    if (file_ptr->fd == fd)
-      break;
-
-  /* It is a new file descriptor.  Add it to the list.  Otherwise,
-     just change the data associated with it.  */
-  if (file_ptr == NULL)
-    {
-      file_ptr = XNEW (struct file_handler);
-      file_ptr->fd = fd;
-      file_ptr->ready_mask = 0;
-      file_ptr->next_file = gdb_notifier.first_file_handler;
-      gdb_notifier.first_file_handler = file_ptr;
-
-      if (mask & GDB_READABLE)
-	FD_SET (fd, &gdb_notifier.check_masks[0]);
-      else
-	FD_CLR (fd, &gdb_notifier.check_masks[0]);
-
-      if (mask & GDB_WRITABLE)
-	FD_SET (fd, &gdb_notifier.check_masks[1]);
-      else
-	FD_CLR (fd, &gdb_notifier.check_masks[1]);
-
-      if (mask & GDB_EXCEPTION)
-	FD_SET (fd, &gdb_notifier.check_masks[2]);
-      else
-	FD_CLR (fd, &gdb_notifier.check_masks[2]);
-
-      if (gdb_notifier.num_fds <= fd)
-	gdb_notifier.num_fds = fd + 1;
-    }
-
-  file_ptr->proc = proc;
-  file_ptr->client_data = client_data;
-  file_ptr->mask = mask;
-}
-
-/* Wrapper function for create_file_handler.  */
-
-void
-add_file_handler (gdb_fildes_t fd,
-		  handler_func *proc, gdb_client_data client_data)
-{
-  create_file_handler (fd, GDB_READABLE | GDB_EXCEPTION, proc, client_data);
-}
-
-/* Remove the file descriptor FD from the list of monitored fd's:
-   i.e. we don't care anymore about events on the FD.  */
-
-void
-delete_file_handler (gdb_fildes_t fd)
-{
-  file_handler *file_ptr, *prev_ptr = NULL;
-  int i;
-
-  /* Find the entry for the given file. */
-
-  for (file_ptr = gdb_notifier.first_file_handler;
-       file_ptr != NULL;
-       file_ptr = file_ptr->next_file)
-    if (file_ptr->fd == fd)
-      break;
-
-  if (file_ptr == NULL)
-    return;
-
-  if (file_ptr->mask & GDB_READABLE)
-    FD_CLR (fd, &gdb_notifier.check_masks[0]);
-  if (file_ptr->mask & GDB_WRITABLE)
-    FD_CLR (fd, &gdb_notifier.check_masks[1]);
-  if (file_ptr->mask & GDB_EXCEPTION)
-    FD_CLR (fd, &gdb_notifier.check_masks[2]);
-
-  /* Find current max fd.  */
-
-  if ((fd + 1) == gdb_notifier.num_fds)
-    {
-      gdb_notifier.num_fds--;
-      for (i = gdb_notifier.num_fds; i; i--)
-	{
-	  if (FD_ISSET (i - 1, &gdb_notifier.check_masks[0])
-	      || FD_ISSET (i - 1, &gdb_notifier.check_masks[1])
-	      || FD_ISSET (i - 1, &gdb_notifier.check_masks[2]))
-	    break;
-	}
-      gdb_notifier.num_fds = i;
-    }
-
-  /* Deactivate the file descriptor, by clearing its mask, so that it
-     will not fire again.  */
-
-  file_ptr->mask = 0;
-
-  /* Get rid of the file handler in the file handler list.  */
-  if (file_ptr == gdb_notifier.first_file_handler)
-    gdb_notifier.first_file_handler = file_ptr->next_file;
-  else
-    {
-      for (prev_ptr = gdb_notifier.first_file_handler;
-	   prev_ptr->next_file != file_ptr;
-	   prev_ptr = prev_ptr->next_file)
-	;
-      prev_ptr->next_file = file_ptr->next_file;
-    }
-  free (file_ptr);
-}
-
-/* Handle the given event by calling the procedure associated to the
-   corresponding file handler.  Called by process_event indirectly,
-   through event_ptr->proc.  EVENT_FILE_DESC is file descriptor of the
-   event in the front of the event queue.  */
-
-static int
-handle_file_event (gdb_fildes_t event_file_desc)
-{
-  file_handler *file_ptr;
-  int mask;
-
-  /* Search the file handler list to find one that matches the fd in
-     the event.  */
-  for (file_ptr = gdb_notifier.first_file_handler; file_ptr != NULL;
-       file_ptr = file_ptr->next_file)
-    {
-      if (file_ptr->fd == event_file_desc)
-	{
-	  /* See if the desired events (mask) match the received
-	     events (ready_mask).  */
-
-	  if (file_ptr->ready_mask & GDB_EXCEPTION)
-	    {
-	      warning ("Exception condition detected on fd %s",
-		       pfildes (file_ptr->fd));
-	      file_ptr->error = 1;
-	    }
-	  else
-	    file_ptr->error = 0;
-	  mask = file_ptr->ready_mask & file_ptr->mask;
-
-	  /* Clear the received events for next time around.  */
-	  file_ptr->ready_mask = 0;
-
-	  /* If there was a match, then call the handler.  */
-	  if (mask != 0)
-	    {
-	      if ((*file_ptr->proc) (file_ptr->error,
-				     file_ptr->client_data) < 0)
-		return -1;
-	    }
-	  break;
-	}
-    }
-
-  return 0;
-}
-
-/* Create a file event, to be enqueued in the event queue for
-   processing.  The procedure associated to this event is always
-   handle_file_event, which will in turn invoke the one that was
-   associated to FD when it was registered with the event loop.  */
-
-static gdb_event *
-create_file_event (gdb_fildes_t fd)
-{
-  gdb_event *file_event_ptr;
-
-  file_event_ptr = XNEW (gdb_event);
-  file_event_ptr->proc = handle_file_event;
-  file_event_ptr->fd = fd;
-
-  return file_event_ptr;
-}
-
-/* Called by do_one_event to wait for new events on the monitored file
-   descriptors.  Queue file events as they are detected by the poll.
-   If there are no events, this function will block in the call to
-   select.  Return -1 if there are no files descriptors to monitor,
-   otherwise return 0.  */
-
-static int
-wait_for_event (void)
-{
-  file_handler *file_ptr;
-  int num_found = 0;
-
-  /* Make sure all output is done before getting another event.  */
-  fflush (stdout);
-  fflush (stderr);
-
-  if (gdb_notifier.num_fds == 0)
-    return -1;
-
-  gdb_notifier.ready_masks[0] = gdb_notifier.check_masks[0];
-  gdb_notifier.ready_masks[1] = gdb_notifier.check_masks[1];
-  gdb_notifier.ready_masks[2] = gdb_notifier.check_masks[2];
-  num_found = select (gdb_notifier.num_fds,
-		      &gdb_notifier.ready_masks[0],
-		      &gdb_notifier.ready_masks[1],
-		      &gdb_notifier.ready_masks[2],
-		      NULL);
-
-  /* Clear the masks after an error from select.  */
-  if (num_found == -1)
-    {
-      FD_ZERO (&gdb_notifier.ready_masks[0]);
-      FD_ZERO (&gdb_notifier.ready_masks[1]);
-      FD_ZERO (&gdb_notifier.ready_masks[2]);
-#ifdef EINTR
-      /* Dont print anything if we got a signal, let gdb handle
-	 it.  */
-      if (errno != EINTR)
-	perror_with_name ("select");
-#endif
-    }
-
-  /* Enqueue all detected file events.  */
-
-  for (file_ptr = gdb_notifier.first_file_handler;
-       file_ptr != NULL && num_found > 0;
-       file_ptr = file_ptr->next_file)
-    {
-      int mask = 0;
-
-      if (FD_ISSET (file_ptr->fd, &gdb_notifier.ready_masks[0]))
-	mask |= GDB_READABLE;
-      if (FD_ISSET (file_ptr->fd, &gdb_notifier.ready_masks[1]))
-	mask |= GDB_WRITABLE;
-      if (FD_ISSET (file_ptr->fd, &gdb_notifier.ready_masks[2]))
-	mask |= GDB_EXCEPTION;
-
-      if (!mask)
-	continue;
-      else
-	num_found--;
-
-      /* Enqueue an event only if this is still a new event for this
-	 fd.  */
-
-      if (file_ptr->ready_mask == 0)
-	{
-	  gdb_event *file_event_ptr = create_file_event (file_ptr->fd);
-
-	  event_queue.emplace (file_event_ptr);
-	}
-      file_ptr->ready_mask = mask;
-    }
-
-  return 0;
-}
-
-/* Start up the event loop.  This is the entry point to the event
-   loop.  */
-
-void
-start_event_loop (void)
-{
-  /* Loop until there is nothing to do.  This is the entry point to
-     the event loop engine.  If nothing is ready at this time, wait
-     for something to happen (via wait_for_event), then process it.
-     Return when there are no longer event sources to wait for.  */
-
-  while (1)
-    {
-      /* Any events already waiting in the queue?  */
-      int res = process_event ();
-
-      /* Did the event handler want the event loop to stop?  */
-      if (res == -1)
-	return;
-
-      if (res)
-	continue;
-
-      /* Process any queued callbacks before we go to sleep.  */
-      res = process_callback ();
-
-      /* Did the callback want the event loop to stop?  */
-      if (res == -1)
-	return;
-
-      if (res)
-	continue;
-
-      /* Wait for a new event.  If wait_for_event returns -1, we
-	 should get out because this means that there are no event
-	 sources left.  This will make the event loop stop, and the
-	 application exit.  */
-
-      if (wait_for_event () < 0)
-	return;
-    }
-
-  /* We are done with the event loop.  There are no more event sources
-     to listen to.  So we exit gdbserver.  */
-}
diff --git a/gdb/gdbserver/event-loop.h b/gdb/gdbserver/event-loop.h
deleted file mode 100644
index a09a6ad4355..00000000000
--- a/gdb/gdbserver/event-loop.h
+++ /dev/null
@@ -1,36 +0,0 @@
-/* Event loop machinery for the remote server for GDB.
-   Copyright (C) 1993-2019 Free Software Foundation, Inc.
-
-   This file is part of GDB.
-
-   This program is free software; you can redistribute it and/or modify
-   it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 3 of the License, or
-   (at your option) any later version.
-
-   This program is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-   GNU General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
-
-#ifndef GDBSERVER_EVENT_LOOP_H
-#define GDBSERVER_EVENT_LOOP_H
-
-typedef void *gdb_client_data;
-typedef int (handler_func) (int, gdb_client_data);
-typedef int (callback_handler_func) (gdb_client_data);
-
-extern void delete_file_handler (gdb_fildes_t fd);
-extern void add_file_handler (gdb_fildes_t fd, handler_func *proc,
-			      gdb_client_data client_data);
-extern int append_callback_event (callback_handler_func *proc,
-				   gdb_client_data client_data);
-extern void delete_callback_event (int id);
-
-extern void start_event_loop (void);
-extern void initialize_event_loop (void);
-
-#endif /* GDBSERVER_EVENT_LOOP_H */
diff --git a/gdb/gdbserver/remote-utils.c b/gdb/gdbserver/remote-utils.c
index ad0228db99c..bda261a4a9f 100644
--- a/gdb/gdbserver/remote-utils.c
+++ b/gdb/gdbserver/remote-utils.c
@@ -150,7 +150,7 @@ enable_async_notification (int fd)
 #endif
 }
 
-static int
+static void
 handle_accept_event (int err, gdb_client_data client_data)
 {
   struct sockaddr_storage sockaddr;
@@ -219,8 +219,6 @@ handle_accept_event (int err, gdb_client_data client_data)
      until GDB as selected all-stop/non-stop, and has queried the
      threads' status ('?').  */
   target_async (0);
-
-  return 0;
 }
 
 /* Prepare for a later connection to a remote debugger.
@@ -936,27 +934,21 @@ reset_readchar (void)
   readchar_bufcnt = 0;
   if (readchar_callback != NOT_SCHEDULED)
     {
-      delete_callback_event (readchar_callback);
+      delete_timer (readchar_callback);
       readchar_callback = NOT_SCHEDULED;
     }
 }
 
 /* Process remaining data in readchar_buf.  */
 
-static int
+static void
 process_remaining (void *context)
 {
-  int res;
-
   /* This is a one-shot event.  */
   readchar_callback = NOT_SCHEDULED;
 
   if (readchar_bufcnt > 0)
-    res = handle_serial_event (0, NULL);
-  else
-    res = 0;
-
-  return res;
+    handle_serial_event (0, NULL);
 }
 
 /* If there is still data in the buffer, queue another event to process it,
@@ -966,7 +958,7 @@ static void
 reschedule (void)
 {
   if (readchar_bufcnt > 0 && readchar_callback == NOT_SCHEDULED)
-    readchar_callback = append_callback_event (process_remaining, NULL);
+    readchar_callback = create_timer (0, process_remaining, NULL);
 }
 
 /* Read a packet from the remote machine, with error checking,
diff --git a/gdb/gdbserver/server.c b/gdb/gdbserver/server.c
index 1b2b86813fb..42147c1d836 100644
--- a/gdb/gdbserver/server.c
+++ b/gdb/gdbserver/server.c
@@ -3785,7 +3785,6 @@ captured_main (int argc, char *argv[])
   initialize_async_io ();
   initialize_low ();
   have_job_control ();
-  initialize_event_loop ();
   if (target_supports_tracepoints ())
     initialize_tracepoint ();
   initialize_notif ();
@@ -4390,7 +4389,7 @@ process_serial_event (void)
 
 /* Event-loop callback for serial events.  */
 
-int
+void
 handle_serial_event (int err, gdb_client_data client_data)
 {
   if (debug_threads)
@@ -4398,13 +4397,14 @@ handle_serial_event (int err, gdb_client_data client_data)
 
   /* Really handle it.  */
   if (process_serial_event () < 0)
-    return -1;
+    {
+      stop_event_loop ();
+      return;
+    }
 
   /* Be sure to not change the selected thread behind GDB's back.
      Important in the non-stop mode asynchronous protocol.  */
   set_desired_thread ();
-
-  return 0;
 }
 
 /* Push a stop notification on the notification queue.  */
@@ -4422,7 +4422,7 @@ push_stop_notification (ptid_t ptid, struct target_waitstatus *status)
 
 /* Event-loop callback for target events.  */
 
-int
+void
 handle_target_event (int err, gdb_client_data client_data)
 {
   client_state &cs = get_client_state ();
@@ -4499,8 +4499,6 @@ handle_target_event (int err, gdb_client_data client_data)
   /* Be sure to not change the selected thread behind GDB's back.
      Important in the non-stop mode asynchronous protocol.  */
   set_desired_thread ();
-
-  return 0;
 }
 
 /* See common/event-loop.h.  */
diff --git a/gdb/gdbserver/server.h b/gdb/gdbserver/server.h
index 400001addd3..5b359c8bae0 100644
--- a/gdb/gdbserver/server.h
+++ b/gdb/gdbserver/server.h
@@ -85,13 +85,13 @@ typedef SOCKET gdb_fildes_t;
 typedef int gdb_fildes_t;
 #endif
 
-#include "event-loop.h"
+#include "common/event-loop.h"
 
 /* Functions from server.c.  */
 extern void handle_v_requests (char *own_buf, int packet_len,
 			       int *new_packet_len);
-extern int handle_serial_event (int err, gdb_client_data client_data);
-extern int handle_target_event (int err, gdb_client_data client_data);
+extern void handle_serial_event (int err, gdb_client_data client_data);
+extern void handle_target_event (int err, gdb_client_data client_data);
 
 /* Get rid of the currently pending stop replies that match PTID.  */
 extern void discard_queued_stop_replies (ptid_t ptid);
-- 
2.17.2

^ permalink raw reply	[flat|nested] 52+ messages in thread

* [RFC 02/17] Move gdb-specific code out of start_event_loop
  2019-02-24 16:51 [RFC 00/17] Merge event loop implementations Tom Tromey
                   ` (2 preceding siblings ...)
  2019-02-24 16:52 ` [RFC 11/17] Implement event-loop glue for gdbserver Tom Tromey
@ 2019-02-24 16:52 ` Tom Tromey
  2019-09-26 14:02   ` Pedro Alves
  2019-02-24 16:52 ` [RFC 16/17] Remove gdb_fildes_t Tom Tromey
                   ` (14 subsequent siblings)
  18 siblings, 1 reply; 52+ messages in thread
From: Tom Tromey @ 2019-02-24 16:52 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This moves some gdb-specific code out of start_event_loop, into a new
function that must be supplied by the event-loop client.

gdb/ChangeLog
2019-02-24  Tom Tromey  <tom@tromey.com>

	* main.c (handle_event_loop_exception): New function.
	* event-loop.c: Don't include event-top.h or observable.h.
	(start_event_loop): Remove gdb-specific code.  Call
	handle_event_loop_exception.
	* event-loop.h (handle_event_loop_exception): Declare.
---
 gdb/ChangeLog    |  8 ++++++++
 gdb/event-loop.c | 26 ++------------------------
 gdb/event-loop.h |  6 +++++-
 gdb/main.c       | 28 ++++++++++++++++++++++++++++
 4 files changed, 43 insertions(+), 25 deletions(-)

diff --git a/gdb/event-loop.c b/gdb/event-loop.c
index 4d05eb9a243..f41094e9add 100644
--- a/gdb/event-loop.c
+++ b/gdb/event-loop.c
@@ -19,7 +19,6 @@
 
 #include "defs.h"
 #include "event-loop.h"
-#include "event-top.h"
 #include "ser-event.h"
 
 #ifdef HAVE_POLL
@@ -33,7 +32,6 @@
 #include <sys/types.h>
 #include "common/gdb_sys_time.h"
 #include "gdb_select.h"
-#include "observable.h"
 #include "top.h"
 
 /* Tell create_file_handler what events we are interested in.
@@ -355,7 +353,7 @@ gdb_do_one_event (void)
    from the command loop.  */
 
 void
-start_event_loop (void)
+start_event_loop ()
 {
   /* Loop until there is nothing to do.  This is the entry point to
      the event loop engine.  gdb_do_one_event will process one event
@@ -371,27 +369,7 @@ start_event_loop (void)
 	}
       CATCH (ex, RETURN_MASK_ALL)
 	{
-	  exception_print (gdb_stderr, ex);
-
-	  /* If any exception escaped to here, we better enable
-	     stdin.  Otherwise, any command that calls async_disable_stdin,
-	     and then throws, will leave stdin inoperable.  */
-	  async_enable_stdin ();
-	  /* If we long-jumped out of do_one_event, we probably didn't
-	     get around to resetting the prompt, which leaves readline
-	     in a messed-up state.  Reset it here.  */
-	  current_ui->prompt_state = PROMPT_NEEDED;
-	  gdb::observers::command_error.notify ();
-	  /* This call looks bizarre, but it is required.  If the user
-	     entered a command that caused an error,
-	     after_char_processing_hook won't be called from
-	     rl_callback_read_char_wrapper.  Using a cleanup there
-	     won't work, since we want this function to be called
-	     after a new prompt is printed.  */
-	  if (after_char_processing_hook)
-	    (*after_char_processing_hook) ();
-	  /* Maybe better to set a flag to be checked somewhere as to
-	     whether display the prompt or not.  */
+	  handle_event_loop_exception (ex);
 	}
       END_CATCH
 
diff --git a/gdb/event-loop.h b/gdb/event-loop.h
index 99b776618bd..f11b008848d 100644
--- a/gdb/event-loop.h
+++ b/gdb/event-loop.h
@@ -80,7 +80,7 @@ typedef void (timer_handler_func) (gdb_client_data);
 
 /* Exported functions from event-loop.c */
 
-extern void start_event_loop (void);
+extern void start_event_loop ();
 extern int gdb_do_one_event (void);
 extern void delete_file_handler (int fd);
 extern void add_file_handler (int fd, handler_func *proc, 
@@ -131,4 +131,8 @@ extern void clear_async_event_handler (struct async_event_handler *handler);
 
 extern void initialize_async_signal_handlers (void);
 
+/* Must be defined by client.  */
+
+extern void handle_event_loop_exception (const gdb_exception &);
+
 #endif /* EVENT_LOOP_H */
diff --git a/gdb/main.c b/gdb/main.c
index e14dd06fa8c..f60f0d0a092 100644
--- a/gdb/main.c
+++ b/gdb/main.c
@@ -48,6 +48,7 @@
 #include <vector>
 #include "common/pathstuff.h"
 #include "cli/cli-style.h"
+#include "observable.h"
 
 /* The selected interpreter.  This will be used as a set command
    variable, so it should always be malloc'ed - since
@@ -314,6 +315,33 @@ setup_alternate_signal_stack (void)
    here.  */
 static void captured_command_loop () __attribute__((noinline));
 
+/* Called to handle an exception when processing an event.  */
+void
+handle_event_loop_exception (const gdb_exception &ex)
+{
+  exception_print (gdb_stderr, ex);
+
+  /* If any exception escaped to here, we better enable
+     stdin.  Otherwise, any command that calls async_disable_stdin,
+     and then throws, will leave stdin inoperable.  */
+  async_enable_stdin ();
+  /* If we long-jumped out of do_one_event, we probably didn't
+     get around to resetting the prompt, which leaves readline
+     in a messed-up state.  Reset it here.  */
+  current_ui->prompt_state = PROMPT_NEEDED;
+  gdb::observers::command_error.notify ();
+  /* This call looks bizarre, but it is required.  If the user
+     entered a command that caused an error,
+     after_char_processing_hook won't be called from
+     rl_callback_read_char_wrapper.  Using a cleanup there
+     won't work, since we want this function to be called
+     after a new prompt is printed.  */
+  if (after_char_processing_hook)
+    (*after_char_processing_hook) ();
+  /* Maybe better to set a flag to be checked somewhere as to
+     whether display the prompt or not.  */
+}
+
 static void
 captured_command_loop ()
 {
-- 
2.17.2

^ permalink raw reply	[flat|nested] 52+ messages in thread

* [RFC 14/17] Remove some dead code from event-loop.c
  2019-02-24 16:51 [RFC 00/17] Merge event loop implementations Tom Tromey
                   ` (5 preceding siblings ...)
  2019-02-24 16:52 ` [RFC 05/17] Remove gdb_usleep.c Tom Tromey
@ 2019-02-24 16:52 ` Tom Tromey
  2019-02-24 16:52 ` [RFC 12/17] Add the ability to stop the event loop Tom Tromey
                   ` (11 subsequent siblings)
  18 siblings, 0 replies; 52+ messages in thread
From: Tom Tromey @ 2019-02-24 16:52 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This removes some dead code from event-loop.c.

gdb/ChangeLog
2019-02-24  Tom Tromey  <tom@tromey.com>

	* common/event-loop.c (event_data, gdb_event, event_handler_func):
	Remove.
---
 gdb/ChangeLog           |  5 +++++
 gdb/common/event-loop.c | 33 ---------------------------------
 2 files changed, 5 insertions(+), 33 deletions(-)

diff --git a/gdb/common/event-loop.c b/gdb/common/event-loop.c
index b8d5b007163..62de430f067 100644
--- a/gdb/common/event-loop.c
+++ b/gdb/common/event-loop.c
@@ -41,39 +41,6 @@
 #define GDB_WRITABLE	(1<<2)
 #define GDB_EXCEPTION	(1<<3)
 
-/* Data point to pass to the event handler.  */
-typedef union event_data
-{
-  void *ptr;
-  int integer;
-} event_data;
-
-typedef struct gdb_event gdb_event;
-typedef void (event_handler_func) (event_data);
-
-/* Event for the GDB event system.  Events are queued by calling
-   async_queue_event and serviced later on by gdb_do_one_event.  An
-   event can be, for instance, a file descriptor becoming ready to be
-   read.  Servicing an event simply means that the procedure PROC will
-   be called.  We have 2 queues, one for file handlers that we listen
-   to in the event loop, and one for the file handlers+events that are
-   ready.  The procedure PROC associated with each event is dependant
-   of the event source.  In the case of monitored file descriptors, it
-   is always the same (handle_file_event).  Its duty is to invoke the
-   handler associated with the file descriptor whose state change
-   generated the event, plus doing other cleanups and such.  In the
-   case of async signal handlers, it is
-   invoke_async_signal_handler.  */
-
-typedef struct gdb_event
-  {
-    /* Procedure to call to service this event.  */
-    event_handler_func *proc;
-
-    /* Data to pass to the event handler.  */
-    event_data data;
-  } *gdb_event_p;
-
 /* Information about each file descriptor we register with the event
    loop.  */
 
-- 
2.17.2

^ permalink raw reply	[flat|nested] 52+ messages in thread

* [RFC 04/17] Move gdb_select.h to common/
  2019-02-24 16:51 [RFC 00/17] Merge event loop implementations Tom Tromey
                   ` (14 preceding siblings ...)
  2019-02-24 16:52 ` [RFC 10/17] Move event-loop.[ch] to common/ Tom Tromey
@ 2019-02-24 16:52 ` Tom Tromey
  2019-02-24 16:52 ` [RFC 03/17] Move event-loop configury to common.m4 Tom Tromey
                   ` (2 subsequent siblings)
  18 siblings, 0 replies; 52+ messages in thread
From: Tom Tromey @ 2019-02-24 16:52 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This moves gdb_select.h to common/, so it can be used by other common
code.

gdb/ChangeLog
2019-02-24  Tom Tromey  <tom@tromey.com>

	* common/gdb_select.h: Move from...
	* gdb_select.h: ... here.
	* event-loop.c: Update include path.
	* top.c: Update include path.
	* ser-base.c: Update include path.
	* ui-file.c: Update include path.
	* ser-tcp.c: Update include path.
	* guile/scm-ports.c: Update include path.
	* posix-hdep.c: Update include path.
	* ser-unix.c: Update include path.
	* gdb_usleep.c: Update include path.
	* mingw-hdep.c: Update include path.
	* inflow.c: Update include path.
	* event-top.c: Update include path.
---
 gdb/ChangeLog                 | 17 +++++++++++++++++
 gdb/{ => common}/gdb_select.h |  0
 gdb/event-loop.c              |  2 +-
 gdb/event-top.c               |  2 +-
 gdb/gdb_usleep.c              |  2 +-
 gdb/guile/scm-ports.c         |  2 +-
 gdb/inflow.c                  |  2 +-
 gdb/mingw-hdep.c              |  2 +-
 gdb/posix-hdep.c              |  2 +-
 gdb/ser-base.c                |  2 +-
 gdb/ser-tcp.c                 |  2 +-
 gdb/ser-unix.c                |  2 +-
 gdb/top.c                     |  2 +-
 gdb/ui-file.c                 |  2 +-
 14 files changed, 29 insertions(+), 12 deletions(-)
 rename gdb/{ => common}/gdb_select.h (100%)

diff --git a/gdb/gdb_select.h b/gdb/common/gdb_select.h
similarity index 100%
rename from gdb/gdb_select.h
rename to gdb/common/gdb_select.h
diff --git a/gdb/event-loop.c b/gdb/event-loop.c
index f41094e9add..41ac5802703 100644
--- a/gdb/event-loop.c
+++ b/gdb/event-loop.c
@@ -31,7 +31,7 @@
 
 #include <sys/types.h>
 #include "common/gdb_sys_time.h"
-#include "gdb_select.h"
+#include "common/gdb_select.h"
 #include "top.h"
 
 /* Tell create_file_handler what events we are interested in.
diff --git a/gdb/event-top.c b/gdb/event-top.c
index fb5d51c6e10..0cc144d397c 100644
--- a/gdb/event-top.c
+++ b/gdb/event-top.c
@@ -39,7 +39,7 @@
 #include "maint.h"
 #include "common/buffer.h"
 #include "ser-event.h"
-#include "gdb_select.h"
+#include "common/gdb_select.h"
 
 /* readline include files.  */
 #include "readline/readline.h"
diff --git a/gdb/gdb_usleep.c b/gdb/gdb_usleep.c
index 25cc8e1b16c..0dcba0e6fad 100644
--- a/gdb/gdb_usleep.c
+++ b/gdb/gdb_usleep.c
@@ -17,7 +17,7 @@
 
 #include "defs.h"
 #include "gdb_usleep.h"
-#include "gdb_select.h"
+#include "common/gdb_select.h"
 #include "common/gdb_sys_time.h"
 
 int
diff --git a/gdb/guile/scm-ports.c b/gdb/guile/scm-ports.c
index 2950b1e39ec..62596966d40 100644
--- a/gdb/guile/scm-ports.c
+++ b/gdb/guile/scm-ports.c
@@ -22,7 +22,7 @@
    conventions, et.al.  */
 
 #include "defs.h"
-#include "gdb_select.h"
+#include "common/gdb_select.h"
 #include "top.h"
 #include "target.h"
 #include "guile-internal.h"
diff --git a/gdb/inflow.c b/gdb/inflow.c
index b71511308b3..8d8284fbea8 100644
--- a/gdb/inflow.c
+++ b/gdb/inflow.c
@@ -27,7 +27,7 @@
 #include "observable.h"
 #include <signal.h>
 #include <fcntl.h>
-#include "gdb_select.h"
+#include "common/gdb_select.h"
 
 #include "inflow.h"
 #include "gdbcmd.h"
diff --git a/gdb/mingw-hdep.c b/gdb/mingw-hdep.c
index 1a4b93bb8e8..2fa82d1d484 100644
--- a/gdb/mingw-hdep.c
+++ b/gdb/mingw-hdep.c
@@ -22,7 +22,7 @@
 #include "serial.h"
 #include "event-loop.h"
 
-#include "gdb_select.h"
+#include "common/gdb_select.h"
 #include "readline/readline.h"
 
 #include <windows.h>
diff --git a/gdb/posix-hdep.c b/gdb/posix-hdep.c
index 7911bc55055..97fd9b535a6 100644
--- a/gdb/posix-hdep.c
+++ b/gdb/posix-hdep.c
@@ -20,7 +20,7 @@
 #include "defs.h"
 #include "event-loop.h"
 
-#include "gdb_select.h"
+#include "common/gdb_select.h"
 
 /* Wrapper for select.  Nothing special needed on POSIX platforms.  */
 
diff --git a/gdb/ser-base.c b/gdb/ser-base.c
index 683d3f42528..6411ad7b2f7 100644
--- a/gdb/ser-base.c
+++ b/gdb/ser-base.c
@@ -22,7 +22,7 @@
 #include "ser-base.h"
 #include "event-loop.h"
 
-#include "gdb_select.h"
+#include "common/gdb_select.h"
 #include "common/gdb_sys_time.h"
 #ifdef USE_WIN32API
 #include <winsock2.h>
diff --git a/gdb/ser-tcp.c b/gdb/ser-tcp.c
index f484e59f196..7a459b38596 100644
--- a/gdb/ser-tcp.c
+++ b/gdb/ser-tcp.c
@@ -59,7 +59,7 @@
 #endif
 
 #include <signal.h>
-#include "gdb_select.h"
+#include "common/gdb_select.h"
 #include <algorithm>
 
 #ifndef HAVE_SOCKLEN_T
diff --git a/gdb/ser-unix.c b/gdb/ser-unix.c
index 5a9965bf744..8f3579bd642 100644
--- a/gdb/ser-unix.c
+++ b/gdb/ser-unix.c
@@ -28,7 +28,7 @@
 #include <sys/socket.h>
 #include "common/gdb_sys_time.h"
 
-#include "gdb_select.h"
+#include "common/gdb_select.h"
 #include "gdbcmd.h"
 #include "common/filestuff.h"
 #include <termios.h>
diff --git a/gdb/top.c b/gdb/top.c
index 22e6f7e29ab..91989609c07 100644
--- a/gdb/top.c
+++ b/gdb/top.c
@@ -51,7 +51,7 @@
 #include "filenames.h"
 #include "frame.h"
 #include "common/buffer.h"
-#include "gdb_select.h"
+#include "common/gdb_select.h"
 #include "common/scope-exit.h"
 
 /* readline include files.  */
diff --git a/gdb/ui-file.c b/gdb/ui-file.c
index 690fc62ed6d..6367c686504 100644
--- a/gdb/ui-file.c
+++ b/gdb/ui-file.c
@@ -22,7 +22,7 @@
 #include "defs.h"
 #include "ui-file.h"
 #include "gdb_obstack.h"
-#include "gdb_select.h"
+#include "common/gdb_select.h"
 #include "common/filestuff.h"
 
 null_file null_stream;
-- 
2.17.2

^ permalink raw reply	[flat|nested] 52+ messages in thread

* [RFC 09/17] Introduce async-event.[ch]
  2019-02-24 16:51 [RFC 00/17] Merge event loop implementations Tom Tromey
                   ` (10 preceding siblings ...)
  2019-02-24 16:52 ` [RFC 08/17] Introduce and use flush_streams Tom Tromey
@ 2019-02-24 16:52 ` Tom Tromey
  2019-09-26 14:06   ` Pedro Alves
  2019-02-24 16:52 ` [RFC 01/17] Remove include from event-loop.c Tom Tromey
                   ` (6 subsequent siblings)
  18 siblings, 1 reply; 52+ messages in thread
From: Tom Tromey @ 2019-02-24 16:52 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This patch splits out some gdb-specific code from event-loop, into new
files async-event.[ch].  Strictly speaking this code could perhaps be
put into common/, but because gdbserver does not currently use it, it
seemed better, for size reasons, to split it out.

gdb/ChangeLog
2019-02-24  Tom Tromey  <tom@tromey.com>

	* tui/tui-win.c: Include async-event.h.
	* remote.c: Include async-event.h.
	* remote-notif.c: Include async-event.h.
	* record-full.c: Include async-event.h.
	* record-btrace.c: Include async-event.h.
	* infrun.c: Include async-event.h.
	* event-top.c: Include async-event.h.
	* event-loop.h: Move some declarations to async-event.h.
	* event-loop.c: Don't include ser-event.h or top.h.  Move some
	code to async-event.c.
	* async-event.h: New file.
	* async-event.c: New file.
	* Makefile.in (COMMON_SFILES): Add async-event.c.
	(HFILES_NO_SRCDIR): Add async-event.h.
---
 gdb/ChangeLog       |  17 +++
 gdb/Makefile.in     |   2 +
 gdb/async-event.c   | 325 ++++++++++++++++++++++++++++++++++++++++++++
 gdb/async-event.h   |  71 ++++++++++
 gdb/event-loop.c    | 305 -----------------------------------------
 gdb/event-loop.h    |  51 ++-----
 gdb/event-top.c     |   1 +
 gdb/infrun.c        |   1 +
 gdb/record-btrace.c |   1 +
 gdb/record-full.c   |   1 +
 gdb/remote-notif.c  |   1 +
 gdb/remote.c        |   1 +
 gdb/tui/tui-win.c   |   1 +
 13 files changed, 430 insertions(+), 348 deletions(-)
 create mode 100644 gdb/async-event.c
 create mode 100644 gdb/async-event.h

diff --git a/gdb/Makefile.in b/gdb/Makefile.in
index 61b0b9d01bd..c7a9cb62d10 100644
--- a/gdb/Makefile.in
+++ b/gdb/Makefile.in
@@ -926,6 +926,7 @@ COMMON_SFILES = \
 	agent.c \
 	annotate.c \
 	arch-utils.c \
+	async-event.c \
 	auto-load.c \
 	auxv.c \
 	ax-gdb.c \
@@ -1197,6 +1198,7 @@ HFILES_NO_SRCDIR = \
 	arch-utils.h \
 	arm-linux-tdep.h \
 	arm-tdep.h \
+	async-event.h \
 	auto-load.h \
 	auxv.h \
 	ax.h \
diff --git a/gdb/async-event.c b/gdb/async-event.c
new file mode 100644
index 00000000000..dd65c17468b
--- /dev/null
+++ b/gdb/async-event.c
@@ -0,0 +1,325 @@
+/* Async events for the GDB event loop.
+   Copyright (C) 1999-2019 Free Software Foundation, Inc.
+
+   This file is part of GDB.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+#include "defs.h"
+#include "async-event.h"
+
+#include "ser-event.h"
+#include "top.h"
+
+/* PROC is a function to be invoked when the READY flag is set.  This
+   happens when there has been a signal and the corresponding signal
+   handler has 'triggered' this async_signal_handler for execution.
+   The actual work to be done in response to a signal will be carried
+   out by PROC at a later time, within process_event.  This provides a
+   deferred execution of signal handlers.
+
+   Async_init_signals takes care of setting up such an
+   async_signal_handler for each interesting signal.  */
+
+typedef struct async_signal_handler
+  {
+    int ready;			    /* If ready, call this handler
+				       from the main event loop, using
+				       invoke_async_handler.  */
+    struct async_signal_handler *next_handler;	/* Ptr to next handler.  */
+    sig_handler_func *proc;	    /* Function to call to do the work.  */
+    gdb_client_data client_data;    /* Argument to async_handler_func.  */
+  }
+async_signal_handler;
+
+/* PROC is a function to be invoked when the READY flag is set.  This
+   happens when the event has been marked with
+   MARK_ASYNC_EVENT_HANDLER.  The actual work to be done in response
+   to an event will be carried out by PROC at a later time, within
+   process_event.  This provides a deferred execution of event
+   handlers.  */
+typedef struct async_event_handler
+  {
+    /* If ready, call this handler from the main event loop, using
+       invoke_event_handler.  */
+    int ready;
+
+    /* Point to next handler.  */
+    struct async_event_handler *next_handler;
+
+    /* Function to call to do the work.  */
+    async_event_handler_func *proc;
+
+    /* Argument to PROC.  */
+    gdb_client_data client_data;
+  }
+async_event_handler;
+
+/* All the async_signal_handlers gdb is interested in are kept onto
+   this list.  */
+static struct
+  {
+    /* Pointer to first in handler list.  */
+    async_signal_handler *first_handler;
+
+    /* Pointer to last in handler list.  */
+    async_signal_handler *last_handler;
+  }
+sighandler_list;
+
+/* All the async_event_handlers gdb is interested in are kept onto
+   this list.  */
+static struct
+  {
+    /* Pointer to first in handler list.  */
+    async_event_handler *first_handler;
+
+    /* Pointer to last in handler list.  */
+    async_event_handler *last_handler;
+  }
+async_event_handler_list;
+
+
+/* This event is signalled whenever an asynchronous handler needs to
+   defer an action to the event loop.  */
+static struct serial_event *async_signal_handlers_serial_event;
+
+/* Callback registered with ASYNC_SIGNAL_HANDLERS_SERIAL_EVENT.  */
+
+static void
+async_signals_handler (int error, gdb_client_data client_data)
+{
+  /* Do nothing.  Handlers are run by invoke_async_signal_handlers
+     from instead.  */
+}
+
+void
+initialize_async_signal_handlers (void)
+{
+  async_signal_handlers_serial_event = make_serial_event ();
+
+  add_file_handler (serial_event_fd (async_signal_handlers_serial_event),
+		    async_signals_handler, NULL);
+}
+
+\f
+
+/* Create an asynchronous handler, allocating memory for it.
+   Return a pointer to the newly created handler.
+   This pointer will be used to invoke the handler by 
+   invoke_async_signal_handler.
+   PROC is the function to call with CLIENT_DATA argument 
+   whenever the handler is invoked.  */
+async_signal_handler *
+create_async_signal_handler (sig_handler_func * proc,
+			     gdb_client_data client_data)
+{
+  async_signal_handler *async_handler_ptr;
+
+  async_handler_ptr = XNEW (async_signal_handler);
+  async_handler_ptr->ready = 0;
+  async_handler_ptr->next_handler = NULL;
+  async_handler_ptr->proc = proc;
+  async_handler_ptr->client_data = client_data;
+  if (sighandler_list.first_handler == NULL)
+    sighandler_list.first_handler = async_handler_ptr;
+  else
+    sighandler_list.last_handler->next_handler = async_handler_ptr;
+  sighandler_list.last_handler = async_handler_ptr;
+  return async_handler_ptr;
+}
+
+/* Mark the handler (ASYNC_HANDLER_PTR) as ready.  This information
+   will be used when the handlers are invoked, after we have waited
+   for some event.  The caller of this function is the interrupt
+   handler associated with a signal.  */
+void
+mark_async_signal_handler (async_signal_handler * async_handler_ptr)
+{
+  async_handler_ptr->ready = 1;
+  serial_event_set (async_signal_handlers_serial_event);
+}
+
+/* See event-loop.h.  */
+
+void
+clear_async_signal_handler (async_signal_handler *async_handler_ptr)
+{
+  async_handler_ptr->ready = 0;
+}
+
+/* See event-loop.h.  */
+
+int
+async_signal_handler_is_marked (async_signal_handler *async_handler_ptr)
+{
+  return async_handler_ptr->ready;
+}
+
+/* Call all the handlers that are ready.  Returns true if any was
+   indeed ready.  */
+
+int
+invoke_async_signal_handlers (void)
+{
+  async_signal_handler *async_handler_ptr;
+  int any_ready = 0;
+
+  /* We're going to handle all pending signals, so no need to wake up
+     the event loop again the next time around.  Note this must be
+     cleared _before_ calling the callbacks, to avoid races.  */
+  serial_event_clear (async_signal_handlers_serial_event);
+
+  /* Invoke all ready handlers.  */
+
+  while (1)
+    {
+      for (async_handler_ptr = sighandler_list.first_handler;
+	   async_handler_ptr != NULL;
+	   async_handler_ptr = async_handler_ptr->next_handler)
+	{
+	  if (async_handler_ptr->ready)
+	    break;
+	}
+      if (async_handler_ptr == NULL)
+	break;
+      any_ready = 1;
+      async_handler_ptr->ready = 0;
+      /* Async signal handlers have no connection to whichever was the
+	 current UI, and thus always run on the main one.  */
+      current_ui = main_ui;
+      (*async_handler_ptr->proc) (async_handler_ptr->client_data);
+    }
+
+  return any_ready;
+}
+
+/* Delete an asynchronous handler (ASYNC_HANDLER_PTR).
+   Free the space allocated for it.  */
+void
+delete_async_signal_handler (async_signal_handler ** async_handler_ptr)
+{
+  async_signal_handler *prev_ptr;
+
+  if (sighandler_list.first_handler == (*async_handler_ptr))
+    {
+      sighandler_list.first_handler = (*async_handler_ptr)->next_handler;
+      if (sighandler_list.first_handler == NULL)
+	sighandler_list.last_handler = NULL;
+    }
+  else
+    {
+      prev_ptr = sighandler_list.first_handler;
+      while (prev_ptr && prev_ptr->next_handler != (*async_handler_ptr))
+	prev_ptr = prev_ptr->next_handler;
+      gdb_assert (prev_ptr);
+      prev_ptr->next_handler = (*async_handler_ptr)->next_handler;
+      if (sighandler_list.last_handler == (*async_handler_ptr))
+	sighandler_list.last_handler = prev_ptr;
+    }
+  xfree ((*async_handler_ptr));
+  (*async_handler_ptr) = NULL;
+}
+
+/* Create an asynchronous event handler, allocating memory for it.
+   Return a pointer to the newly created handler.  PROC is the
+   function to call with CLIENT_DATA argument whenever the handler is
+   invoked.  */
+async_event_handler *
+create_async_event_handler (async_event_handler_func *proc,
+			    gdb_client_data client_data)
+{
+  async_event_handler *h;
+
+  h = XNEW (struct async_event_handler);
+  h->ready = 0;
+  h->next_handler = NULL;
+  h->proc = proc;
+  h->client_data = client_data;
+  if (async_event_handler_list.first_handler == NULL)
+    async_event_handler_list.first_handler = h;
+  else
+    async_event_handler_list.last_handler->next_handler = h;
+  async_event_handler_list.last_handler = h;
+  return h;
+}
+
+/* Mark the handler (ASYNC_HANDLER_PTR) as ready.  This information
+   will be used by gdb_do_one_event.  The caller will be whoever
+   created the event source, and wants to signal that the event is
+   ready to be handled.  */
+void
+mark_async_event_handler (async_event_handler *async_handler_ptr)
+{
+  async_handler_ptr->ready = 1;
+}
+
+/* See event-loop.h.  */
+
+void
+clear_async_event_handler (async_event_handler *async_handler_ptr)
+{
+  async_handler_ptr->ready = 0;
+}
+
+/* Check if asynchronous event handlers are ready, and call the
+   handler function for one that is.  */
+
+int
+check_async_event_handlers ()
+{
+  async_event_handler *async_handler_ptr;
+
+  for (async_handler_ptr = async_event_handler_list.first_handler;
+       async_handler_ptr != NULL;
+       async_handler_ptr = async_handler_ptr->next_handler)
+    {
+      if (async_handler_ptr->ready)
+	{
+	  async_handler_ptr->ready = 0;
+	  (*async_handler_ptr->proc) (async_handler_ptr->client_data);
+	  return 1;
+	}
+    }
+
+  return 0;
+}
+
+/* Delete an asynchronous handler (ASYNC_HANDLER_PTR).
+   Free the space allocated for it.  */
+void
+delete_async_event_handler (async_event_handler **async_handler_ptr)
+{
+  async_event_handler *prev_ptr;
+
+  if (async_event_handler_list.first_handler == *async_handler_ptr)
+    {
+      async_event_handler_list.first_handler
+	= (*async_handler_ptr)->next_handler;
+      if (async_event_handler_list.first_handler == NULL)
+	async_event_handler_list.last_handler = NULL;
+    }
+  else
+    {
+      prev_ptr = async_event_handler_list.first_handler;
+      while (prev_ptr && prev_ptr->next_handler != *async_handler_ptr)
+	prev_ptr = prev_ptr->next_handler;
+      gdb_assert (prev_ptr);
+      prev_ptr->next_handler = (*async_handler_ptr)->next_handler;
+      if (async_event_handler_list.last_handler == (*async_handler_ptr))
+	async_event_handler_list.last_handler = prev_ptr;
+    }
+  xfree (*async_handler_ptr);
+  *async_handler_ptr = NULL;
+}
diff --git a/gdb/async-event.h b/gdb/async-event.h
new file mode 100644
index 00000000000..408f7764f7c
--- /dev/null
+++ b/gdb/async-event.h
@@ -0,0 +1,71 @@
+/* Async events for the GDB event loop.
+   Copyright (C) 1999-2019 Free Software Foundation, Inc.
+
+   This file is part of GDB.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+#ifndef ASYNC_EVENT_H
+#define ASYNC_EVENT_H
+
+#include "event-loop.h"
+
+struct async_signal_handler;
+struct async_event_handler;
+typedef void (sig_handler_func) (gdb_client_data);
+typedef void (async_event_handler_func) (gdb_client_data);
+
+extern struct async_signal_handler *
+  create_async_signal_handler (sig_handler_func *proc, 
+			       gdb_client_data client_data);
+extern void delete_async_signal_handler (struct async_signal_handler **);
+
+/* Call the handler from HANDLER the next time through the event
+   loop.  */
+extern void mark_async_signal_handler (struct async_signal_handler *handler);
+
+/* Returns true if HANDLER is marked ready.  */
+
+extern int
+  async_signal_handler_is_marked (struct async_signal_handler *handler);
+
+/* Mark HANDLER as NOT ready.  */
+
+extern void clear_async_signal_handler (struct async_signal_handler *handler);
+
+/* Create and register an asynchronous event source in the event loop,
+   and set PROC as its callback.  CLIENT_DATA is passed as argument to
+   PROC upon its invocation.  Returns a pointer to an opaque structure
+   used to mark as ready and to later delete this event source from
+   the event loop.  */
+extern struct async_event_handler *
+  create_async_event_handler (async_event_handler_func *proc,
+			      gdb_client_data client_data);
+
+/* Remove the event source pointed by HANDLER_PTR created by
+   CREATE_ASYNC_EVENT_HANDLER from the event loop, and release it.  */
+extern void
+  delete_async_event_handler (struct async_event_handler **handler_ptr);
+
+/* Call the handler from HANDLER the next time through the event
+   loop.  */
+extern void mark_async_event_handler (struct async_event_handler *handler);
+
+/* Mark the handler (ASYNC_HANDLER_PTR) as NOT ready.  */
+
+extern void clear_async_event_handler (struct async_event_handler *handler);
+
+extern void initialize_async_signal_handlers (void);
+
+#endif /* ASYNC_EVENT_H */
diff --git a/gdb/event-loop.c b/gdb/event-loop.c
index b9d9e7e098e..08536f57902 100644
--- a/gdb/event-loop.c
+++ b/gdb/event-loop.c
@@ -19,7 +19,6 @@
 
 #include "defs.h"
 #include "event-loop.h"
-#include "ser-event.h"
 
 #include <chrono>
 
@@ -34,7 +33,6 @@
 #include <sys/types.h>
 #include "common/gdb_sys_time.h"
 #include "common/gdb_select.h"
-#include "top.h"
 
 /* Tell create_file_handler what events we are interested in.
    This is used by the select version of the event loop.  */
@@ -92,50 +90,6 @@ typedef struct file_handler
   }
 file_handler;
 
-/* PROC is a function to be invoked when the READY flag is set.  This
-   happens when there has been a signal and the corresponding signal
-   handler has 'triggered' this async_signal_handler for execution.
-   The actual work to be done in response to a signal will be carried
-   out by PROC at a later time, within process_event.  This provides a
-   deferred execution of signal handlers.
-
-   Async_init_signals takes care of setting up such an
-   async_signal_handler for each interesting signal.  */
-
-typedef struct async_signal_handler
-  {
-    int ready;			    /* If ready, call this handler
-				       from the main event loop, using
-				       invoke_async_handler.  */
-    struct async_signal_handler *next_handler;	/* Ptr to next handler.  */
-    sig_handler_func *proc;	    /* Function to call to do the work.  */
-    gdb_client_data client_data;    /* Argument to async_handler_func.  */
-  }
-async_signal_handler;
-
-/* PROC is a function to be invoked when the READY flag is set.  This
-   happens when the event has been marked with
-   MARK_ASYNC_EVENT_HANDLER.  The actual work to be done in response
-   to an event will be carried out by PROC at a later time, within
-   process_event.  This provides a deferred execution of event
-   handlers.  */
-typedef struct async_event_handler
-  {
-    /* If ready, call this handler from the main event loop, using
-       invoke_event_handler.  */
-    int ready;
-
-    /* Point to next handler.  */
-    struct async_event_handler *next_handler;
-
-    /* Function to call to do the work.  */
-    async_event_handler_func *proc;
-
-    /* Argument to PROC.  */
-    gdb_client_data client_data;
-  }
-async_event_handler;
-
 /* Gdb_notifier is just a list of file descriptors gdb is interested in.
    These are the input file descriptor, and the target file
    descriptor.  We have two flavors of the notifier, one for platforms
@@ -230,61 +184,12 @@ static struct
   }
 timer_list;
 
-/* All the async_signal_handlers gdb is interested in are kept onto
-   this list.  */
-static struct
-  {
-    /* Pointer to first in handler list.  */
-    async_signal_handler *first_handler;
-
-    /* Pointer to last in handler list.  */
-    async_signal_handler *last_handler;
-  }
-sighandler_list;
-
-/* All the async_event_handlers gdb is interested in are kept onto
-   this list.  */
-static struct
-  {
-    /* Pointer to first in handler list.  */
-    async_event_handler *first_handler;
-
-    /* Pointer to last in handler list.  */
-    async_event_handler *last_handler;
-  }
-async_event_handler_list;
-
-static int invoke_async_signal_handlers (void);
 static void create_file_handler (int fd, int mask, handler_func *proc,
 				 gdb_client_data client_data);
-static int check_async_event_handlers (void);
 static int gdb_wait_for_event (int);
 static int update_wait_timeout (void);
 static int poll_timers (void);
 \f
-
-/* This event is signalled whenever an asynchronous handler needs to
-   defer an action to the event loop.  */
-static struct serial_event *async_signal_handlers_serial_event;
-
-/* Callback registered with ASYNC_SIGNAL_HANDLERS_SERIAL_EVENT.  */
-
-static void
-async_signals_handler (int error, gdb_client_data client_data)
-{
-  /* Do nothing.  Handlers are run by invoke_async_signal_handlers
-     from instead.  */
-}
-
-void
-initialize_async_signal_handlers (void)
-{
-  async_signal_handlers_serial_event = make_serial_event ();
-
-  add_file_handler (serial_event_fd (async_signal_handlers_serial_event),
-		    async_signals_handler, NULL);
-}
-
 /* Process one high level event.  If nothing is ready at this time,
    wait for something to happen (via gdb_wait_for_event), then process
    it.  Returns >0 if something was done otherwise returns <0 (this
@@ -864,216 +769,6 @@ gdb_wait_for_event (int block)
   return 0;
 }
 \f
-
-/* Create an asynchronous handler, allocating memory for it.
-   Return a pointer to the newly created handler.
-   This pointer will be used to invoke the handler by 
-   invoke_async_signal_handler.
-   PROC is the function to call with CLIENT_DATA argument 
-   whenever the handler is invoked.  */
-async_signal_handler *
-create_async_signal_handler (sig_handler_func * proc,
-			     gdb_client_data client_data)
-{
-  async_signal_handler *async_handler_ptr;
-
-  async_handler_ptr = XNEW (async_signal_handler);
-  async_handler_ptr->ready = 0;
-  async_handler_ptr->next_handler = NULL;
-  async_handler_ptr->proc = proc;
-  async_handler_ptr->client_data = client_data;
-  if (sighandler_list.first_handler == NULL)
-    sighandler_list.first_handler = async_handler_ptr;
-  else
-    sighandler_list.last_handler->next_handler = async_handler_ptr;
-  sighandler_list.last_handler = async_handler_ptr;
-  return async_handler_ptr;
-}
-
-/* Mark the handler (ASYNC_HANDLER_PTR) as ready.  This information
-   will be used when the handlers are invoked, after we have waited
-   for some event.  The caller of this function is the interrupt
-   handler associated with a signal.  */
-void
-mark_async_signal_handler (async_signal_handler * async_handler_ptr)
-{
-  async_handler_ptr->ready = 1;
-  serial_event_set (async_signal_handlers_serial_event);
-}
-
-/* See event-loop.h.  */
-
-void
-clear_async_signal_handler (async_signal_handler *async_handler_ptr)
-{
-  async_handler_ptr->ready = 0;
-}
-
-/* See event-loop.h.  */
-
-int
-async_signal_handler_is_marked (async_signal_handler *async_handler_ptr)
-{
-  return async_handler_ptr->ready;
-}
-
-/* Call all the handlers that are ready.  Returns true if any was
-   indeed ready.  */
-
-static int
-invoke_async_signal_handlers (void)
-{
-  async_signal_handler *async_handler_ptr;
-  int any_ready = 0;
-
-  /* We're going to handle all pending signals, so no need to wake up
-     the event loop again the next time around.  Note this must be
-     cleared _before_ calling the callbacks, to avoid races.  */
-  serial_event_clear (async_signal_handlers_serial_event);
-
-  /* Invoke all ready handlers.  */
-
-  while (1)
-    {
-      for (async_handler_ptr = sighandler_list.first_handler;
-	   async_handler_ptr != NULL;
-	   async_handler_ptr = async_handler_ptr->next_handler)
-	{
-	  if (async_handler_ptr->ready)
-	    break;
-	}
-      if (async_handler_ptr == NULL)
-	break;
-      any_ready = 1;
-      async_handler_ptr->ready = 0;
-      /* Async signal handlers have no connection to whichever was the
-	 current UI, and thus always run on the main one.  */
-      current_ui = main_ui;
-      (*async_handler_ptr->proc) (async_handler_ptr->client_data);
-    }
-
-  return any_ready;
-}
-
-/* Delete an asynchronous handler (ASYNC_HANDLER_PTR).
-   Free the space allocated for it.  */
-void
-delete_async_signal_handler (async_signal_handler ** async_handler_ptr)
-{
-  async_signal_handler *prev_ptr;
-
-  if (sighandler_list.first_handler == (*async_handler_ptr))
-    {
-      sighandler_list.first_handler = (*async_handler_ptr)->next_handler;
-      if (sighandler_list.first_handler == NULL)
-	sighandler_list.last_handler = NULL;
-    }
-  else
-    {
-      prev_ptr = sighandler_list.first_handler;
-      while (prev_ptr && prev_ptr->next_handler != (*async_handler_ptr))
-	prev_ptr = prev_ptr->next_handler;
-      gdb_assert (prev_ptr);
-      prev_ptr->next_handler = (*async_handler_ptr)->next_handler;
-      if (sighandler_list.last_handler == (*async_handler_ptr))
-	sighandler_list.last_handler = prev_ptr;
-    }
-  xfree ((*async_handler_ptr));
-  (*async_handler_ptr) = NULL;
-}
-
-/* Create an asynchronous event handler, allocating memory for it.
-   Return a pointer to the newly created handler.  PROC is the
-   function to call with CLIENT_DATA argument whenever the handler is
-   invoked.  */
-async_event_handler *
-create_async_event_handler (async_event_handler_func *proc,
-			    gdb_client_data client_data)
-{
-  async_event_handler *h;
-
-  h = XNEW (struct async_event_handler);
-  h->ready = 0;
-  h->next_handler = NULL;
-  h->proc = proc;
-  h->client_data = client_data;
-  if (async_event_handler_list.first_handler == NULL)
-    async_event_handler_list.first_handler = h;
-  else
-    async_event_handler_list.last_handler->next_handler = h;
-  async_event_handler_list.last_handler = h;
-  return h;
-}
-
-/* Mark the handler (ASYNC_HANDLER_PTR) as ready.  This information
-   will be used by gdb_do_one_event.  The caller will be whoever
-   created the event source, and wants to signal that the event is
-   ready to be handled.  */
-void
-mark_async_event_handler (async_event_handler *async_handler_ptr)
-{
-  async_handler_ptr->ready = 1;
-}
-
-/* See event-loop.h.  */
-
-void
-clear_async_event_handler (async_event_handler *async_handler_ptr)
-{
-  async_handler_ptr->ready = 0;
-}
-
-/* Check if asynchronous event handlers are ready, and call the
-   handler function for one that is.  */
-
-static int
-check_async_event_handlers (void)
-{
-  async_event_handler *async_handler_ptr;
-
-  for (async_handler_ptr = async_event_handler_list.first_handler;
-       async_handler_ptr != NULL;
-       async_handler_ptr = async_handler_ptr->next_handler)
-    {
-      if (async_handler_ptr->ready)
-	{
-	  async_handler_ptr->ready = 0;
-	  (*async_handler_ptr->proc) (async_handler_ptr->client_data);
-	  return 1;
-	}
-    }
-
-  return 0;
-}
-
-/* Delete an asynchronous handler (ASYNC_HANDLER_PTR).
-   Free the space allocated for it.  */
-void
-delete_async_event_handler (async_event_handler **async_handler_ptr)
-{
-  async_event_handler *prev_ptr;
-
-  if (async_event_handler_list.first_handler == *async_handler_ptr)
-    {
-      async_event_handler_list.first_handler
-	= (*async_handler_ptr)->next_handler;
-      if (async_event_handler_list.first_handler == NULL)
-	async_event_handler_list.last_handler = NULL;
-    }
-  else
-    {
-      prev_ptr = async_event_handler_list.first_handler;
-      while (prev_ptr && prev_ptr->next_handler != *async_handler_ptr)
-	prev_ptr = prev_ptr->next_handler;
-      gdb_assert (prev_ptr);
-      prev_ptr->next_handler = (*async_handler_ptr)->next_handler;
-      if (async_event_handler_list.last_handler == (*async_handler_ptr))
-	async_event_handler_list.last_handler = prev_ptr;
-    }
-  xfree (*async_handler_ptr);
-  *async_handler_ptr = NULL;
-}
-
 /* Create a timer that will expire in MS milliseconds from now.  When
    the timer is ready, PROC will be executed.  At creation, the timer
    is added to the timers queue.  This queue is kept sorted in order
diff --git a/gdb/event-loop.h b/gdb/event-loop.h
index f11b008848d..16bde6474db 100644
--- a/gdb/event-loop.h
+++ b/gdb/event-loop.h
@@ -71,11 +71,7 @@
    Corollary tasks are the creation and deletion of event sources.  */
 
 typedef void *gdb_client_data;
-struct async_signal_handler;
-struct async_event_handler;
 typedef void (handler_func) (int, gdb_client_data);
-typedef void (sig_handler_func) (gdb_client_data);
-typedef void (async_event_handler_func) (gdb_client_data);
 typedef void (timer_handler_func) (gdb_client_data);
 
 /* Exported functions from event-loop.c */
@@ -85,54 +81,23 @@ extern int gdb_do_one_event (void);
 extern void delete_file_handler (int fd);
 extern void add_file_handler (int fd, handler_func *proc, 
 			      gdb_client_data client_data);
-extern struct async_signal_handler *
-  create_async_signal_handler (sig_handler_func *proc, 
-			       gdb_client_data client_data);
-extern void delete_async_signal_handler (struct async_signal_handler **);
 extern int create_timer (int milliseconds, 
 			 timer_handler_func *proc, 
 			 gdb_client_data client_data);
 extern void delete_timer (int id);
 
-/* Call the handler from HANDLER the next time through the event
-   loop.  */
-extern void mark_async_signal_handler (struct async_signal_handler *handler);
-
-/* Returns true if HANDLER is marked ready.  */
-
-extern int
-  async_signal_handler_is_marked (struct async_signal_handler *handler);
-
-/* Mark HANDLER as NOT ready.  */
-
-extern void clear_async_signal_handler (struct async_signal_handler *handler);
-
-/* Create and register an asynchronous event source in the event loop,
-   and set PROC as its callback.  CLIENT_DATA is passed as argument to
-   PROC upon its invocation.  Returns a pointer to an opaque structure
-   used to mark as ready and to later delete this event source from
-   the event loop.  */
-extern struct async_event_handler *
-  create_async_event_handler (async_event_handler_func *proc,
-			      gdb_client_data client_data);
-
-/* Remove the event source pointed by HANDLER_PTR created by
-   CREATE_ASYNC_EVENT_HANDLER from the event loop, and release it.  */
-extern void
-  delete_async_event_handler (struct async_event_handler **handler_ptr);
-
-/* Call the handler from HANDLER the next time through the event
-   loop.  */
-extern void mark_async_event_handler (struct async_event_handler *handler);
+/* Must be defined by client.  */
 
-/* Mark the handler (ASYNC_HANDLER_PTR) as NOT ready.  */
+extern void handle_event_loop_exception (const gdb_exception &);
 
-extern void clear_async_event_handler (struct async_event_handler *handler);
+/* Must be defined by client.  Returns true if any signal handler was
+   ready.  */
 
-extern void initialize_async_signal_handlers (void);
+extern int invoke_async_signal_handlers ();
 
-/* Must be defined by client.  */
+/* Must be defined by client.  Returns true if any event handler was
+   ready.  */
 
-extern void handle_event_loop_exception (const gdb_exception &);
+extern int check_async_event_handlers ();
 
 #endif /* EVENT_LOOP_H */
diff --git a/gdb/event-top.c b/gdb/event-top.c
index 0cc144d397c..5829957e513 100644
--- a/gdb/event-top.c
+++ b/gdb/event-top.c
@@ -40,6 +40,7 @@
 #include "common/buffer.h"
 #include "ser-event.h"
 #include "common/gdb_select.h"
+#include "async-event.h"
 
 /* readline include files.  */
 #include "readline/readline.h"
diff --git a/gdb/infrun.c b/gdb/infrun.c
index b32635fc422..0eaf1b608b6 100644
--- a/gdb/infrun.c
+++ b/gdb/infrun.c
@@ -68,6 +68,7 @@
 #include "common/gdb_optional.h"
 #include "arch-utils.h"
 #include "common/scope-exit.h"
+#include "async-event.h"
 
 /* Prototypes for local functions */
 
diff --git a/gdb/record-btrace.c b/gdb/record-btrace.c
index dc26938f0b9..5319a1b2bb8 100644
--- a/gdb/record-btrace.c
+++ b/gdb/record-btrace.c
@@ -41,6 +41,7 @@
 #include "common/vec.h"
 #include "inferior.h"
 #include <algorithm>
+#include "async-event.h"
 
 static const target_info record_btrace_target_info = {
   "record-btrace",
diff --git a/gdb/record-full.c b/gdb/record-full.c
index ea0eddb536d..95ccc2c797e 100644
--- a/gdb/record-full.c
+++ b/gdb/record-full.c
@@ -38,6 +38,7 @@
 #include "infrun.h"
 #include "common/gdb_unlinker.h"
 #include "common/byte-vector.h"
+#include "async-event.h"
 
 #include <signal.h>
 
diff --git a/gdb/remote-notif.c b/gdb/remote-notif.c
index ae9a94d9c94..72916023420 100644
--- a/gdb/remote-notif.c
+++ b/gdb/remote-notif.c
@@ -40,6 +40,7 @@
 #include "inferior.h"
 #include "infrun.h"
 #include "gdbcmd.h"
+#include "async-event.h"
 
 int notif_debug = 0;
 
diff --git a/gdb/remote.c b/gdb/remote.c
index 36136e3e3ee..d6561dda61f 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -76,6 +76,7 @@
 #include "common/environ.h"
 #include "common/byte-vector.h"
 #include <unordered_map>
+#include "async-event.h"
 
 /* The remote target.  */
 
diff --git a/gdb/tui/tui-win.c b/gdb/tui/tui-win.c
index a24f25928e2..fa1ee89603d 100644
--- a/gdb/tui/tui-win.c
+++ b/gdb/tui/tui-win.c
@@ -33,6 +33,7 @@
 #include "top.h"
 #include "source.h"
 #include "event-loop.h"
+#include "async-event.h"
 
 #include "tui/tui.h"
 #include "tui/tui-io.h"
-- 
2.17.2

^ permalink raw reply	[flat|nested] 52+ messages in thread

* [RFC 10/17] Move event-loop.[ch] to common/
  2019-02-24 16:51 [RFC 00/17] Merge event loop implementations Tom Tromey
                   ` (13 preceding siblings ...)
  2019-02-24 16:52 ` [RFC 06/17] Include <chrono> in event-loop.c Tom Tromey
@ 2019-02-24 16:52 ` Tom Tromey
  2019-09-26 14:06   ` Pedro Alves
  2019-02-24 16:52 ` [RFC 04/17] Move gdb_select.h " Tom Tromey
                   ` (3 subsequent siblings)
  18 siblings, 1 reply; 52+ messages in thread
From: Tom Tromey @ 2019-02-24 16:52 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This moves event-loop.[ch] to common and updates the uses in gdb.

gdb/ChangeLog
2019-02-24  Tom Tromey  <tom@tromey.com>

	* tui/tui-win.c: Update include.
	* tui/tui-io.c: Update include.
	* tui/tui-interp.c: Update include.
	* tui/tui-hooks.c: Update include.
	* top.h: Update include.
	* top.c: Update include.
	* ser-base.c: Update include.
	* remote.c: Update include.
	* remote-notif.c: Update include.
	* remote-fileio.c: Update include.
	* record-full.c: Update include.
	* record-btrace.c: Update include.
	* python/python.c: Update include.
	* posix-hdep.c: Update include.
	* mingw-hdep.c: Update include.
	* mi/mi-main.c: Update include.
	* mi/mi-interp.c: Update include.
	* main.c: Update include.
	* linux-nat.c: Update include.
	* interps.c: Update include.
	* infrun.c: Update include.
	* inf-loop.c: Update include.
	* event-top.c: Update include.
	* event-loop.c: Move...
	* common/event-loop.c: ... here.
	* event-loop.h: Move...
	* common/event-loop.h: ... here.
	* async-event.h: Update include.
	* Makefile.in (COMMON_SFILES, HFILES_NO_SRCDIR): Update.
---
 gdb/ChangeLog                 | 32 ++++++++++++++++++++++++++++++++
 gdb/Makefile.in               |  4 ++--
 gdb/async-event.h             |  2 +-
 gdb/{ => common}/event-loop.c |  4 ++--
 gdb/{ => common}/event-loop.h |  2 ++
 gdb/event-top.c               |  2 +-
 gdb/inf-loop.c                |  2 +-
 gdb/infrun.c                  |  2 +-
 gdb/interps.c                 |  2 +-
 gdb/linux-nat.c               |  2 +-
 gdb/main.c                    |  2 +-
 gdb/mi/mi-interp.c            |  2 +-
 gdb/mi/mi-main.c              |  2 +-
 gdb/mingw-hdep.c              |  2 +-
 gdb/posix-hdep.c              |  2 +-
 gdb/python/python.c           |  2 +-
 gdb/record-btrace.c           |  2 +-
 gdb/record-full.c             |  2 +-
 gdb/remote-fileio.c           |  2 +-
 gdb/remote-notif.c            |  2 +-
 gdb/remote.c                  |  2 +-
 gdb/ser-base.c                |  2 +-
 gdb/top.c                     |  2 +-
 gdb/top.h                     |  2 +-
 gdb/tui/tui-hooks.c           |  2 +-
 gdb/tui/tui-interp.c          |  2 +-
 gdb/tui/tui-io.c              |  2 +-
 gdb/tui/tui-win.c             |  2 +-
 28 files changed, 62 insertions(+), 28 deletions(-)
 rename gdb/{ => common}/event-loop.c (99%)
 rename gdb/{ => common}/event-loop.h (99%)

diff --git a/gdb/Makefile.in b/gdb/Makefile.in
index c7a9cb62d10..af0d2e95ef8 100644
--- a/gdb/Makefile.in
+++ b/gdb/Makefile.in
@@ -961,6 +961,7 @@ COMMON_SFILES = \
 	common/common-utils.c \
 	common/errors.c \
 	common/environ.c \
+	common/event-loop.c \
 	common/fileio.c \
 	common/filestuff.c \
 	common/format.c \
@@ -1011,7 +1012,6 @@ COMMON_SFILES = \
 	dwarf2loc.c \
 	dwarf2read.c \
 	eval.c \
-	event-loop.c \
 	event-top.c \
 	exceptions.c \
 	exec.c \
@@ -1240,7 +1240,6 @@ HFILES_NO_SRCDIR = \
 	dwarf2expr.h \
 	dwarf2loc.h \
 	dwarf2read.h \
-	event-loop.h \
 	event-top.h \
 	exceptions.h \
 	exec.h \
@@ -1452,6 +1451,7 @@ HFILES_NO_SRCDIR = \
 	common/job-control.h \
 	common/errors.h \
 	common/environ.h \
+	common/event-loop.h \
 	common/fileio.h \
 	common/format.h \
 	common/gdb_assert.h \
diff --git a/gdb/async-event.h b/gdb/async-event.h
index 408f7764f7c..45b4daf3f18 100644
--- a/gdb/async-event.h
+++ b/gdb/async-event.h
@@ -19,7 +19,7 @@
 #ifndef ASYNC_EVENT_H
 #define ASYNC_EVENT_H
 
-#include "event-loop.h"
+#include "common/event-loop.h"
 
 struct async_signal_handler;
 struct async_event_handler;
diff --git a/gdb/event-loop.c b/gdb/common/event-loop.c
similarity index 99%
rename from gdb/event-loop.c
rename to gdb/common/event-loop.c
index 08536f57902..a2563414dfd 100644
--- a/gdb/event-loop.c
+++ b/gdb/common/event-loop.c
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "defs.h"
-#include "event-loop.h"
+#include "common/common-defs.h"
+#include "common/event-loop.h"
 
 #include <chrono>
 
diff --git a/gdb/event-loop.h b/gdb/common/event-loop.h
similarity index 99%
rename from gdb/event-loop.h
rename to gdb/common/event-loop.h
index 16bde6474db..1eec1ed2cd9 100644
--- a/gdb/event-loop.h
+++ b/gdb/common/event-loop.h
@@ -70,6 +70,8 @@
 
    Corollary tasks are the creation and deletion of event sources.  */
 
+#include "common/function-view.h"
+
 typedef void *gdb_client_data;
 typedef void (handler_func) (int, gdb_client_data);
 typedef void (timer_handler_func) (gdb_client_data);
diff --git a/gdb/event-top.c b/gdb/event-top.c
index 5829957e513..1a66721540e 100644
--- a/gdb/event-top.c
+++ b/gdb/event-top.c
@@ -25,7 +25,7 @@
 #include "infrun.h"
 #include "target.h"
 #include "terminal.h"		/* for job_control */
-#include "event-loop.h"
+#include "common/event-loop.h"
 #include "event-top.h"
 #include "interps.h"
 #include <signal.h>
diff --git a/gdb/inf-loop.c b/gdb/inf-loop.c
index d0e19d5f824..34db6a4bce4 100644
--- a/gdb/inf-loop.c
+++ b/gdb/inf-loop.c
@@ -20,7 +20,7 @@
 #include "defs.h"
 #include "inferior.h"
 #include "infrun.h"
-#include "event-loop.h"
+#include "common/event-loop.h"
 #include "event-top.h"
 #include "inf-loop.h"
 #include "remote.h"
diff --git a/gdb/infrun.c b/gdb/infrun.c
index 0eaf1b608b6..029c75bae73 100644
--- a/gdb/infrun.c
+++ b/gdb/infrun.c
@@ -61,7 +61,7 @@
 #include "target-dcache.h"
 #include "terminal.h"
 #include "solist.h"
-#include "event-loop.h"
+#include "common/event-loop.h"
 #include "thread-fsm.h"
 #include "common/enum-flags.h"
 #include "progspace-and-thread.h"
diff --git a/gdb/interps.c b/gdb/interps.c
index b62e33339a2..540786e578a 100644
--- a/gdb/interps.c
+++ b/gdb/interps.c
@@ -32,7 +32,7 @@
 #include "defs.h"
 #include "gdbcmd.h"
 #include "ui-out.h"
-#include "event-loop.h"
+#include "common/event-loop.h"
 #include "event-top.h"
 #include "interps.h"
 #include "completer.h"
diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c
index 063afe26666..4ce78aaceee 100644
--- a/gdb/linux-nat.c
+++ b/gdb/linux-nat.c
@@ -47,7 +47,7 @@
 #include <sys/stat.h>		/* for struct stat */
 #include <fcntl.h>		/* for O_RDONLY */
 #include "inf-loop.h"
-#include "event-loop.h"
+#include "common/event-loop.h"
 #include "event-top.h"
 #include <pwd.h>
 #include <sys/types.h>
diff --git a/gdb/main.c b/gdb/main.c
index f60f0d0a092..043e7b03830 100644
--- a/gdb/main.c
+++ b/gdb/main.c
@@ -28,7 +28,7 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <ctype.h>
-#include "event-loop.h"
+#include "common/event-loop.h"
 #include "ui-out.h"
 
 #include "interps.h"
diff --git a/gdb/mi/mi-interp.c b/gdb/mi/mi-interp.c
index 3e9f36897a8..ea8d6d54907 100644
--- a/gdb/mi/mi-interp.c
+++ b/gdb/mi/mi-interp.c
@@ -20,7 +20,7 @@
 #include "defs.h"
 #include "interps.h"
 #include "event-top.h"
-#include "event-loop.h"
+#include "common/event-loop.h"
 #include "inferior.h"
 #include "infrun.h"
 #include "ui-out.h"
diff --git a/gdb/mi/mi-main.c b/gdb/mi/mi-main.c
index 46bc928d9fe..a39749f1a7c 100644
--- a/gdb/mi/mi-main.c
+++ b/gdb/mi/mi-main.c
@@ -33,7 +33,7 @@
 #include "ui-out.h"
 #include "mi-out.h"
 #include "interps.h"
-#include "event-loop.h"
+#include "common/event-loop.h"
 #include "event-top.h"
 #include "gdbcore.h"		/* For write_memory().  */
 #include "value.h"
diff --git a/gdb/mingw-hdep.c b/gdb/mingw-hdep.c
index 2fa82d1d484..08f1632f4ba 100644
--- a/gdb/mingw-hdep.c
+++ b/gdb/mingw-hdep.c
@@ -20,7 +20,7 @@
 #include "defs.h"
 #include "main.h"
 #include "serial.h"
-#include "event-loop.h"
+#include "common/event-loop.h"
 
 #include "common/gdb_select.h"
 #include "readline/readline.h"
diff --git a/gdb/posix-hdep.c b/gdb/posix-hdep.c
index 97fd9b535a6..b02a76c59c2 100644
--- a/gdb/posix-hdep.c
+++ b/gdb/posix-hdep.c
@@ -18,7 +18,7 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include "defs.h"
-#include "event-loop.h"
+#include "common/event-loop.h"
 
 #include "common/gdb_select.h"
 
diff --git a/gdb/python/python.c b/gdb/python/python.c
index c23db2c1261..154c6023070 100644
--- a/gdb/python/python.c
+++ b/gdb/python/python.c
@@ -27,7 +27,7 @@
 #include "objfiles.h"
 #include "value.h"
 #include "language.h"
-#include "event-loop.h"
+#include "common/event-loop.h"
 #include "serial.h"
 #include "readline/tilde.h"
 #include "python.h"
diff --git a/gdb/record-btrace.c b/gdb/record-btrace.c
index 5319a1b2bb8..d79244129d7 100644
--- a/gdb/record-btrace.c
+++ b/gdb/record-btrace.c
@@ -36,7 +36,7 @@
 #include "frame-unwind.h"
 #include "hashtab.h"
 #include "infrun.h"
-#include "event-loop.h"
+#include "common/event-loop.h"
 #include "inf-loop.h"
 #include "common/vec.h"
 #include "inferior.h"
diff --git a/gdb/record-full.c b/gdb/record-full.c
index 95ccc2c797e..10a5146f4be 100644
--- a/gdb/record-full.c
+++ b/gdb/record-full.c
@@ -31,7 +31,7 @@
 #include "record-full.h"
 #include "elf-bfd.h"
 #include "gcore.h"
-#include "event-loop.h"
+#include "common/event-loop.h"
 #include "inf-loop.h"
 #include "gdb_bfd.h"
 #include "observable.h"
diff --git a/gdb/remote-fileio.c b/gdb/remote-fileio.c
index 91caa2b0726..3db68b8bfc8 100644
--- a/gdb/remote-fileio.c
+++ b/gdb/remote-fileio.c
@@ -25,7 +25,7 @@
 #include "common/gdb_wait.h"
 #include <sys/stat.h>
 #include "remote-fileio.h"
-#include "event-loop.h"
+#include "common/event-loop.h"
 #include "target.h"
 #include "filenames.h"
 #include "common/filestuff.h"
diff --git a/gdb/remote-notif.c b/gdb/remote-notif.c
index 72916023420..d2ffe34efc4 100644
--- a/gdb/remote-notif.c
+++ b/gdb/remote-notif.c
@@ -35,7 +35,7 @@
 #include "remote.h"
 #include "remote-notif.h"
 #include "observable.h"
-#include "event-loop.h"
+#include "common/event-loop.h"
 #include "target.h"
 #include "inferior.h"
 #include "infrun.h"
diff --git a/gdb/remote.c b/gdb/remote.c
index d6561dda61f..c5bc52137a1 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -49,7 +49,7 @@
 
 #include "common/gdb_sys_time.h"
 
-#include "event-loop.h"
+#include "common/event-loop.h"
 #include "event-top.h"
 #include "inf-loop.h"
 
diff --git a/gdb/ser-base.c b/gdb/ser-base.c
index 6411ad7b2f7..8388bec3a7d 100644
--- a/gdb/ser-base.c
+++ b/gdb/ser-base.c
@@ -20,7 +20,7 @@
 #include "defs.h"
 #include "serial.h"
 #include "ser-base.h"
-#include "event-loop.h"
+#include "common/event-loop.h"
 
 #include "common/gdb_select.h"
 #include "common/gdb_sys_time.h"
diff --git a/gdb/top.c b/gdb/top.c
index 91989609c07..9ad4b5a7c04 100644
--- a/gdb/top.c
+++ b/gdb/top.c
@@ -42,7 +42,7 @@
 #include "common/version.h"
 #include "serial.h"
 #include "main.h"
-#include "event-loop.h"
+#include "common/event-loop.h"
 #include "gdbthread.h"
 #include "extension.h"
 #include "interps.h"
diff --git a/gdb/top.h b/gdb/top.h
index 025d9389d60..9c9af1af3e9 100644
--- a/gdb/top.h
+++ b/gdb/top.h
@@ -21,7 +21,7 @@
 #define TOP_H
 
 #include "common/buffer.h"
-#include "event-loop.h"
+#include "common/event-loop.h"
 #include "value.h"
 
 struct tl_interp_info;
diff --git a/gdb/tui/tui-hooks.c b/gdb/tui/tui-hooks.c
index 98c6fd651fa..0e9dbdfc4f4 100644
--- a/gdb/tui/tui-hooks.c
+++ b/gdb/tui/tui-hooks.c
@@ -26,7 +26,7 @@
 #include "objfiles.h"
 #include "target.h"
 #include "gdbcore.h"
-#include "event-loop.h"
+#include "common/event-loop.h"
 #include "event-top.h"
 #include "frame.h"
 #include "breakpoint.h"
diff --git a/gdb/tui/tui-interp.c b/gdb/tui/tui-interp.c
index 14215b83dea..e8f3a69df68 100644
--- a/gdb/tui/tui-interp.c
+++ b/gdb/tui/tui-interp.c
@@ -22,7 +22,7 @@
 #include "interps.h"
 #include "top.h"
 #include "event-top.h"
-#include "event-loop.h"
+#include "common/event-loop.h"
 #include "ui-out.h"
 #include "cli-out.h"
 #include "tui/tui-data.h"
diff --git a/gdb/tui/tui-io.c b/gdb/tui/tui-io.c
index d006e41cabb..bb0bc904f1a 100644
--- a/gdb/tui/tui-io.c
+++ b/gdb/tui/tui-io.c
@@ -21,7 +21,7 @@
 
 #include "defs.h"
 #include "target.h"
-#include "event-loop.h"
+#include "common/event-loop.h"
 #include "event-top.h"
 #include "command.h"
 #include "top.h"
diff --git a/gdb/tui/tui-win.c b/gdb/tui/tui-win.c
index fa1ee89603d..1df21df026d 100644
--- a/gdb/tui/tui-win.c
+++ b/gdb/tui/tui-win.c
@@ -32,7 +32,7 @@
 #include "cli/cli-cmds.h"
 #include "top.h"
 #include "source.h"
-#include "event-loop.h"
+#include "common/event-loop.h"
 #include "async-event.h"
 
 #include "tui/tui.h"
-- 
2.17.2

^ permalink raw reply	[flat|nested] 52+ messages in thread

* [RFC 15/17] Move gdb_notifier comment
  2019-02-24 16:51 [RFC 00/17] Merge event loop implementations Tom Tromey
  2019-02-24 16:52 ` [RFC 13/17] Switch gdbserver to common event loop Tom Tromey
@ 2019-02-24 16:52 ` Tom Tromey
  2019-09-26 14:06   ` Pedro Alves
  2019-02-24 16:52 ` [RFC 11/17] Implement event-loop glue for gdbserver Tom Tromey
                   ` (16 subsequent siblings)
  18 siblings, 1 reply; 52+ messages in thread
From: Tom Tromey @ 2019-02-24 16:52 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This moves the gdb_notifier comment a bit lower in event-loop.c, to
where it belongs.

gdb/ChangeLog
2019-02-24  Tom Tromey  <tom@tromey.com>

	* common/event-loop.c: Move comment.
---
 gdb/ChangeLog           |  4 ++++
 gdb/common/event-loop.c | 22 +++++++++++-----------
 2 files changed, 15 insertions(+), 11 deletions(-)

diff --git a/gdb/common/event-loop.c b/gdb/common/event-loop.c
index 62de430f067..e761ebf27f6 100644
--- a/gdb/common/event-loop.c
+++ b/gdb/common/event-loop.c
@@ -57,17 +57,6 @@ typedef struct file_handler
   }
 file_handler;
 
-/* Gdb_notifier is just a list of file descriptors gdb is interested in.
-   These are the input file descriptor, and the target file
-   descriptor.  We have two flavors of the notifier, one for platforms
-   that have the POLL function, the other for those that don't, and
-   only support SELECT.  Each of the elements in the gdb_notifier list is
-   basically a description of what kind of events gdb is interested
-   in, for each fd.  */
-
-/* As of 1999-04-30 only the input file descriptor is registered with the
-   event loop.  */
-
 /* Do we use poll or select ? */
 #ifdef HAVE_POLL
 #define USE_POLL 1
@@ -82,6 +71,17 @@ static unsigned char use_poll = USE_POLL;
 #include <io.h>
 #endif
 
+/* Gdb_notifier is just a list of file descriptors gdb is interested in.
+   These are the input file descriptor, and the target file
+   descriptor.  We have two flavors of the notifier, one for platforms
+   that have the POLL function, the other for those that don't, and
+   only support SELECT.  Each of the elements in the gdb_notifier list is
+   basically a description of what kind of events gdb is interested
+   in, for each fd.  */
+
+/* As of 1999-04-30 only the input file descriptor is registered with the
+   event loop.  */
+
 static struct
   {
     /* Ptr to head of file handler list.  */
-- 
2.17.2

^ permalink raw reply	[flat|nested] 52+ messages in thread

* [RFC 03/17] Move event-loop configury to common.m4
  2019-02-24 16:51 [RFC 00/17] Merge event loop implementations Tom Tromey
                   ` (15 preceding siblings ...)
  2019-02-24 16:52 ` [RFC 04/17] Move gdb_select.h " Tom Tromey
@ 2019-02-24 16:52 ` Tom Tromey
  2019-02-24 17:14 ` [RFC 00/17] Merge event loop implementations Eli Zaretskii
  2019-09-26 17:47 ` Pedro Alves
  18 siblings, 0 replies; 52+ messages in thread
From: Tom Tromey @ 2019-02-24 16:52 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

gdb_select.h and the event loop require some configure checks, so this
moves the needed checks to common.m4 and updates the configure
scripts.

gdb/ChangeLog
2019-02-24  Tom Tromey  <tom@tromey.com>

	* common/common.m4 (GDB_AC_COMMON): Check for poll.h, sys/poll.h,
	sys/select.h, and poll.
	* configure: Rebuild.
	* configure.ac: Remove checks that are now in GDB_AC_COMMON.

gdb/gdbserver/ChangeLog
2019-02-24  Tom Tromey  <tom@tromey.com>

	* configure: Rebuild.
	* config.in: Rebuild.
---
 gdb/ChangeLog           |  7 +++++++
 gdb/common/common.m4    |  5 +++--
 gdb/configure           | 14 +++++++-------
 gdb/configure.ac        |  6 +++---
 gdb/gdbserver/ChangeLog |  5 +++++
 gdb/gdbserver/config.in | 12 ++++++++++++
 gdb/gdbserver/configure |  4 ++--
 7 files changed, 39 insertions(+), 14 deletions(-)

diff --git a/gdb/common/common.m4 b/gdb/common/common.m4
index 5701dd98293..4461a44c036 100644
--- a/gdb/common/common.m4
+++ b/gdb/common/common.m4
@@ -26,12 +26,13 @@ AC_DEFUN([GDB_AC_COMMON], [
   AM_LANGINFO_CODESET
 
   AC_CHECK_HEADERS(linux/perf_event.h locale.h memory.h signal.h dnl
-		   sys/resource.h sys/socket.h dnl
+		   poll.h sys/poll.h dnl
+		   sys/resource.h sys/select.h sys/socket.h dnl
 		   sys/un.h sys/wait.h dnl
 		   thread_db.h wait.h dnl
 		   termios.h)
 
-  AC_CHECK_FUNCS([fdwalk getrlimit pipe pipe2 socketpair sigaction])
+  AC_CHECK_FUNCS([fdwalk getrlimit pipe pipe2 poll socketpair sigaction])
 
   AC_CHECK_DECLS([strerror, strstr])
 
diff --git a/gdb/configure b/gdb/configure
index 9c99213a168..5bf25045025 100755
--- a/gdb/configure
+++ b/gdb/configure
@@ -11477,8 +11477,8 @@ fi
 
 SRCHIGH_LIBS=
 SRCHIGH_CFLAGS=
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for source highlight" >&5
-$as_echo_n "checking for source highlight... " >&6; }
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for the source-highlight library" >&5
+$as_echo_n "checking for the source-highlight library... " >&6; }
 if test "${pkg_config_prog_path}" = "missing"; then
    { $as_echo "$as_me:${as_lineno-$LINENO}: result: no - pkg-config not found" >&5
 $as_echo "no - pkg-config not found" >&6; }
@@ -12245,11 +12245,11 @@ $as_echo "#define STDC_HEADERS 1" >>confdefs.h
 fi
 
 # elf_hp.h is for HP/UX 64-bit shared library support.
-for ac_header in nlist.h machine/reg.h poll.h sys/poll.h proc_service.h \
+for ac_header in nlist.h machine/reg.h proc_service.h \
                   thread_db.h linux/elf.h \
 		  sys/file.h sys/filio.h sys/ioctl.h sys/param.h \
 		  sys/resource.h sys/procfs.h sys/ptrace.h ptrace.h \
-		  sys/reg.h sys/debugreg.h sys/select.h \
+		  sys/reg.h sys/debugreg.h \
 		  termios.h elf_hp.h \
 		  dlfcn.h
 do :
@@ -13345,7 +13345,7 @@ $as_echo "#define HAVE_WORKING_FORK 1" >>confdefs.h
 fi
 
 for ac_func in getauxval getrusage getuid getgid \
-		pipe poll pread pread64 pwrite resize_term \
+		pipe pread pread64 pwrite resize_term \
 		sbrk getpgid setpgid setpgrp setsid \
 		sigaction sigprocmask sigsetmask socketpair \
 		ttrace wborder wresize setlocale iconvlist libiconvlist btowc \
@@ -13742,7 +13742,7 @@ $as_echo "#define HAVE_LANGINFO_CODESET 1" >>confdefs.h
   fi
 
 
-  for ac_header in linux/perf_event.h locale.h memory.h signal.h 		   sys/resource.h sys/socket.h 		   sys/un.h sys/wait.h 		   thread_db.h wait.h 		   termios.h
+  for ac_header in linux/perf_event.h locale.h memory.h signal.h 		   poll.h sys/poll.h 		   sys/resource.h sys/select.h sys/socket.h 		   sys/un.h sys/wait.h 		   thread_db.h wait.h 		   termios.h
 do :
   as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
 ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
@@ -13756,7 +13756,7 @@ fi
 done
 
 
-  for ac_func in fdwalk getrlimit pipe pipe2 socketpair sigaction
+  for ac_func in fdwalk getrlimit pipe pipe2 poll socketpair sigaction
 do :
   as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
 ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
diff --git a/gdb/configure.ac b/gdb/configure.ac
index f63507ff74e..9b37858affe 100644
--- a/gdb/configure.ac
+++ b/gdb/configure.ac
@@ -1318,11 +1318,11 @@ fi
 
 AC_HEADER_STDC
 # elf_hp.h is for HP/UX 64-bit shared library support.
-AC_CHECK_HEADERS([nlist.h machine/reg.h poll.h sys/poll.h proc_service.h \
+AC_CHECK_HEADERS([nlist.h machine/reg.h proc_service.h \
                   thread_db.h linux/elf.h \
 		  sys/file.h sys/filio.h sys/ioctl.h sys/param.h \
 		  sys/resource.h sys/procfs.h sys/ptrace.h ptrace.h \
-		  sys/reg.h sys/debugreg.h sys/select.h \
+		  sys/reg.h sys/debugreg.h \
 		  termios.h elf_hp.h \
 		  dlfcn.h])
 AC_CHECK_HEADERS(sys/user.h, [], [],
@@ -1377,7 +1377,7 @@ AC_C_BIGENDIAN
 AC_FUNC_MMAP
 AC_FUNC_VFORK
 AC_CHECK_FUNCS([getauxval getrusage getuid getgid \
-		pipe poll pread pread64 pwrite resize_term \
+		pipe pread pread64 pwrite resize_term \
 		sbrk getpgid setpgid setpgrp setsid \
 		sigaction sigprocmask sigsetmask socketpair \
 		ttrace wborder wresize setlocale iconvlist libiconvlist btowc \
diff --git a/gdb/gdbserver/config.in b/gdb/gdbserver/config.in
index 05537df81e3..8b35d20a4b4 100644
--- a/gdb/gdbserver/config.in
+++ b/gdb/gdbserver/config.in
@@ -171,6 +171,12 @@
 /* Define to 1 if you have the `pipe2' function. */
 #undef HAVE_PIPE2
 
+/* Define to 1 if you have the `poll' function. */
+#undef HAVE_POLL
+
+/* Define to 1 if you have the <poll.h> header file. */
+#undef HAVE_POLL_H
+
 /* Define to 1 if you have the `pread' function. */
 #undef HAVE_PREAD
 
@@ -253,6 +259,9 @@
 /* Define to 1 if you have the <sys/ioctl.h> header file. */
 #undef HAVE_SYS_IOCTL_H
 
+/* Define to 1 if you have the <sys/poll.h> header file. */
+#undef HAVE_SYS_POLL_H
+
 /* Define to 1 if you have the <sys/procfs.h> header file. */
 #undef HAVE_SYS_PROCFS_H
 
@@ -265,6 +274,9 @@
 /* Define to 1 if you have the <sys/resource.h> header file. */
 #undef HAVE_SYS_RESOURCE_H
 
+/* Define to 1 if you have the <sys/select.h> header file. */
+#undef HAVE_SYS_SELECT_H
+
 /* Define to 1 if you have the <sys/socket.h> header file. */
 #undef HAVE_SYS_SOCKET_H
 
diff --git a/gdb/gdbserver/configure b/gdb/gdbserver/configure
index 1ddbd6b27e0..ed43b7f50ca 100755
--- a/gdb/gdbserver/configure
+++ b/gdb/gdbserver/configure
@@ -6874,7 +6874,7 @@ $as_echo "#define HAVE_LANGINFO_CODESET 1" >>confdefs.h
   fi
 
 
-  for ac_header in linux/perf_event.h locale.h memory.h signal.h 		   sys/resource.h sys/socket.h 		   sys/un.h sys/wait.h 		   thread_db.h wait.h 		   termios.h
+  for ac_header in linux/perf_event.h locale.h memory.h signal.h 		   poll.h sys/poll.h 		   sys/resource.h sys/select.h sys/socket.h 		   sys/un.h sys/wait.h 		   thread_db.h wait.h 		   termios.h
 do :
   as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
 ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
@@ -6888,7 +6888,7 @@ fi
 done
 
 
-  for ac_func in fdwalk getrlimit pipe pipe2 socketpair sigaction
+  for ac_func in fdwalk getrlimit pipe pipe2 poll socketpair sigaction
 do :
   as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
 ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
-- 
2.17.2

^ permalink raw reply	[flat|nested] 52+ messages in thread

* [RFC 01/17] Remove include from event-loop.c
  2019-02-24 16:51 [RFC 00/17] Merge event loop implementations Tom Tromey
                   ` (11 preceding siblings ...)
  2019-02-24 16:52 ` [RFC 09/17] Introduce async-event.[ch] Tom Tromey
@ 2019-02-24 16:52 ` Tom Tromey
  2019-02-24 16:52 ` [RFC 06/17] Include <chrono> in event-loop.c Tom Tromey
                   ` (5 subsequent siblings)
  18 siblings, 0 replies; 52+ messages in thread
From: Tom Tromey @ 2019-02-24 16:52 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

event-loop.c does not need to include queue.h.

gdb/ChangeLog
2019-02-24  Tom Tromey  <tom@tromey.com>

	* event-loop.c: Don't include queue.h.
---
 gdb/ChangeLog    | 4 ++++
 gdb/event-loop.c | 1 -
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/gdb/event-loop.c b/gdb/event-loop.c
index 28e81646fbd..4d05eb9a243 100644
--- a/gdb/event-loop.c
+++ b/gdb/event-loop.c
@@ -20,7 +20,6 @@
 #include "defs.h"
 #include "event-loop.h"
 #include "event-top.h"
-#include "common/queue.h"
 #include "ser-event.h"
 
 #ifdef HAVE_POLL
-- 
2.17.2

^ permalink raw reply	[flat|nested] 52+ messages in thread

* [RFC 12/17] Add the ability to stop the event loop
  2019-02-24 16:51 [RFC 00/17] Merge event loop implementations Tom Tromey
                   ` (6 preceding siblings ...)
  2019-02-24 16:52 ` [RFC 14/17] Remove some dead code from event-loop.c Tom Tromey
@ 2019-02-24 16:52 ` Tom Tromey
  2019-02-24 16:52 ` [RFC 07/17] Use warning in event-loop Tom Tromey
                   ` (10 subsequent siblings)
  18 siblings, 0 replies; 52+ messages in thread
From: Tom Tromey @ 2019-02-24 16:52 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

gdbserver needs a way to stop the event loop.  This patch adds it.

gdb/ChangeLog
2019-02-24  Tom Tromey  <tom@tromey.com>

	* common/event-loop.h (stop_event_loop): Declare.
	* common/event-loop.c (event_looping): New global.
	(start_event_loop): Check it.
	(stop_event_loop): New function.
---
 gdb/ChangeLog           |  7 +++++++
 gdb/common/event-loop.c | 13 ++++++++++++-
 gdb/common/event-loop.h |  5 +++++
 3 files changed, 24 insertions(+), 1 deletion(-)

diff --git a/gdb/common/event-loop.c b/gdb/common/event-loop.c
index a2563414dfd..b8d5b007163 100644
--- a/gdb/common/event-loop.c
+++ b/gdb/common/event-loop.c
@@ -256,6 +256,8 @@ gdb_do_one_event (void)
   return 1;
 }
 
+static bool event_looping = true;
+
 /* Start up the event loop.  This is the entry point to the event loop
    from the command loop.  */
 
@@ -266,7 +268,8 @@ start_event_loop ()
      the event loop engine.  gdb_do_one_event will process one event
      for each invocation.  It blocks waiting for an event and then
      processes it.  */
-  while (1)
+  event_looping = true;
+  while (event_looping)
     {
       int result = 0;
 
@@ -288,6 +291,14 @@ start_event_loop ()
      to listen to.  So we exit GDB.  */
   return;
 }
+
+/* See event-loop.h.  */
+
+void
+stop_event_loop ()
+{
+  event_looping = false;
+}
 \f
 
 /* Wrapper function for create_file_handler, so that the caller
diff --git a/gdb/common/event-loop.h b/gdb/common/event-loop.h
index 1eec1ed2cd9..9ace0c46f6c 100644
--- a/gdb/common/event-loop.h
+++ b/gdb/common/event-loop.h
@@ -79,6 +79,11 @@ typedef void (timer_handler_func) (gdb_client_data);
 /* Exported functions from event-loop.c */
 
 extern void start_event_loop ();
+
+/* Request that the event loop stop.  */
+
+extern void stop_event_loop ();
+
 extern int gdb_do_one_event (void);
 extern void delete_file_handler (int fd);
 extern void add_file_handler (int fd, handler_func *proc, 
-- 
2.17.2

^ permalink raw reply	[flat|nested] 52+ messages in thread

* [RFC 08/17] Introduce and use flush_streams
  2019-02-24 16:51 [RFC 00/17] Merge event loop implementations Tom Tromey
                   ` (9 preceding siblings ...)
  2019-02-24 16:52 ` [RFC 17/17] Simplify gdbserver's serial event handling Tom Tromey
@ 2019-02-24 16:52 ` Tom Tromey
  2019-02-24 16:52 ` [RFC 09/17] Introduce async-event.[ch] Tom Tromey
                   ` (7 subsequent siblings)
  18 siblings, 0 replies; 52+ messages in thread
From: Tom Tromey @ 2019-02-24 16:52 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

Code in common can't call gdb_flush, so this introduces a new
"flush_streams" function that must be supplied by the client.

Note that the similar gdb_flush_out_err exists, but it isn't defined
in quite the same way, so it wasn't clear to me whether the two could
be merged.

gdb/ChangeLog
2019-02-24  Tom Tromey  <tom@tromey.com>

	* utils.c (flush_streams): New function.
	* event-loop.c (gdb_wait_for_event): Call flush_streams.
	* common/errors.h (flush_streams): Declare.
---
 gdb/ChangeLog       | 6 ++++++
 gdb/common/errors.h | 4 ++++
 gdb/event-loop.c    | 3 +--
 gdb/utils.c         | 9 +++++++++
 4 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/gdb/common/errors.h b/gdb/common/errors.h
index 8dbc6cff5f6..d7738337082 100644
--- a/gdb/common/errors.h
+++ b/gdb/common/errors.h
@@ -87,4 +87,8 @@ extern void perror_with_name (const char *string) ATTRIBUTE_NORETURN;
 
 extern void malloc_failure (long size) ATTRIBUTE_NORETURN;
 
+/* Flush stdout and stderr.  Must be provided by the client.  */
+
+extern void flush_streams ();
+
 #endif /* COMMON_ERRORS_H */
diff --git a/gdb/event-loop.c b/gdb/event-loop.c
index caa910c9f82..b9d9e7e098e 100644
--- a/gdb/event-loop.c
+++ b/gdb/event-loop.c
@@ -727,8 +727,7 @@ gdb_wait_for_event (int block)
   int num_found = 0;
 
   /* Make sure all output is done before getting another event.  */
-  gdb_flush (gdb_stdout);
-  gdb_flush (gdb_stderr);
+  flush_streams ();
 
   if (gdb_notifier.num_fds == 0)
     return -1;
diff --git a/gdb/utils.c b/gdb/utils.c
index e7fde4942ec..a9aef0031b7 100644
--- a/gdb/utils.c
+++ b/gdb/utils.c
@@ -730,6 +730,15 @@ malloc_failure (long size)
     }
 }
 
+/* See common/errors.h.  */
+
+void
+flush_streams ()
+{
+  gdb_flush (gdb_stdout);
+  gdb_flush (gdb_stderr);
+}
+
 /* My replacement for the read system call.
    Used like `read' but keeps going if `read' returns too soon.  */
 
-- 
2.17.2

^ permalink raw reply	[flat|nested] 52+ messages in thread

* [RFC 16/17] Remove gdb_fildes_t
  2019-02-24 16:51 [RFC 00/17] Merge event loop implementations Tom Tromey
                   ` (3 preceding siblings ...)
  2019-02-24 16:52 ` [RFC 02/17] Move gdb-specific code out of start_event_loop Tom Tromey
@ 2019-02-24 16:52 ` Tom Tromey
  2019-02-24 16:52 ` [RFC 05/17] Remove gdb_usleep.c Tom Tromey
                   ` (13 subsequent siblings)
  18 siblings, 0 replies; 52+ messages in thread
From: Tom Tromey @ 2019-02-24 16:52 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

gdb_fildes_t and pfildes are no longer used, so remove them.

2019-02-24  Tom Tromey  <tom@tromey.com>

	* server.h (gdb_fildes_t): Remove typedef.
	* remote-utils.c (remote_desc, list_desc): Now int.
	(INVALID_DESCRIPTOR): Remove.
	(gdb_connected, remote_close)
	(check_remote_input_interrupt_request): Update.
	* utils.h (pfildes): Don't declare.
	* utils.c (pfildes): Remove.
---
 gdb/gdbserver/ChangeLog      | 10 ++++++++++
 gdb/gdbserver/remote-utils.c | 16 +++++-----------
 gdb/gdbserver/server.h       |  7 -------
 gdb/gdbserver/utils.c        | 12 ------------
 gdb/gdbserver/utils.h        |  1 -
 5 files changed, 15 insertions(+), 31 deletions(-)

diff --git a/gdb/gdbserver/remote-utils.c b/gdb/gdbserver/remote-utils.c
index bda261a4a9f..b1e4e869b69 100644
--- a/gdb/gdbserver/remote-utils.c
+++ b/gdb/gdbserver/remote-utils.c
@@ -77,12 +77,6 @@ typedef int socklen_t;
 
 #ifndef IN_PROCESS_AGENT
 
-#if USE_WIN32API
-# define INVALID_DESCRIPTOR INVALID_SOCKET
-#else
-# define INVALID_DESCRIPTOR -1
-#endif
-
 /* Extra value for readchar_callback.  */
 enum {
   /* The callback is currently not scheduled.  */
@@ -110,8 +104,8 @@ struct ui_file *gdb_stdlog;
 
 static int remote_is_stdio = 0;
 
-static gdb_fildes_t remote_desc = INVALID_DESCRIPTOR;
-static gdb_fildes_t listen_desc = INVALID_DESCRIPTOR;
+static int remote_desc = -1;
+static int listen_desc = -1;
 
 /* FIXME headerize? */
 extern int using_threads;
@@ -125,7 +119,7 @@ extern int debug_threads;
 int
 gdb_connected (void)
 {
-  return remote_desc != INVALID_DESCRIPTOR;
+  return remote_desc != -1;
 }
 
 /* Return true if the remote connection is over stdio.  */
@@ -431,7 +425,7 @@ remote_close (void)
   if (! remote_connection_is_stdio ())
     close (remote_desc);
 #endif
-  remote_desc = INVALID_DESCRIPTOR;
+  remote_desc = -1;
 
   reset_readchar ();
 }
@@ -794,7 +788,7 @@ check_remote_input_interrupt_request (void)
   /* This function may be called before establishing communications,
      therefore we need to validate the remote descriptor.  */
 
-  if (remote_desc == INVALID_DESCRIPTOR)
+  if (remote_desc == -1)
     return;
 
   input_interrupt (0);
diff --git a/gdb/gdbserver/server.h b/gdb/gdbserver/server.h
index 5b359c8bae0..e6a8dcc9bf1 100644
--- a/gdb/gdbserver/server.h
+++ b/gdb/gdbserver/server.h
@@ -78,13 +78,6 @@ extern int disable_packet_qfThreadInfo;
 extern int run_once;
 extern int non_stop;
 
-#if USE_WIN32API
-#include <winsock2.h>
-typedef SOCKET gdb_fildes_t;
-#else
-typedef int gdb_fildes_t;
-#endif
-
 #include "common/event-loop.h"
 
 /* Functions from server.c.  */
diff --git a/gdb/gdbserver/utils.c b/gdb/gdbserver/utils.c
index 79a7e80f625..ed5c7fb4e11 100644
--- a/gdb/gdbserver/utils.c
+++ b/gdb/gdbserver/utils.c
@@ -125,15 +125,3 @@ paddress (CORE_ADDR addr)
 {
   return phex_nz (addr, sizeof (CORE_ADDR));
 }
-
-/* Convert a file descriptor into a printable string.  */
-
-char *
-pfildes (gdb_fildes_t fd)
-{
-#if USE_WIN32API
-  return phex_nz (fd, sizeof (gdb_fildes_t));
-#else
-  return plongest (fd);
-#endif
-}
diff --git a/gdb/gdbserver/utils.h b/gdb/gdbserver/utils.h
index 2bc7a6ecab9..dfc9c936892 100644
--- a/gdb/gdbserver/utils.h
+++ b/gdb/gdbserver/utils.h
@@ -20,6 +20,5 @@
 #define GDBSERVER_UTILS_H
 
 char *paddress (CORE_ADDR addr);
-char *pfildes (gdb_fildes_t fd);
 
 #endif /* GDBSERVER_UTILS_H */
-- 
2.17.2

^ permalink raw reply	[flat|nested] 52+ messages in thread

* [RFC 05/17] Remove gdb_usleep.c
  2019-02-24 16:51 [RFC 00/17] Merge event loop implementations Tom Tromey
                   ` (4 preceding siblings ...)
  2019-02-24 16:52 ` [RFC 16/17] Remove gdb_fildes_t Tom Tromey
@ 2019-02-24 16:52 ` Tom Tromey
  2019-09-26 14:02   ` Pedro Alves
  2019-02-24 16:52 ` [RFC 14/17] Remove some dead code from event-loop.c Tom Tromey
                   ` (12 subsequent siblings)
  18 siblings, 1 reply; 52+ messages in thread
From: Tom Tromey @ 2019-02-24 16:52 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

I noticed that gdb_usleep is unused, so this patch removes it.

gdb/ChangeLog
2019-02-24  Tom Tromey  <tom@tromey.com>

	* Makefile.in (COMMON_SFILES): Remove gdb_usleep.c.
	(HFILES_NO_SRCDIR): Remove gdb_usleep.h.
	* gdb_usleep.h: Remove.
	* gdb_usleep.c: Remove.
	* utils.c: Don't include gdb_usleep.h.
---
 gdb/ChangeLog    |  8 ++++++++
 gdb/Makefile.in  |  2 --
 gdb/gdb_usleep.c | 39 ---------------------------------------
 gdb/gdb_usleep.h | 30 ------------------------------
 gdb/utils.c      |  1 -
 5 files changed, 8 insertions(+), 72 deletions(-)
 delete mode 100644 gdb/gdb_usleep.c
 delete mode 100644 gdb/gdb_usleep.h

diff --git a/gdb/Makefile.in b/gdb/Makefile.in
index 5614cc3386c..61b0b9d01bd 100644
--- a/gdb/Makefile.in
+++ b/gdb/Makefile.in
@@ -1031,7 +1031,6 @@ COMMON_SFILES = \
 	gdb-dlfcn.c \
 	gdb_obstack.c \
 	gdb_regex.c \
-	gdb_usleep.c \
 	gdbarch.c \
 	gdbarch-selftests.c \
 	gdbtypes.c \
@@ -1265,7 +1264,6 @@ HFILES_NO_SRCDIR = \
 	gdb_regex.h \
 	gdb_select.h \
 	gdb-stabs.h \
-	gdb_usleep.h \
 	gdb_vfork.h \
 	gdb_wchar.h \
 	gdbarch.h \
diff --git a/gdb/gdb_usleep.c b/gdb/gdb_usleep.c
deleted file mode 100644
index 0dcba0e6fad..00000000000
--- a/gdb/gdb_usleep.c
+++ /dev/null
@@ -1,39 +0,0 @@
-/* Copyright (C) 2009-2019 Free Software Foundation, Inc.
-
-   This file is part of GDB.
-
-   This program is free software; you can redistribute it and/or modify
-   it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 3 of the License, or
-   (at your option) any later version.
-
-   This program is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-   GNU General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
-
-#include "defs.h"
-#include "gdb_usleep.h"
-#include "common/gdb_select.h"
-#include "common/gdb_sys_time.h"
-
-int
-gdb_usleep (int usec)
-{
-  struct timeval delay;
-  int retval;
-
-  delay.tv_sec = usec / 1000000;
-  delay.tv_usec = usec % 1000000;
-  retval = gdb_select (0, 0, 0, 0, &delay);
-
-  if (retval < 0)
-    retval = -1;
-  else
-    retval = 0;
-
-  return retval;
-}
diff --git a/gdb/gdb_usleep.h b/gdb/gdb_usleep.h
deleted file mode 100644
index aadbf0d0ad6..00000000000
--- a/gdb/gdb_usleep.h
+++ /dev/null
@@ -1,30 +0,0 @@
-/* Copyright (C) 2009-2019 Free Software Foundation, Inc.
-
-   This file is part of GDB.
-
-   This program is free software; you can redistribute it and/or modify
-   it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 3 of the License, or
-   (at your option) any later version.
-
-   This program is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-   GNU General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
-
-#if !defined(GDB_USLEEP_H)
-#define GDB_USLEEP_H
-
-/* Suspend execution for USEC microseconds.
-
-   Limitation: If a signal is raised during the delay, gdb_usleep
-   might return earlier than requested.
-
-   It returns 0 on success or -1 on error.  */
-extern int gdb_usleep (int usect);
-
-#endif /* !defined(GDB_USLEEP_H) */
-
diff --git a/gdb/utils.c b/gdb/utils.c
index ec2619642a1..e7fde4942ec 100644
--- a/gdb/utils.c
+++ b/gdb/utils.c
@@ -62,7 +62,6 @@
 
 #include <chrono>
 
-#include "gdb_usleep.h"
 #include "interps.h"
 #include "gdb_regex.h"
 #include "common/job-control.h"
-- 
2.17.2

^ permalink raw reply	[flat|nested] 52+ messages in thread

* [RFC 07/17] Use warning in event-loop
  2019-02-24 16:51 [RFC 00/17] Merge event loop implementations Tom Tromey
                   ` (7 preceding siblings ...)
  2019-02-24 16:52 ` [RFC 12/17] Add the ability to stop the event loop Tom Tromey
@ 2019-02-24 16:52 ` Tom Tromey
  2019-09-26 14:02   ` Pedro Alves
  2019-02-24 16:52 ` [RFC 17/17] Simplify gdbserver's serial event handling Tom Tromey
                   ` (9 subsequent siblings)
  18 siblings, 1 reply; 52+ messages in thread
From: Tom Tromey @ 2019-02-24 16:52 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

Change event-loop.c to avoid printf_unfiltered in favor of warning.
warning is aleady available to code in common/.

gdb/ChangeLog
2019-02-24  Tom Tromey  <tom@tromey.com>

	* event-loop.c (handle_file_event): Use warning, not
	printf_unfiltered.
---
 gdb/ChangeLog    |  5 +++++
 gdb/event-loop.c | 11 +++++------
 2 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/gdb/event-loop.c b/gdb/event-loop.c
index 496111a01c6..caa910c9f82 100644
--- a/gdb/event-loop.c
+++ b/gdb/event-loop.c
@@ -680,11 +680,10 @@ handle_file_event (file_handler *file_ptr, int ready_mask)
 		  /* Work in progress.  We may need to tell somebody
 		     what kind of error we had.  */
 		  if (mask & POLLERR)
-		    printf_unfiltered (_("Error detected on fd %d\n"),
-				       file_ptr->fd);
+		    warning (_("Error detected on fd %d"), file_ptr->fd);
 		  if (mask & POLLNVAL)
-		    printf_unfiltered (_("Invalid or non-`poll'able fd %d\n"),
-				       file_ptr->fd);
+		    warning (_("Invalid or non-`poll'able fd %d"),
+			     file_ptr->fd);
 		  file_ptr->error = 1;
 		}
 	      else
@@ -698,8 +697,8 @@ handle_file_event (file_handler *file_ptr, int ready_mask)
 	    {
 	      if (ready_mask & GDB_EXCEPTION)
 		{
-		  printf_unfiltered (_("Exception condition detected "
-				       "on fd %d\n"), file_ptr->fd);
+		  warning (_("Exception condition detected on fd %d"),
+			   file_ptr->fd);
 		  file_ptr->error = 1;
 		}
 	      else
-- 
2.17.2

^ permalink raw reply	[flat|nested] 52+ messages in thread

* [RFC 17/17] Simplify gdbserver's serial event handling
  2019-02-24 16:51 [RFC 00/17] Merge event loop implementations Tom Tromey
                   ` (8 preceding siblings ...)
  2019-02-24 16:52 ` [RFC 07/17] Use warning in event-loop Tom Tromey
@ 2019-02-24 16:52 ` Tom Tromey
  2019-09-26 17:36   ` Pedro Alves
  2019-02-24 16:52 ` [RFC 08/17] Introduce and use flush_streams Tom Tromey
                   ` (8 subsequent siblings)
  18 siblings, 1 reply; 52+ messages in thread
From: Tom Tromey @ 2019-02-24 16:52 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

Currently, when gdbserver handles a serial event, it also calls
'reschedule' to install a timer that is then used to process any data
that remains after the previous packet was processed.

It seemed better to me to simply have the file descriptor callback
loop, processing packets until complete.

2019-02-24  Tom Tromey  <tom@tromey.com>

	* server.h (handle_serial_event): Update.
	* server.c (handle_serial_event): Return int.  Remove parameters.
	* remote-utils.c (readchar_callback): Remove.
	(handle_accept_event, remote_open): Use handle_all_serial_events.
	(readchar): Don't call reschedule.
	(reset_readchar): Update.
	(process_remaining, reschedule): Remove.
	(handle_all_serial_events): New function.
---
 gdb/gdbserver/ChangeLog      | 11 ++++++++
 gdb/gdbserver/remote-utils.c | 53 +++++++++++++-----------------------
 gdb/gdbserver/server.c       | 10 +++----
 gdb/gdbserver/server.h       |  2 +-
 4 files changed, 35 insertions(+), 41 deletions(-)

diff --git a/gdb/gdbserver/remote-utils.c b/gdb/gdbserver/remote-utils.c
index b1e4e869b69..7b41090efcc 100644
--- a/gdb/gdbserver/remote-utils.c
+++ b/gdb/gdbserver/remote-utils.c
@@ -83,13 +83,9 @@ enum {
   NOT_SCHEDULED = -1
 };
 
-/* Status of the readchar callback.
-   Either NOT_SCHEDULED or the callback id.  */
-static int readchar_callback = NOT_SCHEDULED;
-
 static int readchar (void);
 static void reset_readchar (void);
-static void reschedule (void);
+static void handle_all_serial_events (int err, gdb_client_data client_data);
 
 /* A cache entry for a successfully looked-up symbol.  */
 struct sym_cache
@@ -204,7 +200,7 @@ handle_accept_event (int err, gdb_client_data client_data)
   enable_async_notification (remote_desc);
 
   /* Register the event loop handler.  */
-  add_file_handler (remote_desc, handle_serial_event, NULL);
+  add_file_handler (remote_desc, handle_all_serial_events, NULL);
 
   /* We have a new GDB connection now.  If we were disconnected
      tracing, there's a window where the target could report a stop
@@ -341,7 +337,7 @@ remote_open (const char *name)
       enable_async_notification (remote_desc);
 
       /* Register the event loop handler.  */
-      add_file_handler (remote_desc, handle_serial_event, NULL);
+      add_file_handler (remote_desc, handle_all_serial_events, NULL);
     }
 #ifndef USE_WIN32API
   else if (port_str == NULL)
@@ -382,7 +378,7 @@ remote_open (const char *name)
       enable_async_notification (remote_desc);
 
       /* Register the event loop handler.  */
-      add_file_handler (remote_desc, handle_serial_event, NULL);
+      add_file_handler (remote_desc, handle_all_serial_events, NULL);
     }
 #endif /* USE_WIN32API */
   else
@@ -879,9 +875,9 @@ initialize_async_io (void)
 #endif
 }
 
-/* Internal buffer used by readchar.
-   These are global to readchar because reschedule_remote needs to be
-   able to tell whether the buffer is empty.  */
+/* Internal buffer used by readchar.  These are global to readchar
+   because handle_all_serial_events needs to be able to tell whether
+   the buffer is empty.  */
 
 static unsigned char readchar_buf[BUFSIZ];
 static int readchar_bufcnt = 0;
@@ -916,7 +912,6 @@ readchar (void)
 
   readchar_bufcnt--;
   ch = *readchar_bufp++;
-  reschedule ();
   return ch;
 }
 
@@ -926,33 +921,23 @@ static void
 reset_readchar (void)
 {
   readchar_bufcnt = 0;
-  if (readchar_callback != NOT_SCHEDULED)
-    {
-      delete_timer (readchar_callback);
-      readchar_callback = NOT_SCHEDULED;
-    }
 }
 
-/* Process remaining data in readchar_buf.  */
+/* Loop, calling handle_serial_event, until there is no more data
+   available.  */
 
 static void
-process_remaining (void *context)
+handle_all_serial_events (int err, gdb_client_data client_data)
 {
-  /* This is a one-shot event.  */
-  readchar_callback = NOT_SCHEDULED;
-
-  if (readchar_bufcnt > 0)
-    handle_serial_event (0, NULL);
-}
-
-/* If there is still data in the buffer, queue another event to process it,
-   we can't sleep in select yet.  */
-
-static void
-reschedule (void)
-{
-  if (readchar_bufcnt > 0 && readchar_callback == NOT_SCHEDULED)
-    readchar_callback = create_timer (0, process_remaining, NULL);
+  do
+    {
+      if (handle_serial_event () < 0)
+	{
+	  stop_event_loop ();
+	  break;
+	}
+    }
+  while (readchar_bufcnt > 0);
 }
 
 /* Read a packet from the remote machine, with error checking,
diff --git a/gdb/gdbserver/server.c b/gdb/gdbserver/server.c
index 42147c1d836..3732d53cfbc 100644
--- a/gdb/gdbserver/server.c
+++ b/gdb/gdbserver/server.c
@@ -4389,22 +4389,20 @@ process_serial_event (void)
 
 /* Event-loop callback for serial events.  */
 
-void
-handle_serial_event (int err, gdb_client_data client_data)
+int
+handle_serial_event ()
 {
   if (debug_threads)
     debug_printf ("handling possible serial event\n");
 
   /* Really handle it.  */
   if (process_serial_event () < 0)
-    {
-      stop_event_loop ();
-      return;
-    }
+    return -1;
 
   /* Be sure to not change the selected thread behind GDB's back.
      Important in the non-stop mode asynchronous protocol.  */
   set_desired_thread ();
+  return 0;
 }
 
 /* Push a stop notification on the notification queue.  */
diff --git a/gdb/gdbserver/server.h b/gdb/gdbserver/server.h
index e6a8dcc9bf1..9ffc9e0c958 100644
--- a/gdb/gdbserver/server.h
+++ b/gdb/gdbserver/server.h
@@ -83,7 +83,7 @@ extern int non_stop;
 /* Functions from server.c.  */
 extern void handle_v_requests (char *own_buf, int packet_len,
 			       int *new_packet_len);
-extern void handle_serial_event (int err, gdb_client_data client_data);
+extern int handle_serial_event ();
 extern void handle_target_event (int err, gdb_client_data client_data);
 
 /* Get rid of the currently pending stop replies that match PTID.  */
-- 
2.17.2

^ permalink raw reply	[flat|nested] 52+ messages in thread

* [RFC 11/17] Implement event-loop glue for gdbserver
  2019-02-24 16:51 [RFC 00/17] Merge event loop implementations Tom Tromey
  2019-02-24 16:52 ` [RFC 13/17] Switch gdbserver to common event loop Tom Tromey
  2019-02-24 16:52 ` [RFC 15/17] Move gdb_notifier comment Tom Tromey
@ 2019-02-24 16:52 ` Tom Tromey
  2019-02-24 16:52 ` [RFC 02/17] Move gdb-specific code out of start_event_loop Tom Tromey
                   ` (15 subsequent siblings)
  18 siblings, 0 replies; 52+ messages in thread
From: Tom Tromey @ 2019-02-24 16:52 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

event-loop.c requires the client to provide some functions.  This
patch implements these functions for gdbserver.

gdb/gdbserver/ChangeLog
2019-02-24  Tom Tromey  <tom@tromey.com>

	* server.c (handle_event_loop_exception)
	(invoke_async_signal_handlers, check_async_event_handlers)
	(flush_streams, gdb_select): New functions.
---
 gdb/gdbserver/ChangeLog |  6 ++++++
 gdb/gdbserver/server.c  | 44 +++++++++++++++++++++++++++++++++++++++++
 2 files changed, 50 insertions(+)

diff --git a/gdb/gdbserver/server.c b/gdb/gdbserver/server.c
index e960c10d402..1b2b86813fb 100644
--- a/gdb/gdbserver/server.c
+++ b/gdb/gdbserver/server.c
@@ -4503,6 +4503,50 @@ handle_target_event (int err, gdb_client_data client_data)
   return 0;
 }
 
+/* See common/event-loop.h.  */
+
+void
+handle_event_loop_exception (const gdb_exception &ex)
+{
+  /* gdbserver relies on any exception in getpkt escaping from the
+     event loop, to be caught in captured_main.  */
+  throw_exception (ex);
+}
+
+/* See common/event-loop.h.  */
+
+int
+invoke_async_signal_handlers ()
+{
+  return 0;
+}
+
+/* See common/event-loop.h.  */
+
+int
+check_async_event_handlers ()
+{
+  return 0;
+}
+
+/* See common/errors.h  */
+
+void
+flush_streams ()
+{
+  fflush (stdout);
+  fflush (stderr);
+}
+
+/* See common/gdb_select.h.  */
+
+int
+gdb_select (int n, fd_set *readfds, fd_set *writefds,
+	    fd_set *exceptfds, struct timeval *timeout)
+{
+  return select (n, readfds, writefds, exceptfds, timeout);
+}
+
 #if GDB_SELF_TEST
 namespace selftests
 {
-- 
2.17.2

^ permalink raw reply	[flat|nested] 52+ messages in thread

* [RFC 06/17] Include <chrono> in event-loop.c
  2019-02-24 16:51 [RFC 00/17] Merge event loop implementations Tom Tromey
                   ` (12 preceding siblings ...)
  2019-02-24 16:52 ` [RFC 01/17] Remove include from event-loop.c Tom Tromey
@ 2019-02-24 16:52 ` Tom Tromey
  2019-09-26 14:02   ` Pedro Alves
  2019-02-24 16:52 ` [RFC 10/17] Move event-loop.[ch] to common/ Tom Tromey
                   ` (4 subsequent siblings)
  18 siblings, 1 reply; 52+ messages in thread
From: Tom Tromey @ 2019-02-24 16:52 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

Include <chrono> in event-loop.c, because it is used there.  Currently
it is included indirectly, but after the subsequent patches this will
no longer be the case.

gdb/ChangeLog
2019-02-24  Tom Tromey  <tom@tromey.com>

	* event-loop.c: Include <chrono>.
---
 gdb/ChangeLog    | 4 ++++
 gdb/event-loop.c | 2 ++
 2 files changed, 6 insertions(+)

diff --git a/gdb/event-loop.c b/gdb/event-loop.c
index 41ac5802703..496111a01c6 100644
--- a/gdb/event-loop.c
+++ b/gdb/event-loop.c
@@ -21,6 +21,8 @@
 #include "event-loop.h"
 #include "ser-event.h"
 
+#include <chrono>
+
 #ifdef HAVE_POLL
 #if defined (HAVE_POLL_H)
 #include <poll.h>
-- 
2.17.2

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [RFC 00/17] Merge event loop implementations
  2019-02-24 16:51 [RFC 00/17] Merge event loop implementations Tom Tromey
                   ` (16 preceding siblings ...)
  2019-02-24 16:52 ` [RFC 03/17] Move event-loop configury to common.m4 Tom Tromey
@ 2019-02-24 17:14 ` Eli Zaretskii
  2019-02-24 17:26   ` Tom Tromey
  2019-09-26 17:47 ` Pedro Alves
  18 siblings, 1 reply; 52+ messages in thread
From: Eli Zaretskii @ 2019-02-24 17:14 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

> From: Tom Tromey <tom@tromey.com>
> Date: Sun, 24 Feb 2019 09:51:36 -0700
> 
> The second unresolved issue involves the USE_WIN32API code.  Before
> this series, gdbserver used gdb_fildes_t, defined like:
> 
>     #if USE_WIN32API
>     #include <winsock2.h>
>     typedef SOCKET gdb_fildes_t;
>     #else
>     typedef int gdb_fildes_t;
>     #endif
> 
> gdb did not use this approach, but does have a separate gdb_select
> implementation in mingw-hdep.c, which gdbserver does not.
> 
> I don't know much about Windows, so I don't know why these things are
> needed.  I did a build using " --host=i686-w64-mingw32
> --target=i686-w64-mingw32", and everything built just fine using a
> POSIX-style API.
> 
> Given that, I removed gdb_fildes_t in this series.  However, perhaps
> it is still needed and this series needs some more work.  I could use
> some advice here -- when is this code actually needed and is there a
> way I can reproduce any problems?  I don't have a Windows host, so I'm
> hoping for some sort of compile-time error using a mingw cross.

The problem here is that Windows' implementation of 'select' works
only on sockets, and wants HSOCKET handles instead of file
descriptors.  If you feed it a file descriptor, it won't work, even if
the descriptor is for a socket.

I cannot really tell, by reading the patches, what code would
gdbserver on Windows use after this series, so I don't know whether it
will be broken or not.  But one thing I do see is that mingw-hdep.c
doesn't support waiting on write descriptors, whereas gdbserver's
event-loop.c seems to support that.

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [RFC 00/17] Merge event loop implementations
  2019-02-24 17:14 ` [RFC 00/17] Merge event loop implementations Eli Zaretskii
@ 2019-02-24 17:26   ` Tom Tromey
  2019-02-24 17:45     ` Eli Zaretskii
  0 siblings, 1 reply; 52+ messages in thread
From: Tom Tromey @ 2019-02-24 17:26 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: Tom Tromey, gdb-patches

>>>>> "Eli" == Eli Zaretskii <eliz@gnu.org> writes:

Eli> The problem here is that Windows' implementation of 'select' works
Eli> only on sockets, and wants HSOCKET handles instead of file
Eli> descriptors.  If you feed it a file descriptor, it won't work, even if
Eli> the descriptor is for a socket.

Thanks.

I am still not sure what to do.  Move the mingw-hdep select code to
common?  Or is it better to reintroduce gdb_fildes_t and use it
everywhere?  The former seems simpler I suppose, but the way that the
mingw-hdep select implementation relies on readline gives me pause.
Though perhaps that code will be removed in the readline upgrade, when I
get back to that?  So one idea might be to try to land that first.

Eli> I cannot really tell, by reading the patches, what code would
Eli> gdbserver on Windows use after this series, so I don't know whether it
Eli> will be broken or not.  But one thing I do see is that mingw-hdep.c
Eli> doesn't support waiting on write descriptors, whereas gdbserver's
Eli> event-loop.c seems to support that.

Both event loops claim to support it, but in practice it isn't actually
exposed via the API -- the only exposed API is add_file_handler, which
doesn't allow for requesting a write notification.  All the write stuff
is dead code.

One other thing I forgot to mention is that maybe it would be nice to
just remove gdb's event loop entirely in favor of something like
libevent.  Though of course it is a pain to introduce a new dependency.

Tom

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [RFC 00/17] Merge event loop implementations
  2019-02-24 17:26   ` Tom Tromey
@ 2019-02-24 17:45     ` Eli Zaretskii
  2019-02-25 19:57       ` Tom Tromey
  0 siblings, 1 reply; 52+ messages in thread
From: Eli Zaretskii @ 2019-02-24 17:45 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

> From: Tom Tromey <tom@tromey.com>
> Cc: Tom Tromey <tom@tromey.com>,  gdb-patches@sourceware.org
> Date: Sun, 24 Feb 2019 10:25:55 -0700
> 
> >>>>> "Eli" == Eli Zaretskii <eliz@gnu.org> writes:
> 
> Eli> The problem here is that Windows' implementation of 'select' works
> Eli> only on sockets, and wants HSOCKET handles instead of file
> Eli> descriptors.  If you feed it a file descriptor, it won't work, even if
> Eli> the descriptor is for a socket.
> 
> Thanks.
> 
> I am still not sure what to do.  Move the mingw-hdep select code to
> common?  Or is it better to reintroduce gdb_fildes_t and use it
> everywhere?  The former seems simpler I suppose, but the way that the
> mingw-hdep select implementation relies on readline gives me pause.

The readline bits should IMO be moved to readline, where it calls
'select'.

> Though perhaps that code will be removed in the readline upgrade, when I
> get back to that?  So one idea might be to try to land that first.

I'm sorry, I cannot help you with this dilemma.  Not unless someone
describes in more detail the actual needs of both GDB and gdbserver
for which they call 'select'.  I myself don't know enough about the
internals to give any advice.

The long-term goal is probably to import the Gnulib implementation of
'select', which AFAIR supports any kind of descriptors.  But that
would need some adaptation work.

So, if no one chimes in with more specific advice, perhaps leave this
particular part out of this series.

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [RFC 00/17] Merge event loop implementations
  2019-02-24 17:45     ` Eli Zaretskii
@ 2019-02-25 19:57       ` Tom Tromey
  2019-02-25 20:30         ` Eli Zaretskii
  0 siblings, 1 reply; 52+ messages in thread
From: Tom Tromey @ 2019-02-25 19:57 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: Tom Tromey, gdb-patches

>>>>> "Eli" == Eli Zaretskii <eliz@gnu.org> writes:

Eli> I'm sorry, I cannot help you with this dilemma.  Not unless someone
Eli> describes in more detail the actual needs of both GDB and gdbserver
Eli> for which they call 'select'.  I myself don't know enough about the
Eli> internals to give any advice.

No problem.

For gdb, this series doesn't actually change anything.  So, it's really
only gdbserver that we have to be concerned with.

By my reading of the code, gdbserver on Windows can call select with
just two file descriptors: one that is a socket that is being 'listen'd
to, and another which is the result of 'accept'.  (On other hosts,
gdbserver can also read from stdin, but this is explicitly rejected on
Windows.)

Eli> The long-term goal is probably to import the Gnulib implementation of
Eli> 'select', which AFAIR supports any kind of descriptors.  But that
Eli> would need some adaptation work.

Do you know offhand what is needed?  I didn't know that gnulib had
this... this does seem like a good way to go if possible.

Tom

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [RFC 00/17] Merge event loop implementations
  2019-02-25 19:57       ` Tom Tromey
@ 2019-02-25 20:30         ` Eli Zaretskii
  2019-02-25 20:55           ` Tom Tromey
  0 siblings, 1 reply; 52+ messages in thread
From: Eli Zaretskii @ 2019-02-25 20:30 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

> From: Tom Tromey <tom@tromey.com>
> Cc: Tom Tromey <tom@tromey.com>,  gdb-patches@sourceware.org
> Date: Mon, 25 Feb 2019 12:57:49 -0700
> 
> By my reading of the code, gdbserver on Windows can call select with
> just two file descriptors: one that is a socket that is being 'listen'd
> to, and another which is the result of 'accept'.

Can you point me to the gdbserver code which calls 'socket' and
'accept' on Windows, whose results are used in 'select'?  I'd like to
see what it does on Windows, to be able to have a better idea of what
adaptations would be necessary for Gnulib's 'select'.

> Eli> The long-term goal is probably to import the Gnulib implementation of
> Eli> 'select', which AFAIR supports any kind of descriptors.  But that
> Eli> would need some adaptation work.
> 
> Do you know offhand what is needed?  I didn't know that gnulib had
> this... this does seem like a good way to go if possible.

Offhand, I think we'd need just the trivial adaptations, like make
sure gdbserver uses file descriptors instead of HSOCKETs on Windows as
well.  Probably it would be best to import Gnulib's 'socket' and
'accept' as well, and use their SOCKET_TO_FD and FD_TO_SOCKET macros
if/where needed (hopefully nowhere).  Are there any more related APIs,
besides those 3?  I guess, 'close' (which should call 'closesocket' on
Windows) and perhaps 'ioctl'?  Gnulib has those as well.

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [RFC 00/17] Merge event loop implementations
  2019-02-25 20:30         ` Eli Zaretskii
@ 2019-02-25 20:55           ` Tom Tromey
  2019-02-26 16:04             ` Eli Zaretskii
  0 siblings, 1 reply; 52+ messages in thread
From: Tom Tromey @ 2019-02-25 20:55 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: Tom Tromey, gdb-patches

Eli> Can you point me to the gdbserver code which calls 'socket' and
Eli> 'accept' on Windows, whose results are used in 'select'?  I'd like to
Eli> see what it does on Windows, to be able to have a better idea of what
Eli> adaptations would be necessary for Gnulib's 'select'.

Everything is in gdb/gdbserver/remote-utils.c.  Search for the calls to
add_file_handler.

handle_accept_event calls accept, sets remote_desc, then calls
add_file_handler for it.

remote_open does the other call.  It is maybe less than obvious but this
code rules out the use of stdin on windows:

    #ifdef USE_WIN32API
      if (port_str == NULL)
        error ("Only HOST:PORT is supported on this platform.");
    #endif

So, the STDIO_CONNECTION_NAME branch cannot be taken; the others are
#if'd out; leaving just the final one that calls add_file_handler on
listen_desc.  listen_desc is actually created in remote_prepare.

Eli> Offhand, I think we'd need just the trivial adaptations, like make
Eli> sure gdbserver uses file descriptors instead of HSOCKETs on Windows as
Eli> well.  Probably it would be best to import Gnulib's 'socket' and
Eli> 'accept' as well, and use their SOCKET_TO_FD and FD_TO_SOCKET macros
Eli> if/where needed (hopefully nowhere).  Are there any more related APIs,
Eli> besides those 3?  I guess, 'close' (which should call 'closesocket' on
Eli> Windows) and perhaps 'ioctl'?  Gnulib has those as well.

gdbserver uses setsockopt as well.

Tom

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [RFC 00/17] Merge event loop implementations
  2019-02-25 20:55           ` Tom Tromey
@ 2019-02-26 16:04             ` Eli Zaretskii
  2019-02-26 16:23               ` Tom Tromey
  0 siblings, 1 reply; 52+ messages in thread
From: Eli Zaretskii @ 2019-02-26 16:04 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

> From: Tom Tromey <tom@tromey.com>
> Cc: Tom Tromey <tom@tromey.com>,  gdb-patches@sourceware.org
> Date: Mon, 25 Feb 2019 13:55:13 -0700
> 
> Eli> Can you point me to the gdbserver code which calls 'socket' and
> Eli> 'accept' on Windows, whose results are used in 'select'?  I'd like to
> Eli> see what it does on Windows, to be able to have a better idea of what
> Eli> adaptations would be necessary for Gnulib's 'select'.
> 
> Everything is in gdb/gdbserver/remote-utils.c.  Search for the calls to
> add_file_handler.
> 
> handle_accept_event calls accept, sets remote_desc, then calls
> add_file_handler for it.

Thanks.  It sounds like most of the adaptation is to use Gnulib's
replacements for these functions, and remove most or all of the
USE_WIN32API ifdef's.

> remote_open does the other call.  It is maybe less than obvious but this
> code rules out the use of stdin on windows:
> 
>     #ifdef USE_WIN32API
>       if (port_str == NULL)
>         error ("Only HOST:PORT is supported on this platform.");
>     #endif
> 
> So, the STDIO_CONNECTION_NAME branch cannot be taken; the others are
> #if'd out; leaving just the final one that calls add_file_handler on
> listen_desc.  listen_desc is actually created in remote_prepare.

I guess stdin is disabled because 'select' doesn't support it.  But
with Gnulib, we could allow that, although perhaps not in the initial
phase of the changes.

> Eli> Offhand, I think we'd need just the trivial adaptations, like make
> Eli> sure gdbserver uses file descriptors instead of HSOCKETs on Windows as
> Eli> well.  Probably it would be best to import Gnulib's 'socket' and
> Eli> 'accept' as well, and use their SOCKET_TO_FD and FD_TO_SOCKET macros
> Eli> if/where needed (hopefully nowhere).  Are there any more related APIs,
> Eli> besides those 3?  I guess, 'close' (which should call 'closesocket' on
> Eli> Windows) and perhaps 'ioctl'?  Gnulib has those as well.
> 
> gdbserver uses setsockopt as well.

And also 'accept' and 'bind', all of them are available in Gnulib.  As
a nice bonus, we get to remove the USE_WIN32API parts that call
'closesocket' where on Posix platforms we call 'close', because
Gnulib's 'close' does that as well.

So, on balance I think if we want to remove USE_WIN32API regarding
sockets and related stuff, importing Gnulib replacements will be much
less work, and might also enable some features that are currently
disabled.

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [RFC 00/17] Merge event loop implementations
  2019-02-26 16:04             ` Eli Zaretskii
@ 2019-02-26 16:23               ` Tom Tromey
  2019-02-26 16:46                 ` Eli Zaretskii
  0 siblings, 1 reply; 52+ messages in thread
From: Tom Tromey @ 2019-02-26 16:23 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: Tom Tromey, gdb-patches

>>>>> "Eli" == Eli Zaretskii <eliz@gnu.org> writes:

Eli> So, on balance I think if we want to remove USE_WIN32API regarding
Eli> sockets and related stuff, importing Gnulib replacements will be much
Eli> less work, and might also enable some features that are currently
Eli> disabled.

Yes, that sounds quite nice.  I have a patch to update gnulib and to add
new gnulib modules for most of these things (I forgot to do 'bind' but
that's easily rectified).  I can write the change to remove the relevant
USE_WIN32API bits -- but I can only build it, not test it.  If I send a
patch can you give it a try?

thanks,
Tom

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [RFC 00/17] Merge event loop implementations
  2019-02-26 16:23               ` Tom Tromey
@ 2019-02-26 16:46                 ` Eli Zaretskii
  0 siblings, 0 replies; 52+ messages in thread
From: Eli Zaretskii @ 2019-02-26 16:46 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

> From: Tom Tromey <tom@tromey.com>
> Cc: Tom Tromey <tom@tromey.com>,  gdb-patches@sourceware.org
> Date: Tue, 26 Feb 2019 09:22:59 -0700
> 
> Yes, that sounds quite nice.  I have a patch to update gnulib and to add
> new gnulib modules for most of these things (I forgot to do 'bind' but
> that's easily rectified).  I can write the change to remove the relevant
> USE_WIN32API bits -- but I can only build it, not test it.  If I send a
> patch can you give it a try?

Yes, although it might take some time.  For testing, I guess I should
go through testsuite/gdb.server and run at least some of that manually?

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [RFC 07/17] Use warning in event-loop
  2019-02-24 16:52 ` [RFC 07/17] Use warning in event-loop Tom Tromey
@ 2019-09-26 14:02   ` Pedro Alves
  0 siblings, 0 replies; 52+ messages in thread
From: Pedro Alves @ 2019-09-26 14:02 UTC (permalink / raw)
  To: Tom Tromey, gdb-patches

On 2/24/19 4:51 PM, Tom Tromey wrote:
> Change event-loop.c to avoid printf_unfiltered in favor of warning.
> warning is aleady available to code in common/.
> 
> gdb/ChangeLog
> 2019-02-24  Tom Tromey  <tom@tromey.com>
> 
> 	* event-loop.c (handle_file_event): Use warning, not
> 	printf_unfiltered.

OK.

Thanks,
Pedro Alves

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [RFC 06/17] Include <chrono> in event-loop.c
  2019-02-24 16:52 ` [RFC 06/17] Include <chrono> in event-loop.c Tom Tromey
@ 2019-09-26 14:02   ` Pedro Alves
  0 siblings, 0 replies; 52+ messages in thread
From: Pedro Alves @ 2019-09-26 14:02 UTC (permalink / raw)
  To: Tom Tromey, gdb-patches

On 2/24/19 4:51 PM, Tom Tromey wrote:
> Include <chrono> in event-loop.c, because it is used there.  Currently
> it is included indirectly, but after the subsequent patches this will
> no longer be the case.
> 
> gdb/ChangeLog
> 2019-02-24  Tom Tromey  <tom@tromey.com>
> 
> 	* event-loop.c: Include <chrono>.

OK.

Thanks,
Pedro Alves

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [RFC 05/17] Remove gdb_usleep.c
  2019-02-24 16:52 ` [RFC 05/17] Remove gdb_usleep.c Tom Tromey
@ 2019-09-26 14:02   ` Pedro Alves
  2019-09-26 14:43     ` Tom Tromey
  0 siblings, 1 reply; 52+ messages in thread
From: Pedro Alves @ 2019-09-26 14:02 UTC (permalink / raw)
  To: Tom Tromey, gdb-patches

On 2/24/19 4:51 PM, Tom Tromey wrote:
> I noticed that gdb_usleep is unused, so this patch removes it.
> 
> gdb/ChangeLog
> 2019-02-24  Tom Tromey  <tom@tromey.com>
> 
> 	* Makefile.in (COMMON_SFILES): Remove gdb_usleep.c.
> 	(HFILES_NO_SRCDIR): Remove gdb_usleep.h.
> 	* gdb_usleep.h: Remove.
> 	* gdb_usleep.c: Remove.
> 	* utils.c: Don't include gdb_usleep.h.

Indeed, I noticed this too recently.  You could go ahead and
merge this one, get it out of the way.

Thanks,
Pedro Alves

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [RFC 02/17] Move gdb-specific code out of start_event_loop
  2019-02-24 16:52 ` [RFC 02/17] Move gdb-specific code out of start_event_loop Tom Tromey
@ 2019-09-26 14:02   ` Pedro Alves
  0 siblings, 0 replies; 52+ messages in thread
From: Pedro Alves @ 2019-09-26 14:02 UTC (permalink / raw)
  To: Tom Tromey, gdb-patches

On 2/24/19 4:51 PM, Tom Tromey wrote:
> This moves some gdb-specific code out of start_event_loop, into a new
> function that must be supplied by the event-loop client.
> 
> gdb/ChangeLog
> 2019-02-24  Tom Tromey  <tom@tromey.com>
> 
> 	* main.c (handle_event_loop_exception): New function.
> 	* event-loop.c: Don't include event-top.h or observable.h.
> 	(start_event_loop): Remove gdb-specific code.  Call
> 	handle_event_loop_exception.
> 	* event-loop.h (handle_event_loop_exception): Declare.

I think I'd rather move the whole start_event_loop to gdb.
IIUC, gdbserver version wants to let the exception propagate, so
it'd end up being a while (1) loop calling gdb_do_one_event.

I think the result will be clearer with fewer callsbacks and
no need for the shared ability to stop the event loop that is
only used by gdbserver.

Thanks,
Pedro Alves

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [RFC 10/17] Move event-loop.[ch] to common/
  2019-02-24 16:52 ` [RFC 10/17] Move event-loop.[ch] to common/ Tom Tromey
@ 2019-09-26 14:06   ` Pedro Alves
  2019-10-04 22:06     ` Tom Tromey
  0 siblings, 1 reply; 52+ messages in thread
From: Pedro Alves @ 2019-09-26 14:06 UTC (permalink / raw)
  To: Tom Tromey, gdb-patches

On 2/24/19 4:51 PM, Tom Tromey wrote:
> --- a/gdb/event-loop.h
> +++ b/gdb/common/event-loop.h
> @@ -70,6 +70,8 @@
>  
>     Corollary tasks are the creation and deletion of event sources.  */
>  
> +#include "common/function-view.h"
> +

Is this needed here?

>  typedef void *gdb_client_data;
>  typedef void (handler_func) (int, gdb_client_data);
>  typedef void (timer_handler_func) (gdb_client_data);

Thanks,
Pedro Alves

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [RFC 09/17] Introduce async-event.[ch]
  2019-02-24 16:52 ` [RFC 09/17] Introduce async-event.[ch] Tom Tromey
@ 2019-09-26 14:06   ` Pedro Alves
  2019-10-04 22:17     ` Tom Tromey
  0 siblings, 1 reply; 52+ messages in thread
From: Pedro Alves @ 2019-09-26 14:06 UTC (permalink / raw)
  To: Tom Tromey, gdb-patches

On 2/24/19 4:51 PM, Tom Tromey wrote:
> This patch splits out some gdb-specific code from event-loop, into new
> files async-event.[ch].  Strictly speaking this code could perhaps be
> put into common/, but because gdbserver does not currently use it, it
> seemed better, for size reasons, to split it out.

Seems fine.  Going forward, I wonder whether we'll split event loop
things into more files, and whether using a name prefix like "event-loop-"
or "el-", like "el-async-event.[ch]" would help keeping things a bit
closer together.  Just a thought; not a request.

Thanks,
Pedro Alves

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [RFC 15/17] Move gdb_notifier comment
  2019-02-24 16:52 ` [RFC 15/17] Move gdb_notifier comment Tom Tromey
@ 2019-09-26 14:06   ` Pedro Alves
  0 siblings, 0 replies; 52+ messages in thread
From: Pedro Alves @ 2019-09-26 14:06 UTC (permalink / raw)
  To: Tom Tromey, gdb-patches

On 2/24/19 4:51 PM, Tom Tromey wrote:
> This moves the gdb_notifier comment a bit lower in event-loop.c, to
> where it belongs.
> 
> gdb/ChangeLog
> 2019-02-24  Tom Tromey  <tom@tromey.com>
> 
> 	* common/event-loop.c: Move comment.
> ---
>  gdb/ChangeLog           |  4 ++++
>  gdb/common/event-loop.c | 22 +++++++++++-----------
>  2 files changed, 15 insertions(+), 11 deletions(-)
> 
> diff --git a/gdb/common/event-loop.c b/gdb/common/event-loop.c
> index 62de430f067..e761ebf27f6 100644
> --- a/gdb/common/event-loop.c
> +++ b/gdb/common/event-loop.c
> @@ -57,17 +57,6 @@ typedef struct file_handler
>    }
>  file_handler;
>  
> -/* Gdb_notifier is just a list of file descriptors gdb is interested in.
> -   These are the input file descriptor, and the target file
> -   descriptor.  We have two flavors of the notifier, one for platforms
> -   that have the POLL function, the other for those that don't, and
> -   only support SELECT.  Each of the elements in the gdb_notifier list is
> -   basically a description of what kind of events gdb is interested
> -   in, for each fd.  */
> -
> -/* As of 1999-04-30 only the input file descriptor is registered with the
> -   event loop.  */
> -
>  /* Do we use poll or select ? */
>  #ifdef HAVE_POLL
>  #define USE_POLL 1
> @@ -82,6 +71,17 @@ static unsigned char use_poll = USE_POLL;
>  #include <io.h>
>  #endif
>  
> +/* Gdb_notifier is just a list of file descriptors gdb is interested in.
> +   These are the input file descriptor, and the target file
> +   descriptor.  We have two flavors of the notifier, one for platforms
> +   that have the POLL function, the other for those that don't, and
> +   only support SELECT.  Each of the elements in the gdb_notifier list is
> +   basically a description of what kind of events gdb is interested
> +   in, for each fd.  */
> +
> +/* As of 1999-04-30 only the input file descriptor is registered with the
> +   event loop.  */

Might as well remove this stale "as of 1999-04-30" remark.  We
certainly register more file descriptors in the event loop nowadays.

> +
>  static struct
>    {
>      /* Ptr to head of file handler list.  */
> 


-- 
Thanks,
Pedro Alves

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [RFC 05/17] Remove gdb_usleep.c
  2019-09-26 14:02   ` Pedro Alves
@ 2019-09-26 14:43     ` Tom Tromey
  0 siblings, 0 replies; 52+ messages in thread
From: Tom Tromey @ 2019-09-26 14:43 UTC (permalink / raw)
  To: Pedro Alves; +Cc: Tom Tromey, gdb-patches

>>>>> "Pedro" == Pedro Alves <palves@redhat.com> writes:

Pedro> On 2/24/19 4:51 PM, Tom Tromey wrote:
>> I noticed that gdb_usleep is unused, so this patch removes it.
>> 
>> gdb/ChangeLog
>> 2019-02-24  Tom Tromey  <tom@tromey.com>
>> 
>> * Makefile.in (COMMON_SFILES): Remove gdb_usleep.c.
>> (HFILES_NO_SRCDIR): Remove gdb_usleep.h.
>> * gdb_usleep.h: Remove.
>> * gdb_usleep.c: Remove.
>> * utils.c: Don't include gdb_usleep.h.

Pedro> Indeed, I noticed this too recently.  You could go ahead and
Pedro> merge this one, get it out of the way.

Thanks, I'm going to check it in momentarily.

Tom

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [RFC 17/17] Simplify gdbserver's serial event handling
  2019-02-24 16:52 ` [RFC 17/17] Simplify gdbserver's serial event handling Tom Tromey
@ 2019-09-26 17:36   ` Pedro Alves
  2019-10-04 22:08     ` Tom Tromey
  0 siblings, 1 reply; 52+ messages in thread
From: Pedro Alves @ 2019-09-26 17:36 UTC (permalink / raw)
  To: Tom Tromey, gdb-patches

On 2/24/19 4:51 PM, Tom Tromey wrote:
> Currently, when gdbserver handles a serial event, it also calls
> 'reschedule' to install a timer that is then used to process any data
> that remains after the previous packet was processed.
> 
> It seemed better to me to simply have the file descriptor callback
> loop, processing packets until complete.

I would rather not do this change, because it potentially starves other
event sources.  I've had to fix starvation issues like that in several
places in gdb throughout the years -- see url I pointed that justifying
need for async serial events, random_pending_event_thread in
infrun.c, etc.

Thanks,
Pedro Alves

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [RFC 00/17] Merge event loop implementations
  2019-02-24 16:51 [RFC 00/17] Merge event loop implementations Tom Tromey
                   ` (17 preceding siblings ...)
  2019-02-24 17:14 ` [RFC 00/17] Merge event loop implementations Eli Zaretskii
@ 2019-09-26 17:47 ` Pedro Alves
  2019-09-26 23:09   ` Tom Tromey
  2019-10-04 22:25   ` Tom Tromey
  18 siblings, 2 replies; 52+ messages in thread
From: Pedro Alves @ 2019-09-26 17:47 UTC (permalink / raw)
  To: Tom Tromey, gdb-patches

On 2/24/19 4:51 PM, Tom Tromey wrote:
> This series merges the gdb and gdbserver forks of event-loop.[ch].

Thanks for doing this.

> This is an RFC because there are a few possibly unresolved issues.
> 
> Most of the patches are straightforward.  The series begins by tidying
> up the gdb event-loop code, removing things that are specific to gdb.
> Then, the code is moved.  After this, gdbserver is switched to use the
> common code; and finally, a few cleanups are applied.
> 
> I initially attempted something more ambitious here: unifying the
> async event and async signal code in event-loop (as I do not
> understand the reason for the difference); and then further handling
> the async signal code using the same code path as ordinary file
> descriptors.

See:

 https://sourceware.org/ml/gdb-patches/2008-10/msg00595.html

> 
> However, this didn't work, and since it was not directly important to
> my goal of merging event loops, I dropped it.  I think it may be worth
> reviving.  For example I think th async event code suffers from the
> same race that led Pedro to change the async signal code to use a the
> self-pipe trick.



> 
> Another related possible to-do item is changing the ser-event code to
> maintain just a single self-pipe.  It seems to me that there's never a
> reason to need more than one.

Can you clarify/expand?  Are you suggesting to use one single pipe,
and then if select/poll wakes up, go through a list of registered
ser-events to know which one triggered?  Or something else?

> 
> create_file_handler may have a latent bug where the global select
> masks are not updated if it is called a second time for the same file
> descriptor.  Both versions of the event loop have this issue; I didn't
> try to verify it, so perhaps I'm just misunderstanding the code here.

I think you're right.

> 
> The final patch simplifies the rather convoluted handling of "serial"
> (meaning remote protocol) input in gdbserver.  It passes testing, but
> I wonder whether there's some subtle reason that the code is written
> the way it is.  This is one of the unresolved issues I mentioned.

I replied to this one directly.

> 
> The second unresolved issue involves the USE_WIN32API code.  Before
> this series, gdbserver used gdb_fildes_t, defined like:
> 
>     #if USE_WIN32API
>     #include <winsock2.h>
>     typedef SOCKET gdb_fildes_t;
>     #else
>     typedef int gdb_fildes_t;
>     #endif
> 
> gdb did not use this approach, but does have a separate gdb_select
> implementation in mingw-hdep.c, which gdbserver does not.
> 
> I don't know much about Windows, so I don't know why these things are
> needed.  I did a build using " --host=i686-w64-mingw32
> --target=i686-w64-mingw32", and everything built just fine using a
> POSIX-style API.
> 
> Given that, I removed gdb_fildes_t in this series.  However, perhaps
> it is still needed and this series needs some more work.  I could use
> some advice here -- when is this code actually needed and is there a
> way I can reproduce any problems?  I don't have a Windows host, so I'm
> hoping for some sort of compile-time error using a mingw cross.

This was already discussed.  Do I understand correctly that you're
going to try to replace gdb_select with gnulib's select?

Thanks,
Pedro Alves

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [RFC 00/17] Merge event loop implementations
  2019-09-26 17:47 ` Pedro Alves
@ 2019-09-26 23:09   ` Tom Tromey
  2019-09-27 13:53     ` Pedro Alves
  2019-10-04 22:25   ` Tom Tromey
  1 sibling, 1 reply; 52+ messages in thread
From: Tom Tromey @ 2019-09-26 23:09 UTC (permalink / raw)
  To: Pedro Alves; +Cc: Tom Tromey, gdb-patches

>>>>> "Pedro" == Pedro Alves <palves@redhat.com> writes:

I'll reply to the rest later, after I absorb it.

>> Given that, I removed gdb_fildes_t in this series.  However, perhaps
>> it is still needed and this series needs some more work.  I could use
>> some advice here -- when is this code actually needed and is there a
>> way I can reproduce any problems?  I don't have a Windows host, so I'm
>> hoping for some sort of compile-time error using a mingw cross.

Pedro> This was already discussed.  Do I understand correctly that you're
Pedro> going to try to replace gdb_select with gnulib's select?

Well, that was an idea, but at Cauldron you pointed out that I could
test the event loop under Wine.  Also, this week I finally got a gdb
build working on Windows, so I may just try that instead.  My thinking
for both of these is that if the code seems to work ok, then there's no
reason to attempt the gnulib thing.

Tom

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [RFC 00/17] Merge event loop implementations
  2019-09-26 23:09   ` Tom Tromey
@ 2019-09-27 13:53     ` Pedro Alves
  2019-09-27 14:05       ` Pedro Alves
  2019-09-27 19:10       ` Tom Tromey
  0 siblings, 2 replies; 52+ messages in thread
From: Pedro Alves @ 2019-09-27 13:53 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

On 9/27/19 12:09 AM, Tom Tromey wrote:
>>>>>> "Pedro" == Pedro Alves <palves@redhat.com> writes:
> 
> I'll reply to the rest later, after I absorb it.
> 
>>> Given that, I removed gdb_fildes_t in this series.  However, perhaps
>>> it is still needed and this series needs some more work.  I could use
>>> some advice here -- when is this code actually needed and is there a
>>> way I can reproduce any problems?  I don't have a Windows host, so I'm
>>> hoping for some sort of compile-time error using a mingw cross.
> 
> Pedro> This was already discussed.  Do I understand correctly that you're
> Pedro> going to try to replace gdb_select with gnulib's select?
> 
> Well, that was an idea, but at Cauldron you pointed out that I could
> test the event loop under Wine.  Also, this week I finally got a gdb
> build working on Windows, so I may just try that instead.  My thinking
> for both of these is that if the code seems to work ok, then there's no
> reason to attempt the gnulib thing.

Ah, OK.  Using the gnulib select would make gdbserver's stdio mode
usable on Windows too, but that's certainly not something required
for this patch series.  Can always be done at some other time.

What's the plan for gdb_fildes_t then?

Thanks,
Pedro Alves

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [RFC 00/17] Merge event loop implementations
  2019-09-27 13:53     ` Pedro Alves
@ 2019-09-27 14:05       ` Pedro Alves
  2019-09-27 14:21         ` Eli Zaretskii
  2019-09-27 19:10       ` Tom Tromey
  1 sibling, 1 reply; 52+ messages in thread
From: Pedro Alves @ 2019-09-27 14:05 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

On 9/27/19 2:53 PM, Pedro Alves wrote:
> On 9/27/19 12:09 AM, Tom Tromey wrote:
>>>>>>> "Pedro" == Pedro Alves <palves@redhat.com> writes:
>>
>> I'll reply to the rest later, after I absorb it.
>>
>>>> Given that, I removed gdb_fildes_t in this series.  However, perhaps
>>>> it is still needed and this series needs some more work.  I could use
>>>> some advice here -- when is this code actually needed and is there a
>>>> way I can reproduce any problems?  I don't have a Windows host, so I'm
>>>> hoping for some sort of compile-time error using a mingw cross.
>>
>> Pedro> This was already discussed.  Do I understand correctly that you're
>> Pedro> going to try to replace gdb_select with gnulib's select?
>>
>> Well, that was an idea, but at Cauldron you pointed out that I could
>> test the event loop under Wine.  Also, this week I finally got a gdb
>> build working on Windows, so I may just try that instead.  My thinking
>> for both of these is that if the code seems to work ok, then there's no
>> reason to attempt the gnulib thing.
> 
> Ah, OK.  Using the gnulib select would make gdbserver's stdio mode
> usable on Windows too, but that's certainly not something required
> for this patch series.  Can always be done at some other time.
> 
> What's the plan for gdb_fildes_t then?

FYI, the patch that introduced gdb_fildes_t came from here:

 https://sourceware.org/ml/gdb-patches/2010-08/msg00459.html

Here MSDN talks about Unix vs Windows SOCKET types:

 https://docs.microsoft.com/en-us/windows/win32/winsock/socket-data-type-2

But, given that gdb (unlike gdbserver), has been using "int"
for sockets on Windows for a long while, and 64-bit Windows
has been a thing for a long while too, I wonder whether in
practice Windows just makes sure that SOCKET handles
fit in 32-bit integers, exactly to avoid porting headaches...

Given that GDB has been using int, I guess that indeed, we
could most probably ignore this issue and get rid of gdb_fildes_t.
I'm not 100% sure of that, but the evidence suggests it.

Thanks,
Pedro Alves

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [RFC 00/17] Merge event loop implementations
  2019-09-27 14:05       ` Pedro Alves
@ 2019-09-27 14:21         ` Eli Zaretskii
  2019-09-27 14:53           ` Pedro Alves
  0 siblings, 1 reply; 52+ messages in thread
From: Eli Zaretskii @ 2019-09-27 14:21 UTC (permalink / raw)
  To: Pedro Alves; +Cc: tom, gdb-patches

> Cc: gdb-patches@sourceware.org
> From: Pedro Alves <palves@redhat.com>
> Date: Fri, 27 Sep 2019 15:05:27 +0100
> 
> But, given that gdb (unlike gdbserver), has been using "int"
> for sockets on Windows for a long while, and 64-bit Windows
> has been a thing for a long while too, I wonder whether in
> practice Windows just makes sure that SOCKET handles
> fit in 32-bit integers, exactly to avoid porting headaches...

SOCKET is a 64-bit data type on 64-bit Windows.  However, according to
this:

  https://stackoverflow.com/questions/1953639/is-it-safe-to-cast-socket-to-int-under-win64

Microsoft is unlikely to ever populate the high 32 bits with anything
but zero.

So I'd generally recommend using DWORDPTR or uintptr_t for SOCKETs,
but I'm guessing we are good using unsigned ints instead, if changing
that is too much trouble.

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [RFC 00/17] Merge event loop implementations
  2019-09-27 14:21         ` Eli Zaretskii
@ 2019-09-27 14:53           ` Pedro Alves
  2019-09-27 15:32             ` Eli Zaretskii
  0 siblings, 1 reply; 52+ messages in thread
From: Pedro Alves @ 2019-09-27 14:53 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: tom, gdb-patches

On 9/27/19 3:20 PM, Eli Zaretskii wrote:
>> Cc: gdb-patches@sourceware.org
>> From: Pedro Alves <palves@redhat.com>
>> Date: Fri, 27 Sep 2019 15:05:27 +0100
>>
>> But, given that gdb (unlike gdbserver), has been using "int"
>> for sockets on Windows for a long while, and 64-bit Windows
>> has been a thing for a long while too, I wonder whether in
>> practice Windows just makes sure that SOCKET handles
>> fit in 32-bit integers, exactly to avoid porting headaches...
> 
> SOCKET is a 64-bit data type on 64-bit Windows.  However, according to
> this:
> 
>   https://stackoverflow.com/questions/1953639/is-it-safe-to-cast-socket-to-int-under-win64
> 
> Microsoft is unlikely to ever populate the high 32 bits with anything
> but zero.
> 
> So I'd generally recommend using DWORDPTR or uintptr_t for SOCKETs,
> but I'm guessing we are good using unsigned ints instead, if changing
> that is too much trouble.

Using unsigned ints would be as much trouble as any other type, because
it'd be in conflict with the type that we want to use for Unix -- int.

The main complication is that the code in question works with int file
descriptors, and accepts / passes around all kinds of file descriptors,
including PTYs, sockets, the console's file descriptor on
Windows (fileno(stdin)), etc., all using a single type.

So if we go the typedef way, it'd have to be a type that could
fit all the different types of handles/descriptors on Windows (i.e.,
a 64-bit-wide unsigned integer in practice), and then all code that
checks for handle validity would have to be tweaked to not do
"fd < 0" or "fd == -1" but instead maybe call some callback to validate
the handle.  That seems a lot of trouble, and unusual.  The gnulib
select route seems more attractive compared to that.

Reading that stackoverflow, I'm convinced that we should
just do what everyone does and cast SOCKET to int like gdb is
already doing, and move on.

Alternatively, if someone feels up to it, we could also borrow
what gnulib's socket replacement does, which is to use these
two macros to convert between a socket and a file descriptor:

 #define FD_TO_SOCKET(fd)   ((SOCKET) _get_osfhandle ((fd)))
 #define SOCKET_TO_FD(fh)   (_open_osfhandle ((intptr_t) (fh), O_RDWR | O_BINARY))

_open_osfhandle "Associates a C run-time file descriptor with an existing operating
system file handle.", per:
 https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/open-osfhandle?view=vs-2019

But then again, might as well use gnulib's socket/select/etc.
instead of redoing it ourselves.

In conclusion, I suggest sweeping the issue under the rug for now
and cast SOCKET to int for this series, like GDB already does.

Actually, gdbserver also does that too -- gdb_socket_cloexec
returns int, and gdbserver/remote-utils.c uses that to open sockets.

So removing gdb_fildes_t is not really making things worse.

Thanks,
Pedro Alves

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [RFC 00/17] Merge event loop implementations
  2019-09-27 14:53           ` Pedro Alves
@ 2019-09-27 15:32             ` Eli Zaretskii
  0 siblings, 0 replies; 52+ messages in thread
From: Eli Zaretskii @ 2019-09-27 15:32 UTC (permalink / raw)
  To: Pedro Alves; +Cc: tom, gdb-patches

> Cc: tom@tromey.com, gdb-patches@sourceware.org
> From: Pedro Alves <palves@redhat.com>
> Date: Fri, 27 Sep 2019 15:53:36 +0100
> 
> Alternatively, if someone feels up to it, we could also borrow
> what gnulib's socket replacement does, which is to use these
> two macros to convert between a socket and a file descriptor:
> 
>  #define FD_TO_SOCKET(fd)   ((SOCKET) _get_osfhandle ((fd)))
>  #define SOCKET_TO_FD(fh)   (_open_osfhandle ((intptr_t) (fh), O_RDWR | O_BINARY))

If you want to use sockets in calls to the likes of 'read' and
'write', then the above is the only way, AFAIK.

> In conclusion, I suggest sweeping the issue under the rug for now
> and cast SOCKET to int for this series, like GDB already does.

I'd suggest to at least have a comment about this somewhere.

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [RFC 00/17] Merge event loop implementations
  2019-09-27 13:53     ` Pedro Alves
  2019-09-27 14:05       ` Pedro Alves
@ 2019-09-27 19:10       ` Tom Tromey
  2020-02-14  2:22         ` Tom Tromey
  1 sibling, 1 reply; 52+ messages in thread
From: Tom Tromey @ 2019-09-27 19:10 UTC (permalink / raw)
  To: Pedro Alves; +Cc: Tom Tromey, gdb-patches

>>>>> "Pedro" == Pedro Alves <palves@redhat.com> writes:

Pedro> What's the plan for gdb_fildes_t then?

It's been a while since I wrote this series, so I don't really recall
all the details, and I don't have time to dig into it today :(

However, my hope was that unifying on the gdb approach would be good
enough.  And, while debugging on Windows this week, I happened (I forgot
to look before starting, so it's kind of a goofy accident) to use this
event unification branch.  I used gdb and also tried gdbserver, and as
far as I can tell, everything worked fine.

So, my view is that the current patch series is probably roughly ok.

Tom

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [RFC 10/17] Move event-loop.[ch] to common/
  2019-09-26 14:06   ` Pedro Alves
@ 2019-10-04 22:06     ` Tom Tromey
  0 siblings, 0 replies; 52+ messages in thread
From: Tom Tromey @ 2019-10-04 22:06 UTC (permalink / raw)
  To: Pedro Alves; +Cc: Tom Tromey, gdb-patches

>>>>> "Pedro" == Pedro Alves <palves@redhat.com> writes:

>> +#include "common/function-view.h"
>> +

Pedro> Is this needed here?

Nope.  I removed it.

Tom

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [RFC 17/17] Simplify gdbserver's serial event handling
  2019-09-26 17:36   ` Pedro Alves
@ 2019-10-04 22:08     ` Tom Tromey
  0 siblings, 0 replies; 52+ messages in thread
From: Tom Tromey @ 2019-10-04 22:08 UTC (permalink / raw)
  To: Pedro Alves; +Cc: Tom Tromey, gdb-patches

>>>>> "Pedro" == Pedro Alves <palves@redhat.com> writes:

Pedro> On 2/24/19 4:51 PM, Tom Tromey wrote:
>> Currently, when gdbserver handles a serial event, it also calls
>> 'reschedule' to install a timer that is then used to process any data
>> that remains after the previous packet was processed.
>> 
>> It seemed better to me to simply have the file descriptor callback
>> loop, processing packets until complete.

Pedro> I would rather not do this change, because it potentially starves other
Pedro> event sources.  I've had to fix starvation issues like that in several
Pedro> places in gdb throughout the years -- see url I pointed that justifying
Pedro> need for async serial events, random_pending_event_thread in
Pedro> infrun.c, etc.

I have dropped it.

Tom

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [RFC 09/17] Introduce async-event.[ch]
  2019-09-26 14:06   ` Pedro Alves
@ 2019-10-04 22:17     ` Tom Tromey
  0 siblings, 0 replies; 52+ messages in thread
From: Tom Tromey @ 2019-10-04 22:17 UTC (permalink / raw)
  To: Pedro Alves; +Cc: Tom Tromey, gdb-patches

>>>>> "Pedro" == Pedro Alves <palves@redhat.com> writes:

Pedro> On 2/24/19 4:51 PM, Tom Tromey wrote:
>> This patch splits out some gdb-specific code from event-loop, into new
>> files async-event.[ch].  Strictly speaking this code could perhaps be
>> put into common/, but because gdbserver does not currently use it, it
>> seemed better, for size reasons, to split it out.

Pedro> Seems fine.  Going forward, I wonder whether we'll split event loop
Pedro> things into more files, and whether using a name prefix like "event-loop-"
Pedro> or "el-", like "el-async-event.[ch]" would help keeping things a bit
Pedro> closer together.  Just a thought; not a request.

I don't have plans to do anything more in this area, and I didn't feel
quite strongly enough about it to do the renaming, so I've just left it
as-is.

I somewhat wish we could remove all this code in favor of a pre-canned
event loop solution, like libevent.  Too bad dependencies are such a
pain.

Tom

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [RFC 00/17] Merge event loop implementations
  2019-09-26 17:47 ` Pedro Alves
  2019-09-26 23:09   ` Tom Tromey
@ 2019-10-04 22:25   ` Tom Tromey
  2020-02-14 18:20     ` Pedro Alves
  1 sibling, 1 reply; 52+ messages in thread
From: Tom Tromey @ 2019-10-04 22:25 UTC (permalink / raw)
  To: Pedro Alves; +Cc: Tom Tromey, gdb-patches

>>>>> "Pedro" == Pedro Alves <palves@redhat.com> writes:

Tom> Another related possible to-do item is changing the ser-event code to
Tom> maintain just a single self-pipe.  It seems to me that there's never a
Tom> reason to need more than one.

Pedro> Can you clarify/expand?  Are you suggesting to use one single pipe,
Pedro> and then if select/poll wakes up, go through a list of registered
Pedro> ser-events to know which one triggered?  Or something else?

It seems to me that any use of a serial event could just be replaced
with run_on_main_thread, from the threading patches, instead.

Tom

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [RFC 00/17] Merge event loop implementations
  2019-09-27 19:10       ` Tom Tromey
@ 2020-02-14  2:22         ` Tom Tromey
  2020-02-14 17:58           ` Pedro Alves
  0 siblings, 1 reply; 52+ messages in thread
From: Tom Tromey @ 2020-02-14  2:22 UTC (permalink / raw)
  To: Tom Tromey; +Cc: Pedro Alves, gdb-patches

Tom> However, my hope was that unifying on the gdb approach would be good
Tom> enough.  And, while debugging on Windows this week, I happened (I forgot
Tom> to look before starting, so it's kind of a goofy accident) to use this
Tom> event unification branch.  I used gdb and also tried gdbserver, and as
Tom> far as I can tell, everything worked fine.

I rebased this series recently.

I wasn't sure what the status really was.  I thought this at the time:

Tom> So, my view is that the current patch series is probably roughly ok.

... meaning that gdb_fildes_t could be removed and replaced with plain
"int", and nothing else would have to change.

I can re-test the series on Windows.  The updates due to rebasing were
all mechanical, though, stuff like making sure the files were moved into
the now-correct directories.

I thought maybe we could use gdb_select in gdbsupport, but now I see it
reaches into the serial code, so maybe that isn't so easy after all.

Let me know what you think.

Tom

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [RFC 00/17] Merge event loop implementations
  2020-02-14  2:22         ` Tom Tromey
@ 2020-02-14 17:58           ` Pedro Alves
  2020-02-14 18:36             ` Tom Tromey
  0 siblings, 1 reply; 52+ messages in thread
From: Pedro Alves @ 2020-02-14 17:58 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

On 2/14/20 2:21 AM, Tom Tromey wrote:
> Tom> However, my hope was that unifying on the gdb approach would be good
> Tom> enough.  And, while debugging on Windows this week, I happened (I forgot
> Tom> to look before starting, so it's kind of a goofy accident) to use this
> Tom> event unification branch.  I used gdb and also tried gdbserver, and as
> Tom> far as I can tell, everything worked fine.
> 
> I rebased this series recently.
> 
> I wasn't sure what the status really was.  I thought this at the time:
> 
> Tom> So, my view is that the current patch series is probably roughly ok.
> 
> ... meaning that gdb_fildes_t could be removed and replaced with plain
> "int", and nothing else would have to change.
> 

My latest thoughts were here:

  https://sourceware.org/ml/gdb-patches/2019-09/msg00555.html

"In conclusion, I suggest sweeping the issue under the rug for now
and cast SOCKET to int for this series, like GDB already does."

> I can re-test the series on Windows.  The updates due to rebasing were
> all mechanical, though, stuff like making sure the files were moved into
> the now-correct directories.
> 
> I thought maybe we could use gdb_select in gdbsupport, but now I see it
> reaches into the serial code, so maybe that isn't so easy after all.
> 
> Let me know what you think.

I can't find a response to my comments to patch 2 and 15, for example.
I'm not sure you saw them? 

Thanks,
Pedro Alves

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [RFC 00/17] Merge event loop implementations
  2019-10-04 22:25   ` Tom Tromey
@ 2020-02-14 18:20     ` Pedro Alves
  0 siblings, 0 replies; 52+ messages in thread
From: Pedro Alves @ 2020-02-14 18:20 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

Hi, found this one which I never answered.

On 10/4/19 11:25 PM, Tom Tromey wrote:
>>>>>> "Pedro" == Pedro Alves <palves@redhat.com> writes:
> 
> Tom> Another related possible to-do item is changing the ser-event code to
> Tom> maintain just a single self-pipe.  It seems to me that there's never a
> Tom> reason to need more than one.
> 
> Pedro> Can you clarify/expand?  Are you suggesting to use one single pipe,
> Pedro> and then if select/poll wakes up, go through a list of registered
> Pedro> ser-events to know which one triggered?  Or something else?
> 
> It seems to me that any use of a serial event could just be replaced
> with run_on_main_thread, from the threading patches, instead.

I don't see how that could replace interruptible_select (and
quit_serial_event).

Thanks,
Pedro Alves

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [RFC 00/17] Merge event loop implementations
  2020-02-14 17:58           ` Pedro Alves
@ 2020-02-14 18:36             ` Tom Tromey
  0 siblings, 0 replies; 52+ messages in thread
From: Tom Tromey @ 2020-02-14 18:36 UTC (permalink / raw)
  To: Pedro Alves; +Cc: Tom Tromey, gdb-patches

Pedro> My latest thoughts were here:
Pedro>   https://sourceware.org/ml/gdb-patches/2019-09/msg00555.html
Pedro> "In conclusion, I suggest sweeping the issue under the rug for now
Pedro> and cast SOCKET to int for this series, like GDB already does."

Ok.  I will double check but I think that's what is done?

Pedro> I can't find a response to my comments to patch 2 and 15, for example.
Pedro> I'm not sure you saw them? 

I did and I implemented those.  I will re-send the series so that the
updates can all be verified.

Tom

^ permalink raw reply	[flat|nested] 52+ messages in thread

end of thread, other threads:[~2020-02-14 18:36 UTC | newest]

Thread overview: 52+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-24 16:51 [RFC 00/17] Merge event loop implementations Tom Tromey
2019-02-24 16:52 ` [RFC 13/17] Switch gdbserver to common event loop Tom Tromey
2019-02-24 16:52 ` [RFC 15/17] Move gdb_notifier comment Tom Tromey
2019-09-26 14:06   ` Pedro Alves
2019-02-24 16:52 ` [RFC 11/17] Implement event-loop glue for gdbserver Tom Tromey
2019-02-24 16:52 ` [RFC 02/17] Move gdb-specific code out of start_event_loop Tom Tromey
2019-09-26 14:02   ` Pedro Alves
2019-02-24 16:52 ` [RFC 16/17] Remove gdb_fildes_t Tom Tromey
2019-02-24 16:52 ` [RFC 05/17] Remove gdb_usleep.c Tom Tromey
2019-09-26 14:02   ` Pedro Alves
2019-09-26 14:43     ` Tom Tromey
2019-02-24 16:52 ` [RFC 14/17] Remove some dead code from event-loop.c Tom Tromey
2019-02-24 16:52 ` [RFC 12/17] Add the ability to stop the event loop Tom Tromey
2019-02-24 16:52 ` [RFC 07/17] Use warning in event-loop Tom Tromey
2019-09-26 14:02   ` Pedro Alves
2019-02-24 16:52 ` [RFC 17/17] Simplify gdbserver's serial event handling Tom Tromey
2019-09-26 17:36   ` Pedro Alves
2019-10-04 22:08     ` Tom Tromey
2019-02-24 16:52 ` [RFC 08/17] Introduce and use flush_streams Tom Tromey
2019-02-24 16:52 ` [RFC 09/17] Introduce async-event.[ch] Tom Tromey
2019-09-26 14:06   ` Pedro Alves
2019-10-04 22:17     ` Tom Tromey
2019-02-24 16:52 ` [RFC 01/17] Remove include from event-loop.c Tom Tromey
2019-02-24 16:52 ` [RFC 06/17] Include <chrono> in event-loop.c Tom Tromey
2019-09-26 14:02   ` Pedro Alves
2019-02-24 16:52 ` [RFC 10/17] Move event-loop.[ch] to common/ Tom Tromey
2019-09-26 14:06   ` Pedro Alves
2019-10-04 22:06     ` Tom Tromey
2019-02-24 16:52 ` [RFC 04/17] Move gdb_select.h " Tom Tromey
2019-02-24 16:52 ` [RFC 03/17] Move event-loop configury to common.m4 Tom Tromey
2019-02-24 17:14 ` [RFC 00/17] Merge event loop implementations Eli Zaretskii
2019-02-24 17:26   ` Tom Tromey
2019-02-24 17:45     ` Eli Zaretskii
2019-02-25 19:57       ` Tom Tromey
2019-02-25 20:30         ` Eli Zaretskii
2019-02-25 20:55           ` Tom Tromey
2019-02-26 16:04             ` Eli Zaretskii
2019-02-26 16:23               ` Tom Tromey
2019-02-26 16:46                 ` Eli Zaretskii
2019-09-26 17:47 ` Pedro Alves
2019-09-26 23:09   ` Tom Tromey
2019-09-27 13:53     ` Pedro Alves
2019-09-27 14:05       ` Pedro Alves
2019-09-27 14:21         ` Eli Zaretskii
2019-09-27 14:53           ` Pedro Alves
2019-09-27 15:32             ` Eli Zaretskii
2019-09-27 19:10       ` Tom Tromey
2020-02-14  2:22         ` Tom Tromey
2020-02-14 17:58           ` Pedro Alves
2020-02-14 18:36             ` Tom Tromey
2019-10-04 22:25   ` Tom Tromey
2020-02-14 18:20     ` Pedro Alves

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).