Automatic Copyright Year update after running gdb/copyright.py
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.cp / mb-templates.exp
CommitLineData
88b9d363 1# Copyright 2007-2022 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
ed0616c6 21
f5f3a911 22standard_testfile .cc
ed0616c6 23
4c93b1db 24if [get_compiler_info "c++"] {
ed0616c6
VP
25 return -1
26}
27
5b362f04 28if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug c++}]} {
f5f3a911 29 return -1
ed0616c6
VP
30}
31
d6b6bbb7 32set bp_location [gdb_get_line_number "set breakpoint here"]
ed0616c6 33
d6b6bbb7
LM
34# Set a breakpoint with multiple locations
35# and a condition.
ed0616c6 36
d6b6bbb7
LM
37gdb_test "break $srcfile:$bp_location if i==1" \
38 "Breakpoint.*at.*: $srcfile:$bp_location. \\(2 locations\\).*" \
39 "initial condition: set breakpoint"
ed0616c6 40
d6b6bbb7 41gdb_run_cmd
a06715f8 42
d6b6bbb7
LM
43set test "initial condition: run to breakpoint"
44gdb_test_multiple "" $test {
45 -re "Breakpoint \[0-9\]+,.*foo<int> \\(i=1\\).*$gdb_prompt $" {
46 pass $test
47 break
ed0616c6
VP
48 }
49}
50
51gdb_test "continue" \
52 ".*Breakpoint.*foo<double> \\(i=1\\).*" \
53 "initial condition: run to breakpoint 2"
54
55# Set breakpoint with multiple locations.
56# Separately set the condition.
a06715f8
JK
57
58delete_breakpoints
59gdb_test "kill" "" "kill" \
60 {Kill the program being debugged\? \(y or n\) } "y"
ed0616c6
VP
61
62gdb_test "break $srcfile:$bp_location" \
f8eba3c6 63 "Breakpoint.*at.*: $srcfile:$bp_location. \\(2 locations\\).*" \
ed0616c6
VP
64 "separate condition: set breakpoint"
65
a06715f8 66gdb_test_no_output {condition $bpnum i==1} \
ed0616c6
VP
67 "separate condition: set condition"
68
69gdb_run_cmd
fa43b1d7 70gdb_test "" "Breakpoint \[0-9\]+,.*foo<int> \\(i=1\\).*" "separate condition: run to breakpoint"
ed0616c6
VP
71
72gdb_test "continue" \
73 ".*Breakpoint.*foo<double> \\(i=1\\).*" \
74 "separate condition: run to breakpoint 2"
75
76# Try disabling a single location. We also test
77# that at least in simple cases, the enable/disable
78# state of locations surive "run".
a06715f8 79gdb_test_no_output {disable $bpnum.1} "disabling location: disable"
ed0616c6
VP
80
81gdb_run_cmd
fa43b1d7 82gdb_test "" "Breakpoint \[0-9\]+,.*foo<double> \\(i=1\\).*" "disabling location: run to breakpoint"
ed0616c6
VP
83
84# Try disabling entire breakpoint
a06715f8 85gdb_test_no_output {enable $bpnum.1} "disabling location: enable"
ed0616c6
VP
86
87
a06715f8 88gdb_test_no_output {disable $bpnum} "disable breakpoint: disable"
ed0616c6
VP
89
90gdb_run_cmd
fa43b1d7 91gdb_test "" "$inferior_exited_re normally.*" "disable breakpoint: run to breakpoint"
ed0616c6
VP
92
93# Make sure breakpoint can be set on a specific instantion.
94delete_breakpoints
95gdb_test "break 'void foo<int>(int)'" ".*" \
96 "instantiation: set breakpoint"
97
98
99gdb_run_cmd
fa43b1d7 100gdb_test "" "Breakpoint \[0-9\]+,.*foo<int> \\(i=0\\).*" "instantiation: run to breakpoint"
ed0616c6
VP
101
102gdb_test "continue" \
103 ".*Breakpoint.*foo<int> \\(i=1\\).*" \
104 "instantiation: run to breakpoint 2"
105
9ab4e744
DE
106
107# Make sure we can set a breakpoint on a source statement that spans
108# multiple lines.
109
110delete_breakpoints
111
112set bp_location [gdb_get_line_number "set multi-line breakpoint here"]
113
114if { ![runto_main] } {
bc6c7af4 115 fail "can't run to main for multi_line_foo tests."
9ab4e744
DE
116 return 0
117}
118
119gdb_test "break $srcfile:$bp_location" \
f8eba3c6 120 "Breakpoint.*at.*: $srcfile:$bp_location. \\(2 locations\\).*" \
9ab4e744
DE
121 "set multi_line_foo breakpoint"
122gdb_test "continue" \
123 ".*Breakpoint.*multi_line_foo<int> \\(i=0\\).*" \
124 "run to multi_line_foo breakpoint 2 <int>"
125gdb_test "continue" \
126 ".*Breakpoint.*multi_line_foo<double> \\(i=0\\).*" \
127 "run to multi_line_foo breakpoint 2 <double>"
This page took 1.847263 seconds and 4 git commands to generate.