* lib/gdb.exp (skip_altivec_tests, skip_vsx_tests)
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.cp / mb-templates.exp
1 # Copyright 2007-2012 Free Software Foundation, Inc.
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
5 # the Free Software Foundation; either version 3 of the License, or
6 # (at your option) any later version.
7 #
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.
12 #
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/>.
15
16 # This test verifies that setting breakpoint on line in template
17 # function will fire in all instantiations of that template.
18
19 if { [skip_stl_tests] } { continue }
20
21 # On SPU this test fails because the executable exceeds local storage size.
22 if { [istarget "spu*-*-*"] } {
23 return 0
24 }
25
26
27 set testfile "mb-templates"
28 set srcfile ${testfile}.cc
29 set executable ${testfile}
30 set binfile ${objdir}/${subdir}/${executable}
31
32 if [get_compiler_info "c++"] {
33 return -1
34 }
35
36 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } {
37 untested mb-templates.exp
38 return -1
39 }
40
41 clean_restart ${executable}
42
43 set bp_location [gdb_get_line_number "set breakpoint here"]
44
45 # Set a breakpoint with multiple locations
46 # and a condition.
47
48 gdb_test "break $srcfile:$bp_location if i==1" \
49 "Breakpoint.*at.*: $srcfile:$bp_location. \\(2 locations\\).*" \
50 "initial condition: set breakpoint"
51
52 gdb_run_cmd
53
54 set test "initial condition: run to breakpoint"
55 gdb_test_multiple "" $test {
56 -re "Breakpoint \[0-9\]+,.*foo<int> \\(i=1\\).*$gdb_prompt $" {
57 pass $test
58 break
59 }
60 }
61
62 gdb_test "continue" \
63 ".*Breakpoint.*foo<double> \\(i=1\\).*" \
64 "initial condition: run to breakpoint 2"
65
66 # Set breakpoint with multiple locations.
67 # Separately set the condition.
68
69 delete_breakpoints
70 gdb_test "kill" "" "kill" \
71 {Kill the program being debugged\? \(y or n\) } "y"
72
73 gdb_test "break $srcfile:$bp_location" \
74 "Breakpoint.*at.*: $srcfile:$bp_location. \\(2 locations\\).*" \
75 "separate condition: set breakpoint"
76
77 gdb_test_no_output {condition $bpnum i==1} \
78 "separate condition: set condition"
79
80 gdb_run_cmd
81 gdb_expect {
82 -re "Breakpoint \[0-9\]+,.*foo<int> \\(i=1\\).*$gdb_prompt $" {
83 pass "separate condition: run to breakpoint"
84 }
85 -re "$gdb_prompt $" {
86 fail "separate condition: run to breakpoint"
87 }
88 timeout {
89 fail "separate condition: run to breakpoint (timeout)"
90 }
91 }
92
93 gdb_test "continue" \
94 ".*Breakpoint.*foo<double> \\(i=1\\).*" \
95 "separate condition: run to breakpoint 2"
96
97 # Try disabling a single location. We also test
98 # that at least in simple cases, the enable/disable
99 # state of locations surive "run".
100 gdb_test_no_output {disable $bpnum.1} "disabling location: disable"
101
102 gdb_run_cmd
103 gdb_expect {
104 -re "Breakpoint \[0-9\]+,.*foo<double> \\(i=1\\).*$gdb_prompt $" {
105 pass "disabling location: run to breakpoint"
106 }
107 -re "$gdb_prompt $" {
108 fail "disabling location: run to breakpoint"
109 }
110 timeout {
111 fail "disabling location: run to breakpoint (timeout)"
112 }
113 }
114
115 # Try disabling entire breakpoint
116 gdb_test_no_output {enable $bpnum.1} "disabling location: enable"
117
118
119 gdb_test_no_output {disable $bpnum} "disable breakpoint: disable"
120
121 gdb_run_cmd
122 gdb_expect {
123 -re "$inferior_exited_re normally.*$gdb_prompt $" {
124 pass "disable breakpoint: run to breakpoint"
125 }
126 -re "$gdb_prompt $" {
127 fail "disable breakpoint: run to breakpoint"
128 }
129 timeout {
130 fail "disable breakpoint: run to breakpoint (timeout)"
131 }
132 }
133
134 # Make sure breakpoint can be set on a specific instantion.
135 delete_breakpoints
136 gdb_test "break 'void foo<int>(int)'" ".*" \
137 "instantiation: set breakpoint"
138
139
140 gdb_run_cmd
141 gdb_expect {
142 -re ".*Breakpoint \[0-9\]+,.*foo<int> \\(i=0\\).*$gdb_prompt $" {
143 pass "instantiation: run to breakpoint"
144 }
145 -re "$gdb_prompt $" {
146 fail "instantiation: run to breakpoint"
147 }
148 timeout {
149 fail "instantiation: run to breakpoint (timeout)"
150 }
151 }
152
153 gdb_test "continue" \
154 ".*Breakpoint.*foo<int> \\(i=1\\).*" \
155 "instantiation: run to breakpoint 2"
156
157
158 # Make sure we can set a breakpoint on a source statement that spans
159 # multiple lines.
160
161 delete_breakpoints
162
163 set bp_location [gdb_get_line_number "set multi-line breakpoint here"]
164
165 if { ![runto_main] } {
166 fail "Can't run to main for multi_line_foo tests."
167 return 0
168 }
169
170 gdb_test "break $srcfile:$bp_location" \
171 "Breakpoint.*at.*: $srcfile:$bp_location. \\(2 locations\\).*" \
172 "set multi_line_foo breakpoint"
173 gdb_test "continue" \
174 ".*Breakpoint.*multi_line_foo<int> \\(i=0\\).*" \
175 "run to multi_line_foo breakpoint 2 <int>"
176 gdb_test "continue" \
177 ".*Breakpoint.*multi_line_foo<double> \\(i=0\\).*" \
178 "run to multi_line_foo breakpoint 2 <double>"
This page took 0.035368 seconds and 5 git commands to generate.