1 |
578 |
markom |
# Copyright 1997, 1998, 2000, 2001 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 namespaces
|
21 |
|
|
# Written by Satish Pai 1997-07-23
|
22 |
|
|
|
23 |
|
|
# This file is part of the gdb testsuite
|
24 |
|
|
|
25 |
|
|
# Note: These tests are geared to the HP aCC compiler,
|
26 |
|
|
# which has an idiosyncratic way of emitting debug info
|
27 |
|
|
# for namespaces.
|
28 |
|
|
# Note: As of 2000-06-03, these pass under g++ - djb
|
29 |
|
|
|
30 |
|
|
|
31 |
|
|
if $tracelevel then {
|
32 |
|
|
strace $tracelevel
|
33 |
|
|
}
|
34 |
|
|
|
35 |
|
|
set prms_id 0
|
36 |
|
|
set bug_id 0
|
37 |
|
|
|
38 |
|
|
if { [skip_cplus_tests] } { continue }
|
39 |
|
|
|
40 |
|
|
set testfile "namespace"
|
41 |
|
|
set srcfile ${testfile}.cc
|
42 |
|
|
set binfile ${objdir}/${subdir}/${testfile}
|
43 |
|
|
|
44 |
|
|
if [get_compiler_info ${binfile}] {
|
45 |
|
|
return -1;
|
46 |
|
|
}
|
47 |
|
|
|
48 |
|
|
|
49 |
|
|
|
50 |
|
|
if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } {
|
51 |
|
|
gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will a
|
52 |
|
|
utomatically fail."
|
53 |
|
|
}
|
54 |
|
|
|
55 |
|
|
|
56 |
|
|
|
57 |
|
|
gdb_exit
|
58 |
|
|
gdb_start
|
59 |
|
|
gdb_reinitialize_dir $srcdir/$subdir
|
60 |
|
|
gdb_load ${binfile}
|
61 |
|
|
|
62 |
|
|
|
63 |
|
|
#
|
64 |
|
|
# set it up at a breakpoint so we can play with the variable values
|
65 |
|
|
#
|
66 |
|
|
if ![runto_main] then {
|
67 |
|
|
perror "couldn't run to breakpoint"
|
68 |
|
|
continue
|
69 |
|
|
}
|
70 |
|
|
|
71 |
|
|
if ![runto 'marker1'] then {
|
72 |
|
|
perror "couldn't run to marker1"
|
73 |
|
|
continue
|
74 |
|
|
}
|
75 |
|
|
|
76 |
|
|
gdb_test "up" ".*main.*" "up from marker1"
|
77 |
|
|
|
78 |
|
|
# Access a data item inside a namespace using colons and
|
79 |
|
|
# single quotes :-(
|
80 |
|
|
|
81 |
|
|
send_gdb "print 'AAA::c'\n"
|
82 |
|
|
gdb_expect {
|
83 |
|
|
-re "\\$\[0-9\]* = 0 '\\\\000'\r\n$gdb_prompt $" { pass "print 'AAA::c'" }
|
84 |
|
|
-re ".*$gdb_prompt $" { fail "print 'AAA::c'" }
|
85 |
|
|
timeout { fail "(timeout) print 'AAA::c'" }
|
86 |
|
|
}
|
87 |
|
|
|
88 |
|
|
# An object declared using "using".
|
89 |
|
|
|
90 |
|
|
send_gdb "print ina\n"
|
91 |
|
|
gdb_expect {
|
92 |
|
|
-re "\\$\[0-9\]+ = {xx = 33}.*$gdb_prompt $" {
|
93 |
|
|
pass "print ina"
|
94 |
|
|
}
|
95 |
|
|
-re ".*$gdb_prompt $" { fail "print ina" }
|
96 |
|
|
timeout { fail "(timeout) print ina" }
|
97 |
|
|
}
|
98 |
|
|
|
99 |
|
|
send_gdb "ptype ina\n"
|
100 |
|
|
gdb_expect {
|
101 |
|
|
-re "type = class (AAA::|)inA \{\r\n\[ \]*public:\r\n\[ \]*int xx;\r\n\[ \]*\r\n\[ \]*.*int fum\\(int\\);\r\n\}\r\n$gdb_prompt $" {
|
102 |
|
|
pass "ptype ina"
|
103 |
|
|
}
|
104 |
|
|
-re ".*$gdb_prompt $" { fail "ptype ina" }
|
105 |
|
|
timeout { fail "(timeout) ptype ina" }
|
106 |
|
|
}
|
107 |
|
|
|
108 |
|
|
# Check all functions are known to GDB
|
109 |
|
|
|
110 |
|
|
setup_xfail hppa*-*-*11* CLLbs14869
|
111 |
|
|
send_gdb "info func xyzq\n"
|
112 |
|
|
gdb_expect {
|
113 |
|
|
-re "All functions.*File.*namespace.cc:\r\nint AAA::A_xyzq\\(int\\);\r\nint BBB::B_xyzq\\(int\\);\r\nchar AAA::xyzq\\(char\\);\r\nchar BBB::xyzq\\(char\\);\r\nchar BBB::CCC::xyzq\\(char\\);\r\nchar BBB::Class::xyzq\\(char\\);\r\n$gdb_prompt $" {
|
114 |
|
|
pass "info func xyzq"
|
115 |
|
|
}
|
116 |
|
|
-re ".*$gdb_prompt $" { fail "info func xyzq" }
|
117 |
|
|
timeout { fail "(timeout) info func xyzq" }
|
118 |
|
|
}
|
119 |
|
|
|
120 |
|
|
# Call a function in a namespace
|
121 |
|
|
|
122 |
|
|
send_gdb "print 'AAA::xyzq'('x')\n"
|
123 |
|
|
gdb_expect {
|
124 |
|
|
-re "\\$\[0-9\]* = 97 'a'\r\n$gdb_prompt $" {
|
125 |
|
|
pass "print 'AAA::xyzq'('x')"
|
126 |
|
|
}
|
127 |
|
|
-re ".*$gdb_prompt $" { fail "print 'AAA::xyzq'('x')" }
|
128 |
|
|
timeout { fail "(timeout) print 'AAA::xyzq'('x')" }
|
129 |
|
|
}
|
130 |
|
|
|
131 |
|
|
# Break on a function in a namespace
|
132 |
|
|
|
133 |
|
|
send_gdb "break AAA::xyzq\n"
|
134 |
|
|
gdb_expect {
|
135 |
|
|
-re "Breakpoint.*at $hex: file.*namespace.cc, line 42\\.\r\n$gdb_prompt $" {
|
136 |
|
|
pass "break AAA::xyzq"
|
137 |
|
|
}
|
138 |
|
|
-re ".*$gdb_prompt $" { fail "break AAA::xyzq" }
|
139 |
|
|
timeout { fail "(timeout) break AAA::xyzq" }
|
140 |
|
|
}
|
141 |
|
|
|
142 |
|
|
# Call a function in a nested namespace
|
143 |
|
|
|
144 |
|
|
send_gdb "print 'BBB::CCC::xyzq'('x')\n"
|
145 |
|
|
gdb_expect {
|
146 |
|
|
-re "\\$\[0-9\]* = 122 'z'\r\n$gdb_prompt $" {
|
147 |
|
|
pass "print 'BBB::CCC::xyzq'('x')"
|
148 |
|
|
}
|
149 |
|
|
-re ".*$gdb_prompt $" { fail "print 'BBB::CCC::xyzq'('x')" }
|
150 |
|
|
timeout { fail "(timeout) print 'BBB::CCC::xyzq'('x')" }
|
151 |
|
|
}
|
152 |
|
|
|
153 |
|
|
# Break on a function in a nested namespace
|
154 |
|
|
|
155 |
|
|
send_gdb "break BBB::CCC::xyzq\n"
|
156 |
|
|
gdb_expect {
|
157 |
|
|
-re "Breakpoint.*at $hex: file.*namespace.cc, line 58\\.\r\n$gdb_prompt $" {
|
158 |
|
|
pass "break BBB::CCC::xyzq"
|
159 |
|
|
}
|
160 |
|
|
-re ".*$gdb_prompt $" { fail "break BBB::CCC::xyzq" }
|
161 |
|
|
timeout { fail "(timeout) break BBB::CCC::xyzq" }
|
162 |
|
|
}
|
163 |
|
|
|
164 |
|
|
# Print address of a function in a class in a namespace
|
165 |
|
|
|
166 |
|
|
send_gdb "print 'BBB::Class::xyzq'\n"
|
167 |
|
|
gdb_expect {
|
168 |
|
|
-re "\\$\[0-9\]* = \{char \\((BBB::|)Class \\*, (char|int)\\)\} $hex \r\n$gdb_prompt $" {
|
169 |
|
|
pass "print 'BBB::Class'::xyzq"
|
170 |
|
|
}
|
171 |
|
|
-re ".*$gdb_prompt $" { fail "print 'BBB::Class'::xyzq" }
|
172 |
|
|
timeout { fail "(timeout) print 'BBB::Class'::xyzq" }
|
173 |
|
|
}
|
174 |
|
|
|
175 |
|
|
# Break on a function in a class in a namespace
|
176 |
|
|
|
177 |
|
|
send_gdb "break BBB::Class::xyzq\n"
|
178 |
|
|
gdb_expect {
|
179 |
|
|
-re "Breakpoint.*at $hex: file.*namespace.cc, line 63\\.\r\n$gdb_prompt $" {
|
180 |
|
|
pass "break BBB::Class::xyzq"
|
181 |
|
|
}
|
182 |
|
|
-re ".*$gdb_prompt $" { fail "break BBB::Class::xyzq" }
|
183 |
|
|
timeout { fail "(timeout) break BBB::Class::xyzq" }
|
184 |
|
|
}
|
185 |
|
|
|