summaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.threads/no-unwaited-for-left.exp
blob: 39dbccb0c05fc11c200a0873339d4640952c37fe (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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# Copyright (C) 2007-2014 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/>.

# Exit of a thread when there are other threads in the inferior should
# not hang GDB.

standard_testfile
set executable ${testfile}

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

clean_restart ${executable}

if ![runto_main] {
    return -1
}

gdb_breakpoint $srcfile:[gdb_get_line_number "break-here"]
gdb_continue_to_breakpoint "break-here" ".* break-here .*"

# Resume only the second thread
gdb_test_no_output "set scheduler-locking on" \
    "enable scheduler-locking, for thread 2"

# Continue.  Thread 2 exits, and the main thread was already stopped.
gdb_test "continue" \
    "No unwaited-for children left." \
    "continue stops when thread 2 exits"

gdb_test "info threads" \
	 "\r\n\[ \t\]*Id\[ \t\]+Target\[ \t\]+Id\[ \t\]+Frame\[ \t\]*\r\n *1 *Thread \[^\r\n\]* \[^\r\n\]*.*The current thread <Thread ID 2> has terminated.*" \
	 "only main thread left, thread 2 terminated"

# Select the main thread, let the third thread start, and stop at the
# main thread breakpoint.
gdb_test "thread 1" "" "select main thread"
gdb_test_no_output "set scheduler-locking off" \
    "disable scheduler-locking, letting new thread start"

gdb_breakpoint $srcfile:[gdb_get_line_number "break-here-2"]
gdb_continue_to_breakpoint "break-here-2" ".* break-here-2 .*"

# Let the main thread continue alone.
gdb_test_no_output "set scheduler-locking on" \
    "enable scheduler-locking, for main thread"
# The main thread exits, and thread 3 was already stopped.
gdb_test "continue" \
    "No unwaited-for children left." \
    "continue stops when the main thread exits"

gdb_test "info threads" \
	 "\r\n\[ \t\]*Id\[ \t\]+Target\[ \t\]+Id\[ \t\]+Frame\[ \t\]*\r\n *3 *Thread \[^\r\n\]* \[^\r\n\]*.*The current thread <Thread ID 1> has terminated.*" \
	 "only thread 3 left, main thread terminated"