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