Commit | Line | Data |
---|---|---|
e76126e8 PA |
1 | # This testcase is part of GDB, the GNU debugger. |
2 | ||
32d0add0 | 3 | # Copyright 2014-2015 Free Software Foundation, Inc. |
e76126e8 PA |
4 | |
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. | |
9 | # | |
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. | |
14 | # | |
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/>. */ | |
17 | ||
18 | standard_testfile | |
19 | ||
20 | # Run the test proper. THREADED indicates whether to build a threaded | |
21 | # program and spawn several threads before trying to kill the program. | |
22 | ||
23 | proc test {threaded} { | |
24 | global testfile srcfile | |
25 | ||
26 | with_test_prefix [expr ($threaded)?"threaded":"non-threaded"] { | |
27 | ||
28 | set options {debug} | |
29 | if {$threaded} { | |
30 | lappend options "pthreads" | |
31 | lappend options "additional_flags=-DUSE_THREADS" | |
32 | set prog ${testfile}_threads | |
33 | } else { | |
34 | set prog ${testfile}_nothreads | |
35 | } | |
36 | ||
37 | if {[prepare_for_testing "failed to prepare" $prog $srcfile $options] == -1} { | |
38 | return -1 | |
39 | } | |
40 | ||
41 | if { ![runto main] } then { | |
42 | fail "run to main" | |
43 | return | |
44 | } | |
45 | ||
46 | set linenum [gdb_get_line_number "set break here"] | |
47 | gdb_breakpoint "$srcfile:$linenum" | |
48 | gdb_continue_to_breakpoint "break here" ".*break here.*" | |
49 | ||
50 | if {$threaded} { | |
51 | gdb_test "info threads" "6.*5.*4.*3.*2.*1.*" "all threads started" | |
52 | } | |
53 | ||
54 | # This kills and ensures no output other than the prompt comes out, | |
55 | # like: | |
56 | # | |
57 | # (gdb) kill | |
58 | # Kill the program being debugged? (y or n) y | |
59 | # (gdb) | |
60 | # | |
61 | # If we instead saw more output, like e.g., with an extended-remote | |
62 | # connection: | |
63 | # | |
64 | # (gdb) kill | |
65 | # Kill the program being debugged? (y or n) y | |
66 | # Remote connection closed | |
67 | # (gdb) | |
68 | # | |
69 | # the above would mean that the remote end crashed. | |
70 | ||
71 | gdb_test "kill" "^y" "kill program" "Kill the program being debugged\\? \\(y or n\\) $" "y" | |
72 | } | |
73 | } | |
74 | ||
75 | foreach threaded {true false} { | |
76 | test $threaded | |
77 | } |