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