]> Git Repo - binutils.git/blame - gdb/testsuite/gdb.hp/namespace.exp
import gdb-1999-08-16 snapshot
[binutils.git] / gdb / testsuite / gdb.hp / namespace.exp
CommitLineData
c906108c
SS
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# [email protected]
19
20# tests for namespaces
21# Written by Satish Pai <[email protected]> 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
30if $tracelevel then {
31 strace $tracelevel
32 }
33
c906108c
SS
34set prms_id 0
35set bug_id 0
36
7a292a7a
SS
37if { [skip_hp_tests] } then { continue }
38
c906108c
SS
39set testfile "namespace"
40set srcfile ${testfile}.cc
41set binfile ${objdir}/${subdir}/${testfile}
42
43if [get_compiler_info ${binfile}] {
44 return -1;
45}
7a292a7a
SS
46
47if { $gcc_compiled } then { continue }
c906108c
SS
48
49
50if { [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
52utomatically fail."
53}
54
55
56
57gdb_exit
58gdb_start
59gdb_reinitialize_dir $srcdir/$subdir
60gdb_load ${binfile}
61
62
63#
64# set it up at a breakpoint so we can play with the variable values
65#
66if ![runto_main] then {
67 perror "couldn't run to breakpoint"
68 continue
69}
70
71send_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
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
117send_gdb "info func foo\n"
118gdb_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
128send_gdb "print 'AAA::foo'('x')\n"
129gdb_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
139send_gdb "break AAA::foo\n"
140gdb_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
150send_gdb "print 'BBB::CCC::foo'('x')\n"
151gdb_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
161send_gdb "break BBB::CCC::foo\n"
162gdb_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
172send_gdb "print 'BBB::Class'::foo\n"
173gdb_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
183send_gdb "break BBB::Class::foo\n"
184gdb_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
This page took 0.071515 seconds and 4 git commands to generate.