]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.ada/complete.exp
Update year range in copyright notice of all files owned by the GDB project.
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.ada / complete.exp
CommitLineData
32d0add0 1# Copyright 2005-2015 Free Software Foundation, Inc.
439048e8
JB
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
439048e8
JB
16load_lib "ada.exp"
17
8223e12c 18standard_ada_testfile foo
439048e8 19
439048e8
JB
20if {[gdb_compile_ada "${srcfile}" "${binfile}" executable [list debug ]] != "" } {
21 return -1
22}
23
09050809 24clean_restart ${testfile}
439048e8
JB
25
26set bp_location [gdb_get_line_number "START" ${testdir}/foo.adb]
27runto "foo.adb:$bp_location"
28
29set eol "\[\r\n\]*"
30
31# A convenience function that verifies that the "complete EXPR" command
32# returns the EXPECTED_OUTPUT.
33
34proc test_gdb_complete { expr expected_output } {
35 gdb_test "complete p $expr" \
36 "$expected_output" \
37 "complete p $expr"
38}
39
40# A convenience function that verifies that the "complete EXPR" command
177aadc4 41# does not generate any output.
439048e8
JB
42
43proc test_gdb_no_completion { expr } {
177aadc4 44 gdb_test_no_output "complete p $expr"
439048e8
JB
45}
46
47# A convenience function that joins all the arguments together,
48# with a regexp that matches zero-or-more end of lines in between
49# each argument. This function is ideal to write the expected output
50# of a GDB command that generates more than a couple of lines, as
51# this allows us to write each line as a separate string, which is
52# easier to read by a human being.
53
54proc multi_line { args } {
55 return [join $args "\[\r\n\]*"]
56}
57# Try a global variable, only one match should be found:
58
59test_gdb_complete "my_glob" \
60 "p my_global_variable"
61
62# A global variable, inside a nested package:
63
64test_gdb_complete "insi" \
65 "p inside_variable"
66
67# A global variable inside a nested package, but only giving part of
68# the fully qualified name (top level package name missing):
69
70test_gdb_no_completion "inner.insi"
71
72# An incomplete nested package name, were lies a single symbol:
73test_gdb_complete "pck.inne" \
74 "p pck.inner.inside_variable"
75
76# A fully qualified symbol name, mangled...
77test_gdb_complete "pck__inner__ins" \
78 "p pck__inner__inside_variable"
79
80# A fully qualified symbol name...
81test_gdb_complete "pck.inner.ins" \
82 "p pck.inner.inside_variable"
83
84# Make sure that "inside" is not returned as a possible completion
85# for "side"...
86test_gdb_no_completion "side"
87
88# Verify that "Exported_Capitalized" is not returned as a match for
89# "exported", since its symbol name contains capital letters.
90test_gdb_no_completion "exported"
91
92# check the "<...>" notation.
93test_gdb_complete "<Exported" \
94 "p <Exported_Capitalized>"
95
96# A global symbol, created by the binder, that starts with __gnat...
97test_gdb_complete "__gnat_ada_main_progra" \
98 "p __gnat_ada_main_program_name"
99
100# A global symbol, created by the binder, that starts with __gnat,
101# and using the '<' notation.
102test_gdb_complete "<__gnat_ada_main_prog" \
103 "p <__gnat_ada_main_program_name>"
104
105# A local variable
106test_gdb_complete "some" \
107 "p some_local_variable"
108
109# A local variable variable, but in a different procedure. No match
110# should be returned.
111test_gdb_no_completion "not_in_sco"
112
113# A fully qualified variable name that doesn't exist...
114test_gdb_no_completion "pck.ins"
115
116# A fully qualified variable name that does exist...
117test_gdb_complete "pck.my" \
118 "p pck.my_global_variable"
119
120# A fully qualified package name
121test_gdb_complete "pck.inne" \
122 "p pck.inner.inside_variable"
123
124# A fully qualified package name, with a dot at the end
125test_gdb_complete "pck.inner." \
126 "p pck.inner.inside_variable"
127
128# Two matches, from the global scope:
129test_gdb_complete "local_ident" \
130 [multi_line "p local_identical_one" \
131 "p local_identical_two" ]
132
133# Two matches, from the global scope, but using fully qualified names:
134test_gdb_complete "pck.local_ident" \
135 [multi_line "p pck.local_identical_one" \
136 "p pck.local_identical_two" ]
137
138# Two matches, from the global scope, but using mangled fully qualified
139# names:
140test_gdb_complete "pck__local_ident" \
141 [multi_line "p pck__local_identical_one" \
142 "p pck__local_identical_two" ]
143
144# Two matches, one from the global scope, the other from the local scope:
145test_gdb_complete "external_ident" \
146 [multi_line "p external_identical_one" \
147 "p external_identical_two" ]
148
149# Complete on the name of package.
150test_gdb_complete "pck" \
151 [multi_line "(p pck\\.ad\[sb\])?" \
152 "(p pck\\.ad\[sb\])?" \
153 "p pck.external_identical_one" \
154 "p pck.inner.inside_variable" \
155 "p pck.local_identical_one" \
156 "p pck.local_identical_two" \
157 "p pck.my_global_variable" \
158 "p pck.proc" ]
159
160# Complete on the name of a package followed by a dot:
161test_gdb_complete "pck." \
162 [multi_line "(p pck\\.ad\[sb\])?" \
163 "(p pck\\.ad\[sb\])?" \
164 "p pck.external_identical_one" \
165 "p pck.inner.inside_variable" \
166 "p pck.local_identical_one" \
167 "p pck.local_identical_two" \
168 "p pck.my_global_variable" \
169 "p pck.proc" ]
170
171# Complete a mangled symbol name, but using the '<...>' notation.
172test_gdb_complete "<pck__my" \
173 "p <pck__my_global_variable>"
174
b8fea896
JB
175# Very simple completion, but using the interactive form, this time.
176# The verification we are trying to make involves the event loop,
177# and using the "complete" command is not sufficient to reproduce
178# the original problem.
0d4d0e77
YQ
179
180if { [readline_is_used] } {
181 set test "interactive complete 'print some'"
182 send_gdb "print some\t"
183 gdb_test_multiple "" "$test" {
184 -re "^print some_local_variable $" {
185 send_gdb "\n"
186 gdb_test_multiple "" "$test" {
187 -re " = 1$eol$gdb_prompt $" {
188 pass "$test"
189 }
190 }
191 }
b8fea896
JB
192 }
193}