Add base 'enable/disable invalid location range' tests
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.cp / ena-dis-br-range.exp
CommitLineData
d0fe4701
XR
1# Copyright 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.
17
18# Test the enable/disable commands with breakpoint location ranges.
19
20# Note: more tests involving involving disable/enable commands on
21# multiple locations and breakpoints are found in
22# gdb.base/ena-dis-br.exp.
23
24if { [skip_cplus_tests] } { continue }
25
26standard_testfile .cc
27
28if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug c++}]} {
29 return -1
30}
31
32if ![runto 'marker'] then {
33 fail "run to marker"
34 return -1
35}
36
37# Returns a buffer corresponding to what GDB replies when asking for
38# 'info breakpoint'. The parameters are all the existing breakpoints
39# enabled/disable value: 'n' or 'y'.
40
41proc make_info_breakpoint_reply_re {b1 b2 b21 b22 b23 b24} {
42 set ws "\[\t \]+"
43 return [multi_line \
44 "Num Type${ws}Disp Enb Address${ws}What.*" \
45 "1${ws}breakpoint keep ${b1}${ws}.* in marker\\(\\) at .*" \
46 "${ws}breakpoint already hit 1 time.*" \
47 "2${ws}breakpoint${ws}keep${ws}${b2}${ws}<MULTIPLE>.*" \
48 "2.1${ws}${b21}.*" \
49 "2.2${ws}${b22}.*" \
50 "2.3${ws}${b23}.*" \
51 "2.4${ws}${b24}.*" \
52 ]
53}
54
55gdb_test "break foo::overload" \
56 "Breakpoint \[0-9\]+ at $hex: foo::overload. .4 locations." \
57 "set breakpoint at overload"
58
59gdb_test "info break" [make_info_breakpoint_reply_re y y y y y y] \
60 "breakpoint info"
61
62# Test the enable/disable commands, and check the enable/disable state
63# of the breakpoints/locations in the "info break" output. CMD is the
64# actual disable/enable command. The bNN parameters are the same as
65# make_info_breakpoint_reply_re's.
66proc test_enable_disable {cmd b1 b2 b21 b22 b23 b24} {
67 gdb_test_no_output $cmd
68
69 set re [make_info_breakpoint_reply_re $b1 $b2 $b21 $b22 $b23 $b24]
70 gdb_test "info break" $re "breakpoint info $cmd"
71}
72
73# Check that we can disable/enable a breakpoint with a single
74# location.
75test_enable_disable "disable 1" n y y y y y
76test_enable_disable "enable 1" y y y y y y
77
78# Check that we can disable/disable a breakpoint with multiple
79# locations.
80test_enable_disable "disable 2" y n y y y y
81test_enable_disable "enable 2" y y y y y y
82
83# Check that we can disable/enable a single location breakpoint.
84test_enable_disable "disable 2.2" y y y n y y
85test_enable_disable "enable 2.2" y y y y y y
86
87# Check that we can disable/enable a range of breakpoint locations.
88test_enable_disable "disable 2.2-3" y y y n n y
89test_enable_disable "enable 2.2-3" y y y y y y
90
91# Check that we can disable/enable a breakpoint location range with
92# START==END.
93test_enable_disable "disable 2.2-2" y y y n y y
94test_enable_disable "enable 2.2-2" y y y y y y
95
96# Check that we can disable a location breakpoint range with max >
97# existing breakpoint location.
98gdb_test "disable 2.3-5" "Bad breakpoint location number '5'" \
99 "disable location breakpoint range with max > existing"
100
101gdb_test "info break" [make_info_breakpoint_reply_re y y y y n n] \
102 "breakpoint info disable 2.3 to 2.5"
103
104# Check that we can enable a location breakpoint range with max >
105# existing breakpoint location.
106gdb_test "enable 2.3-5" "Bad breakpoint location number '5'" \
107 "enable location breakpoint range with max > existing"
108
109gdb_test "info break" [make_info_breakpoint_reply_re y y y y y y] \
110 "breakpoint info enable 2.3 to 2.5"
111
112# Check that disabling an reverse location breakpoint range does not
113# work.
114gdb_test_no_output "disable 2.3-2"
115
116gdb_test "info break" [make_info_breakpoint_reply_re y y y y y y] \
117 "breakpoint info disable 2.3-2"
118
119# Check that disabling an invalid breakpoint location range does not
120# cause unexpected behavior.
121gdb_test "disable 2.6-7" "Bad breakpoint location number '6'" \
122 "disable an unvalid location breakpoint range"
123
124gdb_test "info break" [make_info_breakpoint_reply_re y y y y y y] \
125 "breakpoint info disable 2.6-7"
126
127# Check that disabling an invalid breakpoint location range does not
128# cause trouble.
129gdb_test_no_output "disable 2.8-6"
130
131gdb_test "info break" [make_info_breakpoint_reply_re y y y y y y] \
132 "breakpoint info disable 2.8-6"
cee62dbd
PA
133
134# Check that invalid/open ranges are handled correctly.
135with_test_prefix "open range" {
136 gdb_test "disable -" "bad breakpoint number at or near: '-'"
137 gdb_test "disable -1" "bad breakpoint number at or near: '-1'"
138 gdb_test "disable 1-" "bad breakpoint number at or near: '1-'"
139 gdb_test "disable 1.-2" "Bad breakpoint location number '-2'"
140 gdb_test "disable 1.2-" "bad breakpoint number at or near: '2-'"
141 gdb_test "disable 1.-2-3" "Bad breakpoint location number '-2'"
142 gdb_test "disable 1-2-3" "bad breakpoint number at or near: '1-2-3'"
143}
144
145with_test_prefix "dangling period" {
146 gdb_test "disable 2." "bad breakpoint number at or near: '2.'"
147 gdb_test "disable .2" "bad breakpoint number at or near: '.2'"
148 gdb_test "disable 2.3.4" "bad breakpoint number at or near '2.3.4'"
149}
150
151# Check that 0s are handled correctly.
152with_test_prefix "zero" {
153 gdb_test "disable 0" "bad breakpoint number at or near '0'"
154 gdb_test "disable 0.0" "Bad breakpoint number '0.0'"
155 gdb_test "disable 0.1" "Bad breakpoint number '0.1'"
156 gdb_test "disable 0.1-2" "Bad breakpoint number '0.1-2'"
157 gdb_test "disable 2.0" "bad breakpoint number at or near '2.0'"
158
159 # These should really fail...
160 gdb_test_no_output "disable 2.0-0"
161 gdb_test_no_output "enable 2.0-0"
162
163 gdb_test "disable 2.0-1" "Bad breakpoint location number '0'"
164
165 # Likewise, should fail.
166 gdb_test_no_output "disable 2.1-0"
167}
168
169gdb_test "info break" [make_info_breakpoint_reply_re y y y y y y] \
170 "breakpoint info after invalids"
This page took 0.031041 seconds and 4 git commands to generate.