Commit | Line | Data |
---|---|---|
42a4f53d | 1 | # Copyright 2012-2019 Free Software Foundation, Inc. |
87f0e720 KS |
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 3 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, see <http://www.gnu.org/licenses/>. | |
15 | ||
16 | # Tests for explicit locations | |
17 | ||
8955eb2d PA |
18 | load_lib completion-support.exp |
19 | ||
87f0e720 KS |
20 | standard_testfile explicit.c explicit2.c 3explicit.c |
21 | set exefile $testfile | |
22 | ||
5b362f04 | 23 | if {[prepare_for_testing "failed to prepare" $exefile \ |
87f0e720 KS |
24 | [list $srcfile $srcfile2 $srcfile3] {debug nowarnings}]} { |
25 | return -1 | |
26 | } | |
27 | ||
28 | # Wrap the entire test in a namespace to avoid contaminating other tests. | |
29 | namespace eval $testfile { | |
30 | ||
31 | # Test the given (explicit) LINESPEC which should cause gdb to break | |
32 | # at LOCATION. | |
33 | proc test_breakpoint {linespec location} { | |
34 | ||
35 | set testname "set breakpoint at \"$linespec\"" | |
36 | # Delete all breakpoints, set a new breakpoint at LINESPEC, | |
37 | # and attempt to run to it. | |
38 | delete_breakpoints | |
39 | if {[gdb_breakpoint $linespec]} { | |
40 | pass $testname | |
41 | send_log "\nexpecting locpattern \"$location\"\n" | |
42 | gdb_continue_to_breakpoint $linespec $location | |
43 | } else { | |
44 | fail $testname | |
45 | } | |
46 | } | |
47 | ||
48 | # Add the given LINESPEC to the array named in THEARRAY. GDB is expected | |
49 | # to stop at LOCATION. | |
50 | proc add {thearray linespec location} { | |
51 | upvar $thearray ar | |
52 | ||
53 | lappend ar(linespecs) $linespec | |
54 | lappend ar(locations) $location | |
55 | } | |
56 | ||
57 | # A list of all explicit linespec arguments. | |
58 | variable all_arguments | |
59 | set all_arguments {"source" "function" "label" "line"} | |
60 | ||
61 | # Some locations used in this test | |
62 | variable lineno | |
63 | variable location | |
64 | set lineno(normal) [gdb_get_line_number "myfunction location" $srcfile] | |
65 | set lineno(top) [gdb_get_line_number "top location" $srcfile] | |
66 | foreach v [array names lineno] { | |
67 | set location($v) ".*[string_to_regexp "$srcfile:$lineno($v)"].*" | |
68 | } | |
69 | ||
70 | # A list of explicit locations and the corresponding location. | |
71 | variable linespecs | |
72 | set linespecs(linespecs) {} | |
73 | set linespecs(location) {} | |
74 | ||
75 | add linespecs "-source $srcfile -function myfunction" $location(normal) | |
76 | add linespecs "-source $srcfile -function myfunction -label top" \ | |
77 | $location(top) | |
78 | ||
79 | # This isn't implemented yet; -line is silently ignored. | |
80 | add linespecs "-source $srcfile -function myfunction -label top -line 3" \ | |
81 | $location(top) | |
82 | add linespecs "-source $srcfile -line $lineno(top)" $location(top) | |
83 | add linespecs "-function myfunction" $location(normal) | |
84 | add linespecs "-function myfunction -label top" $location(top) | |
85 | ||
86 | # These are also not yet supported; -line is silently ignored. | |
87 | add linespecs "-function myfunction -line 3" $location(normal) | |
88 | add linespecs "-function myfunction -label top -line 3" $location(top) | |
89 | add linespecs "-line 3" $location(normal) | |
90 | ||
87f0e720 KS |
91 | # Fire up gdb. |
92 | if {![runto_main]} { | |
93 | return -1 | |
94 | } | |
95 | ||
96 | # Turn off queries | |
97 | gdb_test_no_output "set confirm off" | |
98 | ||
99 | # Simple error tests (many more are tested in ls-err.exp) | |
100 | foreach arg $all_arguments { | |
101 | # Test missing argument | |
102 | gdb_test "break -$arg" \ | |
103 | [string_to_regexp "missing argument for \"-$arg\""] | |
104 | ||
105 | # Test abbreviations | |
106 | set short [string range $arg 0 3] | |
107 | gdb_test "break -$short" \ | |
108 | [string_to_regexp "missing argument for \"-$short\""] | |
109 | } | |
110 | ||
111 | # Test invalid arguments | |
112 | foreach arg {"-foo" "-foo bar" "-function myfunction -foo" \ | |
113 | "-function -myfunction -foo bar"} { | |
114 | gdb_test "break $arg" \ | |
115 | [string_to_regexp "invalid explicit location argument, \"-foo\""] | |
116 | } | |
117 | ||
118 | # Test explicit locations, with and without conditions. | |
119 | # For these tests, it is easiest to turn of pending breakpoint. | |
120 | gdb_test_no_output "set breakpoint pending off" \ | |
121 | "turn off pending breakpoints" | |
122 | ||
123 | foreach linespec $linespecs(linespecs) loc_pattern $linespecs(locations) { | |
124 | ||
125 | # Test the linespec | |
126 | test_breakpoint $linespec $loc_pattern | |
127 | ||
128 | # Test with a valid condition | |
129 | delete_breakpoints | |
130 | set tst "set breakpoint at \"$linespec\" with valid condition" | |
131 | if {[gdb_breakpoint "$linespec if arg == 0"]} { | |
132 | pass $tst | |
133 | ||
134 | gdb_test "info break" ".*stop only if arg == 0.*" \ | |
135 | "info break of conditional breakpoint at \"$linespec\"" | |
136 | } else { | |
137 | fail $tst | |
138 | } | |
139 | ||
140 | # Test with invalid condition | |
141 | gdb_test "break $linespec if foofoofoo == 1" \ | |
142 | ".*No symbol \"foofoofoo\" in current context.*" \ | |
143 | "set breakpoint at \"$linespec\" with invalid condition" | |
144 | ||
145 | # Test with thread | |
146 | delete_breakpoints | |
147 | gdb_test "break $linespec thread 123" "Unknown thread 123." | |
148 | } | |
149 | ||
515b89b3 SL |
150 | # Tests below are about tab-completion, which doesn't work if readline |
151 | # library isn't used. Check it first. | |
152 | if { [readline_is_used] } { | |
153 | ||
154 | # Test the explicit location completer | |
155 | foreach abbrev {"fun" "so" "lab" "li"} full {"function" "source" "label" "line"} { | |
156 | set tst "complete 'break -$abbrev'" | |
157 | send_gdb "break -${abbrev}\t" | |
158 | gdb_test_multiple "" $tst { | |
bf5f525c | 159 | -re "break -$full " { |
515b89b3 SL |
160 | send_gdb "\n" |
161 | gdb_test_multiple "" $tst { | |
162 | -re "missing argument for \"-$full\".*$gdb_prompt " { | |
163 | pass $tst | |
164 | } | |
87f0e720 KS |
165 | } |
166 | } | |
167 | } | |
515b89b3 SL |
168 | set tst "complete -$full with no value" |
169 | send_gdb "break -$full \t" | |
170 | gdb_test_multiple "" $tst { | |
171 | -re ".*break -$full " { | |
172 | send_gdb "\n" | |
173 | gdb_test_multiple "" $tst { | |
174 | -re ".*Source filename requires function, label, or line offset\..*$gdb_prompt " { | |
175 | if {[string equal $full "source"]} { | |
176 | pass $tst | |
177 | } else { | |
178 | fail $tst | |
179 | } | |
180 | } | |
181 | -re "missing argument for \"-$full\".*$gdb_prompt " { | |
87f0e720 | 182 | pass $tst |
87f0e720 KS |
183 | } |
184 | } | |
87f0e720 KS |
185 | } |
186 | } | |
187 | } | |
87f0e720 | 188 | |
515b89b3 | 189 | set tst "complete unique function name" |
bf5f525c | 190 | send_gdb "break -function my_unique_func\t" |
515b89b3 | 191 | gdb_test_multiple "" $tst { |
bf5f525c | 192 | -re "break -function my_unique_function_name" { |
515b89b3 SL |
193 | send_gdb "\n" |
194 | gdb_test "" ".*Breakpoint \[0-9\]+.*" $tst | |
195 | gdb_test_no_output "delete \$bpnum" "delete $tst breakpoint" | |
196 | } | |
87f0e720 | 197 | } |
87f0e720 | 198 | |
515b89b3 SL |
199 | set tst "complete non-unique function name" |
200 | send_gdb "break -function myfunc\t" | |
201 | gdb_test_multiple "" $tst { | |
bf5f525c | 202 | -re "break -function myfunc\\\x07tion" { |
515b89b3 SL |
203 | send_gdb "\t\t" |
204 | gdb_test_multiple "" $tst { | |
205 | -re "\\\x07\r\nmyfunction\[ \t\]+myfunction2\[ \t\]+myfunction3\[ \t\]+myfunction4\[ \t\]+\r\n$gdb_prompt " { | |
206 | gdb_test "2" ".*Breakpoint \[0-9\]+.*" $tst | |
207 | gdb_test_no_output "delete \$bpnum" "delete $tst breakpoint" | |
208 | } | |
87f0e720 KS |
209 | } |
210 | } | |
211 | } | |
87f0e720 | 212 | |
515b89b3 SL |
213 | set tst "complete non-existant function name" |
214 | send_gdb "break -function foo\t" | |
215 | gdb_test_multiple "" $tst { | |
bf5f525c | 216 | -re "break -function foo\\\x07" { |
515b89b3 SL |
217 | send_gdb "\t\t" |
218 | gdb_test_multiple "" $tst { | |
219 | -re "\\\x07\\\x07" { | |
220 | send_gdb "\n" | |
221 | gdb_test "" {Function "foo" not defined.} $tst | |
222 | } | |
87f0e720 KS |
223 | } |
224 | } | |
225 | } | |
87f0e720 | 226 | |
8955eb2d PA |
227 | with_test_prefix "complete unique file name" { |
228 | foreach qc $completion::maybe_quoted_list { | |
229 | set cmd "break -source ${qc}3explicit.c${qc}" | |
230 | test_gdb_complete_unique \ | |
231 | "break -source ${qc}3ex" \ | |
232 | $cmd | |
233 | gdb_test $cmd \ | |
234 | {Source filename requires function, label, or line offset.} | |
515b89b3 | 235 | } |
87f0e720 | 236 | } |
87f0e720 | 237 | |
515b89b3 SL |
238 | set tst "complete non-unique file name" |
239 | send_gdb "break -source exp\t" | |
240 | gdb_test_multiple "" $tst { | |
bf5f525c | 241 | -re "break -source exp\\\x07licit" { |
515b89b3 SL |
242 | send_gdb "\t\t" |
243 | gdb_test_multiple "" $tst { | |
507dd60e | 244 | -re "\\\x07\r\nexplicit.c\[ \t\]+explicit2.c\[ \t\]+\(expl.*\)?\r\n$gdb_prompt" { |
515b89b3 SL |
245 | send_gdb "\n" |
246 | gdb_test "" \ | |
247 | {Source filename requires function, label, or line offset.} \ | |
248 | $tst | |
249 | } | |
87f0e720 KS |
250 | } |
251 | } | |
252 | } | |
87f0e720 | 253 | |
515b89b3 SL |
254 | set tst "complete non-existant file name" |
255 | send_gdb "break -source foo\t" | |
256 | gdb_test_multiple "" $tst { | |
bf5f525c | 257 | -re "break -source foo" { |
515b89b3 SL |
258 | send_gdb "\t\t" |
259 | gdb_test_multiple "" $tst { | |
bf5f525c | 260 | -re "\\\x07\\\x07" { |
515b89b3 SL |
261 | send_gdb "\n" |
262 | gdb_test "" \ | |
263 | {Source filename requires function, label, or line offset.} \ | |
264 | $tst | |
265 | } | |
87f0e720 KS |
266 | } |
267 | } | |
268 | } | |
87f0e720 | 269 | |
515b89b3 SL |
270 | set tst "complete filename and unique function name" |
271 | send_gdb "break -source explicit.c -function ma\t" | |
272 | gdb_test_multiple "" $tst { | |
bf5f525c | 273 | -re "break -source explicit.c -function main " { |
515b89b3 SL |
274 | send_gdb "\n" |
275 | gdb_test "" ".*Breakpoint .*" $tst | |
276 | gdb_test_no_output "delete \$bpnum" "delete $tst breakpoint" | |
277 | } | |
87f0e720 | 278 | } |
87f0e720 | 279 | |
515b89b3 SL |
280 | set tst "complete filename and non-unique function name" |
281 | send_gdb "break -so 3explicit.c -func myfunc\t" | |
282 | gdb_test_multiple "" $tst { | |
bf5f525c | 283 | -re "break -so 3explicit.c -func myfunc\\\x07tion" { |
515b89b3 SL |
284 | send_gdb "\t\t" |
285 | gdb_test_multiple "" $tst { | |
286 | -re "\\\x07\r\nmyfunction3\[ \t\]+myfunction4\[ \t\]+\r\n$gdb_prompt " { | |
287 | gdb_test "3" ".*Breakpoint \[0-9\]+.*" $tst | |
288 | gdb_test_no_output "delete \$bpnum" "delete $tst breakpoint" | |
289 | } | |
87f0e720 KS |
290 | } |
291 | } | |
292 | } | |
87f0e720 | 293 | |
515b89b3 SL |
294 | set tst "complete filename and non-existant function name" |
295 | send_gdb "break -sou 3explicit.c -fun foo\t" | |
296 | gdb_test_multiple "" $tst { | |
bf5f525c | 297 | -re "break -sou 3explicit.c -fun foo\\\x07" { |
515b89b3 SL |
298 | send_gdb "\t\t" |
299 | gdb_test_multiple "" $tst { | |
bf5f525c | 300 | -re "\\\x07\\\x07" { |
515b89b3 SL |
301 | send_gdb "\n" |
302 | gdb_test "" \ | |
303 | {Function "foo" not defined in "3explicit.c".} $tst | |
304 | } | |
87f0e720 KS |
305 | } |
306 | } | |
307 | } | |
87f0e720 | 308 | |
515b89b3 SL |
309 | set tst "complete filename and function reversed" |
310 | send_gdb "break -func myfunction4 -source 3ex\t" | |
311 | gdb_test_multiple "" $tst { | |
bf5f525c | 312 | -re "break -func myfunction4 -source 3explicit.c " { |
515b89b3 SL |
313 | send_gdb "\n" |
314 | gdb_test "" "Breakpoint \[0-9\]+.*" $tst | |
315 | gdb_test_no_output "delete \$bpnum" "delete $tst breakpoint" | |
316 | } | |
87f0e720 | 317 | } |
87f0e720 | 318 | |
8955eb2d PA |
319 | with_test_prefix "complete unique label name" { |
320 | foreach qc $completion::maybe_quoted_list { | |
321 | test_gdb_complete_unique \ | |
322 | "break -function myfunction -label ${qc}to" \ | |
323 | "break -function myfunction -label ${qc}top${qc}" | |
324 | } | |
325 | } | |
326 | ||
327 | with_test_prefix "complete unique label name with source file" { | |
328 | test_gdb_complete_unique \ | |
329 | "break -source explicit.c -function myfunction -label to" \ | |
330 | "break -source explicit.c -function myfunction -label top" | |
331 | } | |
332 | ||
333 | with_test_prefix "complete unique label name reversed" { | |
334 | test_gdb_complete_multiple "b -label top -function " "myfunction" "" { | |
335 | "myfunction" | |
336 | "myfunction2" | |
337 | "myfunction3" | |
338 | "myfunction4" | |
339 | } | |
340 | } | |
341 | ||
342 | with_test_prefix "complete non-unique label name" { | |
343 | test_gdb_complete_multiple "b -function myfunction -label " "" "" { | |
344 | "done" | |
345 | "top" | |
346 | } | |
347 | } | |
348 | ||
349 | # The program is stopped at myfunction, so gdb is able to | |
350 | # infer the label's function. | |
351 | with_test_prefix "complete label name with no function" { | |
352 | test_gdb_complete_unique \ | |
353 | "break -label to" \ | |
354 | "break -label top" | |
355 | check_bp_locations_match_list \ | |
356 | "break -label top" { | |
357 | "-function myfunction -label top" | |
358 | } | |
359 | } | |
360 | ||
361 | # See above. | |
362 | with_test_prefix "complete label name with source file but no function" { | |
363 | test_gdb_complete_unique \ | |
364 | "break -source explicit.c -label to" \ | |
365 | "break -source explicit.c -label top" | |
366 | check_bp_locations_match_list \ | |
367 | "break -source explicit.c -label top" { | |
368 | "-source explicit.c -function myfunction -label top" | |
369 | } | |
370 | } | |
371 | ||
372 | with_test_prefix "complete label name with wrong source file" { | |
373 | test_gdb_complete_none \ | |
374 | "break -source explicit2.c -function myfunction -label to" | |
375 | check_setting_bp_fails \ | |
376 | "break -source explicit2.c -function myfunction -label top" | |
377 | } | |
378 | ||
379 | # Get rid of symbols from shared libraries, otherwise | |
380 | # "b -source thr<tab>" could find some system library's | |
381 | # source. | |
382 | gdb_test_no_output "nosharedlibrary" | |
383 | ||
384 | # Test that after a seemingly finished option argument, | |
385 | # completion matches both the explicit location options and | |
386 | # the linespec keywords. | |
387 | set completions_list { | |
388 | "-function" | |
389 | "-label" | |
390 | "-line" | |
a20714ff | 391 | "-qualified" |
8955eb2d PA |
392 | "-source" |
393 | "if" | |
394 | "task" | |
395 | "thread" | |
396 | } | |
397 | foreach what { "-function" "-label" "-line" "-source" } { | |
a20714ff PA |
398 | # Also test with "-qualified" appearing before the |
399 | # explicit location. | |
400 | foreach prefix {"" "-qualified "} { | |
401 | ||
402 | # ... and with "-qualified" appearing after the | |
403 | # explicit location. | |
404 | foreach suffix {"" " -qualified"} { | |
405 | with_test_prefix "complete after $prefix$what$suffix" { | |
406 | if {$what != "-line"} { | |
407 | set w "$prefix$what argument$suffix " | |
408 | test_gdb_complete_multiple \ | |
409 | "b $w" "" "" $completions_list | |
410 | test_gdb_complete_unique \ | |
411 | "b $w thr" \ | |
412 | "b $w thread" | |
413 | test_gdb_complete_unique \ | |
414 | "b $w -fun" \ | |
415 | "b $w -function" | |
416 | } else { | |
417 | # After -line, we expect a number / offset. | |
418 | foreach line {"10" "+10" "-10"} { | |
419 | set w "$prefix-line $line$suffix" | |
420 | test_gdb_complete_multiple \ | |
421 | "b $w " "" "" $completions_list | |
422 | test_gdb_complete_unique \ | |
423 | "b $w thr" \ | |
424 | "b $w thread" | |
425 | test_gdb_complete_unique \ | |
426 | "b $w -fun" \ | |
427 | "b $w -function" | |
428 | } | |
429 | ||
430 | # With an invalid -line argument, we don't get any | |
431 | # completions. | |
432 | test_gdb_complete_none "b $prefix-line argument$suffix " | |
433 | } | |
434 | ||
8955eb2d PA |
435 | } |
436 | ||
8955eb2d PA |
437 | } |
438 | ||
a20714ff PA |
439 | # These tests don't make sense with "-qualified" after |
440 | # the location. | |
441 | with_test_prefix "complete after $prefix$what" { | |
442 | # Don't complete a linespec keyword ("thread") or | |
443 | # another option name when expecting an option | |
444 | # argument. | |
445 | test_gdb_complete_none "b $prefix$what thr" | |
446 | test_gdb_complete_none "b $prefix$what -fun" | |
447 | } | |
8955eb2d PA |
448 | } |
449 | } | |
450 | ||
8955eb2d PA |
451 | # Tests that ensure that after "if" we complete on expressions |
452 | # are in cpcompletion.exp. | |
453 | ||
454 | # Disable the completion limit for the rest of the testcase. | |
455 | gdb_test_no_output "set max-completions unlimited" | |
456 | ||
457 | # Get rid of symbols from shared libraries, otherwise the | |
458 | # completions match list for "break <tab>" is huge and makes | |
459 | # the test below quite long while the gdb_test_multiple loop | |
460 | # below consumes the matches. Not doing this added ~20 | |
461 | # seconds at the time of writing. (Actually, already done above.) | |
462 | # gdb_test_no_output "nosharedlibrary" | |
463 | ||
464 | # Test completion with no input argument. We should see all | |
465 | # the options, plus all the functions. To keep it simple, as | |
466 | # proxy, we check for presence of one explicit location | |
467 | # option, one probe location, and one function. | |
468 | set saw_opt_function 0 | |
469 | set saw_opt_probe_stap 0 | |
470 | set saw_function 0 | |
471 | ||
472 | set tst "complete with no arguments" | |
473 | send_gdb "break \t" | |
474 | gdb_test_multiple "" $tst { | |
475 | "break \\\x07" { | |
de28a3b7 | 476 | send_gdb "\t" |
8955eb2d PA |
477 | gdb_test_multiple "" $tst { |
478 | "Display all" { | |
479 | send_gdb "y" | |
480 | exp_continue | |
481 | } | |
482 | -re "-function" { | |
483 | set saw_opt_function 1 | |
484 | exp_continue | |
485 | } | |
486 | -re "-probe-stap" { | |
487 | set saw_opt_probe_stap 1 | |
488 | exp_continue | |
489 | } | |
490 | -re "myfunction4" { | |
491 | set saw_function 1 | |
492 | exp_continue | |
493 | } | |
494 | -re "\r\n$gdb_prompt " { | |
495 | gdb_assert {$saw_opt_function && $saw_opt_probe_stap && $saw_function} $tst | |
496 | } | |
497 | -re " " { | |
498 | exp_continue | |
499 | } | |
500 | } | |
501 | } | |
502 | } | |
503 | clear_input_line $tst | |
504 | ||
515b89b3 SL |
505 | # NOTE: We don't bother testing more elaborate combinations of options, |
506 | # such as "-func main -sour 3ex\t" (main is defined in explicit.c). | |
507 | # The completer cannot handle these yet. | |
508 | ||
8955eb2d PA |
509 | # The following completion tests require having no symbols |
510 | # loaded. | |
511 | gdb_exit | |
512 | gdb_start | |
513 | ||
514 | # The match list you get when you complete with no options | |
515 | # specified at all. | |
516 | set completion_list { | |
517 | "-function" | |
518 | "-label" | |
519 | "-line" | |
520 | "-probe" | |
521 | "-probe-dtrace" | |
522 | "-probe-stap" | |
a20714ff | 523 | "-qualified" |
8955eb2d PA |
524 | "-source" |
525 | } | |
526 | with_test_prefix "complete with no arguments and no symbols" { | |
527 | test_gdb_complete_multiple "b " "" "-" $completion_list | |
528 | test_gdb_complete_multiple "b " "-" "" $completion_list | |
529 | } | |
515b89b3 SL |
530 | } |
531 | # End of completion tests. | |
87f0e720 KS |
532 | |
533 | # Test pending explicit breakpoints | |
534 | gdb_exit | |
535 | gdb_start | |
536 | ||
537 | set tst "pending invalid conditional explicit breakpoint" | |
538 | if {![gdb_breakpoint "-func myfunction if foofoofoo == 1" \ | |
539 | allow-pending]} { | |
540 | fail "set $tst" | |
541 | } else { | |
542 | gdb_test "info break" ".*PENDING.*myfunction if foofoofoo == 1.*" $tst | |
543 | } | |
544 | ||
545 | gdb_exit | |
546 | gdb_start | |
547 | ||
548 | set tst "pending valid conditional explicit breakpoint" | |
549 | if {![gdb_breakpoint "-func myfunction if arg == 0" \ | |
550 | allow-pending]} { | |
551 | fail "set $tst" | |
552 | } else { | |
553 | gdb_test "info break" ".*PENDING.*myfunction if arg == 0" $tst | |
554 | ||
555 | gdb_load [standard_output_file $exefile] | |
556 | gdb_test "info break" \ | |
557 | ".*in myfunction at .*$srcfile:.*stop only if arg == 0.*" \ | |
558 | "$tst resolved" | |
559 | } | |
560 | ||
561 | # Test interaction of condition command and explicit linespec conditons. | |
562 | gdb_exit | |
563 | gdb_start | |
564 | gdb_load [standard_output_file $exefile] | |
565 | ||
566 | set tst "condition_command overrides explicit linespec condition" | |
567 | if {![runto main]} { | |
568 | fail $tst | |
569 | } else { | |
570 | if {![gdb_breakpoint "-func myfunction if arg == 1"]} { | |
571 | fail "set breakpoint with condition 'arg == 1'" | |
572 | } else { | |
573 | gdb_test_no_output "cond 2 arg == 0" \ | |
574 | "set new breakpoint condition for explicit linespec" | |
575 | ||
576 | gdb_continue_to_breakpoint $tst $location(normal) | |
577 | } | |
578 | } | |
579 | ||
580 | gdb_test "cond 2" [string_to_regexp "Breakpoint 2 now unconditional."] \ | |
581 | "clear condition for explicit breakpoint" | |
582 | set tst "info break of cleared condition of explicit breakpoint" | |
583 | gdb_test_multiple "info break" $tst { | |
584 | -re ".*in myfunction at .*$srcfile:.*stop only if arg == 0.*" { | |
585 | fail $tst | |
586 | } | |
587 | -re ".*in myfunction at .*$srcfile:.*$gdb_prompt $" { | |
588 | pass $tst | |
589 | } | |
590 | } | |
591 | ||
592 | # Test explicit "ranges." Make sure that using explicit | |
593 | # locations doesn't alter the expected outcome. | |
594 | gdb_test "list main" ".*" "list main 1" | |
595 | set list_result [capture_command_output "list -,+" ""] | |
596 | gdb_test "list main" ".*" "list main 2" | |
597 | gdb_test "list -line -,-line +" [string_to_regexp $list_result] | |
598 | ||
599 | # Ditto for the reverse (except that no output is expected). | |
600 | gdb_test "list myfunction" ".*" "list myfunction 1" | |
601 | gdb_test_no_output "list +,-" | |
602 | gdb_test "list myfunction" ".*" "list myfunction 2" | |
603 | gdb_test_no_output "list -line +, -line -" | |
604 | } | |
605 | ||
606 | namespace delete $testfile |