1 |
106 |
markom |
# Copyright (C) 1998, 1999 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 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 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 |
|
|
|
36 |
|
|
if { [skip_cplus_tests] } { continue }
|
37 |
|
|
|
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 |
|
|
|
46 |
|
|
if [get_compiler_info $binfile "c++"] {
|
47 |
|
|
return -1
|
48 |
|
|
}
|
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 {
|
71 |
|
|
-re ".*$gdb_prompt $" {}
|
72 |
|
|
timeout { fail "up from marker1" }
|
73 |
|
|
}
|
74 |
|
|
}
|
75 |
|
|
-re "$gdb_prompt $" { fail "continue to marker1" }
|
76 |
|
|
timeout { fail "(timeout) continue to marker1" }
|
77 |
|
|
}
|
78 |
|
|
|
79 |
|
|
# srikanth, These tests have always been run only with aCC. Now in
|
80 |
|
|
# the new scheme of things, we run it twice, once with aCC, and once
|
81 |
|
|
# with g++. Flag these tests as expected failures when run with g++.
|
82 |
|
|
# as these are failing now and were never known to pass with g++.
|
83 |
|
|
global gcc_compiled
|
84 |
|
|
if {$gcc_compiled} then {
|
85 |
|
|
setup_xfail "*-*-*"
|
86 |
|
|
}
|
87 |
|
|
|
88 |
|
|
# Local classes in g++ get names like "main.1::InnerLocal", just like local
|
89 |
|
|
# static variables. Some targets use "___" instead of ".".
|
90 |
|
|
set sep "(\[.\]|___)\[0-9\]"
|
91 |
|
|
|
92 |
|
|
send_gdb "ptype Local\n"
|
93 |
|
|
gdb_expect {
|
94 |
|
|
-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" }
|
95 |
|
|
-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?)" }
|
96 |
|
|
-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" }
|
97 |
|
|
-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)" }
|
98 |
|
|
-re ".*$gdb_prompt $" { fail "ptype Local" }
|
99 |
|
|
timeout { fail "(timeout) ptype Local" }
|
100 |
|
|
}
|
101 |
|
|
|
102 |
|
|
# DTS CLLbs14316 and CLLbs17058
|
103 |
|
|
# coulter - I added a clause for HP's aCC compiler. We print out the type
|
104 |
|
|
# as xx instead of const unsigned char, but we still have an expected failure
|
105 |
|
|
# because of two reasons:
|
106 |
|
|
# There is a number at the end of InnerLocal4 which should not be there,
|
107 |
|
|
# DTS CLLbs14316
|
108 |
|
|
# The line number for the class
|
109 |
|
|
setup_xfail "hppa*-*-*" CLLbs14316
|
110 |
|
|
send_gdb "ptype InnerLocal\n"
|
111 |
|
|
gdb_expect {
|
112 |
|
|
-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" }
|
113 |
|
|
-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" }
|
114 |
|
|
-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?" }
|
115 |
|
|
-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?" }
|
116 |
|
|
-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" }
|
117 |
|
|
-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" }
|
118 |
|
|
-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)" }
|
119 |
|
|
-re ".*$gdb_prompt $" { fail "ptype InnerLocal" }
|
120 |
|
|
timeout { fail "(timeout) ptype InnerLocal" }
|
121 |
|
|
}
|
122 |
|
|
|
123 |
|
|
send_gdb "ptype NestedInnerLocal\n"
|
124 |
|
|
gdb_expect {
|
125 |
|
|
-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" }
|
126 |
|
|
-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?)" }
|
127 |
|
|
-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" }
|
128 |
|
|
-re "No symbol.*in current context.*$gdb_prompt $" { pass "ptype NestedInnerLocal (known aCC limitation)" }
|
129 |
|
|
-re ".*$gdb_prompt $" { fail "ptype NestedInnerLocal" }
|
130 |
|
|
timeout { fail "(timeout) ptype NestedInnerLocal" }
|
131 |
|
|
}
|
132 |
|
|
|
133 |
|
|
# gdb incorrectly interprets the NestedInnerLocal in
|
134 |
|
|
# InnerLocal::NestedInnerLocal as field name instead of a type name;
|
135 |
|
|
# See CLLbs14784.
|
136 |
|
|
setup_xfail *-*-* CLLbs14784
|
137 |
|
|
send_gdb "ptype InnerLocal::NestedInnerLocal\n"
|
138 |
|
|
gdb_expect {
|
139 |
|
|
-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" }
|
140 |
|
|
-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?)" }
|
141 |
|
|
-re ".*$gdb_prompt $" { fail "ptype InnerLocal::NestedInnerLocal" }
|
142 |
|
|
timeout { fail "(timeout) ptype InnerLocal::NestedInnerLocal" }
|
143 |
|
|
}
|
144 |
|
|
|
145 |
|
|
|