Copyright year update in most files of the GDB Project.
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / constvars.exp
1 # Copyright 1997-2004, 2007-2012 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 # written by Elena Zannoni (elz@apollo.hp.com)
17 #
18 # This file is part of the gdb testsuite
19 #
20 # tests for const variables
21 # const pointers to vars
22 # pointers to const variables
23 # const pointers to const vars
24 # with mixed types
25
26 if $tracelevel then {
27 strace $tracelevel
28 }
29
30 #
31 # test running programs
32 #
33
34 set testfile "constvars"
35 set srcfile ${testfile}.c
36 set binfile ${objdir}/${subdir}/${testfile}
37
38 # Create and source the file that provides information about the compiler
39 # used to compile the test case.
40 if [get_compiler_info ${binfile}] {
41 return -1;
42 }
43
44 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable debug ] != "" } {
45 untested constvars.exp
46 return -1
47 }
48
49 gdb_exit
50 gdb_start
51 gdb_reinitialize_dir $srcdir/$subdir
52 gdb_load ${binfile}
53
54
55 #
56 # set it up at a breakpoint so we can play with the variable values
57 #
58 if ![runto_main] then {
59 perror "couldn't run to breakpoint"
60 continue
61 }
62
63 get_debug_format
64
65 # Many tests xfail with gcc 2 -gstabs+.
66 # TODO: check out the hp side of this.
67
68 proc local_compiler_xfail_check { } {
69 if { [test_compiler_info gcc-2-*] } then {
70 if { ![test_debug_format "HP"] \
71 && ![test_debug_format "DWARF 2"] } then {
72 setup_xfail "*-*-*"
73 }
74 }
75
76 global hp_cc_compiler
77 if { $hp_cc_compiler } {
78 setup_xfail "hppa*-*-hpux*"
79 }
80 }
81
82 # A few tests still xfail with gcc 3 -gstabs+ and gcc 4 -gstabs+.
83
84 proc local_compiler_xfail_check_2 { } {
85 if { [test_compiler_info gcc-3-*] || [test_compiler_info gcc-4-*] } {
86 if { [test_debug_format "stabs" ] } {
87 setup_xfail "*-*-*"
88 }
89 }
90 }
91
92 gdb_test "break marker1" "Breakpoint $decimal at .*"
93
94 gdb_test_multiple "cont" "up from marker1" {
95 -re "Break.* marker1 \\(\\) at .*:$decimal.*$gdb_prompt $" {
96 pass "continue to marker1"
97 gdb_test "up" " main .*" "up from marker1"
98 }
99 -re "Break.* marker1__.* \\(\\) at .*:$decimal.*$gdb_prompt $" {
100 fail "continue to marker1 (demangling)"
101 gdb_test "up" " main .*" "up from marker1"
102 }
103 }
104
105 # test function parameters
106
107 local_compiler_xfail_check
108 local_compiler_xfail_check_2
109
110 gdb_test "ptype qux1" \
111 "type = int \\(const char, const char, const char \\*, char \\* const\\).*"
112
113 # test vars and pointers
114
115 proc do_constvar_tests {} {
116 gdb_test "print lave" " = 66 'B'"
117 gdb_test "ptype lave" "type = char"
118 gdb_test "print lavish" " = 10 '\\\\n'"
119 gdb_test "ptype lavish" "type = unsigned char"
120 gdb_test "print lax" " = 20"
121 gdb_test "ptype lax" "type = short.*"
122 gdb_test "print lecherous" " = 30"
123 gdb_test "ptype lecherous" "type = (unsigned short|short unsigned)( int)?"
124 gdb_test "print lechery" " = 40"
125 gdb_test "ptype lechery" "type = long.*"
126 gdb_test "print lectern" " = 50"
127 gdb_test "ptype lectern" "type = (unsigned long|long unsigned)( int)?"
128 gdb_test "print leeway" " = 60"
129 gdb_test "ptype leeway" "type = float"
130 gdb_test "print legacy" " = 70"
131 gdb_test "ptype legacy" "type = double"
132 gdb_test "print laconic" " = 65 'A'"
133 local_compiler_xfail_check
134 gdb_test "ptype laconic" "type = const char"
135 gdb_test "print laggard" " = 1 '.001'"
136 local_compiler_xfail_check
137 gdb_test "ptype laggard" "type = const unsigned char"
138 gdb_test "print lagoon" " = 2"
139 local_compiler_xfail_check
140 gdb_test "ptype lagoon" "type = const short( int)?"
141 gdb_test "print laity" " = 3"
142 local_compiler_xfail_check
143 gdb_test "ptype laity" "type = const (unsigned short|short unsigned)( int)?"
144 gdb_test "print lambent" " = 4"
145 local_compiler_xfail_check
146 gdb_test "ptype lambent" "type = const long( int)?"
147 gdb_test "print laminated" " = 5"
148 local_compiler_xfail_check
149 gdb_test "ptype laminated" "type = const (unsigned long|long unsigned)( int)?"
150 gdb_test "print lampoon" " = 6"
151 local_compiler_xfail_check
152 gdb_test "ptype lampoon" "type = const float"
153 gdb_test "print languid" " = 7"
154 local_compiler_xfail_check
155 gdb_test "ptype languid" "type = const double"
156 gdb_test "print *legend" " = 66 'B'"
157 local_compiler_xfail_check
158 gdb_test "ptype legend" "type = const char \\*"
159 gdb_test "print *legerdemain" " = 10 '\\\\n'"
160 local_compiler_xfail_check
161 gdb_test "ptype legerdemain" "type = const unsigned char \\*"
162 gdb_test "print *leniency" " = 20"
163 local_compiler_xfail_check
164 gdb_test "ptype leniency" "type = const short( int)? \\*"
165 gdb_test "print *leonine" " = 30"
166 local_compiler_xfail_check
167 gdb_test "ptype leonine" "type = const (unsigned short|short unsigned)( int)? \\*"
168 gdb_test "print *lesion" " = 40"
169 local_compiler_xfail_check
170 gdb_test "ptype lesion" "type = const long( int)? \\*"
171 gdb_test "print *lethal" " = 50"
172 local_compiler_xfail_check
173 gdb_test "ptype lethal" "type = const (unsigned long|long unsigned)( int)? \\*"
174 gdb_test "print *lethargic" " = 60"
175 local_compiler_xfail_check
176 gdb_test "ptype lethargic" "type = const float \\*"
177 gdb_test "print *levity" " = 70"
178 local_compiler_xfail_check
179 gdb_test "ptype levity" "type = const double \\*"
180 gdb_test "print *lewd" " = 65 'A'"
181 local_compiler_xfail_check
182 gdb_test "ptype lewd" "type = const char \\* const"
183 gdb_test "print *lexicographer" " = 1 '.001'"
184 local_compiler_xfail_check
185 gdb_test "ptype lexicographer" "type = const unsigned char \\* const"
186 gdb_test "print *lexicon" " = 2"
187 local_compiler_xfail_check
188 gdb_test "ptype lexicon" "type = const short( int)? \\* const"
189 gdb_test "print *liaison" " = 3"
190 local_compiler_xfail_check
191 gdb_test "ptype liaison" "type = const (unsigned short|short unsigned)( int)? \\* const"
192 gdb_test "print *libation" " = 4"
193 local_compiler_xfail_check
194 gdb_test "ptype libation" "type = const long( int)? \\* const"
195 gdb_test "print *libelous" " = 5"
196 local_compiler_xfail_check
197 gdb_test "ptype libelous" "type = const (unsigned long|long unsigned)( int)? \\* const"
198 gdb_test "print *libertine" " = 6"
199 local_compiler_xfail_check
200 gdb_test "ptype libertine" "type = const float \\* const"
201 gdb_test "print *libidinous" " = 7"
202 local_compiler_xfail_check
203 gdb_test "ptype libidinous" "type = const double \\* const"
204 gdb_test "print *languish" " = 65 'A'"
205 local_compiler_xfail_check
206 gdb_test "ptype languish" "type = const char \\*"
207 gdb_test "print *languor" " = 1 '.001'"
208 local_compiler_xfail_check
209 gdb_test "ptype languor" "type = const unsigned char \\*"
210 gdb_test "print *lank" " = 2"
211 local_compiler_xfail_check
212 gdb_test "ptype lank" "type = const short( int)? \\*"
213 gdb_test "print *lapidary" " = 3"
214 local_compiler_xfail_check
215 gdb_test "ptype lapidary" "type = const (unsigned short|short unsigned)( int)? \\*"
216 gdb_test "print *larceny" " = 4"
217 local_compiler_xfail_check
218 gdb_test "ptype larceny" "type = const long( int)? \\*"
219 gdb_test "print *largess" " = 5"
220 local_compiler_xfail_check
221 gdb_test "ptype largess" "type = const (unsigned long|long unsigned)( int)? \\*"
222 gdb_test "print *lascivious" " = 6"
223 local_compiler_xfail_check
224
225 gdb_test "ptype lascivious" "type = const float \\*"
226 gdb_test "print *lassitude" " = 7"
227 local_compiler_xfail_check
228 gdb_test "ptype lassitude" "type = const double \\*"
229 gdb_test "print *lamprey" " = 66 'B'"
230 local_compiler_xfail_check
231 gdb_test "ptype lamprey" "type = char \\* const"
232 gdb_test "print *lariat" " = 10 '\\\\n'"
233 local_compiler_xfail_check
234 gdb_test "ptype lariat" "type = unsigned char \\* const"
235 gdb_test "print *laudanum" " = 20"
236 local_compiler_xfail_check
237 gdb_test "ptype laudanum" "type = short( int)? \\* const"
238 gdb_test "print *lecithin" " = 30"
239 local_compiler_xfail_check
240 gdb_test "ptype lecithin" "type = (unsigned short|short unsigned)( int)? \\* const"
241 gdb_test "print *leviathan" " = 40"
242 local_compiler_xfail_check
243 gdb_test "ptype leviathan" "type = long( int)? \\* const"
244 gdb_test "print *libretto" " = 50"
245 local_compiler_xfail_check
246 gdb_test "ptype libretto" "type = (unsigned long|long unsigned)( int)? \\* const"
247 gdb_test "print *lissome" " = 60"
248 local_compiler_xfail_check
249 gdb_test "ptype lissome" "type = float \\* const"
250 gdb_test "print *locust" " = 70"
251 local_compiler_xfail_check
252 gdb_test "ptype locust" "type = double \\* const"
253
254 local_compiler_xfail_check
255 gdb_test "ptype logical" "type = const char \\\[2\\\]"
256 local_compiler_xfail_check
257 gdb_test "ptype lugged" "type = const unsigned char \\\[2\\\]"
258 local_compiler_xfail_check
259 gdb_test "ptype luck" "type = const short( int)? \\\[2\\\]"
260 local_compiler_xfail_check
261 gdb_test "ptype lunar" "type = const (unsigned short|short unsigned)( int)? \\\[2\\\]"
262 local_compiler_xfail_check
263 gdb_test "ptype lumen" "type = const long( int)? \\\[2\\\]"
264 local_compiler_xfail_check
265 gdb_test "ptype lurk" "type = const (unsigned long|long unsigned)( int)? \\\[2\\\]"
266 local_compiler_xfail_check
267 gdb_test "ptype lush" "type = const float \\\[2\\\]"
268 local_compiler_xfail_check
269 gdb_test "ptype lynx" "type = const double \\\[2\\\]"
270
271 local_compiler_xfail_check
272 local_compiler_xfail_check_2
273 gdb_test "ptype crass" "type = struct crass \{\[\r\n\]+\[\ \t\]+char \\* const ptr;\[\r\n\]+\}"
274 local_compiler_xfail_check
275 gdb_test "ptype crisp" "type = struct crisp \{\[\r\n\]+\[\ \t\]+char \\* const \\*ptr;\[\r\n\]+\}"
276 }
277
278 do_constvar_tests
This page took 0.036072 seconds and 5 git commands to generate.