Update/correct copyright notices.
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.c++ / namespace.exp
CommitLineData
b6ba6518 1# Copyright 1997, 1998, 2000 Free Software Foundation, Inc.
e6d71bf3
DB
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 <pai@apollo.hp.com> 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
31if $tracelevel then {
32 strace $tracelevel
33 }
34
35set prms_id 0
36set bug_id 0
37
38
39set testfile "namespace"
40set srcfile ${testfile}.cc
41set binfile ${objdir}/${subdir}/${testfile}
42
43if [get_compiler_info ${binfile}] {
44 return -1;
45}
46
47
48
49if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } {
50 gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will a
51utomatically fail."
52}
53
54
55
56gdb_exit
57gdb_start
58gdb_reinitialize_dir $srcdir/$subdir
59gdb_load ${binfile}
60
61
62#
63# set it up at a breakpoint so we can play with the variable values
64#
65if ![runto_main] then {
66 perror "couldn't run to breakpoint"
67 continue
68}
69
70send_gdb "break marker1\n" ; gdb_expect -re ".*$gdb_prompt $"
71 send_gdb "cont\n"
72 gdb_expect {
73 -re "Break.* marker1 \\(\\) at .*:$decimal.*$gdb_prompt $" {
74 send_gdb "up\n"
75 gdb_expect {
660fd469 76 -re ".*main.*$gdb_prompt $" { pass "up from marker1" }
3c077de9 77 -re ".*$gdb_prompt $" { fail "up from marker1" }
660fd469 78 timeout { fail "up from marker1 (timeout)" }
e6d71bf3
DB
79 }
80 }
81 -re "$gdb_prompt $" { fail "continue to marker1" }
82 timeout { fail "(timeout) continue to marker1" }
83 }
84
85# Access a data item inside a namespace using colons and
86# single quotes :-(
87
88send_gdb "print 'AAA::c'\n"
89gdb_expect {
90 -re "\\$\[0-9\]* = 0 '\\\\000'\r\n$gdb_prompt $" { pass "print 'AAA::c'" }
91 -re ".*$gdb_prompt $" { fail "print 'AAA::c'" }
92 timeout { fail "(timeout) print 'AAA::c'" }
93}
94
95# An object declared using "using".
96
97send_gdb "print ina\n"
98gdb_expect {
99 -re "\\$\[0-9\]+ = {xx = 33}.*$gdb_prompt $" {
100 pass "print ina"
101 }
102 -re ".*$gdb_prompt $" { fail "print ina" }
103 timeout { fail "(timeout) print ina" }
104}
105
106send_gdb "ptype ina\n"
107gdb_expect {
108 -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 $" {
109 pass "ptype ina"
110 }
111 -re ".*$gdb_prompt $" { fail "ptype ina" }
112 timeout { fail "(timeout) ptype ina" }
113}
114
115# Check all functions are known to GDB
116
117setup_xfail hppa*-*-*11* CLLbs14869
118send_gdb "info func xyzq\n"
119gdb_expect {
120 -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 $" {
121 pass "info func xyzq"
122 }
123 -re ".*$gdb_prompt $" { fail "info func xyzq" }
124 timeout { fail "(timeout) info func xyzq" }
125}
126
127# Call a function in a namespace
128
129send_gdb "print 'AAA::xyzq'('x')\n"
130gdb_expect {
131 -re "\\$\[0-9\]* = 97 'a'\r\n$gdb_prompt $" {
132 pass "print 'AAA::xyzq'('x')"
133 }
134 -re ".*$gdb_prompt $" { fail "print 'AAA::xyzq'('x')" }
135 timeout { fail "(timeout) print 'AAA::xyzq'('x')" }
136}
137
138# Break on a function in a namespace
139
140send_gdb "break AAA::xyzq\n"
141gdb_expect {
142 -re "Breakpoint.*at $hex: file.*namespace.cc, line 42\\.\r\n$gdb_prompt $" {
143 pass "break AAA::xyzq"
144 }
145 -re ".*$gdb_prompt $" { fail "break AAA::xyzq" }
146 timeout { fail "(timeout) break AAA::xyzq" }
147}
148
149# Call a function in a nested namespace
150
151send_gdb "print 'BBB::CCC::xyzq'('x')\n"
152gdb_expect {
153 -re "\\$\[0-9\]* = 122 'z'\r\n$gdb_prompt $" {
154 pass "print 'BBB::CCC::xyzq'('x')"
155 }
156 -re ".*$gdb_prompt $" { fail "print 'BBB::CCC::xyzq'('x')" }
157 timeout { fail "(timeout) print 'BBB::CCC::xyzq'('x')" }
158}
159
160# Break on a function in a nested namespace
161
162send_gdb "break BBB::CCC::xyzq\n"
163gdb_expect {
164 -re "Breakpoint.*at $hex: file.*namespace.cc, line 58\\.\r\n$gdb_prompt $" {
165 pass "break BBB::CCC::xyzq"
166 }
167 -re ".*$gdb_prompt $" { fail "break BBB::CCC::xyzq" }
168 timeout { fail "(timeout) break BBB::CCC::xyzq" }
169}
170
171# Print address of a function in a class in a namespace
172
173send_gdb "print 'BBB::Class::xyzq'\n"
174gdb_expect {
175 -re "\\$\[0-9\]* = \{char \\((BBB::|)Class \\*, (char|int)\\)\} $hex <BBB::Class::xyzq\\(char\\)>\r\n$gdb_prompt $" {
176 pass "print 'BBB::Class'::xyzq"
177 }
178 -re ".*$gdb_prompt $" { fail "print 'BBB::Class'::xyzq" }
179 timeout { fail "(timeout) print 'BBB::Class'::xyzq" }
180}
181
182# Break on a function in a class in a namespace
183
184send_gdb "break BBB::Class::xyzq\n"
185gdb_expect {
186 -re "Breakpoint.*at $hex: file.*namespace.cc, line 63\\.\r\n$gdb_prompt $" {
187 pass "break BBB::Class::xyzq"
188 }
189 -re ".*$gdb_prompt $" { fail "break BBB::Class::xyzq" }
190 timeout { fail "(timeout) break BBB::Class::xyzq" }
191}
192
This page took 0.067327 seconds and 4 git commands to generate.