[binutils-gdb] Adjust gdb.base/exitsignal.exp for MinGW, second-chance SIGSEGV

Pedro Alves via Gdb-cvs <[email protected]> Fri, 12 Jun 2026 13:59:00 +0000 (GMT)
Newsgroups gmane.comp.gdb.cvs
Message-ID <[email protected]>
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=addf54463d8763fe254049aabf7ed131875d8ffb

commit addf54463d8763fe254049aabf7ed131875d8ffb
Author: Pedro Alves <[email protected]>
Date:   Sat May 23 03:08:31 2026 +0100

    Adjust gdb.base/exitsignal.exp for MinGW, second-chance SIGSEGV
    
    On native Windows a segmentation fault is delivered as a SEH
    exception, so GDB stops twice: once for the first-chance exception,
    and -- if no SEH handler in the inferior catches it -- again for the
    second-chance exception, after which the process dies.  The testcase
    currently continues only once, resulting in:
    
     ...
     continue
     Continuing.
    
     Thread 1 received signal SIGSEGV, Segmentation fault.
     0x00007ff765ac1469 in main (argc=1, argv=0x9f2640) at C:/rocgdb/src.cascais-rsync/gdb/testsuite/gdb.base/segv.c:24
     24        *(volatile int *) 0;
     (gdb) PASS: gdb.base/exitsignal.exp: trigger SIGSEGV
     continue
     Continuing.
    
     Thread 1 received signal SIGSEGV, Segmentation fault.
     0x00007ff765ac1469 in main (argc=1, argv=0x9f2640) at C:/rocgdb/src.cascais-rsync/gdb/testsuite/gdb.base/segv.c:24
     24        *(volatile int *) 0;
     (gdb) FAIL: gdb.base/exitsignal.exp: program terminated with SIGSEGV
     ...
    
    Add a second continue on MinGW to step past the second-chance stop.
    
    With this, gdb.base/exitsignal.exp passes cleanly on MinGW:
    
     -FAIL: gdb.base/exitsignal.exp: program terminated with SIGSEGV
     +PASS: gdb.base/exitsignal.exp: trigger SIGSEGV, second-chance
     +PASS: gdb.base/exitsignal.exp: program terminated with SIGSEGV
    
    Change-Id: Ibda1540a602b62c26a5b218d930402eccc3ba98f

Diff:
---
 gdb/testsuite/gdb.base/exitsignal.exp | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/gdb/testsuite/gdb.base/exitsignal.exp b/gdb/testsuite/gdb.base/exitsignal.exp
index 5099ae1a1d6..341197cf0c8 100644
--- a/gdb/testsuite/gdb.base/exitsignal.exp
+++ b/gdb/testsuite/gdb.base/exitsignal.exp
@@ -53,7 +53,13 @@ gdb_test "print \$_exitcode" " = void" \
 gdb_test "continue" "(Thread .*|Program) received signal SIGSEGV.*" \
     "trigger SIGSEGV"
 
-if {[istarget "*-*-cygwin*"]} {
+if {[istarget "*-*-mingw*"]} {
+    # We're debugging a pure Win32 program with no SEH handler.  The
+    # previous continue caught the first-chance exception.  Now we
+    # catch the second-chance.
+    gdb_test "continue" "Thread .* received signal SIGSEGV.*" \
+	"trigger SIGSEGV, second-chance"
+} elseif {[istarget "*-*-cygwin*"]} {
     # Cygwin calls DebugBreak before it lets the process exit.
     gdb_test "continue" "Thread .* received signal SIGTRAP.*" \
 	"trigger try_to_debug SIGTRAP"