Commit | Line | Data |
---|---|---|
0b302171 | 1 | # Copyright 2002, 2007-2012 Free Software Foundation, Inc. |
71ea1be0 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 |
71ea1be0 | 6 | # (at your option) any later version. |
e22f8b7c | 7 | # |
71ea1be0 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 | # |
71ea1be0 | 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/>. |
71ea1be0 MC |
15 | |
16 | # Tests for member data | |
17 | # 2002-05-13 Benjamin Kosnik <bkoz@redhat.com> | |
18 | ||
19 | # This file is part of the gdb testsuite | |
20 | ||
71ea1be0 MC |
21 | if { [skip_cplus_tests] } { continue } |
22 | ||
23 | # | |
24 | # test running programs | |
25 | # | |
71ea1be0 MC |
26 | |
27 | set testfile "m-data" | |
28 | set srcfile ${testfile}.cc | |
29 | set binfile ${objdir}/${subdir}/${testfile} | |
30 | ||
31 | if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } { | |
b60f0898 JB |
32 | untested m-data.exp |
33 | return -1 | |
71ea1be0 MC |
34 | } |
35 | ||
36 | if [get_compiler_info ${binfile} "c++"] { | |
37 | return -1 | |
38 | } | |
39 | ||
40 | gdb_exit | |
41 | gdb_start | |
42 | gdb_reinitialize_dir $srcdir/$subdir | |
43 | gdb_load ${binfile} | |
44 | ||
45 | ||
46 | if ![runto_main] then { | |
47 | perror "couldn't run to breakpoint" | |
48 | continue | |
49 | } | |
50 | ||
a23b6e6a DC |
51 | # First, run to after we've constructed all the gnu_obj_N's: |
52 | ||
53 | gdb_breakpoint [gdb_get_line_number "first-constructs-done"] | |
54 | gdb_continue_to_breakpoint "end of first constructors" | |
55 | ||
71ea1be0 | 56 | # One. |
71ea1be0 MC |
57 | |
58 | # simple object, const bool | |
59 | gdb_test "print test1.test" "\\$\[0-9\]* = true" "simple object, const bool" | |
60 | ||
61 | # simple object, const int | |
62 | gdb_test "print test1.key1" "\\$\[0-9\]* = 5" "simple object, const int" | |
63 | ||
64 | # simple object, long | |
65 | gdb_test "print test1.key2" "\\$\[0-9\]* = 4589" "simple object, long" | |
66 | ||
67 | # simple object, enum | |
68 | gdb_test "print test1.value" "\\$\[0-9\]* = egyptian" "simple object, enum" | |
69 | ||
70 | # Two. | |
71ea1be0 MC |
71 | |
72 | # derived template object, base const bool | |
73 | gdb_test "print test2.test" "\\$\[0-9\]* = true" "derived template object, base const bool" | |
74 | ||
75 | # derived template object, base const int | |
76 | gdb_test "print test2.key1" "\\$\[0-9\]* = 5" "derived template object, base const int" | |
77 | ||
78 | # derived template object, base long | |
79 | gdb_test "print test2.key2" "\\$\[0-9\]* = 7" "derived template object, base long" | |
80 | ||
81 | # derived template object, base enum | |
82 | gdb_test "print test2.value" "\\$\[0-9\]* = oriental" "derived template object, base enum" | |
83 | ||
84 | # derived template object, enum | |
85 | gdb_test "print test2.value_derived" "\\$\[0-9\]* = roman" "derived template object, derived enum" | |
86 | ||
87 | # Three. | |
71ea1be0 MC |
88 | |
89 | # template object, derived template data member's base const bool | |
90 | gdb_test "print test3.data.test" "\\$\[0-9\]* = true" "template object, const bool" | |
91 | ||
92 | # template object, derived template data member's base const int | |
93 | gdb_test "print test3.data.key1" "\\$\[0-9\]* = 5" "template object, const int" | |
94 | ||
95 | # template object, derived template data member's base long | |
96 | gdb_test "print test3.data.key2" "\\$\[0-9\]* = 7" "template object, long" | |
97 | ||
98 | # template object, derived template data member's base enum | |
99 | gdb_test "print test3.data.value" "\\$\[0-9\]* = oriental" "template object, base enum" | |
100 | ||
101 | # template object, derived template data member's enum | |
102 | gdb_test "print test3.data.value_derived" "\\$\[0-9]\* = etruscan" "template object, derived enum" | |
103 | ||
a23b6e6a DC |
104 | # Now some tests for shadowing (see PR gdb/804): |
105 | ||
106 | gdb_breakpoint "C::marker" | |
107 | gdb_continue_to_breakpoint "continue to shadow breakpoint" | |
108 | ||
109 | gdb_test "print shadow" "\\$\[0-9]\* = 1" "shadowing member" | |
110 | gdb_test "print ::shadow" "\\$\[0-9]\* = 0" "shadowed global variable" | |
111 | ||
71ea1be0 MC |
112 | gdb_exit |
113 | return 0 |