blob: c2a3017e62083a9aab8c2857e8d46578493958c9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
|
# Copyright 2017 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# This file is part of the gdb testsuite.
# Test the enable/disable commands with breakpoint location ranges.
# Note: more tests involving involving disable/enable commands on
# multiple locations and breakpoints are found in
# gdb.base/ena-dis-br.exp.
if { [skip_cplus_tests] } { continue }
standard_testfile .cc
if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug c++}]} {
return -1
}
if ![runto 'marker'] then {
fail "run to marker"
return -1
}
# Returns a buffer corresponding to what GDB replies when asking for
# 'info breakpoint'. The parameters are all the existing breakpoints
# enabled/disable value: 'n' or 'y'.
proc make_info_breakpoint_reply_re {b1 b2 b21 b22 b23 b24} {
set ws "\[\t \]+"
return [multi_line \
"Num Type${ws}Disp Enb Address${ws}What.*" \
"1${ws}breakpoint keep ${b1}${ws}.* in marker\\(\\) at .*" \
"${ws}breakpoint already hit 1 time.*" \
"2${ws}breakpoint${ws}keep${ws}${b2}${ws}<MULTIPLE>.*" \
"2.1${ws}${b21}.*" \
"2.2${ws}${b22}.*" \
"2.3${ws}${b23}.*" \
"2.4${ws}${b24}.*" \
]
}
gdb_test "break foo::overload" \
"Breakpoint \[0-9\]+ at $hex: foo::overload. .4 locations." \
"set breakpoint at overload"
gdb_test "info break" [make_info_breakpoint_reply_re y y y y y y] \
"breakpoint info"
# Test the enable/disable commands, and check the enable/disable state
# of the breakpoints/locations in the "info break" output. CMD is the
# actual disable/enable command. The bNN parameters are the same as
# make_info_breakpoint_reply_re's.
proc test_enable_disable {cmd b1 b2 b21 b22 b23 b24} {
gdb_test_no_output $cmd
set re [make_info_breakpoint_reply_re $b1 $b2 $b21 $b22 $b23 $b24]
gdb_test "info break" $re "breakpoint info $cmd"
}
# Check that we can disable/enable a breakpoint with a single
# location.
test_enable_disable "disable 1" n y y y y y
test_enable_disable "enable 1" y y y y y y
# Check that we can disable/disable a breakpoint with multiple
# locations.
test_enable_disable "disable 2" y n y y y y
test_enable_disable "enable 2" y y y y y y
# Check that we can disable/enable a single location breakpoint.
test_enable_disable "disable 2.2" y y y n y y
test_enable_disable "enable 2.2" y y y y y y
# Check that we can disable/enable a range of breakpoint locations.
test_enable_disable "disable 2.2-3" y y y n n y
test_enable_disable "enable 2.2-3" y y y y y y
# Check that we can disable/enable a breakpoint location range with
# START==END.
test_enable_disable "disable 2.2-2" y y y n y y
test_enable_disable "enable 2.2-2" y y y y y y
# Check that we can disable a location breakpoint range with max >
# existing breakpoint location.
gdb_test "disable 2.3-5" "Bad breakpoint location number '5'" \
"disable location breakpoint range with max > existing"
gdb_test "info break" [make_info_breakpoint_reply_re y y y y n n] \
"breakpoint info disable 2.3 to 2.5"
# Check that we can enable a location breakpoint range with max >
# existing breakpoint location.
gdb_test "enable 2.3-5" "Bad breakpoint location number '5'" \
"enable location breakpoint range with max > existing"
gdb_test "info break" [make_info_breakpoint_reply_re y y y y y y] \
"breakpoint info enable 2.3 to 2.5"
# Check that disabling an reverse location breakpoint range does not
# work.
gdb_test_no_output "disable 2.3-2"
gdb_test "info break" [make_info_breakpoint_reply_re y y y y y y] \
"breakpoint info disable 2.3-2"
# Check that disabling an invalid breakpoint location range does not
# cause unexpected behavior.
gdb_test "disable 2.6-7" "Bad breakpoint location number '6'" \
"disable an unvalid location breakpoint range"
gdb_test "info break" [make_info_breakpoint_reply_re y y y y y y] \
"breakpoint info disable 2.6-7"
# Check that disabling an invalid breakpoint location range does not
# cause trouble.
gdb_test_no_output "disable 2.8-6"
gdb_test "info break" [make_info_breakpoint_reply_re y y y y y y] \
"breakpoint info disable 2.8-6"
# Check that invalid/open ranges are handled correctly.
with_test_prefix "open range" {
gdb_test "disable -" "bad breakpoint number at or near: '-'"
gdb_test "disable -1" "bad breakpoint number at or near: '-1'"
gdb_test "disable 1-" "bad breakpoint number at or near: '1-'"
gdb_test "disable 1.-2" "Bad breakpoint location number '-2'"
gdb_test "disable 1.2-" "bad breakpoint number at or near: '2-'"
gdb_test "disable 1.-2-3" "Bad breakpoint location number '-2'"
gdb_test "disable 1-2-3" "bad breakpoint number at or near: '1-2-3'"
}
with_test_prefix "dangling period" {
gdb_test "disable 2." "bad breakpoint number at or near: '2.'"
gdb_test "disable .2" "bad breakpoint number at or near: '.2'"
gdb_test "disable 2.3.4" "bad breakpoint number at or near '2.3.4'"
}
# Check that 0s are handled correctly.
with_test_prefix "zero" {
gdb_test "disable 0" "bad breakpoint number at or near '0'"
gdb_test "disable 0.0" "Bad breakpoint number '0.0'"
gdb_test "disable 0.1" "Bad breakpoint number '0.1'"
gdb_test "disable 0.1-2" "Bad breakpoint number '0.1-2'"
gdb_test "disable 2.0" "bad breakpoint number at or near '2.0'"
# These should really fail...
gdb_test_no_output "disable 2.0-0"
gdb_test_no_output "enable 2.0-0"
gdb_test "disable 2.0-1" "Bad breakpoint location number '0'"
# Likewise, should fail.
gdb_test_no_output "disable 2.1-0"
}
gdb_test "info break" [make_info_breakpoint_reply_re y y y y y y] \
"breakpoint info after invalids"
|