]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.threads/no-unwaited-for-left.exp
Copyright year update in most files of the GDB Project.
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.threads / no-unwaited-for-left.exp
1 # Copyright (C) 2007, 2011-2012 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 # Exit of a thread when there are other threads in the inferior should
17 # not hang GDB.
18
19 set testfile "no-unwaited-for-left"
20 set srcfile ${testfile}.c
21 set executable ${testfile}
22 set binfile ${objdir}/${subdir}/${executable}
23
24 if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
25 return -1
26 }
27
28 clean_restart ${executable}
29
30 if ![runto_main] {
31 return -1
32 }
33
34 gdb_breakpoint $srcfile:[gdb_get_line_number "break-here"]
35 gdb_continue_to_breakpoint "break-here" ".* break-here .*"
36
37 # Resume only the second thread
38 gdb_test_no_output "set scheduler-locking on" \
39 "enable scheduler-locking, for thread 2"
40
41 # Continue. Thread 2 exits, and the main thread was already stopped.
42 gdb_test "continue" \
43 "No unwaited-for children left." \
44 "continue stops when thread 2 exits"
45
46 gdb_test "info threads" \
47 "\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.*" \
48 "only main thread left, thread 2 terminated"
49
50 # Select the main thread, let the third thread start, and stop at the
51 # main thread breakpoint.
52 gdb_test "thread 1" "" "select main thread"
53 gdb_test_no_output "set scheduler-locking off" \
54 "disable scheduler-locking, letting new thread start"
55
56 gdb_breakpoint $srcfile:[gdb_get_line_number "break-here-2"]
57 gdb_continue_to_breakpoint "break-here-2" ".* break-here-2 .*"
58
59 # Let the main thread continue alone.
60 gdb_test_no_output "set scheduler-locking on" \
61 "enable scheduler-locking, for main thread"
62 # The main thread exits, and thread 3 was already stopped.
63 gdb_test "continue" \
64 "No unwaited-for children left." \
65 "continue stops when the main thread exits"
66
67 gdb_test "info threads" \
68 "\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.*" \
69 "only thread 3 left, main thread terminated"