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

Subversion Repositories scarts

[/] [scarts/] [trunk/] [toolchain/] [scarts-gdb/] [gdb-6.8/] [gdb/] [testsuite/] [gdb.cp/] [member-ptr.exp] - Blame information for rev 25

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 25 jlechner
# Copyright 1998, 1999, 2003, 2004, 2006, 2007, 2008
2
# Free Software Foundation, Inc.
3
 
4
# This file is part of the gdb testsuite
5
 
6
# This program is free software; you can redistribute it and/or modify
7
# it under the terms of the GNU General Public License as published by
8
# the Free Software Foundation; either version 3 of the License, or
9
# (at your option) any later version.
10
#
11
# This program is distributed in the hope that it will be useful,
12
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
# GNU General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License
17
# along with this program.  If not, see .
18
 
19
# Tests for pointer-to-member support
20
# Written by Satish Pai  1997-08-19
21
# Rewritten by Michael Chastain  2004-01-11
22
 
23
set vhn "\\$\[0-9\]+"
24
 
25
if $tracelevel then {
26
    strace $tracelevel
27
}
28
 
29
if { [skip_cplus_tests] } { continue }
30
 
31
set prms_id 0
32
set bug_id 0
33
 
34
set testfile "member-ptr"
35
set srcfile ${testfile}.cc
36
set binfile ${objdir}/${subdir}/${testfile}
37
 
38
if [get_compiler_info ${binfile} "c++"] {
39
    return -1
40
}
41
 
42
if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } {
43
     untested member-ptr.exp
44
     return -1
45
}
46
 
47
gdb_exit
48
gdb_start
49
gdb_reinitialize_dir $srcdir/$subdir
50
gdb_load ${binfile}
51
 
52
if ![runto_main] then {
53
    perror "couldn't run to breakpoint"
54
    continue
55
}
56
 
57
gdb_breakpoint [gdb_get_line_number "Breakpoint 1 here"]
58
gdb_continue_to_breakpoint "continue to pmi = NULL"
59
 
60
# ======================
61
# pointer to member data
62
# ======================
63
 
64
# ptype on pointer to data member
65
 
66
set name "ptype pmi (A::j)"
67
gdb_test_multiple "ptype pmi" $name {
68
    -re "type = int A::\\*\r\n$gdb_prompt $" {
69
        pass $name
70
    }
71
}
72
 
73
# print pointer to data member
74
 
75
set name "print pmi (A::j) "
76
gdb_test_multiple "print pmi" $name {
77
    -re "$vhn = &A::j\r\n$gdb_prompt $" {
78
        pass $name
79
    }
80
    -re "$vhn = \\(int ?\\( ?A::\\*\\)\\) &A::j\r\n$gdb_prompt $" {
81
        pass $name
82
    }
83
    -re "$vhn = \\(int ?\\( ?A::\\*\\)\\) ?&A::j ?\\+ ?1 bytes\r\n$gdb_prompt $" {
84
        # gcc 2.95.3 -gdwarf-2
85
        kfail "gdb/NNNN" $name
86
    }
87
    -re "$vhn = &A::j ?\\+ ?1 bytes\r\n$gdb_prompt $" {
88
        # gcc 2.95.3 -gstabs+
89
        kfail "gdb/NNNN" $name
90
    }
91
    -re "$vhn = not implemented: member type in c_val_print\r\n$gdb_prompt $" {
92
        # gcc HEAD 2004-01-11 05:33:21 -gdwarf-2
93
        # gcc HEAD 2004-01-11 05:33:21 -gstabs+
94
        kfail "gdb/NNNN" $name
95
    }
96
    -re "$vhn = \\(int ?\\( A::\\*\\)\\) 536870920\r\n$gdb_prompt $" {
97
        # the value is 0x20000008 hex.   0x20000000 is an internal flag.
98
        # Use '|' to add in more values as needed.
99
        # hpacc A.03.45
100
        kfail "gdb/NNNN" $name
101
    }
102
}
103
 
104
# print dereferenced pointer to data member
105
 
