diff options
author | Tom Tromey <tromey@adacore.com> | 2022-12-05 10:56:23 -0700 |
---|---|---|
committer | Tom Tromey <tromey@adacore.com> | 2022-12-13 12:51:53 -0700 |
commit | c88afe9cf5d7fb0bd878acb930d79aafcf182505 (patch) | |
tree | aa074a83270492bc86695706e82b322d67ab34b8 /gdb/inferior.h | |
parent | c1dc47f53cccf633f3079db25a5b41adaee940a8 (diff) | |
download | gdb-c88afe9cf5d7fb0bd878acb930d79aafcf182505.zip gdb-c88afe9cf5d7fb0bd878acb930d79aafcf182505.tar.gz gdb-c88afe9cf5d7fb0bd878acb930d79aafcf182505.tar.bz2 |
Fix control-c handling on Windows
As Hannes pointed out, the Windows target-async patches broke C-c
handling there. Looking into this, I found a few oddities, fixed
here.
First, windows_nat_target::interrupt calls GenerateConsoleCtrlEvent.
I think this event can be ignored by the inferior, so it's not a great
way to interrupt. Instead, using DebugBreakProcess (or a more
complicated thing for Wow64) seems better.
Second, windows_nat_target did not implement the pass_ctrlc method.
Implementing this lets us remove the special code to call
SetConsoleCtrlHandler and instead integrate into gdb's approach to C-c
handling. I believe that this should also fix the race that's
described in the comment that's being removed.
Initially, I thought a simpler version of this patch would work.
However, I think what happens is that some other library (I'm not sure
what) calls SetConsoleCtrlHandler while gdb is running, and this
intercepts and handles C-c -- so that the gdb SIGINT handler is not
called. C-break continues to work, presumably because whatever
handler is installed ignores it.
This patch works around this issue by ensuring that the gdb handler
always comes first.
Diffstat (limited to 'gdb/inferior.h')
-rw-r--r-- | gdb/inferior.h | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/gdb/inferior.h b/gdb/inferior.h index 547e875..6fc0a30 100644 --- a/gdb/inferior.h +++ b/gdb/inferior.h @@ -178,6 +178,16 @@ extern tribool is_gdb_terminal (const char *tty); extern tribool sharing_input_terminal (int pid); +/* The type of the function that is called when SIGINT is handled. */ + +typedef void c_c_handler_ftype (int); + +/* Install a new SIGINT handler in a host-dependent way. The previous + handler is returned. It is fine to pass SIG_IGN for FN, but not + SIG_DFL. */ + +extern c_c_handler_ftype *install_sigint_handler (c_c_handler_ftype *fn); + extern void child_terminal_info (struct target_ops *self, const char *, int); extern void child_terminal_ours (struct target_ops *self); |