forked from Imagelibrary/binutils-gdb
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.
This commit is contained in:
@@ -1937,7 +1937,6 @@ undisplay_command (char *args, int from_tty)
|
||||
static void
|
||||
do_one_display (struct display *d)
|
||||
{
|
||||
struct cleanup *old_chain;
|
||||
int within_current_scope;
|
||||
|
||||
if (d->enabled_p == 0)
|
||||
@@ -1989,8 +1988,8 @@ do_one_display (struct display *d)
|
||||
if (!within_current_scope)
|
||||
return;
|
||||
|
||||
old_chain = make_cleanup_restore_integer (¤t_display_number);
|
||||
current_display_number = d->number;
|
||||
scoped_restore save_display_number
|
||||
= make_scoped_restore (¤t_display_number, d->number);
|
||||
|
||||
annotate_display_begin ();
|
||||
printf_filtered ("%d", d->number);
|
||||
@@ -2078,7 +2077,6 @@ do_one_display (struct display *d)
|
||||
annotate_display_end ();
|
||||
|
||||
gdb_flush (gdb_stdout);
|
||||
do_cleanups (old_chain);
|
||||
}
|
||||
|
||||
/* Display all of the values on the auto-display chain which can be
|
||||
|
||||
Reference in New Issue
Block a user