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 | |
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" \ | |
74 | "Num Type\[ \]+Disp Enb Address\[ \]+What.* | |
75 | \[0-9\]+\[\t \]+breakpoint keep y.*PENDING.*pendfunc1.*" \ | |
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" \ | |
89 | "Num Type\[ \]+Disp Enb Address\[ \]+What.* | |
90 | \[0-9\]+\[\t \]+breakpoint keep y.*PENDING.*pendfunc1.* | |
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" \ | |
111 | "Num Type\[ \]+Disp Enb Address\[ \]+What.* | |
112 | \[0-9\]+\[\t \]+breakpoint keep y.*PENDING.*pendfunc1.* | |
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" \ | |
124 | "Num Type\[ \]+Disp Enb Address\[ \]+What.* | |
125 | \[0-9\]+\[\t \]+breakpoint keep n.*PENDING.*pendfunc1.* | |
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" \ | |
137 | "Num Type\[ \]+Disp Enb Address\[ \]+What.* | |
138 | \[0-9\]+\[\t \]+breakpoint keep n.*PENDING.*pendfunc1.* | |
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" \ | |
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.* | |
b9c34f67 | 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" \ | |
182 | "Num Type\[ \]+Disp Enb Address\[ \]+What.* | |
183 | \[0-9\]+\[\t \]+breakpoint keep n.*PENDING.*pendfunc1.* | |
184 | \[\t \]+stop only if k == 1.* | |
185 | \[\t \]+print k.* | |
186 | \[0-9\]+\[\t \]+breakpoint keep y.* in main at .*$srcfile:$mainline.* | |
b9c34f67 JB |
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 "" \ | |
18fe2033 | 197 | "Breakpoint.*at.* |
b9c34f67 | 198 | Pending breakpoint \"pendshr.c:$bp2_loc if x > 3\" resolved.* |
18fe2033 JJ |
199 | Breakpoint.*, main.*$mainline.*" \ |
200 | "running to main" | |
201 | ||
202 | # | |
203 | # Re-enable the first pending breakpoint which should resolve | |
204 | # | |
205 | ||
206 | gdb_test "enable 1" \ | |
207 | "Breakpoint.*at.* | |
208 | Pending breakpoint \"pendfunc1.* resolved.*" \ | |
209 | "re-enabling pending breakpoint that can resolve instantly" | |
210 | ||
211 | # | |
212 | # Continue to verify conditionals and commands for breakpoints are honored | |
213 | # | |
214 | ||
215 | gdb_test "continue" \ | |
b9c34f67 | 216 | ".*Breakpoint.*pendfunc1.*at.*pendshr.c:$bp2_loc.*4;" \ |
18fe2033 JJ |
217 | "continue to resolved breakpoint 2" |
218 | ||
219 | gdb_test "continue" \ | |
b9c34f67 | 220 | ".*Breakpoint.*pendfunc1.*at.*pendshr.c:$bp2_loc.* |
18fe2033 JJ |
221 | \[$\]1 = 1." \ |
222 | "continue to resolved breakpoint 1" | |
223 | ||
0a5e7efe JI |
224 | # |
225 | # Disable the other two breakpoints, and continue to the one with | |
226 | # the ignore count. Make sure you hit it the third time, x should | |
227 | # be 3 then. | |
228 | # | |
229 | ||
230 | gdb_test "disable 7" "" "Disable other breakpoints" | |
231 | gdb_test "disable 5" "" "Disable other breakpoints" | |
232 | ||
233 | gdb_test "continue" \ | |
b9c34f67 | 234 | ".*Breakpoint.*pendfunc1.*\\\(x=3\\\) at.*pendshr.c:$bp3_loc.*printf.*;" \ |
0a5e7efe JI |
235 | "continue to resolved breakpoint 3" |
236 | ||
18fe2033 JJ |
237 | delete_breakpoints |
238 | ||
239 | gdb_breakpoint "main" | |
240 | ||
241 | # | |
242 | # Set non-existent pending breakpoint | |
243 | # | |
244 | gdb_test_multiple "break imaginary" "set imaginary pending breakpoint" { | |
9f27c604 | 245 | -re ".*Make breakpoint pending.*y or \\\[n\\\]. $" { |
18fe2033 JJ |
246 | gdb_test "y" "Breakpoint.*imaginary.*pending." \ |
247 | "set imaginary pending breakpoint" | |
248 | } | |
249 | } | |
250 | ||
251 | # | |
252 | # rerun program and make sure that any pending breakpoint remains and no | |
253 | # error messages are issued for the missing function | |
254 | # | |
255 | ||
256 | rerun_to_main | |
0a5e7efe | 257 | |
18fe2033 JJ |
258 | gdb_test "info break" \ |
259 | "Num Type\[ \]+Disp Enb Address\[ \]+What.* | |
260 | \[0-9\]+\[\t \]+breakpoint keep y.* in main at .*$srcfile:$mainline.* | |
261 | \[0-9\]+\[\t \]+breakpoint keep y.*PENDING.*imaginary.*" \ | |
262 | "verify pending breakpoint after restart" |