- /* Loop until there is something to do. This is the entry point to
- the event loop engine. gdb_do_one_event will process one event
- for each invocation. It always returns 1, unless there are no
- more event sources registered. In this case it returns 0. */
- while (gdb_do_one_event () != 0)
- ;
-
- /* We are done with the event loop. There are no more event sources
- to listen to. So we exit GDB. */
+ /* 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)
+ {
+ volatile struct gdb_exception ex;
+ int result = 0;
+
+ TRY_CATCH (ex, RETURN_MASK_ALL)
+ {
+ result = gdb_do_one_event ();
+ }
+ if (ex.reason < 0)
+ {
+ 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. */
+ observer_notify_command_error ();
+ /* 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. */