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

Subversion Repositories or1k

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

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1181 sfurman
# Copyright 1998, 1999, 2000, 2001, 2002 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
if ![runto 'marker1'] then {
65
    perror "couldn't run to marker1"
66
    continue
67
}
68
 
69
gdb_test "up" ".*main.*" "up from marker1"
70
 
71
send_gdb "print foo_instance1\n"
72
gdb_expect {
73
    -re ".\[0-9\]* = \{ifoo = 111, ccpfoo = 0x0\}\r\n$gdb_prompt $" {
74
        pass "print foo_instance1"
75
      }
76
    -re ".*$gdb_prompt $" { fail "print foo_instance1" }
77
    timeout           { fail "(timeout) print foo_instance1" }
78
  }
79
 
80
 
81
setup_xfail "hppa*-*-*" CLLbs16901
82
send_gdb "ptype foo_instance1\n"
83
gdb_expect {
84
  -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 $" {
85
        pass "ptype foo_instance1 (HP aCC -- known quirk with ~foo parameter list)"
86
      }
87
    -re "type = class foo .*int overloadargs\\(int, int, int, int, int, int, int, int, int, int, int\\);\r\n\}\r\n$gdb_prompt $" {
88
        pass "ptype foo_instance1 (shorter match)"
89
    }
90
    -re ".*$gdb_prompt $" { fail "ptype foo_instance1" }
91
    timeout           { fail "(timeout) ptype foo_instance1" }
92
  }
93
 
94
send_gdb "print foo_instance2\n"
95
gdb_expect {
96
    -re ".\[0-9\]* = \{ifoo = 222, ccpfoo = $hex \"A\"\}\r\n$gdb_prompt $" {
97
        pass "print foo_instance2"
98
      }
99
    -re ".*$gdb_prompt $" { fail "print foo_instance2" }
100
    timeout           { fail "(timeout) print foo_instance2" }
101
  }
102
 
103
send_gdb "print foo_instance3\n"
104
gdb_expect {
105
    -re ".\[0-9\]* = \{ifoo = 222, ccpfoo = $hex \"A\"\}\r\n$gdb_prompt $" {
106
        pass "print foo_instance3"
107
      }
108
    -re ".*$gdb_prompt $" { fail "print foo_instance3" }
109
    timeout           { fail "(timeout) print foo_instance3" }
110
  }
111
 
112
 
113
send_gdb "print foo_instance1.overloadargs(1)\n"
114
gdb_expect {
115
    -re ".\[0-9\]* = 1\r\n$gdb_prompt $" {
116
        pass "print call overloaded func 1 arg"
117
      }
118
    -re ".*$gdb_prompt $" { fail "print call overloaded func 1 arg" }
119
    timeout           { fail "(timeout) print call overloaded func 1 arg" }
120
  }
121
 
122
 
123
send_gdb "print foo_instance1.overloadargs(1, 2)\n"
124
gdb_expect {
125
    -re ".\[0-9\]* = 2\r\n$gdb_prompt $" {
126
        pass "print call overloaded func 2 args"
127
      }
128
    -re ".*$gdb_prompt $" { fail "print call overloaded func 2 args" }
129
    timeout           { fail "(timeout) print call overloaded func 2  args" }
130
  }
131
 
132
 
133
send_gdb "print foo_instance1.overloadargs(1, 2, 3)\n"
134
gdb_expect {
135
    -re ".\[0-9\]* = 3\r\n$gdb_prompt $" {
136
        pass "print call overloaded func 3 args"
137
      }
138
    -re ".*$gdb_prompt $" { fail "print call overloaded func 3 args" }
139
    timeout           { fail "(timeout) print call overloaded func 3 args" }
140
  }
141
 
142
 
143
send_gdb "print foo_instance1.overloadargs(1, 2, 3, 4)\n"
144
gdb_expect {
145
    -re ".\[0-9\]* = 4\r\n$gdb_prompt $" {
146
        pass "print call overloaded func 4 args"
147
      }
148
    -re ".*$gdb_prompt $" { fail "print call overloaded func 4 args" }
149
    timeout           { fail "(timeout) print call overloaded func 4 args" }
150
  }
151
 
152
 
153
send_gdb "print foo_instance1.overloadargs(1, 2, 3, 4, 5)\n"
154
gdb_expect {
155
    -re ".\[0-9\]* = 5\r\n$gdb_prompt $" {
156
        pass "print call overloaded func 5 args"
157
      }
158
    -re ".*$gdb_prompt $" { fail "print call overloaded func 5 args" }
159
    timeout           { fail "(timeout) print call overloaded func 5 args" }
160
  }
161
 
162
 
163
send_gdb "print foo_instance1.overloadargs(1, 2, 3, 4, 5, 6)\n"
164
gdb_expect {
165
    -re ".\[0-9\]* = 6\r\n$gdb_prompt $" {
166
        pass "print call overloaded func 6 args"
167
      }
168
    -re ".*$gdb_prompt $" { fail "print call overloaded func 6 args" }
169
    timeout           { fail "(timeout) print call overloaded func 6 args" }
170
  }
