* lib/gdb.exp (skip_altivec_tests, skip_vsx_tests)
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.cp / local.exp
1 # Copyright 1998-2004, 2007-2012 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 # tests for local variables
17 # Written by Satish Pai <pai@apollo.hp.com> 1997-07-08
18 # Cleaned by Michael Chastain <mec@shout.net> 2002-04-08
19
20
21 # This file is part of the gdb testsuite
22
23 set ws "\[\r\n\t \]+"
24 set nl "\[\r\n\]+"
25
26 #
27 # test running programs
28 #
29
30 if { [skip_cplus_tests] } { continue }
31
32 set testfile "local"
33 set srcfile ${testfile}.cc
34 set binfile ${objdir}/${subdir}/${testfile}
35
36 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } {
37 untested local.exp
38 return -1
39 }
40
41 if [get_compiler_info "c++"] {
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 if ![runto 'marker1'] then {
60 perror "couldn't run to marker1"
61 continue
62 }
63
64 gdb_test "up" ".*foobar.*" "up from marker1"
65
66 set sep "(\[.\]|___)\[0-9\]"
67
68 # ptype on a local variable.
69 #
70 # This test has six arms. The first three arms accept normal output:
71 # no synthetic methods; synthetic methods before user methods;
72 # synthetic methods after user methods.
73 #
74 # The next two arms accept "foobar__Fi.0::Local" instead of "Local".
75 # This is a bug. It happens in various places with various versions of
76 # gcc and gdb and various debugging types.
77 #
78 # The last arm accepts the user methods in duplicate. This bug happens
79 # with gcc 3.3.2 -gdwarf-2, and has been fixed in gcc HEAD 2004-01-22.
80 #
81 # -- chastain 2004-01-24
82
83 set re_class "((struct|class) Local \{${ws}public:|struct Local \{)"
84 set re_fields "int loc1;"
85 set re_methods "char loc_foo\\(char\\);"
86 set re_synth_gcc_23 "Local & operator=\\(Local const ?&\\);${ws}Local\\(Local const ?&\\);${ws}Local\\((void|)\\);"
87
88 set XX_class "((struct|class) foobar__Fi.0::Local \{${ws}public:|struct foobar__Fi.0:Local \{)"
89 set XX_synth_gcc_2 "Local & operator=\\(foobar__Fi.0::Local const ?&\\);${ws}Local\\(foobar__Fi.0::Local const ?&\\);${ws}Local\\((void|)\\);"
90 set YY_methods "$re_methods${ws}$re_methods"
91
92 set name "ptype l"
93 gdb_test_multiple "ptype l" $name {
94 -re "type = $re_class${ws}$re_fields${ws}$re_methods$nl\}$nl$gdb_prompt $" {
95 # gdb 6.0, gcc 2.95.3, dwarf-2
96 # gdb 6.0, gcc HEAD 2004-01-22, dwarf-2
97 # gdb HEAD 2004-01-23, gcc HEAD 2004-01,22, dwarf-2
98 pass "$name"
99 }
100 -re "type = $re_class${ws}$re_fields${ws}$re_synth_gcc_23${ws}$re_methods$nl\}$nl$gdb_prompt $" {
101 # gdb 6.0, gcc 3.3.2, stabs+
102 # gdb HEAD 2004-01-23, gcc 3.3.2, stabs+
103 pass "$name"
104 }
105 -re "type = $re_class${ws}$re_fields${ws}$re_methods${ws}$re_synth_gcc_23${ws}$nl\}$nl$gdb_prompt $" {
106 # gdb 6.0, gcc HEAD 2004-01-22, stabs+
107 # gdb HEAD 2004-01-23, gcc HEAD 2004-01-22, stabs+
108 pass "$name"
109 }
110 -re "type = $XX_class${ws}$re_fields${ws}$re_methods$nl\}$nl$gdb_prompt $" {
111 # gdb HEAD 2004-01-23, gcc 2.95.3, dwarf-2
112 kfail "gdb/1516" "$name"
113 }
114 -re "type = ($re_class|$XX_class)${ws}$re_fields${ws}($re_synth_gcc_23|$XX_synth_gcc_2)${ws}$re_methods$nl\}$nl$gdb_prompt $" {
115 # gdb 6.0, gcc 2.95.3, stabs+
116 # gdb HEAD 2004-01-23, gcc 2.95.3, stabs+
117 kfail "gdb/1516" "$name"
118 }
119 -re "type = ($re_class|$XX_class)${ws}$re_fields${ws}$YY_methods$nl\}$nl$gdb_prompt $" {
120 # gdb 6.0, gcc 3.3.2, dwarf-2
121 # gdb HEAD 2004-01-23, gcc 3.2.2, dwarf-2
122 kfail "gdb/483" "$name"
123 }
124 }
125
126 # This is the same test with "ptype Local" (the type name)
127 # instead of "ptype l" (the variable name).
128
129 set name "ptype Local"
130 gdb_test_multiple "ptype Local" $name {
131 -re "type = $re_class${ws}$re_fields${ws}$re_methods$nl\}$nl$gdb_prompt $" {
132 # gdb 6.0, gcc 2.95.3, dwarf-2
133 # gdb 6.0, gcc HEAD 2004-01-22, dwarf-2
134 # gdb HEAD 2004-01-23, gcc HEAD 2004-01-22, dwarf-2
135 pass "$name"
136 }
137 -re "type = $re_class${ws}$re_fields${ws}$re_synth_gcc_23${ws}$re_methods$nl\}$nl$gdb_prompt $" {
138 # gdb 6.0, gcc 3.3.2, stabs+
139 # gdb HEAD 2004-01-23, gcc 3.3.2, stabs+
140 pass "$name"
141 }
142 -re "type = $re_class${ws}$re_fields${ws}$re_methods${ws}$re_synth_gcc_23${ws}$nl\}$nl$gdb_prompt $" {
143 # gdb 6.0, gcc HEAD 2004-01-22, stabs+
144 # gdb HEAD 2004-01-23, gcc HEAD 2004-01-22, stabs+
145 pass "$name"
146 }
147 -re "type = $XX_class${ws}$re_fields${ws}$re_methods$nl\}$nl$gdb_prompt $" {
148 kfail "gdb/1516" "$name"
149 }
150 -re "type = ($re_class|$XX_class)${ws}$re_fields${ws}($re_synth_gcc_23|$XX_synth_gcc_2)${ws}$re_methods$nl\}$nl$gdb_prompt $" {
151 # gdb 6.0, gcc 2.95.3, stabs+
152 # gdb HEAD 2004-01-23, gcc 2.95.3, stabs+
153 kfail "gdb/1516" "$name"
154 }
155 -re "type = ($re_class|$XX_class)${ws}$re_fields${ws}$YY_methods$nl\}$nl$gdb_prompt $" {
156 # gdb 6.0, gcc 3.3.2, dwarf-2
157 # gdb HEAD 2004-01-23, gcc 3.2.2, dwarf-2
158 kfail "gdb/483" "$name"
159 }
160 -re "No symbol \"Local\" in current context.$nl$gdb_prompt $" {
161 # gdb HEAD 2004-01-23, gcc 2.95.3, dwarf-2
162 fail "$name"
163 }
164 }
165
166 gdb_test "break marker2"
167 gdb_test "continue" "Continuing\\..*Breakpoint \[0-9\]+, marker2.*" \
168 "continuing to marker2"
169
170 gdb_test "up" ".*main.*" "up from marker2"
171
172 # Make sure that `Local' isn't in scope here; it's local to foobar.
173 # setup_kfail "gdb/825"
174
175 set eol "\[\t \]*\[\r\n\]+\[\t \]*"
176 gdb_test_multiple "ptype Local" "Local out of scope" {
177 -re "No symbol \"Local\" in current context.*${gdb_prompt} $" {
178 pass "Local out of scope"
179 }
180 -re "ptype Local${eol}type = class Local {${eol} public:${eol} int loc1;${eol}.*${eol} char loc_foo\\(char\\);${eol}}${eol}${gdb_prompt} " {
181 # GCC emits STABS debugging information in a way that doesn't
182 # properly preserve the scoping of local classes. I think
183 # we'd need to start using Sun's extensions to stabs to get
184 # this right.
185 kfail gdb/825 "Local out of scope"
186 }
187 -re "ptype Local${eol}type = class Local {${eol} public:${eol} int loc1;${eol} char loc_foo\\(char\\);${eol}.*${eol}}${eol}${gdb_prompt} " {
188 # gcc 3.X abi-2 -gstabs+
189 kfail gdb/825 "Local out of scope"
190 }
191 }
192
193
194 # DTS CLLbs14316 and CLLbs17058
195 # coulter - I added a clause for HP's aCC compiler. We print out the type
196 # as xx instead of const unsigned char, but we still have an expected failure
197 # because of two reasons:
198 # There is a number at the end of InnerLocal4 which should not be there,
199 # DTS CLLbs14316
200 # The line number for the class
201 # setup_xfail "hppa*-*-*" CLLbs14316
202
203 # ---
204 # Pattern 1:
205 # PASS
206 # dwarf-2
207 # 2.95.3, 2.96-rh, 3.0.4, 3.1, gcc-3_1-branch, HEAD
208 #
209 # Pattern 2:
210 # PASS
211 # stabs+
212 # 2.95.3, 2.96-rh, 3.0.4, 3.1, gcc-3_1-branch, HEAD
213 #
214 # Pattern 3:
215 # Old hppa pattern.
216 #
217 # Pattern 4:
218 # Old hppa pattern.
219 #
220 # chastain 2002-05-27
221
222 # Pattern 5:
223 # PASS
224 # stabs+
225 # HEAD
226 #
227 # chastain 2004-01-02
228
229 gdb_test_multiple "ptype InnerLocal" "ptype InnerLocal" {
230 -re "type = class InnerLocal \{\[\r\n\t \]*public:\[\r\n\t \]*char ilc;\[\r\n\t \]*int \\* *ip;\[\r\n\t \]*(InnerLocal::|)NestedInnerLocal nest1;\[\r\n\t \]*int il_foo\\((unsigned char const|const unsigned char) *&\\);\[\r\n\t \]*\}.*$gdb_prompt $" {
231 pass "ptype InnerLocal (pattern 1)"
232 }
233 -re "type = class InnerLocal \{\[\r\n\t \]*public:\[\r\n\t \]*char ilc;\[\r\n\t \]*int \\* *ip;\[\r\n\t \]*(InnerLocal::|)NestedInnerLocal nest1;\[\r\n\t \]*InnerLocal *& operator *=\\((main${sep}::|)InnerLocal const *&\\);\[\r\n\t \]*InnerLocal\\((main${sep}::|)InnerLocal const *&\\);\[\r\n\t \]*InnerLocal\\((void|)\\);\[\r\n\t \]*int il_foo\\(unsigned char const *&\\);\[\r\n\t \]*\}.*$gdb_prompt $" {
234 pass "ptype InnerLocal (pattern 2)"
235 }
236 -re "type = class InnerLocal \{\r\n\[\t \]*public:\r\n\[\t \]*char ilc;\r\n\[\t \]*int \\*ip;\r\n\[\t \]*InnerLocal::NestedInnerLocal nest1;\r\n\r\n\[\t \]*.int il_foo\\(unsigned char const &\\);\r\n\[\t \]*\}\[\t \]*\\(Local at.*local\\.cc:36\\).*$gdb_prompt $" {
237 pass "ptype InnerLocal (old HP aCC)"
238 }
239 -re "type = class InnerLocal \{\r\n\[\t \]*public:\r\n\[\t \]*char ilc;\r\n\[\t \]*int \\*ip;\r\n\[\t \]*class InnerLocal4::NestedInnerLocal nest1;\r\n\r\n\[\t \]*int il_foo\\(unsigned char const &\\);\r\n\[\t \]*\\(Local at.*local\.cc:\[0-9\]+\\)\r\n\}.*$gdb_prompt $" {
240 pass "ptype InnerLocal (old HP aCC)"
241 }
242 -re "type = class InnerLocal \{\[\r\n\t \]*public:\[\r\n\t \]*char ilc;\[\r\n\t \]*int \\* *ip;\[\r\n\t \]*(InnerLocal::|)NestedInnerLocal nest1;\[\r\n\t \]* int il_foo\\(unsigned char const *&\\);\[\r\n\t \]*InnerLocal *& operator *=\\((main${sep}::|)InnerLocal const *&\\);\[\r\n\t \]*InnerLocal\\((main${sep}::|)InnerLocal const *&\\);\[\r\n\t \]*InnerLocal\\((void|)\\);\[\r\n\t \]*\}.*$gdb_prompt $" {
243 pass "ptype InnerLocal (pattern 5)"
244 }
245 }
246
247 #---
248 # Pattern 1:
249 # PASS
250 # dwarf-2
251 # gcc 2.95.3, 2.96-rh, 3.0.4, gcc-3_1-branch, HEAD
252 #
253 # Pattern 2:
254 # PASS
255 # stabs+
256 # gcc 2.95.3, 2.96-rh, 3.0.4, gcc-3_1-branch, HEAD
257 #
258 # chastain 2002-04-08
259
260 # NOTE (2004-02-24, carlton): This test really is invalid -
261 # 'NestedInnerLocal' shouldn't be visible, so only the third
262 # expression should count as a pass. I'm leaving in the earlier
263 # passes, however, given the current problematic state of our local
264 # class support, but once we fix PR gdb/482, we should delete this
265 # test.
266
267 gdb_test_multiple "ptype NestedInnerLocal" "ptype NestedInnerLocal" {
268 -re "type = class NestedInnerLocal \{\[\r\n\t \]*public:\[\r\n\t \]*int nil;\[\r\n\t \]*int nil_foo\\(int\\);\[\r\n\t \]*\}.*$gdb_prompt $" {
269 pass "ptype NestedInnerLocal"
270 }
271 -re "type = class NestedInnerLocal \{\[\r\n\t \]*public:\[\r\n\t \]*int nil;\[\r\n\t \]*NestedInnerLocal *& *operator *= *\\((main${sep}::|)InnerLocal::NestedInnerLocal const *&\\);\[\r\n\t \]*NestedInnerLocal\\((main${sep}::|)InnerLocal::NestedInnerLocal const *&\\);\[\r\n\t \]*NestedInnerLocal\\((void|)\\);\[\r\n\t \]*int nil_foo\\(int\\);\[\r\n\t \]*\}.*$gdb_prompt $" {
272 pass "ptype NestedInnerLocal"
273 }
274 -re "No symbol \"NestedInnerLocal\" in current context\.\r\n$gdb_prompt $" {
275 pass "ptype NestedInnerLocal"
276 }
277 }
278
279 set re_class "((struct|class) InnerLocal::NestedInnerLocal \{${ws}public:|struct InnerLocal::NestedInnerLocal \{)"
280 set re_fields "int nil;"
281 set re_methods "int nil_foo\\(int\\);"
282 set re_synth_gcc_23 "InnerLocal::NestedInnerLocal & operator=\\(InnerLocal::NestedInnerLocal const ?&\\);${ws}NestedInnerLocal\\(InnerLocal::NestedInnerLocal const ?&\\);${ws}NestedInnerLocal\\(\\);"
283
284 set name "ptype InnerLocal::NestedInnerLocal"
285 gdb_test_multiple "ptype InnerLocal::NestedInnerLocal" $name {
286 -re "type = $re_class${ws}$re_fields${ws}$re_methods$nl\}$nl$gdb_prompt $" {
287 # gcc -gdwarf-2 should produce this but does not yet
288 pass $name
289 }
290 -re "type = $re_class${ws}$re_fields${ws}$re_synth_gcc_23${ws}$re_methods${ws}$nl\}$nl$gdb_prompt $" {
291 # gcc 2.95.3 -gstabs+
292 # gcc v3 -gstabs+, abi 1
293 pass $name
294 }
295 -re "type = $re_class${ws}$re_fields${ws}$re_methods${ws}$re_synth_gcc_23${ws}$nl\}$nl$gdb_prompt $" {
296 # gcc v3 -gstabs+, abi 2
297 pass $name
298 }
299 -re "There is no field named NestedInnerLocal.*$gdb_prompt $" {
300 # gcc v3 -gdwarf-2
301 kfail "gdb/482" $name
302 }
303 }
This page took 0.037618 seconds and 5 git commands to generate.