btrace: Fix memory leak in btrace_clear.
[deliverable/binutils-gdb.git] / gdb / annotate.c
index d82daa2919c21063e505311c990f1b884373c6aa..426005adba558759fa367b99aabc2273b7cc750c 100644 (file)
@@ -1,5 +1,5 @@
 /* Annotation routines for GDB.
-   Copyright (C) 1986-2013 Free Software Foundation, Inc.
+   Copyright (C) 1986-2017 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -24,6 +24,8 @@
 #include "breakpoint.h"
 #include "observer.h"
 #include "inferior.h"
+#include "infrun.h"
+#include "top.h"
 \f
 
 /* Prototypes for local functions.  */
@@ -45,16 +47,6 @@ void (*deprecated_annotate_signal_hook) (void);
 static int frames_invalid_emitted;
 static int breakpoints_invalid_emitted;
 
-/* True if the target can async, and a synchronous execution command
-   is not in progress.  If true, input is accepted, so don't suppress
-   annotations.  */
-
-static int
-async_background_execution_p (void)
-{
-  return (target_can_async_p () && !sync_execution);
-}
-
 static void
 print_value_flags (struct type *t)
 {
@@ -69,10 +61,19 @@ annotate_breakpoints_invalid (void)
 {
   if (annotation_level == 2
       && (!breakpoints_invalid_emitted
-         || async_background_execution_p ()))
+         || current_ui->prompt_state != PROMPT_BLOCKED))
     {
-      target_terminal_ours ();
+      /* 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_ours_for_output ();
+
       printf_unfiltered (("\n\032\032breakpoints-invalid\n"));
+
+      if (was_inferior)
+       target_terminal_inferior ();
+
       breakpoints_invalid_emitted = 1;
     }
 }
@@ -207,10 +208,19 @@ annotate_frames_invalid (void)
 {
   if (annotation_level == 2
       && (!frames_invalid_emitted
-         || async_background_execution_p ()))
+         || current_ui->prompt_state != PROMPT_BLOCKED))
     {
-      target_terminal_ours ();
+      /* 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_ours_for_output ();
+
       printf_unfiltered (("\n\032\032frames-invalid\n"));
+
+      if (was_inferior)
+       target_terminal_inferior ();
+
       frames_invalid_emitted = 1;
     }
 }
@@ -575,6 +585,9 @@ annotate_display_prompt (void)
 static void
 breakpoint_changed (struct breakpoint *b)
 {
+  if (b->number <= 0)
+    return;
+
   annotate_breakpoints_invalid ();
 }
 
This page took 0.02709 seconds and 4 git commands to generate.