1# manythreads.exp -- Expect script to test stopping many threads 2# Copyright (C) 2004, 2006, 2007 Free Software Foundation, Inc. 3 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. 8# 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. 13# 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/>. 16 17# Please email any bugs, comments, and/or additions to this file to: 18# bug-gdb@prep.ai.mit.edu 19 20# This file was written by Jeff Johnston. (jjohnstn@redhat.com) 21 22if $tracelevel then { 23 strace $tracelevel 24} 25 26set prms_id 0 27set bug_id 0 28 29set testfile "manythreads" 30set srcfile ${testfile}.c 31set binfile ${objdir}/${subdir}/${testfile} 32 33if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable [list debug "incdir=${objdir}"]] != "" } { 34 return -1 35} 36 37gdb_start 38gdb_reinitialize_dir $srcdir/$subdir 39gdb_load ${binfile} 40gdb_test "set print sevenbit-strings" "" 41runto_main 42 43# We'll need this when we send_gdb a ^C to GDB. Need to do it before we 44# run the program and gdb starts saving and restoring tty states. 45# On Ultrix, we don't need it and it is really slow (because shell_escape 46# doesn't use vfork). 47if ![istarget "*-*-ultrix*"] then { 48 gdb_test "shell stty intr '^C'" "" 49} 50 51set message "first continue" 52gdb_test_multiple "continue" "first continue" { 53 -re "error:.*$gdb_prompt $" { 54 fail "$message" 55 } 56 -re "Continuing" { 57 pass "$message" 58 } 59} 60 61# Send a Ctrl-C and verify that we can do info threads and continue 62after 1000 63send_gdb "\003" 64set message "stop threads 1" 65gdb_test_multiple "" "stop threads 1" { 66 -re "\\\[New \[^\]\]*\\\]\r\n" { 67 exp_continue 68 } 69 -re "\\\[\[^\]\]* exited\\\]\r\n" { 70 exp_continue 71 } 72 -re "Thread \[^\n\]* executing\r\n" { 73 exp_continue 74 } 75 -re "Program received signal SIGINT.*$gdb_prompt $" { 76 pass "$message" 77 } 78 timeout { 79 fail "$message (timeout)" 80 } 81} 82 83set cmd "info threads" 84set ok 0 85gdb_test_multiple $cmd $cmd { 86 -re " 1 Thread " { 87 set ok 1 88 exp_continue 89 } 90 -re ".*\r\n" { 91 # Eat this line and continue, to prevent the buffer overflowing. 92 exp_continue 93 } 94 -re "$gdb_prompt $" { 95 if { $ok } { 96 pass $cmd 97 } else { 98 fail $cmd 99 } 100 } 101} 102 103set message "second continue" 104gdb_test_multiple "continue" "second continue" { 105 -re "error:.*$gdb_prompt $" { 106 fail "$message" 107 } 108 -re "Continuing" { 109 pass "$message" 110 } 111} 112 113# Send another Ctrl-C and verify that we can do info threads and quit 114after 1000 115send_gdb "\003" 116set message "stop threads 2" 117gdb_test_multiple "" "stop threads 2" { 118 -re "\\\[New \[^\]\]*\\\]\r\n" { 119 exp_continue 120 } 121 -re "\\\[\[^\]\]* exited\\\]\r\n" { 122 exp_continue 123 } 124 -re "Thread \[^\n\]* executing\r\n" { 125 exp_continue 126 } 127 -re "Program received signal SIGINT.*$gdb_prompt $" { 128 pass "$message" 129 } 130 timeout { 131 fail "$message (timeout)" 132 } 133} 134 135gdb_test_multiple "quit" "GDB exits after stopping multithreaded program" { 136 -re "The program is running. Exit anyway\\? \\(y or n\\) $" { 137 send_gdb "y\n" 138 exp_continue 139 } 140 eof { 141 pass "GDB exits after stopping multithreaded program" 142 } 143 timeout { 144 fail "GDB exits after stopping multithreaded program (timeout)" 145 } 146} 147 148