diff options
author | Tom Tromey <tom@tromey.com> | 2017-04-07 15:37:25 -0600 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2017-04-12 11:16:19 -0600 |
commit | 156d9eab863f40fc812245cf1213abbe12d192b3 (patch) | |
tree | d4ac157ce5cd9fe88f8906f233c00f6ccebf3e12 /gdb/guile | |
parent | 4d89769a7b4e38e94a6e027281b36eff71fc8214 (diff) | |
download | gdb-156d9eab863f40fc812245cf1213abbe12d192b3.zip gdb-156d9eab863f40fc812245cf1213abbe12d192b3.tar.gz gdb-156d9eab863f40fc812245cf1213abbe12d192b3.tar.bz2 |
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 <tom@tromey.com>
* 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.
Diffstat (limited to 'gdb/guile')
-rw-r--r-- | gdb/guile/guile.c | 24 | ||||
-rw-r--r-- | gdb/guile/scm-ports.c | 3 |
2 files changed, 7 insertions, 20 deletions
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)); |