1 # This testcase is part of GDB, the GNU debugger.
3 # Copyright 2014 Free Software Foundation, Inc.
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 3 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program. If not, see <http://www.gnu.org/licenses/>. */
20 # Run the test proper. THREADED indicates whether to build a threaded
21 # program and spawn several threads before trying to kill the program.
23 proc test {threaded} {
24 global testfile srcfile
26 with_test_prefix [expr ($threaded)?"threaded":"non-threaded"] {
30 lappend options "pthreads"
31 lappend options "additional_flags=-DUSE_THREADS"
32 set prog ${testfile}_threads
34 set prog ${testfile}_nothreads
37 if {[prepare_for_testing "failed to prepare" $prog $srcfile $options] == -1} {
41 if { ![runto main] } then {
46 set linenum [gdb_get_line_number "set break here"]
47 gdb_breakpoint "$srcfile:$linenum"
48 gdb_continue_to_breakpoint "break here" ".*break here.*"
51 gdb_test "info threads" "6.*5.*4.*3.*2.*1.*" "all threads started"
54 # This kills and ensures no output other than the prompt comes out,
58 # Kill the program being debugged? (y or n) y
61 # If we instead saw more output, like e.g., with an extended-remote
65 # Kill the program being debugged? (y or n) y
66 # Remote connection closed
69 # the above would mean that the remote end crashed.
71 gdb_test "kill" "^y" "kill program" "Kill the program being debugged\\? \\(y or n\\) $" "y"
75 foreach threaded {true false} {