]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.cp/class2.exp
Copyright updates for 2007.
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.cp / class2.exp
CommitLineData
6aba47ca 1# Copyright 2003, 2004, 2007 Free Software Foundation, Inc.
f4e8b6f3
MC
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
17if $tracelevel then {
18 strace $tracelevel
19 }
20
21if { [skip_cplus_tests] } { continue }
22
23set prms_id 0
24set bug_id 0
25
26set testfile "class2"
27set srcfile ${testfile}.cc
28set binfile ${objdir}/${subdir}/${testfile}
29
30# Create and source the file that provides information about the compiler
31# used to compile the test case.
32if [get_compiler_info ${binfile} "c++"] {
33 return -1
34}
35
36if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } {
b60f0898
JB
37 untested class2.exp
38 return -1
f4e8b6f3
MC
39}
40
41gdb_exit
42gdb_start
43gdb_reinitialize_dir $srcdir/$subdir
44gdb_load ${binfile}
45
46# Start with "set print object off".
47
48gdb_test "set print object off" ""
49
50if ![runto_main] then {
51 perror "couldn't run to main"
52 continue
53}
54
55get_debug_format
56
57gdb_test "break [gdb_get_line_number "marker return 0"]" \
58 "Breakpoint.*at.* file .*" ""
59
60gdb_test "continue" "Breakpoint .* at .*" ""
61
62# Access the "A" object.
63
64gdb_test "print alpha" \
65 "= {.*a1 = 100.*}" \
66 "print alpha at marker return 0"
67
68# Access the "B" object.
69
70gdb_test "print beta" \
71 "= {.*a1 = 200.*b1 = 201.*b2 = 202}" \
72 "print beta at marker return 0"
73
74# Access the "A" object through an "A *" pointer.
75
76gdb_test_multiple "print * aap" "print * aap at marker return 0" {
77 -re "= {.*a1 = 100.*}\r\n$gdb_prompt $" {
78 # gcc 2.95.3 -gstabs+
79 # gcc 3.3.2 -gdwarf-2
80 # gcc 3.3.2 -gstabs+
81 pass "print * aap at marker return 0"
82 }
83 -re "= {.*a1 = .*}\r\n$gdb_prompt $" {
84 if { [test_compiler_info gcc-2-*] && [test_debug_format "DWARF 2"] } {
85 # gcc 2.95.3 -gdwarf-2
86 setup_kfail "gdb/1465" "*-*-*"
87 }
88 fail "print * aap at marker return 0"
89 }
90}
91
92# Access the "B" object through a "B *" pointer.
93
94gdb_test "print * bbp" \
95 "= {.*a1 = 200.*b1 = 201.*b2 = 202}" \
96 "print * bbp at marker return 0"
97
98# Access the "B" object through an "A *" pointer.
99# This should print using the "A" type.
100
101gdb_test_multiple "print * abp" "print * abp at marker return 0, s-p-o off" {
102 -re "= {.*a1 = 200.*b1 = .*b2 = .*}\r\n$gdb_prompt $" {
103 # This would violate the documentation for "set print object off".
104 fail "print * abp at marker return 0, s-p-o off"
105 }
106 -re "= {.*a1 = 200.*}\r\n$gdb_prompt $" {
107 pass "print * abp at marker return 0, s-p-o off"
108 }
109}
110
111# Access the "B" object through a "B *" pointer expression.
112# This should print using the "B" type.
113
114gdb_test "print * (B *) abp" \
115 "= {.*a1 = 200.*b1 = 201.*b2 = 202}" \
116 "print * (B *) abp at marker return 0"
98f9cd2d
JB
117
118# Printing the value of an object containing no data fields:
119
120gdb_test "p e" "= \{<No data fields>\}" "print object with no data fields"