[ChangeLog]
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / constvars.exp
1 # Copyright 1997, 1998, 1999, 2000, 2001, 2002, 2003
2 # Free Software Foundation, Inc.
3
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 2 of the License, or
7 # (at your option) any later version.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
17
18 # Please email any bugs, comments, and/or additions to this file to:
19 # bug-gdb@prep.ai.mit.edu
20
21 # written by Elena Zannoni (elz@apollo.hp.com)
22 #
23 # This file is part of the gdb testsuite
24 #
25 # tests for const variables
26 # const pointers to vars
27 # pointers to const variables
28 # const pointers to const vars
29 # with mixed types
30
31 if $tracelevel then {
32 strace $tracelevel
33 }
34
35 #
36 # test running programs
37 #
38 set prms_id 0
39 set bug_id 0
40
41 set testfile "constvars"
42 set srcfile ${testfile}.c
43 set binfile ${objdir}/${subdir}/${testfile}
44
45 # Create and source the file that provides information about the compiler
46 # used to compile the test case.
47 if [get_compiler_info ${binfile}] {
48 return -1;
49 }
50
51 if {$hp_aCC_compiler || $hp_cc_compiler} {
52 set lang "c++"
53 } else {
54 set lang ""
55 }
56
57 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable [concat debug $lang]] != "" } {
58 gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
59 }
60
61 # Create and source the file that provides information about the compiler
62 # used to compile the test case.
63
64 if [get_compiler_info ${binfile}] {
65 return -1;
66 }
67
68 gdb_exit
69 gdb_start
70 gdb_reinitialize_dir $srcdir/$subdir
71 gdb_load ${binfile}
72
73
74 #
75 # set it up at a breakpoint so we can play with the variable values
76 #
77 if ![runto_main] then {
78 perror "couldn't run to breakpoint"
79 continue
80 }
81
82 get_debug_format
83
84 proc local_compiler_xfail_check { } {
85 global gcc_compiled;
86
87 if {$gcc_compiled} then {
88 if { ![test_debug_format "HP"] \
89 && ![test_debug_format "DWARF 2"] } then {
90 setup_xfail "*-*-*"
91 }
92 }
93 }
94
95 send_gdb "break marker1\n" ; gdb_expect -re ".*$gdb_prompt $"
96
97 send_gdb "cont\n"
98 gdb_expect {
99 -re "Break.* marker1 \\(\\) at .*:$decimal.*$gdb_prompt $" {
100 send_gdb "up\n"
101 gdb_expect {
102 -re ".*main.*$gdb_prompt $" {
103 pass "up from marker1"
104 }
105 -re ".*$gdb_prompt $" {
106 fail "up from marker1"
107 }
108 timeout { fail "up from marker1 (timeout)" }
109 }
110 }
111 -re "Break.* marker1__.* \\(\\) at .*:$decimal.*$gdb_prompt $" {
112 fail "continue to marker1 (demangling)"
113 send_gdb "up\n"
114 gdb_expect {
115 -re ".*main.*$gdb_prompt $" {
116 pass "up from marker1"
117 }
118 -re ".*$gdb_prompt $" {
119 fail "up from marker1"
120 }
121 timeout { fail "up from marker1 (timeout)" }
122 }
123 }
124 -re "$gdb_prompt $" { fail "continue to marker1" }
125 timeout { fail "(timeout) continue to marker1" }
126 }
127
128 # test function parameters
129
130 local_compiler_xfail_check
131 send_gdb "ptype qux1\n"
132 gdb_expect {
133 -re "type = int \\(const char, const char, const char \\*, char \\* const\\).*$gdb_prompt $" {
134 pass "ptype qux1"
135 }
136 -re ".*$gdb_prompt $" { fail "ptype qux1" }
137 timeout { fail "(timeout) ptype qux1" }
138 }
139
140 # test vars and pointers
141
142 proc do_constvar_tests {} {
143 gdb_test "print lave" " = 66 'B'"
144 gdb_test "ptype lave" "type = char"
145 gdb_test "print lavish" " = 10 '\\\\n'"
146 gdb_test "ptype lavish" "type = unsigned char"
147 gdb_test "print lax" " = 20"
148 gdb_test "ptype lax" "type = short.*"
149 gdb_test "print lecherous" " = 30"
150 gdb_test "ptype lecherous" "type = (unsigned short|short unsigned)( int)?"
151 gdb_test "print lechery" " = 40"
152 gdb_test "ptype lechery" "type = long.*"
153 gdb_test "print lectern" " = 50"
154 gdb_test "ptype lectern" "type = (unsigned long|long unsigned)( int)?"
155 gdb_test "print leeway" " = 60"
156 gdb_test "ptype leeway" "type = float"
157 gdb_test "print legacy" " = 70"
158 gdb_test "ptype legacy" "type = double"
159 gdb_test "print laconic" " = 65 'A'"
160 local_compiler_xfail_check
161 gdb_test "ptype laconic" "type = const char"
162 gdb_test "print laggard" " = 1 '.001'"
163 local_compiler_xfail_check
164 gdb_test "ptype laggard" "type = const unsigned char"
165 gdb_test "print lagoon" " = 2"
166 local_compiler_xfail_check
167 gdb_test "ptype lagoon" "type = const short( int)?"
168 gdb_test "print laity" " = 3"
169 local_compiler_xfail_check
170 gdb_test "ptype laity" "type = const (unsigned short|short unsigned)( int)?"
171 gdb_test "print lambent" " = 4"
172 local_compiler_xfail_check
173 gdb_test "ptype lambent" "type = const long( int)?"
174 gdb_test "print laminated" " = 5"
175 local_compiler_xfail_check
176 gdb_test "ptype laminated" "type = const (unsigned long|long unsigned)( int)?"
177 gdb_test "print lampoon" " = 6"
178 local_compiler_xfail_check
179 gdb_test "ptype lampoon" "type = const float"
180 gdb_test "print languid" " = 7"
181 local_compiler_xfail_check
182 gdb_test "ptype languid" "type = const double"
183 gdb_test "print *legend" " = 66 'B'"
184 local_compiler_xfail_check
185 gdb_test "ptype legend" "type = const char \\*"
186 gdb_test "print *legerdemain" " = 10 '\\\\n'"
187 local_compiler_xfail_check
188 gdb_test "ptype legerdemain" "type = const unsigned char \\*"
189 gdb_test "print *leniency" " = 20"
190 local_compiler_xfail_check
191 gdb_test "ptype leniency" "type = const short( int)? \\*"
192 gdb_test "print *leonine" " = 30"
193 local_compiler_xfail_check
194 gdb_test "ptype leonine" "type = const (unsigned short|short unsigned)( int)? \\*"
195 gdb_test "print *lesion" " = 40"
196 local_compiler_xfail_check
197 gdb_test "ptype lesion" "type = const long( int)? \\*"
198 gdb_test "print *lethal" " = 50"
199 local_compiler_xfail_check
200 gdb_test "ptype lethal" "type = const (unsigned long|long unsigned)( int)? \\*"
201 gdb_test "print *lethargic" " = 60"
202 local_compiler_xfail_check
203 gdb_test "ptype lethargic" "type = const float \\*"
204 gdb_test "print *levity" " = 70"
205 local_compiler_xfail_check
206 gdb_test "ptype levity" "type = const double \\*"
207 gdb_test "print *lewd" " = 65 'A'"
208 local_compiler_xfail_check
209 gdb_test "ptype lewd" "type = const char \\* const"
210 gdb_test "print *lexicographer" " = 1 '.001'"
211 local_compiler_xfail_check
212 gdb_test "ptype lexicographer" "type = const unsigned char \\* const"
213 gdb_test "print *lexicon" " = 2"
214 local_compiler_xfail_check
215 gdb_test "ptype lexicon" "type = const short( int)? \\* const"
216 gdb_test "print *liaison" " = 3"
217 local_compiler_xfail_check
218 gdb_test "ptype liaison" "type = const (unsigned short|short unsigned)( int)? \\* const"
219 gdb_test "print *libation" " = 4"
220 local_compiler_xfail_check
221 gdb_test "ptype libation" "type = const long( int)? \\* const"
222 gdb_test "print *libelous" " = 5"
223 local_compiler_xfail_check
224 gdb_test "ptype libelous" "type = const (unsigned long|long unsigned)( int)? \\* const"
225 gdb_test "print *libertine" " = 6"
226 local_compiler_xfail_check
227 gdb_test "ptype libertine" "type = const float \\* const"
228 gdb_test "print *libidinous" " = 7"
229 local_compiler_xfail_check
230 gdb_test "ptype libidinous" "type = const double \\* const"
231 gdb_test "print *languish" " = 65 'A'"
232 local_compiler_xfail_check
233 gdb_test "ptype languish" "type = const char \\*"
234 gdb_test "print *languor" " = 1 '.001'"
235 local_compiler_xfail_check
236 gdb_test "ptype languor" "type = const unsigned char \\*"
237 gdb_test "print *lank" " = 2"
238 local_compiler_xfail_check
239 gdb_test "ptype lank" "type = const short( int)? \\*"
240 gdb_test "print *lapidary" " = 3"
241 local_compiler_xfail_check
242 gdb_test "ptype lapidary" "type = const (unsigned short|short unsigned)( int)? \\*"
243 gdb_test "print *larceny" " = 4"
244 local_compiler_xfail_check
245 gdb_test "ptype larceny" "type = const long( int)? \\*"
246 gdb_test "print *largess" " = 5"
247 local_compiler_xfail_check
248 gdb_test "ptype largess" "type = const (unsigned long|long unsigned)( int)? \\*"
249 gdb_test "print *lascivious" " = 6"
250 local_compiler_xfail_check
251
252 gdb_test "ptype lascivious" "type = const float \\*"
253 gdb_test "print *lassitude" " = 7"
254 local_compiler_xfail_check
255 gdb_test "ptype lassitude" "type = const double \\*"
256 gdb_test "print *lamprey" " = 66 'B'"
257 local_compiler_xfail_check
258 gdb_test "ptype lamprey" "type = char \\* const"
259 gdb_test "print *lariat" " = 10 '\\\\n'"
260 local_compiler_xfail_check
261 gdb_test "ptype lariat" "type = unsigned char \\* const"
262 gdb_test "print *laudanum" " = 20"
263 local_compiler_xfail_check
264 gdb_test "ptype laudanum" "type = short( int)? \\* const"
265 gdb_test "print *lecithin" " = 30"
266 local_compiler_xfail_check
267 gdb_test "ptype lecithin" "type = (unsigned short|short unsigned)( int)? \\* const"
268 gdb_test "print *leviathan" " = 40"
269 local_compiler_xfail_check
270 gdb_test "ptype leviathan" "type = long( int)? \\* const"
271 gdb_test "print *libretto" " = 50"
272 local_compiler_xfail_check
273 gdb_test "ptype libretto" "type = (unsigned long|long unsigned)( int)? \\* const"
274 gdb_test "print *lissome" " = 60"
275 local_compiler_xfail_check
276 gdb_test "ptype lissome" "type = float \\* const"
277 gdb_test "print *locust" " = 70"
278 local_compiler_xfail_check
279 gdb_test "ptype locust" "type = double \\* const"
280
281 local_compiler_xfail_check
282 gdb_test "ptype crass" "type = struct crass \{\[\r\n\]+\[\ \t\]+char \\* const ptr;\[\r\n\]+\}"
283 local_compiler_xfail_check
284 gdb_test "ptype crisp" "type = struct crisp \{\[\r\n\]+\[\ \t\]+char \\* const \\*ptr;\[\r\n\]+\}"
285 }
286
287 do_constvar_tests
This page took 0.061695 seconds and 4 git commands to generate.