1 # Copyright (C) 2007-2015 Free Software Foundation, Inc.
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.
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.
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/>.
16 # Exit of a thread when there are other threads in the inferior should
20 set executable ${testfile}
22 if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
26 clean_restart ${executable}
32 gdb_breakpoint $srcfile:[gdb_get_line_number "break-here"]
33 gdb_continue_to_breakpoint "break-here" ".* break-here .*"
35 # Resume only the second thread
36 gdb_test_no_output "set scheduler-locking on" \
37 "enable scheduler-locking, for thread 2"
39 # Continue. Thread 2 exits, and the main thread was already stopped.
40 if [is_remote target] {
41 setup_kfail "gdb/14618" "*-*-*"
44 "No unwaited-for children left." \
45 "continue stops when thread 2 exits"
47 gdb_test "info threads" \
48 "\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.*" \
49 "only main thread left, thread 2 terminated"
51 # Select the main thread, let the third thread start, and stop at the
52 # main thread breakpoint.
53 gdb_test "thread 1" "" "select main thread"
54 gdb_test_no_output "set scheduler-locking off" \
55 "disable scheduler-locking, letting new thread start"
57 gdb_breakpoint $srcfile:[gdb_get_line_number "break-here-2"]
58 gdb_continue_to_breakpoint "break-here-2" ".* break-here-2 .*"
60 # Let the main thread continue alone.
61 gdb_test_no_output "set scheduler-locking on" \
62 "enable scheduler-locking, for main thread"
63 # The main thread exits, and thread 3 was already stopped.
64 if [is_remote target] {
65 setup_kfail "gdb/14618" "*-*-*"
68 "No unwaited-for children left." \
69 "continue stops when the main thread exits"
71 gdb_test "info threads" \
72 "\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.*" \
73 "only thread 3 left, main thread terminated"
75 # Make sure thread apply all works when we have exited threads in the
77 gdb_test "thread apply all print 999" " = 999" "thread apply all with exited thread"