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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [gdb-5.0/] [gdb/] [testsuite/] [gdb.c++/] [cplusfuncs.exp] - Blame information for rev 107

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

Line No. Rev Author Line
1 106 markom
# Copyright (C) 1992, 1997, 1999 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
# This file was written by Fred Fish. (fnf@cygnus.com)
21
 
22
if $tracelevel then {
23
        strace $tracelevel
24
}
25
 
26
if { [skip_cplus_tests] } { continue }
27
 
28
set testfile "cplusfuncs"
29
set srcfile ${testfile}.cc
30
set binfile ${objdir}/${subdir}/${testfile}
31
 
32
if { [get_compiler_info $binfile "c++"] } {
33
    return -1
34
}
35
 
36
if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } {
37
     gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
38
}
39
 
40
#
41
#  Cause gdb to lookup a specific C++ function and print the demangled
42
#  form.
43
#
44
 
45
proc info_func { regex demangled } {
46
    global gdb_prompt
47
 
48
    send_gdb "info function $regex\n"
49
    gdb_expect {
50
        -re "File .*:\r\n$demangled\r\n.*$gdb_prompt $" {
51
            pass "info function for \"$regex\""
52
        }
53
        -re "File .*:\r\nclass $demangled\r\n.*$gdb_prompt $" {
54
            pass "info function for \"$regex\""
55
        }
56
        -re ".*$gdb_prompt $" {
57
            fail "info function for \"$regex\""
58
        }
59
        timeout {
60
            fail "info function for \"$regex\" (timeout)"
61
        }
62
    }
63
}
64
 
65
#
66
#  Run print &'$arg' on the input arg and verify that we can correctly
67
#  lookup the fully qualified C++ function.
68
#  We ignore the return type of the function since we are only interested
69
#  in the rootname and arguments part.
70
#
71
 
72
proc print_addr_of { arg } {
73
    global gdb_prompt
74
    global hex
75
 
76
    set pattern [string_to_regexp $arg]
77
    send_gdb "print &'$arg'\n"
78
    gdb_expect {
79
        -re ".* = .* $hex <$pattern>\r\n$gdb_prompt $" { pass "print &'$arg'" }
80
        -re ".*$gdb_prompt $" {
81
            fail "print &'$arg'"
82
        }
83
        timeout {
84
            fail "print &'$arg' (timeout)"
85
        }
86
    }
87
}
88
 
89
#
90
# Test name demangling for operators.
91
#
92
# The '(' at the end of each regex input pattern is so that we match only
93
# the one we are looking for.  I.E. "operator&" would match both
94
# "operator&(foo &)" and "operator&&(foo &)".
95
#
96
 
97
proc test_lookup_operator_functions {} {
98
 
99
    # These tests don't work for COFF targets; don't even try them
100
    if [istarget "a29k-*-udi"] then {
101
        setup_xfail "a29k-*-udi"
102
        fail "skipping operator tests"
103
        return
104
    }
105
 
106
    info_func "operator&&("  "void foo::operator&&\\(foo &\\);"
107
    info_func "operator&=("  "void foo::operator&=\\(foo &\\);"
108
    info_func "operator&("  "void foo::operator&\\(foo &\\);"
109
    info_func "operator/=("  "void foo::operator/=\\(foo &\\);"
110
    info_func "operator^=("  "void foo::operator.=\\(foo &\\);"
111
    info_func "operator<<=("  "void foo::operator<<=\\(foo &\\);"
112
    info_func "operator%=("  "void foo::operator%=\\(foo &\\);"
113
    info_func "operator-=("  "void foo::operator-=\\(foo &\\);"
114
 
115
    # There doesn't appear to be any way to get GDB to treat '*' as a
116
    # character to match, rather than as a regex special character.
117
    setup_xfail "*-*-*"
118
    info_func "operator\*=("  "void foo::operator\\*=\\(foo &\\);"
119
 
120
    info_func "operator|=("  "void foo::operator\\|=\\(foo &\\);"
121
    info_func "operator+=("  "void foo::operator.=\\(foo &\\);"
122
    info_func "operator>>=("  "void foo::operator\>\>=\\(foo &\\);"
123
    info_func "operator=("  "void foo::operator=\\(foo &\\);"
124
    info_func "operator()("  "void foo::operator\\(\\)\\(foo &\\);"
125
 
126
    # The function should be "operator," not "operator, ".  (note space)
127
    # This test will work; I've commented it out because it should not
128
    # count as a pass, since it is incorrect.  Ian Taylor.
129
    # info_func "operator, ("  "void foo::operator, \\(foo &\\);"
130
    setup_xfail "*-*-*"
131
    info_func "operator,("  "void foo::operator,\\(foo &\\);"
132
 
133
    info_func "operator~("  "void foo::operator~\\(void\\);"
134
    info_func "operator delete("  "void foo::operator delete\\(void \\*\\)(| static);"
135
    info_func "operator/("  "void foo::operator/\\(foo &\\);"
136
    info_func "operator==("  "void foo::operator==\\(foo &\\);"
137
    info_func "operator^("  "void foo::operator\\^\\(foo &\\);"
138
 
139
    info_func "operator>=("  "void foo::operator>=\\(foo &\\);"
140
    info_func "operator>("  "void foo::operator>\\(foo &\\);"
141
    info_func "operator<=("  "void foo::operator<=\\(foo &\\);"
142
    info_func "operator<<("  "void foo::operator<<\\(foo &\\);"
143
    info_func "operator<("  "void foo::operator<\\(foo &\\);"
144
    info_func "operator%("  "void foo::operator%\\(foo &\\);"
145
    info_func "operator-("  "void foo::operator-\\(foo &\\);"
146
 
147
    # There doesn't appear to be anyway to get '*' treated as a character
148
    # to match, rather than as a regex special character.
149
    setup_xfail "*-*-*"
150
    info_func "operator\*("  "void foo::operator\\*\\(foo &\\);"
151
 
152
    info_func "operator--("  "void foo::operator--\\(int\\);"
153
    info_func "operator!=("  "void foo::operator!=\\(foo &\\);"
154
    info_func "operator!("  "void foo::operator!\\(void\\);"
155
    info_func "operator new("  "void \\*foo::operator new\\(.*\\)(| static);"
156
    info_func "operator||("  "void foo::operator\\|\\|\\(foo &\\);"
157
    info_func "operator char \\*("  "char \\*foo::operator char \\*\\(void\\);"
158
    info_func "operator int("  "int foo::operator int\\(void\\);"
159
    info_func "operator|("  "void foo::operator\\|\\(foo &\\);"
160
    info_func "operator+("  "void foo::operator\\+\\(foo &\\);"
161
    info_func "operator++("  "void foo::operator\\+\\+\\(int\\);"
162
    info_func "operator->("  "foo \\*foo::operator->\\(void\\);"
163
    info_func "operator->\\*("  "void foo::operator->\\*\\(foo &\\);"
164
    info_func "operator>>("  "void foo::operator\>\>\\(foo &\\);"
165
 
166
    # GDB says "`operator \[\](' not supported".  I don't know why.
167
    setup_xfail "*-*-*"
168
    info_func "operator\\\[\\\](" "void foo::operator\\\[\\\]\\(foo &\\);"
169
    # But this works, for some reason.
170
    info_func ".perator\\\[\\\](" "void foo::operator\\\[\\\]\\(foo &\\);"
171
}
172
 
173
 
174
proc test_paddr_operator_functions {} {
175
    global hex
176
    global hp_aCC_compiler
177
 
178
    print_addr_of "foo::operator&&(foo &)"
179
    print_addr_of "foo::operator&=(foo &)"
180
    print_addr_of "foo::operator&(foo &)"
181
    print_addr_of "foo::operator/=(foo &)"
182
    print_addr_of "foo::operator^=(foo &)"
183
    print_addr_of "foo::operator<<=(foo &)"
184
    print_addr_of "foo::operator%=(foo &)"
185
    print_addr_of "foo::operator-=(foo &)"
186
    print_addr_of "foo::operator*=(foo &)"
187
    print_addr_of "foo::operator|=(foo &)"
188
    print_addr_of "foo::operator+=(foo &)"
189
    print_addr_of "foo::operator>>=(foo &)"
190
    print_addr_of "foo::operator=(foo &)"
191
    print_addr_of "foo::operator()(foo &)"
192
    print_addr_of "foo::operator, (foo &)"
193
    print_addr_of "foo::operator~(void)"
194
    if { !$hp_aCC_compiler } {
195
        print_addr_of "foo::operator delete(void *)"
196
    } else {
197
        gdb_test "print &'foo::operator delete(void *) static'" \
198
            " = .*(0x\[0-9a-f\]+|) "
199
    }
200
    print_addr_of "foo::operator/(foo &)"
201
    print_addr_of "foo::operator==(foo &)"
202
    print_addr_of "foo::operator^(foo &)"
203
    print_addr_of "foo::operator>=(foo &)"
204
    print_addr_of "foo::operator>(foo &)"
205
    print_addr_of "foo::operator<=(foo &)"
206
    print_addr_of "foo::operator<<(foo &)"
207
    print_addr_of "foo::operator<(foo &)"
208
    print_addr_of "foo::operator%(foo &)"
209
    print_addr_of "foo::operator-(foo &)"
210
    print_addr_of "foo::operator*(foo &)"
211
    print_addr_of "foo::operator--(int)"
212
    print_addr_of "foo::operator!=(foo &)"
213
    print_addr_of "foo::operator!(void)"
214
    gdb_test "print &'foo::operator new'" \
215
        " = .* $hex "
216
    print_addr_of "foo::operator||(foo &)"
217
    print_addr_of "foo::operator char *(void)"
218
    print_addr_of "foo::operator int(void)"
219
    print_addr_of "foo::operator|(foo &)"
220
    print_addr_of "foo::operator+(foo &)"
221
    print_addr_of "foo::operator++(int)"
222
    print_addr_of "foo::operator->(void)"
223
    print_addr_of "foo::operator->*(foo &)"
224
    print_addr_of "foo::operator>>(foo &)"
225
    gdb_test "print &'foo::operator\[\](foo &)'" \
226
        " = .*0x\[0-9a-f\]+ "
227
}
228
 