106
set name "print a.*pmi (A::j)"
107
gdb_test_multiple "print a.*pmi" $name {
108
    -re "$vhn = 121\r\n$gdb_prompt $" {
109
        pass $name
110
    }
111
    -re "$vhn = 855638016\r\n$gdb_prompt $" {
112
        # gcc 2.95.3 -gdwarf-2
113
        # gcc 2.95.3 -gstabs+
114
        kfail "gdb/NNNN" $name
115
    }
116
    -re "not implemented: member types in unpack_long\r\n$gdb_prompt $" {
117
        # gcc HEAD 2004-01-10 -gdwarf-2
118
        # gcc HEAD 2004-01-10 -gstabs+
119
        kfail "gdb/NNNN" $name
120
    }
121
}
122
 
123
# print dereferenced pointer to data member
124
# this time, dereferenced through a pointer
125
 
126
set name "print a_p->*pmi (A::j)"
127
gdb_test_multiple "print a_p->*pmi" $name {
128
    -re "$vhn = 121\r\n$gdb_prompt $" {
129
        pass $name
130
    }
131
    -re "$vhn = 855638016\r\n$gdb_prompt $" {
132
        # gcc 2.95.3 -gdwarf-2
133
        # gcc 2.95.3 -gstabs+
134
        kfail "gdb/NNNN" $name
135
    }
136
    -re "not implemented: member types in unpack_long\r\n$gdb_prompt $" {
137
        # gcc HEAD 2004-01-10 -gdwarf-2
138
        # gcc HEAD 2004-01-10 -gstabs+
139
        kfail "gdb/NNNN" $name
140
    }
141
}
142
 
143
# set the pointer to a different data member
144
 
145
set name "set var pmi = &A::jj"
146
gdb_test_multiple "set var pmi = &A::jj" $name {
147
    -re "Invalid cast.\r\n$gdb_prompt $" {
148
        # gcc HEAD 2004-01-10 -gdwarf-2
149
        # gcc HEAD 2004-01-10 -gstabs+
150
        kfail "gdb/NNNN" $name
151
    }
152
    -re "set var pmi = &A::jj\r\n$gdb_prompt $" {
153
        # I have to match the echo'ed input explicitly here.
154
        # If I leave it out, the pattern becomes too general
155
        # and matches anything that ends in "$gdb_prompt $".
156
        pass $name
157
    }
158
}
159
 
160
# print the pointer again
161
 
162
set name "print pmi (A::jj)"
163
gdb_test_multiple "print pmi" $name {
164
    -re "$vhn = &A::jj\r\n$gdb_prompt $" {
165
        pass $name
166
    }
167
    -re "$vhn = \\(int ?\\( ?A::\\*\\)\\) &A::jj\r\n$gdb_prompt $" {
168
        pass $name
169
    }
170
    -re "$vhn = not implemented: member type in c_val_print\r\n$gdb_prompt $" {
171
        # gcc HEAD 2004-01-11 05:33:21 -gdwarf-2
172
        # gcc HEAD 2004-01-11 05:33:21 -gstabs+
173
        kfail "gdb/NNNN" $name
174
    }
175
    -re "$vhn = \\(int ?\\( A::\\*\\)\\) 536870924\r\n$gdb_prompt $" {
176
        # the value is 0x20000008 hex.   0x20000000 is an internal flag.
177
        # Use '|' to add in more values as needed.
178
        # hpacc A.03.45
179
        kfail "gdb/NNNN" $name
180
    }
181
}
182
 
183
# print dereferenced pointer to data member again
184
 
185
set name "print a.*pmi (A::jj)"
186
gdb_test_multiple "print a.*pmi" $name {
187
    -re "$vhn = 1331\r\n$gdb_prompt $" {
188
        pass $name
189
    }
190
    -re "not implemented: member types in unpack_long\r\n$gdb_prompt $" {
191
        # gcc HEAD 2004-01-10 -gdwarf-2
192
        # gcc HEAD 2004-01-10 -gstabs+
193
        kfail "gdb/NNNN" $name
194
    }
195
}
196
 
197
# set the pointer to data member back to A::j
198
 
199
set name "set var pmi = &A::j"
200
gdb_test_multiple "set var pmi = &A::j" $name {
201
    -re "Invalid cast.\r\n$gdb_prompt $" {
202
        # gcc HEAD 2004-01-10 -gdwarf-2
203
        # gcc HEAD 2004-01-10 -gstabs+
204
        kfail "gdb/NNNN" $name
205
    }
206
    -re "set var pmi = &A::j\r\n$gdb_prompt $" {
207
        # I have to match the echo'ed input explicitly here.
208
        # If I leave it out, the pattern becomes too general
209
        # and matches anything that ends in "$gdb_prompt $".
210
        pass $name
211
    }
212
}
213
 
