1262569Simp# Copyright (C) 2007-2020 Free Software Foundation, Inc.
2262569Simp
3262569Simp# This program is free software; you can redistribute it and/or modify
4262569Simp# it under the terms of the GNU General Public License as published by
5262569Simp# the Free Software Foundation; either version 3 of the License, or
6262569Simp# (at your option) any later version.
7262569Simp#
8262569Simp# This program is distributed in the hope that it will be useful,
9262569Simp# but WITHOUT ANY WARRANTY; without even the implied warranty of
10262569Simp# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11262569Simp# GNU General Public License for more details.
12262569Simp#
13262569Simp# You should have received a copy of the GNU General Public License
14262569Simp# along with this program.  If not, see <http://www.gnu.org/licenses/>.
15295436Sandrew
16295436Sandrewif [target_info exists gdb,nointerrupts] {
17295436Sandrew    verbose "Skipping leader-exit.exp because of nointerrupts."
18295436Sandrew    return
19262569Simp}
20262569Simp
21262569Simp# Exit of the thread group leader should not break GDB.
22262569Simp
23262569Simpstandard_testfile
24270864Simpset executable ${testfile}
25270864Simp
26270864Simpif {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
27270864Simp    return -1
28270864Simp}
29270864Simp
30270864Simpclean_restart ${executable}
31262569Simp
32262569Simpif ![runto_main] {
33262569Simp    return -1
34262569Simp}
35262569Simp
36262569Simpgdb_breakpoint [gdb_get_line_number "break-here"]
37262569Simpgdb_continue_to_breakpoint "break-here" ".* break-here .*"
38262569Simp
39262569Simpgdb_test "info threads" \
40262569Simp	 "\r\n\[ \t\]*Id\[ \t\]+Target\[ \t\]+Id\[ \t\]+Frame\[ \t\]*\r\n\\* 2 *Thread \[^\r\n\]* at \[^\r\n\]*" \
41262569Simp	 "single thread has been left"
42262569Simp
43262569Simp# Test that ctrl-c works even if the leader has exited.
44262569Simp
45262569Simpset test "continue for ctrl-c"
46262569Simpgdb_test_multiple "continue" $test {
47262569Simp    -re "Continuing" {
48262569Simp	pass $test
49262569Simp    }
50262569Simp}
51262569Simp
52262569Simpsleep 1
53262569Simp
54262569Simpsend_gdb "\003"
55262569Simp
56262569Simpset test "caught interrupt"
57262569Simpgdb_test_multiple "" $test {
58262569Simp    -re "Thread .* received signal SIGINT.*$gdb_prompt $" {
59262569Simp	pass $test
60262569Simp    }
61262569Simp}
62262569Simp