From cd94f6d535d1ebd8f252185cd84d21fe0df3c893 Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Fri, 16 Sep 2016 15:44:29 -0400 Subject: Introduce cleanup to restore current_uiout 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/ui-out.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'gdb/ui-out.c') diff --git a/gdb/ui-out.c b/gdb/ui-out.c index 3972a56..ec44ab6 100644 --- a/gdb/ui-out.c +++ b/gdb/ui-out.c @@ -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 -- cgit v1.1