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