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

Subversion Repositories or1k

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

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

Line No. Rev Author Line
1 106 markom
# Copyright (C) 1998, 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
# written by Elena Zannoni (ezannoni@cygnus.com)
21
 
22
# This file is part of the gdb testsuite
23
#
24
# tests for overloaded member functions. Command Line calls
25
#
26
 
27
 
28
if $tracelevel then {
29
        strace $tracelevel
30
        }
31
 
32
#
33
# test running programs
34
#
35
set prms_id 0
36
set bug_id 0
37
 
38
if { [skip_cplus_tests] } { continue }
39
 
40
set testfile "overload"
41
set srcfile ${testfile}.cc
42
set binfile ${objdir}/${subdir}/${testfile}
43
 
44
if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } {
45
     gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
46
}
47
 
48
if [get_compiler_info ${binfile} "c++"] {
49
    return -1
50
}
51
 
52
gdb_exit
53
gdb_start
54
gdb_reinitialize_dir $srcdir/$subdir
55
gdb_load ${binfile}
56
 
57
# set it up at a breakpoint so we can play with the variable values
58
#
59
if ![runto_main] then {
60
    perror "couldn't run to breakpoint"
61
    continue
62
}
63
 
64
send_gdb "break marker1\n" ; gdb_expect -re ".*$gdb_prompt $"
65
 
66
    send_gdb "cont\n"
67
    gdb_expect {
68
        -re "Break.* marker1 \\(\\) at .*:$decimal.*$gdb_prompt $" {
69
            send_gdb "up\n"
70
            gdb_expect {
71
                -re ".*$gdb_prompt $" {}
72
                timeout { fail "up from marker1" }
73
            }
74
        }
75
        -re "$gdb_prompt $" { fail "continue to marker1"  }
76
        timeout { fail "(timeout) continue to marker1"  }
77
    }
78
 
79
 
80
send_gdb "print foo_instance1\n"
81
gdb_expect {
82
    -re ".\[0-9\]* = \{ifoo = 111, ccpfoo = 0x0\}\r\n$gdb_prompt $" {
83
        pass "print foo_instance1"
84
      }
85
    -re ".*$gdb_prompt $" { fail "print foo_instance1" }
86
    timeout           { fail "(timeout) print foo_instance1" }
87
  }
88
 
89
 
90
setup_xfail "hppa*-*-*" CLLbs16901
91
send_gdb "ptype foo_instance1\n"
92
gdb_expect {
93
  -re "type = class foo \{.*public:.*int ifoo;.*const char \\*ccpfoo;.*foo\\(int\\);.*foo\\(int, (const char|char const) \\*\\);.*foo\\(foo &\\);.*~foo\\(void\\);.*void foofunc\\(int\\);.*void foofunc\\(int, signed char \\*\\);.*int overload1arg\\(void\\);.*int overload1arg\\(char\\);.*int overload1arg\\(signed char\\);.*int overload1arg\\(unsigned char\\);.*int overload1arg\\(short\\);.*int overload1arg\\(unsigned short\\);.*int overload1arg\\(int\\);.*int overload1arg\\(unsigned int\\);.*int overload1arg\\(long\\);.*int overload1arg\\(unsigned long\\);.*int overload1arg\\(float\\);.*int overload1arg\\(double\\);.*int overloadargs\\(int\\);.*int overloadargs\\(int, int\\);.*int overloadargs\\(int, int, int\\);.*int overloadargs\\(int, int, int, int\\);.*int overloadargs\\(int, int, int, int, int\\);.*int overloadargs\\(int, int, int, int, int, int\\);.*int overloadargs\\(int, int, int, int, int, int, int\\);.*int overloadargs\\(int, int, int, int, int, int, int, int\\);.*int overloadargs\\(int, int, int, int, int, int, int, int, int\\);.*int overloadargs\\(int, int, int, int, int, int, int, int, int, int\\);.*int overloadargs\\(int, int, int, int, int, int, int, int, int, int, int\\);\r\n\}\r\n$gdb_prompt $" {
94
        pass "ptype foo_instance1 (HP aCC -- known quirk with ~foo parameter list)"
95
      }
96
    -re "type = class foo .*int overloadargs\\(int, int, int, int, int, int, int, int, int, int, int\\);\r\n\}\r\n$gdb_prompt $" {
97
        pass "ptype foo_instance1 (shorter match)"
98
    }
99
    -re ".*$gdb_prompt $" { fail "ptype foo_instance1" }
100
    timeout           { fail "(timeout) ptype foo_instance1" }
101
  }
102
 
