1 # Copyright 2008-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 file is part of the gdb testsuite.
18 # This test verifies that setting breakpoint on line in inline
19 # function will fire in all instantiations of that function.
21 if { [skip_cplus_tests] } { continue }
23 standard_testfile mb-inline1.cc mb-inline2.cc
24 set hdrfile "${testfile}.h"
26 if {[prepare_for_testing "failed to prepare" $testfile \
27 [list $srcfile $srcfile2] {debug c++}]} {
31 set bp_location [gdb_get_line_number "set breakpoint here" $hdrfile]
33 # Set a breakpoint with multiple locations.
35 gdb_test "break $hdrfile:$bp_location" \
36 "Breakpoint.*at.*: $hdrfile:$bp_location. \\(2 locations\\).*" \
39 # Do "info break" now so we can easily compare it with the later "info break"
41 gdb_test "info break" \
42 "\[\r\n\]1\.1.* y .* at .*$hdrfile:$bp_location.*\[\r\n\]1\.2.* y .* at .*$hdrfile:$bp_location.*"
45 gdb_test "" "Breakpoint $bkptno_num_re,.*foo \\(i=0\\).*" "run to breakpoint"
48 ".*Breakpoint.*foo \\(i=1\\).*" \
51 # Try disabling a single location. We also test
52 # that at least in simple cases, the enable/disable
53 # state of locations survive "run".
54 # Early bug would disable 1.1 and enable 1.2 when program is run.
55 gdb_test_no_output "disable 1.2" "disabling location: disable"
58 gdb_test "" "Breakpoint $bkptno_num_re,.*foo \\(i=0\\).*" "disabling location: run to breakpoint"
60 gdb_test_multiple "info break" "disabled breakpoint 1.2" {
61 -re "1\.2.* n .* at .*$hdrfile:$bp_location.*$gdb_prompt $" {
62 pass "disabled breakpoint 1.2"
64 -re "1\.2.* y .* at .*$hdrfile:$bp_location.*$gdb_prompt $" {
65 # When inferior is restarted, breakpoint locations will be updated.
66 # On uclinux, it is not guaranteed that new inferior is located the
67 # same address as previous one, so status/state of breakpoint location
68 # will loose. The heuristic of GDB should be improved.
69 setup_kfail gdb/12924 "*-*-uclinux*"
70 fail "disabled breakpoint 1.2"
74 # Make sure we can set a breakpoint on a source statement that spans
79 set bp_location [gdb_get_line_number "set multi-line breakpoint here" $hdrfile]
81 if { ![runto_main] } {
85 gdb_test "break $hdrfile:$bp_location" \
86 "Breakpoint.*at.*: $hdrfile:$bp_location. \\(2 locations\\).*" \
87 "set multi_line_foo breakpoint"
89 ".*Breakpoint.*multi_line_foo \\(i=0\\).*" \
90 "run to multi_line_foo breakpoint 4 afn"
92 ".*Breakpoint.*multi_line_foo \\(i=1\\).*" \
93 "run to multi_line_foo breakpoint 4 bfn"