[gdb/testsuite] Accept new complex print style in mixed-lang-stack.exp
[deliverable/binutils-gdb.git] / gdb / event-loop.c
index 7304ca7a2a6c19fca73fc0b083b124994f094f91..af8f80b6a2cdf76ae4ed525f778794943d0c00a8 100644 (file)
@@ -1,5 +1,5 @@
 /* Event loop machinery for GDB, the GNU debugger.
-   Copyright (C) 1999-2017 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 "queue.h"
 #include "ser-event.h"
 
 #ifdef HAVE_POLL
@@ -32,9 +31,9 @@
 #endif
 
 #include <sys/types.h>
-#include "gdb_sys_time.h"
+#include "gdbsupport/gdb_sys_time.h"
 #include "gdb_select.h"
-#include "observer.h"
+#include "observable.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.  */
 
@@ -366,23 +332,26 @@ start_event_loop (void)
     {
       int result = 0;
 
-      TRY
+      try
        {
          result = gdb_do_one_event ();
        }
-      CATCH (ex, RETURN_MASK_ALL)
+      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 ();
+         SWITCH_THRU_ALL_UIS ()
+           {
+             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;
-         observer_notify_command_error ();
+         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
@@ -394,7 +363,6 @@ start_event_loop (void)
          /* Maybe better to set a flag to be checked somewhere as to
             whether display the prompt or not.  */
        }
-      END_CATCH
 
       if (result < 0)
        break;
@@ -749,8 +717,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.028494 seconds and 4 git commands to generate.