From 156d9eab863f40fc812245cf1213abbe12d192b3 Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Fri, 7 Apr 2017 15:37:25 -0600 Subject: Use scoped_restore in more places This changes a few more places to use scoped_restore, allowing some cleanup removals. gdb/ChangeLog 2017-04-12 Tom Tromey * mi/mi-main.c (exec_direction_forward): Remove. (exec_reverse_continue, mi_execute_command): Use scoped_restore. * guile/scm-ports.c (ioscm_with_output_to_port_worker): Use scoped_restore. * guile/guile.c (guile_repl_command, guile_command) (gdbscm_execute_gdb_command): Use scoped_restore. * go-exp.y (go_parse): Use scoped_restore. * d-exp.y (d_parse): Use scoped_restore. * cli/cli-decode.c (cmd_func): Use scoped_restore. * c-exp.y (c_parse): Use scoped_restore. --- gdb/guile/guile.c | 24 ++++++------------------ gdb/guile/scm-ports.c | 3 +-- 2 files changed, 7 insertions(+), 20 deletions(-) (limited to 'gdb/guile') diff --git a/gdb/guile/guile.c b/gdb/guile/guile.c index 9bb2487..0dadc3c 100644 --- a/gdb/guile/guile.c +++ b/gdb/guile/guile.c @@ -163,10 +163,7 @@ const struct extension_language_ops guile_extension_ops = static void guile_repl_command (char *arg, int from_tty) { - struct cleanup *cleanup; - - cleanup = make_cleanup_restore_integer (¤t_ui->async); - current_ui->async = 0; + scoped_restore restore_async = make_scoped_restore (¤t_ui->async, 0); arg = skip_spaces (arg); @@ -183,8 +180,6 @@ guile_repl_command (char *arg, int from_tty) dont_repeat (); gdbscm_enter_repl (); } - - do_cleanups (cleanup); } /* Implementation of the gdb "guile" command. @@ -196,10 +191,7 @@ guile_repl_command (char *arg, int from_tty) static void guile_command (char *arg, int from_tty) { - struct cleanup *cleanup; - - cleanup = make_cleanup_restore_integer (¤t_ui->async); - current_ui->async = 0; + scoped_restore restore_async = make_scoped_restore (¤t_ui->async, 0); arg = skip_spaces (arg); @@ -209,6 +201,8 @@ guile_command (char *arg, int from_tty) if (msg != NULL) { + /* It is ok that this is a "dangling cleanup" because we + throw immediately. */ make_cleanup (xfree, msg); error ("%s", msg); } @@ -219,8 +213,6 @@ guile_command (char *arg, int from_tty) execute_control_command_untraced (l.get ()); } - - do_cleanups (cleanup); } /* Given a command_line, return a command string suitable for passing @@ -326,10 +318,8 @@ gdbscm_execute_gdb_command (SCM command_scm, SCM rest) TRY { - struct cleanup *inner_cleanups; - - inner_cleanups = make_cleanup_restore_integer (¤t_ui->async); - current_ui->async = 0; + scoped_restore restore_async = make_scoped_restore (¤t_ui->async, + 0); scoped_restore preventer = prevent_dont_repeat (); if (to_string) @@ -339,8 +329,6 @@ gdbscm_execute_gdb_command (SCM command_scm, SCM rest) /* Do any commands attached to breakpoint we stopped at. */ bpstat_do_actions (); - - do_cleanups (inner_cleanups); } CATCH (ex, RETURN_MASK_ALL) { diff --git a/gdb/guile/scm-ports.c b/gdb/guile/scm-ports.c index fb3a47b..735abc2 100644 --- a/gdb/guile/scm-ports.c +++ b/gdb/guile/scm-ports.c @@ -470,8 +470,7 @@ ioscm_with_output_to_port_worker (SCM port, SCM thunk, enum oport oport, cleanups = set_batch_flag_and_make_cleanup_restore_page_info (); - make_cleanup_restore_integer (¤t_ui->async); - current_ui->async = 0; + scoped_restore restore_async = make_scoped_restore (¤t_ui->async, 0); ui_file_up port_file (new ioscm_file_port (port)); -- cgit v1.1