OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [tags/] [gnu-src/] [gdb-7.2/] [gdb-7.2-or32-1.0rc3/] [gdb/] [testsuite/] [gdb.cp/] [namespace.exp] - Blame information for rev 579

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 330 jeremybenn
# Copyright 1997, 1998, 2000, 2001, 2002, 2003, 2004, 2007, 2008, 2009, 2010
2
# Free Software Foundation, Inc.
3
 
4
# This program is free software; you can redistribute it and/or modify
5
# it under the terms of the GNU General Public License as published by
6
# the Free Software Foundation; either version 3 of the License, or
7
# (at your option) any later version.
8
#
9
# This program is distributed in the hope that it will be useful,
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
# GNU General Public License for more details.
13
#
14
# You should have received a copy of the GNU General Public License
15
# along with this program.  If not, see .
16
 
17
# tests for namespaces
18
# Originally written by Satish Pai  1997-07-23
19
 
20
# This file is part of the gdb testsuite
21
 
22
# Note: The original tests were geared to the HP aCC compiler,
23
# which has an idiosyncratic way of emitting debug info
24
# for namespaces.
25
# Note: As of 2000-06-03, they passed under g++ - djb
26
 
27
 
28
if $tracelevel then {
29
        strace $tracelevel
30
        }
31
 
32
 
33
if { [skip_cplus_tests] } { continue }
34
 
35
set testfile "namespace"
36
set srcfile ${testfile}.cc
37
set objfile ${objdir}/${subdir}/${testfile}.o
38
set srcfile1 ${testfile}1.cc
39
set objfile1 ${objdir}/${subdir}/${testfile}1.o
40
set binfile ${objdir}/${subdir}/${testfile}
41
 
42
if [get_compiler_info ${binfile} c++] {
43
    return -1;
44
}
45
 
46
if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${objfile}" object {debug c++}] != "" } {
47
     untested namespace.exp
48
     return -1
49
}
50
 
51
if  { [gdb_compile "${srcdir}/${subdir}/${srcfile1}" "${objfile1}" object {debug c++}] != "" } {
52
     untested namespace.exp
53
     return -1
54
}
55
 
56
if  { [gdb_compile "${objfile} ${objfile1}" "${binfile}" executable {debug c++}] != "" } {
57
     untested namespace.exp
58
     return -1
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
if ![runto 'marker1'] then {
76
    perror "couldn't run to marker1"
77
    continue
78
}
79
 
80
gdb_test "up" ".*main.*" "up from marker1"
81
 
82
# Access a data item inside a namespace using colons and
83
# single quotes. :-(
84
 
85
# NOTE: carlton/2003-09-24: the quotes are becoming less necessary (or
86
# even desirable.)  For tests where it should still work with quotes,
87
# I'm including versions both with and without quotes; for tests that
88
# shouldn't work with quotes, I'm only including one version.
89
 
90
gdb_test "print 'AAA::c'" \
91
    "\\$\[0-9\]* = 0 '\\\\(0|000)'" \
92
    "print 'AAA::c'"
93
 
94
gdb_test "print AAA::c" \
95
    "\\$\[0-9\]* = 0 '\\\\(0|000)'" \
96
    "print AAA::c"
97
 
98
# An object declared using "using".
99
 
100
gdb_test "print ina" "\\$\[0-9\]+ = {xx = 33}"
101
 
102
gdb_test_multiple "ptype ina" "ptype ina" {
103
    -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 $" {
104
        pass "ptype ina"
105
    }
106
    -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 $" {
107
        pass "ptype ina"
108
    }
109
}
110
 
111
# Check all functions are known to GDB
112
 
113
setup_xfail hppa*-*-*11* CLLbs14869
114
gdb_test_multiple "info func xyzq" "info func xyzq" {
115
    -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 $" {
116
        pass "info func xyzq"
117
    }
118
    -re "All functions.*File.*namespace.cc:\r\nint AAA::A_xyzq\\(int\\);\r\nchar AAA::xyzq\\(char\\);\r\nint BBB::B_xyzq\\(int\\);\r\nchar BBB::CCC::xyzq\\(char\\);\r\nchar BBB::Class::xyzq\\(char\\);\r\nchar BBB::xyzq\\(char\\);\r\n$gdb_prompt $" {
119
        pass "info func xyzq"
120
    }
121
}
122
 
123
# Call a function in a namespace
124
 
125
gdb_test "print 'AAA::xyzq'('x')" \
126
    "\\$\[0-9\]* = 97 'a'" \
127
    "print 'AAA::xyzq'('x')"
128
 
129
gdb_test "print AAA::xyzq('x')" \
130
    "\\$\[0-9\]* = 97 'a'" \
