]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.threads/manythreads.exp
* linux-nat.c (count_events_callback, select_event_lwp_callback): Only
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.threads / manythreads.exp
CommitLineData
7339a42e 1# manythreads.exp -- Expect script to test stopping many threads
9b254dd1 2# Copyright (C) 2004, 2006, 2007, 2008 Free Software Foundation, Inc.
7339a42e
JJ
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
e22f8b7c 6# the Free Software Foundation; either version 3 of the License, or
7339a42e 7# (at your option) any later version.
e22f8b7c 8#
7339a42e
JJ
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.
e22f8b7c 13#
7339a42e 14# You should have received a copy of the GNU General Public License
e22f8b7c 15# along with this program. If not, see <http://www.gnu.org/licenses/>.
7339a42e
JJ
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
4013522b
MC
62after 1000
63send_gdb "\003"
7339a42e
JJ
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
4339e69e
DJ
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}
7339a42e
JJ
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
4013522b
MC
114after 1000
115send_gdb "\003"
7339a42e
JJ
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 $" {
fc133f24
MS
128 pass "$message"
129 }
130 timeout {
131 fail "$message (timeout)"
7339a42e
JJ
132 }
133}
134
135gdb_test_multiple "quit" "GDB exits after stopping multithreaded program" {
b21991b0 136 -re "The program is running. Quit anyway \\(and kill it\\)\\? \\(y or n\\) $" {
7339a42e
JJ
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