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

Subversion Repositories openrisc

[/] [openrisc/] [tags/] [gnu-src/] [gdb-7.2/] [gdb-7.2-or32-1.0rc1/] [gdb/] [testsuite/] [gdb.cp/] [overload.exp] - Blame information for rev 341

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 330 jeremybenn
# Copyright 1998, 1999, 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
# written by Elena Zannoni (ezannoni@cygnus.com)
18
# Rewritten by Michael Chastain 
19
 
20
# This file is part of the gdb testsuite
21
 
22
# Tests for overloaded member functions.
23
 
24
if $tracelevel then {
25
    strace $tracelevel
26
}
27
 
28
set ws "\[\r\n\t \]+"
29
set nl "\[\r\n\]+"
30
 
31
 
32
if { [skip_cplus_tests] } { continue }
33
 
34
set testfile "overload"
35
set srcfile ${testfile}.cc
36
set binfile ${objdir}/${subdir}/${testfile}
37
 
38
if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } {
39
     untested overload.exp
40
     return -1
41
}
42
 
43
gdb_exit
44
gdb_start
45
gdb_reinitialize_dir $srcdir/$subdir
46
gdb_load ${binfile}
47
 
48
# Set it up at a breakpoint so we can play with the variable values.
49
 
50
if ![runto 'marker1'] then {
51
    perror "couldn't run to marker1"
52
    continue
53
}
54
 
55
gdb_test "up" ".*main.*" "up from marker1"
56
 
57
# Print the monster class type.
58
# See virtfunc.exp for a discussion of ptype.
59
#
60
# This is hairy to begin with.  It is even more hairy because of the
61
# XX_* alternate patterns to catch the KFAIL and XFAIL cases.
62
 
63
set re_class    "((struct|class) foo \{${ws}public:|struct foo \{)"
64
set re_fields   "int ifoo;${ws}const char ?\\* ?ccpfoo;"
65
set XX_fields   "int ifoo;${ws}char ?\\* ?ccpfoo;"
66
set re_ctor     "foo\\(int\\);${ws}foo\\(int, (char const|const char) ?\\*\\);${ws}foo\\(foo ?&\\);"
67
set re_dtor     "~foo\\((void|)\\);"
68
set XX_dtor     "~foo\\(int\\);"
69
set re_methods                    "void foofunc\\(int\\);"
70
set re_methods  "${re_methods}${ws}void foofunc\\(int, signed char ?\\*\\);"
71
set re_methods  "${re_methods}${ws}int overload1arg\\((void|)\\);"
72
set re_methods  "${re_methods}${ws}int overload1arg\\(char\\);"
73
set re_methods  "${re_methods}${ws}int overload1arg\\(signed char\\);"
74
set re_methods  "${re_methods}${ws}int overload1arg\\(unsigned char\\);"
75
set re_methods  "${re_methods}${ws}int overload1arg\\(short( int)?\\);"
76
set re_methods  "${re_methods}${ws}int overload1arg\\((unsigned short|short unsigned)( int)?\\);"
77
set re_methods  "${re_methods}${ws}int overload1arg\\(int\\);"
78
set re_methods  "${re_methods}${ws}int overload1arg\\(unsigned int\\);"
79
set re_methods  "${re_methods}${ws}int overload1arg\\(long( int)?\\);"
80
set re_methods  "${re_methods}${ws}int overload1arg\\((unsigned long|long unsigned)( int)?\\);"
81
set re_methods  "${re_methods}${ws}int overload1arg\\(float\\);"
82
set re_methods  "${re_methods}${ws}int overload1arg\\(double\\);"
83
set re_methods  "${re_methods}${ws}int overloadfnarg\\((void|)\\);"
84
set re_methods  "${re_methods}${ws}int overloadfnarg\\(int\\);"
85
set re_methods  "${re_methods}${ws}int overloadfnarg\\(int, int ?\\(\\*\\) ?\\(int\\)\\);"
86
set re_methods  "${re_methods}${ws}int overloadargs\\(int\\);"
87
set re_methods  "${re_methods}${ws}int overloadargs\\(int, int\\);"
88
set re_methods  "${re_methods}${ws}int overloadargs\\(int, int, int\\);"
89
set re_methods  "${re_methods}${ws}int overloadargs\\(int, int, int, int\\);"
90
set re_methods  "${re_methods}${ws}int overloadargs\\(int, int, int, int, int\\);"
91
set re_methods  "${re_methods}${ws}int overloadargs\\(int, int, int, int, int, int\\);"
92
set re_methods  "${re_methods}${ws}int overloadargs\\(int, int, int, int, int, int, int\\);"
93
set re_methods  "${re_methods}${ws}int overloadargs\\(int, int, int, int, int, int, int, int\\);"
94
set re_methods  "${re_methods}${ws}int overloadargs\\(int, int, int, int, int, int, int, int, int\\);"
95
set re_methods  "${re_methods}${ws}int overloadargs\\(int, int, int, int, int, int, int, int, int, int\\);"
96
set re_methods  "${re_methods}${ws}int overloadargs\\(int, int, int, int, int, int, int, int, int, int, int\\);"
97
set re_synth    "foo & operator=\\(foo const ?&\\);"
98
 
