From: Christopher Faylor <cgf-use-the-mailinglist-please@sourceware.org>
To: gdb-patches@sourceware.org
Subject: Re: [RFC] control-c handling on Windows...
Date: Sun, 11 May 2008 05:30:00 -0000 [thread overview]
Message-ID: <20080510172224.GA24393@ednor.casa.cgf.cx> (raw)
In-Reply-To: <20080510153102.GE28890@adacore.com>
On Sat, May 10, 2008 at 08:31:02AM -0700, Joel Brobecker wrote:
>Hi Chris,
>
>> I think the way this is handled in linux is by resetting the controlling
>> process group of the terminal to the pid of the inferior. On thinking
>> about this more, I think it probably makes more sense to bracket the
>> call with:
>>
>> SetConsoleCtrlHandler (NULL, TRUE);
>> retval = get_win32_debug_event (pid, ourstatus);
>> SetConsoleCtrlHandler (NULL, FALSE);
>>
>> That's almost equivalent to what linux does with process groups I think.
>>
>> Does the above work in your scenario, Joel? If so, I think this is
>> safe to check in.
>
>I think it does work. All my experiments at resuming the inferior after
>having interrupted it with C-c have been succesful.
>
>The only problem is that once in a while GDB still receives the SIGINT.
>This time, it doesn't cause the debugger to QUIT during the resume after
>handling the new-thread event like it used to, so we properly report the
>SIGINT event to the user:
>
> (gdb) cont
> Continuing.
> I = 10
> I = 11
> I = 12
> [New thread 2348.0x1550] <<<--- pressed C-c
>
> Program received signal SIGINT, Interrupt.
> [Switching to thread 2348.0x1550]
> 0x7c87534d in KERNEL32!GetConsoleCharType (Quit (expect signal SIGINT when the program is resumed)
>
>However, because the SIGINT handler was called, we still get the unexpected
>"Quit (expect signal SIGINT when the program is resumed" message in
>the middle of printing the current frame. As I said earlier, it doesn't
>prevent the next resume to work properly. It's a little misleading but
>I think this is already a good improvement, so I suggest we go with your
>suggestion.
I think there is obviously a race here. Possibly just calling
SetConsoleCtrlHandler (NULL, TRUE) before calling CreateProcess is all
that's required to handle it but looking at inflow.c it seems like
the process group handling that gdb is expecting is more complicated
than a turn-it-all-off or turn-it-all-on.
I assume that you're using a mingw version of cygwin so I don't know the
setting for the job_control variable. If it is off, it seems like it
should be doing the right thing already. If it's on then I could see
that as being a problem.
Or, maybe it would make sense to use job_control as it was intended. We
could kludge up a tcsetpgrp for windows which messed with CTRL-C
handling for gdb based on whether it was being called with the gdb
process group or the inferior process group. This is under the
assumption that the race you're seeing is already being handled by gdb
but is being bypassed because the windows platform doesn't have enough
capabilities to do the right thing.
cgf
next prev parent reply other threads:[~2008-05-10 17:22 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-05-08 9:46 Joel Brobecker
2008-05-10 4:34 ` Christopher Faylor
2008-05-10 13:10 ` Joel Brobecker
2008-05-10 15:31 ` Christopher Faylor
2008-05-10 22:28 ` Joel Brobecker
2008-05-11 5:30 ` Christopher Faylor [this message]
2008-05-11 13:31 ` Joel Brobecker
2008-05-11 13:46 ` Eli Zaretskii
2008-05-11 13:58 ` Christopher Faylor
2008-05-11 21:26 ` Joel Brobecker
2008-05-17 11:38 ` Christopher Faylor
2008-05-21 0:34 ` Joel Brobecker
2008-05-21 3:19 ` Christopher Faylor
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=20080510172224.GA24393@ednor.casa.cgf.cx \
--to=cgf-use-the-mailinglist-please@sourceware.org \
--cc=gdb-patches@sourceware.org \
/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