1 # This testcase is part of GDB, the GNU debugger.
3 # Copyright 2014-2024 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 decimal
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} {
45 set linenum [gdb_get_line_number "set break here"]
46 gdb_breakpoint "$srcfile:$linenum"
47 gdb_continue_to_breakpoint "break here" ".*break here.*"
50 gdb_test "info threads" "1.*2.*3.*4.*5.*6.*" "all threads started"
53 # This kills and ensures no output other than the prompt comes out,
57 # Kill the program being debugged? (y or n) y
60 # If we instead saw more output, like e.g., with an extended-remote
64 # Kill the program being debugged? (y or n) y
65 # Remote connection closed
68 # the above would mean that the remote end crashed.
70 gdb_test_multiple "kill" "kill" {
71 -re "Kill the program being debugged\\? \\(y or n\\) $" {
72 gdb_test "y" "\\\[Inferior $decimal \\(.*\\) killed\\\]" "kill"
78 foreach threaded {true false} {