2011-02-22 Michael Snyder <msnyder@vmware.com>
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.ada / complete.exp
1 # Copyright 2005, 2007, 2009, 2010, 2011 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 if $tracelevel then {
17 strace $tracelevel
18 }
19
20 load_lib "ada.exp"
21
22 set testdir "complete"
23 set testfile "${testdir}/foo"
24 set srcfile ${srcdir}/${subdir}/${testfile}.adb
25 set binfile ${objdir}/${subdir}/${testfile}
26
27 file mkdir ${objdir}/${subdir}/${testdir}
28 if {[gdb_compile_ada "${srcfile}" "${binfile}" executable [list debug ]] != "" } {
29 return -1
30 }
31
32 clean_restart ${testfile}
33
34 set bp_location [gdb_get_line_number "START" ${testdir}/foo.adb]
35 runto "foo.adb:$bp_location"
36
37 set eol "\[\r\n\]*"
38
39 # A convenience function that verifies that the "complete EXPR" command
40 # returns the EXPECTED_OUTPUT.
41
42 proc test_gdb_complete { expr expected_output } {
43 gdb_test "complete p $expr" \
44 "$expected_output" \
45 "complete p $expr"
46 }
47
48 # A convenience function that verifies that the "complete EXPR" command
49 # does not genearte any output.
50
51 proc test_gdb_no_completion { expr } {
52 # FIXME: brobecker/2007-12-27: How do you verify that the command
53 # output is actually really empty??? For now, the following does
54 # not verify this at all:
55 test_gdb_complete "$expr" ""
56 }
57
58 # A convenience function that joins all the arguments together,
59 # with a regexp that matches zero-or-more end of lines in between
60 # each argument. This function is ideal to write the expected output
61 # of a GDB command that generates more than a couple of lines, as
62 # this allows us to write each line as a separate string, which is
63 # easier to read by a human being.
64
65 proc multi_line { args } {
66 return [join $args "\[\r\n\]*"]
67 }
68 # Try a global variable, only one match should be found:
69
70 test_gdb_complete "my_glob" \
71 "p my_global_variable"
72
73 # A global variable, inside a nested package:
74
75 test_gdb_complete "insi" \
76 "p inside_variable"
77
78 # A global variable inside a nested package, but only giving part of
79 # the fully qualified name (top level package name missing):
80
81 test_gdb_no_completion "inner.insi"
82
83 # An incomplete nested package name, were lies a single symbol:
84 test_gdb_complete "pck.inne" \
85 "p pck.inner.inside_variable"
86
87 # A fully qualified symbol name, mangled...
88 test_gdb_complete "pck__inner__ins" \
89 "p pck__inner__inside_variable"
90
91 # A fully qualified symbol name...
92 test_gdb_complete "pck.inner.ins" \
93 "p pck.inner.inside_variable"
94
95 # Make sure that "inside" is not returned as a possible completion
96 # for "side"...
97 test_gdb_no_completion "side"
98
99 # Verify that "Exported_Capitalized" is not returned as a match for
100 # "exported", since its symbol name contains capital letters.
101 test_gdb_no_completion "exported"
102
103 # check the "<...>" notation.
104 test_gdb_complete "<Exported" \
105 "p <Exported_Capitalized>"
106
107 # A global symbol, created by the binder, that starts with __gnat...
108 test_gdb_complete "__gnat_ada_main_progra" \
109 "p __gnat_ada_main_program_name"
110
111 # A global symbol, created by the binder, that starts with __gnat,
112 # and using the '<' notation.
113 test_gdb_complete "<__gnat_ada_main_prog" \
114 "p <__gnat_ada_main_program_name>"
115
116 # A local variable
117 test_gdb_complete "some" \
118 "p some_local_variable"
119
120 # A local variable variable, but in a different procedure. No match
121 # should be returned.
122 test_gdb_no_completion "not_in_sco"
123
124 # A fully qualified variable name that doesn't exist...
125 test_gdb_no_completion "pck.ins"
126
127 # A fully qualified variable name that does exist...
128 test_gdb_complete "pck.my" \
129 "p pck.my_global_variable"
130
131 # A fully qualified package name
132 test_gdb_complete "pck.inne" \
133 "p pck.inner.inside_variable"
134
135 # A fully qualified package name, with a dot at the end
136 test_gdb_complete "pck.inner." \
137 "p pck.inner.inside_variable"
138
139 # Two matches, from the global scope:
140 test_gdb_complete "local_ident" \
141 [multi_line "p local_identical_one" \
142 "p local_identical_two" ]
143
144 # Two matches, from the global scope, but using fully qualified names:
145 test_gdb_complete "pck.local_ident" \
146 [multi_line "p pck.local_identical_one" \
147 "p pck.local_identical_two" ]
148
149 # Two matches, from the global scope, but using mangled fully qualified
150 # names:
151 test_gdb_complete "pck__local_ident" \
152 [multi_line "p pck__local_identical_one" \
153 "p pck__local_identical_two" ]
154
155 # Two matches, one from the global scope, the other from the local scope:
156 test_gdb_complete "external_ident" \
157 [multi_line "p external_identical_one" \
158 "p external_identical_two" ]
159
160 # Complete on the name of package.
161 test_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 on the name of a package followed by a dot:
172 test_gdb_complete "pck." \
173 [multi_line "(p pck\\.ad\[sb\])?" \
174 "(p pck\\.ad\[sb\])?" \
175 "p pck.external_identical_one" \
176 "p pck.inner.inside_variable" \
177 "p pck.local_identical_one" \
178 "p pck.local_identical_two" \
179 "p pck.my_global_variable" \
180 "p pck.proc" ]
181
182 # Complete a mangled symbol name, but using the '<...>' notation.
183 test_gdb_complete "<pck__my" \
184 "p <pck__my_global_variable>"
185
186
This page took 0.034315 seconds and 4 git commands to generate.