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