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/remote.c | |
parent | e42de8c7f8e7326d284f8b53f3bd6971fbf6e7b7 (diff) | |
download | binutils-gdb-93692b589dc7017d5a2fbdffdfad5f84f597d8f1.tar.gz |
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/remote.c')
-rw-r--r-- | gdb/remote.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/gdb/remote.c b/gdb/remote.c index 1bd2bcfe296..0b2d25fde37 100644 --- a/gdb/remote.c +++ b/gdb/remote.c @@ -5875,6 +5875,27 @@ remote_interrupt (struct target_ops *self, ptid_t ptid) remote_interrupt_as (); } +/* Implement the to_pass_ctrlc function for the remote targets. */ + +static void +remote_pass_ctrlc (struct target_ops *self) +{ + struct remote_state *rs = get_remote_state (); + + if (remote_debug) + fprintf_unfiltered (gdb_stdlog, "remote_pass_ctrlc called\n"); + + /* If we're starting up, we're not fully synced yet. Quit + immediately. */ + if (rs->starting_up) + quit (); + /* If ^C has already been sent once, offer to disconnect. */ + else if (rs->ctrlc_pending_p) + interrupt_query (); + else + target_interrupt (inferior_ptid); +} + /* Ask the user what to do when an interrupt is received. */ static void @@ -13056,6 +13077,7 @@ Specify the serial device it is connected to\n\ remote_ops.to_get_ada_task_ptid = remote_get_ada_task_ptid; remote_ops.to_stop = remote_stop; remote_ops.to_interrupt = remote_interrupt; + remote_ops.to_pass_ctrlc = remote_pass_ctrlc; remote_ops.to_check_pending_interrupt = remote_check_pending_interrupt; remote_ops.to_xfer_partial = remote_xfer_partial; remote_ops.to_rcmd = remote_rcmd; |