From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26591 invoked by alias); 20 May 2008 18:38:44 -0000 Received: (qmail 26582 invoked by uid 22791); 20 May 2008 18:38:42 -0000 X-Spam-Check-By: sourceware.org Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.31) with ESMTP; Tue, 20 May 2008 18:38:24 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 0AC282A9955 for ; Tue, 20 May 2008 14:38:23 -0400 (EDT) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id yxP7DbUB0CFQ for ; Tue, 20 May 2008 14:38:22 -0400 (EDT) Received: from joel.gnat.com (localhost.localdomain [127.0.0.1]) by rock.gnat.com (Postfix) with ESMTP id B1BE32A96BF for ; Tue, 20 May 2008 14:38:22 -0400 (EDT) Received: by joel.gnat.com (Postfix, from userid 1000) id 78755E7ACD; Tue, 20 May 2008 11:38:20 -0700 (PDT) Date: Wed, 21 May 2008 00:34:00 -0000 From: Joel Brobecker To: gdb-patches@sourceware.org Subject: Re: [RFC] control-c handling on Windows... Message-ID: <20080520183820.GB3895@adacore.com> References: <20080507205611.GB7421@adacore.com> <20080509202942.GA4386@ednor.casa.cgf.cx> <20080510013336.GC28890@adacore.com> <20080510043413.GA5429@ednor.casa.cgf.cx> <20080510153102.GE28890@adacore.com> <20080510180010.GF28890@adacore.com> <20080510194232.GC17229@ednor.casa.cgf.cx> <20080511164043.GJ28890@adacore.com> <20080516193438.GA4413@ednor.casa.cgf.cx> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="BXVAT5kNtrzKuDFl" Content-Disposition: inline In-Reply-To: <20080516193438.GA4413@ednor.casa.cgf.cx> User-Agent: Mutt/1.4.2.2i Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2008-05/txt/msg00610.txt.bz2 --BXVAT5kNtrzKuDFl Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-length: 450 Hi Chris, > Checking this in is ok with me but it would be nice to consider a better > solution eventually. Could you put a note to that effect in the patch Attached is the patch that I ended up checking in. Let me know if you'd like me to make some adjustments to the comment... 2008-05-20 Joel Brobecker * win32-nat.c (win32_wait): Block the control-c event while waiting for a debug event. -- Joel --BXVAT5kNtrzKuDFl Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="win32-nat.c.diff" Content-length: 1598 Index: win32-nat.c =================================================================== RCS file: /cvs/src/src/gdb/win32-nat.c,v retrieving revision 1.151 diff -u -p -r1.151 win32-nat.c --- win32-nat.c 11 Mar 2008 05:21:38 -0000 1.151 +++ win32-nat.c 20 May 2008 18:33:29 -0000 @@ -1458,7 +1458,25 @@ win32_wait (ptid_t ptid, struct target_w while (1) { - int retval = get_win32_debug_event (pid, ourstatus); + int retval; + + /* Ignore CTRL+C signals while waiting for a debug event. + FIXME: brobecker/2008-05-20: When the user presses CTRL+C while + the inferior is running, both the inferior and GDB receive the + associated signal. If the inferior receives the signal first + and the delay until GDB receives that signal is sufficiently long, + GDB can sometimes receive the SIGINT after we have unblocked + the CTRL+C handler. This would lead to the debugger to stop + prematurely while handling the new-thread event that comes + with the handling of the SIGINT inside the inferior, and then + stop again immediately when the user tries to resume the execution + in the inferior. This is a classic race, and it would be nice + to find a better solution to that problem. But in the meantime, + the current approach already greatly mitigate this issue. */ + SetConsoleCtrlHandler (NULL, TRUE); + retval = get_win32_debug_event (pid, ourstatus); + SetConsoleCtrlHandler (NULL, FALSE); + if (retval) return pid_to_ptid (retval); else --BXVAT5kNtrzKuDFl--