99
gdb_test "print foo_instance1" "\\$\[0-9\]+ = \{ifoo = 111, ccpfoo = 0x0\}"
100
 
101
gdb_test_multiple "ptype foo_instance1" "ptype foo_instance1" {
102
    -re "type = $re_class${ws}$re_fields${ws}$re_ctor${ws}$re_dtor${ws}$re_methods$nl\}$nl$gdb_prompt $" {
103
        # gcc 2.95.3 -gdwarf-2
104
        # TODO: this is not a quirk!
105
        pass "ptype foo_instance1 (HP aCC -- known quirk with ~foo parameter list)"
106
    }
107
    -re "type = $re_class${ws}$XX_fields${ws}$re_synth${ws}$re_dtor${ws}$re_ctor${ws}$re_methods$nl\}$nl$gdb_prompt $" {
108
        # gcc 2.95.3 -gstabs+, no "const" on "const char *"
109
        # TODO: gdb.base/constvar.exp has XFAILed this kind of problem for a
110
        # long time, but an XFAIL really needs an external bug report.
111
        # -- chastain 2003-12-31
112
        # setup_xfail "*-*-*"
113
        # fail "ptype foo_instance1"
114
        # TODO: this should be a KFAIL.
115
        pass "ptype foo_instance1 (shorter match)"
116
    }
117
    -re "type = $re_class${ws}$re_fields${ws}$re_synth${ws}$re_dtor${ws}$re_ctor${ws}$re_methods$nl\}$nl$gdb_prompt $" {
118
        # gcc 2.95.3 -gstabs+ if "const char *" ever gets fixed
119
        pass "ptype foo_instance1"
120
    }
121
    -re "type = $re_class${ws}$re_fields${ws}$re_ctor${ws}$XX_dtor${ws}$re_methods$nl\}$nl$gdb_prompt $" {
122
        # gcc 3.3.2 -gdwarf-2, "~foo(int)"
123
        # TODO: kfail this
124
        # kfail "gdb/1113" "ptype foo_instance1"
125
        pass "ptype foo_instance1 (shorter match)"
126
    }
127
    -re "type = $re_class${ws}$re_fields${ws}$re_ctor${ws}$re_dtor${ws}$re_methods$nl\}$nl$gdb_prompt $" {
128
        # gcc 3.3.2 -gdwarf-2, if the dtor bug gets fixed
129
        # gcc HEAD -gdwarf-2 (abi-2)
130
        # TODO: just pass this
131
        pass "ptype foo_instance1 (shorter match)"
132
    }
133
    -re "type = $re_class${ws}$re_fields${ws}$re_synth${ws}$re_ctor${ws}$re_dtor${ws}$re_methods$nl\}$nl$gdb_prompt $" {
134
        # gcc 3.3.2 -gstabs+
135
        # TODO: enough with the "shorter match"
136
        pass "ptype foo_instance1 (shorter match)"
137
    }
138
    -re "type = $re_class${ws}$re_fields${ws}$re_ctor${ws}$re_dtor${ws}$re_methods${ws}$re_synth$nl\}$nl$gdb_prompt $" {
139
        # gcc HEAD -gstabs+ (abi-2)
140
        pass "ptype foo_instance1 (shorter match)"
141
    }
142
}
143
 
