[dwarf]: Add DW_LANG_UPC support in set_cu_language.
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.ada / complete.exp
CommitLineData
28e7fd62 1# Copyright 2005-2013 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
41# does not genearte any output.
42
43proc test_gdb_no_completion { expr } {
44 # FIXME: brobecker/2007-12-27: How do you verify that the command
45 # output is actually really empty??? For now, the following does
46 # not verify this at all:
47 test_gdb_complete "$expr" ""
48}
49
50# A convenience function that joins all the arguments together,
51# with a regexp that matches zero-or-more end of lines in between
52# each argument. This function is ideal to write the expected output
53# of a GDB command that generates more than a couple of lines, as
54# this allows us to write each line as a separate string, which is
55# easier to read by a human being.
56
57proc multi_line { args } {
58 return [join $args "\[\r\n\]*"]
59}
60# Try a global variable, only one match should be found:
61
62test_gdb_complete "my_glob" \
63 "p my_global_variable"
64
65# A global variable, inside a nested package:
66
67test_gdb_complete "insi" \
68 "p inside_variable"
69
70# A global variable inside a nested package, but only giving part of
71# the fully qualified name (top level package name missing):
72
73test_gdb_no_completion "inner.insi"
74
75# An incomplete nested package name, were lies a single symbol:
76test_gdb_complete "pck.inne" \
77 "p pck.inner.inside_variable"
78
79# A fully qualified symbol name, mangled...
80test_gdb_complete "pck__inner__ins" \
81 "p pck__inner__inside_variable"
82
83# A fully qualified symbol name...
84test_gdb_complete "pck.inner.ins" \
85 "p pck.inner.inside_variable"
86
87# Make sure that "inside" is not returned as a possible completion
88# for "side"...
89test_gdb_no_completion "side"
90
91# Verify that "Exported_Capitalized" is not returned as a match for
92# "exported", since its symbol name contains capital letters.
93test_gdb_no_completion "exported"
94
95# check the "<...>" notation.
96test_gdb_complete "<Exported" \
97 "p <Exported_Capitalized>"
98
99# A global symbol, created by the binder, that starts with __gnat...
100test_gdb_complete "__gnat_ada_main_progra" \
101 "p __gnat_ada_main_program_name"
102
103# A global symbol, created by the binder, that starts with __gnat,
104# and using the '<' notation.
105test_gdb_complete "<__gnat_ada_main_prog" \
106 "p <__gnat_ada_main_program_name>"
107
108# A local variable
109test_gdb_complete "some" \
110 "p some_local_variable"
111
112# A local variable variable, but in a different procedure. No match
113# should be returned.
114test_gdb_no_completion "not_in_sco"
115
116# A fully qualified variable name that doesn't exist...
117test_gdb_no_completion "pck.ins"
118
119# A fully qualified variable name that does exist...
120test_gdb_complete "pck.my" \
121 "p pck.my_global_variable"
122
123# A fully qualified package name
124test_gdb_complete "pck.inne" \
125 "p pck.inner.inside_variable"
126
127# A fully qualified package name, with a dot at the end
128test_gdb_complete "pck.inner." \
129 "p pck.inner.inside_variable"
130
131# Two matches, from the global scope:
132test_gdb_complete "local_ident" \
133 [multi_line "p local_identical_one" \
134 "p local_identical_two" ]
135
136# Two matches, from the global scope, but using fully qualified names:
137test_gdb_complete "pck.local_ident" \
138 [multi_line "p pck.local_identical_one" \
139 "p pck.local_identical_two" ]
140
141# Two matches, from the global scope, but using mangled fully qualified
142# names:
143test_gdb_complete "pck__local_ident" \
144 [multi_line "p pck__local_identical_one" \
145 "p pck__local_identical_two" ]
146
147# Two matches, one from the global scope, the other from the local scope:
148test_gdb_complete "external_ident" \
149 [multi_line "p external_identical_one" \
150 "p external_identical_two" ]
151
152# Complete on the name of package.
153test_gdb_complete "pck" \
154 [multi_line "(p pck\\.ad\[sb\])?" \
155 "(p pck\\.ad\[sb\])?" \
156 "p pck.external_identical_one" \
157 "p pck.inner.inside_variable" \
158 "p pck.local_identical_one" \
159 "p pck.local_identical_two" \
160 "p pck.my_global_variable" \
161 "p pck.proc" ]
162
163# Complete on the name of a package followed by a dot:
164test_gdb_complete "pck." \
165 [multi_line "(p pck\\.ad\[sb\])?" \
166 "(p pck\\.ad\[sb\])?" \
167 "p pck.external_identical_one" \
168 "p pck.inner.inside_variable" \
169 "p pck.local_identical_one" \
170 "p pck.local_identical_two" \
171 "p pck.my_global_variable" \
172 "p pck.proc" ]
173
174# Complete a mangled symbol name, but using the '<...>' notation.
175test_gdb_complete "<pck__my" \
176 "p <pck__my_global_variable>"
177
b8fea896
JB
178# Very simple completion, but using the interactive form, this time.
179# The verification we are trying to make involves the event loop,
180# and using the "complete" command is not sufficient to reproduce
181# the original problem.
182set test "interactive complete 'print some'"
183send_gdb "print some\t"
184gdb_test_multiple "" "$test" {
185 -re "^print some_local_variable $" {
186 send_gdb "\n"
187 gdb_test_multiple "" "$test" {
188 -re " = 1$eol$gdb_prompt $" {
189 pass "$test"
190 }
191 }
192 }
193}
This page took 0.593708 seconds and 4 git commands to generate.