Replace the sync_execution global with a new enum prompt_state tristate
[deliverable/binutils-gdb.git] / gdb / event-top.c
index 5e42c5605139fbf18b1e63e07c7bb73ce97720e0..c9e754875df007ddc30e10dc1016e42d83dd4b83 100644 (file)
@@ -354,7 +354,11 @@ display_gdb_prompt (const char *new_prompt)
      IE, displayed but not set.  */
   if (! new_prompt)
     {
-      if (sync_execution)
+      struct ui *ui = current_ui;
+
+      if (ui->prompt_state == PROMPTED)
+       internal_error (__FILE__, __LINE__, _("double prompt"));
+      else if (ui->prompt_state == PROMPT_BLOCKED)
        {
          /* This is to trick readline into not trying to display the
             prompt.  Even though we display the prompt using this
@@ -377,10 +381,11 @@ display_gdb_prompt (const char *new_prompt)
          do_cleanups (old_chain);
          return;
        }
-      else
+      else if (ui->prompt_state == PROMPT_NEEDED)
        {
          /* Display the top level prompt.  */
          actual_gdb_prompt = top_level_prompt ();
+         ui->prompt_state = PROMPTED;
        }
     }
   else
@@ -541,14 +546,12 @@ stdin_event_handler (int error, gdb_client_data client_data)
 void
 async_enable_stdin (void)
 {
-  if (sync_execution)
+  struct ui *ui = current_ui;
+
+  if (ui->prompt_state == PROMPT_BLOCKED)
     {
-      /* See NOTE in async_disable_stdin().  */
-      /* FIXME: cagney/1999-09-27: Call this before clearing
-        sync_execution.  Current target_terminal_ours() implementations
-        check for sync_execution before switching the terminal.  */
       target_terminal_ours ();
-      sync_execution = 0;
+      ui->prompt_state = PROMPT_NEEDED;
     }
 }
 
@@ -558,7 +561,9 @@ async_enable_stdin (void)
 void
 async_disable_stdin (void)
 {
-  sync_execution = 1;
+  struct ui *ui = current_ui;
+
+  ui->prompt_state = PROMPT_BLOCKED;
 }
 \f
 
@@ -774,8 +779,12 @@ command_line_handler (char *rl)
     }
   else
     {
+      ui->prompt_state = PROMPT_NEEDED;
+
       command_handler (cmd);
-      display_gdb_prompt (0);
+
+      if (ui->prompt_state != PROMPTED)
+       display_gdb_prompt (0);
     }
 }
 
This page took 0.026105 seconds and 4 git commands to generate.