public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
* [binutils-gdb] gdb: Use scoped_restore_terminal_state in annotate.c
@ 2019-06-14 14:28 Andrew Burgess
  0 siblings, 0 replies; only message in thread
From: Andrew Burgess @ 2019-06-14 14:28 UTC (permalink / raw)
  To: gdb-cvs

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=7c39e397aafaea64812f2611b061bdd50f30dce4

commit 7c39e397aafaea64812f2611b061bdd50f30dce4
Author: Andrew Burgess <andrew.burgess@embecosm.com>
Date:   Thu Jun 13 22:13:28 2019 +0100

    gdb: Use scoped_restore_terminal_state in annotate.c
    
    In a couple of places in annotate.c we are manually backing up and
    restoring the terminal ownership, we could instead make use of
    scoped_restore_terminal_state.
    
    gdb/ChangeLog:
    
    	* annotate.c (annotate_breakpoints_invalid): Make use of
    	scoped_restore_terminal_state.
    	(annotate_frames_invalid): Likewise.

Diff:
---
 gdb/ChangeLog  |  6 ++++++
 gdb/annotate.c | 18 ++----------------
 2 files changed, 8 insertions(+), 16 deletions(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index ee3377c..f4f5b54 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,9 @@
+2019-06-14  Andrew Burgess  <andrew.burgess@embecosm.com>
+
+	* annotate.c (annotate_breakpoints_invalid): Make use of
+	scoped_restore_terminal_state.
+	(annotate_frames_invalid): Likewise.
+
 2019-06-14  Tom Tromey  <tromey@adacore.com>
 
 	* ada-lang.c (ada_evaluate_subexp) <case BINOP_ASSIGN>: Always
diff --git a/gdb/annotate.c b/gdb/annotate.c
index e6e8084..84940ff 100644
--- a/gdb/annotate.c
+++ b/gdb/annotate.c
@@ -61,17 +61,10 @@ annotate_breakpoints_invalid (void)
       && (!breakpoints_invalid_emitted
 	  || current_ui->prompt_state != PROMPT_BLOCKED))
     {
-      /* If the inferior owns the terminal (e.g., we're resuming),
-	 make sure to leave with the inferior still owning it.  */
-      int was_inferior = target_terminal::is_inferior ();
-
+      target_terminal::scoped_restore_terminal_state term_state;
       target_terminal::ours_for_output ();
 
       printf_unfiltered (("\n\032\032breakpoints-invalid\n"));
-
-      if (was_inferior)
-	target_terminal::inferior ();
-
       breakpoints_invalid_emitted = 1;
     }
 }
@@ -208,17 +201,10 @@ annotate_frames_invalid (void)
       && (!frames_invalid_emitted
 	  || current_ui->prompt_state != PROMPT_BLOCKED))
     {
-      /* If the inferior owns the terminal (e.g., we're resuming),
-	 make sure to leave with the inferior still owning it.  */
-      int was_inferior = target_terminal::is_inferior ();
-
+      target_terminal::scoped_restore_terminal_state term_state;
       target_terminal::ours_for_output ();
 
       printf_unfiltered (("\n\032\032frames-invalid\n"));
-
-      if (was_inferior)
-	target_terminal::inferior ();
-
       frames_invalid_emitted = 1;
     }
 }


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2019-06-14 14:28 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-14 14:28 [binutils-gdb] gdb: Use scoped_restore_terminal_state in annotate.c Andrew Burgess

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).