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