Further cleanup of signal-while-stepping-over-bp-other-thread.c.
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.threads / manythreads.exp
1 # manythreads.exp -- Expect script to test stopping many threads
2 # Copyright (C) 2004-2014 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 # This file was written by Jeff Johnston. (jjohnstn@redhat.com)
18
19
20 standard_testfile
21
22 set opts { debug }
23 if [info exists DEBUG] {
24 # make check RUNTESTFLAGS='gdb.threads/manythreads.exp DEBUG=1'
25 lappend opts "additional_flags=-DDEBUG"
26 }
27
28 if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable $opts] != "" } {
29 return -1
30 }
31
32 clean_restart ${binfile}
33 gdb_test_no_output "set print sevenbit-strings"
34 runto_main
35
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
39 # doesn't use vfork).
40 if ![istarget "*-*-ultrix*"] then {
41 gdb_test "shell stty intr '^C'" ".*"
42 }
43
44 set message "first continue"
45 gdb_test_multiple "continue" "first continue" {
46 -re "error:.*$gdb_prompt $" {
47 fail "$message"
48 }
49 -re "Continuing" {
50 pass "$message"
51 }
52 }
53
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 { } }
57
58 # Send a Ctrl-C and verify that we can do info threads and continue
59 send_gdb "\003"
60 set message "stop threads 1"
61 gdb_test_multiple "" "stop threads 1" {
62 -re "\\\[New \[^\]\]*\\\]\r\n" {
63 exp_continue
64 }
65 -re "\\\[\[^\]\]* exited\\\]\r\n" {
66 exp_continue
67 }
68 -re "Program received signal SIGINT.*$gdb_prompt $" {
69 pass "$message"
70 }
71 timeout {
72 fail "$message (timeout)"
73 }
74 }
75
76 set cmd "info threads"
77 set ok 0
78 gdb_test_multiple $cmd $cmd {
79 -re " 1 *Thread " {
80 set ok 1
81 exp_continue
82 }
83 -re ".*\r\n" {
84 # Eat this line and continue, to prevent the buffer overflowing.
85 exp_continue
86 }
87 -re "$gdb_prompt $" {
88 if { $ok } {
89 pass $cmd
90 } else {
91 fail $cmd
92 }
93 }
94 }
95
96 gdb_test_no_output "thread name zardoz" "give a name to the thread"
97 gdb_test "info threads" ".*zardoz.*" "check thread name"
98
99 set message "second continue"
100 gdb_test_multiple "continue" "second continue" {
101 -re "error:.*$gdb_prompt $" {
102 fail "$message"
103 }
104 -re "Continuing" {
105 pass "$message"
106 }
107 }
108
109 # Wait another second. If the program stops on its own, GDB has failed
110 # to handle duplicate SIGINTs sent to multiple threads.
111 set failed 0
112 remote_expect host 1 {
113 -re "\\\[New \[^\]\]*\\\]\r\n" {
114 exp_continue -continue_timer
115 }
116 -re "\\\[\[^\]\]* exited\\\]\r\n" {
117 exp_continue -continue_timer
118 }
119 -re "Program received signal SIGINT.*$gdb_prompt $" {
120 if { $failed == 0 } {
121 fail "check for duplicate SIGINT"
122 }
123 send_gdb "continue\n"
124 set failed 1
125 exp_continue
126 }
127 timeout {
128 if { $failed == 0 } {
129 pass "check for duplicate SIGINT"
130 }
131 }
132 }
133
134 # Send another Ctrl-C and verify that we can do info threads and quit
135 send_gdb "\003"
136 set message "stop threads 2"
137 gdb_test_multiple "" "stop threads 2" {
138 -re "\\\[New \[^\]\]*\\\]\r\n" {
139 exp_continue
140 }
141 -re "\\\[\[^\]\]* exited\\\]\r\n" {
142 exp_continue
143 }
144 -re "Program received signal SIGINT.*$gdb_prompt $" {
145 pass "$message"
146 }
147 timeout {
148 fail "$message (timeout)"
149 }
150 }
151
152 gdb_test_multiple "quit" "GDB exits after stopping multithreaded program" {
153 -re "Quit anyway\\? \\(y or n\\) $" {
154 send_gdb "y\n"
155 exp_continue
156 }
157 eof {
158 pass "GDB exits after stopping multithreaded program"
159 }
160 timeout {
161 fail "GDB exits after stopping multithreaded program (timeout)"
162 }
163 }
164
This page took 0.035557 seconds and 4 git commands to generate.