• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
Keine Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

GNU Binutils with patches for OS216


Commit MetaInfo

Revisionbe0d7abb5e3b0be4cb928845e70a9134f1b19700 (tree)
Zeit2017-09-12 07:15:08
AutorTom Tromey <tom@trom...>
CommiterTom Tromey

Log Message

Replace interp_set_temp with scoped_restore_interp

This removes interp_set_temp and an associated cleanup, in favor of a
new RAII class, scoped_restore_interp.

ChangeLog
2017-09-11 Tom Tromey <tom@tromey.com>

* cli/cli-script.c (restore_interp): Remove.
(read_command_lines): Use scoped_restore_interp.
* interps.c (scoped_restore_interp::set_temp): Rename from
interp_set_temp.
* interps.h (class scoped_restore_interp): New.
(interp_set_temp): Remove.

Ändern Zusammenfassung

Diff

--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,14 @@
11 2017-09-11 Tom Tromey <tom@tromey.com>
22
3+ * cli/cli-script.c (restore_interp): Remove.
4+ (read_command_lines): Use scoped_restore_interp.
5+ * interps.c (scoped_restore_interp::set_temp): Rename from
6+ interp_set_temp.
7+ * interps.h (class scoped_restore_interp): New.
8+ (interp_set_temp): Remove.
9+
10+2017-09-11 Tom Tromey <tom@tromey.com>
11+
312 * mi/mi-cmd-catch.c (mi_cmd_catch_assert)
413 (mi_cmd_catch_exception, mi_catch_load_unload): Update.
514 * mi/mi-cmd-break.c (setup_breakpoint_reporting): Return a
--- a/gdb/cli/cli-script.c
+++ b/gdb/cli/cli-script.c
@@ -1158,12 +1158,6 @@ recurse_read_control_structure (char * (*read_next_line_func) (void),
11581158 return ret;
11591159 }
11601160
1161-static void
1162-restore_interp (void *arg)
1163-{
1164- interp_set_temp (interp_name ((struct interp *)arg));
1165-}
1166-
11671161 /* Read lines from the input stream and accumulate them in a chain of
11681162 struct command_line's, which is then returned. For input from a
11691163 terminal, the special command "end" is used to mark the end of the
@@ -1203,12 +1197,10 @@ read_command_lines (char *prompt_arg, int from_tty, int parse_commands,
12031197 validator, closure);
12041198 else
12051199 {
1206- struct interp *old_interp = interp_set_temp (INTERP_CONSOLE);
1207- struct cleanup *old_chain = make_cleanup (restore_interp, old_interp);
1200+ scoped_restore_interp interp_restorer (INTERP_CONSOLE);
12081201
12091202 head = read_command_lines_1 (read_next_line, parse_commands,
12101203 validator, closure);
1211- do_cleanups (old_chain);
12121204 }
12131205
12141206 if (from_tty && input_interactive_p (current_ui)
--- a/gdb/interps.c
+++ b/gdb/interps.c
@@ -288,7 +288,7 @@ current_interp_set_logging (ui_file_up logfile,
288288
289289 /* Temporarily overrides the current interpreter. */
290290 struct interp *
291-interp_set_temp (const char *name)
291+scoped_restore_interp::set_interp (const char *name)
292292 {
293293 struct ui_interp_info *ui_interp = get_current_interp_info ();
294294 struct interp *interp = interp_lookup (current_ui, name);
--- a/gdb/interps.h
+++ b/gdb/interps.h
@@ -104,6 +104,32 @@ extern struct ui_out *interp_ui_out (struct interp *interp);
104104 extern const char *interp_name (struct interp *interp);
105105 extern struct interp *interp_set_temp (const char *name);
106106
107+/* Temporarily set the current interpreter, and reset it on
108+ destruction. */
109+class scoped_restore_interp
110+{
111+public:
112+
113+ scoped_restore_interp (const char *name)
114+ : m_interp (set_interp (name))
115+ {
116+ }
117+
118+ ~scoped_restore_interp ()
119+ {
120+ set_interp (interp_name (m_interp));
121+ }
122+
123+ scoped_restore_interp (const scoped_restore_interp &) = delete;
124+ scoped_restore_interp &operator= (const scoped_restore_interp &) = delete;
125+
126+private:
127+
128+ struct interp *set_interp (const char *name);
129+
130+ struct interp *m_interp;
131+};
132+
107133 extern int current_interp_named_p (const char *name);
108134
109135 /* Call this function to give the current interpreter an opportunity