aboutsummaryrefslogtreecommitdiff
path: root/gdb/target.h
diff options
context:
space:
mode:
authorPedro Alves <palves@redhat.com>2016-04-12 16:49:31 +0100
committerPedro Alves <palves@redhat.com>2016-04-12 16:57:10 +0100
commit93692b589dc7017d5a2fbdffdfad5f84f597d8f1 (patch)
tree00da39a59755226ec1167996ac644f258a091b4f /gdb/target.h
parente42de8c7f8e7326d284f8b53f3bd6971fbf6e7b7 (diff)
downloadgdb-93692b589dc7017d5a2fbdffdfad5f84f597d8f1.zip
gdb-93692b589dc7017d5a2fbdffdfad5f84f597d8f1.tar.gz
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.h')
-rw-r--r--gdb/target.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/gdb/target.h b/gdb/target.h
index 26c8579..00625fe 100644
--- a/gdb/target.h
+++ b/gdb/target.h
@@ -645,6 +645,8 @@ struct target_ops
TARGET_DEFAULT_IGNORE ();
void (*to_interrupt) (struct target_ops *, ptid_t)
TARGET_DEFAULT_IGNORE ();
+ void (*to_pass_ctrlc) (struct target_ops *)
+ TARGET_DEFAULT_FUNC (default_target_pass_ctrlc);
void (*to_check_pending_interrupt) (struct target_ops *)
TARGET_DEFAULT_IGNORE ();
void (*to_rcmd) (struct target_ops *,
@@ -1716,6 +1718,17 @@ extern void target_stop (ptid_t ptid);
extern void target_interrupt (ptid_t ptid);
+/* Pass a ^C, as determined to have been pressed by checking the quit
+ flag, to the target. Normally calls target_interrupt, but remote
+ targets may take the opportunity to detect the remote side is not
+ responding and offer to disconnect. */
+
+extern void target_pass_ctrlc (void);
+
+/* The default target_ops::to_pass_ctrlc implementation. Simply calls
+ target_interrupt. */
+extern void default_target_pass_ctrlc (struct target_ops *ops);
+
/* Some targets install their own SIGINT handler while the target is
running. This method is called from the QUIT macro to give such
targets a chance to process a Ctrl-C. The target may e.g., choose