From: Tom Tromey <tom@tromey.com>
To: Tom Tromey <tom@tromey.com>
Cc: Pedro Alves <palves@redhat.com>, gdb-patches@sourceware.org
Subject: Re: [RFA v2 12/17] Remove make_cleanup_restore_current_uiout
Date: Thu, 20 Oct 2016 21:46:00 -0000 [thread overview]
Message-ID: <87pomuhex4.fsf@tromey.com> (raw)
In-Reply-To: <87r37iliuw.fsf@tromey.com> (Tom Tromey's message of "Fri, 14 Oct 2016 15:29:43 -0600")
Pedro> I wonder if you had a reasoning that led to deciding when
Pedro> to use two-argument form? A couple places looked like obvious
Pedro> candidates. My reasoning would be: if the assignment is right
Pedro> after the scoped_restore creation.
Tom> I tried to use them everywhere, but I just forgot to restore it in this
Tom> patch when I added the two-arg form back. I'll fix this up.
Here's the updated patch.
Tom
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index f2743fe..d2ab393 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,13 @@
2016-10-20 Tom Tromey <tom@tromey.com>
+ * stack.c (print_stack_frame_to_uiout): Use scoped_restore.
+ * ui-out.c (make_cleanup_restore_current_uiout)
+ (restore_current_uiout_cleanup): Remove.
+ * infrun.c (print_stop_event): Use scoped_restore.
+ * ui-out.h (make_cleanup_restore_current_uiout): Don't declare.
+
+2016-10-20 Tom Tromey <tom@tromey.com>
+
* elfread.c (elf_read_minimal_symbols): Use gdb::unique_ptr.
2016-10-20 Tom Tromey <tom@tromey.com>
diff --git a/gdb/infrun.c b/gdb/infrun.c
index 3069b2d..00bba16 100644
--- a/gdb/infrun.c
+++ b/gdb/infrun.c
@@ -8084,22 +8084,20 @@ print_stop_location (struct target_waitstatus *ws)
void
print_stop_event (struct ui_out *uiout)
{
- struct cleanup *old_chain;
struct target_waitstatus last;
ptid_t last_ptid;
struct thread_info *tp;
get_last_target_status (&last_ptid, &last);
- old_chain = make_cleanup_restore_current_uiout ();
- current_uiout = uiout;
-
- print_stop_location (&last);
+ {
+ scoped_restore save_uiout = make_scoped_restore (¤t_uiout, uiout);
- /* Display the auto-display expressions. */
- do_displays ();
+ print_stop_location (&last);
- do_cleanups (old_chain);
+ /* Display the auto-display expressions. */
+ do_displays ();
+ }
tp = inferior_thread ();
if (tp->thread_fsm != NULL
diff --git a/gdb/python/python.c b/gdb/python/python.c
index e478ec9..d6bd6bf 100644
--- a/gdb/python/python.c
+++ b/gdb/python/python.c
@@ -648,7 +648,7 @@ execute_gdb_command (PyObject *self, PyObject *args, PyObject *kw)
scoped_restore save_async = make_scoped_restore (¤t_ui->async, 0);
- make_cleanup_restore_current_uiout ();
+ scoped_restore save_uiout = make_scoped_restore (¤t_uiout);
/* Use the console interpreter uiout to have the same print format
for console or MI. */
diff --git a/gdb/stack.c b/gdb/stack.c
index 706dd51..823433d 100644
--- a/gdb/stack.c
+++ b/gdb/stack.c
@@ -149,15 +149,9 @@ print_stack_frame_to_uiout (struct ui_out *uiout, struct frame_info *frame,
int print_level, enum print_what print_what,
int set_current_sal)
{
- struct cleanup *old_chain;
-
- old_chain = make_cleanup_restore_current_uiout ();
-
- current_uiout = uiout;
+ scoped_restore save_uiout = make_scoped_restore (¤t_uiout, uiout);
print_stack_frame (frame, print_level, print_what, set_current_sal);
-
- do_cleanups (old_chain);
}
/* Show or print a stack frame FRAME briefly. The output is formatted
diff --git a/gdb/ui-out.c b/gdb/ui-out.c
index f6d6050..932cf12 100644
--- a/gdb/ui-out.c
+++ b/gdb/ui-out.c
@@ -952,24 +952,6 @@ ui_out_destroy (struct ui_out *uiout)
xfree (uiout);
}
-/* Cleanup that restores a previous current uiout. */
-
-static void
-restore_current_uiout_cleanup (void *arg)
-{
- struct ui_out *saved_uiout = (struct ui_out *) arg;
-
- current_uiout = saved_uiout;
-}
-
-/* See ui-out.h. */
-
-struct cleanup *
-make_cleanup_restore_current_uiout (void)
-{
- return make_cleanup (restore_current_uiout_cleanup, current_uiout);
-}
-
/* Standard gdb initialization hook. */
void
diff --git a/gdb/ui-out.h b/gdb/ui-out.h
index 6a4d78a..9e1e74d 100644
--- a/gdb/ui-out.h
+++ b/gdb/ui-out.h
@@ -247,8 +247,4 @@ extern void ui_out_destroy (struct ui_out *uiout);
extern int ui_out_redirect (struct ui_out *uiout, struct ui_file *outstream);
-/* Make a cleanup that restores the previous current uiout. */
-
-extern struct cleanup *make_cleanup_restore_current_uiout (void);
-
#endif /* UI_OUT_H */
next prev parent reply other threads:[~2016-10-20 21:46 UTC|newest]
Thread overview: 59+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-10-13 21:11 [RFA v2 00/17] more C++ Tom Tromey
2016-10-13 21:11 ` [RFA v2 12/17] Remove make_cleanup_restore_current_uiout Tom Tromey
2016-10-13 22:49 ` Pedro Alves
2016-10-14 21:30 ` Tom Tromey
2016-10-20 21:46 ` Tom Tromey [this message]
2016-10-20 21:57 ` Pedro Alves
2016-10-13 21:11 ` [RFA v2 08/17] Remove some cleanups in MI Tom Tromey
2016-10-13 22:38 ` Pedro Alves
2016-10-13 21:11 ` [RFA v2 15/17] Convert DWARF expr functions to methods Tom Tromey
2016-10-13 23:01 ` Pedro Alves
2016-10-20 21:47 ` Tom Tromey
2016-10-20 22:01 ` Pedro Alves
2016-10-13 21:11 ` [RFA v2 04/17] Introduce minimal_symbol_reader Tom Tromey
2016-10-13 22:20 ` Pedro Alves
2016-10-13 21:11 ` [RFA v2 02/17] Use scoped_restore for ui_file Tom Tromey
2016-10-13 22:07 ` Pedro Alves
2016-10-14 21:33 ` Tom Tromey
2016-10-13 21:11 ` [RFA v2 03/17] Use scoped_restore for current_ui Tom Tromey
2016-10-13 22:16 ` Pedro Alves
2016-10-13 21:11 ` [RFA v2 10/17] Replace two xmallocs with unique_ptr Tom Tromey
2016-10-13 22:44 ` Pedro Alves
2016-10-13 21:11 ` [RFA v2 05/17] Change minimal_symbol_reader to store objfile Tom Tromey
2016-10-13 22:21 ` Pedro Alves
2016-10-13 21:11 ` [RFA v2 11/17] Use gdb::unique_ptr in elf_read_minimal_symbols Tom Tromey
2016-10-13 22:44 ` Pedro Alves
2016-10-13 21:11 ` [RFA v2 07/17] Remove make_cleanup_restore_current_ui Tom Tromey
2016-10-13 22:37 ` Pedro Alves
2016-10-13 21:11 ` [RFA v2 01/17] Use RAII to save and restore scalars Tom Tromey
2016-10-13 22:03 ` Pedro Alves
2016-10-13 21:11 ` [RFA v2 14/17] Initial conversion of dwarf_expr_ctx Tom Tromey
2016-10-13 22:54 ` Pedro Alves
2016-10-13 21:11 ` [RFA v2 16/17] Convert dwarf_expr_context_funcs to methods Tom Tromey
2016-10-13 23:05 ` Pedro Alves
2016-10-18 2:50 ` Tom Tromey
2016-10-18 10:51 ` Pedro Alves
2016-10-18 14:55 ` Tom Tromey
2016-10-18 17:38 ` Pedro Alves
2016-10-19 22:29 ` Tom Tromey
2016-10-20 21:48 ` Tom Tromey
2016-10-20 21:56 ` Pedro Alves
2016-10-28 13:36 ` Pedro Alves
2016-10-31 2:48 ` Tom Tromey
2016-11-01 22:07 ` Tom Tromey
2016-11-02 16:12 ` Pedro Alves
2016-10-13 21:11 ` [RFA v2 06/17] Record minimal symbols directly in reader Tom Tromey
2016-10-13 22:34 ` Pedro Alves
2016-10-14 21:22 ` Tom Tromey
2016-10-20 21:47 ` Tom Tromey
2016-10-20 22:13 ` Pedro Alves
2016-10-13 21:13 ` [RFA v2 13/17] Some cleanup removal in dwarf2loc.c Tom Tromey
2016-10-13 22:52 ` Pedro Alves
2016-10-13 21:14 ` [RFA v2 09/17] Change command stats reporting to use class Tom Tromey
2016-10-13 22:43 ` Pedro Alves
2016-10-13 21:18 ` [RFA v2 17/17] Remove last cleanup from captured_main_1 Tom Tromey
2016-10-13 23:13 ` Pedro Alves
2016-10-13 21:39 ` [RFA v2 00/17] more C++ Pedro Alves
2016-10-14 16:26 ` Pedro Alves
2016-10-20 21:49 ` Tom Tromey
2016-10-20 22:27 ` Pedro Alves
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87pomuhex4.fsf@tromey.com \
--to=tom@tromey.com \
--cc=gdb-patches@sourceware.org \
--cc=palves@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).