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