Commit | Line | Data |
---|---|---|
b6ba6518 | 1 | # Copyright 1998, 1999, 2000 Free Software Foundation, Inc. |
c906108c SS |
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 2 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, write to the Free Software | |
15 | # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |
16 | ||
17 | # Please email any bugs, comments, and/or additions to this file to: | |
18 | # bug-gdb@prep.ai.mit.edu | |
19 | ||
20 | # tests for local variables | |
21 | # Written by Satish Pai <pai@apollo.hp.com> 1997-07-08 | |
22 | ||
23 | ||
24 | # This file is part of the gdb testsuite | |
25 | ||
26 | if $tracelevel then { | |
27 | strace $tracelevel | |
28 | } | |
29 | ||
30 | # | |
31 | # test running programs | |
32 | # | |
33 | set prms_id 0 | |
34 | set bug_id 0 | |
35 | ||
d4f3574e SS |
36 | if { [skip_cplus_tests] } { continue } |
37 | ||
c906108c SS |
38 | set testfile "local" |
39 | set srcfile ${testfile}.cc | |
40 | set binfile ${objdir}/${subdir}/${testfile} | |
41 | ||
42 | if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } { | |
43 | gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." | |
44 | } | |
45 | ||
a0b3c4fd JM |
46 | if [get_compiler_info $binfile "c++"] { |
47 | return -1 | |
48 | } | |
c906108c SS |
49 | |
50 | gdb_exit | |
51 | gdb_start | |
52 | gdb_reinitialize_dir $srcdir/$subdir | |
53 | gdb_load ${binfile} | |
54 | ||
55 | ||
56 | # | |
57 | # set it up at a breakpoint so we can play with the variable values | |
58 | # | |
59 | if ![runto_main] then { | |
60 | perror "couldn't run to breakpoint" | |
61 | continue | |
62 | } | |
63 | ||
64 | send_gdb "break marker1\n" ; gdb_expect -re ".*$gdb_prompt $" | |
65 | ||
66 | send_gdb "cont\n" | |
67 | gdb_expect { | |
68 | -re "Break.* marker1 \\(\\) at .*:$decimal.*$gdb_prompt $" { | |
69 | send_gdb "up\n" | |
70 | gdb_expect { | |
3c077de9 MS |
71 | -re ".*main.*$gdb_prompt $" { |
72 | pass "up from marker1" | |
73 | } | |
660fd469 MS |
74 | -re ".*$gdb_prompt $" { |
75 | fail "up from marker1" | |
76 | } | |
77 | timeout { fail "up from marker1 (timeout)" } | |
c906108c SS |
78 | } |
79 | } | |
80 | -re "$gdb_prompt $" { fail "continue to marker1" } | |
81 | timeout { fail "(timeout) continue to marker1" } | |
82 | } | |
83 | ||
a0b3c4fd JM |
84 | # srikanth, These tests have always been run only with aCC. Now in |
85 | # the new scheme of things, we run it twice, once with aCC, and once | |
86 | # with g++. Flag these tests as expected failures when run with g++. | |
87 | # as these are failing now and were never known to pass with g++. | |
88 | global gcc_compiled | |
89 | if {$gcc_compiled} then { | |
90 | setup_xfail "*-*-*" | |
91 | } | |
92 | ||
c2d11a7d JM |
93 | # Local classes in g++ get names like "main.1::InnerLocal", just like local |
94 | # static variables. Some targets use "___" instead of ".". | |
95 | set sep "(\[.\]|___)\[0-9\]" | |
96 | ||
c906108c SS |
97 | send_gdb "ptype Local\n" |
98 | gdb_expect { | |
a0b3c4fd JM |
99 | -re "type = class Local \{\r\n\[\t \]*public:\r\n\[\t \]*int loc1;\r\n\r\n\[\t \]*.char loc_foo\\(char\\);\r\n\[\t \]*\}\[\t \]*\\(Local at.*local\\.cc:10\\).*$gdb_prompt $" { pass "ptype Local" } |
100 | -re "type = class Local \{\r\n\[\t \]*public:\r\n\[\t \]*int loc1;\r\n\r\n\[\t \]*.char loc_foo\\(char\\);\r\n\[\t \]*\}\[\t \]*\\(Local at.*local\\.cc:\[0-9\]*\\).*$gdb_prompt $" { pass "ptype Local (incorrect line number?)" } | |
c2d11a7d | 101 | -re "type = class Local \{\r\n\[\t \]*public:\r\n\[\t \]*int loc1;\r\n\r\n\[\t \]*Local & operator=\\((foobar__Fi${sep}::|)Local const &\\);\r\n\[\t \]*Local\\((foobar__Fi${sep}::|)Local const &\\);\r\n\[\t \]*Local\\(void\\);\r\n\[\t \]*char loc_foo\\(char\\);\r\n\[\t \]*\}*.*$gdb_prompt $" { pass "ptype Local" } |
a0b3c4fd | 102 | -re "type = class Local \{\r\n\[\t \]*public:\r\n\[\t \]*int loc1;\r\n\r\n\[\t \]*char loc_foo\\(char\\);\r\n\[\t \]*\\(Local at.*local\\.cc:\[0-9\]*\\)\r\n\}.*$gdb_prompt $" { pass "ptype Local (aCC)" } |
c906108c SS |
103 | -re ".*$gdb_prompt $" { fail "ptype Local" } |
104 | timeout { fail "(timeout) ptype Local" } | |
105 | } | |
106 | ||
a0b3c4fd JM |
107 | # DTS CLLbs14316 and CLLbs17058 |
108 | # coulter - I added a clause for HP's aCC compiler. We print out the type | |
109 | # as xx instead of const unsigned char, but we still have an expected failure | |
110 | # because of two reasons: | |
111 | # There is a number at the end of InnerLocal4 which should not be there, | |
112 | # DTS CLLbs14316 | |
113 | # The line number for the class | |
114 | setup_xfail "hppa*-*-*" CLLbs14316 | |
c906108c SS |
115 | send_gdb "ptype InnerLocal\n" |
116 | gdb_expect { | |
a0b3c4fd JM |
117 | -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\\(const unsigned char &\\);\r\n\[\t \]*\}\[\t \]*\\(Local at.*local\\.cc:36\\).*$gdb_prompt $" { pass "ptype InnerLocal" } |
118 | -re "type = class InnerLocal \{\r\n\[\t \]*public:\r\n\[\t \]*char ilc;\r\n\[\t \]*int \\*ip;\r\n\[\t \]*class InnerLocal::NestedInnerLocal nest1;\r\n\r\n\[\t \]*.int il_foo\\(const unsigned char &\\);\r\n\[\t \]*\}\[\t \]*\\(Local at.*local\\.cc:36\\).*$gdb_prompt $" { pass "ptype InnerLocal" } | |
119 | -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\\(const unsigned char &\\);\r\n\[\t \]*\}\[\t \]*\\(Local at.*local\\.cc:\[0-9\]*\\).*$gdb_prompt $" { pass "ptype InnerLocal (incorrect line number?" } | |
120 | -re "type = class InnerLocal \{\r\n\[\t \]*public:\r\n\[\t \]*char ilc;\r\n\[\t \]*int \\*ip;\r\n\[\t \]*class InnerLocal::NestedInnerLocal nest1;\r\n\r\n\[\t \]*.int il_foo\\(const unsigned char &\\);\r\n\[\t \]*\}\[\t \]*\\(Local at.*local\\.cc:\[0-9\]*\\).*$gdb_prompt $" { pass "ptype InnerLocal (incorrect line number?" } | |
121 | -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 HP aCC" } | |
c2d11a7d | 122 | -re "type = class InnerLocal \{\r\n\[\t \]*public:\r\n\[\t \]*char ilc;\r\n\[\t \]*int \\*ip;\r\n\[\t \]*NestedInnerLocal nest1;\r\n\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\*\}\r\n*.*$gdb_prompt $" { pass "ptype InnerLocal" } |
a0b3c4fd | 123 | -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 (aCC)" } |
c906108c SS |
124 | -re ".*$gdb_prompt $" { fail "ptype InnerLocal" } |
125 | timeout { fail "(timeout) ptype InnerLocal" } | |
126 | } | |
127 | ||
c906108c SS |
128 | send_gdb "ptype NestedInnerLocal\n" |
129 | gdb_expect { | |
a0b3c4fd JM |
130 | -re "type = class InnerLocal::NestedInnerLocal \{\r\n\[\t \]*public:\r\n\[\t \]*int nil;\r\n\r\n\[\t \]*.int nil_foo\\(int\\);\r\n\[\t \]*\}\[\t \]*\\(Local at.*local\\.cc:44\\).*$gdb_prompt $" { pass "ptype NestedInnerLocal" } |
131 | -re "type = class InnerLocal::NestedInnerLocal \{\r\n\[\t \]*public:\r\n\[\t \]*int nil;\r\n\r\n\[\t \]*.int nil_foo\\(int\\);\r\n\[\t \]*\}\[\t \]*\\(Local at.*local\\.cc:\[0-9\]*\\).*$gdb_prompt $" { pass "ptype NestedInnerLocal (incorrect line number?)" } | |
c2d11a7d | 132 | -re "type = class NestedInnerLocal \{\r\n\[\t \]*public:\r\n\[\t \]*int nil;\r\n\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\}\r\n*.*$gdb_prompt $" { pass "ptype NestedInnerLocal" } |
c906108c SS |
133 | -re "No symbol.*in current context.*$gdb_prompt $" { pass "ptype NestedInnerLocal (known aCC limitation)" } |
134 | -re ".*$gdb_prompt $" { fail "ptype NestedInnerLocal" } | |
135 | timeout { fail "(timeout) ptype NestedInnerLocal" } | |
136 | } | |
137 | ||
e5f9ba7b MS |
138 | # srikanth, These tests have always been run only with aCC. Now in |
139 | # the new scheme of things, we run it twice, once with aCC, and once | |
140 | # with g++. Flag these tests as expected failures when run with g++. | |
141 | # as these are failing now and were never known to pass with g++. | |
142 | global gcc_compiled | |
143 | if {$gcc_compiled} then { | |
144 | setup_xfail "*-*-*" | |
145 | } | |
146 | ||
a0b3c4fd JM |
147 | # gdb incorrectly interprets the NestedInnerLocal in |
148 | # InnerLocal::NestedInnerLocal as field name instead of a type name; | |
149 | # See CLLbs14784. | |
104c1213 | 150 | setup_xfail *-*-* CLLbs14784 |
c906108c SS |
151 | send_gdb "ptype InnerLocal::NestedInnerLocal\n" |
152 | gdb_expect { | |
a0b3c4fd JM |
153 | -re "type = class InnerLocal::NestedInnerLocal \{\r\n\[\t \]*public:\r\n\[\t \]*int nil;\r\n\r\n\[\t \]*.int nil_foo\\(int\\);\r\n\[\t \]*\}\[\t \]*\\(Local at.*local\\.cc:44\\).*$gdb_prompt $" { pass "ptype InnerLocal::NestedInnerLocal" } |
154 | -re "type = class InnerLocal::NestedInnerLocal \{\r\n\[\t \]*public:\r\n\[\t \]*int nil;\r\n\r\n\[\t \]*.int nil_foo\\(int\\);\r\n\[\t \]*\}\[\t \]*\\(Local at.*local\\.cc:\[0-9\]*\\).*$gdb_prompt $" { pass "ptype InnerLocal::NestedInnerLocal (incorrect line number?)" } | |
c906108c SS |
155 | -re ".*$gdb_prompt $" { fail "ptype InnerLocal::NestedInnerLocal" } |
156 | timeout { fail "(timeout) ptype InnerLocal::NestedInnerLocal" } | |
157 | } | |
158 | ||
159 |