1 # manythreads.exp -- Expect script to test stopping many threads
2 # Copyright (C) 2004, 2006, 2007, 2008, 2009, 2010
3 # 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/>.
18 # This file was written by Jeff Johnston. (jjohnstn@redhat.com)
27 set testfile "manythreads"
28 set srcfile ${testfile}.c
29 set binfile ${objdir}/${subdir}/${testfile}
31 if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable [list debug "incdir=${objdir}"]] != "" } {
36 gdb_reinitialize_dir $srcdir/$subdir
38 gdb_test "set print sevenbit-strings" ""
41 # We'll need this when we send_gdb a ^C to GDB. Need to do it before we
42 # run the program and gdb starts saving and restoring tty states.
43 # On Ultrix, we don't need it and it is really slow (because shell_escape
45 if ![istarget "*-*-ultrix*"] then {
46 gdb_test "shell stty intr '^C'" ""
49 set message "first continue"
50 gdb_test_multiple "continue" "first continue" {
51 -re "error:.*$gdb_prompt $" {
59 # Wait one second. This is better than the TCL "after" command, because
60 # we don't lose GDB's output while we do it.
61 remote_expect host 1 { timeout { } }
63 # Send a Ctrl-C and verify that we can do info threads and continue
65 set message "stop threads 1"
66 gdb_test_multiple "" "stop threads 1" {
67 -re "\\\[New \[^\]\]*\\\]\r\n" {
70 -re "\\\[\[^\]\]* exited\\\]\r\n" {
73 -re "Thread \[^\n\]* executing\r\n" {
76 -re "Program received signal SIGINT.*$gdb_prompt $" {
80 fail "$message (timeout)"
84 set cmd "info threads"
86 gdb_test_multiple $cmd $cmd {
92 # Eat this line and continue, to prevent the buffer overflowing.
104 set message "second continue"
105 gdb_test_multiple "continue" "second continue" {
106 -re "error:.*$gdb_prompt $" {
114 # Wait another second. If the program stops on its own, GDB has failed
115 # to handle duplicate SIGINTs sent to multiple threads.
117 remote_expect host 1 {
118 -re "\\\[New \[^\]\]*\\\]\r\n" {
119 exp_continue -continue_timer
121 -re "\\\[\[^\]\]* exited\\\]\r\n" {
122 exp_continue -continue_timer
124 -re "Thread \[^\n\]* executing\r\n" {
125 exp_continue -continue_timer
127 -re "Program received signal SIGINT.*$gdb_prompt $" {
128 if { $failed == 0 } {
129 fail "check for duplicate SIGINT"
131 send_gdb "continue\n"
136 if { $failed == 0 } {
137 pass "check for duplicate SIGINT"
142 # Send another Ctrl-C and verify that we can do info threads and quit
144 set message "stop threads 2"
145 gdb_test_multiple "" "stop threads 2" {
146 -re "\\\[New \[^\]\]*\\\]\r\n" {
149 -re "\\\[\[^\]\]* exited\\\]\r\n" {
152 -re "Thread \[^\n\]* executing\r\n" {
155 -re "Program received signal SIGINT.*$gdb_prompt $" {
159 fail "$message (timeout)"
163 gdb_test_multiple "quit" "GDB exits after stopping multithreaded program" {
164 -re "Quit anyway\\? \\(y or n\\) $" {
169 pass "GDB exits after stopping multithreaded program"
172 fail "GDB exits after stopping multithreaded program (timeout)"