103
send_gdb "print foo_instance2\n"
104
gdb_expect {
105
    -re ".\[0-9\]* = \{ifoo = 222, ccpfoo = $hex \"A\"\}\r\n$gdb_prompt $" {
106
        pass "print foo_instance2"
107
      }
108
    -re ".*$gdb_prompt $" { fail "print foo_instance2" }
109
    timeout           { fail "(timeout) print foo_instance2" }
110
  }
111
 
112
send_gdb "print foo_instance3\n"
113
gdb_expect {
114
    -re ".\[0-9\]* = \{ifoo = 222, ccpfoo = $hex \"A\"\}\r\n$gdb_prompt $" {
115
        pass "print foo_instance3"
116
      }
117
    -re ".*$gdb_prompt $" { fail "print foo_instance3" }
118
    timeout           { fail "(timeout) print foo_instance3" }
119
  }
120
 
121
 
122
# The overload resolver added by HP (valops.c:find_overload_match) doesn't
123
# work right for G++ output, since the list of parameters seems not to
124
# be filled in correctly.  Until this gets fixed, don't expect to pass
125
# these tests.
126
 
127
setup_xfail "*-*-*" CLLbs16901
128
send_gdb "print foo_instance1.overloadargs(1)\n"
129
gdb_expect {
130
    -re ".\[0-9\]* = 1\r\n$gdb_prompt $" {
131
        pass "print call overloaded func 1 arg"
132
      }
133
    -re ".*$gdb_prompt $" { fail "print call overloaded func 1 arg" }
134
    timeout           { fail "(timeout) print call overloaded func 1 arg" }
135
  }
136
 
137
 
138
setup_xfail "*-*-*" CLLbs16901
139
 
140
send_gdb "print foo_instance1.overloadargs(1, 2)\n"
141
gdb_expect {
142
    -re ".\[0-9\]* = 2\r\n$gdb_prompt $" {
143
        pass "print call overloaded func 2 args"
144
      }
145
    -re ".*$gdb_prompt $" { fail "print call overloaded func 2 args" }
146
    timeout           { fail "(timeout) print call overloaded func 2  args" }
147
  }
148
 
149
 
150
setup_xfail "*-*-*" CLLbs16901
151
 
152
send_gdb "print foo_instance1.overloadargs(1, 2, 3)\n"
153
gdb_expect {
154
    -re ".\[0-9\]* = 3\r\n$gdb_prompt $" {
155
        pass "print call overloaded func 3 args"
156
      }
157
    -re ".*$gdb_prompt $" { fail "print call overloaded func 3 args" }
158
    timeout           { fail "(timeout) print call overloaded func 3 args" }
159
  }
160
 
161
 
162
setup_xfail "*-*-*" CLLbs16901
163
 
164
send_gdb "print foo_instance1.overloadargs(1, 2, 3, 4)\n"
165
gdb_expect {
166
    -re ".\[0-9\]* = 4\r\n$gdb_prompt $" {
167
        pass "print call overloaded func 4 args"
168
      }
169
    -re ".*$gdb_prompt $" { fail "print call overloaded func 4 args" }
170
    timeout           { fail "(timeout) print call overloaded func 4 args" }
171
  }
172
 
173
 
174
setup_xfail "*-*-*" CLLbs16901
175
 
176
send_gdb "print foo_instance1.overloadargs(1, 2, 3, 4, 5)\n"
177
gdb_expect {
178
    -re ".\[0-9\]* = 5\r\n$gdb_prompt $" {
179
        pass "print call overloaded func 5 args"
180
      }
181
    -re ".*$gdb_prompt $" { fail "print call overloaded func 5 args" }
182
    timeout           { fail "(timeout) print call overloaded func 5 args" }
183
  }
184
 
185
 
186
setup_xfail "*-*-*" CLLbs16901
187
 
188
send_gdb "print foo_instance1.overloadargs(1, 2, 3, 4, 5, 6)\n"
189
gdb_expect {
190
    -re ".\[0-9\]* = 6\r\n$gdb_prompt $" {
191
        pass "print call overloaded func 6 args"
192
      }
193
    -re ".*$gdb_prompt $" { fail "print call overloaded func 6 args" }
194
    timeout           { fail "(timeout) print call overloaded func 6 args" }
195
  }
196
 
197
 
198
setup_xfail "*-*-*" CLLbs16901
199
 
200
send_gdb "print foo_instance1.overloadargs(1, 2, 3, 4, 5, 6, 7)\n"
201
gdb_expect {
202
    -re ".\[0-9\]* = 7\r\n$gdb_prompt $" {
203
        pass "print call overloaded func 7 args"
204
      }
205
    -re ".*$gdb_prompt $" { fail "print call overloaded func 7 args" }
206
    timeout           { fail "(timeout) print call overloaded func 7 args" }
207
  }
208
 
209
 
210
setup_xfail "*-*-*" CLLbs16901
211
 
