From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12770 invoked by alias); 26 Apr 2010 11:38:37 -0000 Received: (qmail 12758 invoked by uid 22791); 26 Apr 2010 11:38:36 -0000 X-SWARE-Spam-Status: No, hits=-1.9 required=5.0 tests=BAYES_00,MSGID_MULTIPLE_AT X-Spam-Check-By: sourceware.org Received: from mailhost.u-strasbg.fr (HELO mailhost.u-strasbg.fr) (130.79.200.156) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 26 Apr 2010 11:38:31 +0000 Received: from baal.u-strasbg.fr (baal.u-strasbg.fr [IPv6:2001:660:2402::41]) by mailhost.u-strasbg.fr (8.14.3/jtpda-5.5pre1) with ESMTP id o3QBbt1i052975 ; Mon, 26 Apr 2010 13:37:55 +0200 (CEST) (envelope-from pierre.muller@ics-cnrs.unistra.fr) Received: from mailserver.u-strasbg.fr (ms3.u-strasbg.fr [IPv6:2001:660:2402:d::12]) by baal.u-strasbg.fr (8.14.0/jtpda-5.5pre1) with ESMTP id o3QBbsVL048246 ; Mon, 26 Apr 2010 13:37:54 +0200 (CEST) (envelope-from pierre.muller@ics-cnrs.unistra.fr) Received: from d620muller (gw-ics.u-strasbg.fr [130.79.210.225]) (user=mullerp mech=LOGIN) by mailserver.u-strasbg.fr (8.14.3/jtpda-5.5pre1) with ESMTP id o3QBbrTp055107 (version=TLSv1/SSLv3 cipher=RC4-MD5 bits=128 verify=NO) ; Mon, 26 Apr 2010 13:37:53 +0200 (CEST) (envelope-from pierre.muller@ics-cnrs.unistra.fr) From: "Pierre Muller" To: "'Christopher Faylor'" , "'Joel Brobecker'" , , "'Pedro Alves'" , "'John Cortell'" , "'Dave Korn'" References: <201004231941.o3NJfbWR021914@az33smr01.freescale.net> <4BD389B3.2030409@gmail.com> <201004251418.o3PEIBMG000580@az33smr01.freescale.net> <201004252225.08587.pedro@codesourcery.com> <20100426062203.GA31312@ednor.casa.cgf.cx> In-Reply-To: <20100426062203.GA31312@ednor.casa.cgf.cx> Subject: RE: sending CTRL-C to Cygwin gdb 6.8 has no effect Date: Mon, 26 Apr 2010 11:38:00 -0000 Message-ID: <005101cae534$ed96bee0$c8c43ca0$@muller@ics-cnrs.unistra.fr> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org X-SW-Source: 2010-04/txt/msg00140.txt.bz2 > -----Message d'origine----- > De=A0: gdb-owner@sourceware.org [mailto:gdb-owner@sourceware.org] De la > part de Christopher Faylor > Envoy=E9=A0: Monday, April 26, 2010 8:22 AM > =C0=A0: Joel Brobecker; gdb@sourceware.org; Pedro Alves; John Cortell; Da= ve > Korn > Objet=A0: Re: sending CTRL-C to Cygwin gdb 6.8 has no effect >=20 > Aren't we just circling around a simple problem here? The latest > version of gdb has accommodations for CTRL-C, added by Joel. The > current version, shipping with Cygwin does not. No I think that there is a different issue here: The configuration of the Console when starting GDB. If the windows console is configured with ENABLE_PROCESSED_INPUT via a call to SetConsoleMode, then '^C' (ascii 3) is handled as an event, reported to the debugger or passed to the program ConsoleCtrlHandler if the function called SetConsoleCtrlHandler with the appropriate arguments. The problem is that the state of the console is not fixed when we start GDB. If ENABLE_PROCESSED_INPUT is not used '^C' will be handled as a normal character. See for instance this small program: start of program test.c >>>>>>>>>>>>>>>>>>>>>> #include int main (int argc, char **argv) { int i; HANDLE std_in_handle =3D CreateFile ("CONIN$", GENERIC_READ | GENERIC_WRI= TE, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, 0); if (std_in_handle !=3D INVALID_HANDLE_VALUE) { DWORD console_mode; (GetConsoleMode (std_in_handle, &console_mode)); printf ("Console mode is 0x%x\n", console_mode); printf ("Console mode has ENABLE_PROCESSED_INPUT 0x%x\n", console_mode & ENABLE_PROCESSED_INPUT); if (argc > 1) console_mode =3D console_mode | ENABLE_PROCESSED_INPUT; else console_mode =3D console_mode & ~ ENABLE_PROCESSED_INPUT; printf ("New console mode is 0x%x\n", console_mode); (SetConsoleMode (std_in_handle, console_mode)); (GetConsoleMode (std_in_handle, &console_mode)); printf ("Console mode is 0x%x\n", console_mode); } /* This long loop allows to try to interrupt the program either by hitting Ctrl-C or Ctrl-Break. */ for (i =3D 1; i <=3D 600; i++) Sleep (1000); } >>>>>>>>>>>>>>>>>>>>>> end of program test.c gcc -mno-cygwin -g -o test.exe test.c If you try to run test.exe of an ordinary Windows Console (not under Cygwin). Using it without argument, you will disable ENABLE_PROCESSED_INPUT thus Ctrl-C will not work for interruption. CtrlBreak always works. If you use the program with any argument, you will=20 enable ENABLE_PROCESSED_INPUT, and Ctrl-C will be able to=20 interrupt the program. Notice also that (at least on my Command prompt) the initial value of the console mode is always 0x1f. The last run of the program does not change the value of the console after it finished. Inside Cygwin console, I get a different behavior: 'Ctrl-C' is always able to interrupt the program, but this seems to be Cygwin specific (MSys console does not act the same way). =20=20 I will submit a patch to gdb-patches=20 that will change the entry console mode to include also ENABLE_PROCESSED_INPUT. Pierre Muller Pascal language support maintainer for GDB