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