1 # manythreads.exp -- Expect script to test stopping many threads
2 # Copyright (C) 2004, 2006, 2007, 2008 Free Software Foundation, Inc.
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
6 # the Free Software Foundation; either version 3 of the License, or
7 # (at your option) any later version.
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.
14 # You should have received a copy of the GNU General Public License
15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
17 # This file was written by Jeff Johnston. (jjohnstn@redhat.com)
26 set testfile "manythreads"
27 set srcfile ${testfile}.c
28 set binfile ${objdir}/${subdir}/${testfile}
30 if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable [list debug "incdir=${objdir}"]] != "" } {
35 gdb_reinitialize_dir $srcdir/$subdir
37 gdb_test "set print sevenbit-strings" ""
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
44 if ![istarget "*-*-ultrix*"] then {
45 gdb_test "shell stty intr '^C'" ""
48 set message "first continue"
49 gdb_test_multiple "continue" "first continue" {
50 -re "error:.*$gdb_prompt $" {
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 { } }
62 # Send a Ctrl-C and verify that we can do info threads and continue
64 set message "stop threads 1"
65 gdb_test_multiple "" "stop threads 1" {
66 -re "\\\[New \[^\]\]*\\\]\r\n" {
69 -re "\\\[\[^\]\]* exited\\\]\r\n" {
72 -re "Thread \[^\n\]* executing\r\n" {
75 -re "Program received signal SIGINT.*$gdb_prompt $" {
79 fail "$message (timeout)"
83 set cmd "info threads"
85 gdb_test_multiple $cmd $cmd {
91 # Eat this line and continue, to prevent the buffer overflowing.
103 set message "second continue"
104 gdb_test_multiple "continue" "second continue" {
105 -re "error:.*$gdb_prompt $" {
113 # Wait another second. If the program stops on its own, GDB has failed
114 # to handle duplicate SIGINTs sent to multiple threads.
116 remote_expect host 1 {
117 -re "\\\[New \[^\]\]*\\\]\r\n" {
118 exp_continue -continue_timer
120 -re "\\\[\[^\]\]* exited\\\]\r\n" {
121 exp_continue -continue_timer
123 -re "Thread \[^\n\]* executing\r\n" {
124 exp_continue -continue_timer
126 -re "Program received signal SIGINT.*$gdb_prompt $" {
127 if { $failed == 0 } {
128 fail "check for duplicate SIGINT"
130 send_gdb "continue\n"
135 if { $failed == 0 } {
136 pass "check for duplicate SIGINT"
141 # Send another Ctrl-C and verify that we can do info threads and quit
143 set message "stop threads 2"
144 gdb_test_multiple "" "stop threads 2" {
145 -re "\\\[New \[^\]\]*\\\]\r\n" {
148 -re "\\\[\[^\]\]* exited\\\]\r\n" {
151 -re "Thread \[^\n\]* executing\r\n" {
154 -re "Program received signal SIGINT.*$gdb_prompt $" {
158 fail "$message (timeout)"
162 gdb_test_multiple "quit" "GDB exits after stopping multithreaded program" {
163 -re "The program is running. Quit anyway \\(and kill it\\)\\? \\(y or n\\) $" {
168 pass "GDB exits after stopping multithreaded program"
171 fail "GDB exits after stopping multithreaded program (timeout)"