131
    "print AAA::xyzq('x')"
132
 
133
# Break on a function in a namespace
134
 
135
gdb_test "break AAA::xyzq" \
136
    "Breakpoint.*at $hex: file.*namespace.cc, line 47\\."
137
 
138
# Call a function in a nested namespace
139
 
140
gdb_test "print 'BBB::CCC::xyzq'('x')" \
141
    "\\$\[0-9\]* = 122 'z'" \
142
    "print 'BBB::CCC::xyzq'('x')"
143
 
144
gdb_test "print BBB::CCC::xyzq('x')" \
145
    "\\$\[0-9\]* = 122 'z'" \
146
    "print BBB::CCC::xyzq('x')"
147
 
148
# Break on a function in a nested namespace
149
 
150
gdb_test "break BBB::CCC::xyzq" \
151
    "Breakpoint.*at $hex: file.*namespace.cc, line 63\\."
152
 
153
# Print address of a function in a class in a namespace
154
 
155
gdb_test "print 'BBB::Class::xyzq'" \
156
    "\\$\[0-9\]* = \{char \\((BBB::|)Class \\*( const|), (char|int)\\)\} $hex " \
157
    "print 'BBB::Class::xyzq'"
158
 
159
gdb_test "print BBB::Class::xyzq" \
160
    "\\$\[0-9\]* = \{char \\((BBB::|)Class \\*( const|), (char|int)\\)\} $hex " \
161
    "print BBB::Class::xyzq"
162
 
163
# Break on a function in a class in a namespace
164
 
165
gdb_test "break BBB::Class::xyzq" \
166
    "Breakpoint.*at $hex: file.*namespace.cc, line 68\\."
167
 
168
# Tests accessing static elements in namespace of other file.
169
 
170
gdb_test "whatis C::cOtherFileType" "type = short"
171
gdb_test "whatis ::C::cOtherFileType" "type = short"
172
gdb_test "whatis C::cOtherFileVar" "type = const C::cOtherFileType"
173
gdb_test "whatis ::C::cOtherFileVar" "type = const C::cOtherFileType"
174
gdb_test "print C::cOtherFileVar" "\\$\[0-9\].* = 319"
175
gdb_test "print ::C::cOtherFileVar" "\\$\[0-9\].* = 319"
176
 
177
if {[test_compiler_info {gcc-[0-3]-*}]
178
    || [test_compiler_info {gcc-4-[0-4]-*}]} {
179
    # The type in class is missing in older GCCs.
180
    setup_xfail *-*-*
181
}
182
gdb_test "whatis C::OtherFileClass::cOtherFileClassType" "type = short"
183
if {[test_compiler_info {gcc-[0-3]-*}]
184
    || [test_compiler_info {gcc-4-[0-4]-*}]} {
185
    # The type in class is missing in older GCCs.
186
    setup_xfail *-*-*
187
}
188
gdb_test "whatis ::C::OtherFileClass::cOtherFileClassType" "type = short"
189
gdb_test "print C::OtherFileClass::cOtherFileClassVar" " = 318"
190
 
191
# FSF GCC <=4.4 creates unqualified DIE "cOtherFileClassVar" ignoring the
192
# namespace the same way older GDB did.
193
set test "print ::cOtherFileClassVar"
194
set test2 "print ::C::OtherFileClass::cOtherFileClassVar"
195
gdb_test_multiple $test $test {
196
    -re "No symbol \"cOtherFileClassVar\" in current context\\.\r\n$gdb_prompt $" {
197
        pass $test
198
 
199
        gdb_test $test2 " = 318"
200
    }
201
    -re "\\$\[0-9\].* = 318\r\n$gdb_prompt $" {
202
        if {[test_compiler_info {gcc-[0-3]-*}]
203
            || [test_compiler_info {gcc-4-[0-4]-*}]} {
204
            # Do not permit to XFAIL on recent GCCs.
205
            setup_xfail *-*-*
206
        }
207
        fail $test
208
 
209
        unresolved $test2
210
    }
211
}
212
 
213
# Test to see if the appropriate namespaces are in scope when trying
214
# to print out stuff from within a function defined within a
215
# namespace.
216
 
217
if ![runto "C::D::marker2"] then {
218
    perror "couldn't run to marker2"
219
    continue
220
}
221
 
