Move gdb_select.h to gdbsupport/
[deliverable/binutils-gdb.git] / gdb / event-loop.c
index ec776f59e8cd054c1962b4384c3c3a66dc995e05..ae9d27eedd78671cdef383e557b5990c722ba16f 100644 (file)
@@ -1,5 +1,5 @@
 /* Event loop machinery for GDB, the GNU debugger.
-   Copyright (C) 1999-2019 Free Software Foundation, Inc.
+   Copyright (C) 1999-2020 Free Software Foundation, Inc.
    Written by Elena Zannoni <ezannoni@cygnus.com> of Cygnus Solutions.
 
    This file is part of GDB.
@@ -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
@@ -32,9 +31,8 @@
 #endif
 
 #include <sys/types.h>
-#include "common/gdb_sys_time.h"
-#include "gdb_select.h"
-#include "observable.h"
+#include "gdbsupport/gdb_sys_time.h"
+#include "gdbsupport/gdb_select.h"
 #include "top.h"
 
 /* Tell create_file_handler what events we are interested in.
 #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.  */
 
@@ -352,57 +317,6 @@ gdb_do_one_event (void)
   return 1;
 }
 
-/* Start up the event loop.  This is the entry point to the event loop
-   from the command loop.  */
-
-void
-start_event_loop (void)
-{
-  /* 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
-     for each invocation.  It blocks waiting for an event and then
-     processes it.  */
-  while (1)
-    {
-      int result = 0;
-
-      try
-       {
-         result = gdb_do_one_event ();
-       }
-      catch (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.  */
-       }
-
-      if (result < 0)
-       break;
-    }
-
-  /* We are done with the event loop.  There are no more event sources
-     to listen to.  So we exit GDB.  */
-  return;
-}
 \f
 
 /* Wrapper function for create_file_handler, so that the caller
@@ -748,8 +662,8 @@ 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);
+  gdb_stdout->flush ();
+  gdb_stderr->flush ();
 
   if (gdb_notifier.num_fds == 0)
     return -1;
This page took 0.028741 seconds and 4 git commands to generate.