1 # Copyright 2012-2019 Free Software Foundation, Inc.
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.
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.
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/>.
18 if { [prepare_for_testing "failed to prepare" ${testfile}] } {
22 # Setup for the test, create COUNT breakpoints at the function BREAKPT.
23 proc test_setup { count } {
27 clean_restart ${binfile}
29 if ![runto_main] then {
30 fail "can't run to main"
34 for {set i 1} {$i <= $count} {incr i} {
35 gdb_breakpoint "breakpt"
36 gdb_test_no_output "set \$bp_num_${i} = \$bpnum"
40 "spacer \\(\\) at .*$srcfile:\[0-9\]+.*" \
41 "step to place breakpoints"
47 # Test 1: Create two breakpoints at BREAKPT. Delete #1 and expect to stop
49 with_test_prefix "del_1_stop_2" {
52 gdb_test_no_output {delete $bp_num_1}
54 gdb_test continue "Continuing\\..*Breakpoint \[0-9\]+, breakpt \\(\\) at .*$srcfile:\[0-9\]+.*" \
55 "delete #1, stop at #2"
58 # Test 2: Create two breakpoints at BREAKPT. Delete #2 and expect to stop
60 with_test_prefix "del_2_stop_1" {
63 gdb_test_no_output {delete $bp_num_2}
65 gdb_test continue "Continuing\\..*Breakpoint \[0-9\]+, breakpt \\(\\) at .*$srcfile:\[0-9\]+.*" \
66 "delete #2, stop at #1"
69 # Test 3: Create three breakpoints at BREAKPT. Disable #1, delete #2,
70 # expect to stop at #3.
71 with_test_prefix "dis_1_del_2_stop_3" {
74 gdb_test_no_output {disable $bp_num_1}
78 gdb_test_no_output {delete $bp_num_2}
80 gdb_test continue "Continuing\\..*Breakpoint \[0-9\]+, breakpt \\(\\) at .*$srcfile:\[0-9\]+.*" \
81 "disable #1, delete #2, stop at #3"
84 # Test 4: Create three breakpoints at BREAKPT. Disable #2, delete #1,
85 # expect to stop at #3.
86 with_test_prefix "dis_2_del_1_stop_3" {
89 gdb_test_no_output {disable $bp_num_2}
93 gdb_test_no_output {delete $bp_num_1}
95 gdb_test continue "Continuing\\..*Breakpoint \[0-9\]+, breakpt \\(\\) at .*$srcfile:\[0-9\]+.*" \
96 "disable #2, delete #1, stop at #3"
99 # Test 5: Create three breakpoints at BREAKPT. Disable #1, delete #3,
100 # expect to stop at #2.
101 with_test_prefix "dis_1_del_3_stop_1" {
104 gdb_test_no_output {disable $bp_num_1}
108 gdb_test_no_output {delete $bp_num_3}
110 gdb_test continue "Continuing\\..*Breakpoint \[0-9\]+, breakpt \\(\\) at .*$srcfile:\[0-9\]+.*" \
111 "disable #1, delete #3, stop at #2"
114 # Test 6: Create three breakpoints at BREAKPT. Disable #3, delete #1,
115 # expect to stop at #2
116 with_test_prefix "dis_3_del_1_stop_2" {
119 gdb_test_no_output {disable $bp_num_3}
123 gdb_test_no_output {delete $bp_num_1}
125 gdb_test continue "Continuing\\..*Breakpoint \[0-9\]+, breakpt \\(\\) at .*$srcfile:\[0-9\]+.*" \
126 "disable #3, delete #1, stop at #2"
129 # Test 7: Create three breakpoints at BREAKPT. Disable #2, delete #3,
130 # expect to stop at #1.
131 with_test_prefix "dis_2_del_3_stop_1" {
134 gdb_test_no_output {disable $bp_num_2}
138 gdb_test_no_output {delete $bp_num_3}
140 gdb_test continue "Continuing\\..*Breakpoint \[0-9\]+, breakpt \\(\\) at .*$srcfile:\[0-9\]+.*" \
141 "disable #2, delete #3, stop at #1"
144 # Test 8: Create three breakpoints at BREAKPT. Disable #3, delete #2,
145 # expect to stop at #1.
146 with_test_prefix "dis_3_del_2_stop_1" {
149 gdb_test_no_output {disable $bp_num_3}
153 gdb_test_no_output {delete $bp_num_2}
155 gdb_test continue "Continuing\\..*Breakpoint \[0-9\]+, breakpt \\(\\) at .*$srcfile:\[0-9\]+.*" \
156 "disable #3, delete #2, stop at #1"