diff --git a/gdb/testsuite/gdb.base/bt-on-fatal-signal.exp b/gdb/testsuite/gdb.base/bt-on-fatal-signal.exp index 8f9d857106d..1af88d50c4c 100644 --- a/gdb/testsuite/gdb.base/bt-on-fatal-signal.exp +++ b/gdb/testsuite/gdb.base/bt-on-fatal-signal.exp @@ -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] diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp index 7d05fbe557b..a73437a419f 100644 --- a/gdb/testsuite/lib/gdb.exp +++ b/gdb/testsuite/lib/gdb.exp @@ -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.