Remove make_cleanup_restore_current_uiout
authorTom Tromey <tom@tromey.com>
Sun, 25 Sep 2016 03:53:54 +0000 (21:53 -0600)
committerTom Tromey <tom@tromey.com>
Fri, 21 Oct 2016 20:17:36 +0000 (14:17 -0600)
This removes make_cleanup_restore_current_uiout in favor of an
RAII-based class.

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

* stack.c (print_stack_frame_to_uiout): Use scoped_restore.
* ui-out.c (make_cleanup_restore_current_uiout)
(restore_current_uiout_cleanup): Remove.
* infrun.c (print_stop_event): Use scoped_restore.
* ui-out.h (make_cleanup_restore_current_uiout): Don't declare.

gdb/ChangeLog
gdb/infrun.c
gdb/python/python.c
gdb/stack.c
gdb/ui-out.c
gdb/ui-out.h

index 5c87f32571201cf13e3ca81ef87ae0d71b674ea0..4d65d9315df5d517dfd30dd32fd9cce266d05c87 100644 (file)
@@ -1,3 +1,11 @@
+2016-10-21  Tom Tromey  <tom@tromey.com>
+
+       * stack.c (print_stack_frame_to_uiout): Use scoped_restore.
+       * ui-out.c (make_cleanup_restore_current_uiout)
+       (restore_current_uiout_cleanup): Remove.
+       * infrun.c (print_stop_event): Use scoped_restore.
+       * ui-out.h (make_cleanup_restore_current_uiout): Don't declare.
+
 2016-10-21  Tom Tromey  <tom@tromey.com>
 
        * elfread.c (elf_read_minimal_symbols): Use gdb::unique_ptr.
index 3069b2d1fa6a5fbef67944df93a29e76f0b883a0..00bba166dc8bc3d9add66f8ee84f51717ccd50cc 100644 (file)
@@ -8084,22 +8084,20 @@ print_stop_location (struct target_waitstatus *ws)
 void
 print_stop_event (struct ui_out *uiout)
 {
-  struct cleanup *old_chain;
   struct target_waitstatus last;
   ptid_t last_ptid;
   struct thread_info *tp;
 
   get_last_target_status (&last_ptid, &last);
 
-  old_chain = make_cleanup_restore_current_uiout ();
-  current_uiout = uiout;
-
-  print_stop_location (&last);
+  {
+    scoped_restore save_uiout = make_scoped_restore (&current_uiout, uiout);
 
-  /* Display the auto-display expressions.  */
-  do_displays ();
+    print_stop_location (&last);
 
-  do_cleanups (old_chain);
+    /* Display the auto-display expressions.  */
+    do_displays ();
+  }
 
   tp = inferior_thread ();
   if (tp->thread_fsm != NULL
index e478ec955ca5837abc47be0954b8ec1f3ab5f8e0..d6bd6bf4a7afd7ba4455e4793884c028885e577a 100644 (file)
@@ -648,7 +648,7 @@ execute_gdb_command (PyObject *self, PyObject *args, PyObject *kw)
 
       scoped_restore save_async = make_scoped_restore (&current_ui->async, 0);
 
-      make_cleanup_restore_current_uiout ();
+      scoped_restore save_uiout = make_scoped_restore (&current_uiout);
 
       /* Use the console interpreter uiout to have the same print format
        for console or MI.  */
index 706dd51f58cc1707ccb291087c8ddb6940cf59e3..823433d913c9844e0713632c24b88cc04d7447d8 100644 (file)
@@ -149,15 +149,9 @@ print_stack_frame_to_uiout (struct ui_out *uiout, struct frame_info *frame,
                            int print_level, enum print_what print_what,
                            int set_current_sal)
 {
-  struct cleanup *old_chain;
-
-  old_chain = make_cleanup_restore_current_uiout ();
-
-  current_uiout = uiout;
+  scoped_restore save_uiout = make_scoped_restore (&current_uiout, uiout);
 
   print_stack_frame (frame, print_level, print_what, set_current_sal);
-
-  do_cleanups (old_chain);
 }
 
 /* Show or print a stack frame FRAME briefly.  The output is formatted
index f6d605041481619b51e08556a9db48d8466d9d61..932cf121a3d95f84e4fd1198e3e17386e34e5da2 100644 (file)
@@ -952,24 +952,6 @@ ui_out_destroy (struct ui_out *uiout)
   xfree (uiout);
 }
 
-/* Cleanup that restores a previous current uiout.  */
-
-static void
-restore_current_uiout_cleanup (void *arg)
-{
-  struct ui_out *saved_uiout = (struct ui_out *) arg;
-
-  current_uiout = saved_uiout;
-}
-
-/* See ui-out.h.  */
-
-struct cleanup *
-make_cleanup_restore_current_uiout (void)
-{
-  return make_cleanup (restore_current_uiout_cleanup, current_uiout);
-}
-
 /* Standard gdb initialization hook.  */
 
 void
index 6a4d78a18e3e7e7798bb431019a206cd4d9fdd37..9e1e74dabc66b6bad4f912f633c2dcd1097f51e7 100644 (file)
@@ -247,8 +247,4 @@ extern void ui_out_destroy (struct ui_out *uiout);
 
 extern int ui_out_redirect (struct ui_out *uiout, struct ui_file *outstream);
 
-/* Make a cleanup that restores the previous current uiout.  */
-
-extern struct cleanup *make_cleanup_restore_current_uiout (void);
-
 #endif /* UI_OUT_H */
This page took 0.034981 seconds and 4 git commands to generate.