aboutsummaryrefslogtreecommitdiff
path: root/gdb/extension.c
diff options
context:
space:
mode:
authorTom Tromey <tromey@adacore.com>2022-12-05 10:56:23 -0700
committerTom Tromey <tromey@adacore.com>2022-12-13 12:51:53 -0700
commitc88afe9cf5d7fb0bd878acb930d79aafcf182505 (patch)
treeaa074a83270492bc86695706e82b322d67ab34b8 /gdb/extension.c
parentc1dc47f53cccf633f3079db25a5b41adaee940a8 (diff)
downloadbinutils-c88afe9cf5d7fb0bd878acb930d79aafcf182505.zip
binutils-c88afe9cf5d7fb0bd878acb930d79aafcf182505.tar.gz
binutils-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/extension.c')
-rw-r--r--gdb/extension.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/gdb/extension.c b/gdb/extension.c
index 1d951d6..ae8ef0d 100644
--- a/gdb/extension.c
+++ b/gdb/extension.c
@@ -33,6 +33,7 @@
#include "python/python.h"
#include "guile/guile.h"
#include <array>
+#include "inferior.h"
static script_sourcer_func source_gdb_script;
static objfile_script_sourcer_func source_gdb_objfile_script;
@@ -661,7 +662,7 @@ install_ext_sigint_handler (const struct signal_handler *handler_state)
{
gdb_assert (handler_state->handler_saved);
- signal (SIGINT, handler_state->handler);
+ install_sigint_handler (handler_state->handler);
}
/* Install GDB's SIGINT handler, storing the previous version in *PREVIOUS.
@@ -675,7 +676,7 @@ install_gdb_sigint_handler (struct signal_handler *previous)
/* Save here to simplify comparison. */
sighandler_t handle_sigint_for_compare = handle_sigint;
- previous->handler = signal (SIGINT, handle_sigint);
+ previous->handler = install_sigint_handler (handle_sigint);
if (previous->handler != handle_sigint_for_compare)
previous->handler_saved = 1;
else