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