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.
+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.
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
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);
make_cleanup_restore_integer (¤t_ui->async);
current_ui->async = 0;
- make_cleanup_restore_ui_out (¤t_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");
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
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 */
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;
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);