diff mbox

gdb: Use scoped_restore_terminal_state in annotate.c

Message ID 20190613211603.3232-1-andrew.burgess@embecosm.com
State New
Headers show

Commit Message

Andrew Burgess June 13, 2019, 9:16 p.m. UTC
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.
---
 gdb/ChangeLog  |  6 ++++++
 gdb/annotate.c | 18 ++----------------
 2 files changed, 8 insertions(+), 16 deletions(-)

Comments

Tom Tromey June 14, 2019, 12:59 p.m. UTC | #1
>>>>> "Andrew" == Andrew Burgess <andrew.burgess@embecosm.com> writes:

Andrew> In a couple of places in annotate.c we are manually backing up and
Andrew> restoring the terminal ownership, we could instead make use of
Andrew> scoped_restore_terminal_state.

Thanks, this seems like a good cleanup to me.

Tom
diff mbox

Patch

diff --git a/gdb/annotate.c b/gdb/annotate.c
index e6e8084e9b1..84940ff031a 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;
     }
 }