diff options
author | Pedro Alves <palves@redhat.com> | 2016-04-12 16:49:31 +0100 |
---|---|---|
committer | Pedro Alves <palves@redhat.com> | 2016-04-12 16:57:10 +0100 |
commit | 93692b589dc7017d5a2fbdffdfad5f84f597d8f1 (patch) | |
tree | 00da39a59755226ec1167996ac644f258a091b4f /gdb/target-delegates.c | |
parent | e42de8c7f8e7326d284f8b53f3bd6971fbf6e7b7 (diff) | |
download | fsf-binutils-gdb-93692b589dc7017d5a2fbdffdfad5f84f597d8f1.zip fsf-binutils-gdb-93692b589dc7017d5a2fbdffdfad5f84f597d8f1.tar.gz fsf-binutils-gdb-93692b589dc7017d5a2fbdffdfad5f84f597d8f1.tar.bz2 |
Pass Ctrl-C to the target in target_terminal_inferior
If the user presses Ctrl-C immediately before target_terminal_inferior
is called and the target is resumed, instead of after, the Ctrl-C ends
up pending in the quit flag until the target next stops.
remote.c has this bit to handle this:
if (!target_is_async_p ())
{
ofunc = signal (SIGINT, sync_remote_interrupt);
/* If the user hit C-c before this packet, or between packets,
pretend that it was hit right here. */
if (check_quit_flag ())
sync_remote_interrupt (SIGINT);
}
But that's only reachable if async is off, while async is on by
default nowadays. It's also obviously not reacheable on native
targets.
This patch generalizes that to all targets.
We can't remove that remote.c bit yet, until we get rid of the sync
SIGINT handler though. That'll be done later in the series.
gdb/ChangeLog:
2016-04-12 Pedro Alves <palves@redhat.com>
* remote.c (remote_pass_ctrlc): New function.
(init_remote_ops): Install it.
* target.c (target_terminal_inferior): Pass pending Ctrl-C to the
target.
(target_pass_ctrlc, default_target_pass_ctrlc): New functions.
* target.h (struct target_ops) <to_pass_ctrlc>: New method.
(target_pass_ctrlc, default_target_pass_ctrlc): New declarations.
* target-delegates.c: Regenerate.
Diffstat (limited to 'gdb/target-delegates.c')
-rw-r--r-- | gdb/target-delegates.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/gdb/target-delegates.c b/gdb/target-delegates.c index d23bc75..640803a 100644 --- a/gdb/target-delegates.c +++ b/gdb/target-delegates.c @@ -1608,6 +1608,23 @@ debug_interrupt (struct target_ops *self, ptid_t arg1) } static void +delegate_pass_ctrlc (struct target_ops *self) +{ + self = self->beneath; + self->to_pass_ctrlc (self); +} + +static void +debug_pass_ctrlc (struct target_ops *self) +{ + fprintf_unfiltered (gdb_stdlog, "-> %s->to_pass_ctrlc (...)\n", debug_target.to_shortname); + debug_target.to_pass_ctrlc (&debug_target); + fprintf_unfiltered (gdb_stdlog, "<- %s->to_pass_ctrlc (", debug_target.to_shortname); + target_debug_print_struct_target_ops_p (&debug_target); + fputs_unfiltered (")\n", gdb_stdlog); +} + +static void delegate_check_pending_interrupt (struct target_ops *self) { self = self->beneath; @@ -4194,6 +4211,8 @@ install_delegators (struct target_ops *ops) ops->to_stop = delegate_stop; if (ops->to_interrupt == NULL) ops->to_interrupt = delegate_interrupt; + if (ops->to_pass_ctrlc == NULL) + ops->to_pass_ctrlc = delegate_pass_ctrlc; if (ops->to_check_pending_interrupt == NULL) ops->to_check_pending_interrupt = delegate_check_pending_interrupt; if (ops->to_rcmd == NULL) @@ -4442,6 +4461,7 @@ install_dummy_methods (struct target_ops *ops) ops->to_thread_name = tdefault_thread_name; ops->to_stop = tdefault_stop; ops->to_interrupt = tdefault_interrupt; + ops->to_pass_ctrlc = default_target_pass_ctrlc; ops->to_check_pending_interrupt = tdefault_check_pending_interrupt; ops->to_rcmd = default_rcmd; ops->to_pid_to_exec_file = tdefault_pid_to_exec_file; @@ -4598,6 +4618,7 @@ init_debug_target (struct target_ops *ops) ops->to_thread_name = debug_thread_name; ops->to_stop = debug_stop; ops->to_interrupt = debug_interrupt; + ops->to_pass_ctrlc = debug_pass_ctrlc; ops->to_check_pending_interrupt = debug_check_pending_interrupt; ops->to_rcmd = debug_rcmd; ops->to_pid_to_exec_file = debug_pid_to_exec_file; |