aboutsummaryrefslogtreecommitdiff
path: root/gdb/mi
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2016-09-22 20:29:11 -0600
committerTom Tromey <tom@tromey.com>2016-10-21 14:17:31 -0600
commitb7b633e9b13fc5697af035f4504c9790c612a8c7 (patch)
tree0da81b5f31738da5c2aa84819d709a66ef9d4583 /gdb/mi
parent9a1e3f003122c97d6e1822c472bcd37f59fb1a74 (diff)
downloadgdb-b7b633e9b13fc5697af035f4504c9790c612a8c7.zip
gdb-b7b633e9b13fc5697af035f4504c9790c612a8c7.tar.gz
gdb-b7b633e9b13fc5697af035f4504c9790c612a8c7.tar.bz2
Use RAII to save and restore scalars
This patch replaces many (but not all) uses of make_cleanup_restore_integer with a simple RAII-based template class. It also removes the similar restore_execution_direction cleanup in favor of this new class. Subsequent patches will replace other similar cleanups with this class. The class is typically instantiated using make_scoped_restore. This allows for template argument deduction. 2016-10-21 Tom Tromey <tom@tromey.com> * common/scoped_restore.h: New file. * utils.h: Include scoped_restore.h. * top.c (execute_command_to_string): Use scoped_restore. * python/python.c (python_interactive_command): Use scoped_restore. (python_command, execute_gdb_command): Likewise. * printcmd.c (do_one_display): Use scoped_restore. * mi/mi-main.c (exec_continue): Use scoped_restore. * mi/mi-cmd-var.c (mi_cmd_var_assign): Use scoped_restore. * linux-fork.c (checkpoint_command): Use scoped_restore. * infrun.c (restore_execution_direction): Remove. (fetch_inferior_event): Use scoped_restore. * compile/compile.c (compile_file_command): Use scoped_restore. (compile_code_command, compile_print_command): Likewise. * cli/cli-script.c (execute_user_command): Use scoped_restore. (while_command, if_command, script_from_file): Likewise. * arm-tdep.c (arm_insert_single_step_breakpoint): Use scoped_restore.
Diffstat (limited to 'gdb/mi')
-rw-r--r--gdb/mi/mi-cmd-var.c8
-rw-r--r--gdb/mi/mi-main.c3
2 files changed, 3 insertions, 8 deletions
diff --git a/gdb/mi/mi-cmd-var.c b/gdb/mi/mi-cmd-var.c
index 3bfe4f0..16d51f9 100644
--- a/gdb/mi/mi-cmd-var.c
+++ b/gdb/mi/mi-cmd-var.c
@@ -608,7 +608,6 @@ mi_cmd_var_assign (char *command, char **argv, int argc)
struct ui_out *uiout = current_uiout;
struct varobj *var;
char *expression, *val;
- struct cleanup *cleanup;
if (argc != 2)
error (_("-var-assign: Usage: NAME EXPRESSION."));
@@ -623,9 +622,8 @@ mi_cmd_var_assign (char *command, char **argv, int argc)
/* MI command '-var-assign' may write memory, so suppress memory
changed notification if it does. */
- cleanup
- = make_cleanup_restore_integer (&mi_suppress_notification.memory);
- mi_suppress_notification.memory = 1;
+ scoped_restore save_suppress
+ = make_scoped_restore (&mi_suppress_notification.memory, 1);
if (!varobj_set_value (var, expression))
error (_("-var-assign: Could not assign "
@@ -634,8 +632,6 @@ mi_cmd_var_assign (char *command, char **argv, int argc)
val = varobj_get_value (var);
ui_out_field_string (uiout, "value", val);
xfree (val);
-
- do_cleanups (cleanup);
}
/* Type used for parameters passing to mi_cmd_var_update_iter. */
diff --git a/gdb/mi/mi-main.c b/gdb/mi/mi-main.c
index 81e82ed..1bc8241 100644
--- a/gdb/mi/mi-main.c
+++ b/gdb/mi/mi-main.c
@@ -301,7 +301,7 @@ exec_continue (char **argv, int argc)
}
else
{
- struct cleanup *back_to = make_cleanup_restore_integer (&sched_multi);
+ scoped_restore save_multi = make_scoped_restore (&sched_multi);
if (current_context->all)
{
@@ -316,7 +316,6 @@ exec_continue (char **argv, int argc)
same. */
continue_1 (1);
}
- do_cleanups (back_to);
}
}