[v2,01/11] Adjust gdb.base/exitsignal.exp for MinGW, trigger fault

Message ID 20260525191829.984105-2-pedro@palves.net
State New
Headers
Series Fix a few Cygwin/MinGW problems |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_gdb_build--master-arm success Build passed
linaro-tcwg-bot/tcwg_gdb_build--master-aarch64 success Build passed
linaro-tcwg-bot/tcwg_gdb_check--master-arm success Test passed
linaro-tcwg-bot/tcwg_gdb_check--master-aarch64 success Test passed

Commit Message

Pedro Alves May 25, 2026, 7:18 p.m. UTC
  gdb.base/segv.c uses raise(SIGSEGV) to generate a SIGSEGV.  On native
Windows that does not generate an EXCEPTION_ACCESS_VIOLATION; raise is
a pure userspace construct: it dispatches to the registered SIGSEGV
handler if there is one, otherwise calls abort.  GDB therefore never
sees an exception to intercept.  E.g.:

 ...
 continue
 Continuing.
 [Thread 1908.0x3308 (id 2) exited with code 3]
 [Inferior 1 (process 1908) exited with code 03]
 (gdb) FAIL: gdb.base/exitsignal.exp: trigger SIGSEGV (the program exited)
 continue
 The program is not being run.
 ...

Replace the raise with a real null dereference so the kernel actually
raises an access violation.

Note: I confirmed no other tests use segv.c.  segv.c and normal.c are
both "owned" by gdb.base/exitsignal.exp.

Change-Id: Ib54d9e6998cf9bfc18dcb5e76d31a9deb0458da4
commit-id: 86fcf2ce
---
 gdb/testsuite/gdb.base/segv.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
  

Patch

diff --git a/gdb/testsuite/gdb.base/segv.c b/gdb/testsuite/gdb.base/segv.c
index a3db6d292db..fd43d95e9b2 100644
--- a/gdb/testsuite/gdb.base/segv.c
+++ b/gdb/testsuite/gdb.base/segv.c
@@ -17,13 +17,11 @@ 
 
 /* This test can be used just to generate a SIGSEGV.  */
 
-#include <signal.h>
-
 int
 main (int argc, char *argv[])
 {
   /* Generating a SIGSEGV.  */
-  raise (SIGSEGV);
+  *(volatile int *) 0;
 
   return 0;
 }