[gdb/testsuite] Don't generate core in gdb.base/bt-on-fatal-signal.exp
authorTom de Vries <tdevries@suse.de>
Sat, 26 Nov 2022 13:29:10 +0000 (14:29 +0100)
committerTom de Vries <tdevries@suse.de>
Sat, 26 Nov 2022 13:29:10 +0000 (14:29 +0100)
When running test-case gdb.base/bt-on-fatal-signal.exp on powerpc64le-linux I
noticed:
...
FAIL: gdb.base/bt-on-fatal-signal.exp: SEGV: scan for backtrace (timeout)
...

The timeout is 10 seconds, but generating the core file takes more than a
minute, probably due to slow NFS.

I managed to reproduce this behaviour independently of gdb, by compiling
"int main (void) { __builtin_abort (); }" and running it, which took 1.5
seconds for a core file 50 times smaller than the one for gdb.

Fix this by preventing the core file from being generated, using a wrapper
around gdb that does "ulimit -c 0".

Tested on x86_64-linux.

gdb/testsuite/gdb.base/bt-on-fatal-signal.exp
gdb/testsuite/lib/gdb.exp

index 8f9d857106d1e33eeeb7a7662730b804b70a9fe2..1af88d50c4cdb7ca2e5efaa05a7920a8794a2136 100644 (file)
@@ -62,7 +62,10 @@ foreach test_data {{SEGV "Segmentation fault"} \
     with_test_prefix ${sig} {
 
        # Restart GDB.
-       clean_restart $binfile
+       save_vars { GDB } {
+           set GDB [gdb_no_core]
+           clean_restart $binfile
+       }
 
        # Capture the pid of GDB.
        set testpid [spawn_id_get_pid $gdb_spawn_id]
index 7d05fbe557bba4dc97e67a40890dab4f45791291..a73437a419fe278c7e2ca27c415723bc3a7a5758 100644 (file)
@@ -6322,6 +6322,17 @@ proc cached_file { filename txt {executable 0}} {
     return $filename
 }
 
+# Return a wrapper around gdb that prevents generating a core file.
+
+proc gdb_no_core { } {
+    set script \
+       [list \
+            "ulimit -c 0" \
+            [join [list exec $::GDB {"$@"}]]]
+    set script [join $script "\n"]
+    return [cached_file gdb-no-core.sh $script 1]
+}
+
 # Set 'testfile', 'srcfile', and 'binfile'.
 #
 # ARGS is a list of source file specifications.