* [RFA] windows-nat.c: Enable processed input at startup
@ 2010-04-26 11:41 Pierre Muller
2010-04-26 14:32 ` Christopher Faylor
0 siblings, 1 reply; 6+ messages in thread
From: Pierre Muller @ 2010-04-26 11:41 UTC (permalink / raw)
To: gdb-patches
This is the patch I was talking about in
a reply to this thread:
http://sourceware.org/ml/gdb/2010-04/msg00113.html
It ensures that at startup, if GDB can connect to the console
the console mode is modified to enable processed input.
This make '^C' (ascii #3) to be interpreted as a
control event.
Pierre Muller
Pascal language support maintainer for GDB
2010-04-26 Pierre Muller <muller@ics.u-strasbg.fr>
* windows-nat.c (_initialize_windows_nat): Try to set
ENABLE_PROCESSED_INPUT for console mode if accessible.
Index: windows-nat.c
===================================================================
RCS file: /cvs/src/src/gdb/windows-nat.c,v
retrieving revision 1.208
diff -u -p -r1.208 windows-nat.c
--- windows-nat.c 16 Apr 2010 07:49:35 -0000 1.208
+++ windows-nat.c 26 Apr 2010 11:33:08 -0000
@@ -2356,6 +2356,22 @@ void
_initialize_windows_nat (void)
{
struct cmd_list_element *c;
+ HANDLE std_in_handle;
+
+ /* Try to enable processed input for the console.
+ This should allow to use '^C' to interrupt the debuggee
+ at least as log as the debugge does not modify the
+ console mode settings. */
+ 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;
+ CHECK (GetConsoleMode (std_in_handle, &console_mode));
+ console_mode = console_mode | ENABLE_PROCESSED_INPUT;
+ CHECK (SetConsoleMode (std_in_handle, console_mode));
+ }
init_windows_ops ();
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [RFA] windows-nat.c: Enable processed input at startup
2010-04-26 11:41 [RFA] windows-nat.c: Enable processed input at startup Pierre Muller
@ 2010-04-26 14:32 ` Christopher Faylor
2010-04-26 15:07 ` Pierre Muller
0 siblings, 1 reply; 6+ messages in thread
From: Christopher Faylor @ 2010-04-26 14:32 UTC (permalink / raw)
To: gdb-patches, Pierre Muller
On Mon, Apr 26, 2010 at 01:41:16PM +0200, Pierre Muller wrote:
> This is the patch I was talking about in
>a reply to this thread:
>http://sourceware.org/ml/gdb/2010-04/msg00113.html
>
> It ensures that at startup, if GDB can connect to the console
>the console mode is modified to enable processed input.
> This make '^C' (ascii #3) to be interpreted as a
>control event.
>
>
>
>
>Pierre Muller
>Pascal language support maintainer for GDB
>
>
>2010-04-26 Pierre Muller <muller@ics.u-strasbg.fr>
>
> * windows-nat.c (_initialize_windows_nat): Try to set
> ENABLE_PROCESSED_INPUT for console mode if accessible.
>
>Index: windows-nat.c
>===================================================================
>RCS file: /cvs/src/src/gdb/windows-nat.c,v
>retrieving revision 1.208
>diff -u -p -r1.208 windows-nat.c
>--- windows-nat.c 16 Apr 2010 07:49:35 -0000 1.208
>+++ windows-nat.c 26 Apr 2010 11:33:08 -0000
>@@ -2356,6 +2356,22 @@ void
> _initialize_windows_nat (void)
> {
> struct cmd_list_element *c;
>+ HANDLE std_in_handle;
>+
>+ /* Try to enable processed input for the console.
>+ This should allow to use '^C' to interrupt the debuggee
>+ at least as log as the debugge does not modify the
>+ console mode settings. */
>+ 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;
>+ CHECK (GetConsoleMode (std_in_handle, &console_mode));
>+ console_mode = console_mode | ENABLE_PROCESSED_INPUT;
>+ CHECK (SetConsoleMode (std_in_handle, console_mode));
>+ }
>
> init_windows_ops ();
That has to be conditional on __CYGWIN__ since you'll be screwing up Cygwin's
notion of the console state.
And, the name std_in_handle is a misnomer. It should be console_handle
or something like that.
Can't you just set what you need and close the handle? I thought this
setting was global.
cgf
^ permalink raw reply [flat|nested] 6+ messages in thread* RE: [RFA] windows-nat.c: Enable processed input at startup
2010-04-26 14:32 ` Christopher Faylor
@ 2010-04-26 15:07 ` Pierre Muller
2010-04-26 15:20 ` Christopher Faylor
0 siblings, 1 reply; 6+ messages in thread
From: Pierre Muller @ 2010-04-26 15:07 UTC (permalink / raw)
To: gdb-patches
> >+ 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;
> >+ CHECK (GetConsoleMode (std_in_handle, &console_mode));
> >+ console_mode = console_mode | ENABLE_PROCESSED_INPUT;
> >+ CHECK (SetConsoleMode (std_in_handle, console_mode));
> >+ }
> >
> > init_windows_ops ();
>
> That has to be conditional on __CYGWIN__ since you'll be screwing up
> Cygwin's
> notion of the console state.
Is there a Cygwin way to do the same?
> And, the name std_in_handle is a misnomer. It should be console_handle
> or something like that.
Renamed to conin_handle.
> Can't you just set what you need and close the handle? I thought this
> setting was global.
Of course I should close the handle as soon as I changed the
console mode.
What about this version?
Pierre
2010-04-26 Pierre Muller <muller@ics.u-strasbg.fr>
* windows-nat.c (_initialize_windows_nat): Try to set
ENABLE_PROCESSED_INPUT for console mode if accessible.
Index: windows-nat.c
===================================================================
RCS file: /cvs/src/src/gdb/windows-nat.c,v
retrieving revision 1.208
diff -u -p -r1.208 windows-nat.c
--- windows-nat.c 16 Apr 2010 07:49:35 -0000 1.208
+++ windows-nat.c 26 Apr 2010 15:03:52 -0000
@@ -2357,6 +2357,27 @@ _initialize_windows_nat (void)
{
struct cmd_list_element *c;
+#ifndef __CYGWIN__
+
+ HANDLE conin_handle;
+
+ /* Try to enable processed input for the console.
+ This should allow to use '^C' to interrupt the debuggee
+ at least as log as the debugge does not modify the
+ console mode settings. */
+ conin_handle = CreateFile ("CONIN$", GENERIC_READ | GENERIC_WRITE,
+ FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, 0);
+
+ if (conin_handle != INVALID_HANDLE_VALUE)
+ {
+ DWORD console_mode;
+ CHECK (GetConsoleMode (conin_handle, &console_mode));
+ console_mode = console_mode | ENABLE_PROCESSED_INPUT;
+ CHECK (SetConsoleMode (conin_handle, console_mode));
+ CHECK (CloseHandle (conin_handle));
+ }
+#endif
+
init_windows_ops ();
#ifdef __CYGWIN__
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [RFA] windows-nat.c: Enable processed input at startup
2010-04-26 15:07 ` Pierre Muller
@ 2010-04-26 15:20 ` Christopher Faylor
2010-04-26 15:47 ` Pierre Muller
0 siblings, 1 reply; 6+ messages in thread
From: Christopher Faylor @ 2010-04-26 15:20 UTC (permalink / raw)
To: gdb-patches, Pierre Muller
On Mon, Apr 26, 2010 at 05:07:40PM +0200, Pierre Muller wrote:
>
>> >+ 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;
>> >+ CHECK (GetConsoleMode (std_in_handle, &console_mode));
>> >+ console_mode = console_mode | ENABLE_PROCESSED_INPUT;
>> >+ CHECK (SetConsoleMode (std_in_handle, console_mode));
>> >+ }
>> >
>> > init_windows_ops ();
>>
>> That has to be conditional on __CYGWIN__ since you'll be screwing up
>> Cygwin's
>> notion of the console state.
>
> Is there a Cygwin way to do the same?
>
>> And, the name std_in_handle is a misnomer. It should be console_handle
>> or something like that.
> Renamed to conin_handle.
>> Can't you just set what you need and close the handle? I thought this
>> setting was global.
> Of course I should close the handle as soon as I changed the
>console mode.
> What about this version?
>
>Pierre
>
>2010-04-26 Pierre Muller <muller@ics.u-strasbg.fr>
>
> * windows-nat.c (_initialize_windows_nat): Try to set
> ENABLE_PROCESSED_INPUT for console mode if accessible.
Ok with the minor comment changes below.
I don't understand why this would be necessary for Cygwin but, if it is,
then tcsetattr should be used.
cgf
^ permalink raw reply [flat|nested] 6+ messages in thread* RE: [RFA] windows-nat.c: Enable processed input at startup
2010-04-26 15:20 ` Christopher Faylor
@ 2010-04-26 15:47 ` Pierre Muller
2010-04-26 18:24 ` Christopher Faylor
0 siblings, 1 reply; 6+ messages in thread
From: Pierre Muller @ 2010-04-26 15:47 UTC (permalink / raw)
To: gdb-patches
> >> setting was global.
> > Of course I should close the handle as soon as I changed the
> >console mode.
> > What about this version?
> >
> >Pierre
> >
> >2010-04-26 Pierre Muller <muller@ics.u-strasbg.fr>
> >
> > * windows-nat.c (_initialize_windows_nat): Try to set
> > ENABLE_PROCESSED_INPUT for console mode if accessible.
>
> Ok with the minor comment changes below.
Did you mean something to change to the comments
inside the patch?
> I don't understand why this would be necessary for Cygwin but,
Did you try the example code I sent to gdb mailing list?
This executable does change the Console Mode of a Cygwin tty
and that change is kept after the program exits.
This is not the case for a usual Windows command prompt.
If you compile my program and run it.
./test
New console mode is 0x18
(interrupting this works for both Ctrl-C and Ctrl-Break)
but if you now run
gdb gdb
....
(gdb) set prompt top>
top> run
...
Try to hit Ctrl-C now, nothing happens
(exit using q)
Run again my test program with an argument:
./test 1
New console mode is 0x19
Do the same...
This time Ctrl-C works.
> if it is,
> then tcsetattr should be used.
From winsup/cygwin/fhanlde_console.cc
I suppose that I should use
tcsetattr (tcgetattr (h) | ISIG, h);
But what should the variable 'h' be
be initialized?
Pierre
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [RFA] windows-nat.c: Enable processed input at startup
2010-04-26 15:47 ` Pierre Muller
@ 2010-04-26 18:24 ` Christopher Faylor
0 siblings, 0 replies; 6+ messages in thread
From: Christopher Faylor @ 2010-04-26 18:24 UTC (permalink / raw)
To: gdb-patches, Pierre Muller
On Mon, Apr 26, 2010 at 05:47:45PM +0200, Pierre Muller wrote:
>> >> setting was global.
>> > Of course I should close the handle as soon as I changed the
>> >console mode.
>> > What about this version?
>> >
>> >Pierre
>> >
>> >2010-04-26 Pierre Muller <muller@ics.u-strasbg.fr>
>> >
>> > * windows-nat.c (_initialize_windows_nat): Try to set
>> > ENABLE_PROCESSED_INPUT for console mode if accessible.
>>
>> Ok with the minor comment changes below.
> Did you mean something to change to the comments
>inside the patch?
>
>> I don't understand why this would be necessary for Cygwin but,
>
> Did you try the example code I sent to gdb mailing list?
> This executable does change the Console Mode of a Cygwin tty
>and that change is kept after the program exits.
> This is not the case for a usual Windows command prompt.
> If you compile my program and run it.
>./test
>New console mode is 0x18
> (interrupting this works for both Ctrl-C and Ctrl-Break)
>but if you now run
>gdb gdb
>....
>(gdb) set prompt top>
>
>top> run
>...
>Try to hit Ctrl-C now, nothing happens
>(exit using q)
>Run again my test program with an argument:
>./test 1
>New console mode is 0x19
>Do the same...
>This time Ctrl-C works.
How is this a cygwin-specific problem? You can do the similar things on
linux by resetting CTRL-C handling. Does gdb accommodate that? If so,
then whatever works for linux should work for Cygwin.
>>if it is, then tcsetattr should be used.
>
From winsup/cygwin/fhanlde_console.cc I suppose that I should use
>tcsetattr (tcgetattr (h) | ISIG, h); But what should the variable 'h'
>be be initialized?
Uh, what? You can't call a lowlevel Cygwin function from outside of the
DLL. You'd need to use the tcsetattr API. Again, this would be similar
to the way UNIX/Linux handle it and I would think that Cygwin would be
able to use whatever code they use.
cgf
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2010-04-26 18:24 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-04-26 11:41 [RFA] windows-nat.c: Enable processed input at startup Pierre Muller
2010-04-26 14:32 ` Christopher Faylor
2010-04-26 15:07 ` Pierre Muller
2010-04-26 15:20 ` Christopher Faylor
2010-04-26 15:47 ` Pierre Muller
2010-04-26 18:24 ` Christopher Faylor
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox