[PATCH 12/27] gdb.base/exitsignal.exp: Relax SIGSEGV second-chance pattern

Pedro Alves <[email protected]> Thu, 23 Jul 2026 14:01:03 +0100
Newsgroups gmane.comp.gdb.patches
Message-ID <[email protected]>
The "trigger SIGSEGV, second-chance" test matches the signal stop with

  Thread .* received signal SIGSEGV.*

GDB only prints the "Thread NNN received signal ..." form when the
inferior has more than one thread.  For a single-threaded inferior it
prints "Program received signal ..." instead.

Whether a Windows program is multi-threaded by the time it reaches
main depends on the C runtime it links against:

 - A program built against the dynamic UCRT pulls in ucrtbase.dll,
   which starts additional threads during its initialization.

 - A program built with a statically-linked CRT does not go through
   that initialization, so it is still single-threaded at main.

Native MinGW test programs pull in ucrtbase.dll and so are
multi-threaded, but programs built with a clang x86_64-pc-windows-msvc
toolchain default to the static CRT and are single-threaded, so GDB
announces the signal with "Program received signal ..." and the test
fails:

 Program received signal SIGSEGV, Segmentation fault.
 0x00007ff628a9102f in main (argc=1, argv=0x50ff90) at .../gdb/testsuite/gdb.base/segv.c:41
 41        *(volatile int *) 0;
 (gdb) FAIL: gdb.base/exitsignal.exp: how=run: signal: trigger SIGSEGV, second-chance

Fix this by dropping the "Thread .*" prefix from the pattern so that
it matches both the "Thread NNN received signal" and "Program received
signal" forms.

Change-Id: I3ac3cd316da2126635a9e2b3338befec9c2a5195
---
 gdb/testsuite/gdb.base/exitsignal.exp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gdb/testsuite/gdb.base/exitsignal.exp b/gdb/testsuite/gdb.base/exitsignal.exp
index 0ffb20258d1..dd968300fcb 100644
--- a/gdb/testsuite/gdb.base/exitsignal.exp
+++ b/gdb/testsuite/gdb.base/exitsignal.exp
@@ -125,7 +125,7 @@ proc test_signal {how exec binfile} {
 	# 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 one.
-	gdb_test "continue" "Thread .* received signal SIGSEGV.*" \
+	gdb_test "continue" " received signal SIGSEGV.*" \
 	    "trigger SIGSEGV, second-chance"
     } elseif {[istarget "*-*-cygwin*"]} {
 	# Cygwin calls DebugBreak before it lets the process exit.
-- 
2.54.0