214
# print dereferenced pointer to data member yet again (extra check, why not)
215
 
216
set name "print a.*pmi (A::j) (again)"
217
gdb_test_multiple "print a.*pmi" $name {
218
    -re "$vhn = 121\r\n$gdb_prompt $" {
219
        pass $name
220
    }
221
    -re "not implemented: member types in unpack_long\r\n$gdb_prompt $" {
222
        # gcc HEAD 2004-01-10 -gdwarf-2
223
        # gcc HEAD 2004-01-10 -gstabs+
224
        kfail "gdb/NNNN" $name
225
    }
226
}
227
 
228
# Set the data member pointed to.
229
 
230
set name "print a.*pmi = 33"
231
gdb_test_multiple "print a.*pmi = 33" $name {
232
    -re "$vhn = 33\r\n$gdb_prompt $" {
233
        pass $name
234
    }
235
    -re "not implemented: member types in unpack_long\r\n$gdb_prompt $" {
236
        # gcc HEAD 2004-01-10 -gdwarf-2
237
        # gcc HEAD 2004-01-10 -gstabs+
238
        kfail "gdb/NNNN" $name
239
    }
240
}
241
 
242
# Now check that the data really was changed
243
 
244
set name "print a.*pmi (A::j) (33)"
245
gdb_test_multiple "print a.*pmi" $name {
246
    -re "$vhn = 33\r\n$gdb_prompt $" {
247
        pass $name
248
    }
249
    -re "not implemented: member types in unpack_long\r\n$gdb_prompt $" {
250
        # gcc HEAD 2004-01-10 -gdwarf-2
251
        # gcc HEAD 2004-01-10 -gstabs+
252
        kfail "gdb/NNNN" $name
253
    }
254
}
255
 
256
# Double-check by printing a.
257
 
258
set name "print a (j = 33)"
259
gdb_test_multiple "print a" $name {
260
    -re "$vhn = \{c = 120 'x', j = 33, jj = 1331, (static|static int) s = 10, (_vptr.A|_vptr\\$) = ($hex|$hex )\}\r\n$gdb_prompt $" {
261
        pass $name
262
    }
263
    -re "$vhn = \{c = 120 'x', j = 33, jj = 1331, (static|static int) s = 10, Virtual table at $hex\}\r\n$gdb_prompt $" {
264
        pass $name
265
    }
266
    -re "$vhn = \{(_vptr.A|_vptr\\$) = $hex, c = 120 'x', j = 33, jj = 1331, (static|static int) s = 10\}\r\n$gdb_prompt $" {
267
        pass $name
268
    }
269
    -re "$vhn = \{(_vptr.A|_vptr\\$) = $hex, c = 120 'x', j = 121, jj = 1331, (static|static int) s = 10\}\r\n$gdb_prompt $" {
270
        # gcc HEAD 2004-01-10 -gdwarf-2
271
        # gcc HEAD 2004-01-10 -gstabs+
272
        kfail "gdb/NNNN" $name
273
    }
274
}
275
 
276
# Set the data member pointed to, using ->*
277
 
278
set name "print a_p->*pmi = 44"
279
gdb_test_multiple "print a_p->*pmi = 44" $name {
280
    -re "$vhn = 44\r\n$gdb_prompt $" {
281
        pass $name
282
    }
283
    -re "not implemented: member types in unpack_long\r\n$gdb_prompt $" {
284
        # gcc HEAD 2004-01-10 -gdwarf-2
285
        # gcc HEAD 2004-01-10 -gstabs+
286
        kfail "gdb/NNNN" $name
287
    }
288
}
289
 
290
# Check that the data really was changed
291
 
292
set name "print a_p->*pmi (44)"
293
gdb_test_multiple "print a_p->*pmi" $name {
294
    -re "$vhn = 44\r\n$gdb_prompt $" {
295
        pass $name
296
    }
297
    -re "not implemented: member types in unpack_long\r\n$gdb_prompt $" {
298
        # gcc HEAD 2004-01-10 -gdwarf-2
299
        # gcc HEAD 2004-01-10 -gstabs+
300
        kfail "gdb/NNNN" $name
301
    }
302
}
303
 
