diff options
author | Tom Tromey <tom@tromey.com> | 2020-04-13 12:42:59 -0600 |
---|---|---|
committer | Tom Tromey <tromey@adacore.com> | 2020-04-13 14:10:04 -0600 |
commit | 55d7aec85e81c4597e94ebcc8b85f20a1d439bd0 (patch) | |
tree | 664fe7b861844fbe141d01768c38e2f6b033399e /gdbserver/server.cc | |
parent | e487f9949ab654b20da8ac01b8311ae956136e5e (diff) | |
download | binutils-gdb-55d7aec85e81c4597e94ebcc8b85f20a1d439bd0.tar.gz |
Switch gdbserver to gdbsupport event loop
This changes gdbserver to use the gdbserver event loop, removing the
ancient fork.
gdbserver/ChangeLog
2020-04-13 Tom Tromey <tom@tromey.com>
* server.h (handle_serial_event, handle_target_event): Update.
* server.c: Don't call initialize_event_loop.
(keep_processing_events): New global.
(handle_serial_event): Return void. Set keep_processing_events.
(handle_target_event): Return void.
(start_event_loop): Move from event-loop.c. Rewrite.
* 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.cc: Remove.
* Makefile.in (OBS): Use gdbsupport/event-loop.o, not event-loop.o.
Diffstat (limited to 'gdbserver/server.cc')
-rw-r--r-- | gdbserver/server.cc | 44 |
1 files changed, 36 insertions, 8 deletions
diff --git a/gdbserver/server.cc b/gdbserver/server.cc index ac7a7fd75aa..77175ff74cb 100644 --- a/gdbserver/server.cc +++ b/gdbserver/server.cc @@ -83,6 +83,10 @@ bool run_once; /* Whether to report TARGET_WAITKIND_NO_RESUMED events. */ static bool report_no_resumed; +/* The event loop checks this to decide whether to continue accepting + events. */ +static bool keep_processing_events = true; + bool non_stop; static struct { @@ -3463,6 +3467,32 @@ gdbserver_show_disableable (FILE *stream) " threads \tAll of the above\n"); } +/* Start up the event loop. This is the entry point to the event + loop. */ + +static void +start_event_loop () +{ + /* 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. */ + + keep_processing_events = true; + while (keep_processing_events) + { + /* Any events already waiting in the queue? */ + int res = gdb_do_one_event (); + + /* Was there an error? */ + if (res == -1) + break; + } + + /* We are done with the event loop. There are no more event sources + to listen to. So we exit gdbserver. */ +} + static void kill_inferior_callback (process_info *process) { @@ -3762,7 +3792,6 @@ captured_main (int argc, char *argv[]) initialize_async_io (); initialize_low (); have_job_control (); - initialize_event_loop (); if (target_supports_tracepoints ()) initialize_tracepoint (); @@ -4365,7 +4394,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) @@ -4373,13 +4402,14 @@ handle_serial_event (int err, gdb_client_data client_data) /* Really handle it. */ if (process_serial_event () < 0) - return -1; + { + keep_processing_events = false; + 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. */ @@ -4397,7 +4427,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 (); @@ -4474,8 +4504,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 gdbsupport/event-loop.h. */ |