[binutils-gdb] [gdb/python] Fix test_python on msys2-ucrt64

Tom de Vries vries@sourceware.org
Tue Dec 1 08:38:04 GMT 2026


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=9760d1f3c24b4696dc7dbb3134864af0f72bcf97

commit 9760d1f3c24b4696dc7dbb3134864af0f72bcf97
Author: Tom de Vries <tdevries@suse.de>
Date:   Tue Dec 1 09:38:00 2026 +0100

    [gdb/python] Fix test_python on msys2-ucrt64
    
    On msys2-ucrt64, running the selftests terminates after test_python.
    
    The problem is that the test does "raise (SIGINT)", which terminates GDB.
    
    Fix this on MinGW by calling handle_sigint directly.
    
    Tested on x86_64-linux and msys2-ucrt64 by rebuilding and running the
    selftests.

Diff:
---
 gdb/python/python.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/gdb/python/python.c b/gdb/python/python.c
index 1d540959879..ad5c33ad453 100644
--- a/gdb/python/python.c
+++ b/gdb/python/python.c
@@ -2822,9 +2822,19 @@ test_python ()
 
   saw_exception = false;
   {
+    auto raise_sigint = [] ()
+      {
+#ifdef __MINGW32__
+	/* On MinGW, raise (SIGINT) terminates GDB, so call the sigint handler
+	   directly.  */
+	handle_sigint (SIGINT);
+#else
+	raise (SIGINT);
+#endif
+      };
+
     scoped_restore save_hook
-      = make_scoped_restore (&hook_set_active_ext_lang,
-			     []() { raise (SIGINT); });
+      = make_scoped_restore (&hook_set_active_ext_lang, raise_sigint);
     try
       {
 	CMD (output);


More information about the Gdb-cvs mailing list