]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.base/pending.exp
Copyright updates for 2007.
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.base / pending.exp
1 # Copyright 2003, 2004, 2005, 2007 Free Software Foundation, Inc.
2
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 2 of the License, or
6 # (at your option) any later version.
7 #
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
12 #
13 # You should have received a copy of the GNU General Public License
14 # along with this program; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
16
17 # This file was created by Jeff Johnston. (jjohnstn@redhat.com)
18
19 if $tracelevel then {
20 strace $tracelevel
21 }
22
23 #
24 # test running programs
25 #
26 set prms_id 0
27 set bug_id 0
28
29 # are we on a target board?
30 if ![isnative] then {
31 return 0
32 }
33
34 set testfile "pending"
35 set libfile "pendshr"
36 set srcfile $testfile.c
37 set libsrc $srcdir/$subdir/$libfile.c
38 set binfile $objdir/$subdir/$testfile
39 set lib_sl $objdir/$subdir/$libfile.sl
40
41 set lib_opts debug
42 set exec_opts [list debug shlib=$lib_sl]
43
44 if [get_compiler_info ${binfile}] {
45 return -1
46 }
47
48 if { [gdb_compile_shlib $libsrc $lib_sl $lib_opts] != ""
49 || [gdb_compile $srcdir/$subdir/$srcfile $binfile executable $exec_opts] != ""} {
50 untested "Could not compile either $libsrc or $srcdir/$subdir/$srcfile."
51 return -1
52 }
53
54 # Start with a fresh gdb.
55
56 gdb_exit
57 gdb_start
58 gdb_reinitialize_dir $srcdir/$subdir
59 gdb_load ${binfile}
60
61 if [target_info exists gdb_stub] {
62 gdb_step_for_stub;
63 }
64 #
65 # Test setting, querying, and modifying pending breakpoints
66 #
67
68 gdb_test_multiple "break pendfunc1" "set pending breakpoint" {
69 -re ".*Make breakpoint pending.*y or \\\[n\\\]. $" {
70 gdb_test "y" "Breakpoint.*pendfunc1.*pending." "set pending breakpoint"
71 }
72 }
73
74 gdb_test "info break" \
75 "Num Type\[ \]+Disp Enb Address\[ \]+What.*
76 \[0-9\]+\[\t \]+breakpoint keep y.*PENDING.*pendfunc1.*" \
77 "single pending breakpoint info"
78
79 #
80 # Test breaking at existing function
81 #
82
83 set mainline [gdb_get_line_number "break main here"]
84
85 gdb_test "break main" \
86 "Breakpoint.*at.* file .*$srcfile, line $mainline.*" \
87 "breakpoint function"
88
89 gdb_test "info break" \
90 "Num Type\[ \]+Disp Enb Address\[ \]+What.*
91 \[0-9\]+\[\t \]+breakpoint keep y.*PENDING.*pendfunc1.*
92 \[0-9\]+\[\t \]+breakpoint keep y.* in main at .*$srcfile:$mainline" \
93 "pending plus real breakpoint info"
94
95
96 #
97 # Test not setting a pending breakpoint
98 #
99 gdb_test_multiple "break pendfunc2" "Don't set pending breakpoint" {
100 -re ".*Make breakpoint pending.*y or \\\[n\\\]. $" {
101 gdb_test "n" "" "Don't set pending breakpoint"
102 }
103 }
104
105 #
106 # Add condition to pending breakpoint
107 #
108
109 gdb_test "condition 1 k == 1" ""
110
111 gdb_test "info break" \
112 "Num Type\[ \]+Disp Enb Address\[ \]+What.*
113 \[0-9\]+\[\t \]+breakpoint keep y.*PENDING.*pendfunc1.*
114 \[\t \]+stop only if k == 1.*
115 \[0-9\]+\[\t \]+breakpoint keep y.* in main at .*$srcfile:$mainline" \
116 "pending plus condition"
117
118 #
119 # Disable pending breakpoint
120 #
121
122 gdb_test "disable 1" ""
123
124 gdb_test "info break" \
125 "Num Type\[ \]+Disp Enb Address\[ \]+What.*
126 \[0-9\]+\[\t \]+breakpoint keep n.*PENDING.*pendfunc1.*
127 \[\t \]+stop only if k == 1.*
128 \[0-9\]+\[\t \]+breakpoint keep y.* in main at .*$srcfile:$mainline" \
129 "pending disabled"
130
131 #
132 # Add commands to pending breakpoint
133 #
134 gdb_test "commands 1\nprint k\nend" "" \
135 "Set commands for pending breakpoint"
136
137 gdb_test "info break" \
138 "Num Type\[ \]+Disp Enb Address\[ \]+What.*
139 \[0-9\]+\[\t \]+breakpoint keep n.*PENDING.*pendfunc1.*
140 \[\t \]+stop only if k == 1.*
141 \[\t \]+print k.*
142 \[0-9\]+\[\t \]+breakpoint keep y.* in main at .*$srcfile:$mainline" \
143 "pending disabled plus commands"
144
145 #
146 # Try a pending break for a line in a source file with a condition
147 #
148
149 gdb_test_multiple "break pendshr.c:26 if x > 3" "Set pending breakpoint 2" {
150 -re ".*Make breakpoint pending.*y or \\\[n\\\]. $" {
151 gdb_test "y" "Breakpoint.*pendshr.c:26.*pending." \
152 "Set pending breakpoint 2"
153 }
154 }
155
156 gdb_test "info break" \
157 "Num Type\[ \]+Disp Enb Address\[ \]+What.*
158 \[0-9\]+\[\t \]+breakpoint keep n.*PENDING.*pendfunc1.*
159 \[\t \]+stop only if k == 1.*
160 \[\t \]+print k.*
161 \[0-9\]+\[\t \]+breakpoint keep y.* in main at .*$srcfile:$mainline.*
162 \[0-9\]+\[\t \]+breakpoint keep y.*PENDING.*pendshr.c:26 if x > 3.*" \
163 "multiple pending breakpoints"
164
165
166 #
167 # Try a pending break for a line in a source file with ignore count:
168 #
169
170 gdb_test_multiple "break pendshr.c:27" "Set pending breakpoint 3" {
171 -re ".*Make breakpoint pending.*y or \\\[n\\\]. $" {
172 gdb_test "y" "Breakpoint.*pendshr.c:27.*pending." \
173 "Set pending breakpoint 3"
174 }
175 }
176
177 gdb_test {ignore $bpnum 2} "Will ignore next 2 crossings of breakpoint .*" \
178 "set ignore count on pending breakpoint 3"
179
180 gdb_test "info break" \
181 "Num Type\[ \]+Disp Enb Address\[ \]+What.*
182 \[0-9\]+\[\t \]+breakpoint keep n.*PENDING.*pendfunc1.*
183 \[\t \]+stop only if k == 1.*
184 \[\t \]+print k.*
185 \[0-9\]+\[\t \]+breakpoint keep y.* in main at .*$srcfile:$mainline.*
186 \[0-9\]+\[\t \]+breakpoint keep y.*PENDING.*pendshr.c:26 if x > 3.*
187 \[0-9\]+\[\t \]+breakpoint keep y.*PENDING.*pendshr.c:27.*ignore next 2 hits.*" \
188 "multiple pending breakpoints 2"
189
190 #
191 # Run to main which should resolve a pending breakpoint
192 #
193
194 gdb_test "run" \
195 "Breakpoint.*at.*
196 Pending breakpoint \"pendshr.c:26 if x > 3\" resolved.*
197 Breakpoint.*, main.*$mainline.*" \
198 "running to main"
199
200 #
201 # Re-enable the first pending breakpoint which should resolve
202 #
203
204 gdb_test "enable 1" \
205 "Breakpoint.*at.*
206 Pending breakpoint \"pendfunc1.* resolved.*" \
207 "re-enabling pending breakpoint that can resolve instantly"
208
209 #
210 # Continue to verify conditionals and commands for breakpoints are honored
211 #
212
213 gdb_test "continue" \
214 ".*Breakpoint.*pendfunc1.*at.*pendshr.c:26.*4;" \
215 "continue to resolved breakpoint 2"
216
217 gdb_test "continue" \
218 ".*Breakpoint.*pendfunc1.*at.*pendshr.c:26.*
219 \[$\]1 = 1." \
220 "continue to resolved breakpoint 1"
221
222 #
223 # Disable the other two breakpoints, and continue to the one with
224 # the ignore count. Make sure you hit it the third time, x should
225 # be 3 then.
226 #
227
228 gdb_test "disable 7" "" "Disable other breakpoints"
229 gdb_test "disable 5" "" "Disable other breakpoints"
230
231 gdb_test "continue" \
232 {.*Breakpoint.*pendfunc1.*\(x=3\) at.*pendshr.c:27.*printf.*;} \
233 "continue to resolved breakpoint 3"
234
235 delete_breakpoints
236
237 gdb_breakpoint "main"
238
239 #
240 # Set non-existent pending breakpoint
241 #
242 gdb_test_multiple "break imaginary" "set imaginary pending breakpoint" {
243 -re ".*Make breakpoint pending.*y or \\\[n\\\]. $" {
244 gdb_test "y" "Breakpoint.*imaginary.*pending." \
245 "set imaginary pending breakpoint"
246 }
247 }
248
249 #
250 # rerun program and make sure that any pending breakpoint remains and no
251 # error messages are issued for the missing function
252 #
253
254 rerun_to_main
255
256 gdb_test "info break" \
257 "Num Type\[ \]+Disp Enb Address\[ \]+What.*
258 \[0-9\]+\[\t \]+breakpoint keep y.* in main at .*$srcfile:$mainline.*
259 \[0-9\]+\[\t \]+breakpoint keep y.*PENDING.*imaginary.*" \
260 "verify pending breakpoint after restart"