gdb: Use scoped_restore_terminal_state in annotate.c
authorAndrew Burgess <andrew.burgess@embecosm.com>
Thu, 13 Jun 2019 21:13:28 +0000 (22:13 +0100)
committerAndrew Burgess <andrew.burgess@embecosm.com>
Fri, 14 Jun 2019 14:27:34 +0000 (15:27 +0100)
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
gdb/annotate.c

index ee3377c56b29c8f80e7b3882b5d2766e2e3fa444..f4f5b54b7f562bca028ed196d7809ee9f281a580 100644 (file)
@@ -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
index e6e8084e9b1895e8d320fab4d7df7d987466c5de..84940ff031a7f001f089858406f9adc9f081e249 100644 (file)
@@ -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;
     }
 }