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