144
# Print variables and method calls.
145
# This is a walk in the park.
146
 
147
gdb_test "print foo_instance2" "\\$\[0-9\]+ = \{ifoo = 222, ccpfoo = $hex \"A\"\}"
148
gdb_test "print foo_instance3" "\\$\[0-9\]+ = \{ifoo = 222, ccpfoo = $hex \"A\"\}"
149
 
150
gdb_test "print foo_instance1.overloadargs(1)" "\\$\[0-9\]+ = 1" \
151
    "print call overloaded func 1 arg"
152
 
153
# If GDB fails to restore the selected frame properly after the
154
# inferior function call above (see GDB PR 1155 for an explanation of
155
# why this might happen), all the subsequent tests will fail.  We
156
# should detect and report that failure, but let the marker call
157
# finish so that the rest of the tests can run undisturbed.
158
 
159
gdb_test_multiple "frame" "re-selected 'main' frame after inferior call" {
160
    -re "#0  marker1.*$gdb_prompt $" {
161
        setup_kfail "gdb/1155" s390-*-linux-gnu
162
        fail "re-selected 'main' frame after inferior call"
163
        gdb_test "finish" ".*main.*at .*overload.cc:.*// marker1-returns-here.*" \
164
            "finish call to marker1"
165
    }
166
    -re "#1  ($hex in )?main.*$gdb_prompt $" {
167
        pass "re-selected 'main' frame after inferior call"
168
    }
169
}
170
 
171
gdb_test "print foo_instance1.overloadargs(1, 2)" \
172
    "\\$\[0-9\]+ = 2" \
173
    "print call overloaded func 2 args"
174
 
175
gdb_test "print foo_instance1.overloadargs(1, 2, 3)" \
176
    "\\$\[0-9\]+ = 3" \
177
    "print call overloaded func 3 args"
178
 
179
gdb_test "print foo_instance1.overloadargs(1, 2, 3, 4)" \
180
    "\\$\[0-9\]+ = 4" \
181
    "print call overloaded func 4 args"
182
 
183
gdb_test "print foo_instance1.overloadargs(1, 2, 3, 4, 5)" \
184
    "\\$\[0-9\]+ = 5" \
185
    "print call overloaded func 5 args"
186
 
187
gdb_test "print foo_instance1.overloadargs(1, 2, 3, 4, 5, 6)" \
188
    "\\$\[0-9\]+ = 6" \
189
    "print call overloaded func 6 args"
190
 
191
gdb_test "print foo_instance1.overloadargs(1, 2, 3, 4, 5, 6, 7)" \
192
    "\\$\[0-9\]+ = 7" \
193
    "print call overloaded func 7 args"
194
 
195
gdb_test "print foo_instance1.overloadargs(1, 2, 3, 4, 5, 6, 7, 8)" \
196
    "\\$\[0-9\]+ = 8" \
197
    "print call overloaded func 8 args"
198
 
199
gdb_test "print foo_instance1.overloadargs(1, 2, 3, 4, 5, 6, 7, 8, 9)" \
200
    "\\$\[0-9\]+ = 9" \
201
    "print call overloaded func 9 args"
202
 
203
gdb_test "print foo_instance1.overloadargs(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)" \
204
    "\\$\[0-9\]+ = 10" \
