]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.cp/mb-templates.exp
Update Copyright year range in all files maintained by GDB.
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.cp / mb-templates.exp
CommitLineData
ecd75fc8 1# Copyright 2007-2014 Free Software Foundation, Inc.
ed0616c6
VP
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
759f0f0b 19if { [skip_stl_tests] } { continue }
c3ea9a14 20
62172bb9
UW
21# On SPU this test fails because the executable exceeds local storage size.
22if { [istarget "spu*-*-*"] } {
23 return 0
24}
25
ed0616c6 26
f5f3a911 27standard_testfile .cc
ed0616c6 28
4c93b1db 29if [get_compiler_info "c++"] {
ed0616c6
VP
30 return -1
31}
32
f5f3a911
TT
33if {[prepare_for_testing $testfile.exp $testfile $srcfile {debug c++}]} {
34 return -1
ed0616c6
VP
35}
36
d6b6bbb7 37set bp_location [gdb_get_line_number "set breakpoint here"]
ed0616c6 38
d6b6bbb7
LM
39# Set a breakpoint with multiple locations
40# and a condition.
ed0616c6 41
d6b6bbb7
LM
42gdb_test "break $srcfile:$bp_location if i==1" \
43 "Breakpoint.*at.*: $srcfile:$bp_location. \\(2 locations\\).*" \
44 "initial condition: set breakpoint"
ed0616c6 45
d6b6bbb7 46gdb_run_cmd
a06715f8 47
d6b6bbb7
LM
48set test "initial condition: run to breakpoint"
49gdb_test_multiple "" $test {
50 -re "Breakpoint \[0-9\]+,.*foo<int> \\(i=1\\).*$gdb_prompt $" {
51 pass $test
52 break
ed0616c6
VP
53 }
54}
55
56gdb_test "continue" \
57 ".*Breakpoint.*foo<double> \\(i=1\\).*" \
58 "initial condition: run to breakpoint 2"
59
60# Set breakpoint with multiple locations.
61# Separately set the condition.
a06715f8
JK
62
63delete_breakpoints
64gdb_test "kill" "" "kill" \
65 {Kill the program being debugged\? \(y or n\) } "y"
ed0616c6
VP
66
67gdb_test "break $srcfile:$bp_location" \
f8eba3c6 68 "Breakpoint.*at.*: $srcfile:$bp_location. \\(2 locations\\).*" \
ed0616c6
VP
69 "separate condition: set breakpoint"
70
a06715f8 71gdb_test_no_output {condition $bpnum i==1} \
ed0616c6
VP
72 "separate condition: set condition"
73
74gdb_run_cmd
75gdb_expect {
76 -re "Breakpoint \[0-9\]+,.*foo<int> \\(i=1\\).*$gdb_prompt $" {
77 pass "separate condition: run to breakpoint"
78 }
79 -re "$gdb_prompt $" {
80 fail "separate condition: run to breakpoint"
81 }
82 timeout {
83 fail "separate condition: run to breakpoint (timeout)"
84 }
85}
86
87gdb_test "continue" \
88 ".*Breakpoint.*foo<double> \\(i=1\\).*" \
89 "separate condition: run to breakpoint 2"
90
91# Try disabling a single location. We also test
92# that at least in simple cases, the enable/disable
93# state of locations surive "run".
a06715f8 94gdb_test_no_output {disable $bpnum.1} "disabling location: disable"
ed0616c6
VP
95
96gdb_run_cmd
97gdb_expect {
98 -re "Breakpoint \[0-9\]+,.*foo<double> \\(i=1\\).*$gdb_prompt $" {
99 pass "disabling location: run to breakpoint"
100 }
101 -re "$gdb_prompt $" {
102 fail "disabling location: run to breakpoint"
103 }
104 timeout {
105 fail "disabling location: run to breakpoint (timeout)"
106 }
107}
108
109# Try disabling entire breakpoint
a06715f8 110gdb_test_no_output {enable $bpnum.1} "disabling location: enable"
ed0616c6
VP
111
112
a06715f8 113gdb_test_no_output {disable $bpnum} "disable breakpoint: disable"
ed0616c6
VP
114
115gdb_run_cmd
116gdb_expect {
fda326dd 117 -re "$inferior_exited_re normally.*$gdb_prompt $" {
ed0616c6
VP
118 pass "disable breakpoint: run to breakpoint"
119 }
120 -re "$gdb_prompt $" {
121 fail "disable breakpoint: run to breakpoint"
122 }
123 timeout {
124 fail "disable breakpoint: run to breakpoint (timeout)"
125 }
126}
127
128# Make sure breakpoint can be set on a specific instantion.
129delete_breakpoints
130gdb_test "break 'void foo<int>(int)'" ".*" \
131 "instantiation: set breakpoint"
132
133
134gdb_run_cmd
135gdb_expect {
136 -re ".*Breakpoint \[0-9\]+,.*foo<int> \\(i=0\\).*$gdb_prompt $" {
137 pass "instantiation: run to breakpoint"
138 }
139 -re "$gdb_prompt $" {
140 fail "instantiation: run to breakpoint"
141 }
142 timeout {
143 fail "instantiation: run to breakpoint (timeout)"
144 }
145}
146
147gdb_test "continue" \
148 ".*Breakpoint.*foo<int> \\(i=1\\).*" \
149 "instantiation: run to breakpoint 2"
150
9ab4e744
DE
151
152# Make sure we can set a breakpoint on a source statement that spans
153# multiple lines.
154
155delete_breakpoints
156
157set bp_location [gdb_get_line_number "set multi-line breakpoint here"]
158
159if { ![runto_main] } {
160 fail "Can't run to main for multi_line_foo tests."
161 return 0
162}
163
164gdb_test "break $srcfile:$bp_location" \
f8eba3c6 165 "Breakpoint.*at.*: $srcfile:$bp_location. \\(2 locations\\).*" \
9ab4e744
DE
166 "set multi_line_foo breakpoint"
167gdb_test "continue" \
168 ".*Breakpoint.*multi_line_foo<int> \\(i=0\\).*" \
169 "run to multi_line_foo breakpoint 2 <int>"
170gdb_test "continue" \
171 ".*Breakpoint.*multi_line_foo<double> \\(i=0\\).*" \
172 "run to multi_line_foo breakpoint 2 <double>"