]> git.eshelyaron.com Git - emacs.git/commitdiff
Remove low-level keyboard hook when attaching GDB to Emacs on Windows
authorEli Zaretskii <eliz@gnu.org>
Sat, 7 Sep 2024 08:15:43 +0000 (11:15 +0300)
committerEshel Yaron <me@eshelyaron.com>
Sun, 8 Sep 2024 11:24:08 +0000 (13:24 +0200)
This fixes the problem whereby attaching GDB to a running Emacs
on MS-Windows would slow down keyboard input, because the
low-level keyboard hook installed by Emacs at startup was still
installed, but with Emacs stopped, the hook code couldn't run,
and therefore the OS would time-out waiting for the hook to
return.  Now when GDB is attached to Emacs, it will remove the
hook right away.
* src/.gdbinit: Call 'remove_w32_kbdhook' if the keyboard hook is
already installed.
* src/alloc.c (defined_WINDOWSNT): New enum.
(gdb_make_enums_visible): Add 'defined_WINDOWSNT'.

(cherry picked from commit 358208dfaa374cc71c4a1c081c2d5bff9127c55a)

src/.gdbinit
src/alloc.c

index 0f55cc186994ecba2d3750c13e2048e832c1797d..d13134a4e3f4259f75adeb5b63fbff6991be0aad 100644 (file)
@@ -1308,6 +1308,11 @@ if defined_HAVE_X_WINDOWS
   break x_error_quitter
 end
 
+if defined_WINDOWSNT
+  while kbdhook.hook_count > 0
+    call remove_w32_kbdhook()
+  end
+end
 
 # Put the Python code at the end of .gdbinit so that if GDB does not
 # support Python, GDB will do all the above initializations before
index c22a5a787e4332d0d074ec840000bcb481510ef6..066ec9fefe545b9a2d7e38fb443487c0cc558d51 100644 (file)
@@ -8297,6 +8297,9 @@ N should be nonnegative.  */);
   DEFSYM (QCemergency, ":emergency");
 }
 
+/* The below is for being able to do platform-specific stuff in .gdbinit
+   without risking error messages from GDB about missing types and
+   variables on other platforms.  */
 #ifdef HAVE_X_WINDOWS
 enum defined_HAVE_X_WINDOWS { defined_HAVE_X_WINDOWS = true };
 #else
@@ -8309,6 +8312,12 @@ enum defined_HAVE_PGTK { defined_HAVE_PGTK = true };
 enum defined_HAVE_PGTK { defined_HAVE_PGTK = false };
 #endif
 
+#ifdef WINDOWSNT
+enum defined_WINDOWSNT { defined_WINDOWSNT = true };
+#else
+enum defined_WINDOWSNT { defined_WINDOWSNT = false };
+#endif
+
 /* When compiled with GCC, GDB might say "No enum type named
    pvec_type" if we don't have at least one symbol with that type, and
    then xbacktrace could fail.  Similarly for the other enums and
@@ -8329,6 +8338,7 @@ extern union enums_for_gdb
   enum pvec_type pvec_type;
   enum defined_HAVE_X_WINDOWS defined_HAVE_X_WINDOWS;
   enum defined_HAVE_PGTK defined_HAVE_PGTK;
+  enum defined_WINDOWSNT defined_WINDOWSNT;
 } const gdb_make_enums_visible;
 union enums_for_gdb const EXTERNALLY_VISIBLE gdb_make_enums_visible = {0};
 #endif /* __GNUC__ */