212
send_gdb "print foo_instance1.overloadargs(1, 2, 3, 4, 5, 6, 7, 8)\n"
213
gdb_expect {
214
    -re ".\[0-9\]* = 8\r\n$gdb_prompt $" {
215
        pass "print call overloaded func 8 args"
216
      }
217
    -re ".*$gdb_prompt $" { fail "print call overloaded func 8 args" }
218
    timeout           { fail "(timeout) print call overloaded func 8 args" }
219
  }
220
 
221
 
222
setup_xfail "*-*-*" CLLbs16901
223
 
224
send_gdb "print foo_instance1.overloadargs(1, 2, 3, 4, 5, 6, 7, 8, 9)\n"
225
gdb_expect {
226
    -re ".\[0-9\]* = 9\r\n$gdb_prompt $" {
227
        pass "print call overloaded func 9 args"
228
      }
229
    -re ".*$gdb_prompt $" { fail "print call overloaded func 9 args" }
230
    timeout           { fail "(timeout) print call overloaded func 9 args" }
231
  }
232
 
233
 
234
setup_xfail "*-*-*" CLLbs16901
235
 
236
send_gdb "print foo_instance1.overloadargs(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)\n"
237
gdb_expect {
238
    -re ".\[0-9\]* = 10\r\n$gdb_prompt $" {
239
        pass "print call overloaded func 10 args"
240
      }
241
    -re ".*$gdb_prompt $" { fail "print call overloaded func 10 args" }
242
    timeout           { fail "(timeout) print call overloaded func 10 args" }
243
  }
244
 
245
 
246
setup_xfail "*-*-*" CLLbs16901
247
 
248
send_gdb "print foo_instance1.overloadargs(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11)\n"
249
gdb_expect {
250
    -re ".\[0-9\]* = 11\r\n$gdb_prompt $" {
251
        pass "print call overloaded func 11 args"
252
      }
253
    -re ".*$gdb_prompt $" { fail "print call overloaded func 11 args" }
254
    timeout           { fail "(timeout) print call overloaded func 11 args" }
255
  }
256
 
257
 
258
setup_xfail "*-*-*" CLLbs16901
259
 
260
send_gdb "print foo_instance1.overload1arg()\n"
261
gdb_expect {
262
    -re ".\[0-9\]* = 1\r\n$gdb_prompt $" {
263
        pass "print call overloaded func void arg"
264
      }
265
    -re ".*$gdb_prompt $" { fail "print call overloaded func void arg" }
266
    timeout           { fail "(timeout) print call overloaded func void arg" }
267
  }
268
 
269
 
270
setup_xfail "*-*-*" CLLbs16901
271
 
272
send_gdb "print foo_instance1.overload1arg((char)arg2)\n"
273
gdb_expect {
274
    -re ".\[0-9\]* = 2\r\n$gdb_prompt $" {
275
        pass "print call overloaded func char arg"
276
      }
277
    -re ".*$gdb_prompt $" { fail "print call overloaded func char arg" }
278
    timeout           { fail "(timeout) print call overloaded func char arg" }
279
  }
280
 
281
 
282
setup_xfail "*-*-*" CLLbs16901
283
 
284
send_gdb "print foo_instance1.overload1arg((signed char)arg3)\n"
285
gdb_expect {
286
    -re ".\[0-9\]* = 3\r\n$gdb_prompt $" {
287
        pass "print call overloaded func signed char arg"
288
      }
289
    -re ".*$gdb_prompt $" { fail "print call overloaded func signed char arg" }
290
    timeout           { fail "(timeout) print call overloaded func signed char arg" }
291
  }
292
 
293
 
294
setup_xfail "*-*-*" CLLbs16901
295
 
296
send_gdb "print foo_instance1.overload1arg((unsigned char)arg4)\n"
297
gdb_expect {
298
    -re ".\[0-9\]* = 4\r\n$gdb_prompt $" {
299
        pass "print call overloaded func unsigned char arg"
300
      }
301
    -re ".*$gdb_prompt $" { fail "print call overloaded func unsigned char arg" }
302
    timeout           { fail "(timeout) print call overloaded func unsigned char arg" }
303
  }
304
 
305
 
306
setup_xfail "*-*-*" CLLbs16901
307
 
308
send_gdb "print foo_instance1.overload1arg((short)arg5)\n"
309
gdb_expect {
310
    -re ".\[0-9\]* = 5\r\n$gdb_prompt $" {
311
        pass "print call overloaded func short arg"
312
      }
313
    -re ".*$gdb_prompt $" { fail "print call overloaded func short arg" }
314
    timeout           { fail "(timeout) print call overloaded func short arg" }
315
  }
316
 
317
 
318
setup_xfail "*-*-*" CLLbs16901
319
 