304
# Double-check by printing a.
305
 
306
set name "print a (j = 44)"
307
gdb_test_multiple "print a" $name {
308
    -re "$vhn = \{c = 120 'x', j = 44, jj = 1331, (static|static int) s = 10, (_vptr.A|_vptr\\$) = ($hex|$hex )\}\r\n$gdb_prompt $" {
309
        pass $name
310
    }
311
    -re "$vhn = \{c = 120 'x', j = 44, jj = 1331, (static|static int) s = 10, Virtual table at $hex\}\r\n$gdb_prompt $" {
312
        pass $name
313
    }
314
    -re "$vhn = \{(_vptr.A|_vptr\\$) = $hex, c = 120 'x', j = 44, jj = 1331, (static|static int) s = 10\}\r\n$gdb_prompt $" {
315
        pass $name
316
    }
317
    -re "$vhn = \{(_vptr.A|_vptr\\$) = $hex, c = 120 'x', j = 121, jj = 1331, (static|static int) s = 10\}\r\n$gdb_prompt $" {
318
        # gcc HEAD 2004-01-10 -gdwarf-2
319
        # gcc HEAD 2004-01-10 -gstabs+
320
        kfail "gdb/NNNN" $name
321
    }
322
}
323
 
324
# ptype the dereferenced pointer to member.
325
 
326
set name "ptype a.*pmi"
327
gdb_test_multiple "ptype a.*pmi" $name {
328
    -re "type = int\r\n$gdb_prompt" {
329
        pass $name
330
    }
331
    -re "not implemented: member types in unpack_long\r\n$gdb_prompt $" {
332
        # gcc HEAD 2004-01-10 -gdwarf-2
333
        # gcc HEAD 2004-01-10 -gstabs+
334
        kfail "gdb/NNNN" $name
335
    }
336
}
337
 
338
# dereference the pointer to data member without any object
339
# this is not allowed: a pmi must be bound to an object to dereference
340
 
341
set name "print *pmi"
342
gdb_test_multiple "print *pmi" $name {
343
    -re "Attempt to dereference pointer to member without an object\r\n$gdb_prompt $" {
344
        pass $name
345
    }
346
    -re "Cannot access memory at address 0x4\r\n$gdb_prompt $" {
347
        # gcc 2.95.3 -gstabs+
348
        kfail "gdb/NNNN" $name
349
    }
350
    -re "Cannot access memory at address 0x8\r\n$gdb_prompt $" {
351
        # gcc 3.3.2 -gdwarf-2
352
        # gcc 3.3.2 -gstabs+
353
        kfail "gdb/NNNN" $name
354
    }
355
}
356
 
357
# dereference the pointer to data member without any object
358
# this is not allowed: a pmi must be bound to an object to dereference
359
 
360
set name "ptype *pmi"
361
gdb_test_multiple "ptype *pmi" $name {
362
    -re "Attempt to dereference pointer to member without an object\r\n$gdb_prompt $" {
363
        pass $name
364
    }
365
    -re "type = int  A::\r\n$gdb_prompt $" {
366
        # gcc 2.95.3 -gstabs+
367
        # gcc HEAD 2004-01-10 -gdwarf-2
368
        # gcc HEAD 2004-01-10 -gstabs+
369
        kfail "gdb/NNNN" $name
370
    }
371
}
372
 
373
# Check cast of pointer to member to integer.
374
# This is similar to "offset-of".
375
# such as "A a; print (size_t) &A.j - (size_t) &A".
376
 
377
set name "print (int) pmi"
378
gdb_test_multiple "print (int) pmi" $name {
379
    -re "$vhn = (4|8|12)\r\n$gdb_prompt" {
380
        pass $name
381
    }
382
}
383
 
384
# Check "(int) pmi" explicitly for equality.
385
 
386
set name "print ((int) pmi) == ((char *) &a.j - (char *) &a)"
387
gdb_test_multiple "print ((int) pmi) == ((char *) &a.j - (char *) & a)" $name {
388
    -re "$vhn = true\r\n$gdb_prompt" {
389
        pass $name
390
    }
391
}
392
 
393
# ==========================
394
# pointer to member function
395
# ==========================
396
 
