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.
+
+2017-04-12 Tom Tromey <tom@tromey.com>
+
* mi/mi-parse.h (struct mi_parse): Add constructor, destructor.
(mi_parse): Update return type.
(mi_parse_free): Remove.
gdb_assert (! macro_original_text);
make_cleanup (scan_macro_cleanup, 0);
- make_cleanup_restore_integer (&yydebug);
- yydebug = parser_debug;
+ scoped_restore restore_yydebug = make_scoped_restore (&yydebug,
+ parser_debug);
/* Initialize some state used by the lexer. */
last_was_structop = 0;
#include "ui-out.h"
#include "cli/cli-cmds.h"
#include "cli/cli-decode.h"
+#include "common/gdb_optional.h"
/* Prototypes for local functions. */
{
if (cmd_func_p (cmd))
{
- struct cleanup *cleanups = make_cleanup (null_cleanup, NULL);
+ gdb::optional<scoped_restore_tmpl<int>> restore_suppress;
if (cmd->suppress_notification != NULL)
- {
- make_cleanup_restore_integer (cmd->suppress_notification);
- *cmd->suppress_notification = 1;
- }
+ restore_suppress.emplace (cmd->suppress_notification, 1);
(*cmd->func) (cmd, args, from_tty);
-
- do_cleanups (cleanups);
}
else
error (_("Invalid command"));
back_to = make_cleanup (null_cleanup, NULL);
- make_cleanup_restore_integer (&yydebug);
+ scoped_restore restore_yydebug = make_scoped_restore (&yydebug,
+ parser_debug);
make_cleanup_clear_parser_state (&pstate);
- yydebug = parser_debug;
/* Initialize some state used by the lexer. */
last_was_structop = 0;
back_to = make_cleanup (null_cleanup, NULL);
- make_cleanup_restore_integer (&yydebug);
+ scoped_restore restore_yydebug = make_scoped_restore (&yydebug,
+ parser_debug);
make_cleanup_clear_parser_state (&pstate);
- yydebug = parser_debug;
/* Initialize some state used by the lexer. */
last_was_structop = 0;
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);
dont_repeat ();
gdbscm_enter_repl ();
}
-
- do_cleanups (cleanup);
}
/* Implementation of the gdb "guile" command.
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);
if (msg != NULL)
{
+ /* It is ok that this is a "dangling cleanup" because we
+ throw immediately. */
make_cleanup (xfree, msg);
error ("%s", msg);
}
execute_control_command_untraced (l.get ());
}
-
- do_cleanups (cleanup);
}
/* Given a command_line, return a command string suitable for passing
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)
/* Do any commands attached to breakpoint we stopped at. */
bpstat_do_actions ();
-
- do_cleanups (inner_cleanups);
}
CATCH (ex, RETURN_MASK_ALL)
{
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));
#include "extension.h"
#include "gdbcmd.h"
#include "observer.h"
+#include "common/gdb_optional.h"
#include <ctype.h>
#include "run-time-clock.h"
}
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."));
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
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)
{
(USER_SELECTED_THREAD | USER_SELECTED_FRAME);
}
}
-
- do_cleanups (cleanup);
}
}