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