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