-# Copyright 2008-2016 Free Software Foundation, Inc.
+# Copyright 2008-2023 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# end up leaving stale state behind that confuse the following
# attach).
+# Return true if the running version of DejaGnu is known to not be
+# able to run this test.
+proc bad_dejagnu {} {
+ set dj_ver [dejagnu_version]
+ set dj_ver_major [lindex $dj_ver 0]
+ set dj_ver_minor [lindex $dj_ver 1]
+
+ # DejaGnu versions prior to 1.6 manage to kill the wrong process
+ # due to PID-reuse races. Since this test spawns many threads, it
+ # widens the race window a whole lot, enough that the inferior is
+ # often killed, and thus the test randomly fails. See:
+ # http://lists.gnu.org/archive/html/dejagnu/2015-07/msg00005.html
+ # The fix added a close_wait_program procedure. If that procedure
+ # is defined, and DejaGnu is older than 1.6, assume that means the
+ # fix was backported.
+ if {$dj_ver_major == 1
+ && ($dj_ver_minor < 6 && [info procs close_wait_program] == "")} {
+ return 1
+ }
+
+ return 0
+}
+
+if {[bad_dejagnu]} {
+ unsupported "broken DejaGnu"
+ return 0
+}
+
if {![can_spawn_for_attach]} {
return 0
}
global gdb_prompt
global decimal
- clean_restart ${binfile}
-
set test_spawn_id [spawn_wait_for_attach $binfile]
set testpid [spawn_id_get_pid $test_spawn_id]
sleep 1
set test "no new threads"
- gdb_test_multiple "info threads" $test {
- -re "New .*$gdb_prompt $" {
- fail $test
+ set status 1
+ gdb_test_multiple "info threads" $test -lbl {
+ -re "\r\n\[^\r\n\]*New " {
+ set status 0
+ exp_continue
}
- -re "$gdb_prompt $" {
- pass $test
+ -re -wrap "" {
+ if { $status == 1 } {
+ pass $gdb_test_name
+ } else {
+ fail $gdb_test_name
+ }
}
}
# detaching from the program and reattaching, we check that
# the program doesn't die due to gdb leaving a pending
# breakpoint hit on a new thread unprocessed.
- gdb_test "break break_fn" "Breakpoint.*" "break break_fn"
+ gdb_test "break break_fn" "Breakpoint.*"
# Wait a bit, to give time for most threads to hit the
# breakpoint, including threads we might have failed to
# failure.
set options { "additional_flags=-DTIMEOUT=$timeout" debug pthreads }
-if {[prepare_for_testing "failed to prepare" $testfile $srcfile $options] == -1} {
+if {[prepare_for_testing "failed to prepare" $testfile $srcfile \
+ $options] == -1} {
return -1
}