205
    "print call overloaded func 10 args"
206
 
207
gdb_test "print foo_instance1.overloadargs(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11)" \
208
    "\\$\[0-9\]+ = 11" \
209
    "print call overloaded func 11 args"
210
 
211
gdb_test "print foo_instance1.overload1arg()" \
212
    "\\$\[0-9\]+ = 1" \
213
    "print call overloaded func void arg"
214
 
215
gdb_test "print foo_instance1.overload1arg((char)arg2)" \
216
    "\\$\[0-9\]+ = 2" \
217
    "print call overloaded func char arg"
218
 
219
gdb_test "print foo_instance1.overload1arg((signed char)arg3)" \
220
    "\\$\[0-9\]+ = 3" \
221
    "print call overloaded func signed char arg"
222
 
223
gdb_test "print foo_instance1.overload1arg((unsigned char)arg4)" \
224
    "\\$\[0-9\]+ = 4" \
225
    "print call overloaded func unsigned char arg"
226
 
227
gdb_test "print foo_instance1.overload1arg((short)arg5)" \
228
    "\\$\[0-9\]+ = 5" \
229
    "print call overloaded func short arg"
230
 
231
gdb_test "print foo_instance1.overload1arg((unsigned short)arg6)" \
232
    "\\$\[0-9\]+ = 6" \
233
    "print call overloaded func unsigned short arg"
234
 
235
gdb_test "print foo_instance1.overload1arg((int)arg7)" \
236
    "\\$\[0-9\]+ = 7" \
237
    "print call overloaded func int arg"
238
 
239
gdb_test "print foo_instance1.overload1arg((unsigned int)arg8)" \
240
    "\\$\[0-9\]+ = 8" \
241
    "print call overloaded func unsigned int arg"
242
 
243
gdb_test "print foo_instance1.overload1arg((long)arg9)" \
244
    "\\$\[0-9\]+ = 9" \
245
    "print call overloaded func long arg"
246
 
247
gdb_test "print foo_instance1.overload1arg((unsigned long)arg10)" \
248
    "\\$\[0-9\]+ = 10" \
249
    "print call overloaded func unsigned long arg"
250
 
251
gdb_test "print foo_instance1.overload1arg((float)arg11)" \
252
    "\\$\[0-9\]+ = 11" \
253
    "print call overloaded func float arg"
254
 
255
gdb_test "print foo_instance1.overload1arg((double)arg12)" \
256
    "\\$\[0-9\]+ = 12" \
257
    "print call overloaded func double arg"
258
 
259
# ---
260
 
261
# List overloaded functions.
262
 
263
# The void case is tricky because some compilers say "(void)"
264
# and some compilers say "()".
265
 
266
gdb_test_no_output "set listsize 1" ""
267
gdb_test_multiple "info func overloadfnarg" "list overloaded function with no args" {
268
    -re ".*overloadfnarg\\(void\\).*$gdb_prompt $" {
269
        # gcc 2
270
        gdb_test "list foo::overloadfnarg(void)"\
271
                ".*int foo::overloadfnarg.*\\(void\\).*" \
272
                "list overloaded function with no args"
273
    }
274
    -re ".*overloadfnarg\\(\\).*$gdb_prompt $" {
275
        # gcc 3
276
        gdb_test "list foo::overloadfnarg()"\
277
                ".*int foo::overloadfnarg.*\\(void\\).*" \
278
                "list overloaded function with no args"
279
    }
280
}
281
 
282
gdb_test "list foo::overloadfnarg(int)" \
283
    "int foo::overloadfnarg.*\\(int arg\\).*" \
284
   "list overloaded function with int arg"
285
 
286
gdb_test "list foo::overloadfnarg(int, int (*)(int))" \
287
   "int foo::overloadfnarg.*\\(int arg, int \\(\\*foo\\) \\(int\\)\\).*" \
