* config/sh/tm-sh.h (BELIEVE_PCC_PROMOTION): Define, so that
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.hp / attach2.exp
1 # attach.exp -- Expect script to test attaching to a threaded pgm
2 # Copyright (C) 1992 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 2 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, write to the Free Software
16 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
17
18 # Please email any bugs, comments, and/or additions to this file to:
19 # bug-gdb@prep.ai.mit.edu
20
21 # use this to debug:
22 #
23 #log_user 1
24
25 # Temporarily comment out - hanging
26 #return 0
27
28 if $tracelevel then {
29 strace $tracelevel
30 }
31
32 # Thread stuff is _slow_; prepare for long waits.
33 #
34 # Further, this test has some "null" lines designed
35 # to consume output from gdb that was too late to be
36 # matched (sequence is "gdb_test" sends; timeout and
37 # on to next send; result finally comes in; mismatch).
38 #
39 # The null command is 'gdb_test "p \$pc" ".*" ""'
40 # NOTE: this command undoes any up/down stuff!
41 #
42 proc pre_timeout { how_long } {
43 global timeout
44
45 set timeout [expr "$timeout + $how_long"]
46 }
47
48 proc post_timeout {} {
49 global timeout
50 global oldtimeout
51
52 set timeout $oldtimeout
53 gdb_test "p \$pc" ".*" ""
54 }
55
56 if { ![istarget "hppa*-*-hpux10.30"] && ![istarget "hppa*-*-hpux11.*"] } {
57 verbose "HPUX thread test ignored for non-hppa or pre-HP/UX-10.30 targets."
58 return 0
59 }
60
61 # We used to wait 5 seconds , but tiamat is faster than
62 # hydra...or is it that the OS allocates time differently(?).
63 #
64 set delay 5
65 if { ![istarget "hppa*-*-hpux11.*"] } {
66 set delay 45
67 }
68
69 set testfile quicksort
70 set srcfile ${srcdir}/${subdir}/${testfile}.c
71 set binfile ${objdir}/${subdir}/${testfile}
72
73 if [get_compiler_info ${binfile}] {
74 return -1
75 }
76
77 set oldtimeout $timeout
78 #set timeout [expr "$timeout + 100"]
79 set oldverbose $verbose
80 #set verbose 40
81
82 # To build the executable we need to link against the thread library.
83 #
84 # cc -Ae -g -o quicksort -lpthread quicksort.c
85 #
86 #remote_exec build "${srcfile} -Ae -g -lpthread -o ${binfile}"
87 #gdb_compile "${srcfile} -Ae -g -lpthread -o ${binfile}"
88
89 if {$gcc_compiled == 0} {
90 set additional_flags "additional_flags=-Ae"
91 } else {
92 set additional_flags ""
93 }
94
95 if { [gdb_compile "${srcdir}/${subdir}/${testfile}.c" "${binfile}.o" object [list debug $additional_flags]] != "" } {
96 gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
97 }
98 remote_exec build "ld /usr/ccs/lib/crt0.o ${binfile}.o -lcl -lpthread -lc /opt/langtools/lib/end.o -o ${binfile}"
99
100
101 gdb_exit
102 gdb_start
103 gdb_reinitialize_dir $srcdir/$subdir
104
105 # Start the application running and get its pid.
106 # Then we wait for it to get started and attach.
107 #
108 set testpid [eval exec $binfile 1 &]
109 exec sleep $delay
110
111 # Now attach to the file.
112 #
113 pre_timeout 100
114 gdb_test "attach $testpid" ".*Attaching to process.*Reading symbols from.*done.*" "attach to target"
115 post_timeout
116
117 # Wait for things to quiesce.
118 #
119 exec sleep 0
120
121 send_gdb "bt\n"
122
123 set do_return 0
124 set do_go_to_118 0
125 pre_timeout 400
126 gdb_expect {
127 -re ".*sleep.*work_init.*main.*$gdb_prompt $" {
128 pass "at expected location"
129 }
130 -re ".*drand48.*$gdb_prompt $" {
131 set do_go_to_118 1
132 }
133 -re ".*pthread_mutex_lock.*$gdb_prompt $" {
134 set do_go_to_118 1
135 }
136 -re ".*pthread_mutex_unlock.*$gdb_prompt $" {
137 set do_go_to_118 1
138 }
139 -re ".*main.*$gdb_prompt $" {
140 set do_go_to_118 1
141 }
142 -re ".*No stack.*$gdb_prompt $" {
143 fail "Failed attach, change wait amount down, rest would fail"
144 set do_return 1
145 }
146 -re ".*$gdb_prompt $" {
147 # Who knows?
148 #
149 set do_go_to_118 1
150 }
151 timeout {
152 set do_return 1
153 fail "timeout on bt, avoiding rest of test"
154 }
155 }
156 post_timeout
157
158 # Too late; just give up.
159 #
160 if { $do_return } {
161 set timeout $oldtimeout
162 set verbose $oldverbose
163 return 0
164 }
165
166 # Maybe too early--set a temp break and continue.
167 # We have to set this on both paths, so that we can
168 # know what numbers breakpoints will be.
169 #
170 gdb_test "tb 118" ".*Breakpoint 1.*118.*" ""
171 if { $do_go_to_118 } {
172 pre_timeout 100
173 send_gdb "c\n"
174 gdb_expect {
175 -re ".*at.*118.*118.*$gdb_prompt $" {
176 # Ok, just keep going
177 }
178 -re ".*Program exited.*$gdb_prompt $" {
179 fail "Attached too late, set wait amount downwards"
180 set timeout $oldtimeout
181 set verbose $oldverbose
182 return 0
183 }
184 -re ".*$gdb_prompt $" {
185 fail "Unexpected result on attach"
186 set timeout $oldtimeout
187 set verbose $oldverbose
188 return 0
189 }
190 timeout {
191 fail "timeout on continue "
192 }
193 }
194 post_timeout
195 }
196
197 # Look at the threads.
198 #
199 pre_timeout 100
200 gdb_test "info thread" ".*7.*6.*5.*4.*3.*2.*\\\* 1.*thread.*" "first info thread"
201 post_timeout
202
203 # We expect to be inside the "sleep" call, so check that.
204 #
205 if { [expr "!$do_go_to_118"] } {
206 gdb_test "up" ".*\#1.*nanosleep.*" "up 1"
207 gdb_test "up" ".*\#2.*sleep.*" "up 2"
208 pre_timeout 100
209 gdb_test "up" ".*\#3.*work_init.*$testfile.*c:118.*sleep.*" "up 3"
210 post_timeout
211 } else {
212 send_user "Skipped three tests\n"
213 }
214
215 # Get out of that call.
216 #
217 gdb_test "b 120" ".*Breakpoint 2.*120.*" "set bp"
218 pre_timeout 100
219 gdb_test "c" ".*Breakpoint 2.*at.*120.*" "hit bp"
220 post_timeout
221
222 # Look at the threads.
223 #
224 pre_timeout 100
225 gdb_test "info thread" ".*7.*6.*5.*4.*3.*2.*1.*thread.*$testfile.*c*120.*" "2nd info thread"
226 post_timeout
227
228 # Do some more stuff, to make sure we can
229 #
230 gdb_test "thread 3" ".*Switching to.*thread.*ksleep.*" "switch thread"
231
232 gdb_test "up" ".*_lwp_cond_timedwait.*" "up 5"
233 gdb_test "up" ".*pthread_cond_wait.*" "up 6"
234 gdb_test "up" ".*\#3.*worker.*144.*" "up 7"
235 gdb_test "up" ".*__pthread_exit.*" "up 8"
236 gdb_test "up" ".*Initial.*cannot go up.*" "found thread base"
237
238 gdb_test "b 145 thr 3" ".*Breakpoint 3.*145.*" "thread-specific bp"
239 gdb_test "i b" ".*2.*breakpoint.*at.*120.*3.*breakpoint.*at.*145 thread 3.*" "show thread-specific bp"
240 gdb_test "del 2" ".*" ""
241
242 gdb_test "c" ".*Breakpoint 3.*145.*" "hit thread-specific bp"
243 gdb_test "i th" ".*\\\* 3.*145.*" "at correct thread"
244
245 pre_timeout 100
246 gdb_test "n" ".*146.*" "next from thread-specific bp"
247 post_timeout
248
249 gdb_test "d 3" ".*" ""
250 gdb_test "c" ".*Program exited normally\..*" "run to finish"
251
252 # Done!
253 #
254 gdb_exit
255
256 set timeout $oldtimeout
257 set verbose $oldverbose
258
259 # execute_anywhere "rm -f ${binfile}"
260 #
261 return 0
262
263
This page took 0.034355 seconds and 4 git commands to generate.