]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.cp/mb-inline.exp
Update copyright year range in header of all files managed by GDB
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.cp / mb-inline.exp
1 # Copyright 2008-2024 Free Software Foundation, Inc.
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 file is part of the gdb testsuite.
17
18 # This test verifies that setting breakpoint on line in inline
19 # function will fire in all instantiations of that function.
20
21 require allow_cplus_tests
22
23 standard_testfile mb-inline1.cc mb-inline2.cc
24 set hdrfile "${testfile}.h"
25 include_file $hdrfile
26
27 if {[prepare_for_testing "failed to prepare" $testfile \
28 [list $srcfile $srcfile2] {debug c++}]} {
29 return -1
30 }
31
32 set bp_location [gdb_get_line_number "set breakpoint here" $hdrfile]
33
34 # Set a breakpoint with multiple locations.
35
36 gdb_test "break $hdrfile:$bp_location" \
37 "Breakpoint.*at.*: $hdrfile:$bp_location. \\(2 locations\\).*" \
38 "set breakpoint"
39
40 # Do "info break" now so we can easily compare it with the later "info break"
41 # if problems arise.
42 gdb_test "info break" \
43 "\[\r\n\]1\.1.* y .* at .*$hdrfile:$bp_location.*\[\r\n\]1\.2.* y .* at .*$hdrfile:$bp_location.*"
44
45 gdb_run_cmd
46 gdb_test "" "Breakpoint $bkptno_num_re,.*foo \\(i=0\\).*" "run to breakpoint"
47
48 gdb_test "continue" \
49 ".*Breakpoint.*foo \\(i=1\\).*" \
50 "run to breakpoint 2"
51
52 # Try disabling a single location. We also test
53 # that at least in simple cases, the enable/disable
54 # state of locations survive "run".
55 # Early bug would disable 1.1 and enable 1.2 when program is run.
56 gdb_test_no_output "disable 1.2" "disabling location: disable"
57
58 gdb_run_cmd
59 gdb_test "" "Breakpoint $bkptno_num_re,.*foo \\(i=0\\).*" "disabling location: run to breakpoint"
60
61 gdb_test_multiple "info break" "disabled breakpoint 1.2" {
62 -re "1\.2.* n .* at .*$hdrfile:$bp_location.*$gdb_prompt $" {
63 pass "disabled breakpoint 1.2"
64 }
65 -re "1\.2.* y .* at .*$hdrfile:$bp_location.*$gdb_prompt $" {
66 # When inferior is restarted, breakpoint locations will be updated.
67 # On uclinux, it is not guaranteed that new inferior is located the
68 # same address as previous one, so status/state of breakpoint location
69 # will loose. The heuristic of GDB should be improved.
70 setup_kfail gdb/12924 "*-*-uclinux*"
71 fail "disabled breakpoint 1.2"
72 }
73 }
74
75 # Make sure we can set a breakpoint on a source statement that spans
76 # multiple lines.
77
78 delete_breakpoints
79
80 set bp_location [gdb_get_line_number "set multi-line breakpoint here" $hdrfile]
81
82 if { ![runto_main] } {
83 return 0
84 }
85
86 gdb_test "break $hdrfile:$bp_location" \
87 "Breakpoint.*at.*: $hdrfile:$bp_location. \\(2 locations\\).*" \
88 "set multi_line_foo breakpoint"
89 gdb_test "continue" \
90 ".*Breakpoint.*multi_line_foo \\(i=0\\).*" \
91 "run to multi_line_foo breakpoint 4 afn"
92 gdb_test "continue" \
93 ".*Breakpoint.*multi_line_foo \\(i=1\\).*" \
94 "run to multi_line_foo breakpoint 4 bfn"