1 # manythreads.exp -- Expect script to test stopping many threads
2 # Copyright (C) 2004-2014 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)
23 if [info exists DEBUG] {
24 # make check RUNTESTFLAGS='gdb.threads/manythreads.exp DEBUG=1'
25 lappend opts "additional_flags=-DDEBUG"
28 if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable $opts] != "" } {
32 clean_restart ${binfile}
33 gdb_test_no_output "set print sevenbit-strings"
36 # We'll need this when we send_gdb a ^C to GDB. Need to do it before we
37 # run the program and gdb starts saving and restoring tty states.
38 # On Ultrix, we don't need it and it is really slow (because shell_escape
40 if ![istarget "*-*-ultrix*"] then {
41 gdb_test "shell stty intr '^C'" ".*"
44 set message "first continue"
45 gdb_test_multiple "continue" "first continue" {
46 -re "error:.*$gdb_prompt $" {
54 # Wait one second. This is better than the TCL "after" command, because
55 # we don't lose GDB's output while we do it.
56 remote_expect host 1 { timeout { } }
58 # Send a Ctrl-C and verify that we can do info threads and continue
60 set message "stop threads 1"
61 gdb_test_multiple "" "stop threads 1" {
62 -re "\\\[New \[^\]\]*\\\]\r\n" {
65 -re "\\\[\[^\]\]* exited\\\]\r\n" {
68 -re "Program received signal SIGINT.*$gdb_prompt $" {
72 fail "$message (timeout)"
76 set cmd "info threads"
78 gdb_test_multiple $cmd $cmd {
84 # Eat this line and continue, to prevent the buffer overflowing.
96 gdb_test_no_output "thread name zardoz" "give a name to the thread"
97 gdb_test "info threads" ".*zardoz.*" "check thread name"
99 set message "second continue"
100 gdb_test_multiple "continue" "second continue" {
101 -re "error:.*$gdb_prompt $" {
109 # Wait another second. If the program stops on its own, GDB has failed
110 # to handle duplicate SIGINTs sent to multiple threads.
112 remote_expect host 1 {
113 -re "\\\[New \[^\]\]*\\\]\r\n" {
114 exp_continue -continue_timer
116 -re "\\\[\[^\]\]* exited\\\]\r\n" {
117 exp_continue -continue_timer
119 -re "Program received signal SIGINT.*$gdb_prompt $" {
120 if { $failed == 0 } {
121 fail "check for duplicate SIGINT"
123 send_gdb "continue\n"
128 if { $failed == 0 } {
129 pass "check for duplicate SIGINT"
134 # Send another Ctrl-C and verify that we can do info threads and quit
136 set message "stop threads 2"
137 gdb_test_multiple "" "stop threads 2" {
138 -re "\\\[New \[^\]\]*\\\]\r\n" {
141 -re "\\\[\[^\]\]* exited\\\]\r\n" {
144 -re "Program received signal SIGINT.*$gdb_prompt $" {
148 fail "$message (timeout)"
152 gdb_test_multiple "quit" "GDB exits after stopping multithreaded program" {
153 -re "Quit anyway\\? \\(y or n\\) $" {
158 pass "GDB exits after stopping multithreaded program"
161 fail "GDB exits after stopping multithreaded program (timeout)"