aboutsummaryrefslogtreecommitdiff
path: root/gdb/mi/mi-main.c
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2017-04-07 15:37:25 -0600
committerTom Tromey <tom@tromey.com>2017-04-12 11:16:19 -0600
commit156d9eab863f40fc812245cf1213abbe12d192b3 (patch)
treed4ac157ce5cd9fe88f8906f233c00f6ccebf3e12 /gdb/mi/mi-main.c
parent4d89769a7b4e38e94a6e027281b36eff71fc8214 (diff)
downloadgdb-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/mi/mi-main.c')
-rw-r--r--gdb/mi/mi-main.c25
1 files changed, 7 insertions, 18 deletions
diff --git a/gdb/mi/mi-main.c b/gdb/mi/mi-main.c
index d99c40e..c3e7bf7 100644
--- a/gdb/mi/mi-main.c
+++ b/gdb/mi/mi-main.c
@@ -54,6 +54,7 @@
#include "extension.h"
#include "gdbcmd.h"
#include "observer.h"
+#include "common/gdb_optional.h"
#include <ctype.h>
#include "run-time-clock.h"
@@ -312,16 +313,9 @@ exec_continue (char **argv, int argc)
}
static void
-exec_direction_forward (void *notused)
-{
- execution_direction = EXEC_FORWARD;
-}
-
-static void
exec_reverse_continue (char **argv, int argc)
{
enum exec_direction_kind dir = execution_direction;
- struct cleanup *old_chain;
if (dir == EXEC_REVERSE)
error (_("Already in reverse mode."));
@@ -329,10 +323,9 @@ exec_reverse_continue (char **argv, int argc)
if (!target_can_execute_reverse)
error (_("Target %s does not support this command."), target_shortname);
- old_chain = make_cleanup (exec_direction_forward, NULL);
- execution_direction = EXEC_REVERSE;
+ scoped_restore save_exec_dir = make_scoped_restore (&execution_direction,
+ EXEC_REVERSE);
exec_continue (argv, argc);
- do_cleanups (old_chain);
}
void
@@ -2140,15 +2133,13 @@ mi_execute_command (const char *cmd, int from_tty)
if (command != NULL)
{
ptid_t previous_ptid = inferior_ptid;
- struct cleanup *cleanup = make_cleanup (null_cleanup, NULL);
- command->token = token;
+ gdb::optional<scoped_restore_tmpl<int>> restore_suppress;
if (command->cmd != NULL && command->cmd->suppress_notification != NULL)
- {
- make_cleanup_restore_integer (command->cmd->suppress_notification);
- *command->cmd->suppress_notification = 1;
- }
+ restore_suppress.emplace (command->cmd->suppress_notification, 1);
+
+ command->token = token;
if (do_timings)
{
@@ -2210,8 +2201,6 @@ mi_execute_command (const char *cmd, int from_tty)
(USER_SELECTED_THREAD | USER_SELECTED_FRAME);
}
}
-
- do_cleanups (cleanup);
}
}