]>
Commit | Line | Data |
---|---|---|
7339a42e | 1 | # manythreads.exp -- Expect script to test stopping many threads |
0fb0cc75 | 2 | # Copyright (C) 2004, 2006, 2007, 2008, 2009 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 | ||
19 | if $tracelevel then { | |
20 | strace $tracelevel | |
21 | } | |
22 | ||
23 | set prms_id 0 | |
24 | set bug_id 0 | |
25 | ||
26 | set testfile "manythreads" | |
27 | set srcfile ${testfile}.c | |
28 | set binfile ${objdir}/${subdir}/${testfile} | |
29 | ||
30 | if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable [list debug "incdir=${objdir}"]] != "" } { | |
31 | return -1 | |
32 | } | |
33 | ||
34 | gdb_start | |
35 | gdb_reinitialize_dir $srcdir/$subdir | |
36 | gdb_load ${binfile} | |
37 | gdb_test "set print sevenbit-strings" "" | |
38 | runto_main | |
39 | ||
40 | # We'll need this when we send_gdb a ^C to GDB. Need to do it before we | |
41 | # run the program and gdb starts saving and restoring tty states. | |
42 | # On Ultrix, we don't need it and it is really slow (because shell_escape | |
43 | # doesn't use vfork). | |
44 | if ![istarget "*-*-ultrix*"] then { | |
45 | gdb_test "shell stty intr '^C'" "" | |
46 | } | |
47 | ||
48 | set message "first continue" | |
49 | gdb_test_multiple "continue" "first continue" { | |
50 | -re "error:.*$gdb_prompt $" { | |
51 | fail "$message" | |
52 | } | |
53 | -re "Continuing" { | |
54 | pass "$message" | |
55 | } | |
56 | } | |
57 | ||
57380f4e DJ |
58 | # Wait one second. This is better than the TCL "after" command, because |
59 | # we don't lose GDB's output while we do it. | |
60 | remote_expect host 1 { timeout { } } | |
61 | ||
7339a42e | 62 | # Send a Ctrl-C and verify that we can do info threads and continue |
4013522b | 63 | send_gdb "\003" |
7339a42e JJ |
64 | set message "stop threads 1" |
65 | gdb_test_multiple "" "stop threads 1" { | |
66 | -re "\\\[New \[^\]\]*\\\]\r\n" { | |
67 | exp_continue | |
68 | } | |
69 | -re "\\\[\[^\]\]* exited\\\]\r\n" { | |
70 | exp_continue | |
71 | } | |
72 | -re "Thread \[^\n\]* executing\r\n" { | |
73 | exp_continue | |
74 | } | |
75 | -re "Program received signal SIGINT.*$gdb_prompt $" { | |
76 | pass "$message" | |
77 | } | |
78 | timeout { | |
79 | fail "$message (timeout)" | |
80 | } | |
81 | } | |
82 | ||
4339e69e DJ |
83 | set cmd "info threads" |
84 | set ok 0 | |
85 | gdb_test_multiple $cmd $cmd { | |
86 | -re " 1 Thread " { | |
87 | set ok 1 | |
88 | exp_continue | |
89 | } | |
90 | -re ".*\r\n" { | |
91 | # Eat this line and continue, to prevent the buffer overflowing. | |
92 | exp_continue | |
93 | } | |
94 | -re "$gdb_prompt $" { | |
95 | if { $ok } { | |
96 | pass $cmd | |
97 | } else { | |
98 | fail $cmd | |
99 | } | |
100 | } | |
101 | } | |
7339a42e JJ |
102 | |
103 | set message "second continue" | |
104 | gdb_test_multiple "continue" "second continue" { | |
105 | -re "error:.*$gdb_prompt $" { | |
106 | fail "$message" | |
107 | } | |
108 | -re "Continuing" { | |
109 | pass "$message" | |
110 | } | |
111 | } | |
112 | ||
57380f4e DJ |
113 | # Wait another second. If the program stops on its own, GDB has failed |
114 | # to handle duplicate SIGINTs sent to multiple threads. | |
115 | set failed 0 | |
116 | remote_expect host 1 { | |
117 | -re "\\\[New \[^\]\]*\\\]\r\n" { | |
118 | exp_continue -continue_timer | |
119 | } | |
120 | -re "\\\[\[^\]\]* exited\\\]\r\n" { | |
121 | exp_continue -continue_timer | |
122 | } | |
123 | -re "Thread \[^\n\]* executing\r\n" { | |
124 | exp_continue -continue_timer | |
125 | } | |
126 | -re "Program received signal SIGINT.*$gdb_prompt $" { | |
127 | if { $failed == 0 } { | |
128 | fail "check for duplicate SIGINT" | |
129 | } | |
130 | send_gdb "continue\n" | |
131 | set failed 1 | |
132 | exp_continue | |
133 | } | |
134 | timeout { | |
135 | if { $failed == 0 } { | |
136 | pass "check for duplicate SIGINT" | |
137 | } | |
138 | } | |
139 | } | |
140 | ||
7339a42e | 141 | # Send another Ctrl-C and verify that we can do info threads and quit |
4013522b | 142 | send_gdb "\003" |
7339a42e JJ |
143 | set message "stop threads 2" |
144 | gdb_test_multiple "" "stop threads 2" { | |
145 | -re "\\\[New \[^\]\]*\\\]\r\n" { | |
146 | exp_continue | |
147 | } | |
148 | -re "\\\[\[^\]\]* exited\\\]\r\n" { | |
149 | exp_continue | |
150 | } | |
151 | -re "Thread \[^\n\]* executing\r\n" { | |
152 | exp_continue | |
153 | } | |
154 | -re "Program received signal SIGINT.*$gdb_prompt $" { | |
fc133f24 MS |
155 | pass "$message" |
156 | } | |
157 | timeout { | |
158 | fail "$message (timeout)" | |
7339a42e JJ |
159 | } |
160 | } | |
161 | ||
162 | gdb_test_multiple "quit" "GDB exits after stopping multithreaded program" { | |
b21991b0 | 163 | -re "The program is running. Quit anyway \\(and kill it\\)\\? \\(y or n\\) $" { |
7339a42e JJ |
164 | send_gdb "y\n" |
165 | exp_continue | |
166 | } | |
167 | eof { | |
168 | pass "GDB exits after stopping multithreaded program" | |
169 | } | |
170 | timeout { | |
171 | fail "GDB exits after stopping multithreaded program (timeout)" | |
172 | } | |
173 | } | |
174 |