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