171
 
172
 
173
send_gdb "print foo_instance1.overloadargs(1, 2, 3, 4, 5, 6, 7)\n"
174
gdb_expect {
175
    -re ".\[0-9\]* = 7\r\n$gdb_prompt $" {
176
        pass "print call overloaded func 7 args"
177
      }
178
    -re ".*$gdb_prompt $" { fail "print call overloaded func 7 args" }
179
    timeout           { fail "(timeout) print call overloaded func 7 args" }
180
  }
181
 
182
 
183
send_gdb "print foo_instance1.overloadargs(1, 2, 3, 4, 5, 6, 7, 8)\n"
184
gdb_expect {
185
    -re ".\[0-9\]* = 8\r\n$gdb_prompt $" {
186
        pass "print call overloaded func 8 args"
187
      }
188
    -re ".*$gdb_prompt $" { fail "print call overloaded func 8 args" }
189
    timeout           { fail "(timeout) print call overloaded func 8 args" }
190
  }
191
 
192
 
193
send_gdb "print foo_instance1.overloadargs(1, 2, 3, 4, 5, 6, 7, 8, 9)\n"
194
gdb_expect {
195
    -re ".\[0-9\]* = 9\r\n$gdb_prompt $" {
196
        pass "print call overloaded func 9 args"
197
      }
198
    -re ".*$gdb_prompt $" { fail "print call overloaded func 9 args" }
199
    timeout           { fail "(timeout) print call overloaded func 9 args" }
200
  }
201
 
202
 
203
send_gdb "print foo_instance1.overloadargs(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)\n"
204
gdb_expect {
205
    -re ".\[0-9\]* = 10\r\n$gdb_prompt $" {
206
        pass "print call overloaded func 10 args"
207
      }
208
    -re ".*$gdb_prompt $" { fail "print call overloaded func 10 args" }
209
    timeout           { fail "(timeout) print call overloaded func 10 args" }
210
  }
211
 
212
 
213
send_gdb "print foo_instance1.overloadargs(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11)\n"
214
gdb_expect {
215
    -re ".\[0-9\]* = 11\r\n$gdb_prompt $" {
216
        pass "print call overloaded func 11 args"
217
      }
218
    -re ".*$gdb_prompt $" { fail "print call overloaded func 11 args" }
219
    timeout           { fail "(timeout) print call overloaded func 11 args" }
220
  }
221
 
222
 
223
send_gdb "print foo_instance1.overload1arg()\n"
224
gdb_expect {
225
    -re ".\[0-9\]* = 1\r\n$gdb_prompt $" {
226
        pass "print call overloaded func void arg"
227
      }
228
    -re ".*$gdb_prompt $" { fail "print call overloaded func void arg" }
229
    timeout           { fail "(timeout) print call overloaded func void arg" }
230
  }
231
 
232
 
233
send_gdb "print foo_instance1.overload1arg((char)arg2)\n"
234
gdb_expect {
235
    -re ".\[0-9\]* = 2\r\n$gdb_prompt $" {
236
        pass "print call overloaded func char arg"
237
      }
238
    -re ".*$gdb_prompt $" { fail "print call overloaded func char arg" }
239
    timeout           { fail "(timeout) print call overloaded func char arg" }
240
  }
241
 
242
 
243
send_gdb "print foo_instance1.overload1arg((signed char)arg3)\n"
244
gdb_expect {
245
    -re ".\[0-9\]* = 3\r\n$gdb_prompt $" {
246
        pass "print call overloaded func signed char arg"
247
      }
248
    -re ".*$gdb_prompt $" { fail "print call overloaded func signed char arg" }
249
    timeout           { fail "(timeout) print call overloaded func signed char arg" }
250
  }
251
 
252
 
253
send_gdb "print foo_instance1.overload1arg((unsigned char)arg4)\n"
254
gdb_expect {
255
    -re ".\[0-9\]* = 4\r\n$gdb_prompt $" {
256
        pass "print call overloaded func unsigned char arg"
257
      }
258
    -re ".*$gdb_prompt $" { fail "print call overloaded func unsigned char arg" }
259
    timeout           { fail "(timeout) print call overloaded func unsigned char arg" }
260
  }
261
 
262
 
263
# The overload resolver added by HP (valops.c:find_overload_match) doesn't
264
# work right for G++ output, since the list of parameters seems not to
265
# be filled in correctly.  Until this gets fixed, don't expect to pass
266
# some of these tests.
267
 
268
setup_xfail "*-*-*" CLLbs16901
269
 
270
send_gdb "print foo_instance1.overload1arg((short)arg5)\n"
271
gdb_expect {
272
    -re ".\[0-9\]* = 5\r\n$gdb_prompt $" {
273
        pass "print call overloaded func short arg"
274
      }
275
    -re ".*$gdb_prompt $" { fail "print call overloaded func short arg" }
276
    timeout           { fail "(timeout) print call overloaded func short arg" }
277
  }
278
 
279
 
280
setup_xfail "*-*-*" CLLbs16901
281
 