222
gdb_test "print c" "\\$\[0-9\].* = 1"
223
gdb_test "print cc" "No symbol \"cc\" in current context."
224
gdb_test "print 'C::cc'" "\\$\[0-9\].* = 2"
225
gdb_test "print C::cc" "\\$\[0-9\].* = 2"
226
gdb_test "print cd" "\\$\[0-9\].* = 3"
227
gdb_test "print C::D::cd" "No type \"D\" within class or namespace \"C::C\"."
228
gdb_test "print 'E::cde'" "\\$\[0-9\].* = 5"
229
gdb_test "print E::cde" "\\$\[0-9\].* = 5"
230
gdb_test "print shadow" "\\$\[0-9\].* = 13"
231
gdb_test "print E::ce" "No symbol \"ce\" in namespace \"C::D::E\"."
232
gdb_test "ptype C" "type = namespace C::C"
233
gdb_test "ptype E" "type = namespace C::D::E"
234
 
235
gdb_test "ptype CClass" "type = (class C::CClass \{\r\n  public:|struct C::CClass \{)\r\n    int x;\r\n\}"
236
gdb_test "ptype CClass::NestedClass" "type = (class C::CClass::NestedClass \{\r\n  public:|struct C::CClass::NestedClass \{)\r\n    int y;\r\n\}"
237
gdb_test "ptype NestedClass" "No symbol \"NestedClass\" in current context."
238
gdb_test "ptype ::C::CClass" "type = class C::CClass \{\r\n  public:\r\n    int x;\r\n\}"
239
gdb_test "ptype ::C::CClass::NestedClass" "type = class C::CClass::NestedClass \{\r\n  public:\r\n    int y;\r\n\}"
240
gdb_test "ptype ::C::NestedClass" "No symbol \"NestedClass\" in namespace \"C\"."
241
gdb_test "ptype C::CClass" "No symbol \"CClass\" in namespace \"C::C\"."
242
gdb_test "ptype C::CClass::NestedClass" "No type \"CClass\" within class or namespace \"C::C\"."
243
gdb_test "ptype C::NestedClass" "No symbol \"NestedClass\" in namespace \"C::C\"."
244
 
245
# Tests involving multiple files
246
 
247
gdb_test "print cOtherFile" "\\$\[0-9\].* = 316"
248
gdb_test "ptype OtherFileClass" "type = (class C::OtherFileClass \{\r\n  public:|struct C::OtherFileClass \{)\r\n    int z;\r\n.*\}"
249
gdb_test "ptype ::C::OtherFileClass" "type = class C::OtherFileClass \{\r\n  public:\r\n    int z;\r\n.*\}"
250
gdb_test "ptype C::OtherFileClass" "No symbol \"OtherFileClass\" in namespace \"C::C\"."
251
 
252
# Test class typedefs printing.
253
set expect "type = class C::OtherFileClass \{\r\n.*\r\n *typedef short cOtherFileClassType;\r\n *typedef long cOtherFileClassType2;\r\n\}"
254
if {[test_compiler_info {gcc-[0-3]-*}]
255
    || [test_compiler_info {gcc-4-[0-4]-*}]} {
256
    # The type in class is missing in older GCCs.
257
    setup_xfail *-*-*
258
}
259
gdb_test "ptype OtherFileClass" $expect "ptype OtherFileClass typedefs"
260
if {[test_compiler_info {gcc-[0-3]-*}]
261
    || [test_compiler_info {gcc-4-[0-4]-*}]} {
262
    # The type in class is missing in older GCCs.
263
    setup_xfail *-*-*
264
}
265
gdb_test "ptype ::C::OtherFileClass" $expect "ptype ::C::OtherFileClass typedefs"
266
 
267
# Some anonymous namespace tests.
268
 
269
gdb_test "print cX" "\\$\[0-9\].* = 6"
270
gdb_test "print 'F::cXf'" "\\$\[0-9\].* = 7"
271
gdb_test "print F::cXf" "\\$\[0-9\].* = 7"
272
gdb_test "print F::cXfX" "\\$\[0-9\].* = 8"
273
gdb_test "print X" "\\$\[0-9\].* = 9"
274
gdb_test "print 'G::Xg'" "\\$\[0-9\].* = 10"
275
gdb_test "print G::Xg" "\\$\[0-9\].* = 10"
276
gdb_test "print G::XgX" "\\$\[0-9\].* = 11"
277
gdb_test "print cXOtherFile" "No symbol \"cXOtherFile\" in current context."
278
gdb_test "print XOtherFile" "No symbol \"XOtherFile\" in current context."
279
 
280
# Enum tests.
281
gdb_test "print AAA::ALPHA" "\\$\[0-9\].* = AAA::ALPHA"
282
 
283
# Regression tests for PR 9496.
284
gdb_test "whatis ::C::CClass::NestedClass" "type = C::CClass::NestedClass"
285
gdb_test "whatis ::C::CClass::NestedClass *" "type = C::CClass::NestedClass \\*"

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.