2 # Free Software Foundation, Inc.
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 3 of the License, or
7 # (at your option) any later version.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
17 # This test verifies that setting breakpoint on line in template
18 # function will fire in all instantiations of that template.
24 if { [skip_cplus_tests] } { continue }
29 set testfile "mb-templates"
30 set srcfile ${testfile}.cc
31 set binfile ${objdir}/${subdir}/${testfile}
33 if [get_compiler_info ${binfile} "c++"] {
37 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } {
38 untested mb-templates.exp
44 gdb_reinitialize_dir $srcdir/$subdir
47 set bp_location [gdb_get_line_number "set breakpoint here"]
49 # Set a breakpoint with multiple locations
52 gdb_test "break $srcfile:$bp_location if i==1" \
53 "Breakpoint.*at.* file .*$srcfile, line.*\\(2 locations\\).*" \
54 "initial condition: set breakpoint"
58 -re "Breakpoint \[0-9\]+,.*foo<int> \\(i=1\\).*$gdb_prompt $" {
59 pass "initial condition: run to breakpoint"
62 fail "initial condition: run to breakpoint"
65 fail "initial condition: run to breakpoint (timeout)"
70 ".*Breakpoint.*foo<double> \\(i=1\\).*" \
71 "initial condition: run to breakpoint 2"
73 # Set breakpoint with multiple locations.
74 # Separately set the condition.
77 gdb_reinitialize_dir $srcdir/$subdir
80 gdb_test "break $srcfile:$bp_location" \
81 "Breakpoint.*at.* file .*$srcfile, line.*\\(2 locations\\).*" \
82 "separate condition: set breakpoint"
84 gdb_test "condition 1 i==1" "" \
85 "separate condition: set condition"
89 -re "Breakpoint \[0-9\]+,.*foo<int> \\(i=1\\).*$gdb_prompt $" {
90 pass "separate condition: run to breakpoint"
93 fail "separate condition: run to breakpoint"
96 fail "separate condition: run to breakpoint (timeout)"
100 gdb_test "continue" \
101 ".*Breakpoint.*foo<double> \\(i=1\\).*" \
102 "separate condition: run to breakpoint 2"
104 # Try disabling a single location. We also test
105 # that at least in simple cases, the enable/disable
106 # state of locations surive "run".
107 gdb_test "disable 1.1" "" "disabling location: disable"
111 -re "Breakpoint \[0-9\]+,.*foo<double> \\(i=1\\).*$gdb_prompt $" {
112 pass "disabling location: run to breakpoint"
114 -re "$gdb_prompt $" {
115 fail "disabling location: run to breakpoint"
118 fail "disabling location: run to breakpoint (timeout)"
122 # Try disabling entire breakpoint
123 gdb_test "enable 1.1" "" "disabling location: enable"
126 gdb_test "disable 1" "" "disable breakpoint: disable"
130 -re "Program exited normally.*$gdb_prompt $" {
131 pass "disable breakpoint: run to breakpoint"
133 -re "$gdb_prompt $" {
134 fail "disable breakpoint: run to breakpoint"
137 fail "disable breakpoint: run to breakpoint (timeout)"
141 # Make sure breakpoint can be set on a specific instantion.
143 gdb_test "break 'void foo<int>(int)'" ".*" \
144 "instantiation: set breakpoint"
149 -re ".*Breakpoint \[0-9\]+,.*foo<int> \\(i=0\\).*$gdb_prompt $" {
150 pass "instantiation: run to breakpoint"
152 -re "$gdb_prompt $" {
153 fail "instantiation: run to breakpoint"
156 fail "instantiation: run to breakpoint (timeout)"
160 gdb_test "continue" \
161 ".*Breakpoint.*foo<int> \\(i=1\\).*" \
162 "instantiation: run to breakpoint 2"