Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Pedro Alves <pedro@palves.net>
To: gdb-patches@sourceware.org
Subject: [PATCH v2 02/11] Adjust gdb.base/exitsignal.exp for MinGW, second-chance SIGSEGV
Date: Mon, 25 May 2026 20:18:20 +0100	[thread overview]
Message-ID: <20260525191829.984105-3-pedro@palves.net> (raw)
In-Reply-To: <20260525191829.984105-1-pedro@palves.net>

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
commit-id: 385755c8
---
 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"
-- 
2.53.0


  parent reply	other threads:[~2026-05-25 19:19 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-25 19:18 [PATCH v2 00/11] Fix a few Cygwin/MinGW problems Pedro Alves
2026-05-25 19:18 ` [PATCH v2 01/11] Adjust gdb.base/exitsignal.exp for MinGW, trigger fault Pedro Alves
2026-05-25 19:18 ` Pedro Alves [this message]
2026-05-26 11:18   ` [PATCH v2 02/11] Adjust gdb.base/exitsignal.exp for MinGW, second-chance SIGSEGV Eli Zaretskii
2026-05-27 12:56     ` Pedro Alves
2026-05-25 19:18 ` [PATCH v2 03/11] Adjust gdb.base/exitsignal.exp for MinGW, separate program names Pedro Alves
2026-05-27 21:59   ` Thiago Jung Bauermann
2026-06-12 14:00     ` Pedro Alves
2026-05-25 19:18 ` [PATCH v2 04/11] gdb.base/exitsignal.exp: Exit with non-zero Pedro Alves
2026-05-25 19:18 ` [PATCH v2 05/11] gdb.base/exitsignal.exp: Test attaching too Pedro Alves
2026-05-25 19:18 ` [PATCH v2 06/11] gdb/testsuite: Add mechanism to compile Windows native programs on Cygwin Pedro Alves
2026-05-25 19:18 ` [PATCH v2 07/11] Windows gdb+gdbserver: Share exit status logic Pedro Alves
2026-05-25 19:18 ` [PATCH v2 08/11] Windows gdb+gdbserver: Decode Cygwin ExitProcess codes Pedro Alves
2026-05-26 11:31   ` Eli Zaretskii
2026-05-27 13:58     ` Pedro Alves
2026-05-27 14:12       ` Eli Zaretskii
2026-05-27 22:00   ` Thiago Jung Bauermann
2026-05-25 19:18 ` [PATCH v2 09/11] Adjust gdb.python/py-events.exp for Cygwin/MinGW, thread IDs Pedro Alves
2026-05-25 19:18 ` [PATCH v2 10/11] Adjust gdb.python/py-events.exp for Cygwin/MinGW, no fork Pedro Alves
2026-05-25 19:18 ` [PATCH v2 11/11] Adjust gdb.python/py-events.exp for Cygwin/MinGW, "info proc" => "inferior" Pedro Alves

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260525191829.984105-3-pedro@palves.net \
    --to=pedro@palves.net \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox