]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.hp/namespace.exp
import gdb-19990422 snapshot
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.hp / namespace.exp
1 # Copyright (C) 1997, 1998 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 <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
29
30 if $tracelevel then {
31 strace $tracelevel
32 }
33
34 set prms_id 0
35 set bug_id 0
36
37 if { [skip_hp_tests] } then { continue }
38
39 set testfile "namespace"
40 set srcfile ${testfile}.cc
41 set binfile ${objdir}/${subdir}/${testfile}
42
43 if [get_compiler_info ${binfile}] {
44 return -1;
45 }
46
47 if { $gcc_compiled } then { continue }
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 send_gdb "break marker1\n" ; gdb_expect -re ".*$gdb_prompt $"
72 send_gdb "cont\n"
73 gdb_expect {
74 -re "Break.* marker1 \\(\\) at .*:$decimal.*$gdb_prompt $" {
75 send_gdb "up\n"
76 gdb_expect {
77 -re ".*$gdb_prompt $" { pass "up from marker1" }
78 timeout { fail "up from marker1" }
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
88 send_gdb "print 'AAA::c'\n"
89 gdb_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
97 send_gdb "print ina\n"
98 gdb_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
106 send_gdb "ptype ina\n"
107 gdb_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
117 send_gdb "info func foo\n"
118 gdb_expect {
119 -re "All functions.*File.*namespace.cc:\r\nint AAA::A_foo\\(int\\);\r\nint BBB::B_foo\\(int\\);\r\nchar AAA::foo\\(char\\);\r\nchar BBB::foo\\(char\\);\r\nchar BBB::CCC::foo\\(char\\);\r\nchar BBB::Class::foo\\(char\\);\r\n$gdb_prompt $" {
120 pass "info func foo"
121 }
122 -re ".*$gdb_prompt $" { fail "info func foo" }
123 timeout { fail "(timeout) info func foo" }
124 }
125
126 # Call a function in a namespace
127
128 send_gdb "print 'AAA::foo'('x')\n"
129 gdb_expect {
130 -re "\\$\[0-9\]* = 97 'a'\r\n$gdb_prompt $" {
131 pass "print 'AAA::foo'('x')"
132 }
133 -re ".*$gdb_prompt $" { fail "print 'AAA::foo'('x')" }
134 timeout { fail "(timeout) print 'AAA::foo'('x')" }
135 }
136
137 # Break on a function in a namespace
138
139 send_gdb "break AAA::foo\n"
140 gdb_expect {
141 -re "Breakpoint.*at $hex: file.*namespace.cc, line 42\\.\r\n$gdb_prompt $" {
142 pass "break AAA::foo"
143 }
144 -re ".*$gdb_prompt $" { fail "break AAA::foo" }
145 timeout { fail "(timeout) break AAA::foo" }
146 }
147
148 # Call a function in a nested namespace
149
150 send_gdb "print 'BBB::CCC::foo'('x')\n"
151 gdb_expect {
152 -re "\\$\[0-9\]* = 122 'z'\r\n$gdb_prompt $" {
153 pass "print 'BBB::CCC::foo'('x')"
154 }
155 -re ".*$gdb_prompt $" { fail "print 'BBB::CCC::foo'('x')" }
156 timeout { fail "(timeout) print 'BBB::CCC::foo'('x')" }
157 }
158
159 # Break on a function in a nested namespace
160
161 send_gdb "break BBB::CCC::foo\n"
162 gdb_expect {
163 -re "Breakpoint.*at $hex: file.*namespace.cc, line 58\\.\r\n$gdb_prompt $" {
164 pass "break BBB::CCC::foo"
165 }
166 -re ".*$gdb_prompt $" { fail "break BBB::CCC::foo" }
167 timeout { fail "(timeout) break BBB::CCC::foo" }
168 }
169
170 # Print address of a function in a class in a namespace
171
172 send_gdb "print 'BBB::Class'::foo\n"
173 gdb_expect {
174 -re "\\$\[0-9\]* = \{char \\(BBB::Class \\*, char\\)\} $hex <BBB::Class::foo\\(char\\)>\r\n$gdb_prompt $" {
175 pass "print 'BBB::Class'::foo"
176 }
177 -re ".*$gdb_prompt $" { fail "print 'BBB::Class'::foo" }
178 timeout { fail "(timeout) print 'BBB::Class'::foo" }
179 }
180
181 # Break on a function in a class in a namespace
182
183 send_gdb "break BBB::Class::foo\n"
184 gdb_expect {
185 -re "Breakpoint.*at $hex: file.*namespace.cc, line 63\\.\r\n$gdb_prompt $" {
186 pass "break BBB::Class::foo"
187 }
188 -re ".*$gdb_prompt $" { fail "break BBB::Class::foo" }
189 timeout { fail "(timeout) break BBB::Class::foo" }
190 }
191