along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include "defs.h"
-#include "dyn-string.h"
#include <ctype.h>
#include "gdb_wait.h"
#include "event-top.h"
return make_cleanup (do_freeargv, arg);
}
-static void
-do_dyn_string_delete (void *arg)
-{
- dyn_string_delete ((dyn_string_t) arg);
-}
-
-struct cleanup *
-make_cleanup_dyn_string_delete (dyn_string_t arg)
-{
- return make_cleanup (do_dyn_string_delete, arg);
-}
-
static void
do_bfd_close_cleanup (void *arg)
{
return make_cleanup (do_htab_delete_cleanup, htab);
}
-struct restore_ui_out_closure
-{
- struct ui_out **variable;
- struct ui_out *value;
-};
-
-static void
-do_restore_ui_out (void *p)
-{
- struct restore_ui_out_closure *closure
- = (struct restore_ui_out_closure *) p;
-
- *(closure->variable) = closure->value;
-}
-
-/* Remember the current value of *VARIABLE and make it restored when
- the cleanup is run. */
-
-struct cleanup *
-make_cleanup_restore_ui_out (struct ui_out **variable)
-{
- struct restore_ui_out_closure *c = XNEW (struct restore_ui_out_closure);
-
- c->variable = variable;
- c->value = *variable;
-
- return make_cleanup_dtor (do_restore_ui_out, (void *) c, xfree);
-}
-
-struct restore_ui_file_closure
-{
- struct ui_file **variable;
- struct ui_file *value;
-};
-
-static void
-do_restore_ui_file (void *p)
-{
- struct restore_ui_file_closure *closure
- = (struct restore_ui_file_closure *) p;
-
- *(closure->variable) = closure->value;
-}
-
-/* Remember the current value of *VARIABLE and make it restored when
- the cleanup is run. */
-
-struct cleanup *
-make_cleanup_restore_ui_file (struct ui_file **variable)
-{
- struct restore_ui_file_closure *c = XNEW (struct restore_ui_file_closure);
-
- c->variable = variable;
- c->value = *variable;
-
- return make_cleanup_dtor (do_restore_ui_file, (void *) c, xfree);
-}
-
/* Helper for make_cleanup_value_free_to_mark. */
static void
return make_regfree_cleanup (pattern);
}
+/* A cleanup that simply calls ui_unregister_input_event_handler. */
+
+static void
+ui_unregister_input_event_handler_cleanup (void *ui)
+{
+ ui_unregister_input_event_handler ((struct ui *) ui);
+}
+
+/* Set up to handle input. */
+
+static struct cleanup *
+prepare_to_handle_input (void)
+{
+ struct cleanup *old_chain;
+
+ old_chain = make_cleanup_restore_target_terminal ();
+ target_terminal_ours ();
+
+ ui_register_input_event_handler (current_ui);
+ if (current_ui->prompt_state == PROMPT_BLOCKED)
+ make_cleanup (ui_unregister_input_event_handler_cleanup, current_ui);
+
+ make_cleanup_override_quit_handler (default_quit_handler);
+
+ return old_chain;
+}
+
\f
/* This function supports the query, nquery, and yquery functions.
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
if (current_ui->instream != current_ui->stdin_stream
|| !input_interactive_p (current_ui))
{
+ old_chain = make_cleanup_restore_target_terminal ();
+
target_terminal_ours_for_output ();
wrap_here ("");
vfprintf_filtered (gdb_stdout, ctlstr, args);
{
int res;
+ old_chain = make_cleanup_restore_target_terminal ();
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);
- make_cleanup (xfree, question);
+ old_chain = make_cleanup (xfree, question);
prompt = xstrprintf (_("%s%s(%s or %s) %s"),
annotation_level > 1 ? "\n\032\032pre-query\n" : "",
question, y_string, n_string,
/* 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);
+ prepare_to_handle_input ();
while (1)
{
beyond the end of the screen. */
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);
+ prepare_to_handle_input ();
/* Call gdb_readline_wrapper, not readline, in order to keep an
event loop running. */
if (minor == NULL)
minor = &min;
- /* Skip any identifier after "GNU " - such as "C11" "C++" or "Java".
+ /* Skip any identifier after "GNU " - such as "C11" or "C++".
A full producer string might look like:
"GNU C 4.7.2"
"GNU Fortran 4.8.2 20140120 (Red Hat 4.8.2-16) -mtune=generic ..."