/* 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.
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include "defs.h"
-
-/* Local non-gdb includes. */
-#include "common/queue.h"
#include "event-loop.h"
#include "event-top.h"
#include "ser-event.h"
#endif
#include <sys/types.h>
-#include "common/gdb_sys_time.h"
+#include "gdbsupport/gdb_sys_time.h"
#include "gdb_select.h"
#include "observable.h"
#include "top.h"
#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. */
{
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. */
/* Maybe better to set a flag to be checked somewhere as to
whether display the prompt or not. */
}
- END_CATCH
if (result < 0)
break;
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;