1 # Copyright
1998, 1999, 2000, 2001, 2002, 2003, 2004
2 # Free Software Foundation
, Inc.
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
2 of the License
, or
7 #
(at your option
) any later version.
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.
14 # You should have received a copy of the GNU General Public License
15 # along with this
program; if not
, write to the Free Software
16 # Foundation
, Inc.
, 59 Temple Place
- Suite
330, Boston
, MA
02111-1307, USA.
18 # tests
for local variables
19 # Written by Satish Pai
<pai@apollo.hp.com
> 1997-07-08
20 # Cleaned by Michael Chastain
<mec@shout.net
> 2002-04-08
23 # This file is part of the gdb testsuite
33 # test running programs
38 if { [skip_cplus_tests
] } { continue }
41 set srcfile $
{testfile
}.cc
42 set binfile $
{objdir
}/$
{subdir
}/$
{testfile
}
44 if { [gdb_compile
"${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } {
45 gdb_suppress_entire_file
"Testcase compile failed, so all tests in this file will automatically fail."
48 if [get_compiler_info $binfile
"c++"] {
54 gdb_reinitialize_dir $srcdir
/$subdir
59 #
set it up at a breakpoint so we can play with the
variable values
61 if ![runto_main
] then {
62 perror
"couldn't run to breakpoint"
66 if ![runto
'marker1'] then {
67 perror
"couldn't run to marker1"
71 gdb_test
"up" ".*foobar.*" "up from marker1"
73 set sep
"(\[.\]|___)\[0-9\]"
75 # ptype
on a local
variable.
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.
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.
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.
88 #
-- chastain
2004-01-24
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|)\\);"
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"
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
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
+
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
+
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"
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"
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"
133 # This is the same test with
"ptype Local" (the type name)
134 # instead of
"ptype l" (the variable name).
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
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
+
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
+
154 -re
"type = $XX_class${ws}$re_fields${ws}$re_methods$nl\}$nl$gdb_prompt $" {
155 kfail
"gdb/1516" "$name"
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"
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"
167 -re
"No symbol \"Local\" in current context.$nl$gdb_prompt $" {
168 # gdb HEAD
2004-01-23, gcc
2.95.3, dwarf
-2
173 gdb_test
"break marker2"
174 gdb_test
"continue" "Continuing\\..*Breakpoint \[0-9\]+, marker2.*" \
175 "continuing to marker2"
177 gdb_test
"up" ".*main.*" "up from marker2"
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 \]*"
184 -re "No symbol \"Local\" in current context.*${gdb_prompt} $" {
185 pass "Local out of scope"
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
192 kfail gdb
/825 "Local out of scope"
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"
198 -re
".*${gdb_prompt} $" {
199 fail
"Local out of scope"
202 fail
"Local out of scope (timeout)"
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,
213 # The line number for the class
214 # setup_xfail "hppa*-*-*" CLLbs14316
220 # 2.95.3, 2.96-rh, 3.0.4, 3.1, gcc-3_1-branch, HEAD
225 # 2.95.3, 2.96-rh, 3.0.4, 3.1, gcc-3_1-branch, HEAD
233 # chastain 2002-05-27
240 # chastain 2004-01-02
242 send_gdb "ptype InnerLocal\n"
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" }
257 # gcc 2.95.3, 2.96-rh, 3.0.4, gcc-3_1-branch, HEAD
262 # gcc 2.95.3, 2.96-rh, 3.0.4, gcc-3_1-branch, HEAD
264 # chastain 2002-04-08
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
273 send_gdb "ptype NestedInnerLocal\n"
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"
280 -re ".*$gdb_prompt $" { fail "ptype NestedInnerLocal" }
281 timeout { fail "(timeout) ptype NestedInnerLocal" }
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\\(\\);"
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
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
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
304 -re "There is no field named NestedInnerLocal.*$gdb_prompt $" {
306 kfail "gdb/482" $name