Commit | Line | Data |
---|---|---|
6aba47ca | 1 | # Copyright 2003, 2004, 2005, 2007 Free Software Foundation, Inc. |
18fe2033 JJ |
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 | ||
18fe2033 | 17 | # This file was created by Jeff Johnston. (jjohnstn@redhat.com) |
18fe2033 JJ |
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 | ||
93f02886 | 29 | if {[skip_shlib_tests]} { |
18fe2033 JJ |
30 | return 0 |
31 | } | |
32 | ||
33 | set testfile "pending" | |
34 | set libfile "pendshr" | |
3cbba3d1 PG |
35 | set srcfile $testfile.c |
36 | set libsrc $srcdir/$subdir/$libfile.c | |
37 | set binfile $objdir/$subdir/$testfile | |
38 | set lib_sl $objdir/$subdir/$libfile.sl | |
39 | ||
40 | set lib_opts debug | |
41 | set exec_opts [list debug shlib=$lib_sl] | |
18fe2033 JJ |
42 | |
43 | if [get_compiler_info ${binfile}] { | |
44 | return -1 | |
45 | } | |
46 | ||
3cbba3d1 PG |
47 | if { [gdb_compile_shlib $libsrc $lib_sl $lib_opts] != "" |
48 | || [gdb_compile $srcdir/$subdir/$srcfile $binfile executable $exec_opts] != ""} { | |
49 | untested "Could not compile either $libsrc or $srcdir/$subdir/$srcfile." | |
50 | return -1 | |
18fe2033 JJ |
51 | } |
52 | ||
3cbba3d1 | 53 | # Start with a fresh gdb. |
18fe2033 JJ |
54 | |
55 | gdb_exit | |
56 | gdb_start | |
57 | gdb_reinitialize_dir $srcdir/$subdir | |
58 | gdb_load ${binfile} | |
93f02886 | 59 | gdb_load_shlibs $lib_sl |
18fe2033 JJ |
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" { | |
9f27c604 | 69 | -re ".*Make breakpoint pending.*y or \\\[n\\\]. $" { |
18fe2033 JJ |
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" { | |
9f27c604 | 100 | -re ".*Make breakpoint pending.*y or \\\[n\\\]. $" { |
18fe2033 JJ |
101 | gdb_test "n" "" "Don't set pending breakpoint" |
102 | } | |
103 | } | |
104 | ||
105 | # | |
106 | # Add condition to pending breakpoint | |
107 | # | |
108 | ||
d2dc51db | 109 | gdb_test "condition 1 k == 1" "" |
18fe2033 JJ |
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 | ||
d2dc51db | 122 | gdb_test "disable 1" "" |
18fe2033 JJ |
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 | ||
b9c34f67 JB |
149 | set bp2_loc [gdb_get_line_number "y = x + 4" ${libfile}.c] |
150 | gdb_test_multiple "break pendshr.c:$bp2_loc if x > 3" "Set pending breakpoint 2" { | |
9f27c604 | 151 | -re ".*Make breakpoint pending.*y or \\\[n\\\]. $" { |
b9c34f67 | 152 | gdb_test "y" "Breakpoint.*pendshr.c:$bp2_loc.*pending." \ |
18fe2033 JJ |
153 | "Set pending breakpoint 2" |
154 | } | |
155 | } | |
156 | ||
157 | gdb_test "info break" \ | |
158 | "Num Type\[ \]+Disp Enb Address\[ \]+What.* | |
159 | \[0-9\]+\[\t \]+breakpoint keep n.*PENDING.*pendfunc1.* | |
160 | \[\t \]+stop only if k == 1.* | |
161 | \[\t \]+print k.* | |
162 | \[0-9\]+\[\t \]+breakpoint keep y.* in main at .*$srcfile:$mainline.* | |
b9c34f67 | 163 | \[0-9\]+\[\t \]+breakpoint keep y.*PENDING.*pendshr.c:$bp2_loc if x > 3.*" \ |
18fe2033 JJ |
164 | "multiple pending breakpoints" |
165 | ||
0a5e7efe JI |
166 | |
167 | # | |
168 | # Try a pending break for a line in a source file with ignore count: | |
169 | # | |
170 | ||
b9c34f67 JB |
171 | set bp3_loc [gdb_get_line_number "printf" ${libfile}.c] |
172 | gdb_test_multiple "break pendshr.c:$bp3_loc" "Set pending breakpoint 3" { | |
0a5e7efe | 173 | -re ".*Make breakpoint pending.*y or \\\[n\\\]. $" { |
b9c34f67 | 174 | gdb_test "y" "Breakpoint.*pendshr.c:$bp3_loc.*pending." \ |
0a5e7efe JI |
175 | "Set pending breakpoint 3" |
176 | } | |
177 | } | |
178 | ||
179 | gdb_test {ignore $bpnum 2} "Will ignore next 2 crossings of breakpoint .*" \ | |
180 | "set ignore count on pending breakpoint 3" | |
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.* | |
b9c34f67 JB |
188 | \[0-9\]+\[\t \]+breakpoint keep y.*PENDING.*pendshr.c:$bp2_loc if x > 3.* |
189 | \[0-9\]+\[\t \]+breakpoint keep y.*PENDING.*pendshr.c:$bp3_loc.*ignore next 2 hits.*" \ | |
0a5e7efe JI |
190 | "multiple pending breakpoints 2" |
191 | ||
18fe2033 JJ |
192 | # |
193 | # Run to main which should resolve a pending breakpoint | |
194 | # | |
195 | ||
b741e217 DJ |
196 | gdb_run_cmd |
197 | gdb_test "" \ | |
18fe2033 | 198 | "Breakpoint.*at.* |
b9c34f67 | 199 | Pending breakpoint \"pendshr.c:$bp2_loc if x > 3\" resolved.* |
18fe2033 JJ |
200 | Breakpoint.*, main.*$mainline.*" \ |
201 | "running to main" | |
202 | ||
203 | # | |
204 | # Re-enable the first pending breakpoint which should resolve | |
205 | # | |
206 | ||
207 | gdb_test "enable 1" \ | |
208 | "Breakpoint.*at.* | |
209 | Pending breakpoint \"pendfunc1.* resolved.*" \ | |
210 | "re-enabling pending breakpoint that can resolve instantly" | |
211 | ||
212 | # | |
213 | # Continue to verify conditionals and commands for breakpoints are honored | |
214 | # | |
215 | ||
216 | gdb_test "continue" \ | |
b9c34f67 | 217 | ".*Breakpoint.*pendfunc1.*at.*pendshr.c:$bp2_loc.*4;" \ |
18fe2033 JJ |
218 | "continue to resolved breakpoint 2" |
219 | ||
220 | gdb_test "continue" \ | |
b9c34f67 | 221 | ".*Breakpoint.*pendfunc1.*at.*pendshr.c:$bp2_loc.* |
18fe2033 JJ |
222 | \[$\]1 = 1." \ |
223 | "continue to resolved breakpoint 1" | |
224 | ||
0a5e7efe JI |
225 | # |
226 | # Disable the other two breakpoints, and continue to the one with | |
227 | # the ignore count. Make sure you hit it the third time, x should | |
228 | # be 3 then. | |
229 | # | |
230 | ||
231 | gdb_test "disable 7" "" "Disable other breakpoints" | |
232 | gdb_test "disable 5" "" "Disable other breakpoints" | |
233 | ||
234 | gdb_test "continue" \ | |
b9c34f67 | 235 | ".*Breakpoint.*pendfunc1.*\\\(x=3\\\) at.*pendshr.c:$bp3_loc.*printf.*;" \ |
0a5e7efe JI |
236 | "continue to resolved breakpoint 3" |
237 | ||
18fe2033 JJ |
238 | delete_breakpoints |
239 | ||
240 | gdb_breakpoint "main" | |
241 | ||
242 | # | |
243 | # Set non-existent pending breakpoint | |
244 | # | |
245 | gdb_test_multiple "break imaginary" "set imaginary pending breakpoint" { | |
9f27c604 | 246 | -re ".*Make breakpoint pending.*y or \\\[n\\\]. $" { |
18fe2033 JJ |
247 | gdb_test "y" "Breakpoint.*imaginary.*pending." \ |
248 | "set imaginary pending breakpoint" | |
249 | } | |
250 | } | |
251 | ||
252 | # | |
253 | # rerun program and make sure that any pending breakpoint remains and no | |
254 | # error messages are issued for the missing function | |
255 | # | |
256 | ||
257 | rerun_to_main | |
0a5e7efe | 258 | |
18fe2033 JJ |
259 | gdb_test "info break" \ |
260 | "Num Type\[ \]+Disp Enb Address\[ \]+What.* | |
261 | \[0-9\]+\[\t \]+breakpoint keep y.* in main at .*$srcfile:$mainline.* | |
262 | \[0-9\]+\[\t \]+breakpoint keep y.*PENDING.*imaginary.*" \ | |
263 | "verify pending breakpoint after restart" |