/* Interface between gdb and its extension languages.
- Copyright (C) 2014-2015 Free Software Foundation, Inc.
+ Copyright (C) 2014-2016 Free Software Foundation, Inc.
This file is part of GDB.
#include "defs.h"
#include <signal.h>
+#include "target.h"
#include "auto-load.h"
#include "breakpoint.h"
#include "event-top.h"
int
apply_ext_lang_val_pretty_printer (struct type *type, const gdb_byte *valaddr,
- int embedded_offset, CORE_ADDR address,
+ LONGEST embedded_offset, CORE_ADDR address,
struct ui_file *stream, int recurse,
const struct value *val,
const struct value_print_options *options,
install_gdb_sigint_handler (struct signal_handler *previous)
{
/* Save here to simplify comparison. */
- RETSIGTYPE (*handle_sigint_for_compare) () = handle_sigint;
+ sighandler_t handle_sigint_for_compare = handle_sigint;
previous->handler = signal (SIGINT, handle_sigint);
if (previous->handler != handle_sigint_for_compare)
= XCNEW (struct active_ext_lang_state);
previous->ext_lang = active_ext_lang;
+ previous->sigint_handler.handler_saved = 0;
active_ext_lang = now_active;
- /* If the newly active extension language uses cooperative SIGINT handling
- then ensure GDB's SIGINT handler is installed. */
- if (now_active->language == EXT_LANG_GDB
- || now_active->ops->check_quit_flag != NULL)
- install_gdb_sigint_handler (&previous->sigint_handler);
-
- /* If there's a SIGINT recorded in the cooperative extension languages,
- move it to the new language, or save it in GDB's global flag if the newly
- active extension language doesn't use cooperative SIGINT handling. */
- if (check_quit_flag ())
- set_quit_flag ();
+ if (target_terminal_is_ours ())
+ {
+ /* If the newly active extension language uses cooperative SIGINT
+ handling then ensure GDB's SIGINT handler is installed. */
+ if (now_active->language == EXT_LANG_GDB
+ || now_active->ops->check_quit_flag != NULL)
+ install_gdb_sigint_handler (&previous->sigint_handler);
+
+ /* If there's a SIGINT recorded in the cooperative extension languages,
+ move it to the new language, or save it in GDB's global flag if the
+ newly active extension language doesn't use cooperative SIGINT
+ handling. */
+ if (check_quit_flag ())
+ set_quit_flag ();
+ }
return previous;
}
void
restore_active_ext_lang (struct active_ext_lang_state *previous)
{
- const struct extension_language_defn *current = active_ext_lang;
-
active_ext_lang = previous->ext_lang;
- /* Restore the previous SIGINT handler if one was saved. */
- if (previous->sigint_handler.handler_saved)
- install_sigint_handler (&previous->sigint_handler);
-
- /* If there's a SIGINT recorded in the cooperative extension languages,
- move it to the new language, or save it in GDB's global flag if the newly
- active extension language doesn't use cooperative SIGINT handling. */
- if (check_quit_flag ())
- set_quit_flag ();
-
- xfree (previous);
-}
-
-/* Clear the quit flag.
- The flag is cleared in all extension languages,
- not just the currently active one. */
-
-void
-clear_quit_flag (void)
-{
- int i;
- const struct extension_language_defn *extlang;
-
- ALL_ENABLED_EXTENSION_LANGUAGES (i, extlang)
+ if (target_terminal_is_ours ())
{
- if (extlang->ops->clear_quit_flag != NULL)
- extlang->ops->clear_quit_flag (extlang);
+ /* Restore the previous SIGINT handler if one was saved. */
+ if (previous->sigint_handler.handler_saved)
+ install_sigint_handler (&previous->sigint_handler);
+
+ /* If there's a SIGINT recorded in the cooperative extension languages,
+ move it to the new language, or save it in GDB's global flag if the
+ newly active extension language doesn't use cooperative SIGINT
+ handling. */
+ if (check_quit_flag ())
+ set_quit_flag ();
}
-
- quit_flag = 0;
+ xfree (previous);
}
/* Set the quit flag.
&& active_ext_lang->ops->set_quit_flag != NULL)
active_ext_lang->ops->set_quit_flag (active_ext_lang);
else
- quit_flag = 1;
+ {
+ quit_flag = 1;
+
+ /* Now wake up the event loop, or any interruptible_select. Do
+ this after setting the flag, because signals on Windows
+ actually run on a separate thread, and thus otherwise the
+ main code could be woken up and find quit_flag still
+ clear. */
+ quit_serial_event_set ();
+ }
}
/* Return true if the quit flag has been set, false otherwise.
/* This is written in a particular way to avoid races. */
if (quit_flag)
{
+ /* No longer need to wake up the event loop or any
+ interruptible_select. The caller handles the quit
+ request. */
+ quit_serial_event_clear ();
quit_flag = 0;
result = 1;
}