PR gold/14309
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.cp / m-static.exp
CommitLineData
0b302171 1# Copyright 2002, 2004, 2007-2012 Free Software Foundation, Inc.
258093ca
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
e22f8b7c 5# the Free Software Foundation; either version 3 of the License, or
258093ca 6# (at your option) any later version.
e22f8b7c 7#
258093ca
MC
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.
e22f8b7c 12#
258093ca 13# You should have received a copy of the GNU General Public License
e22f8b7c 14# along with this program. If not, see <http://www.gnu.org/licenses/>.
258093ca
MC
15
16# Tests for member static data
17# 2002-05-13 Benjamin Kosnik <bkoz@redhat.com>
e70d6e3f 18# 2002-08-22 David Carlton <carlton@math.stanford.edu>
258093ca
MC
19
20# This file is part of the gdb testsuite
21
258093ca
MC
22if { [skip_cplus_tests] } { continue }
23
24#
25# test running programs
26#
258093ca
MC
27
28set testfile "m-static"
dd8c8ee7
MC
29set srcfile "${testfile}.cc"
30set srcfile1 "${testfile}1.cc"
31set objfile "${testfile}.o"
32set objfile1 "${testfile}1.o"
f8d4bac4 33set binfile "${objdir}/${subdir}/${testfile}"
258093ca 34
dd8c8ee7 35if { [gdb_compile "$srcdir/$subdir/$srcfile" "$objdir/$subdir/$objfile" object {debug c++}] != "" } {
b60f0898
JB
36 untested m-static.exp
37 return -1
258093ca
MC
38}
39
dd8c8ee7 40if { [gdb_compile "$srcdir/$subdir/$srcfile1" "$objdir/$subdir/$objfile1" object {debug c++}] != "" } {
b60f0898
JB
41 untested m-static.exp
42 return -1
f8d4bac4
MC
43}
44
dd8c8ee7 45if { [gdb_compile "$objdir/$subdir/$objfile $objdir/$subdir/$objfile1" "${binfile}" executable {debug c++}] != "" } {
b60f0898
JB
46 untested m-static.exp
47 return -1
258093ca
MC
48}
49
4c93b1db 50if [get_compiler_info] {
46fc714c
JK
51 return -1
52}
53
258093ca
MC
54gdb_exit
55gdb_start
56gdb_reinitialize_dir $srcdir/$subdir
57gdb_load ${binfile}
58
258093ca
MC
59if ![runto_main] then {
60 perror "couldn't run to breakpoint"
61 continue
62}
63
254e6b9e
DE
64get_debug_format
65set non_dwarf [expr ! [test_debug_format "DWARF 2"]]
66
e70d6e3f
DC
67# First, run to after we've constructed all the objects:
68
69gdb_breakpoint [gdb_get_line_number "constructs-done"]
70gdb_continue_to_breakpoint "end of constructors"
71
72
258093ca 73# One.
258093ca
MC
74
75# simple object, static const bool
76gdb_test "print test1.test" "\\$\[0-9\]* = true" "simple object, static const bool"
77
78# simple object, static const int
79gdb_test "print test1.key1" "\\$\[0-9\]* = 5" "simple object, static const int"
80
81# simple object, static long
82gdb_test "print test1.key2" "\\$\[0-9\]* = 77" "simple object, static long"
83
84# simple object, static enum
85gdb_test "print test1.value" "\\$\[0-9\]* = oriental" "simple object, static enum"
86
87# Two.
258093ca
MC
88
89# derived template object, base static const bool
90gdb_test "print test2.test" "\\$\[0-9\]* = true" "derived template object, base static const bool"
91
92# derived template object, base static const int
93gdb_test "print test2.key1" "\\$\[0-9\]* = 5" "derived template object, base static const int"
94
95# derived template object, base static long
96gdb_test "print test2.key2" "\\$\[0-9\]* = 77" "derived template object, base static long"
97
98# derived template object, base static enum
99gdb_test "print test2.value" "\\$\[0-9\].* = oriental" "derived template object, base static enum"
100
101# derived template object, static enum
102gdb_test "print test2.value_derived" "\\$\[0-9\].* = etruscan" "derived template object, static enum"
103
104# Three.
258093ca
MC
105
106# template object, static derived template data member's base static const bool
107gdb_test "print test3.data.test" "\\$\[0-9\].* = true" "template object, static const bool"
108
109# template object, static derived template data member's base static const int
110gdb_test "print test3.data.key1" "\\$\[0-9\].* = 5" "template object, static const int"
111
112# template object, static derived template data member's base static long
113gdb_test "print test3.data.key2" "\\$\[0-9\].* = 77" "template object, static long"
114
115# template object, static derived template data member's base static enum
116gdb_test "print test3.data.value" "\\$\[0-9\].* = oriental" "template object, static enum"
117
118# template object, static derived template data member's static enum
119gdb_test "print test3.data.value_derived" "\\$\[0-9\].* = etruscan" "template object, static derived enum"
120
e70d6e3f
DC
121# 2002-08-16
122# Four.
123
124# static const int initialized in another file.
125gdb_test "print test4.elsewhere" "\\$\[0-9\].* = 221" "static const int initialized elsewhere"
126
127# static const int that nobody initializes. From PR gdb/635.
46fc714c
JK
128if {[test_compiler_info {gcc-[0-3]-*}]
129 || [test_compiler_info {gcc-4-[0-4]-*}]} {
130 # There was an extra CU-level DW_TAG_variable as DW_AT_declaration
131 # with DW_AT_name = nowhere
132 # and DW_AT_MIPS_linkage_name = _ZN9gnu_obj_47nowhereE .
133 setup_xfail *-*-*
134}
b2dae948 135gdb_test "print test4.nowhere" "field nowhere is nonexistent or has been optimized out" "static const int initialized nowhere"
e70d6e3f 136
254e6b9e
DE
137# static const initialized in the class definition, PR gdb/11702.
138if { $non_dwarf } { setup_xfail *-*-* }
139gdb_test "print test4.everywhere" "\\$\[0-9\].* = 317" "static const int initialized in class definition"
140if { $non_dwarf } { setup_xfail *-*-* }
141gdb_test "print test4.somewhere" "\\$\[0-9\].* = 3.14\[0-9\]*" "static const float initialized in class definition"
142
143# Also make sure static const members can be found via "info var".
144if { $non_dwarf } { setup_xfail *-*-* }
145gdb_test "info variable everywhere" "File .*/m-static\[.\]h.*const int gnu_obj_4::everywhere;" "info variable everywhere"
146
e70d6e3f
DC
147# Perhaps at some point test4 should also include a test for a static
148# const int that was initialized in the header file. But I'm not sure
149# that GDB's current behavior in such situations is either consistent
150# across platforms or optimal, so I'm not including one now.
151
1c809c68
TT
152# Step into test1.method and examine the method-scoped static.
153# This is a regression test for PR 9708.
154gdb_test "step" "gnu_obj_1::method.*"
155gdb_test "print svar" " = true"
156
258093ca
MC
157gdb_exit
158return 0
This page took 0.999721 seconds and 4 git commands to generate.