* Contribute CGEN simulator build support code.
[binutils-gdb.git] / gdb / testsuite / gdb.c++ / namespace.exp
blob9298c90e79ebc6c516c6ad3d482e1cbb0e600330
1 # Copyright (C) 1997, 1998 Free Software Foundation, Inc.
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.  
17 # Please email any bugs, comments, and/or additions to this file to:
18 # bug-gdb@prep.ai.mit.edu
20 # tests for namespaces
21 # Written by Satish Pai <pai@apollo.hp.com> 1997-07-23
23 # This file is part of the gdb testsuite
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
31 if $tracelevel then {
32         strace $tracelevel
33         }
35 set prms_id 0
36 set bug_id 0
39 set testfile "namespace"
40 set srcfile ${testfile}.cc
41 set binfile ${objdir}/${subdir}/${testfile}
43 if [get_compiler_info ${binfile}] {
44     return -1;
49 if  { [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
51 utomatically fail."
56 gdb_exit
57 gdb_start
58 gdb_reinitialize_dir $srcdir/$subdir
59 gdb_load ${binfile}
63 # set it up at a breakpoint so we can play with the variable values
65 if ![runto_main] then {
66     perror "couldn't run to breakpoint"
67     continue
70 send_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 {
76                 -re ".*$gdb_prompt $" { pass "up from marker1" }
77                 timeout { fail "up from marker1" }
78             }
79         }
80         -re "$gdb_prompt $" { fail "continue to marker1"  }
81         timeout { fail "(timeout) continue to marker1"  }
82     }
84 # Access a data item inside a namespace using colons and
85 # single quotes :-(
87 send_gdb "print 'AAA::c'\n"
88 gdb_expect {
89    -re "\\$\[0-9\]* = 0 '\\\\000'\r\n$gdb_prompt $" { pass "print 'AAA::c'" }
90    -re ".*$gdb_prompt $" { fail "print 'AAA::c'" }
91    timeout { fail "(timeout) print 'AAA::c'" }
94 # An object declared using "using".
96 send_gdb "print ina\n"
97 gdb_expect {
98    -re "\\$\[0-9\]+ = {xx = 33}.*$gdb_prompt $" {
99       pass "print ina"
100    }
101    -re ".*$gdb_prompt $" { fail "print ina" }
102    timeout { fail "(timeout) print ina" }
105 send_gdb "ptype ina\n"
106 gdb_expect {
107    -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 $" {
108        pass "ptype ina"
109    }
110    -re ".*$gdb_prompt $" { fail "ptype ina" }
111    timeout { fail "(timeout) ptype ina" }
114 # Check all functions are known to GDB
116 setup_xfail hppa*-*-*11* CLLbs14869
117 send_gdb "info func xyzq\n"
118 gdb_expect {
119    -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 $" {
120        pass "info func xyzq"
121    }    
122    -re ".*$gdb_prompt $" { fail "info func xyzq" }
123    timeout { fail "(timeout) info func xyzq" }
126 # Call a function in a namespace
128 send_gdb "print 'AAA::xyzq'('x')\n"
129 gdb_expect {
130    -re "\\$\[0-9\]* = 97 'a'\r\n$gdb_prompt $" {
131        pass "print 'AAA::xyzq'('x')"
132    }
133    -re ".*$gdb_prompt $" { fail "print 'AAA::xyzq'('x')" }
134    timeout { fail "(timeout) print 'AAA::xyzq'('x')" }
136        
137 # Break on a function in a namespace
139 send_gdb "break AAA::xyzq\n"
140 gdb_expect {
141     -re "Breakpoint.*at $hex: file.*namespace.cc, line 42\\.\r\n$gdb_prompt $" {
142          pass "break AAA::xyzq"
143     }    
144    -re ".*$gdb_prompt $" { fail "break AAA::xyzq" }
145    timeout { fail "(timeout) break AAA::xyzq" }
148 # Call a function in a nested namespace
150 send_gdb "print 'BBB::CCC::xyzq'('x')\n"
151 gdb_expect {
152    -re "\\$\[0-9\]* = 122 'z'\r\n$gdb_prompt $" {
153        pass "print 'BBB::CCC::xyzq'('x')"
154    }
155    -re ".*$gdb_prompt $" { fail "print 'BBB::CCC::xyzq'('x')" }
156    timeout { fail "(timeout) print 'BBB::CCC::xyzq'('x')" }
158        
159 # Break on a function in a nested namespace
161 send_gdb "break BBB::CCC::xyzq\n"
162 gdb_expect {
163     -re "Breakpoint.*at $hex: file.*namespace.cc, line 58\\.\r\n$gdb_prompt $" {
164          pass "break BBB::CCC::xyzq"
165     }    
166    -re ".*$gdb_prompt $" { fail "break BBB::CCC::xyzq" }
167    timeout { fail "(timeout) break BBB::CCC::xyzq" }
170 # Print address of a function in a class in a namespace
172 send_gdb "print 'BBB::Class::xyzq'\n"
173 gdb_expect {
174    -re "\\$\[0-9\]* = \{char \\((BBB::|)Class \\*, (char|int)\\)\} $hex <BBB::Class::xyzq\\(char\\)>\r\n$gdb_prompt $" {
175        pass "print 'BBB::Class'::xyzq"
176    }
177    -re ".*$gdb_prompt $" { fail "print 'BBB::Class'::xyzq" }
178    timeout { fail "(timeout) print 'BBB::Class'::xyzq" }
181 # Break on a function in a class in a namespace
183 send_gdb "break BBB::Class::xyzq\n"
184 gdb_expect {
185     -re "Breakpoint.*at $hex: file.*namespace.cc, line 63\\.\r\n$gdb_prompt $" {
186          pass "break BBB::Class::xyzq"
187     }    
188    -re ".*$gdb_prompt $" { fail "break BBB::Class::xyzq" }
189    timeout { fail "(timeout) break BBB::Class::xyzq" }