• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No 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

Revisióna9921622de0a7332a333c5206ce8cd632803df97 (tree)
Tiempo2017-09-12 07:15:09
AutorTom Tromey <tom@trom...>
CommiterTom Tromey

Log Message

Replace clear_hook_in_cleanup with scoped_restore_hook_in

This removes clear_hook_in_cleanup in favor of a scoped_restore-like
class. scoped_restore itself can't be used because hook_in is a
bitfield.

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

* cli/cli-script.c (class scoped_restore_hook_in): New.
(clear_hook_in_cleanup): Remove.
(execute_cmd_pre_hook, execute_cmd_post_hook): Use
scoped_restore_hook_in.

Cambiar Resumen

Diferencia incremental

--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,12 @@
11 2017-09-11 Tom Tromey <tom@tromey.com>
22
3+ * cli/cli-script.c (class scoped_restore_hook_in): New.
4+ (clear_hook_in_cleanup): Remove.
5+ (execute_cmd_pre_hook, execute_cmd_post_hook): Use
6+ scoped_restore_hook_in.
7+
8+2017-09-11 Tom Tromey <tom@tromey.com>
9+
310 * cli/cli-script.c (restore_interp): Remove.
411 (read_command_lines): Use scoped_restore_interp.
512 * interps.c (scoped_restore_interp::set_temp): Rename from
--- a/gdb/cli/cli-script.c
+++ b/gdb/cli/cli-script.c
@@ -340,23 +340,36 @@ print_command_lines (struct ui_out *uiout, struct command_line *cmd,
340340
341341 /* Handle pre-post hooks. */
342342
343-static void
344-clear_hook_in_cleanup (void *data)
343+class scoped_restore_hook_in
345344 {
346- struct cmd_list_element *c = (struct cmd_list_element *) data;
345+public:
347346
348- c->hook_in = 0; /* Allow hook to work again once it is complete. */
349-}
347+ scoped_restore_hook_in (struct cmd_list_element *c)
348+ : m_cmd (c)
349+ {
350+ }
351+
352+ ~scoped_restore_hook_in ()
353+ {
354+ m_cmd->hook_in = 0;
355+ }
356+
357+ scoped_restore_hook_in (const scoped_restore_hook_in &) = delete;
358+ scoped_restore_hook_in &operator= (const scoped_restore_hook_in &) = delete;
359+
360+private:
361+
362+ struct cmd_list_element *m_cmd;
363+};
350364
351365 void
352366 execute_cmd_pre_hook (struct cmd_list_element *c)
353367 {
354368 if ((c->hook_pre) && (!c->hook_in))
355369 {
356- struct cleanup *cleanups = make_cleanup (clear_hook_in_cleanup, c);
370+ scoped_restore_hook_in restore_hook (c);
357371 c->hook_in = 1; /* Prevent recursive hooking. */
358372 execute_user_command (c->hook_pre, (char *) 0);
359- do_cleanups (cleanups);
360373 }
361374 }
362375
@@ -365,11 +378,9 @@ execute_cmd_post_hook (struct cmd_list_element *c)
365378 {
366379 if ((c->hook_post) && (!c->hook_in))
367380 {
368- struct cleanup *cleanups = make_cleanup (clear_hook_in_cleanup, c);
369-
381+ scoped_restore_hook_in restore_hook (c);
370382 c->hook_in = 1; /* Prevent recursive hooking. */
371383 execute_user_command (c->hook_post, (char *) 0);
372- do_cleanups (cleanups);
373384 }
374385 }
375386