Remove remaining cleanup from fetch_inferior_event

This removes the remaining cleanup from fetch_inferior_event,
replacing it with a SCOPE_EXIT.  This required introducing a new scope
and reindenting.

gdb/ChangeLog:
2019-01-23  Tom Tromey  <tom@tromey.com>
	    Pedro Alves  <palves@redhat.com>

	* infrun.c (reinstall_readline_callback_handler_cleanup): Remove
	parameter.
	(fetch_inferior_event): Use SCOPE_EXIT.
This commit is contained in:
Tom Tromey
2019-01-23 18:58:35 +00:00
committed by Pedro Alves
parent 9885e6bb5b
commit d238133d02
2 changed files with 100 additions and 90 deletions

View File

@ -1,3 +1,11 @@
2019-01-23 Tom Tromey <tom@tromey.com>
Pedro Alves <palves@redhat.com>
* infrun.c (reinstall_readline_callback_handler_cleanup): Remove
parameter.
(fetch_inferior_event): Use SCOPE_EXIT.
2019-01-23 Tom Tromey <tom@tromey.com> 2019-01-23 Tom Tromey <tom@tromey.com>
Pedro Alves <palves@redhat.com> Pedro Alves <palves@redhat.com>

View File

@ -3585,7 +3585,7 @@ wait_for_inferior (void)
input. */ input. */
static void static void
reinstall_readline_callback_handler_cleanup (void *arg) reinstall_readline_callback_handler_cleanup ()
{ {
struct ui *ui = current_ui; struct ui *ui = current_ui;
@ -3687,7 +3687,6 @@ fetch_inferior_event (void *client_data)
{ {
struct execution_control_state ecss; struct execution_control_state ecss;
struct execution_control_state *ecs = &ecss; struct execution_control_state *ecs = &ecss;
struct cleanup *old_chain = make_cleanup (null_cleanup, NULL);
int cmd_done = 0; int cmd_done = 0;
ptid_t waiton_ptid = minus_one_ptid; ptid_t waiton_ptid = minus_one_ptid;
@ -3699,7 +3698,8 @@ fetch_inferior_event (void *client_data)
scoped_restore save_ui = make_scoped_restore (&current_ui, main_ui); scoped_restore save_ui = make_scoped_restore (&current_ui, main_ui);
/* End up with readline processing input, if necessary. */ /* End up with readline processing input, if necessary. */
make_cleanup (reinstall_readline_callback_handler_cleanup, NULL); {
SCOPE_EXIT { reinstall_readline_callback_handler_cleanup (); };
/* We're handling a live event, so make sure we're doing live /* We're handling a live event, so make sure we're doing live
debugging. If we're looking at traceframes while the target is debugging. If we're looking at traceframes while the target is
@ -3729,7 +3729,8 @@ fetch_inferior_event (void *client_data)
target_dcache_invalidate (); target_dcache_invalidate ();
scoped_restore save_exec_dir scoped_restore save_exec_dir
= make_scoped_restore (&execution_direction, target_execution_direction ()); = make_scoped_restore (&execution_direction,
target_execution_direction ());
ecs->ptid = do_target_wait (waiton_ptid, &ecs->ws, ecs->ptid = do_target_wait (waiton_ptid, &ecs->ws,
target_can_async_p () ? TARGET_WNOHANG : 0); target_can_async_p () ? TARGET_WNOHANG : 0);
@ -3807,8 +3808,9 @@ fetch_inferior_event (void *client_data)
/* No error, don't finish the thread states yet. */ /* No error, don't finish the thread states yet. */
finish_state.release (); finish_state.release ();
/* Revert thread and frame. */ /* This scope is used to ensure that readline callbacks are
do_cleanups (old_chain); reinstalled here. */
}
/* If a UI was in sync execution mode, and now isn't, restore its /* If a UI was in sync execution mode, and now isn't, restore its
prompt (a synchronous execution command has finished, and we're prompt (a synchronous execution command has finished, and we're