Use scoped_restore for current_ui
authorTom Tromey <tom@tromey.com>
Fri, 23 Sep 2016 02:50:52 +0000 (20:50 -0600)
committerTom Tromey <tom@tromey.com>
Fri, 21 Oct 2016 20:17:32 +0000 (14:17 -0600)
This changes most uses of make_cleanup_restore_current_ui to use
scoped_restore.  The use in switch_thru_all_uis_init still remains;
that is dealt with in a later patch by replacing this iterator with a
real class.

2016-10-21  Tom Tromey  <tom@tromey.com>

* top.c (new_ui_command, wait_sync_command_done)
(gdb_readline_wrapper): Use scoped_restore.
* infrun.c (fetch_inferior_event): Use scoped_restore.
* infcall.c (call_thread_fsm_should_stop): Use scoped_restore.

gdb/ChangeLog
gdb/infcall.c
gdb/infrun.c
gdb/top.c

index 9d0d5364ad0937dc6716d60e043bfd7fb0ea6e44..ebfdf99cb9e6ebc3e885ef240b719601be800c56 100644 (file)
@@ -1,3 +1,10 @@
+2016-10-21  Tom Tromey  <tom@tromey.com>
+
+       * top.c (new_ui_command, wait_sync_command_done)
+       (gdb_readline_wrapper): Use scoped_restore.
+       * infrun.c (fetch_inferior_event): Use scoped_restore.
+       * infcall.c (call_thread_fsm_should_stop): Use scoped_restore.
+
 2016-10-21  Tom Tromey  <tom@tromey.com>
 
        * utils.c (make_cleanup_restore_ui_file, do_restore_ui_file)
index ab7426d6f3c45987ce213d87784956fca366cf00..e435cf721a6f7d45e578d2eeea81617134b13f7e 100644 (file)
@@ -519,8 +519,6 @@ call_thread_fsm_should_stop (struct thread_fsm *self,
 
   if (stop_stack_dummy == STOP_STACK_DUMMY)
     {
-      struct cleanup *old_chain;
-
       /* Done.  */
       thread_fsm_set_finished (self);
 
@@ -530,13 +528,9 @@ call_thread_fsm_should_stop (struct thread_fsm *self,
       f->return_value = get_call_return_value (&f->return_meta_info);
 
       /* Break out of wait_sync_command_done.  */
-      old_chain = make_cleanup_restore_current_ui ();
-      current_ui = f->waiting_ui;
+      scoped_restore save_ui = make_scoped_restore (&current_ui, f->waiting_ui);
       target_terminal_ours ();
       f->waiting_ui->prompt_state = PROMPT_NEEDED;
-
-      /* This restores the previous UI.  */
-      do_cleanups (old_chain);
     }
 
   return 1;
index 6fc1acf77ffe0cb490d2c60a576736014a07baac..8d81c97a2fbf5306d4b5c4ffb7d5367742e055bc 100644 (file)
@@ -3903,8 +3903,7 @@ fetch_inferior_event (void *client_data)
   /* Events are always processed with the main UI as current UI.  This
      way, warnings, debug output, etc. are always consistently sent to
      the main console.  */
-  make_cleanup_restore_current_ui ();
-  current_ui = main_ui;
+  scoped_restore save_ui = make_scoped_restore (&current_ui, main_ui);
 
   /* End up with readline processing input, if necessary.  */
   make_cleanup (reinstall_readline_callback_handler_cleanup, NULL);
index 053c510333f63377021275ad1f40f73fef5a8f7f..c84feaf6ca97aa0891f59a64796c95d3d1fd2a57 100644 (file)
--- a/gdb/top.c
+++ b/gdb/top.c
@@ -386,33 +386,35 @@ new_ui_command (char *args, int from_tty)
   interpreter_name = argv[0];
   tty_name = argv[1];
 
-  make_cleanup_restore_current_ui ();
+  {
+    scoped_restore save_ui = make_scoped_restore (&current_ui);
 
-  failure_chain = make_cleanup (null_cleanup, NULL);
+    failure_chain = make_cleanup (null_cleanup, NULL);
 
-  /* Open specified terminal, once for each of
-     stdin/stdout/stderr.  */
-  for (i = 0; i < 3; i++)
-    {
-      stream[i] = open_terminal_stream (tty_name);
-      make_cleanup_fclose (stream[i]);
-    }
+    /* Open specified terminal, once for each of
+       stdin/stdout/stderr.  */
+    for (i = 0; i < 3; i++)
+      {
+       stream[i] = open_terminal_stream (tty_name);
+       make_cleanup_fclose (stream[i]);
+      }
 
-  ui = new_ui (stream[0], stream[1], stream[2]);
-  make_cleanup (delete_ui_cleanup, ui);
+    ui = new_ui (stream[0], stream[1], stream[2]);
+    make_cleanup (delete_ui_cleanup, ui);
 
-  ui->async = 1;
+    ui->async = 1;
 
-  current_ui = ui;
+    current_ui = ui;
 
-  set_top_level_interpreter (interpreter_name);
+    set_top_level_interpreter (interpreter_name);
 
-  interp_pre_command_loop (top_level_interpreter ());
+    interp_pre_command_loop (top_level_interpreter ());
 
-  discard_cleanups (failure_chain);
+    discard_cleanups (failure_chain);
 
-  /* This restores the previous UI and frees argv.  */
-  do_cleanups (success_chain);
+    /* This restores the previous UI and frees argv.  */
+    do_cleanups (success_chain);
+  }
 
   printf_unfiltered ("New UI allocated\n");
 }
@@ -562,14 +564,12 @@ void
 wait_sync_command_done (void)
 {
   /* Processing events may change the current UI.  */
-  struct cleanup *old_chain = make_cleanup_restore_current_ui ();
+  scoped_restore save_ui = make_scoped_restore (&current_ui);
   struct ui *ui = current_ui;
 
   while (gdb_do_one_event () >= 0)
     if (ui->prompt_state != PROMPT_BLOCKED)
       break;
-
-  do_cleanups (old_chain);
 }
 
 /* See top.h.  */
@@ -1036,7 +1036,7 @@ gdb_readline_wrapper (const char *prompt)
   back_to = make_cleanup (gdb_readline_wrapper_cleanup, cleanup);
 
   /* Processing events may change the current UI.  */
-  make_cleanup_restore_current_ui ();
+  scoped_restore save_ui = make_scoped_restore (&current_ui);
 
   if (cleanup->target_is_async_orig)
     target_async (0);
This page took 0.036316 seconds and 4 git commands to generate.