320
send_gdb "print foo_instance1.overload1arg((unsigned short)arg6)\n"
321
gdb_expect {
322
    -re ".\[0-9\]* = 6\r\n$gdb_prompt $" {
323
        pass "print call overloaded func unsigned short arg"
324
      }
325
    -re ".*$gdb_prompt $" { fail "print call overloaded func unsigned short  arg" }
326
    timeout           { fail "(timeout) print call overloaded func unsigned short arg" }
327
  }
328
 
329
 
330
setup_xfail "*-*-*" CLLbs16901
331
 
332
send_gdb "print foo_instance1.overload1arg((int)arg7)\n"
333
gdb_expect {
334
    -re ".\[0-9\]* = 7\r\n$gdb_prompt $" {
335
        pass "print call overloaded func int arg"
336
      }
337
    -re ".*$gdb_prompt $" { fail "print call overloaded func int arg" }
338
    timeout           { fail "(timeout) print call overloaded func int arg" }
339
  }
340
 
341
 
342
setup_xfail "*-*-*" CLLbs16901
343
 
344
send_gdb "print foo_instance1.overload1arg((unsigned int)arg8)\n"
345
gdb_expect {
346
    -re ".\[0-9\]* = 8\r\n$gdb_prompt $" {
347
        pass "print call overloaded func unsigned int arg"
348
      }
349
    -re ".*$gdb_prompt $" { fail "print call overloaded func unsigned int arg" }
350
    timeout           { fail "(timeout) print call overloaded func unsigned int arg" }
351
  }
352
 
353
 
354
setup_xfail "*-*-*" CLLbs16901
355
 
356
send_gdb "print foo_instance1.overload1arg((long)arg9)\n"
357
gdb_expect {
358
    -re ".\[0-9\]* = 9\r\n$gdb_prompt $" {
359
        pass "print call overloaded func long arg"
360
      }
361
    -re ".*$gdb_prompt $" { fail "print call overloaded func long arg" }
362
    timeout           { fail "(timeout) print call overloaded func long arg" }
363
  }
364
 
365
 
366
setup_xfail "*-*-*" CLLbs16901
367
 
368
send_gdb "print foo_instance1.overload1arg((unsigned long)arg10)\n"
369
gdb_expect {
370
    -re ".\[0-9\]* = 10\r\n$gdb_prompt $" {
371
        pass "print call overloaded func unsigned long arg"
372
      }
373
    -re ".*$gdb_prompt $" { fail "print call overloaded func unsigned long arg" }
374
    timeout           { fail "(timeout) print call overloaded func unsigned long arg" }
375
  }
376
 
377
 
378
setup_xfail "*-*-*" CLLbs16901
379
 
380
send_gdb "print foo_instance1.overload1arg((float)arg11)\n"
381
gdb_expect {
382
    -re ".\[0-9\]* = 11\r\n$gdb_prompt $" {
383
        pass "print call overloaded func float arg"
384
      }
385
    -re ".*$gdb_prompt $" { fail "print call overloaded func float arg" }
386
    timeout           { fail "(timeout) print call overloaded func float arg" }
387
  }
388
 
389
 
390
setup_xfail "*-*-*" CLLbs16901
391
 
392
send_gdb "print foo_instance1.overload1arg((double)arg12)\n"
393
gdb_expect {
394
    -re ".\[0-9\]* = 12\r\n$gdb_prompt $" {
395
        pass "print call overloaded func double arg"
396
      }
397
    -re ".*$gdb_prompt $" { fail "print call overloaded func double arg" }
398
    timeout           { fail "(timeout) print call overloaded func double arg" }
399
  }
400
 
401
# Now some tests to see if we can list overloaded functions properly:
402
 
403
send_gdb "set listsize 1\n"
404
gdb_expect -re ".*$gdb_prompt $"
405
 
406
gdb_test "list foo::overloadfnarg(void)"\
407
   ".*int foo::overloadfnarg.*\\(void\\).*" \
408
   "print overloaded function with no args"
409
 
410
gdb_test "list foo::overloadfnarg(int)"\
411
    "int foo::overloadfnarg.*\\(int arg\\).*" \
412
   "print overloaded function with int arg"
413
 
414
gdb_test "list foo::overloadfnarg(int, int (*)(int))" \
415
   "int foo::overloadfnarg.*\\(int arg, int \\(\\*foo\\) \\(int\\)\\).*" \
416
   "print overloaded function with function ptr args"
417
 
418
# This one crashes GDB.  Don't know why yet.
419
gdb_test "list \"foo::overloadfnarg(int, int (*)(int))\"" \
420
   "int foo::overloadfnarg.*\\(int arg, int \\(\\*foo\\) \\(int\\)\\).*" \
421
   "print overloaded function with function ptr args - quotes around argument"

powered by: WebSVN 2.1.0

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