This is the mail archive of the gdb@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: sending CTRL-C to Cygwin gdb 6.8 has no effect



> -----Message d'origine-----
> De?: gdb-owner@sourceware.org [mailto:gdb-owner@sourceware.org] De la
> part de Christopher Faylor
> Envoyé?: Monday, April 26, 2010 8:22 AM
> À?: Joel Brobecker; gdb@sourceware.org; Pedro Alves; John Cortell; Dave
> Korn
> Objet?: Re: sending CTRL-C to Cygwin gdb 6.8 has no effect
> 
> 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 <windows.h>

int
main (int argc, char **argv)
{
  int i;
  HANDLE std_in_handle = CreateFile ("CONIN$", GENERIC_READ | GENERIC_WRITE,
                              FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, 0);

  if (std_in_handle != 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 = console_mode | ENABLE_PROCESSED_INPUT;
      else
        console_mode = 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 = 1; i <= 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 
enable ENABLE_PROCESSED_INPUT, and Ctrl-C will be able to 
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).
  
  I will submit a patch to gdb-patches 
that will change the entry console mode to
include also ENABLE_PROCESSED_INPUT.


Pierre Muller
Pascal language support maintainer for GDB





Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]