397
# ptype a pointer to a method
398
 
399
set name "ptype pmf"
400
gdb_test_multiple "ptype pmf" $name {
401
    -re "type = int \\( ?A::\\*\\)\\(A \\*, int\\)\r\n$gdb_prompt $" {
402
        pass $name
403
    }
404
    -re "type = int \\( ?A::\\*\\)\\(void\\)\r\n$gdb_prompt $" {
405
        # hpacc A.03.45
406
        kfail "gdb/NNNN" $name
407
    }
408
    -re "type = struct \{.*\}\r\n$gdb_prompt $" {
409
        # gcc 2.95.3 -gdwarf-2
410
        # gcc 2.95.3 -gstabs+
411
        # gcc 3.2.2 -gdwarf-2
412
        # gcc 3.2.2 -gstabs+
413
        # gcc HEAD 2004-01-10 -gdwarf-2
414
        # gcc HEAD 2004-01-10 -gstabs+
415
        kfail "gdb/NNNN" $name
416
    }
417
}
418
 
419
# print a pointer to a method
420
 
421
set name "print pmf"
422
gdb_test_multiple "print pmf" $name {
423
    -re "$vhn = $hex \r\n$gdb_prompt $" {
424
        pass $name
425
    }
426
    -re "$vhn = .*not supported with HP aCC.*\r\n$gdb_prompt $" {
427
        # hpacc A.03.45
428
        kfail "gdb/NNNN" $name
429
    }
430
    -re "$vhn = \{.*\}\r\n$gdb_prompt $" {
431
        # gcc 2.95.3 -gdwarf-2
432
        # gcc 2.95.3 -gstabs+
433
        # gcc 3.2.2 -gdwarf-2
434
        # gcc 3.2.2 -gstabs+
435
        # gcc HEAD 2004-01-10 -gdwarf-2
436
        # gcc HEAD 2004-01-10 -gstabs+
437
        kfail "gdb/NNNN" $name
438
    }
439
}
440
 
441
# ptype a pointer to a pointer to a method
442
 
443
set name "ptype pmf_p"
444
gdb_test_multiple "ptype pmf_p" $name {
445
    -re "type = int \\( ?A::\\*\\*\\)\\(A \\*, int\\)\r\n$gdb_prompt $" {
446
        pass $name
447
    }
448
    -re "type = int \\( ?A::\\*\\*\\)\\(void\\)\r\n$gdb_prompt $" {
449
        # hpacc A.03.45
450
        kfail "gdb/NNNN" $name
451
    }
452
    -re "type = struct \{.*\} \\*\r\n$gdb_prompt $" {
453
        # gcc 2.95.3 -gdwarf-2
454
        # gcc 2.95.3 -gstabs+
455
        # gcc 3.2.2 -gdwarf-2
456
        # gcc 3.2.2 -gstabs+
457
        # gcc HEAD 2004-01-10 -gdwarf-2
458
        # gcc HEAD 2004-01-10 -gstabs+
459
        kfail "gdb/NNNN" $name
460
    }
461
}
462
 
463
# print a pointer to a pointer to a method
464
 
465
set name "print pmf_p"
466
gdb_test_multiple "print pmf_p" $name {
467
    -re "$vhn = \\(int \\( ?A::\\*\\*\\)\\)\\(int\\)\\) $hex\r\n$gdb_prompt $" {
468
        pass $name
469
    }
470
    -re "$vhn = \\(PMF \\*\\) $hex\r\n$gdb_prompt $" {
471
        pass "gdb/NNNN"
472
    }
473
    -re "$vhn = \\(int \\( ?A::\\*\\*\\)\\(void\\)\\) $hex\r\n$gdb_prompt $" {
474
        # hpacc A.03.45
475
        kfail "gdb/NNNN" $name
476
    }
477
    -re "$vhn = \\(struct \{.*\} \\*\\) $hex\r\n$gdb_prompt $" {
478
        # gcc 2.95.3 -gdwarf-2
479
        kfail "gdb/NNNN" $name
480
    }
481
}
482
 
483
# print dereferenced pointer to method
484
 
485
set name "print a.*pmf"
486
gdb_test_multiple "print a.*pmf" $name {
487
    -re "$vhn = {int \\(A \\*, int\\)} $hex \r\n$gdb_prompt $" {
488
        pass $name
489
    }
490
    -re "Pointers to methods not supported with HP aCC\r\n$gdb_prompt $" {
491
        # hpacc A.03.45
492
        kfail "gdb/NNNN" $name
493
    }
494
    -re "Value can't be converted to integer.\r\n$gdb_prompt $" {
495
        # gcc 2.95.3 -gdwarf-2
496
        # gcc 2.95.3 -gstabs+
497
        # gcc 3.2.2 -gdwarf-2
498
        # gcc 3.2.2 -gstabs+
499
        # gcc HEAD 2004-01-10 -gdwarf-2
500
        # gcc HEAD 2004-01-10 -gstabs+
501
        kfail "gdb/NNNN" $name
502
    }
503
}
504
 
505
# print dereferenced pointer to method, using ->*
506
 
507
set name "print a_p->*pmf"
508
gdb_test_multiple "print a_p->*pmf" $name {
509
    -re "$vhn = {int \\(A \\*, int\\)} $hex \r\n$gdb_prompt $" {
510
        pass $name
511
    }
512
    -re "Pointers to methods not supported with HP aCC\r\n$gdb_prompt $" {
513
        # hpacc A.03.45
514
        kfail "gdb/NNNN" $name
515
    }
516
    -re "Value can't be converted to integer.\r\n$gdb_prompt $" {
517
        # gcc 2.95.3 -gdwarf-2
518
        # gcc 2.95.3 -gstabs+
519
        # gcc 3.2.2 -gdwarf-2
520
        # gcc 3.2.2 -gstabs+
521
        # gcc HEAD 2004-01-10 -gdwarf-2
522
        # gcc HEAD 2004-01-10 -gstabs+
523
        kfail "gdb/NNNN" $name
524
    }
525
}
526
 
527
# set the pointer to data member
528
 
529
set name "set var pmf = &A::foo"
530
gdb_test_multiple "set var pmf = &A::foo" $name {
531
    -re "set var pmf = &A::foo\r\n$gdb_prompt $" {
532
        # I have to match the echo'ed input explicitly here.
533
        # If I leave it out, the pattern becomes too general
534
        # and matches anything that ends in "$gdb_prompt $".
535
        pass $name
536
    }
537
    -re "Invalid cast.\r\n$gdb_prompt $" {
538
        # gcc 2.95.3 -gdwarf-2
539
        # gcc 2.95.3 -gstabs+
540
        # gcc 3.2.2 -gdwarf-2
541
        # gcc 3.2.2 -gstabs+
542
        # gcc HEAD 2004-01-10 -gdwarf-2
543
        # gcc HEAD 2004-01-10 -gstabs+
544
        kfail "gdb/NNNN" $name
545
    }
546
    -re "Assignment to pointers to methods not implemented with HP aCC\r\n$gdb_prompt $" {
547
        kfail "gdb/NNNN" $name
548
    }
549
}
550
 
551
# dereference the pointer to data member without any object
552
# this is not allowed: a pmf must be bound to an object to dereference
553
 
554
set name "print *pmf"
555
gdb_test_multiple "print *pmf" $name {
556
    -re "Attempt to dereference pointer to member without an object\r\n$gdb_prompt $" {
557
        pass $name
558
    }
559
    -re "Structure has no component named operator\\*.\r\n$gdb_prompt $" {
560
        # gcc 2.95.3 -gdwarf-2
561
        # gcc 2.95.3 -gstabs+
562
        # gcc 3.3.2 -gdwarf-2
563
        # gcc 3.3.2 -gstabs+
564
        # gcc HEAD 2004-01-10 -gdwarf-2
565
        # gcc HEAD 2004-01-10 -gstabs+
566
        kfail "gdb/NNNN" $name
567
    }
568
}
569
 
570
# dereference the pointer to data member without any object
571
# this is not allowed: a pmf must be bound to an object to dereference
572
 
573
set name "ptype *pmf"
574
gdb_test_multiple "ptype *pmf" $name {
575
    -re "Attempt to dereference pointer to member without an object\r\n$gdb_prompt $" {
576
        pass $name
577
    }
578
    -re "Structure has no component named operator\\*.\r\n$gdb_prompt $" {
579
        # gcc 2.95.3 -gdwarf-2
580
        # gcc 2.95.3 -gstabs+
581
        # gcc 3.3.2 -gdwarf-2
582
        # gcc 3.3.2 -gstabs+
583
        # gcc HEAD 2004-01-10 -gdwarf-2
584
        # gcc HEAD 2004-01-10 -gstabs+
585
        kfail "gdb/NNNN" $name
586
    }
587
}
588
 
