Update copyright year range in header of all files managed by GDB
[binutils-gdb.git] / gdb / testsuite / gdb.cp / mb-templates.exp
blobd4e7d3925ba8681df84f425befad4aab79bcec1d
1 # Copyright 2007-2023 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.
19 if { [skip_stl_tests] } { continue }
22 standard_testfile .cc
24 if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug c++}]} {
25     return -1
28 set bp_location [gdb_get_line_number "set breakpoint here"]
30 # Set a breakpoint with multiple locations
31 # and a condition.
33 gdb_test "break $srcfile:$bp_location if i==1" \
34     "Breakpoint.*at.*: $srcfile:$bp_location. \\(2 locations\\).*" \
35     "initial condition: set breakpoint"
37 gdb_run_cmd
39 set test "initial condition: run to breakpoint"
40 gdb_test_multiple "" $test {
41     -re "Breakpoint $bkptno_num_re,.*foo<int> \\(i=1\\).*$gdb_prompt $" {
42         pass $test
43         break
44     }
47 gdb_test "continue" \
48     ".*Breakpoint.*foo<double> \\(i=1\\).*" \
49     "initial condition: run to breakpoint 2"
51 # Set breakpoint with multiple locations.
52 # Separately set the condition.
54 delete_breakpoints
55 gdb_test "kill" "" "kill" \
56          {Kill the program being debugged\? \(y or n\) } "y"
58 gdb_test "break $srcfile:$bp_location" \
59     "Breakpoint.*at.*: $srcfile:$bp_location. \\(2 locations\\).*" \
60     "separate condition: set breakpoint"
62 gdb_test_no_output {condition $bpnum i==1} \
63     "separate condition: set condition"
64     
65 gdb_run_cmd
66 gdb_test "" "Breakpoint $bkptno_num_re,.*foo<int> \\(i=1\\).*" "separate condition: run to breakpoint"
68 gdb_test "continue" \
69     ".*Breakpoint.*foo<double> \\(i=1\\).*" \
70     "separate condition: run to breakpoint 2"
72 # Try disabling a single location. We also test
73 # that at least in simple cases, the enable/disable
74 # state of locations surive "run".
75 gdb_test_no_output {disable $bpnum.1} "disabling location: disable"
77 gdb_run_cmd
78 gdb_test "" "Breakpoint $bkptno_num_re,.*foo<double> \\(i=1\\).*" "disabling location: run to breakpoint"
80 # Try disabling entire breakpoint
81 gdb_test_no_output {enable $bpnum.1} "disabling location: enable"
84 gdb_test_no_output {disable $bpnum} "disable breakpoint: disable"
86 gdb_run_cmd
87 gdb_test "" "$inferior_exited_re normally.*" "disable breakpoint: run to breakpoint"
89 # Make sure breakpoint can be set on a specific instantion.
90 delete_breakpoints
91 gdb_test "break 'void foo<int>(int)'" ".*" \
92     "instantiation: set breakpoint"
95 gdb_run_cmd
96 gdb_test "" "Breakpoint \[0-9\]+,.*foo<int> \\(i=0\\).*" "instantiation: run to breakpoint"
98 gdb_test "continue" \
99     ".*Breakpoint.*foo<int> \\(i=1\\).*" \
100     "instantiation: run to breakpoint 2"
103 # Make sure we can set a breakpoint on a source statement that spans
104 # multiple lines.
106 delete_breakpoints
108 set bp_location [gdb_get_line_number "set multi-line breakpoint here"]
110 if { ![runto_main] } {
111     return 0
114 gdb_test "break $srcfile:$bp_location" \
115     "Breakpoint.*at.*: $srcfile:$bp_location. \\(2 locations\\).*" \
116     "set multi_line_foo breakpoint"
117 gdb_test "continue" \
118     ".*Breakpoint.*multi_line_foo<int> \\(i=0\\).*" \
119     "run to multi_line_foo breakpoint 2 <int>"
120 gdb_test "continue" \
121     ".*Breakpoint.*multi_line_foo<double> \\(i=0\\).*" \
122     "run to multi_line_foo breakpoint 2 <double>"