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