Implement explicit locations for Python breakpoints.
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.python / py-breakpoint.exp
1 # Copyright (C) 2010-2017 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 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 # This file is part of the GDB testsuite. It tests the mechanism
17 # exposing breakpoints to Python.
18
19 load_lib gdb-python.exp
20
21 standard_testfile
22
23 if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile}] } {
24 return -1
25 }
26
27 # Skip all tests if Python scripting is not enabled.
28 if { [skip_python_tests] } { continue }
29
30 proc_with_prefix test_bkpt_basic { } {
31 global srcfile testfile hex decimal
32
33 # Start with a fresh gdb.
34 clean_restart ${testfile}
35
36 # We should start with no breakpoints.
37 gdb_test "python print (gdb.breakpoints())" "\\(\\)"
38
39 if ![runto_main] then {
40 fail "cannot run to main."
41 return 0
42 }
43
44 # Now there should be one breakpoint: main.
45 gdb_py_test_silent_cmd "python blist = gdb.breakpoints()" \
46 "Get Breakpoint List" 0
47 gdb_test "python print (blist\[0\])" \
48 "<gdb.Breakpoint object at $hex>" "Check obj exists @main"
49 gdb_test "python print (blist\[0\].location)" \
50 "main." "Check breakpoint location @main"
51 gdb_test "python print (blist\[0\].pending)" "False" \
52 "Check pending status of main breakpoint"
53
54 set mult_line [gdb_get_line_number "Break at multiply."]
55 gdb_breakpoint ${mult_line}
56 gdb_continue_to_breakpoint "Break at multiply" \
57 ".*Break at multiply.*"
58
59 # Check that the Python breakpoint code noted the addition of a
60 # breakpoint "behind the scenes".
61 gdb_py_test_silent_cmd "python blist = gdb.breakpoints()" \
62 "Get Breakpoint List" 0
63 gdb_test "python print (len(blist))" \
64 "2" "Check for two breakpoints"
65 gdb_test "python print (blist\[0\])" \
66 "<gdb.Breakpoint object at $hex>" "Check obj exists @main 2"
67 gdb_test "python print (blist\[0\].location)" \
68 "main." "Check breakpoint location @main 2"
69 gdb_test "python print (blist\[1\])" \
70 "<gdb.Breakpoint object at $hex>" "Check obj exists @mult_line"
71
72 gdb_test "python print (blist\[1\].location)" \
73 "py-breakpoint\.c:${mult_line}*" \
74 "check breakpoint location @mult_line"
75
76 # Check hit and ignore counts.
77 gdb_test "python print (blist\[1\].hit_count)" \
78 "1" "Check breakpoint hit count @1"
79 gdb_py_test_silent_cmd "python blist\[1\].ignore_count = 4" \
80 "Set breakpoint hit count" 0
81 gdb_continue_to_breakpoint "Break at multiply @6" \
82 ".*Break at multiply.*"
83 gdb_test "python print (blist\[1\].hit_count)" \
84 "6" "Check breakpoint hit count @6"
85 gdb_test "print result" \
86 " = 545" "Check expected variable result after 6 iterations"
87
88 # Test breakpoint is enabled and disabled correctly..
89 gdb_breakpoint [gdb_get_line_number "Break at add."]
90 gdb_continue_to_breakpoint "Break at add 1" ".*Break at add.*"
91 gdb_test "python print (blist\[1\].enabled)" \
92 "True" "Check breakpoint enabled."
93 gdb_py_test_silent_cmd "python blist\[1\].enabled = False" \
94 "Set breakpoint disabled." 0
95 gdb_continue_to_breakpoint "Break at add 2" ".*Break at add.*"
96 gdb_py_test_silent_cmd "python blist\[1\].enabled = True" \
97 "Set breakpoint enabled." 0
98 gdb_continue_to_breakpoint "Break at multiply after re-enable" \
99 ".*Break at multiply.*"
100
101 # Test other getters and setters.
102 gdb_py_test_silent_cmd "python blist = gdb.breakpoints()" \
103 "Get Breakpoint List" 0
104 gdb_test "python print (blist\[1\].thread)" \
105 "None" "Check breakpoint thread"
106 gdb_test "python print (blist\[1\].type == gdb.BP_BREAKPOINT)" \
107 "True" "Check breakpoint type"
108 gdb_test "python print (blist\[0\].number)" \
109 "1" "Check breakpoint number 0"
110 gdb_test "python print (blist\[1\].number)" \
111 "2" "Check breakpoint number 1"
112 gdb_test "python print (blist\[2\].number)" \
113 "3" "Check breakpoint number 2"
114 }
115
116 proc_with_prefix test_bkpt_deletion { } {
117 global srcfile testfile hex decimal
118
119 # Start with a fresh gdb.
120 clean_restart ${testfile}
121
122 if ![runto_main] then {
123 fail "cannot run to main."
124 return 0
125 }
126
127 # Test breakpoints are deleted correctly.
128 set deltst_location [gdb_get_line_number "Break at multiply."]
129 set end_location [gdb_get_line_number "Break at end."]
130 gdb_py_test_silent_cmd "python dp1 = gdb.Breakpoint (\"$deltst_location\")" \
131 "Set breakpoint" 0
132 gdb_breakpoint [gdb_get_line_number "Break at end."]
133 gdb_py_test_silent_cmd "python del_list = gdb.breakpoints()" \
134 "Get Breakpoint List" 0
135 gdb_test "python print (len(del_list))" \
136 "3" "Number of breakpoints before delete"
137 gdb_continue_to_breakpoint "Break at multiply." \
138 ".*$srcfile:$deltst_location.*"
139 gdb_py_test_silent_cmd "python dp1.delete()" \
140 "Delete Breakpoint" 0
141 gdb_test "python print (dp1.number)" \
142 "RuntimeError: Breakpoint 2 is invalid.*" \
143 "Check breakpoint invalidated"
144 gdb_py_test_silent_cmd "python del_list = gdb.breakpoints()" \
145 "Get Breakpoint List" 0
146 gdb_test "python print (len(del_list))" \
147 "2" "Number of breakpoints after delete"
148 gdb_continue_to_breakpoint "Break at end." \
149 ".*$srcfile:$end_location.*"
150 }
151
152 proc_with_prefix test_bkpt_cond_and_cmds { } {
153 global srcfile testfile hex decimal
154
155 # Start with a fresh gdb.
156 clean_restart ${testfile}
157
158 if ![runto_main] then {
159 fail "cannot run to main."
160 return 0
161 }
162
163 # Test conditional setting.
164 set bp_location1 [gdb_get_line_number "Break at multiply."]
165 gdb_py_test_silent_cmd "python bp1 = gdb.Breakpoint (\"$bp_location1\")" \
166 "Set breakpoint" 0
167 gdb_continue_to_breakpoint "Break at multiply" \
168 ".*Break at multiply.*"
169 gdb_py_test_silent_cmd "python bp1.condition = \"i == 5\"" \
170 "Set breakpoint" 0
171 gdb_test "python print (bp1.condition)" "i == 5" \
172 "Test conditional has been set"
173 gdb_continue_to_breakpoint "Break at multiply @5" \
174 ".*Break at multiply.*"
175 gdb_test "print i" \
176 "5" "Test conditional breakpoint stopped after five iterations"
177 gdb_py_test_silent_cmd "python bp1.condition = None" \
178 "Clear condition" 0
179 gdb_test "python print (bp1.condition)" \
180 "None" "Test conditional read"
181 gdb_continue_to_breakpoint "Break at multiply @6" \
182 ".*Break at multiply.*"
183 gdb_test "print i" \
184 "6" "Test breakpoint stopped after six iterations"
185
186 # Test commands.
187 gdb_breakpoint [gdb_get_line_number "Break at add."]
188 set test {commands $bpnum}
189 gdb_test_multiple $test $test { -re "\r\n>$" { pass $test } }
190 set test {print "Command for breakpoint has been executed."}
191 gdb_test_multiple $test $test { -re "\r\n>$" { pass $test } }
192 set test {print result}
193 gdb_test_multiple $test $test { -re "\r\n>$" { pass $test } }
194 gdb_test "end"
195
196 gdb_py_test_silent_cmd "python blist = gdb.breakpoints()" \
197 "Get Breakpoint List" 0
198 gdb_test "python print (blist\[len(blist)-1\].commands)" \
199 "print \"Command for breakpoint has been executed.\".*print result"
200 }
201
202 proc_with_prefix test_bkpt_invisible { } {
203 global srcfile testfile hex decimal
204
205 # Start with a fresh gdb.
206 clean_restart ${testfile}
207
208 if ![runto_main] then {
209 fail "cannot run to main."
210 return 0
211 }
212
213 delete_breakpoints
214 set ibp_location [gdb_get_line_number "Break at multiply."]
215 gdb_py_test_silent_cmd "python ibp = gdb.Breakpoint(\"$ibp_location\", internal=False)" \
216 "Set invisible breakpoint" 0
217 gdb_py_test_silent_cmd "python ilist = gdb.breakpoints()" \
218 "Get Breakpoint List" 0
219 gdb_test "python print (ilist\[0\])" \
220 "<gdb.Breakpoint object at $hex>" "Check invisible bp obj exists 1"
221 gdb_test "python print (ilist\[0\].location)" \
222 "py-breakpoint\.c:$ibp_location*" "Check breakpoint location 1"
223 gdb_test "python print (ilist\[0\].visible)" \
224 "True" "Check breakpoint visibility 1"
225 gdb_test "info breakpoints" "py-breakpoint\.c:$ibp_location.*" \
226 "Check info breakpoints shows visible breakpoints"
227 delete_breakpoints
228 gdb_py_test_silent_cmd "python ibp = gdb.Breakpoint(\"$ibp_location\", internal=True)" \
229 "Set invisible breakpoint" 0
230 gdb_py_test_silent_cmd "python ilist = gdb.breakpoints()" \
231 "Get Breakpoint List" 0
232 gdb_test "python print (ilist\[0\])" \
233 "<gdb.Breakpoint object at $hex>" "Check invisible bp obj exists 2"
234 gdb_test "python print (ilist\[0\].location)" \
235 "py-breakpoint\.c:$ibp_location*" "Check breakpoint location 2"
236 gdb_test "python print (ilist\[0\].visible)" \
237 "False" "Check breakpoint visibility 2"
238 gdb_test "info breakpoints" "No breakpoints or watchpoints.*" \
239 "Check info breakpoints does not show invisible breakpoints"
240 gdb_test "maint info breakpoints" \
241 "py-breakpoint\.c:$ibp_location.*" \
242 "Check maint info breakpoints shows invisible breakpoints"
243 }
244
245 proc_with_prefix test_watchpoints { } {
246 global srcfile testfile hex decimal
247
248 # Start with a fresh gdb.
249 clean_restart ${testfile}
250
251 # Disable hardware watchpoints if necessary.
252 if [target_info exists gdb,no_hardware_watchpoints] {
253 gdb_test_no_output "set can-use-hw-watchpoints 0" ""
254 }
255
256 if ![runto_main] then {
257 fail "cannot run to main."
258 return 0
259 }
260
261 gdb_py_test_silent_cmd "python wp1 = gdb.Breakpoint (\"result\", type=gdb.BP_WATCHPOINT, wp_class=gdb.WP_WRITE )" \
262 "Set watchpoint" 0
263 gdb_test "python print (wp1.pending)" "False"
264 gdb_test "continue" \
265 ".*\[Ww\]atchpoint.*result.*Old value = 0.*New value = 25.*main.*" \
266 "Test watchpoint write"
267 }
268
269 proc_with_prefix test_bkpt_internal { } {
270 global srcfile testfile hex decimal
271
272 # Start with a fresh gdb.
273 clean_restart ${testfile}
274
275 # Disable hardware watchpoints if necessary.
276 if [target_info exists gdb,no_hardware_watchpoints] {
277 gdb_test_no_output "set can-use-hw-watchpoints 0" ""
278 }
279 if ![runto_main] then {
280 fail "cannot run to main."
281 return 0
282 }
283 delete_breakpoints
284 gdb_py_test_silent_cmd "python wp1 = gdb.Breakpoint (\"result\", type=gdb.BP_WATCHPOINT, wp_class=gdb.WP_WRITE, internal=True )" \
285 "Set watchpoint" 0
286 gdb_test "info breakpoints" \
287 "No breakpoints or watchpoints.*" \
288 "Check info breakpoints does not show invisible breakpoints"
289 gdb_test "maint info breakpoints" \
290 ".*watchpoint.*result.*" \
291 "Check maint info breakpoints shows invisible breakpoints"
292 gdb_test "continue" \
293 ".*\[Ww\]atchpoint.*result.*Old value = 0.*New value = 25.*" \
294 "Test watchpoint write"
295 }
296
297 proc_with_prefix test_bkpt_eval_funcs { } {
298 global srcfile testfile hex decimal
299
300 # Start with a fresh gdb.
301 clean_restart ${testfile}
302
303 # Disable hardware watchpoints if necessary.
304 if [target_info exists gdb,no_hardware_watchpoints] {
305 gdb_test_no_output "set can-use-hw-watchpoints 0" ""
306 }
307 if ![runto_main] then {
308 fail "cannot run to main."
309 return 0
310 }
311 delete_breakpoints
312
313 gdb_py_test_multiple "Sub-class a breakpoint" \
314 "python" "" \
315 "class bp_eval (gdb.Breakpoint):" "" \
316 " inf_i = 0" "" \
317 " count = 0" "" \
318 " def stop (self):" "" \
319 " self.count = self.count + 1" "" \
320 " self.inf_i = gdb.parse_and_eval(\"i\")" "" \
321 " if self.inf_i == 3:" "" \
322 " return True" "" \
323 " return False" "" \
324 "end" ""
325
326 gdb_py_test_multiple "Sub-class a second breakpoint" \
327 "python" "" \
328 "class bp_also_eval (gdb.Breakpoint):" "" \
329 " count = 0" "" \
330 " def stop (self):" "" \
331 " self.count = self.count + 1" "" \
332 " if self.count == 9:" "" \
333 " return True" "" \
334 " return False" "" \
335 "end" ""
336
337 gdb_py_test_multiple "Sub-class a third breakpoint" \
338 "python" "" \
339 "class basic (gdb.Breakpoint):" "" \
340 " count = 0" "" \
341 "end" ""
342
343 set bp_location2 [gdb_get_line_number "Break at multiply."]
344 set end_location [gdb_get_line_number "Break at end."]
345 gdb_py_test_silent_cmd "python eval_bp1 = bp_eval(\"$bp_location2\")" \
346 "Set breakpoint" 0
347 gdb_py_test_silent_cmd "python also_eval_bp1 = bp_also_eval(\"$bp_location2\")" \
348 "Set breakpoint" 0
349 gdb_py_test_silent_cmd "python never_eval_bp1 = bp_also_eval(\"$end_location\")" \
350 "Set breakpoint" 0
351 gdb_continue_to_breakpoint "Break at multiply, i==3" \
352 ".*$srcfile:$bp_location2.*"
353 gdb_test "print i" \
354 "3" "Check inferior value matches python accounting"
355 gdb_test "python print (eval_bp1.inf_i)" \
356 "3" "Check python accounting matches inferior"
357 gdb_test "python print (also_eval_bp1.count)" "4" \
358 "Check non firing same-location also_eval_bp1 function was also called at each stop."
359 gdb_test "python print (eval_bp1.count)" "4" \
360 "Check non firing same-location eval_bp1 function was also called at each stop."
361
362 delete_breakpoints
363 set cond_bp [gdb_get_line_number "Break at multiply."]
364 gdb_py_test_silent_cmd "python eval_bp1 = bp_eval(\"$cond_bp\")" \
365 "Set breakpoint" 0
366 set test_cond {cond $bpnum}
367 gdb_test "$test_cond \"foo==3\"" \
368 "Only one stop condition allowed. There is currently a Python.*" \
369 "Check you cannot add a CLI condition to a Python breakpoint that has defined stop"
370 gdb_py_test_silent_cmd "python eval_bp2 = basic(\"$cond_bp\")" \
371 "Set breakpoint" 0
372 gdb_py_test_silent_cmd "python eval_bp2.condition = \"1==1\"" \
373 "Set a condition" 0
374 gdb_py_test_multiple "Construct an eval function" \
375 "python" "" \
376 "def stop_func ():" "" \
377 " return True" "" \
378 "end" ""
379
380 gdb_test "python eval_bp2.stop = stop_func" \
381 "RuntimeError: Only one stop condition allowed. There is currently a GDB.*" \
382 "assign stop function to a breakpoint that has a condition"
383
384 delete_breakpoints
385 gdb_breakpoint [gdb_get_line_number "Break at multiply."]
386 gdb_py_test_silent_cmd "python check_eval = bp_eval(\"$bp_location2\")" \
387 "Set breakpoint" 0
388 gdb_test "python print (check_eval.count)" "0" \
389 "Test that evaluate function has not been yet executed (ie count = 0)"
390 gdb_continue_to_breakpoint "Break at multiply, count==1" \
391 ".*$srcfile:$bp_location2.*"
392 gdb_test "python print (check_eval.count)" "1" \
393 "Test that evaluate function is run when location also has normal bp"
394
395 gdb_py_test_multiple "Sub-class a watchpoint" \
396 "python" "" \
397 "class wp_eval (gdb.Breakpoint):" "" \
398 " def stop (self):" "" \
399 " self.result = gdb.parse_and_eval(\"result\")" "" \
400 " if self.result == 788:" "" \
401 " return True" "" \
402 " return False" "" \
403 "end" ""
404
405 delete_breakpoints
406 gdb_py_test_silent_cmd "python wp1 = wp_eval (\"result\", type=gdb.BP_WATCHPOINT, wp_class=gdb.WP_WRITE)" \
407 "Set watchpoint" 0
408 gdb_test "continue" \
409 ".*\[Ww\]atchpoint.*result.*Old value =.*New value = 788.*" \
410 "Test watchpoint write"
411 gdb_test "python print (never_eval_bp1.count)" "0" \
412 "Check that this unrelated breakpoints eval function was never called."
413 }
414
415 proc_with_prefix test_bkpt_temporary { } {
416 global srcfile testfile hex decimal
417
418 # Start with a fresh gdb.
419 clean_restart ${testfile}
420
421 if ![runto_main] then {
422 fail "cannot run to main."
423 return 0
424 }
425 delete_breakpoints
426
427 gdb_py_test_multiple "Sub-class and check temporary breakpoint" \
428 "python" "" \
429 "class temp_bp (gdb.Breakpoint):" "" \
430 " count = 0" "" \
431 " def stop (self):" "" \
432 " self.count = self.count + 1" "" \
433 " return True" "" \
434 "end" ""
435 set ibp_location [gdb_get_line_number "Break at multiply."]
436 gdb_py_test_silent_cmd "python ibp = temp_bp(\"$ibp_location\", temporary=True)" \
437 "Set temporary breakpoint" 0
438 gdb_test "info breakpoints" \
439 "2.*breakpoint.*del.*py-breakpoint\.c:$ibp_location.*" \
440 "Check info breakpoints shows breakpoint with temporary status"
441 gdb_test "python print (ibp.location)" "py-breakpoint\.c:$ibp_location*" \
442 "Check temporary breakpoint location"
443 gdb_test "python print (ibp.temporary)" "True" \
444 "Check breakpoint temporary status"
445 gdb_continue_to_breakpoint "Break at multiply." \
446 ".*$srcfile:$ibp_location.*"
447 gdb_test "python print (ibp.count)" "1" \
448 "Check temporary stop callback executed before deletion."
449 gdb_test "python print (ibp.temporary)" "RuntimeError: Breakpoint 2 is invalid.*" \
450 "Check temporary breakpoint is deleted after being hit"
451 gdb_test "info breakpoints" "No breakpoints or watchpoints.*" \
452 "Check info breakpoints shows temporary breakpoint is deleted"
453 }
454
455 # Test address locations.
456
457 proc_with_prefix test_bkpt_address {} {
458 global gdb_prompt decimal srcfile
459
460 # Delete all breakpoints
461 delete_breakpoints
462
463 gdb_test "python gdb.Breakpoint(\"*main\")" \
464 ".*Breakpoint ($decimal)+ at .*$srcfile, line ($decimal)+\."
465
466 gdb_py_test_silent_cmd \
467 "python main_loc = gdb.parse_and_eval(\"main\").address" \
468 "eval address of main" 0
469
470 # Python 2 vs 3 ... Check `int' first. If that fails, try `long'.
471 gdb_test_multiple "python main_addr = int(main_loc)" "int value of main" {
472 -re "Traceback.*$gdb_prompt $" {
473 gdb_test_no_output "python main_addr = long(main_loc)" \
474 "long value of main"
475 }
476 -re "$gdb_prompt $" {
477 pass "int value of main"
478 }
479 }
480
481 # Include whitespace in the linespec to double-check proper
482 # grokking of argument to gdb.Breakpoint.
483 gdb_test "python gdb.Breakpoint(\" *{}\".format(str(main_addr)))" \
484 ".*Breakpoint ($decimal)+ at .*$srcfile, line ($decimal)+\."
485 }
486
487 proc_with_prefix test_bkpt_pending {} {
488 delete_breakpoints
489 gdb_breakpoint "nosuchfunction" allow-pending
490 gdb_test "python print (gdb.breakpoints()\[0\].pending)" "True" \
491 "Check pending status of pending breakpoint"
492 }
493
494 # Helper proc to install an event listener for a given breakpoint
495 # event. NAME is the name of the event to listen for.
496 proc connect_event {name} {
497 set lambda "lambda x: note_event(\"$name\")"
498 gdb_test_no_output "python gdb.events.$name.connect($lambda)" \
499 "install $name event listener"
500 }
501
502 # Helper proc to check that the most recently emitted breakpoint event
503 # is EXPECTED.
504 proc check_last_event {expected} {
505 gdb_test "python print (last_bp_event)" $expected \
506 "check for $expected event"
507 }
508
509 proc_with_prefix test_bkpt_events {} {
510 global testfile
511
512 clean_restart ${testfile}
513
514 gdb_py_test_multiple "Create event handler" \
515 "python" "" \
516 "def note_event(arg):" "" \
517 " global last_bp_event" "" \
518 " last_bp_event = arg" "" \
519 "end" ""
520 gdb_test_no_output "python last_bp_event = None"
521
522 connect_event breakpoint_created
523 connect_event breakpoint_modified
524 connect_event breakpoint_deleted
525
526 gdb_breakpoint [gdb_get_line_number "Break at add."]
527 check_last_event breakpoint_created
528 gdb_test_no_output "disable 1"
529 check_last_event breakpoint_modified
530 gdb_test_no_output "delete 1"
531 check_last_event breakpoint_deleted
532 }
533
534 proc test_bkpt_explicit_loc {} {
535 global srcfile testfile
536
537 with_test_prefix test_bkpt_invisible {
538 # Start with a fresh gdb.
539 clean_restart ${testfile}
540
541 if ![runto_main] then {
542 fail "cannot run to main."
543 return 0
544 }
545
546 delete_breakpoints
547
548 set bp_location1 [gdb_get_line_number "Break at multiply."]
549 set bp_location2 [gdb_get_line_number "Break at add."]
550
551 gdb_py_test_silent_cmd "python bp1 = gdb.Breakpoint (line=$bp_location1)" \
552 "set explicit breakpoint by line" 0
553 gdb_continue_to_breakpoint "break at multiply for explicit line" \
554 ".*Break at multiply.*"
555
556 gdb_py_test_silent_cmd "python bp1 = gdb.Breakpoint (line=\"+1\")" \
557 "set explicit breakpoint by relative line" 0
558 gdb_continue_to_breakpoint "break at add for relative line" \
559 ".*Break at add.*"
560
561 delete_breakpoints
562 gdb_py_test_silent_cmd "python bp1 = gdb.Breakpoint (line=\"-1\")" \
563 "set explicit breakpoint by relative negative line" 0
564 gdb_continue_to_breakpoint "break at multiply for negative line" \
565 ".*Break at multiply.*"
566
567 delete_breakpoints
568 gdb_test "python bp1 = gdb.Breakpoint (line=bp1)" \
569 "RuntimeError: Line keyword should be an integer or a string.*" \
570 "set explicit breakpoint by invalid line type"
571
572 delete_breakpoints
573 gdb_py_test_silent_cmd "python bp1 = gdb.Breakpoint (function=\"add\")" \
574 "set explicit breakpoint by function" 0
575 gdb_continue_to_breakpoint "break at function add for function" \
576 ".*Break at function add.*"
577
578 delete_breakpoints
579 gdb_py_test_silent_cmd "python bp1 = gdb.Breakpoint (source=\"$srcfile\", function=\"add\")" \
580 "set explicit breakpoint by source file and function" 0
581 gdb_continue_to_breakpoint "break at function add for source and function" \
582 ".*Break at function add.*"
583
584 delete_breakpoints
585 gdb_py_test_silent_cmd "python bp1 = gdb.Breakpoint (source=\"$srcfile\", line=\"$bp_location2\")" \
586 "set explicit breakpoint by source file and line number" 0
587 gdb_continue_to_breakpoint "break at add for source and line" \
588 ".*Break at add.*"
589
590 delete_breakpoints
591 gdb_py_test_silent_cmd "python bp1 = gdb.Breakpoint (\"-source $srcfile -line $bp_location2\")" \
592 "set explicit breakpoint by source file and line number in spec" 0
593 gdb_continue_to_breakpoint "break at add for source and line in spec" \
594 ".*Break at add.*"
595
596 delete_breakpoints
597 gdb_test "python bp1 = gdb.Breakpoint (source=\"$srcfile\")" \
598 "RuntimeError: Specifying a source must also include a line, label or function.*" \
599 "set invalid explicit breakpoint by source only"
600
601 gdb_test "python bp1 = gdb.Breakpoint (source=\"foo.c\", line=\"5\")" \
602 "No source file named foo.*" \
603 "set invalid explicit breakpoint by missing source and line"
604 gdb_test "python bp1 = gdb.Breakpoint (source=\"$srcfile\", line=\"900\")" \
605 "No line 900 in file \"$srcfile\".*" \
606 "set invalid explicit breakpoint by source and invalid line"
607 gdb_test "python bp1 = gdb.Breakpoint (function=\"blah\")" \
608 "Function \"blah\" not defined.*" \
609 "set invalid explicit breakpoint by missing function"
610 }
611 }
612
613 test_bkpt_basic
614 test_bkpt_deletion
615 test_bkpt_cond_and_cmds
616 test_bkpt_invisible
617 test_watchpoints
618 test_bkpt_internal
619 test_bkpt_eval_funcs
620 test_bkpt_temporary
621 test_bkpt_address
622 test_bkpt_pending
623 test_bkpt_events
624 test_bkpt_explicit_loc
This page took 0.060091 seconds and 5 git commands to generate.