gdb/
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.cp / ref-params.exp
1 # Tests for reference parameters of types and their subtypes in GDB.
2 # Copyright 2006 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 2 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, write to the Free Software
16 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17
18 # written by Paul N. Hilfinger (Hilfinger@adacore.com)
19
20 if $tracelevel then {
21 strace $tracelevel
22 }
23
24 #
25 # test running programs
26 #
27 set prms_id 0
28 set bug_id 0
29
30 if { [skip_cplus_tests] } { continue }
31
32 set testfile "ref-params"
33 set srcfile ${testfile}.cc
34 set binfile ${objdir}/${subdir}/${testfile}
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 gdb_exit
41
42 proc gdb_start_again { text } {
43 global srcdir
44 global subdir
45 global binfile
46 global srcfile
47
48 gdb_start
49 gdb_reinitialize_dir $srcdir/$subdir
50 gdb_load ${binfile}
51
52 runto ${srcfile}:[gdb_get_line_number $text]
53 }
54
55 gdb_start_again "marker1 here"
56 gdb_test "print Q" ".*id = 42.*" "print value of a Child in main"
57 gdb_test "print f1(Q)" ".* = 42.*" "print value of f1 on Child in main"
58 gdb_test "print f2(Q)" ".* = 42.*" "print value of f2 on Child in main"
59
60 gdb_start_again "marker1 here"
61 gdb_test "print f1(QR)" ".* = 42.*" "print value of f1 on (Child&) in main"
62
63 gdb_start_again "marker1 here"
64 gdb_test "print f2(QR)" ".* = 42.*" "print value of f2 on (Child&) in main"
65
66 gdb_start_again "marker2 here"
67 gdb_test "print C" ".*id = 42.*" "print value of Child& in f2"
68 gdb_test "print f1(C)" ".* = 42.*" "print value of f1 on Child& in f2"
69
70 gdb_start_again "marker3 here"
71 gdb_test "print R" ".*id = 42.*" "print value of Parent& in f1"
72
73 gdb_start_again "breakpoint MQ here"
74 gdb_test "print f1(MQ)" ".* = 53"
75 gdb_test "print mf1(MQ)" ".* = 106"
76 gdb_test "print mf2(MQ)" ".* = 106"
77 gdb_test "print f1(MQR)" ".* = 53"
78 gdb_test "print mf1(MQR)" ".* = 106"
79 gdb_test "print mf2(MQR)" ".* = 106"
This page took 0.031874 seconds and 5 git commands to generate.