Replace the sync_execution global with a new enum prompt_state tristate
[deliverable/binutils-gdb.git] / gdb / mi / mi-interp.c
index 4376ffa06a8e4d3c3946f4dc1f8d34a84fd9fa07..5db61e14f1f2e3fbcaffedebd8937b8af5041f41 100644 (file)
@@ -93,8 +93,11 @@ static int report_initial_inferior (struct inferior *inf, void *closure);
 static void
 display_mi_prompt (struct mi_interp *mi)
 {
+  struct ui *ui = current_ui;
+
   fputs_unfiltered ("(gdb) \n", mi->raw_stdout);
   gdb_flush (mi->raw_stdout);
+  ui->prompt_state = PROMPTED;
 }
 
 /* Returns the INTERP's data cast as mi_interp if INTERP is an MI, and
@@ -169,13 +172,6 @@ mi_interpreter_resume (void *data)
 
   ui->call_readline = gdb_readline_no_editing_callback;
   ui->input_handler = mi_execute_command_input_handler;
-  /* FIXME: This is a total hack for now.  PB's use of the MI
-     implicitly relies on a bug in the async support which allows
-     asynchronous commands to leak through the commmand loop.  The bug
-     involves (but is not limited to) the fact that sync_execution was
-     erroneously initialized to 0.  Duplicate by initializing it thus
-     here...  */
-  sync_execution = 0;
 
   gdb_stdout = mi->out;
   /* Route error and log output through the MI.  */
@@ -315,6 +311,9 @@ static void
 mi_execute_command_input_handler (char *cmd)
 {
   struct mi_interp *mi = as_mi_interp (top_level_interpreter ());
+  struct ui *ui = current_ui;
+
+  ui->prompt_state = PROMPT_NEEDED;
 
   mi_execute_command_wrapper (cmd);
 
@@ -323,7 +322,7 @@ mi_execute_command_input_handler (char *cmd)
      to go back to the event loop and will output the prompt in the
      'synchronous_command_done' observer when the target next
      stops.  */
-  if (!sync_execution)
+  if (ui->prompt_state == PROMPT_NEEDED)
     display_mi_prompt (mi);
 }
 
@@ -1139,12 +1138,10 @@ mi_on_resume_1 (struct mi_interp *mi, ptid_t ptid)
   if (!running_result_record_printed && mi_proceeded)
     {
       running_result_record_printed = 1;
-      /* This is what gdb used to do historically -- printing prompt even if
-        it cannot actually accept any input.  This will be surely removed
-        for MI3, and may be removed even earlier.  SYNC_EXECUTION is
-        checked here because we only need to emit a prompt if a
-        synchronous command was issued when the target is async.  */
-      if (!target_can_async_p () || sync_execution)
+      /* This is what gdb used to do historically -- printing prompt
+        even if it cannot actually accept any input.  This will be
+        surely removed for MI3, and may be removed even earlier.  */
+      if (current_ui->prompt_state == PROMPT_BLOCKED)
        fputs_unfiltered ("(gdb) \n", mi->raw_stdout);
     }
   gdb_flush (mi->raw_stdout);
This page took 0.029798 seconds and 4 git commands to generate.