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