xref: /netbsd-src/external/gpl3/gdb.old/dist/gdb/testsuite/gdb.threads/create-fail.exp (revision 8b657b0747480f8989760d71343d6dd33f8d4cf9)
1# Copyright (C) 2012-2023 Free Software Foundation, Inc.
2
3# This program is free software; you can redistribute it and/or modify
4# it under the terms of the GNU General Public License as published by
5# the Free Software Foundation; either version 3 of the License, or
6# (at your option) any later version.
7#
8# This program is distributed in the hope that it will be useful,
9# but WITHOUT ANY WARRANTY; without even the implied warranty of
10# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11# GNU General Public License for more details.
12#
13# You should have received a copy of the GNU General Public License
14# along with this program.  If not, see <http://www.gnu.org/licenses/>.
15
16# On GNU/Linux, a creating a thread bound to an unexisting cpu spawns
17# the clone child thread for a bit, which is then immediately
18# cancelled.  The spawned child may trigger a dlopen (for libgcc_s)
19# while being cancelled, which results in a trap being reported to
20# GDB, for a thread that libthread_db considers to be TD_THR_ZOMBIE.
21# Make sure we handle that scenario properly.
22
23standard_testfile
24set executable ${testfile}
25
26if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
27    return -1
28}
29
30set iterations 10
31for {set i 1} {$i <= $iterations} {incr i} {
32    with_test_prefix "iteration $i" {
33
34	clean_restart ${executable}
35
36	if ![runto_main] {
37	    return -1
38	}
39
40	set test "run till end"
41	gdb_test_multiple "continue" "$test" {
42	    -re "exited with code 01.*$gdb_prompt $" {
43		pass "$test"
44	    }
45	    -re "exited with code 02.*$gdb_prompt $" {
46		unsupported "$test (too many CPUs for test?)"
47	    }
48	    -re "exited normally.*$gdb_prompt $" {
49		pass "$test"
50	    }
51	}
52    }
53}
54