* gdb.base/bitfields2.exp: New test.
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / pending.exp
1 # Copyright 2003, 2004
2 # 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 # This file was created by Jeff Johnston. (jjohnstn@redhat.com)
22 # The shared library compilation portion was copied from shlib-call.exp which was
23 # written by Elena Zannoni (ezannoni@redhat.com).
24
25 if $tracelevel then {
26 strace $tracelevel
27 }
28
29 #
30 # test running programs
31 #
32 set prms_id 0
33 set bug_id 0
34
35 # are we on a target board?
36 if ![isnative] then {
37 return 0
38 }
39
40 set testfile "pending"
41 set libfile "pendshr"
42 set srcfile ${testfile}.c
43 set binfile ${objdir}/${subdir}/${testfile}
44
45 if [get_compiler_info ${binfile}] {
46 return -1
47 }
48
49 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}.o" object {debug}] != "" } {
50 gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
51 }
52
53 # Build the shared libraries this test case needs.
54 #
55
56 if {$gcc_compiled == 0} {
57 if [istarget "hppa*-hp-hpux*"] then {
58 set additional_flags "additional_flags=+z"
59 } elseif { [istarget "mips-sgi-irix*"] } {
60 # Disable SGI compiler's implicit -Dsgi
61 set additional_flags "additional_flags=-Usgi"
62 } else {
63 # don't know what the compiler is...
64 set additional_flags ""
65 }
66 } else {
67 if { ([istarget "powerpc*-*-aix*"]
68 || [istarget "rs6000*-*-aix*"]) } {
69 set additional_flags ""
70 } else {
71 set additional_flags "additional_flags=-fpic"
72 }
73 }
74
75 if {[gdb_compile "${srcdir}/${subdir}/${libfile}.c" "${objdir}/${subdir}/${libfile}.o" object [list debug $additional_flags]] != ""} {
76 gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
77 }
78
79 if [istarget "hppa*-*-hpux*"] {
80 remote_exec build "ld -b ${objdir}/${subdir}/${libfile}.o -o ${objdir}/${subdir}/${libfile}.sl"
81 } else {
82 set additional_flags "additional_flags=-shared"
83 if {[gdb_compile "${objdir}/${subdir}/${libfile}.o" "${objdir}/${subdir}/${libfile}.sl" executable [list debug $additional_flags]] != ""} {
84 gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
85 }
86 }
87
88 if { ($gcc_compiled
89 && ([istarget "powerpc*-*-aix*"]
90 || [istarget "rs6000*-*-aix*"] )) } {
91 set additional_flags "additional_flags=-L${objdir}/${subdir}"
92 } elseif { [istarget "mips-sgi-irix*"] } {
93 set additional_flags "additional_flags=-rpath ${objdir}/${subdir}"
94 } else {
95 set additional_flags ""
96 }
97 if {[gdb_compile "${objdir}/${subdir}/${testfile}.o ${objdir}/${subdir}/${libfile}.sl" "${binfile}" executable [list debug $additional_flags]] != ""} {
98 gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
99 }
100
101 gdb_exit
102 gdb_start
103 gdb_reinitialize_dir $srcdir/$subdir
104 gdb_load ${binfile}
105
106 if [target_info exists gdb_stub] {
107 gdb_step_for_stub;
108 }
109 #
110 # Test setting, querying, and modifying pending breakpoints
111 #
112
113 gdb_test_multiple "break pendfunc1" "set pending breakpoint" {
114 -re ".*Make breakpoint pending.*y or \\\[n\\\]. $" {
115 gdb_test "y" "Breakpoint.*pendfunc1.*pending." "set pending breakpoint"
116 }
117 }
118
119 gdb_test "info break" \
120 "Num Type\[ \]+Disp Enb Address\[ \]+What.*
121 \[0-9\]+\[\t \]+breakpoint keep y.*PENDING.*pendfunc1.*" \
122 "single pending breakpoint info"
123
124 #
125 # Test breaking at existing function
126 #
127
128 set mainline [gdb_get_line_number "break main here"]
129
130 gdb_test "break main" \
131 "Breakpoint.*at.* file .*$srcfile, line $mainline.*" \
132 "breakpoint function"
133
134 gdb_test "info break" \
135 "Num Type\[ \]+Disp Enb Address\[ \]+What.*
136 \[0-9\]+\[\t \]+breakpoint keep y.*PENDING.*pendfunc1.*
137 \[0-9\]+\[\t \]+breakpoint keep y.* in main at .*$srcfile:$mainline" \
138 "pending plus real breakpoint info"
139
140
141 #
142 # Test not setting a pending breakpoint
143 #
144 gdb_test_multiple "break pendfunc2" "Don't set pending breakpoint" {
145 -re ".*Make breakpoint pending.*y or \\\[n\\\]. $" {
146 gdb_test "n" "" "Don't set pending breakpoint"
147 }
148 }
149
150 #
151 # Add condition to pending breakpoint
152 #
153
154 gdb_test "condition 1 k == 1" ""
155
156 gdb_test "info break" \
157 "Num Type\[ \]+Disp Enb Address\[ \]+What.*
158 \[0-9\]+\[\t \]+breakpoint keep y.*PENDING.*pendfunc1.*
159 \[\t \]+stop only if k == 1.*
160 \[0-9\]+\[\t \]+breakpoint keep y.* in main at .*$srcfile:$mainline" \
161 "pending plus condition"
162
163 #
164 # Disable pending breakpoint
165 #
166
167 gdb_test "disable 1" ""
168
169 gdb_test "info break" \
170 "Num Type\[ \]+Disp Enb Address\[ \]+What.*
171 \[0-9\]+\[\t \]+breakpoint keep n.*PENDING.*pendfunc1.*
172 \[\t \]+stop only if k == 1.*
173 \[0-9\]+\[\t \]+breakpoint keep y.* in main at .*$srcfile:$mainline" \
174 "pending disabled"
175
176 #
177 # Add commands to pending breakpoint
178 #
179 gdb_test "commands 1\nprint k\nend" "" \
180 "Set commands for pending breakpoint"
181
182 gdb_test "info break" \
183 "Num Type\[ \]+Disp Enb Address\[ \]+What.*
184 \[0-9\]+\[\t \]+breakpoint keep n.*PENDING.*pendfunc1.*
185 \[\t \]+stop only if k == 1.*
186 \[\t \]+print k.*
187 \[0-9\]+\[\t \]+breakpoint keep y.* in main at .*$srcfile:$mainline" \
188 "pending disabled plus commands"
189
190 #
191 # Try a pending break for a line in a source file with a condition
192 #
193
194 gdb_test_multiple "break pendshr.c:26 if x > 3" "Set pending breakpoint 2" {
195 -re ".*Make breakpoint pending.*y or \\\[n\\\]. $" {
196 gdb_test "y" "Breakpoint.*pendshr.c:26.*pending." \
197 "Set pending breakpoint 2"
198 }
199 }
200
201 gdb_test "info break" \
202 "Num Type\[ \]+Disp Enb Address\[ \]+What.*
203 \[0-9\]+\[\t \]+breakpoint keep n.*PENDING.*pendfunc1.*
204 \[\t \]+stop only if k == 1.*
205 \[\t \]+print k.*
206 \[0-9\]+\[\t \]+breakpoint keep y.* in main at .*$srcfile:$mainline.*
207 \[0-9\]+\[\t \]+breakpoint keep y.*PENDING.*pendshr.c:26 if x > 3.*" \
208 "multiple pending breakpoints"
209
210
211 #
212 # Try a pending break for a line in a source file with ignore count:
213 #
214
215 gdb_test_multiple "break pendshr.c:27" "Set pending breakpoint 3" {
216 -re ".*Make breakpoint pending.*y or \\\[n\\\]. $" {
217 gdb_test "y" "Breakpoint.*pendshr.c:27.*pending." \
218 "Set pending breakpoint 3"
219 }
220 }
221
222 gdb_test {ignore $bpnum 2} "Will ignore next 2 crossings of breakpoint .*" \
223 "set ignore count on pending breakpoint 3"
224
225 gdb_test "info break" \
226 "Num Type\[ \]+Disp Enb Address\[ \]+What.*
227 \[0-9\]+\[\t \]+breakpoint keep n.*PENDING.*pendfunc1.*
228 \[\t \]+stop only if k == 1.*
229 \[\t \]+print k.*
230 \[0-9\]+\[\t \]+breakpoint keep y.* in main at .*$srcfile:$mainline.*
231 \[0-9\]+\[\t \]+breakpoint keep y.*PENDING.*pendshr.c:26 if x > 3.*
232 \[0-9\]+\[\t \]+breakpoint keep y.*PENDING.*pendshr.c:27.*ignore next 2 hits.*" \
233 "multiple pending breakpoints 2"
234
235 #
236 # Run to main which should resolve a pending breakpoint
237 #
238
239 gdb_test "run" \
240 "Breakpoint.*at.*
241 Pending breakpoint \"pendshr.c:26 if x > 3\" resolved.*
242 Breakpoint.*, main.*$mainline.*" \
243 "running to main"
244
245 #
246 # Re-enable the first pending breakpoint which should resolve
247 #
248
249 gdb_test "enable 1" \
250 "Breakpoint.*at.*
251 Pending breakpoint \"pendfunc1.* resolved.*" \
252 "re-enabling pending breakpoint that can resolve instantly"
253
254 #
255 # Continue to verify conditionals and commands for breakpoints are honored
256 #
257
258 gdb_test "continue" \
259 ".*Breakpoint.*pendfunc1.*at.*pendshr.c:26.*4;" \
260 "continue to resolved breakpoint 2"
261
262 gdb_test "continue" \
263 ".*Breakpoint.*pendfunc1.*at.*pendshr.c:26.*
264 \[$\]1 = 1." \
265 "continue to resolved breakpoint 1"
266
267 #
268 # Disable the other two breakpoints, and continue to the one with
269 # the ignore count. Make sure you hit it the third time, x should
270 # be 3 then.
271 #
272
273 gdb_test "disable 7" "" "Disable other breakpoints"
274 gdb_test "disable 5" "" "Disable other breakpoints"
275
276 gdb_test "continue" \
277 {.*Breakpoint.*pendfunc1.*\(x=3\) at.*pendshr.c:27.*printf.*;} \
278 "continue to resolved breakpoint 3"
279
280 delete_breakpoints
281
282 gdb_breakpoint "main"
283
284 #
285 # Set non-existent pending breakpoint
286 #
287 gdb_test_multiple "break imaginary" "set imaginary pending breakpoint" {
288 -re ".*Make breakpoint pending.*y or \\\[n\\\]. $" {
289 gdb_test "y" "Breakpoint.*imaginary.*pending." \
290 "set imaginary pending breakpoint"
291 }
292 }
293
294 #
295 # rerun program and make sure that any pending breakpoint remains and no
296 # error messages are issued for the missing function
297 #
298
299 rerun_to_main
300
301 gdb_test "info break" \
302 "Num Type\[ \]+Disp Enb Address\[ \]+What.*
303 \[0-9\]+\[\t \]+breakpoint keep y.* in main at .*$srcfile:$mainline.*
304 \[0-9\]+\[\t \]+breakpoint keep y.*PENDING.*imaginary.*" \
305 "verify pending breakpoint after restart"
This page took 0.035848 seconds and 4 git commands to generate.