Make reinsert_breakpoint thread specific
[deliverable/binutils-gdb.git] / gdb / utils.c
index 760c37654e59d7b70ca80458bdf80e9f97a997e8..c70e99cea4924a3dc5093b3d340db29a03b85784 100644 (file)
@@ -109,19 +109,6 @@ static int debug_timestamp = 0;
 
 int job_control;
 
-/* Nonzero means quit immediately if Control-C is typed now, rather
-   than waiting until QUIT is executed.  Be careful in setting this;
-   code which executes with immediate_quit set has to be very careful
-   about being able to deal with being interrupted at any time.  It is
-   almost always better to use QUIT; the only exception I can think of
-   is being able to quit out of a system call (using EINTR loses if
-   the SIGINT happens between the previous QUIT and the system call).
-   To immediately quit in the case in which a SIGINT happens between
-   the previous QUIT and setting immediate_quit (desirable anytime we
-   expect to block), call QUIT after setting immediate_quit.  */
-
-int immediate_quit;
-
 /* Nonzero means that strings with character values >0x7F should be printed
    as octal escapes.  Zero means just print the value (e.g. it's an
    international character, and the terminal or window can cope.)  */
@@ -1060,10 +1047,12 @@ print_sys_errmsg (const char *string, int errcode)
 void
 quit (void)
 {
+  struct ui *ui = current_ui;
+
   if (sync_quit_force_run)
     {
       sync_quit_force_run = 0;
-      quit_force (NULL, stdin == instream);
+      quit_force (NULL, 0);
     }
 
 #ifdef __MSDOS__
@@ -1086,11 +1075,13 @@ quit (void)
 void
 maybe_quit (void)
 {
-  if (check_quit_flag () || sync_quit_force_run)
+  if (sync_quit_force_run)
     quit ();
+
+  quit_handler ();
+
   if (deprecated_interactive_hook)
     deprecated_interactive_hook ();
-  target_check_pending_interrupt ();
 }
 
 \f
@@ -1274,12 +1265,16 @@ defaulted_query (const char *ctlstr, const char defchar, va_list args)
   if (!confirm || server_command)
     return def_value;
 
+  old_chain = make_cleanup_restore_target_terminal ();
+
   /* If input isn't coming from the user directly, just say what
      question we're asking, and then answer the default automatically.  This
      way, important error messages don't get lost when talking to GDB
      over a pipe.  */
-  if (! input_from_terminal_p ())
+  if (current_ui->instream != current_ui->stdin_stream
+      || !input_interactive_p (current_ui))
     {
+      target_terminal_ours_for_output ();
       wrap_here ("");
       vfprintf_filtered (gdb_stdout, ctlstr, args);
 
@@ -1288,15 +1283,18 @@ defaulted_query (const char *ctlstr, const char defchar, va_list args)
                       y_string, n_string, def_answer);
       gdb_flush (gdb_stdout);
 
+      do_cleanups (old_chain);
       return def_value;
     }
 
   if (deprecated_query_hook)
     {
-      return deprecated_query_hook (ctlstr, args);
-    }
+      int res;
 
-  old_chain = make_cleanup (null_cleanup, NULL);
+      res = deprecated_query_hook (ctlstr, args);
+      do_cleanups (old_chain);
+      return res;
+    }
 
   /* Format the question outside of the loop, to avoid reusing args.  */
   question = xstrvprintf (ctlstr, args);
@@ -1310,6 +1308,10 @@ defaulted_query (const char *ctlstr, const char defchar, va_list args)
   /* Used for calculating time spend waiting for user.  */
   gettimeofday (&prompt_started, NULL);
 
+  /* We'll need to handle input.  */
+  target_terminal_ours ();
+  make_cleanup_override_quit_handler (default_quit_handler);
+
   while (1)
     {
       char *response, answer;
@@ -1881,7 +1883,9 @@ prompt_for_continue (void)
   reinitialize_more_filter ();
 
   /* We'll need to handle input.  */
+  make_cleanup_restore_target_terminal ();
   target_terminal_ours ();
+  make_cleanup_override_quit_handler (default_quit_handler);
 
   /* Call gdb_readline_wrapper, not readline, in order to keep an
      event loop running.  */
This page took 0.026069 seconds and 4 git commands to generate.