diff options
-rw-r--r-- | gdb/ChangeLog | 10 | ||||
-rw-r--r-- | gdb/extension.c | 51 | ||||
-rw-r--r-- | gdb/target.c | 8 | ||||
-rw-r--r-- | gdb/target.h | 4 |
4 files changed, 52 insertions, 21 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 73ba8cd..471d02b 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,13 @@ +2016-01-08 Yao Qi <yao.qi@linaro.org> + + * extension.c: Include target.h. + (set_active_ext_lang): Only call install_gdb_sigint_handler, + check_quit_flag, and set_quit_flag if target_terminal_is_ours + returns false. + (restore_active_ext_lang): Likewise. + * target.c (target_terminal_is_ours): New function. + * target.h (target_terminal_is_ours): Declare. + 2016-01-07 Maciej W. Rozycki <macro@imgtec.com> * mips-tdep.c (mips_breakpoint_from_pc): Rename local `status' diff --git a/gdb/extension.c b/gdb/extension.c index 5c23bcc..d2c5669 100644 --- a/gdb/extension.c +++ b/gdb/extension.c @@ -22,6 +22,7 @@ #include "defs.h" #include <signal.h> +#include "target.h" #include "auto-load.h" #include "breakpoint.h" #include "event-top.h" @@ -746,19 +747,24 @@ set_active_ext_lang (const struct extension_language_defn *now_active) = 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; } @@ -772,16 +778,19 @@ restore_active_ext_lang (struct active_ext_lang_state *previous) 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 (); - + if (target_terminal_is_ours ()) + { + /* 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); } diff --git a/gdb/target.c b/gdb/target.c index d331fe4..e88d60c 100644 --- a/gdb/target.c +++ b/gdb/target.c @@ -466,6 +466,14 @@ target_terminal_is_inferior (void) /* See target.h. */ +int +target_terminal_is_ours (void) +{ + return (terminal_state == terminal_is_ours); +} + +/* See target.h. */ + void target_terminal_inferior (void) { diff --git a/gdb/target.h b/gdb/target.h index dd2896f..e1419a9 100644 --- a/gdb/target.h +++ b/gdb/target.h @@ -1503,6 +1503,10 @@ extern int target_remove_breakpoint (struct gdbarch *gdbarch, extern int target_terminal_is_inferior (void); +/* Returns true if our terminal settings are in effect. */ + +extern int target_terminal_is_ours (void); + /* Initialize the terminal settings we record for the inferior, before we actually run the inferior. */ |