From: Hannes Domani <ssbssa@yahoo.de>
To: "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>,
Tom Tromey <tromey@adacore.com>
Subject: Re: [PATCH 3/3] Fix control-c handling on Windows
Date: Wed, 7 Dec 2022 17:13:42 +0000 (UTC) [thread overview]
Message-ID: <102195784.4047621.1670433222150@mail.yahoo.com> (raw)
In-Reply-To: <20221205185651.2704492-4-tromey@adacore.com>
Am Montag, 5. Dezember 2022, 19:57:36 MEZ hat Tom Tromey via Gdb-patches <gdb-patches@sourceware.org> Folgendes geschrieben:
> 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.
I've now tested this a bit, it's a big improvement.
Now it even works to interrupt a GUI program that was started with
'new-console off', that didn't work before.
But I did notice a few problems:
1)
When I first started a program with 'new-console on', then the
sigint_ours variable would not be initialized, and I would later get
a crash on C-c.
I've fixed it like this:
diff --git a/gdb/inflow.c b/gdb/inflow.c
index f9926122099..50c93b6e15a 100644
--- a/gdb/inflow.c
+++ b/gdb/inflow.c
@@ -165,7 +165,7 @@ static struct terminal_info *get_inflow_inferior_data (struct inferior *);
save our handlers in these two variables and set SIGINT and SIGQUIT
to SIG_IGN. */
-static sighandler_t sigint_ours;
+static sighandler_t sigint_ours = SIG_IGN;
#ifdef SIGQUIT
static sighandler_t sigquit_ours;
#endif
@@ -805,7 +805,8 @@ child_terminal_ours_1 (target_terminal_state desired_state)
}
}
- if (!job_control && desired_state == target_terminal_state::is_ours)
+ if (!job_control && desired_state == target_terminal_state::is_ours
+ && sigint_ours != SIG_IGN)
{
install_sigint_handler (sigint_ours);
#ifdef SIGQUIT
Not sure if there is a better solution.
2)
And for some reason one of my builds (x86_64+TUI+python) needed the
#include <signal.h> in mingw-hdep.c, but my other (i686 basic) didn't.
3)
But my basic i686 build had another problem when starting a program with
'new-console on', because at program start it called install_sigint_handler(),
but rl_set_signals() would later override the SIGINT handler again, so C-c
didn't work work in this situation.
With 'new-console off' this didn't happen, since install_sigint_handler() was
again called later since it shared the console.
That's all I've seen so far, thanks for this.
Hannes
next prev parent reply other threads:[~2022-12-07 17:13 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-05 18:56 [PATCH 0/3] Fix Windows C-c handling Tom Tromey
2022-12-05 18:56 ` [PATCH 1/3] Rename install_sigint_handler Tom Tromey
2022-12-05 18:56 ` [PATCH 2/3] Refactor code to check for terminal sharing Tom Tromey
2022-12-05 19:50 ` Eli Zaretskii
2022-12-12 17:27 ` Tom Tromey
2022-12-05 18:56 ` [PATCH 3/3] Fix control-c handling on Windows Tom Tromey
2022-12-07 17:13 ` Hannes Domani [this message]
2022-12-09 15:58 ` Tom Tromey
2022-12-09 16:19 ` Hannes Domani
2022-12-09 17:20 ` Tom Tromey
2022-12-09 18:13 ` Hannes Domani
2022-12-12 15:36 ` Tom Tromey
2022-12-12 17:05 ` Tom Tromey
2022-12-13 11:30 ` Hannes Domani
2022-12-13 19:51 ` Tom Tromey
2022-12-05 18:59 ` [PATCH 0/3] Fix Windows C-c handling Tom Tromey
2022-12-12 13:23 ` Jon Turney
2022-12-12 17:29 ` Tom Tromey
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=102195784.4047621.1670433222150@mail.yahoo.com \
--to=ssbssa@yahoo.de \
--cc=gdb-patches@sourceware.org \
--cc=tromey@adacore.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).