Commit | Line | Data |
---|---|---|
7339a42e | 1 | # manythreads.exp -- Expect script to test stopping many threads |
ecd75fc8 | 2 | # Copyright (C) 2004-2014 Free Software Foundation, Inc. |
7339a42e JJ |
3 | |
4 | # This program is free software; you can redistribute it and/or modify | |
5 | # it under the terms of the GNU General Public License as published by | |
e22f8b7c | 6 | # the Free Software Foundation; either version 3 of the License, or |
7339a42e | 7 | # (at your option) any later version. |
e22f8b7c | 8 | # |
7339a42e JJ |
9 | # This program is distributed in the hope that it will be useful, |
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | # GNU General Public License for more details. | |
e22f8b7c | 13 | # |
7339a42e | 14 | # You should have received a copy of the GNU General Public License |
e22f8b7c | 15 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
7339a42e | 16 | |
7339a42e JJ |
17 | # This file was written by Jeff Johnston. (jjohnstn@redhat.com) |
18 | ||
7339a42e | 19 | |
0efbbabc | 20 | standard_testfile |
7339a42e | 21 | |
e5d98164 YQ |
22 | set opts { debug } |
23 | if [info exists DEBUG] { | |
24 | # make check RUNTESTFLAGS='gdb.threads/manythreads.exp DEBUG=1' | |
25 | lappend opts "additional_flags=-DDEBUG" | |
26 | } | |
27 | ||
28 | if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable $opts] != "" } { | |
7339a42e JJ |
29 | return -1 |
30 | } | |
31 | ||
0efbbabc | 32 | clean_restart ${binfile} |
12b5d08a | 33 | gdb_test_no_output "set print sevenbit-strings" |
7339a42e JJ |
34 | runto_main |
35 | ||
36 | # We'll need this when we send_gdb a ^C to GDB. Need to do it before we | |
37 | # run the program and gdb starts saving and restoring tty states. | |
38 | # On Ultrix, we don't need it and it is really slow (because shell_escape | |
39 | # doesn't use vfork). | |
40 | if ![istarget "*-*-ultrix*"] then { | |
f6978de9 | 41 | gdb_test "shell stty intr '^C'" ".*" |
7339a42e JJ |
42 | } |
43 | ||
44 | set message "first continue" | |
45 | gdb_test_multiple "continue" "first continue" { | |
46 | -re "error:.*$gdb_prompt $" { | |
47 | fail "$message" | |
48 | } | |
49 | -re "Continuing" { | |
50 | pass "$message" | |
51 | } | |
52 | } | |
53 | ||
57380f4e DJ |
54 | # Wait one second. This is better than the TCL "after" command, because |
55 | # we don't lose GDB's output while we do it. | |
56 | remote_expect host 1 { timeout { } } | |
57 | ||
7339a42e | 58 | # Send a Ctrl-C and verify that we can do info threads and continue |
4013522b | 59 | send_gdb "\003" |
7339a42e JJ |
60 | set message "stop threads 1" |
61 | gdb_test_multiple "" "stop threads 1" { | |
62 | -re "\\\[New \[^\]\]*\\\]\r\n" { | |
63 | exp_continue | |
64 | } | |
65 | -re "\\\[\[^\]\]* exited\\\]\r\n" { | |
66 | exp_continue | |
67 | } | |
7339a42e JJ |
68 | -re "Program received signal SIGINT.*$gdb_prompt $" { |
69 | pass "$message" | |
70 | } | |
71 | timeout { | |
72 | fail "$message (timeout)" | |
73 | } | |
74 | } | |
75 | ||
4339e69e DJ |
76 | set cmd "info threads" |
77 | set ok 0 | |
78 | gdb_test_multiple $cmd $cmd { | |
a7658b96 | 79 | -re " 1 *Thread " { |
4339e69e DJ |
80 | set ok 1 |
81 | exp_continue | |
82 | } | |
83 | -re ".*\r\n" { | |
84 | # Eat this line and continue, to prevent the buffer overflowing. | |
85 | exp_continue | |
86 | } | |
87 | -re "$gdb_prompt $" { | |
88 | if { $ok } { | |
89 | pass $cmd | |
90 | } else { | |
91 | fail $cmd | |
92 | } | |
93 | } | |
94 | } | |
7339a42e | 95 | |
4694da01 TT |
96 | gdb_test_no_output "thread name zardoz" "give a name to the thread" |
97 | gdb_test "info threads" ".*zardoz.*" "check thread name" | |
98 | ||
7339a42e JJ |
99 | set message "second continue" |
100 | gdb_test_multiple "continue" "second continue" { | |
101 | -re "error:.*$gdb_prompt $" { | |
102 | fail "$message" | |
103 | } | |
104 | -re "Continuing" { | |
105 | pass "$message" | |
106 | } | |
107 | } | |
108 | ||
57380f4e DJ |
109 | # Wait another second. If the program stops on its own, GDB has failed |
110 | # to handle duplicate SIGINTs sent to multiple threads. | |
111 | set failed 0 | |
112 | remote_expect host 1 { | |
113 | -re "\\\[New \[^\]\]*\\\]\r\n" { | |
114 | exp_continue -continue_timer | |
115 | } | |
116 | -re "\\\[\[^\]\]* exited\\\]\r\n" { | |
117 | exp_continue -continue_timer | |
118 | } | |
57380f4e DJ |
119 | -re "Program received signal SIGINT.*$gdb_prompt $" { |
120 | if { $failed == 0 } { | |
121 | fail "check for duplicate SIGINT" | |
122 | } | |
123 | send_gdb "continue\n" | |
124 | set failed 1 | |
125 | exp_continue | |
126 | } | |
127 | timeout { | |
128 | if { $failed == 0 } { | |
129 | pass "check for duplicate SIGINT" | |
130 | } | |
131 | } | |
132 | } | |
133 | ||
7339a42e | 134 | # Send another Ctrl-C and verify that we can do info threads and quit |
4013522b | 135 | send_gdb "\003" |
7339a42e JJ |
136 | set message "stop threads 2" |
137 | gdb_test_multiple "" "stop threads 2" { | |
138 | -re "\\\[New \[^\]\]*\\\]\r\n" { | |
139 | exp_continue | |
140 | } | |
141 | -re "\\\[\[^\]\]* exited\\\]\r\n" { | |
142 | exp_continue | |
143 | } | |
7339a42e | 144 | -re "Program received signal SIGINT.*$gdb_prompt $" { |
fc133f24 MS |
145 | pass "$message" |
146 | } | |
147 | timeout { | |
148 | fail "$message (timeout)" | |
7339a42e JJ |
149 | } |
150 | } | |
151 | ||
152 | gdb_test_multiple "quit" "GDB exits after stopping multithreaded program" { | |
b8fa0bfa | 153 | -re "Quit anyway\\? \\(y or n\\) $" { |
7339a42e JJ |
154 | send_gdb "y\n" |
155 | exp_continue | |
156 | } | |
157 | eof { | |
158 | pass "GDB exits after stopping multithreaded program" | |
159 | } | |
160 | timeout { | |
161 | fail "GDB exits after stopping multithreaded program (timeout)" | |
162 | } | |
163 | } | |
164 |