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