229
#
230
# Test overloaded functions (1 arg).
231
#
232
 
233
proc test_paddr_overloaded_functions {} {
234
    print_addr_of "overload1arg(signed char)"
235
    print_addr_of "overload1arg(unsigned char)"
236
    print_addr_of "overload1arg(unsigned int)"
237
    print_addr_of "overload1arg(unsigned long)"
238
    print_addr_of "overload1arg(unsigned short)"
239
    print_addr_of "overload1arg(char)"
240
    print_addr_of "overload1arg(double)"
241
    print_addr_of "overload1arg(float)"
242
    print_addr_of "overload1arg(int)"
243
    print_addr_of "overload1arg(long)"
244
    print_addr_of "overload1arg(short)"
245
    print_addr_of "overload1arg(void)"
246
    print_addr_of "overloadargs(int)"
247
    print_addr_of "overloadargs(int, int)"
248
    print_addr_of "overloadargs(int, int, int)"
249
    print_addr_of "overloadargs(int, int, int, int)"
250
    print_addr_of "overloadargs(int, int, int, int, int)"
251
    print_addr_of "overloadargs(int, int, int, int, int, int)"
252
    print_addr_of "overloadargs(int, int, int, int, int, int, int)"
253
    print_addr_of "overloadargs(int, int, int, int, int, int, int, int)"
254
    print_addr_of "overloadargs(int, int, int, int, int, int, int, int, int)"
255
    print_addr_of "overloadargs(int, int, int, int, int, int, int, int, int, int)"
256
    print_addr_of "overloadargs(int, int, int, int, int, int, int, int, int, int, int)"
257
}
258
 
259
proc test_paddr_hairy_functions {} {
260
    print_addr_of "hairyfunc1(int)"
261
    print_addr_of "hairyfunc2(int (*)(char *))"
262
    print_addr_of "hairyfunc3(int (*)(short (*)(long *)))"
263
    print_addr_of "hairyfunc4(int (*)(short (*)(char *)))"
264
    print_addr_of "hairyfunc5(int (*(*)(char *))(long))"
265
    print_addr_of "hairyfunc6(int (*(*)(int *))(long))"
266
    print_addr_of "hairyfunc7(int (*(*)(int (*)(char *)))(long))"
267
}
268
 
269
proc do_tests {} {
270
    global prms_id
271
    global bug_id
272
    global subdir
273
    global objdir
274
    global srcdir
275
    global binfile
276
    global gdb_prompt
277
 
278
    set prms_id 0
279
    set bug_id 0
280
 
281
    # Start with a fresh gdb.
282
 
283
    gdb_exit
284
    gdb_start
285
    gdb_reinitialize_dir $srcdir/$subdir
286
    gdb_load $binfile
287
 
288
    send_gdb "set language c++\n"
289
    gdb_expect -re "$gdb_prompt $"
290
    send_gdb "set width 0\n"
291
    gdb_expect -re "$gdb_prompt $"
292
 
293
    # Get the debug format for the compiled test case.  If that
294
    # format is DWARF 1 then just skip all the tests since none of
295
    # them will pass.
296
 
297
    if [ runto_main] then {
298
        get_debug_format
299
        if [ setup_xfail_format "DWARF 1" ] then {
300
            fail "C++ tests skipped due to limited C++ support in DWARF 1 debug format"
301
            return
302
        }
303
        clear_xfail "*-*-*"
304
    }
305
 
306
    test_paddr_overloaded_functions
307
    test_paddr_operator_functions
308
    test_paddr_hairy_functions
309
    test_lookup_operator_functions
310
}
311
 
312
do_tests

powered by: WebSVN 2.1.0

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