diff options
| author | Eli Zaretskii | 2016-07-12 16:18:06 +0300 |
|---|---|---|
| committer | Eli Zaretskii | 2016-07-12 16:18:06 +0300 |
| commit | 1048151cc4bec79f7310f4f2ede309889822a6bb (patch) | |
| tree | ab799df374ea990645ea89e028fd727e50798f2b /src | |
| parent | 2f67f8a145af8f185f644b1d094a03895a124ef1 (diff) | |
| download | emacs-1048151cc4bec79f7310f4f2ede309889822a6bb.tar.gz emacs-1048151cc4bec79f7310f4f2ede309889822a6bb.zip | |
Don't install keyboard hook when debugged on MS-Windows
* src/w32fns.c (setup_w32_kbdhook): Don't install the keyboard
hook if we are being debugged. This avoids hosing the debugger,
because the hook is global, and is called in the context of the
thread which installed it, and that thread is stopped when GDB has
control. Reported by Fabrice Popineau <fabrice.popineau@gmail.com>.
Diffstat (limited to 'src')
| -rw-r--r-- | src/w32fns.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/w32fns.c b/src/w32fns.c index 0eb720e1cbe..f5e5b33556c 100644 --- a/src/w32fns.c +++ b/src/w32fns.c | |||
| @@ -276,6 +276,8 @@ static struct | |||
| 276 | } kbdhook; | 276 | } kbdhook; |
| 277 | typedef HWND (WINAPI *GetConsoleWindow_Proc) (void); | 277 | typedef HWND (WINAPI *GetConsoleWindow_Proc) (void); |
| 278 | 278 | ||
| 279 | typedef BOOL (WINAPI *IsDebuggerPresent_Proc) (void); | ||
| 280 | |||
| 279 | /* stdin, from w32console.c */ | 281 | /* stdin, from w32console.c */ |
| 280 | extern HANDLE keyboard_handle; | 282 | extern HANDLE keyboard_handle; |
| 281 | 283 | ||
| @@ -2303,6 +2305,19 @@ setup_w32_kbdhook (void) | |||
| 2303 | { | 2305 | { |
| 2304 | kbdhook.hook_count++; | 2306 | kbdhook.hook_count++; |
| 2305 | 2307 | ||
| 2308 | /* This hook gets in the way of debugging, since when Emacs stops, | ||
| 2309 | its input thread stops, and there's nothing to process keyboard | ||
| 2310 | events, whereas this hook is global, and is invoked in the | ||
| 2311 | context of the thread that installed it. So we don't install the | ||
| 2312 | hook if the process is being debugged. */ | ||
| 2313 | if (w32_kbdhook_active) | ||
| 2314 | { | ||
| 2315 | IsDebuggerPresent_Proc is_debugger_present = (IsDebuggerPresent_Proc) | ||
| 2316 | GetProcAddress (GetModuleHandle ("kernel32.dll"), "IsDebuggerPresent"); | ||
| 2317 | if (is_debugger_present && is_debugger_present ()) | ||
| 2318 | return; | ||
| 2319 | } | ||
| 2320 | |||
| 2306 | /* Hooking is only available on NT architecture systems, as | 2321 | /* Hooking is only available on NT architecture systems, as |
| 2307 | indicated by the w32_kbdhook_active variable. */ | 2322 | indicated by the w32_kbdhook_active variable. */ |
| 2308 | if (kbdhook.hook_count == 1 && w32_kbdhook_active) | 2323 | if (kbdhook.hook_count == 1 && w32_kbdhook_active) |