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)
25 set testfile "manythreads"
26 set srcfile ${testfile}.c
27 set binfile ${objdir}/${subdir}/${testfile}
29 if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable [list debug "incdir=${objdir}"]] != "" } {
34 gdb_reinitialize_dir $srcdir/$subdir
36 gdb_test_no_output "set print sevenbit-strings"
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
43 if ![istarget "*-*-ultrix*"] then {
44 gdb_test "shell stty intr '^C'" ""
47 set message "first continue"
48 gdb_test_multiple "continue" "first continue" {
49 -re "error:.*$gdb_prompt $" {
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.
59 remote_expect host 1 { timeout { } }
61 # Send a Ctrl-C and verify that we can do info threads and continue
63 set message "stop threads 1"
64 gdb_test_multiple "" "stop threads 1" {
65 -re "\\\[New \[^\]\]*\\\]\r\n" {
68 -re "\\\[\[^\]\]* exited\\\]\r\n" {
71 -re "Thread \[^\n\]* executing\r\n" {
74 -re "Program received signal SIGINT.*$gdb_prompt $" {
78 fail "$message (timeout)"
82 set cmd "info threads"
84 gdb_test_multiple $cmd $cmd {
90 # Eat this line and continue, to prevent the buffer overflowing.
102 set message "second continue"
103 gdb_test_multiple "continue" "second continue" {
104 -re "error:.*$gdb_prompt $" {
112 # Wait another second. If the program stops on its own, GDB has failed
113 # to handle duplicate SIGINTs sent to multiple threads.
115 remote_expect host 1 {
116 -re "\\\[New \[^\]\]*\\\]\r\n" {
117 exp_continue -continue_timer
119 -re "\\\[\[^\]\]* exited\\\]\r\n" {
120 exp_continue -continue_timer
122 -re "Thread \[^\n\]* executing\r\n" {
123 exp_continue -continue_timer
125 -re "Program received signal SIGINT.*$gdb_prompt $" {
126 if { $failed == 0 } {
127 fail "check for duplicate SIGINT"
129 send_gdb "continue\n"
134 if { $failed == 0 } {
135 pass "check for duplicate SIGINT"
140 # Send another Ctrl-C and verify that we can do info threads and quit
142 set message "stop threads 2"
143 gdb_test_multiple "" "stop threads 2" {
144 -re "\\\[New \[^\]\]*\\\]\r\n" {
147 -re "\\\[\[^\]\]* exited\\\]\r\n" {
150 -re "Thread \[^\n\]* executing\r\n" {
153 -re "Program received signal SIGINT.*$gdb_prompt $" {
157 fail "$message (timeout)"
161 gdb_test_multiple "quit" "GDB exits after stopping multithreaded program" {
162 -re "Quit anyway\\? \\(y or n\\) $" {
167 pass "GDB exits after stopping multithreaded program"
170 fail "GDB exits after stopping multithreaded program (timeout)"