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