]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Introduce cleanup to restore current_uiout
authorSimon Marchi <simark@simark.ca>
Fri, 16 Sep 2016 19:44:29 +0000 (15:44 -0400)
committerSimon Marchi <simon.marchi@ericsson.com>
Fri, 16 Sep 2016 19:44:29 +0000 (15:44 -0400)
Make a globally available cleanup from a pre-existing one in infrun.c.
This is used in a following patch.

gdb/ChangeLog:

* infrun.c (restore_current_uiout_cleanup): Move to ui-out.c.
(print_stop_event): Use make_cleanup_restore_current_uiout.
* python/python.c (execute_gdb_command): Likewise.
* ui-out.c (restore_current_uiout_cleanup): Move from infrun.c.
(make_cleanup_restore_current_uiout): New function definition.
* ui-out.h (make_cleanup_restore_current_uiout): New function
declaration.
* utils.c (do_restore_ui_out): Remove.
(make_cleanup_restore_ui_out): Remove.
* utils.h (make_cleanup_restore_ui_out): Remove.

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

index d8cbd81658f34c72eb57bdeff89940f43c50adb3..2c980b78dc8cc561aae651fb46571e975cbecc3c 100644 (file)
@@ -1,3 +1,16 @@
+2016-09-16  Simon Marchi  <simark@simark.ca>
+
+       * infrun.c (restore_current_uiout_cleanup): Move to ui-out.c.
+       (print_stop_event): Use make_cleanup_restore_current_uiout.
+       * python/python.c (execute_gdb_command): Likewise.
+       * ui-out.c (restore_current_uiout_cleanup): Move from infrun.c.
+       (make_cleanup_restore_current_uiout): New function definition.
+       * ui-out.h (make_cleanup_restore_current_uiout): New function
+       declaration.
+       * utils.c (do_restore_ui_out): Remove.
+       (make_cleanup_restore_ui_out): Remove.
+       * utils.h (make_cleanup_restore_ui_out): Remove.
+
 2016-09-16  Pedro Alves  <palves@redhat.com>
 
        * defs.h (min, max): Delete.
index 70d7a095cfdacbf77403df44f009d665f4ed4aca..ec37ca11d85b650e92118df6df47c60ca0532b16 100644 (file)
@@ -8096,16 +8096,6 @@ print_stop_location (struct target_waitstatus *ws)
     print_stack_frame (get_selected_frame (NULL), 0, source_flag, 1);
 }
 
-/* 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 infrun.h.  */
 
 void
@@ -8118,7 +8108,7 @@ print_stop_event (struct ui_out *uiout)
 
   get_last_target_status (&last_ptid, &last);
 
-  old_chain = make_cleanup (restore_current_uiout_cleanup, current_uiout);
+  old_chain = make_cleanup_restore_current_uiout ();
   current_uiout = uiout;
 
   print_stop_location (&last);
index 621e2012ae79a95cedf407da0214cd8c0cf44b7f..b00b70be85b11c248025a3faa9803c4fbf335e51 100644 (file)
@@ -654,7 +654,8 @@ execute_gdb_command (PyObject *self, PyObject *args, PyObject *kw)
       make_cleanup_restore_integer (&current_ui->async);
       current_ui->async = 0;
 
-      make_cleanup_restore_ui_out (&current_uiout);
+      make_cleanup_restore_current_uiout ();
+
       /* Use the console interpreter uiout to have the same print format
        for console or MI.  */
       interp = interp_lookup (current_ui, "console");
index 3972a56f9f48eef270dbf3b683ca6bf16b9b4bcb..ec44ab6916a1690c0ce5321552383936d35737e9 100644 (file)
@@ -953,6 +953,24 @@ 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 9e1e74dabc66b6bad4f912f633c2dcd1097f51e7..6a4d78a18e3e7e7798bb431019a206cd4d9fdd37 100644 (file)
@@ -247,4 +247,8 @@ 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 */
index 5188828ef486af76b3ef500045615d8a987f0f3a..2afff806ad6020e678bb105dfc6507335caae422 100644 (file)
@@ -338,29 +338,6 @@ struct restore_ui_out_closure
   struct ui_out *value;
 };
 
-static void
-do_restore_ui_out (void *p)
-{
-  struct restore_ui_out_closure *closure
-    = (struct restore_ui_out_closure *) p;
-
-  *(closure->variable) = closure->value;
-}
-
-/* Remember the current value of *VARIABLE and make it restored when
-   the cleanup is run.  */
-
-struct cleanup *
-make_cleanup_restore_ui_out (struct ui_out **variable)
-{
-  struct restore_ui_out_closure *c = XNEW (struct restore_ui_out_closure);
-
-  c->variable = variable;
-  c->value = *variable;
-
-  return make_cleanup_dtor (do_restore_ui_out, (void *) c, xfree);
-}
-
 struct restore_ui_file_closure
 {
   struct ui_file **variable;
index 6080f5bc7d3a032d7c55a4c5807df22b727cd77f..bf77d7daba0135af010d5076e91b5b56d0b0e766 100644 (file)
@@ -93,9 +93,6 @@ extern struct cleanup *make_cleanup_restore_uinteger (unsigned int *variable);
 struct target_ops;
 extern struct cleanup *make_cleanup_unpush_target (struct target_ops *ops);
 
-
-extern struct cleanup *
-  make_cleanup_restore_ui_out (struct ui_out **variable);
 extern struct cleanup *
   make_cleanup_restore_ui_file (struct ui_file **variable);