282
send_gdb "print foo_instance1.overload1arg((unsigned short)arg6)\n"
283
gdb_expect {
284
    -re ".\[0-9\]* = 6\r\n$gdb_prompt $" {
285
        pass "print call overloaded func unsigned short arg"
286
      }
287
    -re ".*$gdb_prompt $" { fail "print call overloaded func unsigned short  arg" }
288
    timeout           { fail "(timeout) print call overloaded func unsigned short arg" }
289
  }
290
 
291
 
292
send_gdb "print foo_instance1.overload1arg((int)arg7)\n"
293
gdb_expect {
294
    -re ".\[0-9\]* = 7\r\n$gdb_prompt $" {
295
        pass "print call overloaded func int arg"
296
      }
297
    -re ".*$gdb_prompt $" { fail "print call overloaded func int arg" }
298
    timeout           { fail "(timeout) print call overloaded func int arg" }
299
  }
300
 
301
 
302
send_gdb "print foo_instance1.overload1arg((unsigned int)arg8)\n"
303
gdb_expect {
304
    -re ".\[0-9\]* = 8\r\n$gdb_prompt $" {
305
        pass "print call overloaded func unsigned int arg"
306
      }
307
    -re ".*$gdb_prompt $" { fail "print call overloaded func unsigned int arg" }
308
    timeout           { fail "(timeout) print call overloaded func unsigned int arg" }
309
  }
310
 
311
 
312
setup_xfail "*-*-*" CLLbs16901
313
 
314
send_gdb "print foo_instance1.overload1arg((long)arg9)\n"
315
gdb_expect {
316
    -re ".\[0-9\]* = 9\r\n$gdb_prompt $" {
317
        pass "print call overloaded func long arg"
318
      }
319
    -re ".*$gdb_prompt $" { fail "print call overloaded func long arg" }
320
    timeout           { fail "(timeout) print call overloaded func long arg" }
321
  }
322
 
323
 
324
setup_xfail "*-*-*" CLLbs16901
325
 
326
send_gdb "print foo_instance1.overload1arg((unsigned long)arg10)\n"
327
gdb_expect {
328
    -re ".\[0-9\]* = 10\r\n$gdb_prompt $" {
329
        pass "print call overloaded func unsigned long arg"
330
      }
331
    -re ".*$gdb_prompt $" { fail "print call overloaded func unsigned long arg" }
332
    timeout           { fail "(timeout) print call overloaded func unsigned long arg" }
333
  }
334
 
335
 
336
send_gdb "print foo_instance1.overload1arg((float)arg11)\n"
337
gdb_expect {
338
    -re ".\[0-9\]* = 11\r\n$gdb_prompt $" {
339
        pass "print call overloaded func float arg"
340
      }
341
    -re ".*$gdb_prompt $" { fail "print call overloaded func float arg" }
342
    timeout           { fail "(timeout) print call overloaded func float arg" }
343
  }
344
 
345
 
346
send_gdb "print foo_instance1.overload1arg((double)arg12)\n"
347
gdb_expect {
348
    -re ".\[0-9\]* = 12\r\n$gdb_prompt $" {
349
        pass "print call overloaded func double arg"
350
      }
351
    -re ".*$gdb_prompt $" { fail "print call overloaded func double arg" }
352
    timeout           { fail "(timeout) print call overloaded func double arg" }
353
  }
354
 
355
# Now some tests to see if we can list overloaded functions properly:
356
 
357
gdb_test "set listsize 1" "" ""
358
# send_gdb "set listsize 1\n"
359
# gdb_expect -re ".*$gdb_prompt $"
360
 
361
#
362
# Decide whether to use "()" or "(void)"
363
#
364
 
365
send_gdb "info func overloadfnarg\n"
366
gdb_expect {
367
    -re ".*overloadfnarg\\(void\\).*$gdb_prompt $" {
368
        gdb_test "list foo::overloadfnarg(void)"\
369
                ".*int foo::overloadfnarg.*\\(void\\).*" \
370
                "list overloaded function with no args"
371
    }
372
    -re ".*overloadfnarg\\(\\).*$gdb_prompt $" {
373
        gdb_test "list foo::overloadfnarg()"\
374
                ".*int foo::overloadfnarg.*\\(void\\).*" \
375
                "list overloaded function with no args"
376
    }
377
    -re ".*$gdb_prompt $" {
378
        fail "list overloaded function with no args (no matching symbol)"
379
    }
380
}
381
 
382
gdb_test "list foo::overloadfnarg(int)"\
383
    "int foo::overloadfnarg.*\\(int arg\\).*" \
384
   "list overloaded function with int arg"
385
 
386
gdb_test "list foo::overloadfnarg(int, int (*)(int))" \
387
   "int foo::overloadfnarg.*\\(int arg, int \\(\\*foo\\) \\(int\\)\\).*" \
388
   "list overloaded function with function ptr args"
389
 
390
# This one crashes GDB.  Don't know why yet.
391
gdb_test "list \"foo::overloadfnarg(int, int (*)(int))\"" \
392
   "int foo::overloadfnarg.*\\(int arg, int \\(\\*foo\\) \\(int\\)\\).*" \
393
   "list 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.