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