Commit | Line | Data |
---|---|---|
28e7fd62 | 1 | # Copyright 2002-2013 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 |
22 | if { [skip_cplus_tests] } { continue } |
23 | ||
24 | # | |
25 | # test running programs | |
26 | # | |
258093ca | 27 | |
f5f3a911 | 28 | standard_testfile .cc m-static1.cc |
258093ca | 29 | |
4c93b1db | 30 | if [get_compiler_info] { |
46fc714c JK |
31 | return -1 |
32 | } | |
33 | ||
f5f3a911 TT |
34 | if {[prepare_for_testing $testfile.exp $testfile \ |
35 | [list $srcfile $srcfile2] {debug c++}]} { | |
36 | return -1 | |
37 | } | |
258093ca | 38 | |
258093ca MC |
39 | if ![runto_main] then { |
40 | perror "couldn't run to breakpoint" | |
41 | continue | |
42 | } | |
43 | ||
254e6b9e DE |
44 | get_debug_format |
45 | set non_dwarf [expr ! [test_debug_format "DWARF 2"]] | |
46 | ||
e70d6e3f DC |
47 | # First, run to after we've constructed all the objects: |
48 | ||
49 | gdb_breakpoint [gdb_get_line_number "constructs-done"] | |
50 | gdb_continue_to_breakpoint "end of constructors" | |
51 | ||
52 | ||
258093ca | 53 | # One. |
258093ca MC |
54 | |
55 | # simple object, static const bool | |
56 | gdb_test "print test1.test" "\\$\[0-9\]* = true" "simple object, static const bool" | |
57 | ||
58 | # simple object, static const int | |
59 | gdb_test "print test1.key1" "\\$\[0-9\]* = 5" "simple object, static const int" | |
60 | ||
61 | # simple object, static long | |
62 | gdb_test "print test1.key2" "\\$\[0-9\]* = 77" "simple object, static long" | |
63 | ||
64 | # simple object, static enum | |
65 | gdb_test "print test1.value" "\\$\[0-9\]* = oriental" "simple object, static enum" | |
66 | ||
e234dfaf TT |
67 | gdb_test "print test1.'~gnu_obj_1'" \ |
68 | { = {void \(gnu_obj_1 \*( const)?, int\)} 0x[0-9a-f]+ <gnu_obj_1::~gnu_obj_1\(\)>} \ | |
69 | "simple object instance, print quoted destructor" | |
70 | ||
71 | gdb_test "ptype gnu_obj_1::'~gnu_obj_1'" \ | |
72 | {type = void \(gnu_obj_1 \* const\)} \ | |
73 | "simple object class, ptype quoted destructor" | |
74 | ||
258093ca | 75 | # Two. |
258093ca MC |
76 | |
77 | # derived template object, base static const bool | |
78 | gdb_test "print test2.test" "\\$\[0-9\]* = true" "derived template object, base static const bool" | |
79 | ||
80 | # derived template object, base static const int | |
81 | gdb_test "print test2.key1" "\\$\[0-9\]* = 5" "derived template object, base static const int" | |
82 | ||
83 | # derived template object, base static long | |
84 | gdb_test "print test2.key2" "\\$\[0-9\]* = 77" "derived template object, base static long" | |
85 | ||
86 | # derived template object, base static enum | |
87 | gdb_test "print test2.value" "\\$\[0-9\].* = oriental" "derived template object, base static enum" | |
88 | ||
89 | # derived template object, static enum | |
90 | gdb_test "print test2.value_derived" "\\$\[0-9\].* = etruscan" "derived template object, static enum" | |
91 | ||
92 | # Three. | |
258093ca MC |
93 | |
94 | # template object, static derived template data member's base static const bool | |
95 | gdb_test "print test3.data.test" "\\$\[0-9\].* = true" "template object, static const bool" | |
96 | ||
97 | # template object, static derived template data member's base static const int | |
98 | gdb_test "print test3.data.key1" "\\$\[0-9\].* = 5" "template object, static const int" | |
99 | ||
100 | # template object, static derived template data member's base static long | |
101 | gdb_test "print test3.data.key2" "\\$\[0-9\].* = 77" "template object, static long" | |
102 | ||
103 | # template object, static derived template data member's base static enum | |
104 | gdb_test "print test3.data.value" "\\$\[0-9\].* = oriental" "template object, static enum" | |
105 | ||
106 | # template object, static derived template data member's static enum | |
107 | gdb_test "print test3.data.value_derived" "\\$\[0-9\].* = etruscan" "template object, static derived enum" | |
108 | ||
e70d6e3f DC |
109 | # 2002-08-16 |
110 | # Four. | |
111 | ||
112 | # static const int initialized in another file. | |
113 | gdb_test "print test4.elsewhere" "\\$\[0-9\].* = 221" "static const int initialized elsewhere" | |
114 | ||
115 | # static const int that nobody initializes. From PR gdb/635. | |
46fc714c JK |
116 | if {[test_compiler_info {gcc-[0-3]-*}] |
117 | || [test_compiler_info {gcc-4-[0-4]-*}]} { | |
118 | # There was an extra CU-level DW_TAG_variable as DW_AT_declaration | |
119 | # with DW_AT_name = nowhere | |
120 | # and DW_AT_MIPS_linkage_name = _ZN9gnu_obj_47nowhereE . | |
121 | setup_xfail *-*-* | |
122 | } | |
b2dae948 | 123 | gdb_test "print test4.nowhere" "field nowhere is nonexistent or has been optimized out" "static const int initialized nowhere" |
e70d6e3f | 124 | |
254e6b9e DE |
125 | # static const initialized in the class definition, PR gdb/11702. |
126 | if { $non_dwarf } { setup_xfail *-*-* } | |
127 | gdb_test "print test4.everywhere" "\\$\[0-9\].* = 317" "static const int initialized in class definition" | |
128 | if { $non_dwarf } { setup_xfail *-*-* } | |
129 | gdb_test "print test4.somewhere" "\\$\[0-9\].* = 3.14\[0-9\]*" "static const float initialized in class definition" | |
130 | ||
131 | # Also make sure static const members can be found via "info var". | |
132 | if { $non_dwarf } { setup_xfail *-*-* } | |
133 | gdb_test "info variable everywhere" "File .*/m-static\[.\]h.*const int gnu_obj_4::everywhere;" "info variable everywhere" | |
134 | ||
e70d6e3f DC |
135 | # Perhaps at some point test4 should also include a test for a static |
136 | # const int that was initialized in the header file. But I'm not sure | |
137 | # that GDB's current behavior in such situations is either consistent | |
138 | # across platforms or optimal, so I'm not including one now. | |
139 | ||
1c809c68 TT |
140 | # Step into test1.method and examine the method-scoped static. |
141 | # This is a regression test for PR 9708. | |
142 | gdb_test "step" "gnu_obj_1::method.*" | |
143 | gdb_test "print svar" " = true" | |
144 | ||
258093ca MC |
145 | gdb_exit |
146 | return 0 |