public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Simon Marchi <simon.marchi@ericsson.com>
To: <gdb-patches@sourceware.org>
Cc: Simon Marchi <simon.marchi@ericsson.com>
Subject: [PATCH master+7.12 v2 1/3] Introduce cleanup to restore current_uiout
Date: Wed, 14 Sep 2016 17:46:00 -0000	[thread overview]
Message-ID: <20160914174548.5873-2-simon.marchi@ericsson.com> (raw)
In-Reply-To: <20160914174548.5873-1-simon.marchi@ericsson.com>

Make a globally available cleanup from a pre-existing one in infrun.c.
This is used in the following patch.

gdb/ChangeLog:

	* infrun.c (restore_current_uiout_cleanup): Move to ui-out.c.
	(print_stop_event): Use make_cleanup_restore_current_uiout.
	* ui-out.c (restore_current_uiout_cleanup): Move from infrun.c.
	(make_cleanup_restore_current_uiout): New function definition.
	* ui-out.h (make_cleanup_restore_current_uiout): New function
	definition.
---
 gdb/infrun.c | 12 +-----------
 gdb/ui-out.c | 18 ++++++++++++++++++
 gdb/ui-out.h |  4 ++++
 3 files changed, 23 insertions(+), 11 deletions(-)

diff --git a/gdb/infrun.c b/gdb/infrun.c
index 70d7a09..ec37ca1 100644
--- a/gdb/infrun.c
+++ b/gdb/infrun.c
@@ -8096,16 +8096,6 @@ print_stop_location (struct target_waitstatus *ws)
     print_stack_frame (get_selected_frame (NULL), 0, source_flag, 1);
 }
 
-/* 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 infrun.h.  */
 
 void
@@ -8118,7 +8108,7 @@ print_stop_event (struct ui_out *uiout)
 
   get_last_target_status (&last_ptid, &last);
 
-  old_chain = make_cleanup (restore_current_uiout_cleanup, current_uiout);
+  old_chain = make_cleanup_restore_current_uiout ();
   current_uiout = uiout;
 
   print_stop_location (&last);
diff --git a/gdb/ui-out.c b/gdb/ui-out.c
index 3972a56..ec44ab6 100644
--- a/gdb/ui-out.c
+++ b/gdb/ui-out.c
@@ -953,6 +953,24 @@ 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 9e1e74d..6a4d78a 100644
--- a/gdb/ui-out.h
+++ b/gdb/ui-out.h
@@ -247,4 +247,8 @@ 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 */
-- 
2.9.3

  parent reply	other threads:[~2016-09-14 17:46 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-14 17:46 [PATCH master+7.12 v2 0/3] Emit user selection change notifications on all UIs Simon Marchi
2016-09-14 17:46 ` [PATCH master+7.12 v2 3/3] Add test for user context selection sync Simon Marchi
2016-09-14 19:31   ` Pedro Alves
2016-09-16  2:02     ` Simon Marchi
2016-09-21 16:43       ` Pedro Alves
2016-09-21 21:38         ` Simon Marchi
2016-09-22  1:56           ` Simon Marchi
2016-09-14 17:46 ` Simon Marchi [this message]
2016-09-14 17:56   ` [PATCH master+7.12 v2 1/3] Introduce cleanup to restore current_uiout Pedro Alves
2016-09-15  3:24     ` Simon Marchi
2016-09-16 18:18       ` Pedro Alves
     [not found]         ` <0c9914b2-f012-3b59-f127-04e70a7f867a@ericsson.com>
2016-10-03 21:25           ` Simon Marchi
2016-09-14 18:11   ` Tom Tromey
2016-09-14 18:18     ` Simon Marchi
2016-09-14 18:32       ` Pedro Alves
2016-09-14 19:12         ` Tom Tromey
2016-09-15  3:17           ` Simon Marchi
2016-09-14 17:46 ` [PATCH master+7.12 v2 2/3] Emit inferior, thread and frame selection events to all UIs Simon Marchi
2016-09-14 18:30   ` Pedro Alves
2016-09-15 16:21     ` Simon Marchi
2016-09-16 18:26       ` 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=20160914174548.5873-2-simon.marchi@ericsson.com \
    --to=simon.marchi@ericsson.com \
    --cc=gdb-patches@sourceware.org \
    /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).