288
   "list overloaded function with function ptr args"
289
 
290
gdb_test "list \"foo::overloadfnarg(int, int (*)(int))\"" \
291
   "int foo::overloadfnarg.*\\(int arg, int \\(\\*foo\\) \\(int\\)\\).*" \
292
   "list overloaded function with function ptr args - quotes around argument"
293
 
294
# Test list with filename.
295
 
296
gdb_test "list ${srcfile}:intToChar" "int intToChar.*"
297
gdb_test "list ${srcfile}:intToChar(char)" "int intToChar.*"
298
gdb_test "list ${srcfile}:'intToChar(char)'" "int intToChar.*"
299
gdb_test "list '${srcfile}:intToChar(char)'" "int intToChar.*"
300
gdb_test "list '${srcfile}':intToChar(char)" "int intToChar.*"
301
gdb_test "list '${srcfile}':'intToChar(char)'" "int intToChar.*"
302
 
303
# And with filename and namespace... which does not work.
304
 
305
setup_kfail gdb/11289 *-*-*
306
gdb_test "list ${srcfile}:foo::overloadfnarg(int)" "int foo::overloadfnarg"
307
 
308
setup_kfail gdb/11289 *-*-*
309
gdb_test "list ${srcfile}:'foo::overloadfnarg(int)'" "int foo::overloadfnarg"
310
 
311
# Now some tests to see how overloading and namespaces interact.
312
 
313
gdb_test "print overloadNamespace(1)" ".\[0-9\]* = 1"
314
gdb_test "print overloadNamespace('a')" ".\[0-9\]* = 1"
315
gdb_test "print overloadNamespace(dummyInstance)" ".\[0-9\]* = 2"
316
 
317
# Static methods.
318
gdb_test "print K::staticoverload ()" " = 1"
319
gdb_test "print K::staticoverload (2)" " = 2"
320
gdb_test "print K::staticoverload (2, 3)" " = 5"
321
 
322
# Namespace-qualified functions.
323
gdb_test "print N::nsoverload ()" " = 1"
324
gdb_test "print N::nsoverload (2)" " = 2"
325
gdb_test "print N::nsoverload (2, 3)" " = 5"
326
 
327
if ![runto 'XXX::marker2'] then {
328
    perror "couldn't run to XXX::marker2"
329
    continue
330
}
331
 
332
gdb_test "print overloadNamespace(1)" ".\[0-9\]* = 3" "print overloadNamespace(1) in XXX"
333
gdb_test "print overloadNamespace('a')" ".\[0-9\]* = 3" "print overloadNamespace('a') in XXX"
334
gdb_test "print overloadNamespace(dummyInstance)" ".\[0-9\]* = 2" "print overloadNamespace(dummyInstance) in XXX"
335
 
336
# One last mysterious test.
337
# I wonder what this is for?
338
 
339
gdb_test "print intToChar(1)" "\\$\[0-9\]+ = 297"
340
 
341
# Test expression evaluation with overloaded methods
342
gdb_test "print foo::overload1arg" \
343
    "non-unique member `overload1arg' requires type instantiation" \
344
    "print foo::overload1arg"
345
 
346
gdb_test "print foo::overload1arg(char***)" \
347
    "no member function matches that type instantiation" \
348
    "print foo::overload1arg(char***)"
349
 
350
gdb_test "print foo::overload1arg(void)" \
351
    "\\$$decimal = {int \\(foo \\*( const|)\\)} $hex " \
352
    "print foo::overload1arg(void)"
353
 
354
foreach t [list char "signed char" "unsigned char" "short" \
355
               "unsigned short" int "unsigned int" long "unsigned long" \
356
               float double] {
357
    gdb_test "print foo::overload1arg($t)" \
358
        "\\$$decimal = {int \\(foo \\*( const|), $t\\)} $hex " \
359
        "print foo::overload1arg($t)"
360
}

powered by: WebSVN 2.1.0

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