ignore invalid DOF provider sections
[binutils-gdb.git] / gdb / testsuite / gdb.cp / m-static.exp
blob8daeaf7995a1f028feaff6847be5b43492d8e965
1 # Copyright 2002-2015 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 3 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, see <http://www.gnu.org/licenses/>.
16 # Tests for member static data
17 # 2002-05-13 Benjamin Kosnik <bkoz@redhat.com>
18 # 2002-08-22 David Carlton <carlton@math.stanford.edu>
20 # This file is part of the gdb testsuite
22 if { [skip_cplus_tests] } { continue }
25 # test running programs
28 standard_testfile .cc m-static1.cc
30 if [get_compiler_info] {
31 return -1
34 if {[prepare_for_testing $testfile.exp $testfile \
35 [list $srcfile $srcfile2] {debug c++}]} {
36 return -1
39 if ![runto_main] then {
40 perror "couldn't run to breakpoint"
41 continue
44 get_debug_format
45 set non_dwarf [expr ! [test_debug_format "DWARF 2"]]
47 # First, run to after we've constructed all the objects:
49 gdb_breakpoint [gdb_get_line_number "constructs-done"]
50 gdb_continue_to_breakpoint "end of constructors"
53 # One.
55 # simple object, static const int, accessing via 'class::method::variable'
56 # Regression test for PR c++/15203 and PR c++/15210
57 gdb_test "print 'gnu_obj_1::method()::sintvar'" "\\$\[0-9\]+ = 4" \
58 "simple object, static const int, accessing via 'class::method::variable"
60 # simple object, static const bool
61 gdb_test "print test1.test" "\\$\[0-9\]* = true" "simple object, static const bool"
63 # simple object, static const int
64 gdb_test "print test1.key1" "\\$\[0-9\]* = 5" "simple object, static const int"
66 # simple object, static long
67 gdb_test "print test1.key2" "\\$\[0-9\]* = 77" "simple object, static long"
69 # simple object, static enum
70 gdb_test "print test1.value" "\\$\[0-9\]* = oriental" "simple object, static enum"
72 if { [istarget arm*-*-*] } {
73 gdb_test "print test5.single_constructor" \
74 { = {single_constructor \*\(single_constructor \* const\)} 0x[0-9a-f]+ <single_constructor::single_constructor\(\)>} \
75 "simple object instance, print constructor"
76 gdb_test "ptype test5.single_constructor" \
77 {type = class single_constructor {\r\n public:\r\n single_constructor\(void\);\r\n ~single_constructor\(int\);\r\n} \*\(single_constructor \* const\)} \
78 "simple object instance, ptype constructor"
79 gdb_test "ptype single_constructor::single_constructor" \
80 {type = class single_constructor {\r\n public:\r\n single_constructor\(void\);\r\n ~single_constructor\(int\);\r\n} \*\(single_constructor \* const\)} \
81 "simple object class, ptype constructor"
83 gdb_test "print test1.~gnu_obj_1" \
84 { = {void \*\(gnu_obj_1 \* const, int\)} 0x[0-9a-f]+ <gnu_obj_1::~gnu_obj_1\(\)>} \
85 "simple object instance, print destructor"
86 gdb_test "ptype test1.~gnu_obj_1" \
87 {type = void \*\(gnu_obj_1 \* const, int\)} \
88 "simple object instance, ptype destructor"
90 gdb_test "print test1.'~gnu_obj_1'" \
91 { = {void \*\(gnu_obj_1 \*( const)?, int\)} 0x[0-9a-f]+ <gnu_obj_1::~gnu_obj_1\(\)>} \
92 "simple object instance, print quoted destructor"
94 gdb_test "ptype gnu_obj_1::'~gnu_obj_1'" \
95 {type = void \*\(gnu_obj_1 \* const\)} \
96 "simple object class, ptype quoted destructor"
97 } else {
98 gdb_test "print test5.single_constructor" \
99 { = {void \(single_constructor \* const\)} 0x[0-9a-f]+ <single_constructor::single_constructor\(\)>} \
100 "simple object instance, print constructor"
101 gdb_test "ptype test5.single_constructor" \
102 {type = void \(single_constructor \* const\)} \
103 "simple object instance, ptype constructor"
104 gdb_test "ptype single_constructor::single_constructor" \
105 {type = void \(single_constructor \* const\)} \
106 "simple object class, ptype constructor"
108 gdb_test "print test1.~gnu_obj_1" \
109 { = {void \(gnu_obj_1 \* const, int\)} 0x[0-9a-f]+ <gnu_obj_1::~gnu_obj_1\(\)>} \
110 "simple object instance, print destructor"
111 gdb_test "ptype test1.~gnu_obj_1" \
112 {type = void \(gnu_obj_1 \* const, int\)} \
113 "simple object instance, ptype destructor"
115 gdb_test "print test1.'~gnu_obj_1'" \
116 { = {void \(gnu_obj_1 \*( const)?, int\)} 0x[0-9a-f]+ <gnu_obj_1::~gnu_obj_1\(\)>} \
117 "simple object instance, print quoted destructor"
119 gdb_test "ptype gnu_obj_1::'~gnu_obj_1'" \
120 {type = void \(gnu_obj_1 \* const\)} \
121 "simple object class, ptype quoted destructor"
124 # Two.
126 # derived template object, base static const bool
127 gdb_test "print test2.test" "\\$\[0-9\]* = true" "derived template object, base static const bool"
129 # derived template object, base static const int
130 gdb_test "print test2.key1" "\\$\[0-9\]* = 5" "derived template object, base static const int"
132 # derived template object, base static long
133 gdb_test "print test2.key2" "\\$\[0-9\]* = 77" "derived template object, base static long"
135 # derived template object, base static enum
136 gdb_test "print test2.value" "\\$\[0-9\].* = oriental" "derived template object, base static enum"
138 # derived template object, static enum
139 gdb_test "print test2.value_derived" "\\$\[0-9\].* = etruscan" "derived template object, static enum"
141 # Three.
143 # template object, static derived template data member's base static const bool
144 gdb_test "print test3.data.test" "\\$\[0-9\].* = true" "template object, static const bool"
146 # template object, static derived template data member's base static const int
147 gdb_test "print test3.data.key1" "\\$\[0-9\].* = 5" "template object, static const int"
149 # template object, static derived template data member's base static long
150 gdb_test "print test3.data.key2" "\\$\[0-9\].* = 77" "template object, static long"
152 # template object, static derived template data member's base static enum
153 gdb_test "print test3.data.value" "\\$\[0-9\].* = oriental" "template object, static enum"
155 # template object, static derived template data member's static enum
156 gdb_test "print test3.data.value_derived" "\\$\[0-9\].* = etruscan" "template object, static derived enum"
158 # 2002-08-16
159 # Four.
161 # static const int initialized in another file.
162 gdb_test "print test4.elsewhere" "\\$\[0-9\].* = 221" "static const int initialized elsewhere"
164 # static const int that nobody initializes. From PR gdb/635.
165 if {[test_compiler_info {gcc-[0-3]-*}]
166 || [test_compiler_info {gcc-4-[0-4]-*}]} {
167 # There was an extra CU-level DW_TAG_variable as DW_AT_declaration
168 # with DW_AT_name = nowhere
169 # and DW_AT_MIPS_linkage_name = _ZN9gnu_obj_47nowhereE .
170 setup_xfail *-*-*
172 gdb_test "print test4.nowhere" "<optimized out>" "static const int initialized nowhere (print field)"
174 # Same, but print the whole struct.
175 gdb_test "print test4" "static nowhere = <optimized out>.*" "static const int initialized nowhere (whole struct)"
177 # static const initialized in the class definition, PR gdb/11702.
178 if { $non_dwarf } { setup_xfail *-*-* }
179 gdb_test "print test4.everywhere" "\\$\[0-9\].* = 317" "static const int initialized in class definition"
180 if { $non_dwarf } { setup_xfail *-*-* }
181 gdb_test "print test4.somewhere" "\\$\[0-9\].* = 3.14\[0-9\]*" "static const float initialized in class definition"
183 # Also make sure static const members can be found via "info var".
184 if { $non_dwarf } { setup_xfail *-*-* }
185 gdb_test "info variable everywhere" "File .*/m-static\[.\]h.*const int gnu_obj_4::everywhere;" "info variable everywhere"
187 # Perhaps at some point test4 should also include a test for a static
188 # const int that was initialized in the header file. But I'm not sure
189 # that GDB's current behavior in such situations is either consistent
190 # across platforms or optimal, so I'm not including one now.
192 # Step into test1.method and examine the method-scoped static.
193 # This is a regression test for PR 9708.
194 gdb_test "step" "gnu_obj_1::method.*"
195 gdb_test "print svar" " = true"
197 gdb_exit
198 return 0