1 # Copyright 2007, 2008 Free Software Foundation, Inc.
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.
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.
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/>.
16 # This test verifies that setting breakpoint on line in template
17 # function will fire in all instantiations of that template.
23 if { [skip_cplus_tests] } { continue }
28 set testfile "mb-templates"
29 set srcfile ${testfile}.cc
30 set binfile ${objdir}/${subdir}/${testfile}
32 if [get_compiler_info ${binfile} "c++"] {
36 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } {
37 untested mb-templates.exp
43 gdb_reinitialize_dir $srcdir/$subdir
46 set bp_location [gdb_get_line_number "set breakpoint here"]
48 # Set a breakpoint with multiple locations
51 gdb_test "break $srcfile:$bp_location if i==1" \
52 "Breakpoint.*at.* file .*$srcfile, line.*\\(2 locations\\).*" \
53 "initial condition: set breakpoint"
57 -re "Breakpoint \[0-9\]+,.*foo<int> \\(i=1\\).*$gdb_prompt $" {
58 pass "initial condition: run to breakpoint"
61 fail "initial condition: run to breakpoint"
64 fail "initial condition: run to breakpoint (timeout)"
69 ".*Breakpoint.*foo<double> \\(i=1\\).*" \
70 "initial condition: run to breakpoint 2"
72 # Set breakpoint with multiple locations.
73 # Separately set the condition.
76 gdb_reinitialize_dir $srcdir/$subdir
79 gdb_test "break $srcfile:$bp_location" \
80 "Breakpoint.*at.* file .*$srcfile, line.*\\(2 locations\\).*" \
81 "separate condition: set breakpoint"
83 gdb_test "condition 1 i==1" "" \
84 "separate condition: set condition"
88 -re "Breakpoint \[0-9\]+,.*foo<int> \\(i=1\\).*$gdb_prompt $" {
89 pass "separate condition: run to breakpoint"
92 fail "separate condition: run to breakpoint"
95 fail "separate condition: run to breakpoint (timeout)"
100 ".*Breakpoint.*foo<double> \\(i=1\\).*" \
101 "separate condition: run to breakpoint 2"
103 # Try disabling a single location. We also test
104 # that at least in simple cases, the enable/disable
105 # state of locations surive "run".
106 gdb_test "disable 1.1" "" "disabling location: disable"
110 -re "Breakpoint \[0-9\]+,.*foo<double> \\(i=1\\).*$gdb_prompt $" {
111 pass "disabling location: run to breakpoint"
113 -re "$gdb_prompt $" {
114 fail "disabling location: run to breakpoint"
117 fail "disabling location: run to breakpoint (timeout)"
121 # Try disabling entire breakpoint
122 gdb_test "enable 1.1" "" "disabling location: enable"
125 gdb_test "disable 1" "" "disable breakpoint: disable"
129 -re "Program exited normally.*$gdb_prompt $" {
130 pass "disable breakpoint: run to breakpoint"
132 -re "$gdb_prompt $" {
133 fail "disable breakpoint: run to breakpoint"
136 fail "disable breakpoint: run to breakpoint (timeout)"
140 # Make sure breakpoint can be set on a specific instantion.
142 gdb_test "break 'void foo<int>(int)'" ".*" \
143 "instantiation: set breakpoint"
148 -re ".*Breakpoint \[0-9\]+,.*foo<int> \\(i=0\\).*$gdb_prompt $" {
149 pass "instantiation: run to breakpoint"
151 -re "$gdb_prompt $" {
152 fail "instantiation: run to breakpoint"
155 fail "instantiation: run to breakpoint (timeout)"
159 gdb_test "continue" \
160 ".*Breakpoint.*foo<int> \\(i=1\\).*" \
161 "instantiation: run to breakpoint 2"