aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.threads/create-fail.exp
blob: 843d0198d82c35689ae8e43096cb1af5e94e399f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# Copyright (C) 2012-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
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

# On GNU/Linux, a creating a thread bound to an unexisting cpu spawns
# the clone child thread for a bit, which is then immediately
# cancelled.  The spawned child may trigger a dlopen (for libgcc_s)
# while being cancelled, which results in a trap being reported to
# GDB, for a thread that libthread_db considers to be TD_THR_ZOMBIE.
# Make sure we handle that scenario properly.

standard_testfile
set executable ${testfile}

if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
    return -1
}

set iterations 10
for {set i 1} {$i <= $iterations} {incr i} {
    with_test_prefix "iteration $i" {

	clean_restart ${executable}

	if ![runto_main] {
	    return -1
	}

	set test "run till end"
	gdb_test_multiple "continue" "$test" {
	    -re "exited with code 01.*$gdb_prompt $" {
		pass "$test"
	    }
	    -re "exited with code 02.*$gdb_prompt $" {
		unsupported "$test (too many CPUs for test?)"
	    }
	    -re "exited normally.*$gdb_prompt $" {
		pass "$test"
	    }
	}
    }
}