1 # Copyright 2003, 2004 Free Software Foundation, Inc.
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.
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.
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.
21 if { [skip_cplus_tests] } { continue }
27 set srcfile ${testfile}.cc
28 set binfile ${objdir}/${subdir}/${testfile}
30 # Create and source the file that provides information about the compiler
31 # used to compile the test case.
32 if [get_compiler_info ${binfile} "c++"] {
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."
42 gdb_reinitialize_dir $srcdir/$subdir
45 # Start with "set print object off".
47 gdb_test "set print object off" ""
49 if ![runto_main] then {
50 perror "couldn't run to main"
56 gdb_test "break [gdb_get_line_number "marker return 0"]" \
57 "Breakpoint.*at.* file .*" ""
59 gdb_test "continue" "Breakpoint .* at .*" ""
61 # Access the "A" object.
63 gdb_test "print alpha" \
65 "print alpha at marker return 0"
67 # Access the "B" object.
69 gdb_test "print beta" \
70 "= {.*a1 = 200.*b1 = 201.*b2 = 202}" \
71 "print beta at marker return 0"
73 # Access the "A" object through an "A *" pointer.
75 gdb_test_multiple "print * aap" "print * aap at marker return 0" {
76 -re "= {.*a1 = 100.*}\r\n$gdb_prompt $" {
80 pass "print * aap at marker return 0"
82 -re "= {.*a1 = .*}\r\n$gdb_prompt $" {
83 if { [test_compiler_info gcc-2-*] && [test_debug_format "DWARF 2"] } {
84 # gcc 2.95.3 -gdwarf-2
85 setup_kfail "gdb/1465" "*-*-*"
87 fail "print * aap at marker return 0"
91 # Access the "B" object through a "B *" pointer.
93 gdb_test "print * bbp" \
94 "= {.*a1 = 200.*b1 = 201.*b2 = 202}" \
95 "print * bbp at marker return 0"
97 # Access the "B" object through an "A *" pointer.
98 # This should print using the "A" type.
100 gdb_test_multiple "print * abp" "print * abp at marker return 0, s-p-o off" {
101 -re "= {.*a1 = 200.*b1 = .*b2 = .*}\r\n$gdb_prompt $" {
102 # This would violate the documentation for "set print object off".
103 fail "print * abp at marker return 0, s-p-o off"
105 -re "= {.*a1 = 200.*}\r\n$gdb_prompt $" {
106 pass "print * abp at marker return 0, s-p-o off"
110 # Access the "B" object through a "B *" pointer expression.
111 # This should print using the "B" type.
113 gdb_test "print * (B *) abp" \
114 "= {.*a1 = 200.*b1 = 201.*b2 = 202}" \
115 "print * (B *) abp at marker return 0"
117 # Printing the value of an object containing no data fields:
119 gdb_test "p e" "= \{<No data fields>\}" "print object with no data fields"