aboutsummaryrefslogtreecommitdiff
path: root/gdb/reverse.c
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2017-04-26 22:53:40 -0600
committerTom Tromey <tom@tromey.com>2017-08-03 07:59:00 -0600
commit2ec845e758762030f2333c21fa532fc57fe3762f (patch)
tree9732e9de0eb998580859fcc3d2a33285b454d561 /gdb/reverse.c
parentb3bc84537bc6de78e2bbd550ce9c57dd4b7e2ec6 (diff)
downloadgdb-2ec845e758762030f2333c21fa532fc57fe3762f.zip
gdb-2ec845e758762030f2333c21fa532fc57fe3762f.tar.gz
gdb-2ec845e758762030f2333c21fa532fc57fe3762f.tar.bz2
More uses of scoped_restore
There were a few more places in gdb that could easily use scoped_restore, replacing some cleanups. ChangeLog 2017-08-03 Tom Tromey <tom@tromey.com> * reverse.c (exec_direction_default): Remove. (exec_reverse_once): Use scoped_restore. * remote.c (restore_remote_timeout): Remove. (remote_flash_erase, remote_flash_write, remote_flash_done) (readchar, remote_serial_write): Use scoped_restore. * cli/cli-script.c (struct source_cleanup_lines_args) (source_cleanup_lines): Remove. (script_from_file): Use scoped_restore. * cli/cli-cmds.c (source_verbose_cleanup): Remove. (source_command): Use scoped_restore.
Diffstat (limited to 'gdb/reverse.c')
-rw-r--r--gdb/reverse.c19
1 files changed, 4 insertions, 15 deletions
diff --git a/gdb/reverse.c b/gdb/reverse.c
index 4080616..c8f3811 100644
--- a/gdb/reverse.c
+++ b/gdb/reverse.c
@@ -30,13 +30,6 @@
/* User interface:
reverse-step, reverse-next etc. */
-static void
-exec_direction_default (void *notused)
-{
- /* Return execution direction to default state. */
- execution_direction = EXEC_FORWARD;
-}
-
/* exec_reverse_once -- accepts an arbitrary gdb command (string),
and executes it with exec-direction set to 'reverse'.
@@ -45,9 +38,7 @@ exec_direction_default (void *notused)
static void
exec_reverse_once (const char *cmd, char *args, int from_tty)
{
- char *reverse_command;
enum exec_direction_kind dir = execution_direction;
- struct cleanup *old_chain;
if (dir == EXEC_REVERSE)
error (_("Already in reverse mode. Use '%s' or 'set exec-dir forward'."),
@@ -56,12 +47,10 @@ exec_reverse_once (const char *cmd, char *args, int from_tty)
if (!target_can_execute_reverse)
error (_("Target %s does not support this command."), target_shortname);
- reverse_command = xstrprintf ("%s %s", cmd, args ? args : "");
- old_chain = make_cleanup (exec_direction_default, NULL);
- make_cleanup (xfree, reverse_command);
- execution_direction = EXEC_REVERSE;
- execute_command (reverse_command, from_tty);
- do_cleanups (old_chain);
+ std::string reverse_command = string_printf ("%s %s", cmd, args ? args : "");
+ scoped_restore restore_exec_dir
+ = make_scoped_restore (&execution_direction, EXEC_REVERSE);
+ execute_command (&reverse_command[0], from_tty);
}
static void