ignore invalid DOF provider sections
[binutils-gdb.git] / gdb / testsuite / gdb.cp / local.exp
blob32b8f12fb1965a211374a717b6a91ebacd0f4e61
1 # Copyright 1998-2015 Free Software Foundation, Inc.
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.
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.
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/>.
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
21 # This file is part of the gdb testsuite
23 set ws "\[\r\n\t \]+"
24 set nl "\[\r\n\]+"
27 # test running programs
30 if { [skip_cplus_tests] } { continue }
32 standard_testfile .cc
34 if [get_compiler_info "c++"] {
35 return -1
38 if {[prepare_for_testing $testfile.exp $testfile $srcfile {debug c++}]} {
39 return -1
43 # set it up at a breakpoint so we can play with the variable values
45 if ![runto_main] then {
46 perror "couldn't run to breakpoint"
47 continue
50 if ![runto 'marker1'] then {
51 perror "couldn't run to marker1"
52 continue
55 gdb_test "up" ".*foobar.*" "up from marker1"
57 set sep "(\[.\]|___)\[0-9\]"
59 # ptype on a local variable.
61 # This test has six arms. The first three arms accept normal output:
62 # no synthetic methods; synthetic methods before user methods;
63 # synthetic methods after user methods.
65 # The next two arms accept "foobar__Fi.0::Local" instead of "Local".
66 # This is a bug. It happens in various places with various versions of
67 # gcc and gdb and various debugging types.
69 # The last arm accepts the user methods in duplicate. This bug happens
70 # with gcc 3.3.2 -gdwarf-2, and has been fixed in gcc HEAD 2004-01-22.
72 # -- chastain 2004-01-24
74 set re_class "((struct|class) Local \{${ws}public:|struct Local \{)"
75 set re_fields "int loc1;"
76 set re_methods "char loc_foo\\(char\\);"
77 set re_synth_gcc_23 "Local & operator=\\(Local const ?&\\);${ws}Local\\(Local const ?&\\);${ws}Local\\((void|)\\);"
79 set XX_class "((struct|class) foobar__Fi.0::Local \{${ws}public:|struct foobar__Fi.0:Local \{)"
80 set XX_synth_gcc_2 "Local & operator=\\(foobar__Fi.0::Local const ?&\\);${ws}Local\\(foobar__Fi.0::Local const ?&\\);${ws}Local\\((void|)\\);"
81 set YY_methods "$re_methods${ws}$re_methods"
83 set name "ptype l"
84 gdb_test_multiple "ptype l" $name {
85 -re "type = $re_class${ws}$re_fields${ws}$re_methods$nl\}$nl$gdb_prompt $" {
86 # gdb 6.0, gcc 2.95.3, dwarf-2
87 # gdb 6.0, gcc HEAD 2004-01-22, dwarf-2
88 # gdb HEAD 2004-01-23, gcc HEAD 2004-01,22, dwarf-2
89 pass "$name"
91 -re "type = $re_class${ws}$re_fields${ws}$re_synth_gcc_23${ws}$re_methods$nl\}$nl$gdb_prompt $" {
92 # gdb 6.0, gcc 3.3.2, stabs+
93 # gdb HEAD 2004-01-23, gcc 3.3.2, stabs+
94 pass "$name"
96 -re "type = $re_class${ws}$re_fields${ws}$re_methods${ws}$re_synth_gcc_23${ws}$nl\}$nl$gdb_prompt $" {
97 # gdb 6.0, gcc HEAD 2004-01-22, stabs+
98 # gdb HEAD 2004-01-23, gcc HEAD 2004-01-22, stabs+
99 pass "$name"
101 -re "type = $XX_class${ws}$re_fields${ws}$re_methods$nl\}$nl$gdb_prompt $" {
102 # gdb HEAD 2004-01-23, gcc 2.95.3, dwarf-2
103 kfail "gdb/1516" "$name"
105 -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 $" {
106 # gdb 6.0, gcc 2.95.3, stabs+
107 # gdb HEAD 2004-01-23, gcc 2.95.3, stabs+
108 kfail "gdb/1516" "$name"
110 -re "type = ($re_class|$XX_class)${ws}$re_fields${ws}$YY_methods$nl\}$nl$gdb_prompt $" {
111 # gdb 6.0, gcc 3.3.2, dwarf-2
112 # gdb HEAD 2004-01-23, gcc 3.2.2, dwarf-2
113 kfail "gdb/483" "$name"
117 # This is the same test with "ptype Local" (the type name)
118 # instead of "ptype l" (the variable name).
120 set name "ptype Local"
121 gdb_test_multiple "ptype Local" $name {
122 -re "type = $re_class${ws}$re_fields${ws}$re_methods$nl\}$nl$gdb_prompt $" {
123 # gdb 6.0, gcc 2.95.3, dwarf-2
124 # gdb 6.0, gcc HEAD 2004-01-22, dwarf-2
125 # gdb HEAD 2004-01-23, gcc HEAD 2004-01-22, dwarf-2
126 pass "$name"
128 -re "type = $re_class${ws}$re_fields${ws}$re_synth_gcc_23${ws}$re_methods$nl\}$nl$gdb_prompt $" {
129 # gdb 6.0, gcc 3.3.2, stabs+
130 # gdb HEAD 2004-01-23, gcc 3.3.2, stabs+
131 pass "$name"
133 -re "type = $re_class${ws}$re_fields${ws}$re_methods${ws}$re_synth_gcc_23${ws}$nl\}$nl$gdb_prompt $" {
134 # gdb 6.0, gcc HEAD 2004-01-22, stabs+
135 # gdb HEAD 2004-01-23, gcc HEAD 2004-01-22, stabs+
136 pass "$name"
138 -re "type = $XX_class${ws}$re_fields${ws}$re_methods$nl\}$nl$gdb_prompt $" {
139 kfail "gdb/1516" "$name"
141 -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 $" {
142 # gdb 6.0, gcc 2.95.3, stabs+
143 # gdb HEAD 2004-01-23, gcc 2.95.3, stabs+
144 kfail "gdb/1516" "$name"
146 -re "type = ($re_class|$XX_class)${ws}$re_fields${ws}$YY_methods$nl\}$nl$gdb_prompt $" {
147 # gdb 6.0, gcc 3.3.2, dwarf-2
148 # gdb HEAD 2004-01-23, gcc 3.2.2, dwarf-2
149 kfail "gdb/483" "$name"
151 -re "No symbol \"Local\" in current context.$nl$gdb_prompt $" {
152 # gdb HEAD 2004-01-23, gcc 2.95.3, dwarf-2
153 fail "$name"
157 gdb_test "break marker2"
158 gdb_test "continue" "Continuing\\..*Breakpoint \[0-9\]+, marker2.*" \
159 "continuing to marker2"
161 gdb_test "up" ".*main.*" "up from marker2"
163 # Make sure that `Local' isn't in scope here; it's local to foobar.
164 # setup_kfail "gdb/825"
166 set eol "\[\t \]*\[\r\n\]+\[\t \]*"
167 gdb_test_multiple "ptype Local" "Local out of scope" {
168 -re "No symbol \"Local\" in current context.*${gdb_prompt} $" {
169 pass "Local out of scope"
171 -re "ptype Local${eol}type = class Local {${eol} public:${eol} int loc1;${eol}.*${eol} char loc_foo\\(char\\);${eol}}${eol}${gdb_prompt} " {
172 # GCC emits STABS debugging information in a way that doesn't
173 # properly preserve the scoping of local classes. I think
174 # we'd need to start using Sun's extensions to stabs to get
175 # this right.
176 kfail gdb/825 "Local out of scope"
178 -re "ptype Local${eol}type = class Local {${eol} public:${eol} int loc1;${eol} char loc_foo\\(char\\);${eol}.*${eol}}${eol}${gdb_prompt} " {
179 # gcc 3.X abi-2 -gstabs+
180 kfail gdb/825 "Local out of scope"
185 # DTS CLLbs14316 and CLLbs17058
186 # coulter - I added a clause for HP's aCC compiler. We print out the type
187 # as xx instead of const unsigned char, but we still have an expected failure
188 # because of two reasons:
189 # There is a number at the end of InnerLocal4 which should not be there,
190 # DTS CLLbs14316
191 # The line number for the class
192 # setup_xfail "hppa*-*-*" CLLbs14316
194 # ---
195 # Pattern 1:
196 # PASS
197 # dwarf-2
198 # 2.95.3, 2.96-rh, 3.0.4, 3.1, gcc-3_1-branch, HEAD
200 # Pattern 2:
201 # PASS
202 # stabs+
203 # 2.95.3, 2.96-rh, 3.0.4, 3.1, gcc-3_1-branch, HEAD
205 # Pattern 3:
206 # Old hppa pattern.
208 # Pattern 4:
209 # Old hppa pattern.
211 # chastain 2002-05-27
213 # Pattern 5:
214 # PASS
215 # stabs+
216 # HEAD
218 # chastain 2004-01-02
220 gdb_test_multiple "ptype InnerLocal" "ptype InnerLocal" {
221 -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 $" {
222 pass "ptype InnerLocal (pattern 1)"
224 -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 $" {
225 pass "ptype InnerLocal (pattern 2)"
227 -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 $" {
228 pass "ptype InnerLocal (old HP aCC)"
230 -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 $" {
231 pass "ptype InnerLocal (old HP aCC)"
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 \]* 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 $" {
234 pass "ptype InnerLocal (pattern 5)"
238 #---
239 # Pattern 1:
240 # PASS
241 # dwarf-2
242 # gcc 2.95.3, 2.96-rh, 3.0.4, gcc-3_1-branch, HEAD
244 # Pattern 2:
245 # PASS
246 # stabs+
247 # gcc 2.95.3, 2.96-rh, 3.0.4, gcc-3_1-branch, HEAD
249 # chastain 2002-04-08
251 # NOTE (2004-02-24, carlton): This test really is invalid -
252 # 'NestedInnerLocal' shouldn't be visible, so only the third
253 # expression should count as a pass. I'm leaving in the earlier
254 # passes, however, given the current problematic state of our local
255 # class support, but once we fix PR gdb/482, we should delete this
256 # test.
258 gdb_test_multiple "ptype NestedInnerLocal" "ptype NestedInnerLocal" {
259 -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 $" {
260 pass "ptype NestedInnerLocal"
262 -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 $" {
263 pass "ptype NestedInnerLocal"
265 -re "No symbol \"NestedInnerLocal\" in current context\.\r\n$gdb_prompt $" {
266 pass "ptype NestedInnerLocal"
270 set re_class "((struct|class) InnerLocal::NestedInnerLocal \{${ws}public:|struct InnerLocal::NestedInnerLocal \{)"
271 set re_fields "int nil;"
272 set re_methods "int nil_foo\\(int\\);"
273 set re_synth_gcc_23 "InnerLocal::NestedInnerLocal & operator=\\(InnerLocal::NestedInnerLocal const ?&\\);${ws}NestedInnerLocal\\(InnerLocal::NestedInnerLocal const ?&\\);${ws}NestedInnerLocal\\(\\);"
275 set name "ptype InnerLocal::NestedInnerLocal"
276 gdb_test_multiple "ptype InnerLocal::NestedInnerLocal" $name {
277 -re "type = $re_class${ws}$re_fields${ws}$re_methods$nl\}$nl$gdb_prompt $" {
278 # gcc -gdwarf-2 should produce this but does not yet
279 pass $name
281 -re "type = $re_class${ws}$re_fields${ws}$re_synth_gcc_23${ws}$re_methods${ws}$nl\}$nl$gdb_prompt $" {
282 # gcc 2.95.3 -gstabs+
283 # gcc v3 -gstabs+, abi 1
284 pass $name
286 -re "type = $re_class${ws}$re_fields${ws}$re_methods${ws}$re_synth_gcc_23${ws}$nl\}$nl$gdb_prompt $" {
287 # gcc v3 -gstabs+, abi 2
288 pass $name
290 -re "There is no field named NestedInnerLocal.*$gdb_prompt $" {
291 # gcc v3 -gdwarf-2
292 kfail "gdb/482" $name