xref: /netbsd-src/external/gpl3/gdb.old/dist/gdb/testsuite/gdb.threads/schedlock-thread-exit.exp (revision f8cf1a9151c7af1cb0bd8b09c13c66bca599c027)
1# Copyright 2021-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# Test that GDB handles well a thread exiting with sched-lock on.  A buggy GDB
17# would hang, a fixed GDB shows the "No unwaited-for children left" message and
18# shows the prompt.
19#
20# The explanation for the original bug involved some threads with a pending
21# wait status, so we launch multiple threads, which very likely gives us that.
22
23standard_testfile
24
25if { [build_executable "failed to prepare" ${testfile} ${srcfile} \
26	  {debug pthreads additional_flags=-std=c99}] } {
27    return
28}
29
30proc do_test { } {
31    clean_restart $::binfile
32
33    # One of the launched threads will report a stop on thread_func.  Some
34    # others will also stop on thread_func and have a pending status.
35    if { ![runto "thread_func"] } {
36	return
37    }
38
39    gdb_test_no_output "set scheduler-locking on"
40    gdb_test "continue" "No unwaited-for children left."
41}
42
43do_test
44