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