* gas/config/tc-avr.c: Change ISA for devices with USB support to
[external/binutils.git] / gdb / testsuite / gdb.base / constvars.exp
1 # Copyright 1997-2013 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 3 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, see <http://www.gnu.org/licenses/>.  */
15
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
26 #
27 # test running programs
28 #
29
30 set testfile "constvars"
31 set srcfile ${testfile}.c
32 set binfile ${objdir}/${subdir}/${testfile}
33
34 # Create and source the file that provides information about the compiler
35 # used to compile the test case.
36 if [get_compiler_info] {
37     return -1
38 }
39
40 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable debug ] != "" } {
41     untested constvars.exp
42     return -1
43 }
44
45 gdb_exit
46 gdb_start
47 gdb_reinitialize_dir $srcdir/$subdir
48 gdb_load ${binfile}
49
50
51 #
52 # set it up at a breakpoint so we can play with the variable values
53 #
54 if ![runto_main] then {
55     perror "couldn't run to breakpoint"
56     continue
57 }
58
59 get_debug_format
60
61 # Many tests xfail with gcc 2 -gstabs+.
62 # TODO: check out the hp side of this.
63
64 proc local_compiler_xfail_check { } {
65     if { [test_compiler_info gcc-2-*] } then {
66         if { ![test_debug_format "HP"] \
67                 && ![test_debug_format "DWARF 2"] } then {
68             setup_xfail "*-*-*" 
69         }
70     }
71
72     global hp_cc_compiler
73     if { $hp_cc_compiler } {
74         setup_xfail "hppa*-*-hpux*"
75     }
76 }
77
78 # A few tests still xfail with gcc 3 -gstabs+ and gcc 4 -gstabs+.
79
80 proc local_compiler_xfail_check_2 { } {
81     if { [test_compiler_info gcc-3-*] || [test_compiler_info gcc-4-*] } {
82         if { [test_debug_format "stabs" ] } {
83             setup_xfail "*-*-*"
84         }
85     }
86 }
87
88 gdb_test "break marker1" "Breakpoint $decimal at .*" 
89
90 gdb_test_multiple "cont" "up from marker1" {
91     -re "Break.* marker1 \\(\\) at .*:$decimal.*$gdb_prompt $" {
92         pass "continue to marker1"
93         gdb_test "up" " main .*" "up from marker1"
94     }
95     -re "Break.* marker1__.* \\(\\) at .*:$decimal.*$gdb_prompt $" {
96         fail "continue to marker1 (demangling)"
97         gdb_test "up" " main .*" "up from marker1"
98     }
99 }
100
101 # test function parameters
102
103 local_compiler_xfail_check
104 local_compiler_xfail_check_2
105
106 gdb_test "ptype qux1" \
107     "type = int \\(const char, const char, const char \\*, char \\* const\\).*"
108
109 # test vars and pointers
110
111 proc do_constvar_tests {} {
112     gdb_test "print lave" " = 66 'B'"
113     gdb_test "ptype lave" "type = char"
114     gdb_test "print lavish" " = 10 '\\\\n'"
115     gdb_test "ptype lavish" "type = unsigned char"
116     gdb_test "print lax" " = 20"
117     gdb_test "ptype lax" "type = short.*"
118     gdb_test "print lecherous" " = 30"
119     gdb_test "ptype lecherous" "type = (unsigned short|short unsigned)( int)?"
120     gdb_test "print lechery" " = 40"
121     gdb_test "ptype lechery" "type = long.*"
122     gdb_test "print lectern" " = 50"
123     gdb_test "ptype lectern" "type = (unsigned long|long unsigned)( int)?"
124     gdb_test "print leeway" " = 60"
125     gdb_test "ptype leeway" "type = float"
126     gdb_test "print legacy" " = 70"
127     gdb_test "ptype legacy" "type = double"
128     gdb_test "print laconic" " = 65 'A'"
129     local_compiler_xfail_check
130     gdb_test "ptype laconic" "type = const char"
131     gdb_test "print laggard" " = 1 '.001'"
132     local_compiler_xfail_check
133     gdb_test "ptype laggard" "type = const unsigned char"
134     gdb_test "print lagoon" " = 2"
135     local_compiler_xfail_check
136     gdb_test "ptype lagoon" "type = const short( int)?"
137     gdb_test "print laity" " = 3"
138     local_compiler_xfail_check
139     gdb_test "ptype laity" "type = const (unsigned short|short unsigned)( int)?"
140     gdb_test "print lambent" " = 4"
141     local_compiler_xfail_check
142     gdb_test "ptype lambent" "type = const long( int)?"
143     gdb_test "print laminated" " = 5"
144     local_compiler_xfail_check
145     gdb_test "ptype laminated" "type = const (unsigned long|long unsigned)( int)?"
146     gdb_test "print lampoon" " = 6"
147     local_compiler_xfail_check
148     gdb_test "ptype lampoon" "type = const float"
149     gdb_test "print languid" " = 7"
150     local_compiler_xfail_check
151     gdb_test "ptype languid" "type = const double"
152     gdb_test "print *legend" " = 66 'B'"
153     local_compiler_xfail_check
154     gdb_test "ptype legend" "type = const char \\*"
155     gdb_test "print *legerdemain" " = 10 '\\\\n'"
156     local_compiler_xfail_check
157     gdb_test "ptype legerdemain" "type = const unsigned char \\*"
158     gdb_test "print *leniency" " = 20"
159     local_compiler_xfail_check
160     gdb_test "ptype leniency" "type = const short( int)? \\*"
161     gdb_test "print *leonine" " = 30"
162     local_compiler_xfail_check
163     gdb_test "ptype leonine" "type = const (unsigned short|short unsigned)( int)? \\*"
164     gdb_test "print *lesion" " = 40"
165     local_compiler_xfail_check
166     gdb_test "ptype lesion" "type = const long( int)? \\*"
167     gdb_test "print *lethal" " = 50"
168     local_compiler_xfail_check
169     gdb_test "ptype lethal" "type = const (unsigned long|long unsigned)( int)? \\*"
170     gdb_test "print *lethargic" " = 60"
171     local_compiler_xfail_check
172     gdb_test "ptype lethargic" "type = const float \\*"
173     gdb_test "print *levity" " = 70"
174     local_compiler_xfail_check
175     gdb_test "ptype levity" "type = const double \\*"
176     gdb_test "print *lewd" " = 65 'A'"
177     local_compiler_xfail_check
178     gdb_test "ptype lewd" "type = const char \\* const"
179     gdb_test "print *lexicographer" " = 1 '.001'"
180     local_compiler_xfail_check
181     gdb_test "ptype lexicographer" "type = const unsigned char \\* const"
182     gdb_test "print *lexicon" " = 2"
183     local_compiler_xfail_check
184     gdb_test "ptype lexicon" "type = const short( int)? \\* const"
185     gdb_test "print *liaison" " = 3"
186     local_compiler_xfail_check
187     gdb_test "ptype liaison" "type = const (unsigned short|short unsigned)( int)? \\* const"
188     gdb_test "print *libation" " = 4"
189     local_compiler_xfail_check
190     gdb_test "ptype libation" "type = const long( int)? \\* const"
191     gdb_test "print *libelous" " = 5"
192     local_compiler_xfail_check
193     gdb_test "ptype libelous" "type = const (unsigned long|long unsigned)( int)? \\* const"
194     gdb_test "print *libertine" " = 6"
195     local_compiler_xfail_check
196     gdb_test "ptype libertine" "type = const float \\* const"
197     gdb_test "print *libidinous" " = 7"
198     local_compiler_xfail_check
199     gdb_test "ptype libidinous" "type = const double \\* const"
200     gdb_test "print *languish" " = 65 'A'"
201     local_compiler_xfail_check
202     gdb_test "ptype languish" "type = const char \\*"
203     gdb_test "print *languor" " = 1 '.001'"
204     local_compiler_xfail_check
205     gdb_test "ptype languor" "type = const unsigned char \\*"
206     gdb_test "print *lank" " = 2"
207     local_compiler_xfail_check
208     gdb_test "ptype lank" "type = const short( int)? \\*"
209     gdb_test "print *lapidary" " = 3"
210     local_compiler_xfail_check
211     gdb_test "ptype lapidary" "type = const (unsigned short|short unsigned)( int)? \\*"
212     gdb_test "print *larceny" " = 4"
213     local_compiler_xfail_check
214     gdb_test "ptype larceny" "type = const long( int)? \\*"
215     gdb_test "print *largess" " = 5"
216     local_compiler_xfail_check
217     gdb_test "ptype largess" "type = const (unsigned long|long unsigned)( int)? \\*"
218     gdb_test "print *lascivious" " = 6"
219     local_compiler_xfail_check
220
221     gdb_test "ptype lascivious" "type = const float \\*"
222     gdb_test "print *lassitude" " = 7"
223     local_compiler_xfail_check
224     gdb_test "ptype lassitude" "type = const double \\*"
225     gdb_test "print *lamprey" " = 66 'B'"
226     local_compiler_xfail_check
227     gdb_test "ptype lamprey" "type = char \\* const"
228     gdb_test "print *lariat" " = 10 '\\\\n'"
229     local_compiler_xfail_check
230     gdb_test "ptype lariat" "type = unsigned char \\* const"
231     gdb_test "print *laudanum" " = 20"
232     local_compiler_xfail_check
233     gdb_test "ptype laudanum" "type = short( int)? \\* const"
234     gdb_test "print *lecithin" " = 30"
235     local_compiler_xfail_check
236     gdb_test "ptype lecithin" "type = (unsigned short|short unsigned)( int)? \\* const"
237     gdb_test "print *leviathan" " = 40"
238     local_compiler_xfail_check
239     gdb_test "ptype leviathan" "type = long( int)? \\* const"
240     gdb_test "print *libretto" " = 50"
241     local_compiler_xfail_check
242     gdb_test "ptype libretto" "type = (unsigned long|long unsigned)( int)? \\* const"
243     gdb_test "print *lissome" " = 60"
244     local_compiler_xfail_check
245     gdb_test "ptype lissome" "type = float \\* const"
246     gdb_test "print *locust" " = 70"
247     local_compiler_xfail_check
248     gdb_test "ptype locust" "type = double \\* const"
249
250     local_compiler_xfail_check
251     gdb_test "ptype logical" "type = const char \\\[2\\\]"
252     local_compiler_xfail_check
253     gdb_test "ptype lugged" "type = const unsigned char \\\[2\\\]"
254     local_compiler_xfail_check
255     gdb_test "ptype luck" "type = const short( int)? \\\[2\\\]"
256     local_compiler_xfail_check
257     gdb_test "ptype lunar" "type = const (unsigned short|short unsigned)( int)? \\\[2\\\]"
258     local_compiler_xfail_check
259     gdb_test "ptype lumen" "type = const long( int)? \\\[2\\\]"
260     local_compiler_xfail_check
261     gdb_test "ptype lurk" "type = const (unsigned long|long unsigned)( int)? \\\[2\\\]"
262     local_compiler_xfail_check
263     gdb_test "ptype lush" "type = const float \\\[2\\\]"
264     local_compiler_xfail_check
265     gdb_test "ptype lynx" "type = const double \\\[2\\\]"
266
267     local_compiler_xfail_check
268     local_compiler_xfail_check_2
269     gdb_test "ptype crass" "type = struct crass \{\[\r\n\]+\[\ \t\]+char \\* const ptr;\[\r\n\]+\}"
270     local_compiler_xfail_check
271     gdb_test "ptype crisp" "type = struct crisp \{\[\r\n\]+\[\ \t\]+char \\* const \\*ptr;\[\r\n\]+\}"
272 }
273
274 do_constvar_tests