[RFA] windows-nat.c: Handle CTRL_BREAK_EVENT in ctrl_c_handler

Pierre Muller
2009-09-21T15:24:36Z

Using Ctrl-C to interrupt a running application
does not always work nicely because the application
can decide to handle Ctrl-C as a normal character.
On the contrary, Ctrl-Break always generates a
call to the installed SetConsoleCtrlHandler.
This patch allows me to interrupt a debuggee
running in another console (with 'set new-console on')
by pressing Ctrl-Break, even, if Ctrl-C has been
transformed by the debuggee as a normal char
using SetConsoleMode API function.

Pierre Muller
Pascal language support maintainer for GDB

2009-09-21 Pierre Muller <muller@ics.u-strasbg.fr>

* src/gdb/windows-nat.c (ctrl_c_handler): Also handle
CTRL_BREAK_EVENT.

Index: src/gdb/windows-nat.c
===================================================================
RCS file: /cvs/src/src/gdb/windows-nat.c,v
retrieving revision 1.196
diff -u -p -r1.196 windows-nat.c
--- src/gdb/windows-nat.c 2 Jul 2009 17:21:07 -0000 1.196
+++ src/gdb/windows-nat.c 21 Sep 2009 14:53:38 -0000
@@ -1289,8 +1304,8 @@ ctrl_c_handler (DWORD event_type)
{
const int attach_flag = current_inferior ()->attach_flag;

- /* Only handle Ctrl-C event. Ignore others. */
- if (event_type != CTRL_C_EVENT)
+ /* Only handle Ctrl-C and Ctrl-Break events. Ignore others. */
+ if (event_type != CTRL_C_EVENT && event_type != CTRL_BREAK_EVENT)
return FALSE;

/* If the inferior and the debugger share the same console, do nothing as