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