import gdb-1999-06-28 snapshot
[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 {
82 -re ".*$gdb_prompt $" {}
83 timeout { fail "up from marker1" }
84 }
85 }
86 -re "Break.* marker1__.* \\(\\) at .*:$decimal.*$gdb_prompt $" {
87 fail "continue to marker1 (demangling)"
88 send_gdb "up\n"
89 gdb_expect {
90 -re ".*$gdb_prompt $" {}
91 timeout { fail "up from marker1" }
92 }
93 }
94 -re "$gdb_prompt $" { fail "continue to marker1" }
95 timeout { fail "(timeout) continue to marker1" }
96 }
97
98# test function parameters
99
100if {$gcc_compiled} then { setup_xfail "*-*-*" }
101send_gdb "ptype qux1\n"
102gdb_expect {
085dd6e6 103 -re "type = int \\(const char, const char, const char \\*, char \\* const\\).*$gdb_prompt $" {
c906108c
SS
104 pass "ptype qux1"
105 }
106 -re ".*$gdb_prompt $" { fail "ptype qux1" }
107 timeout { fail "(timeout) ptype qux1" }
108}
109
110# test vars and pointers
111
112proc do_constvar_tests {} {
113 global gcc_compiled
114
115 gdb_test "print lave" " = 66 'B'"
116 gdb_test "ptype lave" "type = char"
117 gdb_test "print lavish" " = 10 '\\\\n'"
118 gdb_test "ptype lavish" "type = unsigned char"
119 gdb_test "print lax" " = 20"
120 gdb_test "ptype lax" "type = short.*"
121 gdb_test "print lecherous" " = 30"
122 if {$gcc_compiled} then { setup_xfail "*-*-*" }
123 gdb_test "ptype lecherous" "type = unsigned short.*"
124 gdb_test "print lechery" " = 40"
125 gdb_test "ptype lechery" "type = long.*"
126 gdb_test "print lectern" " = 50"
127 if {$gcc_compiled} then { setup_xfail "*-*-*" }
128 gdb_test "ptype lectern" "type = unsigned long.*"
129 gdb_test "print leeway" " = 60"
130 gdb_test "ptype leeway" "type = float"
131 gdb_test "print legacy" " = 70"
132 gdb_test "ptype legacy" "type = double"
133 gdb_test "print laconic" " = 65 'A'"
134 if {$gcc_compiled} then { setup_xfail "*-*-*" }
135 gdb_test "ptype laconic" "type = const char"
136 gdb_test "print laggard" " = 1 '.001'"
137 if {$gcc_compiled} then { setup_xfail "*-*-*" }
138 gdb_test "ptype laggard" "type = const unsigned char"
139 gdb_test "print lagoon" " = 2"
140 if {$gcc_compiled} then { setup_xfail "*-*-*" }
141 gdb_test "ptype lagoon" "type = const short"
142 gdb_test "print laity" " = 3"
143 if {$gcc_compiled} then { setup_xfail "*-*-*" }
144 gdb_test "ptype laity" "type = const unsigned short"
145 gdb_test "print lambent" " = 4"
146 if {$gcc_compiled} then { setup_xfail "*-*-*" }
147 gdb_test "ptype lambent" "type = const long"
148 gdb_test "print laminated" " = 5"
149 if {$gcc_compiled} then { setup_xfail "*-*-*" }
150 gdb_test "ptype laminated" "type = const unsigned long"
151 gdb_test "print lampoon" " = 6"
152 if {$gcc_compiled} then { setup_xfail "*-*-*" }
153 gdb_test "ptype lampoon" "type = const float"
154 gdb_test "print languid" " = 7"
155 if {$gcc_compiled} then { setup_xfail "*-*-*" }
156 gdb_test "ptype languid" "type = const double"
157 gdb_test "print *legend" " = 66 'B'"
158 if {$gcc_compiled} then { setup_xfail "*-*-*" }
085dd6e6 159 gdb_test "ptype legend" "type = const char \\*"
c906108c
SS
160 gdb_test "print *legerdemain" " = 10 '\\\\n'"
161 if {$gcc_compiled} then { setup_xfail "*-*-*" }
085dd6e6 162 gdb_test "ptype legerdemain" "type = const unsigned char \\*"
c906108c
SS
163 gdb_test "print *leniency" " = 20"
164 if {$gcc_compiled} then { setup_xfail "*-*-*" }
085dd6e6 165 gdb_test "ptype leniency" "type = const short \\*"
c906108c
SS
166 gdb_test "print *leonine" " = 30"
167 if {$gcc_compiled} then { setup_xfail "*-*-*" }
085dd6e6 168 gdb_test "ptype leonine" "type = const unsigned short \\*"
c906108c
SS
169 gdb_test "print *lesion" " = 40"
170 if {$gcc_compiled} then { setup_xfail "*-*-*" }
085dd6e6 171 gdb_test "ptype lesion" "type = const long \\*"
c906108c
SS
172 gdb_test "print *lethal" " = 50"
173 if {$gcc_compiled} then { setup_xfail "*-*-*" }
085dd6e6 174 gdb_test "ptype lethal" "type = const unsigned long \\*"
c906108c
SS
175 gdb_test "print *lethargic" " = 60"
176 if {$gcc_compiled} then { setup_xfail "*-*-*" }
085dd6e6 177 gdb_test "ptype lethargic" "type = const float \\*"
c906108c
SS
178 gdb_test "print *levity" " = 70"
179 if {$gcc_compiled} then { setup_xfail "*-*-*" }
085dd6e6 180 gdb_test "ptype levity" "type = const double \\*"
c906108c
SS
181 gdb_test "print *lewd" " = 65 'A'"
182 if {$gcc_compiled} then { setup_xfail "*-*-*" }
085dd6e6 183 gdb_test "ptype lewd" "type = const char \\* const"
c906108c
SS
184 gdb_test "print *lexicographer" " = 1 '.001'"
185 if {$gcc_compiled} then { setup_xfail "*-*-*" }
085dd6e6 186 gdb_test "ptype lexicographer" "type = const unsigned char \\* const"
c906108c
SS
187 gdb_test "print *lexicon" " = 2"
188 if {$gcc_compiled} then { setup_xfail "*-*-*" }
085dd6e6 189 gdb_test "ptype lexicon" "type = const short \\* const"
c906108c
SS
190 gdb_test "print *liaison" " = 3"
191 if {$gcc_compiled} then { setup_xfail "*-*-*" }
085dd6e6 192 gdb_test "ptype liaison" "type = const unsigned short \\* const"
c906108c
SS
193 gdb_test "print *libation" " = 4"
194 if {$gcc_compiled} then { setup_xfail "*-*-*" }
085dd6e6 195 gdb_test "ptype libation" "type = const long \\* const"
c906108c
SS
196 gdb_test "print *libelous" " = 5"
197 if {$gcc_compiled} then { setup_xfail "*-*-*" }
085dd6e6 198 gdb_test "ptype libelous" "type = const unsigned long \\* const"
c906108c
SS
199 gdb_test "print *libertine" " = 6"
200 if {$gcc_compiled} then { setup_xfail "*-*-*" }
085dd6e6 201 gdb_test "ptype libertine" "type = const float \\* const"
c906108c
SS
202 gdb_test "print *libidinous" " = 7"
203 if {$gcc_compiled} then { setup_xfail "*-*-*" }
085dd6e6 204 gdb_test "ptype libidinous" "type = const double \\* const"
c906108c
SS
205 gdb_test "print *languish" " = 65 'A'"
206 if {$gcc_compiled} then { setup_xfail "*-*-*" }
085dd6e6 207 gdb_test "ptype languish" "type = const char \\*"
c906108c
SS
208 gdb_test "print *languor" " = 1 '.001'"
209 if {$gcc_compiled} then { setup_xfail "*-*-*" }
085dd6e6 210 gdb_test "ptype languor" "type = const unsigned char \\*"
c906108c
SS
211 gdb_test "print *lank" " = 2"
212 if {$gcc_compiled} then { setup_xfail "*-*-*" }
085dd6e6 213 gdb_test "ptype lank" "type = const short \\*"
c906108c
SS
214 gdb_test "print *lapidary" " = 3"
215 if {$gcc_compiled} then { setup_xfail "*-*-*" }
085dd6e6 216 gdb_test "ptype lapidary" "type = const unsigned short \\*"
c906108c
SS
217 gdb_test "print *larceny" " = 4"
218 if {$gcc_compiled} then { setup_xfail "*-*-*" }
085dd6e6 219 gdb_test "ptype larceny" "type = const long \\*"
c906108c
SS
220 gdb_test "print *largess" " = 5"
221 if {$gcc_compiled} then { setup_xfail "*-*-*" }
085dd6e6 222 gdb_test "ptype largess" "type = const unsigned long \\*"
c906108c
SS
223 gdb_test "print *lascivious" " = 6"
224 if {$gcc_compiled} then { setup_xfail "*-*-*" }
085dd6e6 225 gdb_test "ptype lascivious" "type = const float \\*"
c906108c
SS
226 gdb_test "print *lassitude" " = 7"
227 if {$gcc_compiled} then { setup_xfail "*-*-*" }
085dd6e6 228 gdb_test "ptype lassitude" "type = const double \\*"
c906108c
SS
229 gdb_test "print *lamprey" " = 66 'B'"
230 if {$gcc_compiled} then { setup_xfail "*-*-*" }
085dd6e6 231 gdb_test "ptype lamprey" "type = char \\* const"
c906108c
SS
232 gdb_test "print *lariat" " = 10 '\\\\n'"
233 if {$gcc_compiled} then { setup_xfail "*-*-*" }
085dd6e6 234 gdb_test "ptype lariat" "type = unsigned char \\* const"
c906108c
SS
235 gdb_test "print *laudanum" " = 20"
236 if {$gcc_compiled} then { setup_xfail "*-*-*" }
085dd6e6 237 gdb_test "ptype laudanum" "type = short \\* const"
c906108c
SS
238 gdb_test "print *lecithin" " = 30"
239 if {$gcc_compiled} then { setup_xfail "*-*-*" }
085dd6e6 240 gdb_test "ptype lecithin" "type = unsigned short \\* const"
c906108c
SS
241 gdb_test "print *leviathan" " = 40"
242 if {$gcc_compiled} then { setup_xfail "*-*-*" }
085dd6e6 243 gdb_test "ptype leviathan" "type = long \\* const"
c906108c
SS
244 gdb_test "print *libretto" " = 50"
245 if {$gcc_compiled} then { setup_xfail "*-*-*" }
085dd6e6 246 gdb_test "ptype libretto" "type = unsigned long \\* const"
c906108c
SS
247 gdb_test "print *lissome" " = 60"
248 if {$gcc_compiled} then { setup_xfail "*-*-*" }
085dd6e6 249 gdb_test "ptype lissome" "type = float \\* const"
c906108c
SS
250 gdb_test "print *locust" " = 70"
251 if {$gcc_compiled} then { setup_xfail "*-*-*" }
085dd6e6 252 gdb_test "ptype locust" "type = double \\* const"
c906108c
SS
253}
254
255do_constvar_tests
This page took 0.055193 seconds and 4 git commands to generate.