589
# Call a function through a pmf.
590
 
591
set name "print (a.*pmf)(3)"
592
gdb_test_multiple "print (a.*pmf)(3)" $name {
593
    -re "$vhn = 50\r\n$gdb_prompt $" {
594
        pass $name
595
    }
596
    -re "Not implemented: function invocation through pointer to method with HP aCC\r\n$gdb_prompt $" {
597
        # hpacc A.03.45
598
        kfail "gdb/NNNN" $name
599
    }
600
    -re "Value can't be converted to integer.\r\n$gdb_prompt $" {
601
        # gcc 2.95.3 -gdwarf-2
602
        # gcc 2.95.3 -gstabs+
603
        # gcc 3.3.2 -gdwarf-2
604
        # gcc 3.3.2 -gstabs+
605
        # gcc HEAD 2004-01-10 -gdwarf-2
606
        # gcc HEAD 2004-01-10 -gstabs+
607
        kfail "gdb/NNNN" $name
608
    }
609
}
610
 
611
# Print out a pointer to data member which requires looking into
612
# a base class.
613
gdb_test "print diamond_pmi" "$vhn = &Base::x"
614
gdb_test "print diamond.*diamond_pmi" "$vhn = 77"
615
 
616
# Examine some more complicated pmfs, which require adjusting "this"
617
# and looking through virtual tables.
618
 
619
# These two have a different object adjustment, but call the same method.
620
gdb_test "print diamond.*left_pmf" \
621
    "$vhn = {int \\(Diamond \\*\\)} $hex "
622
gdb_test "print diamond.*right_pmf" \
623
    "$vhn = {int \\(Diamond \\*\\)} $hex "
624
 
625
gdb_test "print (diamond.*left_pmf) ()" "$vhn = 77"
626
gdb_test "print (diamond.*right_pmf) ()" "$vhn = 88"
627
 
628
# These two point to different methods, although they have the same
629
# virtual table offsets.
630
gdb_test "print diamond.*left_vpmf" \
631
    "$vhn = {int \\(Diamond \\*\\)} $hex "
632
gdb_test "print diamond.*right_vpmf" \
633
    "$vhn = {int \\(Diamond \\*\\)} $hex "
634
 
635
gdb_test "print (diamond.*left_vpmf) ()" "$vhn = 177"
636
gdb_test "print (diamond.*left_base_vpmf) ()" "$vhn = 2077"
637
gdb_test "print (diamond.*right_vpmf) ()" "$vhn = 288"
638
 
639
# We should be able to figure out left_vpmf even without an object,
640
# because it comes from a non-virtual base.  The same for right_vpmf.
641
gdb_test "print left_vpmf" "$vhn = &virtual Left::vget\\(\\)"
642
gdb_test "print right_vpmf" "$vhn = &virtual Right::vget\\(\\)"
643
 
644
# But we should gracefully fail to figure out base_vpmf, because
645
# its runtime type is more derived than its static type.  This
646
# is a valid but unspecified cast (it is value preserving, i.e.
647
# can be casted back to the correct type and used).
648
gdb_test "print base_vpmf" \
649
    "$vhn = &virtual table offset \[0-9\]*, this adjustment -\[0-9\]*"
650
 
651
# Make sure we parse this correctly; it's invalid.
652
gdb_test "print diamond.*left_vpmf ()" \
653
    "Invalid data type for function to be called\\."
654
 
655
# NULL pointer to member tests.
656
gdb_test "print null_pmi" "$vhn = NULL"
657
gdb_test "print null_pmi = &A::j" "$vhn = &A::j"
658
gdb_test "print null_pmi = 0" "$vhn = NULL"
659
 
660
gdb_test "print null_pmf" "$vhn = NULL"
661
gdb_test "print null_pmf = &A::foo" "$vhn = $hex "
662
gdb_test "print null_pmf = 0" "$vhn = NULL"

powered by: WebSVN 2.1.0

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