Update copyright year range in all GDB files.
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.linespec / cpls-abi-tag.exp
CommitLineData
b811d2c2 1# Copyright 2017-2020 Free Software Foundation, Inc.
bd69330d
PA
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 ABI tag support in linespecs.
19
20load_lib completion-support.exp
21
22standard_testfile cpls-abi-tag.cc
23
24if {[prepare_for_testing "failed to prepare" $testfile \
25 [list $srcfile] {c++ debug}]} {
26 return -1
27}
28
4ee9b0c5
SL
29# Tests below are about tab-completion, which doesn't work if readline
30# library isn't used. Check it first.
31
32if { ![readline_is_used] } {
33 untested "no tab completion support without readline"
34 return -1
35}
36
bd69330d
PA
37gdb_test_no_output "set max-completions unlimited"
38
39# Check that the explicit location completer manages to find the next
40# option name after a -function option, when the -function's argument
41# is a function with an ABI tag.
42
43proc check_explicit_skips_function_argument {function} {
44 test_gdb_complete_unique \
45 "b -function $function -sour" \
46 "b -function $function -source"
47}
48
49# The ABI tag tests.
50
51proc_with_prefix test_abi_tag {} {
52 with_test_prefix "completion" {
53 foreach cmd_prefix {"b" "b -function"} {
54 # Complete all prefixes between "_funcio" and the full
55 # prototype. The ABI tag is not considered for actual
56 # completion.
57
58 with_test_prefix "skip tag" {
59 # set location "test_abi_tag_function\[abi:tag1\](int)"
60 set location "test_abi_tag_function(int)"
61 set line "$cmd_prefix $location"
62 set start [index_after "_functio" $line]
63 test_complete_prefix_range $line $start
64 }
65
66 # Now the same, but start completing at the [. In that case,
67 # GDB considers the ABI tag as part of actual completion.
68 with_test_prefix "at tag" {
69 set location "test_abi_tag_function\[abi:tag1\](int)"
70 set line "$cmd_prefix $location"
71 set start [index_after "_function" $line]
72 test_complete_prefix_range $line $start
73 }
74
75 # Same, but with extra spaces. Note that the original spaces in
76 # the input line are preserved after completion.
77
78 with_test_prefix "spaces" {
79 test_gdb_complete_unique \
80 "$cmd_prefix test_abi_tag_function \[abi:tag1\] (" \
81 "$cmd_prefix test_abi_tag_function \[abi:tag1\] (int)"
82
83 test_gdb_complete_unique \
84 "$cmd_prefix test_abi_tag_function \[abi:tag1\] ( int " \
85 "$cmd_prefix test_abi_tag_function \[abi:tag1\] ( int )"
86 }
87 }
88 }
89
90 with_test_prefix "set breakpoints" {
91 foreach cmd_prefix {"b" "b -function"} {
92 # Test setting breakpoints. If the symbol name has an ABI
93 # tag, but the input linespec doesn't, then the ABI tag in the
94 # symbol name is ignored.
95 set linespec_list {
96 "test_abi_tag_function"
97 "test_abi_tag_function[abi:tag1]"
98 "test_abi_tag_function[abi:tag1](int)"
99 "test_abi_tag_function [abi:tag1]"
100 "test_abi_tag_function [abi:tag1] ( int )"
101 "test_abi_tag_function(int)"
102 "test_abi_tag_function (int)"
103 "test_abi_tag_function ( int )"
104 }
105 foreach linespec $linespec_list {
106 check_bp_locations_match_list \
107 "$cmd_prefix $linespec" [list $location]
108 }
109 }
110 }
111
112 with_test_prefix "set breakpoints wrong ABI tag" {
113 foreach cmd_prefix {"b" "b -function"} {
114 # Test setting breakpoints with the wrong ABI tag. Should
115 # fail to create the breakpoints. Completion should not find
116 # any match either.
117 set linespec_list {
118 "test_abi_tag_function[abi:tag2]"
119 "test_abi_tag_function[abi:tag2](int)"
120 "test_abi_tag_function [abi:tag2]"
121 "test_abi_tag_function [abi:tag2] ( int )"
122 }
123 foreach linespec $linespec_list {
124 check_setting_bp_fails "$cmd_prefix $linespec"
125 test_gdb_complete_none "$cmd_prefix $linespec"
126 }
127
128 }
129 }
130
131 # Test completion of overloaded functions with ABI tags.
132 with_test_prefix "completion of overloaded functions" {
133 foreach cmd_prefix {"b" "b -function"} {
134 set completion_list {
135 "test_abi_tag_ovld_function[abi:tag1]()"
136 "test_abi_tag_ovld_function[abi:tag1](int)"
137 }
138
139 # If the input string does not include the ABI tag, then
140 # actual completion ignores it.
141 test_gdb_complete_multiple \
142 "$cmd_prefix " "test_abi_tag_ovld_f" "unction(" \
143 $completion_list
144
145 # Otherwise, it's considered.
146 test_gdb_complete_multiple \
147 "$cmd_prefix " "test_abi_tag_ovld_function\[" "abi:tag1\](" \
148 $completion_list
149
150 }
151 }
152
153 # Test setting breakpoints on overloaded functions with ABI tags.
154 with_test_prefix "breakpoints on overloaded functions" {
155 foreach cmd_prefix {"b" "b -function"} {
156 set completion_list {
157 "test_abi_tag_ovld_function[abi:tag1]()"
158 "test_abi_tag_ovld_function[abi:tag1](int)"
159 }
160 set location_list {
161 "test_abi_tag_ovld_function"
162 "test_abi_tag_ovld_function[abi:tag1]"
163 }
164 foreach linespec $location_list {
165 check_bp_locations_match_list \
166 "$cmd_prefix $linespec" $completion_list
167 }
168
169 }
170 }
171
172 with_test_prefix "completion of overloaded functions different abi" {
173 foreach cmd_prefix {"b" "b -function"} {
174 # Test completion of overloaded functions with ABI tags.
175 set completion_list {
176 "test_abi_tag_ovld2_function()"
177 "test_abi_tag_ovld2_function[abi:tag1](short)"
178 "test_abi_tag_ovld2_function[abi:tag2](int)"
179 "test_abi_tag_ovld2_function[abi:tag2](long)"
180 }
181
182 # If the input string does not include the ABI tag, then
183 # actual completion ignores it.
184 test_gdb_complete_multiple \
185 "$cmd_prefix " "test_abi_tag_ovld2_f" "unction(" \
186 $completion_list
187
188 # Otherwise, it's considered. Match stops at the part of
189 # the tag that diverges, and the completion list only
190 # shows matches with ABI tags.
191 set completion_list {
192 "test_abi_tag_ovld2_function[abi:tag1](short)"
193 "test_abi_tag_ovld2_function[abi:tag2](int)"
194 "test_abi_tag_ovld2_function[abi:tag2](long)"
195 }
196 test_gdb_complete_multiple \
197 "$cmd_prefix " "test_abi_tag_ovld2_function\[" "abi:tag" \
198 $completion_list
199
200 # If you disambiguate, matches include only locations for
201 # the specified tag.
202 set completion_list {
203 "test_abi_tag_ovld2_function[abi:tag2](int)"
204 "test_abi_tag_ovld2_function[abi:tag2](long)"
205 }
206 test_gdb_complete_multiple \
207 "$cmd_prefix " "test_abi_tag_ovld2_function\[abi:tag2" "\](" \
208 $completion_list
209
210 test_gdb_complete_unique \
211 "$cmd_prefix test_abi_tag_ovld2_function\[abi:tag1" \
212 "$cmd_prefix test_abi_tag_ovld2_function\[abi:tag1\](short)"
213 }
214 }
215
216 with_test_prefix "completion of struct prefixes with tags" {
217 foreach cmd_prefix {"b" "b -function"} {
218 # Test completion of methods of structs with ABI tags.
219 set completion_list {
220 "test_abi_tag_struct[abi:tag1]::test_abi_tag_struct[abi:tag2]()"
221 "test_abi_tag_struct[abi:tag1]::~test_abi_tag_struct[abi:tag2]()"
222 }
223
224 # If the input string does not include the ABI tag, then
225 # actual completion ignores it.
226 test_gdb_complete_multiple \
227 "$cmd_prefix " "test_abi_tag_struc" "t::" \
228 $completion_list
229
230 # Otherwise, it's considered.
231 test_gdb_complete_multiple \
232 "$cmd_prefix " "test_abi_tag_struct\[" "abi:tag1\]::" \
233 $completion_list
234
235 # Mix and match different abi tag positions.
236 test_gdb_complete_unique \
237 "$cmd_prefix test_abi_tag_struct::t" \
238 "$cmd_prefix test_abi_tag_struct::test_abi_tag_struct()"
239
240 test_gdb_complete_unique \
241 "$cmd_prefix test_abi_tag_struct\[abi:tag1\]::t" \
242 "$cmd_prefix test_abi_tag_struct\[abi:tag1\]::test_abi_tag_struct()"
243
244 test_gdb_complete_unique \
245 "$cmd_prefix test_abi_tag_struct\[abi:tag1\]::test_abi_tag_struct\[" \
246 "$cmd_prefix test_abi_tag_struct\[abi:tag1\]::test_abi_tag_struct\[abi:tag2\]()"
247 }
248 }
249
250 with_test_prefix "abi tag in parameters" {
251 foreach cmd_prefix {"b" "b -function"} {
252 # Complete all prefixes between "_funcio" and the full
253 # prototype. The ABI tag is not considered for actual
254 # completion.
255
256 set completion_list {
257 "test_abi_tag_in_params(abi_tag_param_struct1[abi:tag2])"
258 "test_abi_tag_in_params(abi_tag_param_struct1[abi:tag2], abi_tag_param_struct2[abi:tag2])"
259 }
260 # If the input string does not include the ABI tag, then
261 # actual completion ignores it.
262 test_gdb_complete_multiple \
263 "$cmd_prefix " "test_abi_tag_in_para" "ms(abi_tag_param_struct1" \
264 $completion_list
265
266 # If OTOH the input string includes the ABI tag, then it
267 # is considered.
268 test_gdb_complete_multiple \
269 "$cmd_prefix " "test_abi_tag_in_params(abi_tag_param_struct1\[ab" "i:tag2\]"\
270 $completion_list
271
272 set location_list {
273 "test_abi_tag_in_params(abi_tag_param_struct1[abi:tag2], abi_tag_param_struct2[abi:tag2])"
274 }
275
276 set tags {"" "\[abi:tag2\]"}
277 foreach tag1 $tags {
278 foreach tag2 $tags {
279 set linespec "test_abi_tag_in_params(abi_tag_param_struct1${tag1}, abi_tag_param_struct2${tag2})"
280 check_bp_locations_match_list \
281 "$cmd_prefix $linespec" $location_list
282 }
283 }
284 }
285 }
286
287 # Check that the explicit location completer manages to find the
288 # option name after -function, when the -function's argument is a
289 # function with an ABI tag.
290 check_explicit_skips_function_argument \
291 "test_abi_tag_function\[abi:unknown\](int)"
292}
293
294test_abi_tag
This page took 0.27729 seconds and 4 git commands to generate.